agent-skill-manager 2.13.0 → 2.15.0
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 +588 -714
- package/data/skill-index/Affitor_affiliate-skills.json +2375 -323
- package/data/skill-index/AvdLee_Core-Data-Agent-Skill.json +44 -6
- package/data/skill-index/AvdLee_Swift-Concurrency-Agent-Skill.json +49 -11
- package/data/skill-index/AvdLee_Swift-Testing-Agent-Skill.json +44 -6
- package/data/skill-index/AvdLee_SwiftUI-Agent-Skill.json +100 -24
- package/data/skill-index/AvdLee_Xcode-Build-Optimization-Agent-Skill.json +262 -34
- package/data/skill-index/Dimillian_Skills.json +699 -91
- package/data/skill-index/Egonex-AI_Understand-Anything.json +578 -81
- package/data/skill-index/Eronred_aso-skills.json +1729 -209
- package/data/skill-index/GPTomics_bioSkills.json +33358 -9410
- package/data/skill-index/Galaxy-Dawn_claude-scholar.json +1966 -256
- package/data/skill-index/Imbad0202_academic-research-skills.json +256 -98
- package/data/skill-index/K-Dense-AI_claude-scientific-skills.json +14175 -5202
- package/data/skill-index/Leonxlnx_taste-skill.json +570 -76
- package/data/skill-index/Master-cai_Research-Paper-Writing-Skills.json +44 -6
- package/data/skill-index/MiniMax-AI_skills.json +1007 -133
- package/data/skill-index/Paramchoudhary_ResumeSkills.json +1290 -114
- package/data/skill-index/ParthJadhav_app-store-screenshots.json +185 -0
- package/data/skill-index/addyosmani_agent-skills.json +1146 -222
- package/data/skill-index/affaan-m_everything-claude-code.json +18337 -5085
- package/data/skill-index/alirezarezvani_claude-skills.json +21303 -2755
- package/data/skill-index/anthropics_skills.json +1249 -161
- package/data/skill-index/antonbabenko_terraform-skill.json +44 -6
- package/data/skill-index/badlogic_pi-skills.json +349 -45
- package/data/skill-index/briiirussell_cybersecurity-skills.json +1474 -183
- package/data/skill-index/bytedance_deer-flow.json +1574 -226
- package/data/skill-index/cloudai-x_threejs-skills.json +2007 -0
- package/data/skill-index/coreyhaines31_marketingskills.json +3227 -661
- package/data/skill-index/davidondrej_skills.json +10480 -0
- package/data/skill-index/emilkowalski_skills.json +2302 -0
- package/data/skill-index/entireio_skills.json +713 -60
- package/data/skill-index/garrytan_gstack.json +3113 -509
- package/data/skill-index/github_awesome-copilot.json +31610 -8236
- package/data/skill-index/google_skills.json +17724 -921
- package/data/skill-index/heygen-com_hyperframes.json +2999 -449
- package/data/skill-index/himself65_finance-skills.json +1614 -254
- package/data/skill-index/ivan-magda_uikit-expert-skill.json +49 -11
- package/data/skill-index/kemiljk_fluid-design.json +44 -6
- package/data/skill-index/kepano_obsidian-skills.json +217 -27
- package/data/skill-index/luongnv89_asm.json +1992 -13
- package/data/skill-index/luongnv89_idd.json +1452 -0
- package/data/skill-index/luongnv89_skills.json +2832 -852
- package/data/skill-index/mattpocock_skills.json +2943 -815
- package/data/skill-index/mvanhorn_last30days-skill.json +58 -14
- package/data/skill-index/nextlevelbuilder_ui-ux-pro-max-skill.json +407 -147
- package/data/skill-index/obra_superpowers.json +653 -127
- package/data/skill-index/oliver-zehentleitner_keep-the-why.json +185 -0
- package/data/skill-index/romainsimon_paperasse.json +273 -45
- package/data/skill-index/rudrankriyam_app-store-connect-cli-skills.json +1542 -246
- package/data/skill-index/santifer_career-ops.json +61 -23
- package/data/skill-index/sickn33_antigravity-awesome-skills.json +158205 -31989
- package/data/skill-index/slavingia_skills.json +436 -56
- package/data/skill-index/twostraws_Swift-Concurrency-Agent-Skill.json +44 -6
- package/data/skill-index/twostraws_Swift-Testing-Agent-Skill.json +44 -6
- package/data/skill-index/twostraws_SwiftData-Agent-Skill.json +44 -6
- package/data/skill-index/twostraws_SwiftUI-Agent-Skill.json +44 -6
- package/data/skill-index/warpdotdev_oz-skills.json +651 -81
- package/data/skill-index/zarazhangrui_follow-builders.json +44 -6
- package/data/skill-index-resources.json +57 -3
- package/dist/agent-skill-manager.js +803 -613
- package/dist/chunk-BQ4RW237.js +20 -0
- package/dist/chunk-LH2C3PE7.js +3 -0
- package/dist/chunk-LS24FFOX.js +3 -0
- package/dist/chunk-RSVWCEZR.js +2 -0
- package/dist/config-AZYQEQOQ.js +2 -0
- package/dist/devtools-2L45W5A2.js +11 -0
- package/dist/lock-NN2MADX7.js +2 -0
- package/dist/src-BD3KFE5H.js +119 -0
- package/package.json +48 -22
- package/dist/chunk-7BMOBFGJ.js +0 -2
- package/dist/chunk-APSM2WG3.js +0 -3
- package/dist/chunk-GHPE6SB3.js +0 -3
- package/dist/chunk-HY3VQ3SV.js +0 -19
- package/dist/config-FRM3YOMA.js +0 -2
- package/dist/devtools-6JCLZ364.js +0 -8
- package/dist/lock-6S53S4SC.js +0 -2
- package/dist/src-3UQIRSQN.js +0 -108
|
@@ -1,296 +1,220 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __asmCreateRequire } from 'node:module'; const require = __asmCreateRequire(import.meta.url);
|
|
3
|
-
import{a as
|
|
4
|
-
`)}};
|
|
5
|
-
`)?
|
|
3
|
+
import{a as Nl,b as di,c as Tl,d as Be,e as vt,f as Ol,g as Ml,h as Dl}from"./chunk-LH2C3PE7.js";import{A as $l,B as U,D as H,E as Cl,F as li,G as Ll,H as Al,I as en,J as qe,K as ci,L as Rl,M as tn,N as ui,O as _l,P as Fl,Q as jl,R as fi,S as ql,T as pi,U as Bl,W as Ul,X as Vl,Y as Kl,a as je,b as J,c as tt,d as Gt,e as W,f as de,g as Yr,h as Ht,i as Jt,j as hl,k as kt,l,m as gl,n as zr,o as yl,p as ri,q as Xr,r as Qr,s as bl,t as wl,u as ni,v as kl,w as vl,x as Sl}from"./chunk-BQ4RW237.js";import{a as xl,b as A,c as oi,d as ai,e as Wt,f as El,g as Zr,h as Yt,j as Me,k as st,l as Pl,o as se,p as j,q as Il}from"./chunk-LS24FFOX.js";import{a as ii,b as N,d as ml}from"./chunk-RSVWCEZR.js";var B=N(ae=>{"use strict";var sn=Symbol.for("yaml.alias"),Gl=Symbol.for("yaml.document"),hi=Symbol.for("yaml.map"),Hl=Symbol.for("yaml.pair"),rn=Symbol.for("yaml.scalar"),gi=Symbol.for("yaml.seq"),De=Symbol.for("yaml.node.type"),Ph=e=>!!e&&typeof e=="object"&&e[De]===sn,Ih=e=>!!e&&typeof e=="object"&&e[De]===Gl,Ch=e=>!!e&&typeof e=="object"&&e[De]===hi,Lh=e=>!!e&&typeof e=="object"&&e[De]===Hl,Jl=e=>!!e&&typeof e=="object"&&e[De]===rn,Ah=e=>!!e&&typeof e=="object"&&e[De]===gi;function Wl(e){if(e&&typeof e=="object")switch(e[De]){case hi:case gi:return!0}return!1}function Rh(e){if(e&&typeof e=="object")switch(e[De]){case sn:case hi:case rn:case gi:return!0}return!1}var Nh=e=>(Jl(e)||Wl(e))&&!!e.anchor;ae.ALIAS=sn;ae.DOC=Gl;ae.MAP=hi;ae.NODE_TYPE=De;ae.PAIR=Hl;ae.SCALAR=rn;ae.SEQ=gi;ae.hasAnchor=Nh;ae.isAlias=Ph;ae.isCollection=Wl;ae.isDocument=Ih;ae.isMap=Ch;ae.isNode=Rh;ae.isPair=Lh;ae.isScalar=Jl;ae.isSeq=Ah});var zt=N(nn=>{"use strict";var ie=B(),fe=Symbol("break visit"),Yl=Symbol("skip children"),Ae=Symbol("remove node");function yi(e,t){let s=zl(t);ie.isDocument(e)?St(null,e.contents,s,Object.freeze([e]))===Ae&&(e.contents=null):St(null,e,s,Object.freeze([]))}yi.BREAK=fe;yi.SKIP=Yl;yi.REMOVE=Ae;function St(e,t,s,i){let r=Xl(e,t,s,i);if(ie.isNode(r)||ie.isPair(r))return Ql(e,i,r),St(e,r,s,i);if(typeof r!="symbol"){if(ie.isCollection(t)){i=Object.freeze(i.concat(t));for(let n=0;n<t.items.length;++n){let o=St(n,t.items[n],s,i);if(typeof o=="number")n=o-1;else{if(o===fe)return fe;o===Ae&&(t.items.splice(n,1),n-=1)}}}else if(ie.isPair(t)){i=Object.freeze(i.concat(t));let n=St("key",t.key,s,i);if(n===fe)return fe;n===Ae&&(t.key=null);let o=St("value",t.value,s,i);if(o===fe)return fe;o===Ae&&(t.value=null)}}return r}async function bi(e,t){let s=zl(t);ie.isDocument(e)?await $t(null,e.contents,s,Object.freeze([e]))===Ae&&(e.contents=null):await $t(null,e,s,Object.freeze([]))}bi.BREAK=fe;bi.SKIP=Yl;bi.REMOVE=Ae;async function $t(e,t,s,i){let r=await Xl(e,t,s,i);if(ie.isNode(r)||ie.isPair(r))return Ql(e,i,r),$t(e,r,s,i);if(typeof r!="symbol"){if(ie.isCollection(t)){i=Object.freeze(i.concat(t));for(let n=0;n<t.items.length;++n){let o=await $t(n,t.items[n],s,i);if(typeof o=="number")n=o-1;else{if(o===fe)return fe;o===Ae&&(t.items.splice(n,1),n-=1)}}}else if(ie.isPair(t)){i=Object.freeze(i.concat(t));let n=await $t("key",t.key,s,i);if(n===fe)return fe;n===Ae&&(t.key=null);let o=await $t("value",t.value,s,i);if(o===fe)return fe;o===Ae&&(t.value=null)}}return r}function zl(e){return typeof e=="object"&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function Xl(e,t,s,i){if(typeof s=="function")return s(e,t,i);if(ie.isMap(t))return s.Map?.(e,t,i);if(ie.isSeq(t))return s.Seq?.(e,t,i);if(ie.isPair(t))return s.Pair?.(e,t,i);if(ie.isScalar(t))return s.Scalar?.(e,t,i);if(ie.isAlias(t))return s.Alias?.(e,t,i)}function Ql(e,t,s){let i=t[t.length-1];if(ie.isCollection(i))i.items[e]=s;else if(ie.isPair(i))e==="key"?i.key=s:i.value=s;else if(ie.isDocument(i))i.contents=s;else{let r=ie.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${r} parent`)}}nn.visit=yi;nn.visitAsync=bi});var on=N(ec=>{"use strict";var Zl=B(),Th=zt(),Oh={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Mh=e=>e.replace(/[!,[\]{}]/g,t=>Oh[t]),Xt=class e{constructor(t,s){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,s)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,s){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),r=i.shift();switch(r){case"%TAG":{if(i.length!==2&&(s(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[n,o]=i;return this.tags[n]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return s(0,"%YAML directive should contain exactly one part"),!1;let[n]=i;if(n==="1.1"||n==="1.2")return this.yaml.version=n,!0;{let o=/^\d+\.\d+$/.test(n);return s(6,`Unsupported YAML version ${n}`,o),!1}}default:return s(0,`Unknown directive ${r}`,!0),!1}}tagName(t,s){if(t==="!")return"!";if(t[0]!=="!")return s(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(s(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&s("Verbatim tags must end with a >"),o)}let[,i,r]=t.match(/^(.*!)([^!]*)$/s);r||s(`The ${t} tag has no suffix`);let n=this.tags[i];if(n)try{return n+decodeURIComponent(r)}catch(o){return s(String(o)),null}return i==="!"?t:(s(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[s,i]of Object.entries(this.tags))if(t.startsWith(i))return s+Mh(t.substring(i.length));return t[0]==="!"?t:`!<${t}>`}toString(t){let s=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],i=Object.entries(this.tags),r;if(t&&i.length>0&&Zl.isNode(t.contents)){let n={};Th.visit(t.contents,(o,a)=>{Zl.isNode(a)&&a.tag&&(n[a.tag]=!0)}),r=Object.keys(n)}else r=[];for(let[n,o]of i)n==="!!"&&o==="tag:yaml.org,2002:"||(!t||r.some(a=>a.startsWith(o)))&&s.push(`%TAG ${n} ${o}`);return s.join(`
|
|
4
|
+
`)}};Xt.defaultYaml={explicit:!1,version:"1.2"};Xt.defaultTags={"!!":"tag:yaml.org,2002:"};ec.Directives=Xt});var wi=N(Qt=>{"use strict";var tc=B(),Dh=zt();function _h(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let s=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw new Error(s)}return!0}function sc(e){let t=new Set;return Dh.visit(e,{Value(s,i){i.anchor&&t.add(i.anchor)}}),t}function ic(e,t){for(let s=1;;++s){let i=`${e}${s}`;if(!t.has(i))return i}}function Fh(e,t){let s=[],i=new Map,r=null;return{onAnchor:n=>{s.push(n),r??(r=sc(e));let o=ic(t,r);return r.add(o),o},setAnchors:()=>{for(let n of s){let o=i.get(n);if(typeof o=="object"&&o.anchor&&(tc.isScalar(o.node)||tc.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=n,a}}},sourceObjects:i}}Qt.anchorIsValid=_h;Qt.anchorNames=sc;Qt.createNodeAnchors=Fh;Qt.findNewAnchor=ic});var an=N(rc=>{"use strict";function Zt(e,t,s,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let r=0,n=i.length;r<n;++r){let o=i[r],a=Zt(e,i,String(r),o);a===void 0?delete i[r]:a!==o&&(i[r]=a)}else if(i instanceof Map)for(let r of Array.from(i.keys())){let n=i.get(r),o=Zt(e,i,r,n);o===void 0?i.delete(r):o!==n&&i.set(r,o)}else if(i instanceof Set)for(let r of Array.from(i)){let n=Zt(e,i,r,r);n===void 0?i.delete(r):n!==r&&(i.delete(r),i.add(n))}else for(let[r,n]of Object.entries(i)){let o=Zt(e,i,r,n);o===void 0?delete i[r]:o!==n&&(i[r]=o)}return e.call(t,s,i)}rc.applyReviver=Zt});var Ue=N(oc=>{"use strict";var jh=B();function nc(e,t,s){if(Array.isArray(e))return e.map((i,r)=>nc(i,String(r),s));if(e&&typeof e.toJSON=="function"){if(!s||!jh.hasAnchor(e))return e.toJSON(t,s);let i={aliasCount:0,count:1,res:void 0};s.anchors.set(e,i),s.onCreate=n=>{i.res=n,delete s.onCreate};let r=e.toJSON(t,s);return s.onCreate&&s.onCreate(r),r}return typeof e=="bigint"&&!s?.keep?Number(e):e}oc.toJS=nc});var ki=N(lc=>{"use strict";var qh=an(),ac=B(),Bh=Ue(),ln=class{constructor(t){Object.defineProperty(this,ac.NODE_TYPE,{value:t})}clone(){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(t.range=this.range.slice()),t}toJS(t,{mapAsMap:s,maxAliasCount:i,onAnchor:r,reviver:n}={}){if(!ac.isDocument(t))throw new TypeError("A document argument is required");let o={anchors:new Map,doc:t,keep:!0,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},a=Bh.toJS(this,"",o);if(typeof r=="function")for(let{count:c,res:u}of o.anchors.values())r(u,c);return typeof n=="function"?qh.applyReviver(n,{"":a},"",a):a}};lc.NodeBase=ln});var es=N(cc=>{"use strict";var Uh=wi(),Vh=zt(),xt=B(),Kh=ki(),Gh=Ue(),cn=class extends Kh.NodeBase{constructor(t){super(xt.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,s){if(s?.maxAliasCount===0)throw new ReferenceError("Alias resolution is disabled");let i;s?.aliasResolveCache?i=s.aliasResolveCache:(i=[],Vh.visit(t,{Node:(n,o)=>{(xt.isAlias(o)||xt.hasAnchor(o))&&i.push(o)}}),s&&(s.aliasResolveCache=i));let r;for(let n of i){if(n===this)break;n.anchor===this.source&&(r=n)}return r}toJSON(t,s){if(!s)return{source:this.source};let{anchors:i,doc:r,maxAliasCount:n}=s,o=this.resolve(r,s);if(!o){let c=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(c)}let a=i.get(o);if(a||(Gh.toJS(o,null,s),a=i.get(o)),a?.res===void 0){let c="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(c)}if(n>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=vi(r,o,i)),a.count*a.aliasCount>n)){let c="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(c)}return a.res}toString(t,s,i){let r=`*${this.source}`;if(t){if(Uh.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let n=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(n)}if(t.implicitKey)return`${r} `}return r}};function vi(e,t,s){if(xt.isAlias(t)){let i=t.resolve(e),r=s&&i&&s.get(i);return r?r.count*r.aliasCount:0}else if(xt.isCollection(t)){let i=0;for(let r of t.items){let n=vi(e,r,s);n>i&&(i=n)}return i}else if(xt.isPair(t)){let i=vi(e,t.key,s),r=vi(e,t.value,s);return Math.max(i,r)}return 1}cc.Alias=cn});var X=N(un=>{"use strict";var Hh=B(),Jh=ki(),Wh=Ue(),Yh=e=>!e||typeof e!="function"&&typeof e!="object",Ve=class extends Jh.NodeBase{constructor(t){super(Hh.SCALAR),this.value=t}toJSON(t,s){return s?.keep?this.value:Wh.toJS(this.value,t,s)}toString(){return String(this.value)}};Ve.BLOCK_FOLDED="BLOCK_FOLDED";Ve.BLOCK_LITERAL="BLOCK_LITERAL";Ve.PLAIN="PLAIN";Ve.QUOTE_DOUBLE="QUOTE_DOUBLE";Ve.QUOTE_SINGLE="QUOTE_SINGLE";un.Scalar=Ve;un.isScalarValue=Yh});var ts=N(dc=>{"use strict";var zh=es(),it=B(),uc=X(),Xh="tag:yaml.org,2002:";function Qh(e,t,s){if(t){let i=s.filter(n=>n.tag===t),r=i.find(n=>!n.format)??i[0];if(!r)throw new Error(`Tag ${t} not found`);return r}return s.find(i=>i.identify?.(e)&&!i.format)}function Zh(e,t,s){if(it.isDocument(e)&&(e=e.contents),it.isNode(e))return e;if(it.isPair(e)){let d=s.schema[it.MAP].createNode?.(s.schema,null,s);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:r,onTagObj:n,schema:o,sourceObjects:a}=s,c;if(i&&e&&typeof e=="object"){if(c=a.get(e),c)return c.anchor??(c.anchor=r(e)),new zh.Alias(c.anchor);c={anchor:null,node:null},a.set(e,c)}t?.startsWith("!!")&&(t=Xh+t.slice(2));let u=Qh(e,t,o.tags);if(!u){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new uc.Scalar(e);return c&&(c.node=d),d}u=e instanceof Map?o[it.MAP]:Symbol.iterator in Object(e)?o[it.SEQ]:o[it.MAP]}n&&(n(u),delete s.onTagObj);let f=u?.createNode?u.createNode(s.schema,e,s):typeof u?.nodeClass?.from=="function"?u.nodeClass.from(s.schema,e,s):new uc.Scalar(e);return t?f.tag=t:u.default||(f.tag=u.tag),c&&(c.node=f),f}dc.createNode=Zh});var $i=N(Si=>{"use strict";var eg=ts(),Re=B(),tg=ki();function dn(e,t,s){let i=s;for(let r=t.length-1;r>=0;--r){let n=t[r];if(typeof n=="number"&&Number.isInteger(n)&&n>=0){let o=[];o[n]=i,i=o}else i=new Map([[n,i]])}return eg.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:e,sourceObjects:new Map})}var fc=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,fn=class extends tg.NodeBase{constructor(t,s){super(t),Object.defineProperty(this,"schema",{value:s,configurable:!0,enumerable:!1,writable:!0})}clone(t){let s=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(s.schema=t),s.items=s.items.map(i=>Re.isNode(i)||Re.isPair(i)?i.clone(t):i),this.range&&(s.range=this.range.slice()),s}addIn(t,s){if(fc(t))this.add(s);else{let[i,...r]=t,n=this.get(i,!0);if(Re.isCollection(n))n.addIn(r,s);else if(n===void 0&&this.schema)this.set(i,dn(this.schema,r,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}deleteIn(t){let[s,...i]=t;if(i.length===0)return this.delete(s);let r=this.get(s,!0);if(Re.isCollection(r))return r.deleteIn(i);throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}getIn(t,s){let[i,...r]=t,n=this.get(i,!0);return r.length===0?!s&&Re.isScalar(n)?n.value:n:Re.isCollection(n)?n.getIn(r,s):void 0}hasAllNullValues(t){return this.items.every(s=>{if(!Re.isPair(s))return!1;let i=s.value;return i==null||t&&Re.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[s,...i]=t;if(i.length===0)return this.has(s);let r=this.get(s,!0);return Re.isCollection(r)?r.hasIn(i):!1}setIn(t,s){let[i,...r]=t;if(r.length===0)this.set(i,s);else{let n=this.get(i,!0);if(Re.isCollection(n))n.setIn(r,s);else if(n===void 0&&this.schema)this.set(i,dn(this.schema,r,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${r}`)}}};Si.Collection=fn;Si.collectionFromPath=dn;Si.isEmptyPath=fc});var ss=N(xi=>{"use strict";var sg=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function pn(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var ig=(e,t,s)=>e.endsWith(`
|
|
5
|
+
`)?pn(s,t):s.includes(`
|
|
6
6
|
`)?`
|
|
7
|
-
`+
|
|
8
|
-
`)s===
|
|
9
|
-
`&&m!==" "){let
|
|
10
|
-
`&&
|
|
11
|
-
${t}${e.slice(0,
|
|
12
|
-
${t}${e.slice(
|
|
13
|
-
`);i=t,
|
|
14
|
-
`){if(
|
|
15
|
-
|
|
16
|
-
`;s[
|
|
17
|
-
`,
|
|
18
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return
|
|
19
|
-
${s}`)+"'";return t.implicitKey?i:
|
|
7
|
+
`+pn(s,t):(e.endsWith(" ")?"":" ")+s;xi.indentComment=pn;xi.lineComment=ig;xi.stringifyComment=sg});var mc=N(is=>{"use strict";var rg="flow",mn="block",Ei="quoted";function ng(e,t,s="flow",{indentAtStart:i,lineWidth:r=80,minContentWidth:n=20,onFold:o,onOverflow:a}={}){if(!r||r<0)return e;r<n&&(n=0);let c=Math.max(1+n,1+r-t.length);if(e.length<=c)return e;let u=[],f={},d=r-t.length;typeof i=="number"&&(i>r-Math.max(2,n)?u.push(0):d=r-i);let p,m,y=!1,h=-1,g=-1,b=-1;s===mn&&(h=pc(e,h,t.length),h!==-1&&(d=h+c));for(let S;S=e[h+=1];){if(s===Ei&&S==="\\"){switch(g=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}b=h}if(S===`
|
|
8
|
+
`)s===mn&&(h=pc(e,h,t.length)),d=h+t.length+c,p=void 0;else{if(S===" "&&m&&m!==" "&&m!==`
|
|
9
|
+
`&&m!==" "){let v=e[h+1];v&&v!==" "&&v!==`
|
|
10
|
+
`&&v!==" "&&(p=h)}if(h>=d)if(p)u.push(p),d=p+c,p=void 0;else if(s===Ei){for(;m===" "||m===" ";)m=S,S=e[h+=1],y=!0;let v=h>b+1?h-2:g-1;if(f[v])return e;u.push(v),f[v]=!0,d=v+c,p=void 0}else y=!0}m=S}if(y&&a&&a(),u.length===0)return e;o&&o();let k=e.slice(0,u[0]);for(let S=0;S<u.length;++S){let v=u[S],x=u[S+1]||e.length;v===0?k=`
|
|
11
|
+
${t}${e.slice(0,x)}`:(s===Ei&&f[v]&&(k+=`${e[v]}\\`),k+=`
|
|
12
|
+
${t}${e.slice(v+1,x)}`)}return k}function pc(e,t,s){let i=t,r=t+1,n=e[r];for(;n===" "||n===" ";)if(t<r+s)n=e[++t];else{do n=e[++t];while(n&&n!==`
|
|
13
|
+
`);i=t,r=t+1,n=e[r]}return i}is.FOLD_BLOCK=mn;is.FOLD_FLOW=rg;is.FOLD_QUOTED=Ei;is.foldFlowLines=ng});var ns=N(hc=>{"use strict";var xe=X(),Ke=mc(),Ii=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Ci=e=>/^(%|---|\.\.\.)/m.test(e);function og(e,t,s){if(!t||t<0)return!1;let i=t-s,r=e.length;if(r<=i)return!1;for(let n=0,o=0;n<r;++n)if(e[n]===`
|
|
14
|
+
`){if(n-o>i)return!0;if(o=n+1,r-o<=i)return!1}return!0}function rs(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,r=t.options.doubleQuotedMinMultiLineLength,n=t.indent||(Ci(e)?" ":""),o="",a=0;for(let c=0,u=s[c];u;u=s[++c])if(u===" "&&s[c+1]==="\\"&&s[c+2]==="n"&&(o+=s.slice(a,c)+"\\ ",c+=1,a=c,u="\\"),u==="\\")switch(s[c+1]){case"u":{o+=s.slice(a,c);let f=s.substr(c+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=s.substr(c,6)}c+=5,a=c+1}break;case"n":if(i||s[c+2]==='"'||s.length<r)c+=1;else{for(o+=s.slice(a,c)+`
|
|
15
|
+
|
|
16
|
+
`;s[c+2]==="\\"&&s[c+3]==="n"&&s[c+4]!=='"';)o+=`
|
|
17
|
+
`,c+=2;o+=n,s[c+2]===" "&&(o+="\\"),c+=1,a=c+1}break;default:c+=1}return o=a?o+s.slice(a):s,i?o:Ke.foldFlowLines(o,n,Ke.FOLD_QUOTED,Ii(t,!1))}function hn(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
18
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return rs(e,t);let s=t.indent||(Ci(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
19
|
+
${s}`)+"'";return t.implicitKey?i:Ke.foldFlowLines(i,s,Ke.FOLD_FLOW,Ii(t,!1))}function Et(e,t){let{singleQuote:s}=t.options,i;if(s===!1)i=rs;else{let r=e.includes('"'),n=e.includes("'");r&&!n?i=hn:n&&!r?i=rs:i=s?hn:rs}return i(e,t)}var gn;try{gn=new RegExp(`(^|(?<!
|
|
20
20
|
))
|
|
21
21
|
+(?!
|
|
22
|
-
|$)`,"g")}catch{
|
|
22
|
+
|$)`,"g")}catch{gn=/\n+(?!\n|$)/g}function Pi({comment:e,type:t,value:s},i,r,n){let{blockQuote:o,commentString:a,lineWidth:c}=i.options;if(!o||/\n[\t ]+$/.test(s))return Et(s,i);let u=i.indent||(i.forceBlockIndent||Ci(s)?" ":""),f=o==="literal"?!0:o==="folded"||t===xe.Scalar.BLOCK_FOLDED?!1:t===xe.Scalar.BLOCK_LITERAL?!0:!og(s,c,u.length);if(!s)return f?`|
|
|
23
23
|
`:`>
|
|
24
|
-
`;let d,p;for(p=s.length;p>0;--p){let
|
|
25
|
-
`&&
|
|
26
|
-
`);y===-1?d="-":s===m||y!==m.length-1?(d="+",
|
|
27
|
-
`&&(m=m.slice(0,-1)),m=m.replace(
|
|
28
|
-
`)b=g;else break}let
|
|
29
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${
|
|
30
|
-
${
|
|
31
|
-
${
|
|
32
|
-
`)||f&&/[[\]{},]/.test(
|
|
33
|
-
`)?
|
|
34
|
-
`))return
|
|
35
|
-
${
|
|
36
|
-
${t.indent}${a}`:a}
|
|
37
|
-
${a}:`):(g=`${g}:`,p&&(g+=
|
|
38
|
-
`:"",
|
|
39
|
-
${
|
|
40
|
-
`&&
|
|
41
|
-
|
|
42
|
-
`):
|
|
43
|
-
${s.indent}`}else if(!m&&
|
|
44
|
-
`),
|
|
45
|
-
${s.indent}`)}}else(
|
|
46
|
-
`)&&(
|
|
47
|
-
${
|
|
24
|
+
`;let d,p;for(p=s.length;p>0;--p){let x=s[p-1];if(x!==`
|
|
25
|
+
`&&x!==" "&&x!==" ")break}let m=s.substring(p),y=m.indexOf(`
|
|
26
|
+
`);y===-1?d="-":s===m||y!==m.length-1?(d="+",n&&n()):d="",m&&(s=s.slice(0,-m.length),m[m.length-1]===`
|
|
27
|
+
`&&(m=m.slice(0,-1)),m=m.replace(gn,`$&${u}`));let h=!1,g,b=-1;for(g=0;g<s.length;++g){let x=s[g];if(x===" ")h=!0;else if(x===`
|
|
28
|
+
`)b=g;else break}let k=s.substring(0,b<g?b+1:g);k&&(s=s.substring(k.length),k=k.replace(/\n+/g,`$&${u}`));let v=(h?u?"2":"1":"")+d;if(e&&(v+=" "+a(e.replace(/ ?[\r\n]+/g," ")),r&&r()),!f){let x=s.replace(/\n+/g,`
|
|
29
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${u}`),I=!1,L=Ii(i,!0);o!=="folded"&&t!==xe.Scalar.BLOCK_FOLDED&&(L.onOverflow=()=>{I=!0});let E=Ke.foldFlowLines(`${k}${x}${m}`,u,Ke.FOLD_BLOCK,L);if(!I)return`>${v}
|
|
30
|
+
${u}${E}`}return s=s.replace(/\n+/g,`$&${u}`),`|${v}
|
|
31
|
+
${u}${k}${s}${m}`}function ag(e,t,s,i){let{type:r,value:n}=e,{actualString:o,implicitKey:a,indent:c,indentStep:u,inFlow:f}=t;if(a&&n.includes(`
|
|
32
|
+
`)||f&&/[[\]{},]/.test(n))return Et(n,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(n))return a||f||!n.includes(`
|
|
33
|
+
`)?Et(n,t):Pi(e,t,s,i);if(!a&&!f&&r!==xe.Scalar.PLAIN&&n.includes(`
|
|
34
|
+
`))return Pi(e,t,s,i);if(Ci(n)){if(c==="")return t.forceBlockIndent=!0,Pi(e,t,s,i);if(a&&c===u)return Et(n,t)}let d=n.replace(/\n+/g,`$&
|
|
35
|
+
${c}`);if(o){let p=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:m,tags:y}=t.doc.schema;if(y.some(p)||m?.some(p))return Et(n,t)}return a?d:Ke.foldFlowLines(d,c,Ke.FOLD_FLOW,Ii(t,!1))}function lg(e,t,s,i){let{implicitKey:r,inFlow:n}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;a!==xe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=xe.Scalar.QUOTE_DOUBLE);let c=f=>{switch(f){case xe.Scalar.BLOCK_FOLDED:case xe.Scalar.BLOCK_LITERAL:return r||n?Et(o.value,t):Pi(o,t,s,i);case xe.Scalar.QUOTE_DOUBLE:return rs(o.value,t);case xe.Scalar.QUOTE_SINGLE:return hn(o.value,t);case xe.Scalar.PLAIN:return ag(o,t,s,i);default:return null}},u=c(a);if(u===null){let{defaultKeyType:f,defaultStringType:d}=t.options,p=r&&f||d;if(u=c(p),u===null)throw new Error(`Unsupported default string type ${p}`)}return u}hc.stringifyString=lg});var os=N(yn=>{"use strict";var cg=wi(),Ge=B(),ug=ss(),dg=ns();function fg(e,t){let s=Object.assign({blockQuote:!0,commentString:ug.stringifyComment,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:"true",verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(s.collectionStyle){case"block":i=!1;break;case"flow":i=!0;break;default:i=null}return{anchors:new Set,doc:e,flowCollectionPadding:s.flowCollectionPadding?" ":"",indent:"",indentStep:typeof s.indent=="number"?" ".repeat(s.indent):" ",inFlow:i,options:s}}function pg(e,t){if(t.tag){let r=e.filter(n=>n.tag===t.tag);if(r.length>0)return r.find(n=>n.format===t.format)??r[0]}let s,i;if(Ge.isScalar(t)){i=t.value;let r=e.filter(n=>n.identify?.(i));if(r.length>1){let n=r.filter(o=>o.test);n.length>0&&(r=n)}s=r.find(n=>n.format===t.format)??r.find(n=>!n.format)}else i=t,s=e.find(r=>r.nodeClass&&i instanceof r.nodeClass);if(!s){let r=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${r} value`)}return s}function mg(e,t,{anchors:s,doc:i}){if(!i.directives)return"";let r=[],n=(Ge.isScalar(e)||Ge.isCollection(e))&&e.anchor;n&&cg.anchorIsValid(n)&&(s.add(n),r.push(`&${n}`));let o=e.tag??(t.default?null:t.tag);return o&&r.push(i.directives.tagString(o)),r.join(" ")}function hg(e,t,s,i){if(Ge.isPair(e))return e.toString(t,s,i);if(Ge.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let r,n=Ge.isNode(e)?e:t.doc.createNode(e,{onTagObj:c=>r=c});r??(r=pg(t.doc.schema.tags,n));let o=mg(n,r,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let a=typeof r.stringify=="function"?r.stringify(n,t,s,i):Ge.isScalar(n)?dg.stringifyString(n,t,s,i):n.toString(t,s,i);return o?Ge.isScalar(n)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
36
|
+
${t.indent}${a}`:a}yn.createStringifyContext=fg;yn.stringify=hg});var wc=N(bc=>{"use strict";var _e=B(),gc=X(),yc=os(),as=ss();function gg({key:e,value:t},s,i,r){let{allNullValues:n,doc:o,indent:a,indentStep:c,options:{commentString:u,indentSeq:f,simpleKeys:d}}=s,p=_e.isNode(e)&&e.comment||null;if(d){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(_e.isCollection(e)||!_e.isNode(e)&&typeof e=="object"){let L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let m=!d&&(!e||p&&t==null&&!s.inFlow||_e.isCollection(e)||(_e.isScalar(e)?e.type===gc.Scalar.BLOCK_FOLDED||e.type===gc.Scalar.BLOCK_LITERAL:typeof e=="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!m&&(d||!n),indent:a+c});let y=!1,h=!1,g=yc.stringify(e,s,()=>y=!0,()=>h=!0);if(!m&&!s.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(s.inFlow){if(n||t==null)return y&&i&&i(),g===""?"?":m?`? ${g}`:g}else if(n&&!d||t==null&&m)return g=`? ${g}`,p&&!y?g+=as.lineComment(g,s.indent,u(p)):h&&r&&r(),g;y&&(p=null),m?(p&&(g+=as.lineComment(g,s.indent,u(p))),g=`? ${g}
|
|
37
|
+
${a}:`):(g=`${g}:`,p&&(g+=as.lineComment(g,s.indent,u(p))));let b,k,S;_e.isNode(t)?(b=!!t.spaceBefore,k=t.commentBefore,S=t.comment):(b=!1,k=null,S=null,t&&typeof t=="object"&&(t=o.createNode(t))),s.implicitKey=!1,!m&&!p&&_e.isScalar(t)&&(s.indentAtStart=g.length+1),h=!1,!f&&c.length>=2&&!s.inFlow&&!m&&_e.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(s.indent=s.indent.substring(2));let v=!1,x=yc.stringify(t,s,()=>v=!0,()=>h=!0),I=" ";if(p||b||k){if(I=b?`
|
|
38
|
+
`:"",k){let L=u(k);I+=`
|
|
39
|
+
${as.indentComment(L,s.indent)}`}x===""&&!s.inFlow?I===`
|
|
40
|
+
`&&S&&(I=`
|
|
41
|
+
|
|
42
|
+
`):I+=`
|
|
43
|
+
${s.indent}`}else if(!m&&_e.isCollection(t)){let L=x[0],E=x.indexOf(`
|
|
44
|
+
`),F=E!==-1,O=s.inFlow??t.flow??t.items.length===0;if(F||!O){let w=!1;if(F&&(L==="&"||L==="!")){let P=x.indexOf(" ");L==="&"&&P!==-1&&P<E&&x[P+1]==="!"&&(P=x.indexOf(" ",P+1)),(P===-1||E<P)&&(w=!0)}w||(I=`
|
|
45
|
+
${s.indent}`)}}else(x===""||x[0]===`
|
|
46
|
+
`)&&(I="");return g+=I+x,s.inFlow?v&&i&&i():S&&!v?g+=as.lineComment(g,s.indent,u(S)):h&&r&&r(),g}bc.stringifyPair=gg});var wn=N(bn=>{"use strict";var kc=ii("process");function yg(e,...t){e==="debug"&&console.log(...t)}function bg(e,t){(e==="debug"||e==="warn")&&(typeof kc.emitWarning=="function"?kc.emitWarning(t):console.warn(t))}bn.debug=yg;bn.warn=bg});var Ti=N(Ni=>{"use strict";var Ri=B(),vc=X(),Li="<<",Ai={identify:e=>e===Li||typeof e=="symbol"&&e.description===Li,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new vc.Scalar(Symbol(Li)),{addToJSMap:Sc}),stringify:()=>Li},wg=(e,t)=>(Ai.identify(t)||Ri.isScalar(t)&&(!t.type||t.type===vc.Scalar.PLAIN)&&Ai.identify(t.value))&&e?.doc.schema.tags.some(s=>s.tag===Ai.tag&&s.default);function Sc(e,t,s){let i=$c(e,s);if(Ri.isSeq(i))for(let r of i.items)kn(e,t,r);else if(Array.isArray(i))for(let r of i)kn(e,t,r);else kn(e,t,i)}function kn(e,t,s){let i=$c(e,s);if(!Ri.isMap(i))throw new Error("Merge sources must be maps or map aliases");let r=i.toJSON(null,e,Map);for(let[n,o]of r)t instanceof Map?t.has(n)||t.set(n,o):t instanceof Set?t.add(n):Object.prototype.hasOwnProperty.call(t,n)||Object.defineProperty(t,n,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}function $c(e,t){return e&&Ri.isAlias(t)?t.resolve(e.doc,e):t}Ni.addMergeToJSMap=Sc;Ni.isMergeKey=wg;Ni.merge=Ai});var Sn=N(Pc=>{"use strict";var kg=wn(),xc=Ti(),vg=os(),Ec=B(),vn=Ue();function Sg(e,t,{key:s,value:i}){if(Ec.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,i);else if(xc.isMergeKey(e,s))xc.addMergeToJSMap(e,t,i);else{let r=vn.toJS(s,"",e);if(t instanceof Map)t.set(r,vn.toJS(i,r,e));else if(t instanceof Set)t.add(r);else{let n=$g(s,r,e),o=vn.toJS(i,n,e);n in t?Object.defineProperty(t,n,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[n]=o}}return t}function $g(e,t,s){if(t===null)return"";if(typeof t!="object")return String(t);if(Ec.isNode(e)&&s?.doc){let i=vg.createStringifyContext(s.doc,{});i.anchors=new Set;for(let n of s.anchors.keys())i.anchors.add(n.anchor);i.inFlow=!0,i.inStringifyKey=!0;let r=e.toString(i);if(!s.mapKeyWarned){let n=JSON.stringify(r);n.length>40&&(n=n.substring(0,36)+'..."'),kg.warn(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${n}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return r}return JSON.stringify(t)}Pc.addPairToJSMap=Sg});var He=N($n=>{"use strict";var Ic=ts(),xg=wc(),Eg=Sn(),Oi=B();function Pg(e,t,s){let i=Ic.createNode(e,void 0,s),r=Ic.createNode(t,void 0,s);return new Mi(i,r)}var Mi=class e{constructor(t,s=null){Object.defineProperty(this,Oi.NODE_TYPE,{value:Oi.PAIR}),this.key=t,this.value=s}clone(t){let{key:s,value:i}=this;return Oi.isNode(s)&&(s=s.clone(t)),Oi.isNode(i)&&(i=i.clone(t)),new e(s,i)}toJSON(t,s){let i=s?.mapAsMap?new Map:{};return Eg.addPairToJSMap(s,i,this)}toString(t,s,i){return t?.doc?xg.stringifyPair(this,t,s,i):JSON.stringify(this)}};$n.Pair=Mi;$n.createPair=Pg});var xn=N(Lc=>{"use strict";var rt=B(),Cc=os(),Di=ss();function Ig(e,t,s){return(t.inFlow??e.flow?Lg:Cg)(e,t,s)}function Cg({comment:e,items:t},s,{blockItemPrefix:i,flowChars:r,itemIndent:n,onChompKeep:o,onComment:a}){let{indent:c,options:{commentString:u}}=s,f=Object.assign({},s,{indent:n,type:null}),d=!1,p=[];for(let y=0;y<t.length;++y){let h=t[y],g=null;if(rt.isNode(h))!d&&h.spaceBefore&&p.push(""),_i(s,p,h.commentBefore,d),h.comment&&(g=h.comment);else if(rt.isPair(h)){let k=rt.isNode(h.key)?h.key:null;k&&(!d&&k.spaceBefore&&p.push(""),_i(s,p,k.commentBefore,d))}d=!1;let b=Cc.stringify(h,f,()=>g=null,()=>d=!0);g&&(b+=Di.lineComment(b,n,u(g))),d&&g&&(d=!1),p.push(i+b)}let m;if(p.length===0)m=r.start+r.end;else{m=p[0];for(let y=1;y<p.length;++y){let h=p[y];m+=h?`
|
|
47
|
+
${c}${h}`:`
|
|
48
48
|
`}}return e?(m+=`
|
|
49
|
-
`+
|
|
50
|
-
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(
|
|
51
|
-
${
|
|
49
|
+
`+Di.indentComment(u(e),c),a&&a()):d&&o&&o(),m}function Lg({items:e},t,{flowChars:s,itemIndent:i}){let{indent:r,indentStep:n,flowCollectionPadding:o,options:{commentString:a}}=t;i+=n;let c=Object.assign({},t,{indent:i,inFlow:!0,type:null}),u=!1,f=0,d=[];for(let y=0;y<e.length;++y){let h=e[y],g=null;if(rt.isNode(h))h.spaceBefore&&d.push(""),_i(t,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(rt.isPair(h)){let k=rt.isNode(h.key)?h.key:null;k&&(k.spaceBefore&&d.push(""),_i(t,d,k.commentBefore,!1),k.comment&&(u=!0));let S=rt.isNode(h.value)?h.value:null;S?(S.comment&&(g=S.comment),S.commentBefore&&(u=!0)):h.value==null&&k?.comment&&(g=k.comment)}g&&(u=!0);let b=Cc.stringify(h,c,()=>g=null);u||(u=d.length>f||b.includes(`
|
|
50
|
+
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(u||(u=d.reduce((k,S)=>k+S.length+2,2)+(b.length+2)>t.options.lineWidth)),u&&(b+=",")),g&&(b+=Di.lineComment(b,i,a(g))),d.push(b),f=d.length}let{start:p,end:m}=s;if(d.length===0)return p+m;if(!u){let y=d.reduce((h,g)=>h+g.length+2,2);u=t.options.lineWidth>0&&y>t.options.lineWidth}if(u){let y=p;for(let h of d)y+=h?`
|
|
51
|
+
${n}${r}${h}`:`
|
|
52
52
|
`;return`${y}
|
|
53
|
-
${
|
|
54
|
-
`:" ")}return
|
|
55
|
-
${
|
|
56
|
-
${r.comment}`:i.comment}i=n}e.items[s]=Gs.isPair(i)?i:new Dn.Pair(i)}}else t("Expected a sequence for this tag");return e}function yl(e,t,s){let{replacer:i}=s,n=new Am.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;n.items.push(Dn.createPair(a,l,s))}return n}var Pm={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:gl,createNode:yl};Ys.createPairs=yl;Ys.pairs=Pm;Ys.resolvePairs=gl});var jn=A(_n=>{"use strict";var bl=_(),Fn=xe(),Dt=Ie(),Nm=Re(),wl=zs(),Ke=class e extends Nm.YAMLSeq{constructor(){super(),this.add=Dt.YAMLMap.prototype.add.bind(this),this.delete=Dt.YAMLMap.prototype.delete.bind(this),this.get=Dt.YAMLMap.prototype.get.bind(this),this.has=Dt.YAMLMap.prototype.has.bind(this),this.set=Dt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,s){if(!s)return super.toJSON(t);let i=new Map;s?.onCreate&&s.onCreate(i);for(let n of this.items){let r,o;if(bl.isPair(n)?(r=Fn.toJS(n.key,"",s),o=Fn.toJS(n.value,r,s)):r=Fn.toJS(n,"",s),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}static from(t,s,i){let n=wl.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Ke.tag="tag:yaml.org,2002:omap";var Im={collection:"seq",identify:e=>e instanceof Map,nodeClass:Ke,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=wl.resolvePairs(e,t),i=[];for(let{key:n}of s.items)bl.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Ke,s)},createNode:(e,t,s)=>Ke.from(e,t,s)};_n.YAMLOMap=Ke;_n.omap=Im});var xl=A(qn=>{"use strict";var vl=V();function kl({value:e,source:t},s){return t&&(e?Sl:$l).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var Sl={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new vl.Scalar(!0),stringify:kl},$l={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new vl.Scalar(!1),stringify:kl};qn.falseTag=$l;qn.trueTag=Sl});var El=A(Qs=>{"use strict";var Rm=V(),Bn=ot(),Lm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Bn.stringifyNumber},Om={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Bn.stringifyNumber(e)}},Tm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Rm.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let i=e.substring(s+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Bn.stringifyNumber};Qs.float=Tm;Qs.floatExp=Om;Qs.floatNaN=Lm});var Al=A(_t=>{"use strict";var Cl=ot(),Ft=e=>typeof e=="bigint"||Number.isInteger(e);function Xs(e,t,s,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let r=parseInt(e,s);return n==="-"?-1*r:r}function Un(e,t,s){let{value:i}=e;if(Ft(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return Cl.stringifyNumber(e)}var Mm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Xs(e,2,2,s),stringify:e=>Un(e,2,"0b")},Dm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Xs(e,1,8,s),stringify:e=>Un(e,8,"0")},Fm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Xs(e,0,10,s),stringify:Cl.stringifyNumber},_m={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Xs(e,2,16,s),stringify:e=>Un(e,16,"0x")};_t.int=Fm;_t.intBin=Mm;_t.intHex=_m;_t.intOct=Dm});var Vn=A(Kn=>{"use strict";var ti=_(),Zs=Pe(),ei=Ie(),Ve=class e extends ei.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;ti.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Zs.Pair(t.key,null):s=new Zs.Pair(t,null),ei.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=ei.findPair(this.items,t);return!s&&ti.isPair(i)?ti.isScalar(i.key)?i.key.value:i.key:i}set(t,s){if(typeof s!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof s}`);let i=ei.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Zs.Pair(t))}toJSON(t,s){return super.toJSON(t,s,Set)}toString(t,s,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),s,i);throw new Error("Set items must all have null values")}static from(t,s,i){let{replacer:n}=i,r=new this(t);if(s&&Symbol.iterator in Object(s))for(let o of s)typeof n=="function"&&(o=n.call(s,o,o)),r.items.push(Zs.createPair(o,null,i));return r}};Ve.tag="tag:yaml.org,2002:set";var jm={collection:"map",identify:e=>e instanceof Set,nodeClass:Ve,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>Ve.from(e,t,s),resolve(e,t){if(ti.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ve,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Kn.YAMLSet=Ve;Kn.set=jm});var Hn=A(si=>{"use strict";var qm=ot();function Jn(e,t){let s=e[0],i=s==="-"||s==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return s==="-"?n(-1)*r:r}function Pl(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return qm.stringifyNumber(e);let i="";t<0&&(i="-",t*=s(-1));let n=s(60),r=[t%n];return t<60?r.unshift(0):(t=(t-r[0])/n,r.unshift(t%n),t>=60&&(t=(t-r[0])/n,r.unshift(t))),i+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Bm={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>Jn(e,s),stringify:Pl},Um={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Jn(e,!1),stringify:Pl},Nl={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Nl.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,n,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,i-1,n,r||0,o||0,a||0,l),f=t[8];if(f&&f!=="Z"){let d=Jn(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};si.floatTime=Um;si.intTime=Bm;si.timestamp=Nl});var Ll=A(Rl=>{"use strict";var Km=nt(),Vm=Ks(),Jm=rt(),Hm=Tt(),Wm=Mn(),Il=xl(),Wn=El(),ii=Al(),Gm=Ms(),Ym=jn(),zm=zs(),Qm=Vn(),Gn=Hn(),Xm=[Km.map,Jm.seq,Hm.string,Vm.nullTag,Il.trueTag,Il.falseTag,ii.intBin,ii.intOct,ii.int,ii.intHex,Wn.floatNaN,Wn.floatExp,Wn.float,Wm.binary,Gm.merge,Ym.omap,zm.pairs,Qm.set,Gn.intTime,Gn.floatTime,Gn.timestamp];Rl.schema=Xm});var Ul=A(Qn=>{"use strict";var Dl=nt(),Zm=Ks(),Fl=rt(),eh=Tt(),th=An(),Yn=Nn(),zn=Rn(),sh=dl(),ih=ml(),_l=Mn(),jt=Ms(),jl=jn(),ql=zs(),Ol=Ll(),Bl=Vn(),ni=Hn(),Tl=new Map([["core",sh.schema],["failsafe",[Dl.map,Fl.seq,eh.string]],["json",ih.schema],["yaml11",Ol.schema],["yaml-1.1",Ol.schema]]),Ml={binary:_l.binary,bool:th.boolTag,float:Yn.float,floatExp:Yn.floatExp,floatNaN:Yn.floatNaN,floatTime:ni.floatTime,int:zn.int,intHex:zn.intHex,intOct:zn.intOct,intTime:ni.intTime,map:Dl.map,merge:jt.merge,null:Zm.nullTag,omap:jl.omap,pairs:ql.pairs,seq:Fl.seq,set:Bl.set,timestamp:ni.timestamp},nh={"tag:yaml.org,2002:binary":_l.binary,"tag:yaml.org,2002:merge":jt.merge,"tag:yaml.org,2002:omap":jl.omap,"tag:yaml.org,2002:pairs":ql.pairs,"tag:yaml.org,2002:set":Bl.set,"tag:yaml.org,2002:timestamp":ni.timestamp};function rh(e,t,s){let i=Tl.get(t);if(i&&!e)return s&&!i.includes(jt.merge)?i.concat(jt.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(Tl.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${r} or define customTags array`)}if(Array.isArray(e))for(let r of e)n=n.concat(r);else typeof e=="function"&&(n=e(n.slice()));return s&&(n=n.concat(jt.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?Ml[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Ml).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Qn.coreKnownTags=nh;Qn.getTags=rh});var er=A(Kl=>{"use strict";var Xn=_(),oh=nt(),ah=rt(),lh=Tt(),ri=Ul(),ch=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Zn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?ri.getTags(t,"compat"):t?ri.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?ri.coreKnownTags:{},this.tags=ri.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Xn.MAP,{value:oh.map}),Object.defineProperty(this,Xn.SCALAR,{value:lh.string}),Object.defineProperty(this,Xn.SEQ,{value:ah.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?ch:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};Kl.Schema=Zn});var Jl=A(Vl=>{"use strict";var uh=_(),tr=It(),qt=Ct();function dh(e,t){let s=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(s.push(l),i=!0):e.directives.docStart&&(i=!0)}i&&s.push("---");let n=tr.createStringifyContext(e,t),{commentString:r}=n.options;if(e.commentBefore){s.length!==1&&s.unshift("");let l=r(e.commentBefore);s.unshift(qt.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(uh.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let f=r(e.contents.commentBefore);s.push(qt.indentComment(f,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=tr.stringify(e.contents,n,()=>a=null,l);a&&(c+=qt.lineComment(c,"",r(a))),(c[0]==="|"||c[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${c}`:s.push(c)}else s.push(tr.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
57
|
-
`)?(s.push("..."),s.push(
|
|
53
|
+
${r}${m}`}else return`${p}${o}${d.join(" ")}${o}${m}`}function _i({indent:e,options:{commentString:t}},s,i,r){if(i&&r&&(i=i.replace(/^\n+/,"")),i){let n=Di.indentComment(t(i),e);s.push(n.trimStart())}}Lc.stringifyCollection=Ig});var We=N(Pn=>{"use strict";var Ag=xn(),Rg=Sn(),Ng=$i(),Je=B(),Fi=He(),Tg=X();function ls(e,t){let s=Je.isScalar(t)?t.value:t;for(let i of e)if(Je.isPair(i)&&(i.key===t||i.key===s||Je.isScalar(i.key)&&i.key.value===s))return i}var En=class extends Ng.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Je.MAP,t),this.items=[]}static from(t,s,i){let{keepUndefined:r,replacer:n}=i,o=new this(t),a=(c,u)=>{if(typeof n=="function")u=n.call(s,c,u);else if(Array.isArray(n)&&!n.includes(c))return;(u!==void 0||r)&&o.items.push(Fi.createPair(c,u,i))};if(s instanceof Map)for(let[c,u]of s)a(c,u);else if(s&&typeof s=="object")for(let c of Object.keys(s))a(c,s[c]);return typeof t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,s){let i;Je.isPair(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new Fi.Pair(t,t?.value):i=new Fi.Pair(t.key,t.value);let r=ls(this.items,i.key),n=this.schema?.sortMapEntries;if(r){if(!s)throw new Error(`Key ${i.key} already set`);Je.isScalar(r.value)&&Tg.isScalarValue(i.value)?r.value.value=i.value:r.value=i.value}else if(n){let o=this.items.findIndex(a=>n(i,a)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){let s=ls(this.items,t);return s?this.items.splice(this.items.indexOf(s),1).length>0:!1}get(t,s){let r=ls(this.items,t)?.value;return(!s&&Je.isScalar(r)?r.value:r)??void 0}has(t){return!!ls(this.items,t)}set(t,s){this.add(new Fi.Pair(t,s),!0)}toJSON(t,s,i){let r=i?new i:s?.mapAsMap?new Map:{};s?.onCreate&&s.onCreate(r);for(let n of this.items)Rg.addPairToJSMap(s,r,n);return r}toString(t,s,i){if(!t)return JSON.stringify(this);for(let r of this.items)if(!Je.isPair(r))throw new Error(`Map items must all be pairs; found ${JSON.stringify(r)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),Ag.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:s})}};Pn.YAMLMap=En;Pn.findPair=ls});var Pt=N(Rc=>{"use strict";var Og=B(),Ac=We(),Mg={collection:"map",default:!0,nodeClass:Ac.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return Og.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,s)=>Ac.YAMLMap.from(e,t,s)};Rc.map=Mg});var Ye=N(Nc=>{"use strict";var Dg=ts(),_g=xn(),Fg=$i(),qi=B(),jg=X(),qg=Ue(),In=class extends Fg.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(qi.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let s=ji(t);return typeof s!="number"?!1:this.items.splice(s,1).length>0}get(t,s){let i=ji(t);if(typeof i!="number")return;let r=this.items[i];return!s&&qi.isScalar(r)?r.value:r}has(t){let s=ji(t);return typeof s=="number"&&s<this.items.length}set(t,s){let i=ji(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let r=this.items[i];qi.isScalar(r)&&jg.isScalarValue(s)?r.value=s:this.items[i]=s}toJSON(t,s){let i=[];s?.onCreate&&s.onCreate(i);let r=0;for(let n of this.items)i.push(qg.toJS(n,String(r++),s));return i}toString(t,s,i){return t?_g.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:i,onComment:s}):JSON.stringify(this)}static from(t,s,i){let{replacer:r}=i,n=new this(t);if(s&&Symbol.iterator in Object(s)){let o=0;for(let a of s){if(typeof r=="function"){let c=s instanceof Set?a:String(o++);a=r.call(s,c,a)}n.items.push(Dg.createNode(a,void 0,i))}}return n}};function ji(e){let t=qi.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}Nc.YAMLSeq=In});var It=N(Oc=>{"use strict";var Bg=B(),Tc=Ye(),Ug={collection:"seq",default:!0,nodeClass:Tc.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return Bg.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,s)=>Tc.YAMLSeq.from(e,t,s)};Oc.seq=Ug});var cs=N(Mc=>{"use strict";var Vg=ns(),Kg={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,s,i){return t=Object.assign({actualString:!0},t),Vg.stringifyString(e,t,s,i)}};Mc.string=Kg});var Bi=N(Fc=>{"use strict";var Dc=X(),_c={identify:e=>e==null,createNode:()=>new Dc.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Dc.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&_c.test.test(e)?e:t.options.nullStr};Fc.nullTag=_c});var Cn=N(qc=>{"use strict";var Gg=X(),jc={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Gg.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&jc.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?s.options.trueStr:s.options.falseStr}};qc.boolTag=jc});var Ct=N(Bc=>{"use strict";function Hg({format:e,minFractionDigits:t,tag:s,value:i}){if(typeof i=="bigint")return String(i);let r=typeof i=="number"?i:Number(i);if(!isFinite(r))return isNaN(r)?".nan":r<0?"-.inf":".inf";let n=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!s||s==="tag:yaml.org,2002:float")&&/^-?\d/.test(n)&&!n.includes("e")){let o=n.indexOf(".");o<0&&(o=n.length,n+=".");let a=t-(n.length-o-1);for(;a-- >0;)n+="0"}return n}Bc.stringifyNumber=Hg});var An=N(Ui=>{"use strict";var Jg=X(),Ln=Ct(),Wg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ln.stringifyNumber},Yg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ln.stringifyNumber(e)}},zg={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new Jg.Scalar(parseFloat(e)),s=e.indexOf(".");return s!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-s-1),t},stringify:Ln.stringifyNumber};Ui.float=zg;Ui.floatExp=Yg;Ui.floatNaN=Wg});var Nn=N(Ki=>{"use strict";var Uc=Ct(),Vi=e=>typeof e=="bigint"||Number.isInteger(e),Rn=(e,t,s,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),s);function Vc(e,t,s){let{value:i}=e;return Vi(i)&&i>=0?s+i.toString(t):Uc.stringifyNumber(e)}var Xg={identify:e=>Vi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>Rn(e,2,8,s),stringify:e=>Vc(e,8,"0o")},Qg={identify:Vi,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>Rn(e,0,10,s),stringify:Uc.stringifyNumber},Zg={identify:e=>Vi(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>Rn(e,2,16,s),stringify:e=>Vc(e,16,"0x")};Ki.int=Qg;Ki.intHex=Zg;Ki.intOct=Xg});var Gc=N(Kc=>{"use strict";var ey=Pt(),ty=Bi(),sy=It(),iy=cs(),ry=Cn(),Tn=An(),On=Nn(),ny=[ey.map,sy.seq,iy.string,ty.nullTag,ry.boolTag,On.intOct,On.int,On.intHex,Tn.floatNaN,Tn.floatExp,Tn.float];Kc.schema=ny});var Wc=N(Jc=>{"use strict";var oy=X(),ay=Pt(),ly=It();function Hc(e){return typeof e=="bigint"||Number.isInteger(e)}var Gi=({value:e})=>JSON.stringify(e),cy=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Gi},{identify:e=>e==null,createNode:()=>new oy.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Gi},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Gi},{identify:Hc,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:s})=>s?BigInt(e):parseInt(e,10),stringify:({value:e})=>Hc(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:Gi}],uy={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},dy=[ay.map,ly.seq].concat(cy,uy);Jc.schema=dy});var Dn=N(Yc=>{"use strict";var us=ii("buffer"),Mn=X(),fy=ns(),py={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof us.Buffer=="function")return us.Buffer.from(e,"base64");if(typeof atob=="function"){let s=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(s.length);for(let r=0;r<s.length;++r)i[r]=s.charCodeAt(r);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:s},i,r,n){if(!s)return"";let o=s,a;if(typeof us.Buffer=="function")a=o instanceof us.Buffer?o.toString("base64"):us.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let c="";for(let u=0;u<o.length;++u)c+=String.fromCharCode(o[u]);a=btoa(c)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Mn.Scalar.BLOCK_LITERAL),t!==Mn.Scalar.QUOTE_DOUBLE){let c=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),u=Math.ceil(a.length/c),f=new Array(u);for(let d=0,p=0;d<u;++d,p+=c)f[d]=a.substr(p,c);a=f.join(t===Mn.Scalar.BLOCK_LITERAL?`
|
|
54
|
+
`:" ")}return fy.stringifyString({comment:e,type:t,value:a},i,r,n)}};Yc.binary=py});var Wi=N(Ji=>{"use strict";var Hi=B(),_n=He(),my=X(),hy=Ye();function zc(e,t){if(Hi.isSeq(e))for(let s=0;s<e.items.length;++s){let i=e.items[s];if(!Hi.isPair(i)){if(Hi.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let r=i.items[0]||new _n.Pair(new my.Scalar(null));if(i.commentBefore&&(r.key.commentBefore=r.key.commentBefore?`${i.commentBefore}
|
|
55
|
+
${r.key.commentBefore}`:i.commentBefore),i.comment){let n=r.value??r.key;n.comment=n.comment?`${i.comment}
|
|
56
|
+
${n.comment}`:i.comment}i=r}e.items[s]=Hi.isPair(i)?i:new _n.Pair(i)}}else t("Expected a sequence for this tag");return e}function Xc(e,t,s){let{replacer:i}=s,r=new hy.YAMLSeq(e);r.tag="tag:yaml.org,2002:pairs";let n=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(n++),o));let a,c;if(Array.isArray(o))if(o.length===2)a=o[0],c=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let u=Object.keys(o);if(u.length===1)a=u[0],c=o[a];else throw new TypeError(`Expected tuple with one key, not ${u.length} keys`)}else a=o;r.items.push(_n.createPair(a,c,s))}return r}var gy={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:zc,createNode:Xc};Ji.createPairs=Xc;Ji.pairs=gy;Ji.resolvePairs=zc});var qn=N(jn=>{"use strict";var Qc=B(),Fn=Ue(),ds=We(),yy=Ye(),Zc=Wi(),nt=class e extends yy.YAMLSeq{constructor(){super(),this.add=ds.YAMLMap.prototype.add.bind(this),this.delete=ds.YAMLMap.prototype.delete.bind(this),this.get=ds.YAMLMap.prototype.get.bind(this),this.has=ds.YAMLMap.prototype.has.bind(this),this.set=ds.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,s){if(!s)return super.toJSON(t);let i=new Map;s?.onCreate&&s.onCreate(i);for(let r of this.items){let n,o;if(Qc.isPair(r)?(n=Fn.toJS(r.key,"",s),o=Fn.toJS(r.value,n,s)):n=Fn.toJS(r,"",s),i.has(n))throw new Error("Ordered maps must not include duplicate keys");i.set(n,o)}return i}static from(t,s,i){let r=Zc.createPairs(t,s,i),n=new this;return n.items=r.items,n}};nt.tag="tag:yaml.org,2002:omap";var by={collection:"seq",identify:e=>e instanceof Map,nodeClass:nt,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=Zc.resolvePairs(e,t),i=[];for(let{key:r}of s.items)Qc.isScalar(r)&&(i.includes(r.value)?t(`Ordered maps must not include duplicate keys: ${r.value}`):i.push(r.value));return Object.assign(new nt,s)},createNode:(e,t,s)=>nt.from(e,t,s)};jn.YAMLOMap=nt;jn.omap=by});var ru=N(Bn=>{"use strict";var eu=X();function tu({value:e,source:t},s){return t&&(e?su:iu).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var su={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new eu.Scalar(!0),stringify:tu},iu={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new eu.Scalar(!1),stringify:tu};Bn.falseTag=iu;Bn.trueTag=su});var nu=N(Yi=>{"use strict";var wy=X(),Un=Ct(),ky={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Un.stringifyNumber},vy={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Un.stringifyNumber(e)}},Sy={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new wy.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let i=e.substring(s+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Un.stringifyNumber};Yi.float=Sy;Yi.floatExp=vy;Yi.floatNaN=ky});var au=N(ps=>{"use strict";var ou=Ct(),fs=e=>typeof e=="bigint"||Number.isInteger(e);function zi(e,t,s,{intAsBigInt:i}){let r=e[0];if((r==="-"||r==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return r==="-"?BigInt(-1)*o:o}let n=parseInt(e,s);return r==="-"?-1*n:n}function Vn(e,t,s){let{value:i}=e;if(fs(i)){let r=i.toString(t);return i<0?"-"+s+r.substr(1):s+r}return ou.stringifyNumber(e)}var $y={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>zi(e,2,2,s),stringify:e=>Vn(e,2,"0b")},xy={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>zi(e,1,8,s),stringify:e=>Vn(e,8,"0")},Ey={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>zi(e,0,10,s),stringify:ou.stringifyNumber},Py={identify:fs,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>zi(e,2,16,s),stringify:e=>Vn(e,16,"0x")};ps.int=Ey;ps.intBin=$y;ps.intHex=Py;ps.intOct=xy});var Gn=N(Kn=>{"use strict";var Zi=B(),Xi=He(),Qi=We(),ot=class e extends Qi.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;Zi.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Xi.Pair(t.key,null):s=new Xi.Pair(t,null),Qi.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=Qi.findPair(this.items,t);return!s&&Zi.isPair(i)?Zi.isScalar(i.key)?i.key.value:i.key:i}set(t,s){if(typeof s!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof s}`);let i=Qi.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Xi.Pair(t))}toJSON(t,s){return super.toJSON(t,s,Set)}toString(t,s,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),s,i);throw new Error("Set items must all have null values")}static from(t,s,i){let{replacer:r}=i,n=new this(t);if(s&&Symbol.iterator in Object(s))for(let o of s)typeof r=="function"&&(o=r.call(s,o,o)),n.items.push(Xi.createPair(o,null,i));return n}};ot.tag="tag:yaml.org,2002:set";var Iy={collection:"map",identify:e=>e instanceof Set,nodeClass:ot,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>ot.from(e,t,s),resolve(e,t){if(Zi.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new ot,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Kn.YAMLSet=ot;Kn.set=Iy});var Jn=N(er=>{"use strict";var Cy=Ct();function Hn(e,t){let s=e[0],i=s==="-"||s==="+"?e.substring(1):e,r=o=>t?BigInt(o):Number(o),n=i.replace(/_/g,"").split(":").reduce((o,a)=>o*r(60)+r(a),r(0));return s==="-"?r(-1)*n:n}function lu(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Cy.stringifyNumber(e);let i="";t<0&&(i="-",t*=s(-1));let r=s(60),n=[t%r];return t<60?n.unshift(0):(t=(t-n[0])/r,n.unshift(t%r),t>=60&&(t=(t-n[0])/r,n.unshift(t))),i+n.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Ly={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>Hn(e,s),stringify:lu},Ay={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Hn(e,!1),stringify:lu},cu={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(cu.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,r,n,o,a]=t.map(Number),c=t[7]?Number((t[7]+"00").substr(1,3)):0,u=Date.UTC(s,i-1,r,n||0,o||0,a||0,c),f=t[8];if(f&&f!=="Z"){let d=Hn(f,!1);Math.abs(d)<30&&(d*=60),u-=6e4*d}return new Date(u)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};er.floatTime=Ay;er.intTime=Ly;er.timestamp=cu});var fu=N(du=>{"use strict";var Ry=Pt(),Ny=Bi(),Ty=It(),Oy=cs(),My=Dn(),uu=ru(),Wn=nu(),tr=au(),Dy=Ti(),_y=qn(),Fy=Wi(),jy=Gn(),Yn=Jn(),qy=[Ry.map,Ty.seq,Oy.string,Ny.nullTag,uu.trueTag,uu.falseTag,tr.intBin,tr.intOct,tr.int,tr.intHex,Wn.floatNaN,Wn.floatExp,Wn.float,My.binary,Dy.merge,_y.omap,Fy.pairs,jy.set,Yn.intTime,Yn.floatTime,Yn.timestamp];du.schema=qy});var Su=N(Qn=>{"use strict";var gu=Pt(),By=Bi(),yu=It(),Uy=cs(),Vy=Cn(),zn=An(),Xn=Nn(),Ky=Gc(),Gy=Wc(),bu=Dn(),ms=Ti(),wu=qn(),ku=Wi(),pu=fu(),vu=Gn(),sr=Jn(),mu=new Map([["core",Ky.schema],["failsafe",[gu.map,yu.seq,Uy.string]],["json",Gy.schema],["yaml11",pu.schema],["yaml-1.1",pu.schema]]),hu={binary:bu.binary,bool:Vy.boolTag,float:zn.float,floatExp:zn.floatExp,floatNaN:zn.floatNaN,floatTime:sr.floatTime,int:Xn.int,intHex:Xn.intHex,intOct:Xn.intOct,intTime:sr.intTime,map:gu.map,merge:ms.merge,null:By.nullTag,omap:wu.omap,pairs:ku.pairs,seq:yu.seq,set:vu.set,timestamp:sr.timestamp},Hy={"tag:yaml.org,2002:binary":bu.binary,"tag:yaml.org,2002:merge":ms.merge,"tag:yaml.org,2002:omap":wu.omap,"tag:yaml.org,2002:pairs":ku.pairs,"tag:yaml.org,2002:set":vu.set,"tag:yaml.org,2002:timestamp":sr.timestamp};function Jy(e,t,s){let i=mu.get(t);if(i&&!e)return s&&!i.includes(ms.merge)?i.concat(ms.merge):i.slice();let r=i;if(!r)if(Array.isArray(e))r=[];else{let n=Array.from(mu.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${n} or define customTags array`)}if(Array.isArray(e))for(let n of e)r=r.concat(n);else typeof e=="function"&&(r=e(r.slice()));return s&&(r=r.concat(ms.merge)),r.reduce((n,o)=>{let a=typeof o=="string"?hu[o]:o;if(!a){let c=JSON.stringify(o),u=Object.keys(hu).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${c}; use one of ${u}`)}return n.includes(a)||n.push(a),n},[])}Qn.coreKnownTags=Hy;Qn.getTags=Jy});var to=N($u=>{"use strict";var Zn=B(),Wy=Pt(),Yy=It(),zy=cs(),ir=Su(),Xy=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,eo=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:r,schema:n,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?ir.getTags(t,"compat"):t?ir.getTags(null,t):null,this.name=typeof n=="string"&&n||"core",this.knownTags=r?ir.coreKnownTags:{},this.tags=ir.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Zn.MAP,{value:Wy.map}),Object.defineProperty(this,Zn.SCALAR,{value:zy.string}),Object.defineProperty(this,Zn.SEQ,{value:Yy.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Xy:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};$u.Schema=eo});var Eu=N(xu=>{"use strict";var Qy=B(),so=os(),hs=ss();function Zy(e,t){let s=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let c=e.directives.toString(e);c?(s.push(c),i=!0):e.directives.docStart&&(i=!0)}i&&s.push("---");let r=so.createStringifyContext(e,t),{commentString:n}=r.options;if(e.commentBefore){s.length!==1&&s.unshift("");let c=n(e.commentBefore);s.unshift(hs.indentComment(c,""))}let o=!1,a=null;if(e.contents){if(Qy.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let f=n(e.contents.commentBefore);s.push(hs.indentComment(f,""))}r.forceBlockIndent=!!e.comment,a=e.contents.comment}let c=a?void 0:()=>o=!0,u=so.stringify(e.contents,r,()=>a=null,c);a&&(u+=hs.lineComment(u,"",n(a))),(u[0]==="|"||u[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${u}`:s.push(u)}else s.push(so.stringify(e.contents,r));if(e.directives?.docEnd)if(e.comment){let c=n(e.comment);c.includes(`
|
|
57
|
+
`)?(s.push("..."),s.push(hs.indentComment(c,""))):s.push(`... ${c}`)}else s.push("...");else{let c=e.comment;c&&o&&(c=c.replace(/^\n+/,"")),c&&((!o||a)&&s[s.length-1]!==""&&s.push(""),s.push(hs.indentComment(n(c),"")))}return s.join(`
|
|
58
58
|
`)+`
|
|
59
|
-
`}
|
|
60
|
-
`),o=a+o}if(/[^ ]/.test(o)){let a=1,
|
|
59
|
+
`}xu.stringifyDocument=Zy});var gs=N(Pu=>{"use strict";var eb=es(),Lt=$i(),ke=B(),tb=He(),sb=Ue(),ib=to(),rb=Eu(),io=wi(),nb=an(),ob=ts(),ro=on(),no=class e{constructor(t,s,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ke.NODE_TYPE,{value:ke.DOC});let r=null;typeof s=="function"||Array.isArray(s)?r=s:i===void 0&&s&&(i=s,s=void 0);let n=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=n;let{version:o}=n;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new ro.Directives({version:o}),this.setSchema(o,i),this.contents=t===void 0?null:this.createNode(t,r,i)}clone(){let t=Object.create(e.prototype,{[ke.NODE_TYPE]:{value:ke.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=ke.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){At(this.contents)&&this.contents.add(t)}addIn(t,s){At(this.contents)&&this.contents.addIn(t,s)}createAlias(t,s){if(!t.anchor){let i=io.anchorNames(this);t.anchor=!s||i.has(s)?io.findNewAnchor(s||"a",i):s}return new eb.Alias(t.anchor)}createNode(t,s,i){let r;if(typeof s=="function")t=s.call({"":t},"",t),r=s;else if(Array.isArray(s)){let g=k=>typeof k=="number"||k instanceof String||k instanceof Number,b=s.filter(g).map(String);b.length>0&&(s=s.concat(b)),r=s}else i===void 0&&s&&(i=s,s=void 0);let{aliasDuplicateObjects:n,anchorPrefix:o,flow:a,keepUndefined:c,onTagObj:u,tag:f}=i??{},{onAnchor:d,setAnchors:p,sourceObjects:m}=io.createNodeAnchors(this,o||"a"),y={aliasDuplicateObjects:n??!0,keepUndefined:c??!1,onAnchor:d,onTagObj:u,replacer:r,schema:this.schema,sourceObjects:m},h=ob.createNode(t,f,y);return a&&ke.isCollection(h)&&(h.flow=!0),p(),h}createPair(t,s,i={}){let r=this.createNode(t,null,i),n=this.createNode(s,null,i);return new tb.Pair(r,n)}delete(t){return At(this.contents)?this.contents.delete(t):!1}deleteIn(t){return Lt.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):At(this.contents)?this.contents.deleteIn(t):!1}get(t,s){return ke.isCollection(this.contents)?this.contents.get(t,s):void 0}getIn(t,s){return Lt.isEmptyPath(t)?!s&&ke.isScalar(this.contents)?this.contents.value:this.contents:ke.isCollection(this.contents)?this.contents.getIn(t,s):void 0}has(t){return ke.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return Lt.isEmptyPath(t)?this.contents!==void 0:ke.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,s){this.contents==null?this.contents=Lt.collectionFromPath(this.schema,[t],s):At(this.contents)&&this.contents.set(t,s)}setIn(t,s){Lt.isEmptyPath(t)?this.contents=s:this.contents==null?this.contents=Lt.collectionFromPath(this.schema,Array.from(t),s):At(this.contents)&&this.contents.setIn(t,s)}setSchema(t,s={}){typeof t=="number"&&(t=String(t));let i;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new ro.Directives({version:"1.1"}),i={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=t:this.directives=new ro.Directives({version:t}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let r=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${r}`)}}if(s.schema instanceof Object)this.schema=s.schema;else if(i)this.schema=new ib.Schema(Object.assign(i,s));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:t,jsonArg:s,mapAsMap:i,maxAliasCount:r,onAnchor:n,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!t,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof r=="number"?r:100},c=sb.toJS(this.contents,s??"",a);if(typeof n=="function")for(let{count:u,res:f}of a.anchors.values())n(f,u);return typeof o=="function"?nb.applyReviver(o,{"":c},"",c):c}toJSON(t,s){return this.toJS({json:!0,jsonArg:t,mapAsMap:!1,onAnchor:s})}toString(t={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in t&&(!Number.isInteger(t.indent)||Number(t.indent)<=0)){let s=JSON.stringify(t.indent);throw new Error(`"indent" option must be a positive integer, not ${s}`)}return rb.stringifyDocument(this,t)}};function At(e){if(ke.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}Pu.Document=no});var ws=N(bs=>{"use strict";var ys=class extends Error{constructor(t,s,i,r){super(),this.name=t,this.code=i,this.message=r,this.pos=s}},oo=class extends ys{constructor(t,s,i){super("YAMLParseError",t,s,i)}},ao=class extends ys{constructor(t,s,i){super("YAMLWarning",t,s,i)}},ab=(e,t)=>s=>{if(s.pos[0]===-1)return;s.linePos=s.pos.map(a=>t.linePos(a));let{line:i,col:r}=s.linePos[0];s.message+=` at line ${i}, column ${r}`;let n=r-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(n>=60&&o.length>80){let a=Math.min(n-39,o.length-79);o="\u2026"+o.substring(a),n-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),i>1&&/^ *$/.test(o.substring(0,n))){let a=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
60
|
+
`),o=a+o}if(/[^ ]/.test(o)){let a=1,c=s.linePos[1];c?.line===i&&c.col>r&&(a=Math.max(1,Math.min(c.col-r,80-n)));let u=" ".repeat(n)+"^".repeat(a);s.message+=`:
|
|
61
61
|
|
|
62
62
|
${o}
|
|
63
|
-
${
|
|
64
|
-
`}};
|
|
65
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let s of t.start)if(s.type==="newline")return!0;if(t.sep){for(let s of t.sep)if(s.type==="newline")return!0}if(
|
|
66
|
-
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||
|
|
67
|
-
`+
|
|
68
|
-
`+
|
|
69
|
-
`+E
|
|
70
|
-
`+
|
|
71
|
-
`+g.comment:
|
|
72
|
-
`.repeat(Math.max(1,o.length-1)):"",g=i+
|
|
73
|
-
`;for(let h=f;h<a;++h){let[g,b]=o[h];
|
|
74
|
-
`):g.length>
|
|
63
|
+
${u}
|
|
64
|
+
`}};bs.YAMLError=ys;bs.YAMLParseError=oo;bs.YAMLWarning=ao;bs.prettifyError=ab});var ks=N(Iu=>{"use strict";function lb(e,{flow:t,indicator:s,next:i,offset:r,onError:n,parentIndent:o,startOnNewline:a}){let c=!1,u=a,f=a,d="",p="",m=!1,y=!1,h=null,g=null,b=null,k=null,S=null,v=null,x=null;for(let E of e)switch(y&&(E.type!=="space"&&E.type!=="newline"&&E.type!=="comma"&&n(E.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),y=!1),h&&(u&&E.type!=="comment"&&E.type!=="newline"&&n(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),E.type){case"space":!t&&(s!=="doc-start"||i?.type!=="flow-collection")&&E.source.includes(" ")&&(h=E),f=!0;break;case"comment":{f||n(E,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let F=E.source.substring(1)||" ";d?d+=p+F:d=F,p="",u=!1;break}case"newline":u?d?d+=E.source:(!v||s!=="seq-item-ind")&&(c=!0):p+=E.source,u=!0,m=!0,(g||b)&&(k=E),f=!0;break;case"anchor":g&&n(E,"MULTIPLE_ANCHORS","A node can have at most one anchor"),E.source.endsWith(":")&&n(E.offset+E.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=E,x??(x=E.offset),u=!1,f=!1,y=!0;break;case"tag":{b&&n(E,"MULTIPLE_TAGS","A node can have at most one tag"),b=E,x??(x=E.offset),u=!1,f=!1,y=!0;break}case s:(g||b)&&n(E,"BAD_PROP_ORDER",`Anchors and tags must be after the ${E.source} indicator`),v&&n(E,"UNEXPECTED_TOKEN",`Unexpected ${E.source} in ${t??"collection"}`),v=E,u=s==="seq-item-ind"||s==="explicit-key-ind",f=!1;break;case"comma":if(t){S&&n(E,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),S=E,u=!1,f=!1;break}default:n(E,"UNEXPECTED_TOKEN",`Unexpected ${E.type} token`),u=!1,f=!1}let I=e[e.length-1],L=I?I.offset+I.source.length:r;return y&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&n(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(u&&h.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&n(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:S,found:v,spaceBefore:c,comment:d,hasNewline:m,anchor:g,tag:b,newlineAfterProp:k,end:L,start:x??L}}Iu.resolveProps=lb});var rr=N(Cu=>{"use strict";function lo(e){if(!e)return null;switch(e.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(e.source.includes(`
|
|
65
|
+
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let s of t.start)if(s.type==="newline")return!0;if(t.sep){for(let s of t.sep)if(s.type==="newline")return!0}if(lo(t.key)||lo(t.value))return!0}return!1;default:return!0}}Cu.containsNewline=lo});var co=N(Lu=>{"use strict";var cb=rr();function ub(e,t,s){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&cb.containsNewline(t)&&s(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Lu.flowIndentCheck=ub});var uo=N(Ru=>{"use strict";var Au=B();function db(e,t,s){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let r=typeof i=="function"?i:(n,o)=>n===o||Au.isScalar(n)&&Au.isScalar(o)&&n.value===o.value;return t.some(n=>r(n.key,s))}Ru.mapIncludes=db});var _u=N(Du=>{"use strict";var Nu=He(),fb=We(),Tu=ks(),pb=rr(),Ou=co(),mb=uo(),Mu="All mapping items must start at the same column";function hb({composeNode:e,composeEmptyNode:t},s,i,r,n){let o=n?.nodeClass??fb.YAMLMap,a=new o(s.schema);s.atRoot&&(s.atRoot=!1);let c=i.offset,u=null;for(let f of i.items){let{start:d,key:p,sep:m,value:y}=f,h=Tu.resolveProps(d,{indicator:"explicit-key-ind",next:p??m?.[0],offset:c,onError:r,parentIndent:i.indent,startOnNewline:!0}),g=!h.found;if(g){if(p&&(p.type==="block-seq"?r(c,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&r(c,"BAD_INDENT",Mu)),!h.anchor&&!h.tag&&!m){u=h.end,h.comment&&(a.comment?a.comment+=`
|
|
66
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||pb.containsNewline(p))&&r(p??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&r(c,"BAD_INDENT",Mu);s.atKey=!0;let b=h.end,k=p?e(s,p,h,r):t(s,b,d,null,h,r);s.schema.compat&&Ou.flowIndentCheck(i.indent,p,r),s.atKey=!1,mb.mapIncludes(s,a.items,k)&&r(b,"DUPLICATE_KEY","Map keys must be unique");let S=Tu.resolveProps(m??[],{indicator:"map-value-ind",next:y,offset:k.range[2],onError:r,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(c=S.end,S.found){g&&(y?.type==="block-map"&&!S.hasNewline&&r(c,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),s.options.strict&&h.start<S.found.offset-1024&&r(k.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let v=y?e(s,y,S,r):t(s,c,m,null,S,r);s.schema.compat&&Ou.flowIndentCheck(i.indent,y,r),c=v.range[2];let x=new Nu.Pair(k,v);s.options.keepSourceTokens&&(x.srcToken=f),a.items.push(x)}else{g&&r(k.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),S.comment&&(k.comment?k.comment+=`
|
|
67
|
+
`+S.comment:k.comment=S.comment);let v=new Nu.Pair(k);s.options.keepSourceTokens&&(v.srcToken=f),a.items.push(v)}}return u&&u<c&&r(u,"IMPOSSIBLE","Map comment with trailing content"),a.range=[i.offset,c,u??c],a}Du.resolveBlockMap=hb});var ju=N(Fu=>{"use strict";var gb=Ye(),yb=ks(),bb=co();function wb({composeNode:e,composeEmptyNode:t},s,i,r,n){let o=n?.nodeClass??gb.YAMLSeq,a=new o(s.schema);s.atRoot&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let c=i.offset,u=null;for(let{start:f,value:d}of i.items){let p=yb.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:c,onError:r,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||d)d?.type==="block-seq"?r(p.end,"BAD_INDENT","All sequence items must start at the same column"):r(c,"MISSING_CHAR","Sequence item without - indicator");else{u=p.end,p.comment&&(a.comment=p.comment);continue}let m=d?e(s,d,p,r):t(s,p.end,f,null,p,r);s.schema.compat&&bb.flowIndentCheck(i.indent,d,r),c=m.range[2],a.items.push(m)}return a.range=[i.offset,c,u??c],a}Fu.resolveBlockSeq=wb});var Rt=N(qu=>{"use strict";function kb(e,t,s,i){let r="";if(e){let n=!1,o="";for(let a of e){let{source:c,type:u}=a;switch(u){case"space":n=!0;break;case"comment":{s&&!n&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=c.substring(1)||" ";r?r+=o+f:r=f,o="";break}case"newline":r&&(o+=c),n=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${u} at node end`)}t+=c.length}}return{comment:r,offset:t}}qu.resolveEnd=kb});var Ku=N(Vu=>{"use strict";var vb=B(),Sb=He(),Bu=We(),$b=Ye(),xb=Rt(),Uu=ks(),Eb=rr(),Pb=uo(),fo="Block collections are not allowed within flow collections",po=e=>e&&(e.type==="block-map"||e.type==="block-seq");function Ib({composeNode:e,composeEmptyNode:t},s,i,r,n){let o=i.start.source==="{",a=o?"flow map":"flow sequence",c=n?.nodeClass??(o?Bu.YAMLMap:$b.YAMLSeq),u=new c(s.schema);u.flow=!0;let f=s.atRoot;f&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let d=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let b=i.items[g],{start:k,key:S,sep:v,value:x}=b,I=Uu.resolveProps(k,{flow:a,indicator:"explicit-key-ind",next:S??v?.[0],offset:d,onError:r,parentIndent:i.indent,startOnNewline:!1});if(!I.found){if(!I.anchor&&!I.tag&&!v&&!x){g===0&&I.comma?r(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<i.items.length-1&&r(I.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),I.comment&&(u.comment?u.comment+=`
|
|
68
|
+
`+I.comment:u.comment=I.comment),d=I.end;continue}!o&&s.options.strict&&Eb.containsNewline(S)&&r(S,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)I.comma&&r(I.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(I.comma||r(I.start,"MISSING_CHAR",`Missing , between ${a} items`),I.comment){let L="";e:for(let E of k)switch(E.type){case"comma":case"space":break;case"comment":L=E.source.substring(1);break e;default:break e}if(L){let E=u.items[u.items.length-1];vb.isPair(E)&&(E=E.value??E.key),E.comment?E.comment+=`
|
|
69
|
+
`+L:E.comment=L,I.comment=I.comment.substring(L.length+1)}}if(!o&&!v&&!I.found){let L=x?e(s,x,I,r):t(s,I.end,v,null,I,r);u.items.push(L),d=L.range[2],po(x)&&r(L.range,"BLOCK_IN_FLOW",fo)}else{s.atKey=!0;let L=I.end,E=S?e(s,S,I,r):t(s,L,k,null,I,r);po(S)&&r(E.range,"BLOCK_IN_FLOW",fo),s.atKey=!1;let F=Uu.resolveProps(v??[],{flow:a,indicator:"map-value-ind",next:x,offset:E.range[2],onError:r,parentIndent:i.indent,startOnNewline:!1});if(F.found){if(!o&&!I.found&&s.options.strict){if(v)for(let P of v){if(P===F.found)break;if(P.type==="newline"){r(P,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}I.start<F.found.offset-1024&&r(F.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else x&&("source"in x&&x.source?.[0]===":"?r(x,"MISSING_CHAR",`Missing space after : in ${a}`):r(F.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let O=x?e(s,x,F,r):F.found?t(s,F.end,v,null,F,r):null;O?po(x)&&r(O.range,"BLOCK_IN_FLOW",fo):F.comment&&(E.comment?E.comment+=`
|
|
70
|
+
`+F.comment:E.comment=F.comment);let w=new Sb.Pair(E,O);if(s.options.keepSourceTokens&&(w.srcToken=b),o){let P=u;Pb.mapIncludes(s,P.items,E)&&r(L,"DUPLICATE_KEY","Map keys must be unique"),P.items.push(w)}else{let P=new Bu.YAMLMap(s.schema);P.flow=!0,P.items.push(w);let q=(O??E).range;P.range=[E.range[0],q[1],q[2]],u.items.push(P)}d=O?O.range[2]:F.end}}let p=o?"}":"]",[m,...y]=i.end,h=d;if(m?.source===p)h=m.offset+m.source.length;else{let g=a[0].toUpperCase()+a.substring(1),b=f?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;r(d,f?"MISSING_CHAR":"BAD_INDENT",b),m&&m.source.length!==1&&y.unshift(m)}if(y.length>0){let g=xb.resolveEnd(y,h,s.options.strict,r);g.comment&&(u.comment?u.comment+=`
|
|
71
|
+
`+g.comment:u.comment=g.comment),u.range=[i.offset,h,g.offset]}else u.range=[i.offset,h,h];return u}Vu.resolveFlowCollection=Ib});var Hu=N(Gu=>{"use strict";var Cb=B(),Lb=X(),Ab=We(),Rb=Ye(),Nb=_u(),Tb=ju(),Ob=Ku();function mo(e,t,s,i,r,n){let o=s.type==="block-map"?Nb.resolveBlockMap(e,t,s,i,n):s.type==="block-seq"?Tb.resolveBlockSeq(e,t,s,i,n):Ob.resolveFlowCollection(e,t,s,i,n),a=o.constructor;return r==="!"||r===a.tagName?(o.tag=a.tagName,o):(r&&(o.tag=r),o)}function Mb(e,t,s,i,r){let n=i.tag,o=n?t.directives.tagName(n.source,p=>r(n,"TAG_RESOLVE_FAILED",p)):null;if(s.type==="block-seq"){let{anchor:p,newlineAfterProp:m}=i,y=p&&n?p.offset>n.offset?p:n:p??n;y&&(!m||m.offset<y.offset)&&r(y,"MISSING_CHAR","Missing newline after block sequence props")}let a=s.type==="block-map"?"map":s.type==="block-seq"?"seq":s.start.source==="{"?"map":"seq";if(!n||!o||o==="!"||o===Ab.YAMLMap.tagName&&a==="map"||o===Rb.YAMLSeq.tagName&&a==="seq")return mo(e,t,s,r,o);let c=t.schema.tags.find(p=>p.tag===o&&p.collection===a);if(!c){let p=t.schema.knownTags[o];if(p?.collection===a)t.schema.tags.push(Object.assign({},p,{default:!1})),c=p;else return p?r(n,"BAD_COLLECTION_TYPE",`${p.tag} used for ${a} collection, but expects ${p.collection??"scalar"}`,!0):r(n,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),mo(e,t,s,r,o)}let u=mo(e,t,s,r,o,c),f=c.resolve?.(u,p=>r(n,"TAG_RESOLVE_FAILED",p),t.options)??u,d=Cb.isNode(f)?f:new Lb.Scalar(f);return d.range=u.range,d.tag=o,c?.format&&(d.format=c.format),d}Gu.composeCollection=Mb});var go=N(Ju=>{"use strict";var ho=X();function Db(e,t,s){let i=t.offset,r=_b(t,e.options.strict,s);if(!r)return{value:"",type:null,comment:"",range:[i,i,i]};let n=r.mode===">"?ho.Scalar.BLOCK_FOLDED:ho.Scalar.BLOCK_LITERAL,o=t.source?Fb(t.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")a=h;else break}if(a===0){let h=r.chomp==="+"&&o.length>0?`
|
|
72
|
+
`.repeat(Math.max(1,o.length-1)):"",g=i+r.length;return t.source&&(g+=t.source.length),{value:h,type:n,comment:r.comment,range:[i,g,g]}}let c=t.indent+r.indent,u=t.offset+r.length,f=0;for(let h=0;h<a;++h){let[g,b]=o[h];if(b===""||b==="\r")r.indent===0&&g.length>c&&(c=g.length);else{g.length<c&&s(u+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),r.indent===0&&(c=g.length),f=h,c===0&&!e.atRoot&&s(u,"BAD_INDENT","Block scalar values in collections must be indented");break}u+=g.length+b.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>c&&(a=h+1);let d="",p="",m=!1;for(let h=0;h<f;++h)d+=o[h][0].slice(c)+`
|
|
73
|
+
`;for(let h=f;h<a;++h){let[g,b]=o[h];u+=g.length+b.length+1;let k=b[b.length-1]==="\r";if(k&&(b=b.slice(0,-1)),b&&g.length<c){let v=`Block scalar lines must not be less indented than their ${r.indent?"explicit indentation indicator":"first line"}`;s(u-b.length-(k?2:1),"BAD_INDENT",v),g=""}n===ho.Scalar.BLOCK_LITERAL?(d+=p+g.slice(c)+b,p=`
|
|
74
|
+
`):g.length>c||b[0]===" "?(p===" "?p=`
|
|
75
75
|
`:!m&&p===`
|
|
76
76
|
`&&(p=`
|
|
77
77
|
|
|
78
|
-
`),d+=p+g.slice(
|
|
78
|
+
`),d+=p+g.slice(c)+b,p=`
|
|
79
79
|
`,m=!0):b===""?p===`
|
|
80
80
|
`?d+=`
|
|
81
81
|
`:p=`
|
|
82
|
-
`:(d+=p+b,p=" ",m=!1)}switch(
|
|
83
|
-
`+o[h][0].slice(
|
|
82
|
+
`:(d+=p+b,p=" ",m=!1)}switch(r.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)d+=`
|
|
83
|
+
`+o[h][0].slice(c);d[d.length-1]!==`
|
|
84
84
|
`&&(d+=`
|
|
85
85
|
`);break;default:d+=`
|
|
86
|
-
`}let y=i+
|
|
86
|
+
`}let y=i+r.length+t.source.length;return{value:d,type:n,comment:r.comment,range:[i,y,y]}}function _b({offset:e,props:t},s,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:r}=t[0],n=r[0],o=0,a="",c=-1;for(let p=1;p<r.length;++p){let m=r[p];if(!a&&(m==="-"||m==="+"))a=m;else{let y=Number(m);!o&&y?o=y:c===-1&&(c=e+p)}}c!==-1&&i(c,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${r}`);let u=!1,f="",d=r.length;for(let p=1;p<t.length;++p){let m=t[p];switch(m.type){case"space":u=!0;case"newline":d+=m.source.length;break;case"comment":s&&!u&&i(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=m.source.length,f=m.source.substring(1);break;case"error":i(m,"UNEXPECTED_TOKEN",m.message),d+=m.source.length;break;default:{let y=`Unexpected token in block scalar header: ${m.type}`;i(m,"UNEXPECTED_TOKEN",y);let h=m.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:n,indent:o,chomp:a,comment:f,length:d}}function Fb(e){let t=e.split(/\n( *)/),s=t[0],i=s.match(/^( *)/),n=[i?.[1]?[i[1],s.slice(i[1].length)]:["",s]];for(let o=1;o<t.length;o+=2)n.push([t[o],t[o+1]]);return n}Ju.resolveBlockScalar=Db});var bo=N(Yu=>{"use strict";var yo=X(),jb=Rt();function qb(e,t,s){let{offset:i,type:r,source:n,end:o}=e,a,c,u=(p,m,y)=>s(i+p,m,y);switch(r){case"scalar":a=yo.Scalar.PLAIN,c=Bb(n,u);break;case"single-quoted-scalar":a=yo.Scalar.QUOTE_SINGLE,c=Ub(n,u);break;case"double-quoted-scalar":a=yo.Scalar.QUOTE_DOUBLE,c=Vb(n,u);break;default:return s(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${r}`),{value:"",type:null,comment:"",range:[i,i+n.length,i+n.length]}}let f=i+n.length,d=jb.resolveEnd(o,f,t,s);return{value:c,type:a,comment:d.comment,range:[i,f,d.offset]}}function Bb(e,t){let s="";switch(e[0]){case" ":s="a tab character";break;case",":s="flow indicator character ,";break;case"%":s="directive indicator character %";break;case"|":case">":{s=`block scalar indicator ${e[0]}`;break}case"@":case"`":{s=`reserved character ${e[0]}`;break}}return s&&t(0,"BAD_SCALAR_START",`Plain value cannot start with ${s}`),Wu(e)}function Ub(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),Wu(e.slice(1,-1)).replace(/''/g,"'")}function Wu(e){let t,s;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
87
87
|
`,"sy"),s=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
88
|
-
`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,s=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let
|
|
89
|
-
`?n
|
|
90
|
-
`:(n
|
|
91
|
-
`))if(
|
|
92
|
-
`){let{fold:
|
|
93
|
-
`)for(
|
|
94
|
-
`)for(
|
|
88
|
+
`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,s=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let r=i[1],n=" ",o=t.lastIndex;for(s.lastIndex=o;i=s.exec(e);)i[1]===""?n===`
|
|
89
|
+
`?r+=n:n=`
|
|
90
|
+
`:(r+=n+i[1],n=" "),o=s.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),r+n+(i?.[1]??"")}function Vb(e,t){let s="";for(let i=1;i<e.length-1;++i){let r=e[i];if(!(r==="\r"&&e[i+1]===`
|
|
91
|
+
`))if(r===`
|
|
92
|
+
`){let{fold:n,offset:o}=Kb(e,i);s+=n,i=o}else if(r==="\\"){let n=e[++i],o=Gb[n];if(o)s+=o;else if(n===`
|
|
93
|
+
`)for(n=e[i+1];n===" "||n===" ";)n=e[++i+1];else if(n==="\r"&&e[i+1]===`
|
|
94
|
+
`)for(n=e[++i+1];n===" "||n===" ";)n=e[++i+1];else if(n==="x"||n==="u"||n==="U"){let a=n==="x"?2:n==="u"?4:8;s+=Hb(e,i+1,a,t),i+=a}else{let a=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),s+=a}}else if(r===" "||r===" "){let n=i,o=e[i+1];for(;o===" "||o===" ";)o=e[++i+1];o!==`
|
|
95
95
|
`&&!(o==="\r"&&e[i+2]===`
|
|
96
|
-
`)&&(s+=i>
|
|
96
|
+
`)&&(s+=i>n?e.slice(n,i+1):r)}else s+=r}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),s}function Kb(e,t){let s="",i=e[t+1];for(;(i===" "||i===" "||i===`
|
|
97
97
|
`||i==="\r")&&!(i==="\r"&&e[t+2]!==`
|
|
98
98
|
`);)i===`
|
|
99
99
|
`&&(s+=`
|
|
100
|
-
`),t+=1,i=e[t+1];return s||(s=" "),{fold:s,offset:t}}var
|
|
101
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
100
|
+
`),t+=1,i=e[t+1];return s||(s=" "),{fold:s,offset:t}}var Gb={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
101
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Hb(e,t,s,i){let r=e.substr(t,s),o=r.length===s&&/^[0-9a-fA-F]+$/.test(r)?parseInt(r,16):NaN;try{return String.fromCodePoint(o)}catch{let a=e.substr(t-2,s+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}}Yu.resolveFlowScalar=qb});var Qu=N(Xu=>{"use strict";var at=B(),zu=X(),Jb=go(),Wb=bo();function Yb(e,t,s,i){let{value:r,type:n,comment:o,range:a}=t.type==="block-scalar"?Jb.resolveBlockScalar(e,t,i):Wb.resolveFlowScalar(t,e.options.strict,i),c=s?e.directives.tagName(s.source,d=>i(s,"TAG_RESOLVE_FAILED",d)):null,u;e.options.stringKeys&&e.atKey?u=e.schema[at.SCALAR]:c?u=zb(e.schema,r,c,s,i):t.type==="scalar"?u=Xb(e,r,t,i):u=e.schema[at.SCALAR];let f;try{let d=u.resolve(r,p=>i(s??t,"TAG_RESOLVE_FAILED",p),e.options);f=at.isScalar(d)?d:new zu.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(s??t,"TAG_RESOLVE_FAILED",p),f=new zu.Scalar(r)}return f.range=a,f.source=r,n&&(f.type=n),c&&(f.tag=c),u.format&&(f.format=u.format),o&&(f.comment=o),f}function zb(e,t,s,i,r){if(s==="!")return e[at.SCALAR];let n=[];for(let a of e.tags)if(!a.collection&&a.tag===s)if(a.default&&a.test)n.push(a);else return a;for(let a of n)if(a.test?.test(t))return a;let o=e.knownTags[s];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(r(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,s!=="tag:yaml.org,2002:str"),e[at.SCALAR])}function Xb({atKey:e,directives:t,schema:s},i,r,n){let o=s.tags.find(a=>(a.default===!0||e&&a.default==="key")&&a.test?.test(i))||s[at.SCALAR];if(s.compat){let a=s.compat.find(c=>c.default&&c.test?.test(i))??s[at.SCALAR];if(o.tag!==a.tag){let c=t.tagString(o.tag),u=t.tagString(a.tag),f=`Value may be parsed as either ${c} or ${u}`;n(r,"TAG_RESOLVE_FAILED",f,!0)}}return o}Xu.composeScalar=Yb});var ed=N(Zu=>{"use strict";function Qb(e,t,s){if(t){s??(s=t.length);for(let i=s-1;i>=0;--i){let r=t[i];switch(r.type){case"space":case"comment":case"newline":e-=r.source.length;continue}for(r=t[++i];r?.type==="space";)e+=r.source.length,r=t[++i];break}}return e}Zu.emptyScalarPosition=Qb});var id=N(ko=>{"use strict";var Zb=es(),ew=B(),tw=Hu(),td=Qu(),sw=Rt(),iw=ed(),rw={composeNode:sd,composeEmptyNode:wo};function sd(e,t,s,i){let r=e.atKey,{spaceBefore:n,comment:o,anchor:a,tag:c}=s,u,f=!0;switch(t.type){case"alias":u=nw(e,t,i),(a||c)&&i(t,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":u=td.composeScalar(e,t,c,i),a&&(u.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{u=tw.composeCollection(rw,e,t,s,i),a&&(u.anchor=a.source.substring(1))}catch(d){let p=d instanceof Error?d.message:String(d);i(t,"RESOURCE_EXHAUSTION",p)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",d),f=!1}}return u??(u=wo(e,t.offset,void 0,null,s,i)),a&&u.anchor===""&&i(a,"BAD_ALIAS","Anchor cannot be an empty string"),r&&e.options.stringKeys&&(!ew.isScalar(u)||typeof u.value!="string"||u.tag&&u.tag!=="tag:yaml.org,2002:str")&&i(c??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),n&&(u.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?u.comment=o:u.commentBefore=o),e.options.keepSourceTokens&&f&&(u.srcToken=t),u}function wo(e,t,s,i,{spaceBefore:r,comment:n,anchor:o,tag:a,end:c},u){let f={type:"scalar",offset:iw.emptyScalarPosition(t,s,i),indent:-1,source:""},d=td.composeScalar(e,f,a,u);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&u(o,"BAD_ALIAS","Anchor cannot be an empty string")),r&&(d.spaceBefore=!0),n&&(d.comment=n,d.range[2]=c),d}function nw({options:e},{offset:t,source:s,end:i},r){let n=new Zb.Alias(s.substring(1));n.source===""&&r(t,"BAD_ALIAS","Alias cannot be an empty string"),n.source.endsWith(":")&&r(t+s.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+s.length,a=sw.resolveEnd(i,o,e.strict,r);return n.range=[t,o,a.offset],a.comment&&(n.comment=a.comment),n}ko.composeEmptyNode=wo;ko.composeNode=sd});var od=N(nd=>{"use strict";var ow=gs(),rd=id(),aw=Rt(),lw=ks();function cw(e,t,{offset:s,start:i,value:r,end:n},o){let a=Object.assign({_directives:t},e),c=new ow.Document(void 0,a),u={atKey:!1,atRoot:!0,directives:c.directives,options:c.options,schema:c.schema},f=lw.resolveProps(i,{indicator:"doc-start",next:r??n?.[0],offset:s,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(c.directives.docStart=!0,r&&(r.type==="block-map"||r.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),c.contents=r?rd.composeNode(u,r,f,o):rd.composeEmptyNode(u,f.end,i,null,f,o);let d=c.contents.range[2],p=aw.resolveEnd(n,d,!1,o);return p.comment&&(c.comment=p.comment),c.range=[s,d,p.offset],c}nd.composeDoc=cw});var So=N(cd=>{"use strict";var uw=ii("process"),dw=on(),fw=gs(),vs=ws(),ad=B(),pw=od(),mw=Rt();function Ss(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:s}=e;return[t,t+(typeof s=="string"?s.length:1)]}function ld(e){let t="",s=!1,i=!1;for(let r=0;r<e.length;++r){let n=e[r];switch(n[0]){case"#":t+=(t===""?"":i?`
|
|
102
102
|
|
|
103
103
|
`:`
|
|
104
|
-
`)+(
|
|
105
|
-
${i}`:i;else if(
|
|
106
|
-
${a}`:i}else{let o=
|
|
107
|
-
${o}`:i}}s
|
|
108
|
-
${s.comment}`:s.comment}this.doc.range[2]=s.offset;break}default:this.errors.push(new
|
|
109
|
-
`}];switch(a[0]){case"|":case">":{let
|
|
110
|
-
`),f=a.substring(0,
|
|
111
|
-
`,p=[{type:"block-scalar-header",offset:
|
|
112
|
-
`}),{type:"block-scalar",offset:
|
|
113
|
-
`),i=t.substring(0,s),
|
|
114
|
-
`;if(e.type==="block-scalar"){let
|
|
115
|
-
`});for(let
|
|
116
|
-
`};delete e.items,Object.assign(e,{type:s,source:t,end:[
|
|
104
|
+
`)+(n.substring(1)||" "),s=!0,i=!1;break;case"%":e[r+1]?.[0]!=="#"&&(r+=1),s=!1;break;default:s||(i=!0),s=!1}}return{comment:t,afterEmptyLine:i}}var vo=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(s,i,r,n)=>{let o=Ss(s);n?this.warnings.push(new vs.YAMLWarning(o,i,r)):this.errors.push(new vs.YAMLParseError(o,i,r))},this.directives=new dw.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,s){let{comment:i,afterEmptyLine:r}=ld(this.prelude);if(i){let n=t.contents;if(s)t.comment=t.comment?`${t.comment}
|
|
105
|
+
${i}`:i;else if(r||t.directives.docStart||!n)t.commentBefore=i;else if(ad.isCollection(n)&&!n.flow&&n.items.length>0){let o=n.items[0];ad.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${i}
|
|
106
|
+
${a}`:i}else{let o=n.commentBefore;n.commentBefore=o?`${i}
|
|
107
|
+
${o}`:i}}if(s){for(let n=0;n<this.errors.length;++n)t.errors.push(this.errors[n]);for(let n=0;n<this.warnings.length;++n)t.warnings.push(this.warnings[n])}else t.errors=this.errors,t.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:ld(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,s=!1,i=-1){for(let r of t)yield*this.next(r);yield*this.end(s,i)}*next(t){switch(uw.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(s,i,r)=>{let n=Ss(t);n[0]+=s,this.onError(n,"BAD_DIRECTIVE",i,r)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let s=pw.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!s.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(s,!1),this.doc&&(yield this.doc),this.doc=s,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let s=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new vs.YAMLParseError(Ss(t),"UNEXPECTED_TOKEN",s);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new vs.YAMLParseError(Ss(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let s=mw.resolveEnd(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),s.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
|
|
108
|
+
${s.comment}`:s.comment}this.doc.range[2]=s.offset;break}default:this.errors.push(new vs.YAMLParseError(Ss(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,s=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let i=Object.assign({_directives:this.directives},this.options),r=new fw.Document(void 0,i);this.atDirectives&&this.onError(s,"MISSING_CHAR","Missing directives-end indicator line"),r.range=[0,s,s],this.decorate(r,!1),yield r}}};cd.Composer=vo});var fd=N(nr=>{"use strict";var hw=go(),gw=bo(),yw=ws(),ud=ns();function bw(e,t=!0,s){if(e){let i=(r,n,o)=>{let a=typeof r=="number"?r:Array.isArray(r)?r[0]:r.offset;if(s)s(a,n,o);else throw new yw.YAMLParseError([a,a+1],n,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return gw.resolveFlowScalar(e,t,i);case"block-scalar":return hw.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function ww(e,t){let{implicitKey:s=!1,indent:i,inFlow:r=!1,offset:n=-1,type:o="PLAIN"}=t,a=ud.stringifyString({type:o,value:e},{implicitKey:s,indent:i>0?" ".repeat(i):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}}),c=t.end??[{type:"newline",offset:-1,indent:i,source:`
|
|
109
|
+
`}];switch(a[0]){case"|":case">":{let u=a.indexOf(`
|
|
110
|
+
`),f=a.substring(0,u),d=a.substring(u+1)+`
|
|
111
|
+
`,p=[{type:"block-scalar-header",offset:n,indent:i,source:f}];return dd(p,c)||p.push({type:"newline",offset:-1,indent:i,source:`
|
|
112
|
+
`}),{type:"block-scalar",offset:n,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:n,indent:i,source:a,end:c};case"'":return{type:"single-quoted-scalar",offset:n,indent:i,source:a,end:c};default:return{type:"scalar",offset:n,indent:i,source:a,end:c}}}function kw(e,t,s={}){let{afterKey:i=!1,implicitKey:r=!1,inFlow:n=!1,type:o}=s,a="indent"in e?e.indent:null;if(i&&typeof a=="number"&&(a+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let u=e.props[0];if(u.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=u.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let c=ud.stringifyString({type:o,value:t},{implicitKey:r||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}});switch(c[0]){case"|":case">":vw(e,c);break;case'"':$o(e,c,"double-quoted-scalar");break;case"'":$o(e,c,"single-quoted-scalar");break;default:$o(e,c,"scalar")}}function vw(e,t){let s=t.indexOf(`
|
|
113
|
+
`),i=t.substring(0,s),r=t.substring(s+1)+`
|
|
114
|
+
`;if(e.type==="block-scalar"){let n=e.props[0];if(n.type!=="block-scalar-header")throw new Error("Invalid block scalar header");n.source=i,e.source=r}else{let{offset:n}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:n,indent:o,source:i}];dd(a,"end"in e?e.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
|
|
115
|
+
`});for(let c of Object.keys(e))c!=="type"&&c!=="offset"&&delete e[c];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:r})}}function dd(e,t){if(t)for(let s of t)switch(s.type){case"space":case"comment":e.push(s);break;case"newline":return e.push(s),!0}return!1}function $o(e,t,s){switch(e.type){case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":e.type=s,e.source=t;break;case"block-scalar":{let i=e.props.slice(1),r=t.length;e.props[0].type==="block-scalar-header"&&(r-=e.props[0].source.length);for(let n of i)n.offset+=r;delete e.props,Object.assign(e,{type:s,source:t,end:i});break}case"block-map":case"block-seq":{let r={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
|
|
116
|
+
`};delete e.items,Object.assign(e,{type:s,source:t,end:[r]});break}default:{let i="indent"in e?e.indent:-1,r="end"in e&&Array.isArray(e.end)?e.end.filter(n=>n.type==="space"||n.type==="comment"||n.type==="newline"):[];for(let n of Object.keys(e))n!=="type"&&n!=="offset"&&delete e[n];Object.assign(e,{type:s,indent:i,source:t,end:r})}}}nr.createScalarToken=ww;nr.resolveAsScalar=bw;nr.setScalarValue=kw});var md=N(pd=>{"use strict";var Sw=e=>"type"in e?ar(e):or(e);function ar(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=ar(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=or(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=or(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=or(e);if(e.end)for(let s of e.end)t+=s.source;return t}default:{let t=e.source;if("end"in e&&e.end)for(let s of e.end)t+=s.source;return t}}}function or({start:e,key:t,sep:s,value:i}){let r="";for(let n of e)r+=n.source;if(t&&(r+=ar(t)),s)for(let n of s)r+=n.source;return i&&(r+=ar(i)),r}pd.stringify=Sw});var bd=N(yd=>{"use strict";var xo=Symbol("break visit"),$w=Symbol("skip children"),hd=Symbol("remove item");function lt(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),gd(Object.freeze([]),e,t)}lt.BREAK=xo;lt.SKIP=$w;lt.REMOVE=hd;lt.itemAtPath=(e,t)=>{let s=e;for(let[i,r]of t){let n=s?.[i];if(n&&"items"in n)s=n.items[r];else return}return s};lt.parentCollection=(e,t)=>{let s=lt.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],r=s?.[i];if(r&&"items"in r)return r;throw new Error("Parent collection not found")};function gd(e,t,s){let i=s(t,e);if(typeof i=="symbol")return i;for(let r of["key","value"]){let n=t[r];if(n&&"items"in n){for(let o=0;o<n.items.length;++o){let a=gd(Object.freeze(e.concat([[r,o]])),n.items[o],s);if(typeof a=="number")o=a-1;else{if(a===xo)return xo;a===hd&&(n.items.splice(o,1),o-=1)}}typeof i=="function"&&r==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}yd.visit=lt});var lr=N(pe=>{"use strict";var Eo=fd(),xw=md(),Ew=bd(),Po="\uFEFF",Io="",Co="",Lo="",Pw=e=>!!e&&"items"in e,Iw=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Cw(e){switch(e){case Po:return"<BOM>";case Io:return"<DOC>";case Co:return"<FLOW_END>";case Lo:return"<SCALAR>";default:return JSON.stringify(e)}}function Lw(e){switch(e){case Po:return"byte-order-mark";case Io:return"doc-mode";case Co:return"flow-error-end";case Lo:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
117
117
|
`:case`\r
|
|
118
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}
|
|
119
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
120
|
-
\r `),
|
|
118
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}pe.createScalarToken=Eo.createScalarToken;pe.resolveAsScalar=Eo.resolveAsScalar;pe.setScalarValue=Eo.setScalarValue;pe.stringify=xw.stringify;pe.visit=Ew.visit;pe.BOM=Po;pe.DOCUMENT=Io;pe.FLOW_END=Co;pe.SCALAR=Lo;pe.isCollection=Pw;pe.isScalar=Iw;pe.prettyToken=Cw;pe.tokenType=Lw});var No=N(kd=>{"use strict";var $s=lr();function Ee(e){switch(e){case void 0:case" ":case`
|
|
119
|
+
`:case"\r":case" ":return!0;default:return!1}}var wd=new Set("0123456789ABCDEFabcdef"),Aw=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),cr=new Set(",[]{}"),Rw=new Set(` ,[]{}
|
|
120
|
+
\r `),Ao=e=>!e||Rw.has(e),Ro=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(t,s=!1){if(t){if(typeof t!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+t:t,this.lineEndPos=null}this.atEnd=!s;let i=this.next??"stream";for(;i&&(s||this.hasChars(1));)i=yield*this.parseNext(i)}atLineEnd(){let t=this.pos,s=this.buffer[t];for(;s===" "||s===" ";)s=this.buffer[++t];return!s||s==="#"||s===`
|
|
121
121
|
`?!0:s==="\r"?this.buffer[t+1]===`
|
|
122
|
-
`:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let s=this.buffer[t];if(this.indentNext>0){let i=0;for(;s===" ";)s=this.buffer[++i+t];if(s==="\r"){let
|
|
123
|
-
`||!
|
|
124
|
-
`||i>=this.indentNext||!s&&!this.atEnd?t+i:-1}if(s==="-"||s==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&
|
|
125
|
-
`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]
|
|
126
|
-
`,this.pos);if(
|
|
127
|
-
`,
|
|
128
|
-
`:t=
|
|
129
|
-
`)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(s>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=s:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let
|
|
130
|
-
`,
|
|
131
|
-
`;)i=this.buffer[++
|
|
132
|
-
`&&
|
|
133
|
-
`?(i+=1,
|
|
134
|
-
`,
|
|
135
|
-
`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&
|
|
122
|
+
`:!1}charAt(t){return this.buffer[this.pos+t]}continueScalar(t){let s=this.buffer[t];if(this.indentNext>0){let i=0;for(;s===" ";)s=this.buffer[++i+t];if(s==="\r"){let r=this.buffer[i+t+1];if(r===`
|
|
123
|
+
`||!r&&!this.atEnd)return t+i+1}return s===`
|
|
124
|
+
`||i>=this.indentNext||!s&&!this.atEnd?t+i:-1}if(s==="-"||s==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&Ee(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
|
|
125
|
+
`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===$s.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let s=t.length,i=t.indexOf("#");for(;i!==-1;){let n=t[i-1];if(n===" "||n===" "){s=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let n=t[s-1];if(n===" "||n===" ")s-=1;else break}let r=(yield*this.pushCount(s))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-r),this.pushNewline(),"stream"}if(this.atLineEnd()){let s=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-s),yield*this.pushNewline(),"stream"}return yield $s.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let s=this.peek(3);if((s==="---"||s==="...")&&Ee(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,s==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!Ee(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,s]=this.peek(2);if(!s&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&Ee(s)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,"block-start"}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let s=yield*this.pushIndicators();switch(t[s]){case"#":yield*this.pushCount(t.length-s);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(Ao),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return s+=yield*this.parseBlockScalarHeader(),s+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-s),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,s,i=-1;do t=yield*this.pushNewline(),t>0?(s=yield*this.pushSpaces(!1),this.indentValue=i=s):s=0,s+=yield*this.pushSpaces(!0);while(t+s>0);let r=this.getLine();if(r===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&r[0]!=="#"||i===0&&(r.startsWith("---")||r.startsWith("..."))&&Ee(r[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(r[0]==="]"||r[0]==="}")))return this.flowLevel=0,yield $s.FLOW_END,yield*this.parseLineStart();let n=0;for(;r[n]===",";)n+=yield*this.pushCount(1),n+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(n+=yield*this.pushIndicators(),r[n]){case void 0:return"flow";case"#":return yield*this.pushCount(r.length-n),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Ao),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||Ee(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),s=this.buffer.indexOf(t,this.pos+1);if(t==="'")for(;s!==-1&&this.buffer[s+1]==="'";)s=this.buffer.indexOf("'",s+2);else for(;s!==-1;){let n=0;for(;this.buffer[s-1-n]==="\\";)n+=1;if(n%2===0)break;s=this.buffer.indexOf('"',s+1)}let i=this.buffer.substring(0,s),r=i.indexOf(`
|
|
126
|
+
`,this.pos);if(r!==-1){for(;r!==-1;){let n=this.continueScalar(r+1);if(n===-1)break;r=i.indexOf(`
|
|
127
|
+
`,n)}r!==-1&&(s=r-(i[r-1]==="\r"?2:1))}if(s===-1){if(!this.atEnd)return this.setNext("quoted-scalar");s=this.buffer.length}return yield*this.pushToIndex(s+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let t=this.pos;for(;;){let s=this.buffer[++t];if(s==="+")this.blockScalarKeep=!0;else if(s>"0"&&s<="9")this.blockScalarIndent=Number(s)-1;else if(s!=="-")break}return yield*this.pushUntil(s=>Ee(s)||s==="#")}*parseBlockScalar(){let t=this.pos-1,s=0,i;e:for(let n=this.pos;i=this.buffer[n];++n)switch(i){case" ":s+=1;break;case`
|
|
128
|
+
`:t=n,s=0;break;case"\r":{let o=this.buffer[n+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
129
|
+
`)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(s>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=s:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let n=this.continueScalar(t+1);if(n===-1)break;t=this.buffer.indexOf(`
|
|
130
|
+
`,n)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let r=t+1;for(i=this.buffer[r];i===" ";)i=this.buffer[++r];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
|
|
131
|
+
`;)i=this.buffer[++r];t=r-1}else if(!this.blockScalarKeep)do{let n=t-1,o=this.buffer[n];o==="\r"&&(o=this.buffer[--n]);let a=n;for(;o===" ";)o=this.buffer[--n];if(o===`
|
|
132
|
+
`&&n>=this.pos&&n+1+s>a)t=n;else break}while(!0);return yield $s.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,s=this.pos-1,i=this.pos-1,r;for(;r=this.buffer[++i];)if(r===":"){let n=this.buffer[i+1];if(Ee(n)||t&&cr.has(n))break;s=i}else if(Ee(r)){let n=this.buffer[i+1];if(r==="\r"&&(n===`
|
|
133
|
+
`?(i+=1,r=`
|
|
134
|
+
`,n=this.buffer[i+1]):s=i),n==="#"||t&&cr.has(n))break;if(r===`
|
|
135
|
+
`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&cr.has(r))break;s=i}return!r&&!this.atEnd?this.setNext("plain-scalar"):(yield $s.SCALAR,yield*this.pushToIndex(s+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,s){let i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(s&&(yield""),0)}*pushIndicators(){let t=0;e:for(;;){switch(this.charAt(0)){case"!":t+=yield*this.pushTag(),t+=yield*this.pushSpaces(!0);continue e;case"&":t+=yield*this.pushUntil(Ao),t+=yield*this.pushSpaces(!0);continue e;case"-":case"?":case":":{let s=this.flowLevel>0,i=this.charAt(1);if(Ee(i)||s&&cr.has(i)){s?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,t+=yield*this.pushCount(1),t+=yield*this.pushSpaces(!0);continue e}}}break e}return t}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,s=this.buffer[t];for(;!Ee(s)&&s!==">";)s=this.buffer[++t];return yield*this.pushToIndex(s===">"?t+1:t,!1)}else{let t=this.pos+1,s=this.buffer[t];for(;s;)if(Aw.has(s))s=this.buffer[++t];else if(s==="%"&&wd.has(this.buffer[t+1])&&wd.has(this.buffer[t+2]))s=this.buffer[t+=3];else break;return yield*this.pushToIndex(t,!1)}}*pushNewline(){let t=this.buffer[this.pos];return t===`
|
|
136
136
|
`?yield*this.pushCount(1):t==="\r"&&this.charAt(1)===`
|
|
137
|
-
`?yield*this.pushCount(2):0}*pushSpaces(t){let s=this.pos-1,i;do i=this.buffer[++s];while(i===" "||t&&i===" ");let
|
|
137
|
+
`?yield*this.pushCount(2):0}*pushSpaces(t){let s=this.pos-1,i;do i=this.buffer[++s];while(i===" "||t&&i===" ");let r=s-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=s),r}*pushUntil(t){let s=this.pos,i=this.buffer[s];for(;!t(i);)i=this.buffer[++s];return yield*this.pushToIndex(s,!1)}};kd.Lexer=Ro});var Oo=N(vd=>{"use strict";var To=class{constructor(){this.lineStarts=[],this.addNewLine=t=>this.lineStarts.push(t),this.linePos=t=>{let s=0,i=this.lineStarts.length;for(;s<i;){let n=s+i>>1;this.lineStarts[n]<t?s=n+1:i=n}if(this.lineStarts[s]===t)return{line:s+1,col:1};if(s===0)return{line:0,col:t};let r=this.lineStarts[s-1];return{line:s,col:t-r+1}}}};vd.LineCounter=To});var Do=N(Pd=>{"use strict";var Nw=ii("process"),Sd=lr(),Tw=No();function ze(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function $d(e){for(let t=0;t<e.length;++t)switch(e[t].type){case"space":case"comment":case"newline":break;default:return t}return-1}function Ed(e){switch(e?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function ur(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function Nt(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function dr(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let s=0;s<t.length;++s)e.push(t[s])}function xd(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!ze(t.start,"explicit-key-ind")&&!ze(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,Ed(t.value)?t.value.end?dr(t.value.end,t.sep):t.value.end=t.sep:dr(t.start,t.sep),delete t.sep)}var Mo=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Tw.Lexer,this.onNewLine=t}*parse(t,s=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(t,s))yield*this.next(i);s||(yield*this.end())}*next(t){if(this.source=t,Nw.env.LOG_TOKENS&&console.log("|",Sd.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let s=Sd.tokenType(t);if(s)if(s==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=s,yield*this.step(),s){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+t.length);break;case"space":this.atNewLine&&t[0]===" "&&(this.indent+=t.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=t.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=t.length}else{let i=`Not a YAML token: ${t}`;yield*this.pop({type:"error",offset:this.offset,message:i,source:t}),this.offset+=t.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let t=this.peek(1);if(this.type==="doc-end"&&t?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!t)return yield*this.stream();switch(t.type){case"document":return yield*this.document(t);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(t);case"block-scalar":return yield*this.blockScalar(t);case"block-map":return yield*this.blockMap(t);case"block-seq":return yield*this.blockSequence(t);case"flow-collection":return yield*this.flowCollection(t);case"doc-end":return yield*this.documentEnd(t)}yield*this.pop()}peek(t){return this.stack[this.stack.length-t]}*pop(t){let s=t??this.stack.pop();if(!s)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield s;else{let i=this.peek(1);switch(s.type==="block-scalar"?s.indent="indent"in i?i.indent:0:s.type==="flow-collection"&&i.type==="document"&&(s.indent=0),s.type==="flow-collection"&&xd(s),i.type){case"document":i.value=s;break;case"block-scalar":i.props.push(s);break;case"block-map":{let r=i.items[i.items.length-1];if(r.value){i.items.push({start:[],key:s,sep:[]}),this.onKeyLine=!0;return}else if(r.sep)r.value=s;else{Object.assign(r,{key:s,sep:[]}),this.onKeyLine=!r.explicitKey;return}break}case"block-seq":{let r=i.items[i.items.length-1];r.value?i.items.push({start:[],value:s}):r.value=s;break}case"flow-collection":{let r=i.items[i.items.length-1];!r||r.value?i.items.push({start:[],key:s,sep:[]}):r.sep?r.value=s:Object.assign(r,{key:s,sep:[]});return}default:yield*this.pop(),yield*this.pop(s)}if((i.type==="document"||i.type==="block-map"||i.type==="block-seq")&&(s.type==="block-map"||s.type==="block-seq")){let r=s.items[s.items.length-1];r&&!r.sep&&!r.value&&r.start.length>0&&$d(r.start)===-1&&(s.indent===0||r.start.every(n=>n.type!=="comment"||n.indent<s.indent))&&(i.type==="document"?i.end=r.start:i.items.push({start:r.start}),s.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{let t={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&t.start.push(this.sourceToken),this.stack.push(t);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(t){if(t.value)return yield*this.lineEnd(t);switch(this.type){case"doc-start":{$d(t.start)!==-1?(yield*this.pop(),yield*this.step()):t.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":t.start.push(this.sourceToken);return}let s=this.startBlockValue(t);s?this.stack.push(s):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(t){if(this.type==="map-value-ind"){let s=ur(this.peek(2)),i=Nt(s),r;t.end?(r=t.end,r.push(this.sourceToken),delete t.end):r=[this.sourceToken];let n={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:i,key:t,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=n}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let s=this.source.indexOf(`
|
|
138
138
|
`)+1;for(;s!==0;)this.onNewLine(this.offset+s),s=this.source.indexOf(`
|
|
139
|
-
`,s)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let s=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,s.value){let i="end"in s.value?s.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)t.items.push({start:[this.sourceToken]});else if(s.sep)s.sep.push(this.sourceToken);else{if(this.atIndentedComment(s.start,t.indent)){let
|
|
139
|
+
`,s)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let s=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,s.value){let i="end"in s.value?s.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)t.items.push({start:[this.sourceToken]});else if(s.sep)s.sep.push(this.sourceToken);else{if(this.atIndentedComment(s.start,t.indent)){let r=t.items[t.items.length-2]?.value?.end;if(Array.isArray(r)){dr(r,s.start),r.push(this.sourceToken),t.items.pop();return}}s.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let i=!this.onKeyLine&&this.indent===t.indent,r=i&&(s.sep||s.explicitKey)&&this.type!=="seq-item-ind",n=[];if(r&&s.sep&&!s.value){let o=[];for(let a=0;a<s.sep.length;++a){let c=s.sep[a];switch(c.type){case"newline":o.push(a);break;case"space":break;case"comment":c.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(n=s.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":r||s.value?(n.push(this.sourceToken),t.items.push({start:n}),this.onKeyLine=!0):s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"explicit-key-ind":!s.sep&&!s.explicitKey?(s.start.push(this.sourceToken),s.explicitKey=!0):r||s.value?(n.push(this.sourceToken),t.items.push({start:n,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(s.explicitKey)if(s.sep)if(s.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(ze(s.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:n,key:null,sep:[this.sourceToken]}]});else if(Ed(s.key)&&!ze(s.sep,"newline")){let o=Nt(s.start),a=s.key,c=s.sep;c.push(this.sourceToken),delete s.key,delete s.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:c}]})}else n.length>0?s.sep=s.sep.concat(n,this.sourceToken):s.sep.push(this.sourceToken);else if(ze(s.start,"newline"))Object.assign(s,{key:null,sep:[this.sourceToken]});else{let o=Nt(s.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else s.sep?s.value||r?t.items.push({start:n,key:null,sep:[this.sourceToken]}):ze(s.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):s.sep.push(this.sourceToken):Object.assign(s,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);r||s.value?(t.items.push({start:n,key:o,sep:[]}),this.onKeyLine=!0):s.sep?this.stack.push(o):(Object.assign(s,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(t);if(o){if(o.type==="block-seq"){if(!s.explicitKey&&s.sep&&!ze(s.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&t.items.push({start:n});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let s=t.items[t.items.length-1];switch(this.type){case"newline":if(s.value){let i="end"in s.value?s.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(s.start,t.indent)){let r=t.items[t.items.length-2]?.value?.end;if(Array.isArray(r)){dr(r,s.start),r.push(this.sourceToken),t.items.pop();return}}s.start.push(this.sourceToken)}return;case"anchor":case"tag":if(s.value||this.indent<=t.indent)break;s.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;s.value||ze(s.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):s.start.push(this.sourceToken);return}if(this.indent>t.indent){let i=this.startBlockValue(t);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let s=t.items[t.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!s||s.sep?t.items.push({start:[this.sourceToken]}):s.start.push(this.sourceToken);return;case"map-value-ind":!s||s.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):s.sep?s.sep.push(this.sourceToken):Object.assign(s,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!s||s.value?t.items.push({start:[this.sourceToken]}):s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let r=this.flowScalar(this.type);!s||s.value?t.items.push({start:[],key:r,sep:[]}):s.sep?this.stack.push(r):Object.assign(s,{key:r,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===t.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let r=ur(i),n=Nt(r);xd(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:n,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let s=this.source.indexOf(`
|
|
140
140
|
`)+1;for(;s!==0;)this.onNewLine(this.offset+s),s=this.source.indexOf(`
|
|
141
|
-
`,s)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let s=
|
|
142
|
-
|
|
143
|
-
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var Yi=class{selected;cursor;scrollOffset;pageSize;itemCount;filter;searchActive;filteredMap;constructor(t,s){this.selected=t.map(i=>i.checked),this.cursor=1,this.scrollOffset=0,this.pageSize=s,this.itemCount=t.length,this.filter="",this.searchActive=!1,this.filteredMap=t.map((i,n)=>n)}get totalRows(){return this.filteredMap.length+1}applyFilter(t){if(this.filter==="")this.filteredMap=t.map((s,i)=>i);else{let s=this.filter.toLowerCase();this.filteredMap=[];for(let i=0;i<t.length;i++)(t[i].label.toLowerCase()+" "+(t[i].hint?.toLowerCase()??"")).includes(s)&&this.filteredMap.push(i)}this.cursor>=this.totalRows&&(this.cursor=Math.max(0,this.totalRows-1)),this.scrollOffset>0&&this.scrollOffset>=this.totalRows&&(this.scrollOffset=Math.max(0,this.totalRows-this.pageSize))}cursorToOriginalIndex(){return this.cursor===0?-1:this.filteredMap[this.cursor-1]??-1}toggleCurrent(){if(this.cursor===0)this.toggleAll();else{let t=this.cursorToOriginalIndex();t>=0&&(this.selected[t]=!this.selected[t])}}toggleAll(){let t=this.filteredMap,i=!t.every(n=>this.selected[n]);for(let n of t)this.selected[n]=i}moveUp(){this.cursor>0?this.cursor--:this.cursor=this.totalRows-1,this.adjustScroll()}moveDown(){this.cursor<this.totalRows-1?this.cursor++:this.cursor=0,this.adjustScroll()}getSelectedIndices(){let t=[];for(let s=0;s<this.selected.length;s++)this.selected[s]&&t.push(s);return t}getVisibleRange(){let t=this.scrollOffset,s=Math.min(this.scrollOffset+this.pageSize,this.totalRows);return{start:t,end:s}}adjustScroll(){this.cursor<this.scrollOffset?this.scrollOffset=this.cursor:this.cursor>=this.scrollOffset+this.pageSize&&(this.scrollOffset=this.cursor-this.pageSize+1)}};function kf(e,t,s){let i=[];if(e.searchActive||e.filter!==""){let c=u.cyan("/"),f=e.filter,d=e.searchActive?u.cyan("\u2588"):"";i.push(` ${c}${f}${d}`),e.filteredMap.length===0&&i.push(u.dim(" No matches found")),i.push("")}let{start:n,end:r}=e.getVisibleRange();n>0&&i.push(u.dim(` ... ${n} more above`));for(let c=n;c<r;c++){let d=c===e.cursor?u.cyan(">"):" ";if(c===0){let p=e.filteredMap,y=p.length>0&&p.every(g=>e.selected[g])?u.green("[*]"):"[ ]",h=e.filter!==""?`Select All Matching (${e.filteredMap.length})`:"Select All / Deselect All";i.push(`${d} ${y} ${u.bold(h)}`)}else{let p=e.filteredMap[c-1],m=t[p],h=e.selected[p]?u.green("[*]"):"[ ]",g=`${d} ${h} `,b=7,w=u.bold(m.label),k=m.label.length;if(m.hint){let S=s-b-k-2;if(S>10){let v=Gi(m.hint,S);i.push(`${g}${w} ${u.dim(v)}`)}else{let v=Gi(m.label,s-b);i.push(`${g}${u.bold(v)}`)}}else{let S=Gi(m.label,s-b);i.push(`${g}${u.bold(S)}`)}}}let o=e.totalRows-r;o>0&&i.push(u.dim(` ... ${o} more below`));let a=e.getSelectedIndices().length,l=e.filter!==""?` matching: ${e.filteredMap.length}/${e.itemCount}`:"";return i.push(""),e.searchActive?i.push(u.dim(` ${a} of ${e.itemCount} selected${l} | Type to filter Esc Clear Enter Done searching`)):i.push(u.dim(` ${a} of ${e.itemCount} selected${l} | \u2191/\u2193 Navigate Space Toggle a All / Search Enter Confirm Esc Cancel`)),i}function Gi(e,t){return t<=0?"":e.length<=t?e:t<=3?e.slice(0,t):e.slice(0,t-3)+"..."}async function Xe(e){let{items:t}=e,s=e.pageSize??Math.min(t.length+1,15),i=new Yi(t,s),n=process.stderr,r=process.stdin,o=n.columns||80;typeof r.setRawMode=="function"&&r.setRawMode(!0),r.resume(),r.setEncoding("utf-8"),n.write("\x1B[?25l");let a=0;function l(){let c=kf(i,t,o);a>0&&n.write(`\x1B[${a}F`);let f=Math.max(c.length,a),d="";for(let p=0;p<f;p++)d+=`\x1B[2K${p<c.length?c[p]:""}
|
|
144
|
-
`;n.write(d),a=f}return l(),new Promise(c=>{let f="",d=null;function p(){r.removeListener("data",h),typeof r.setRawMode=="function"&&r.setRawMode(!1),r.pause(),n.write("\x1B[?25h"),d&&clearTimeout(d)}function m(g){p(),c(g)}function y(g){if(i.searchActive){if(g==="\x1B"){i.searchActive=!1,i.filter="",i.applyFilter(t),l();return}if(g==="\r"||g===`
|
|
145
|
-
`){i.searchActive=!1,l();return}if(g==="\x7F"||g==="\b"){i.filter.length>0?(i.filter=i.filter.slice(0,-1),i.applyFilter(t)):i.searchActive=!1,l();return}if(g===""){p(),process.kill(process.pid,"SIGINT");return}if(g==="\x1B[A"){i.moveUp(),l();return}if(g==="\x1B[B"){i.moveDown(),l();return}if(g===" "){i.toggleCurrent(),l();return}if(g.length===1&&g>=" "&&g<="~"){i.filter+=g,i.applyFilter(t),l();return}return}switch(g){case"\x1B[A":case"k":i.moveUp(),l();break;case"\x1B[B":case"j":i.moveDown(),l();break;case" ":i.toggleCurrent(),l();break;case"a":i.toggleAll(),l();break;case"/":i.searchActive=!0,l();break;case"\r":case`
|
|
146
|
-
`:m(i.getSelectedIndices());break;case"\x1B":i.filter!==""?(i.filter="",i.applyFilter(t),l()):m([]);break;case"\x7F":case"\b":i.filter.length>0&&(i.filter=i.filter.slice(0,-1),i.applyFilter(t),l());break;case"":p(),process.kill(process.pid,"SIGINT");break}}function h(g){if(f.length>0){if(f+=g,d&&clearTimeout(d),f.length>=3&&f[1]==="["){let w=f.slice(0,3),k=f.slice(3);f="",y(w),k&&h(k);return}let b=f;f="",y("\x1B");for(let w=1;w<b.length;w++)y(b[w]);return}for(let b=0;b<g.length;b++){let w=g[b];if(w==="\x1B"){let k=g.slice(b);if(k.length>=3&&k[1]==="[")y(k.slice(0,3)),b+=2;else if(k.length>=2){f=k,d=setTimeout(()=>{let S=f;f="",y("\x1B");for(let v=1;v<S.length;v++)y(S[v])},50);return}else{f="\x1B",d=setTimeout(()=>{f="",y("\x1B")},50);return}}else y(w)}}r.on("data",h)})}var Se=$f(Sf),If=/^[a-zA-Z0-9_-]+$/,Rf=/^[a-zA-Z0-9._-]+$/,Lf=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,ta=128,Of=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function Xi(e){return e.startsWith("/")||e.startsWith("./")||e.startsWith(".\\")||e.startsWith("../")||e.startsWith("..\\")||e.startsWith("~/")||e.startsWith("~\\")||e==="~"||e==="."||e===".."||/^[a-zA-Z]:[/\\]/.test(e)}async function na(e){if(!e.includes("/")&&!e.includes("\\"))return!1;try{return(await sa(Qi(e))).isDirectory()}catch{return!1}}function Tf(e){let t;e==="~"?t=Zo():e.startsWith("~/")||e.startsWith("~\\")?t=Qi(Zo(),e.slice(2)):t=Qi(e);let s=ia(t);return P(`install: parsed local source -> path=${t}`),{owner:"local",repo:s,ref:null,subpath:null,cloneUrl:"",sshCloneUrl:"",isLocal:!0,localPath:t}}function Fe(e){if(Xi(e))return Tf(e);let t=Of.exec(e);if(t){let[,d,p,m]=t,y=p.endsWith(".git")?p.slice(0,-4):p;e=`github:${d}/${y}${m?`#${m}`:""}`}if(!e.startsWith("github:"))throw new Error(`Invalid source format. Got: "${e}"
|
|
147
|
-
Supported formats:
|
|
148
|
-
github:owner/repo[#ref]
|
|
149
|
-
github:owner/repo#ref:path
|
|
150
|
-
https://github.com/owner/repo
|
|
151
|
-
https://github.com/owner/repo/tree/branch/path/to/skill
|
|
152
|
-
/path/to/local/skill
|
|
153
|
-
./relative/path/to/skill`);let s=e.slice(7),i=s.indexOf("#"),n,r=null,o=null;if(i!==-1){n=s.slice(0,i);let d=s.slice(i+1);if(!d)throw new Error("Invalid source: ref cannot be empty after #");let p=d.indexOf(":");if(p!==-1){if(r=d.slice(0,p),!r)throw new Error("Invalid source: ref cannot be empty before :");o=d.slice(p+1)||null}else r=d}else{let d=s.indexOf(":");d!==-1?(n=s.slice(0,d),o=s.slice(d+1)||null):n=s}let a=n.indexOf("/");if(a===-1)throw new Error(`Invalid source: format must be github:owner/repo. Got: "${e}"`);let l=n.slice(0,a),c=n.slice(a+1);if(!l)throw new Error("Invalid source: owner cannot be empty");if(!c)throw new Error("Invalid source: repo cannot be empty");if(!If.test(l))throw new Error(`Invalid source: owner contains invalid characters: "${l}". Allowed: [a-zA-Z0-9_-]`);if(!Rf.test(c))throw new Error(`Invalid source: repo contains invalid characters: "${c}". Allowed: [a-zA-Z0-9._-]`);let f={owner:l,repo:c,ref:r,subpath:o,cloneUrl:`https://github.com/${l}/${c}.git`,sshCloneUrl:`git@github.com:${l}/${c}.git`};return P(`install: parsed source -> owner=${l} repo=${c} ref=${r} subpath=${o}`),f}async function hs(e){if(e.subpath!==null||!e.ref||!e.ref.includes("/"))return e;try{let{stdout:t}=await Se("git",["ls-remote","--heads","--tags",e.cloneUrl],{timeout:15e3}),s=new Set;for(let n of t.split(`
|
|
154
|
-
`)){let r=n.match(/\trefs\/(?:heads|tags)\/(.+)$/);r&&s.add(r[1])}let i=e.ref.split("/");for(let n=1;n<i.length;n++){let r=i.slice(0,n).join("/");if(s.has(r)){let o=i.slice(n).join("/");return P(`install: resolved ref="${r}" subpath="${o}"`),{...e,ref:r,subpath:o||null}}}}catch(t){P(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function $e(e){if(!e)throw new Error("Invalid skill name: name cannot be empty");if(e.includes("\0"))throw new Error("Invalid skill name: contains unsafe characters (null byte)");if(e.includes(".."))throw new Error("Invalid skill name: contains unsafe characters (..)");if(e.includes("/")||e.includes("\\"))throw new Error("Invalid skill name: contains unsafe characters (path separator)");if(e.startsWith("."))throw new Error("Invalid skill name: must not start with a dot");if(e.length>ta)throw new Error(`Invalid skill name: exceeds maximum length of ${ta} characters`);if(!Lf.test(e))throw new Error(`Invalid skill name: "${e}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return e}function Zi(e){let t=e.split(/[/\\]/).filter(Boolean),s=t.length>0?t[t.length-1]:e;return $e(s)}function ra(e,t=Zi){let s=new Map;for(let i of e){let n=t(i),r=s.get(n);r?r.push(i):s.set(n,[i])}return[...s.entries()].filter(([,i])=>i.length>1).map(([i,n])=>({name:i,paths:n}))}async function _e(){try{await Se("git",["--version"]),P("install: git available")}catch{throw new Error("git is required for installing skills. Install git from https://git-scm.com")}}function Mf(e){if(e.killed)return!1;let t=(e.stderr||e.message||"").toLowerCase();return t.includes("authentication failed")||t.includes("could not read username")||t.includes("repository not found")||t.includes("returned error: 403")||t.includes("returned error: 401")||t.includes("terminal prompts disabled")||t.includes("permission denied")}function ds(e){return e.killed?"Clone timed out after 60 seconds":`Clone failed: ${e.stderr||e.message}`}async function zi(e,t,s){if(t!==null&&/^[0-9a-f]{40}$/i.test(t))return await Se("git",["clone","--no-checkout",e,s],{timeout:6e4}),await Se("git",["checkout",t],{cwd:s,timeout:3e4}),s;let n=["clone","--depth","1"];return t&&n.push("--branch",t),n.push(e,s),await Se("git",n,{timeout:6e4}),s}async function je(e,t="auto"){P(`install: cloning ${e.owner}/${e.repo}${e.ref?` (ref: ${e.ref})`:""} (transport: ${t})`);let s=await Xo(ce(ea(),"asm-install-"));if(t==="ssh"||t==="https"){let i=t==="ssh"?e.sshCloneUrl:e.cloneUrl;try{return await zi(i,e.ref,s)}catch(n){throw await le(s),new Error(ds(n))}}try{return await zi(e.cloneUrl,e.ref,s)}catch(i){if(!Mf(i))throw await le(s),new Error(ds(i));P("install: HTTPS clone failed with auth error, retrying with SSH..."),await le(s);let n=await Xo(ce(ea(),"asm-install-"));try{return await zi(e.sshCloneUrl,e.ref,n)}catch(r){throw await le(n),new Error(`Clone failed with both transports:
|
|
155
|
-
HTTPS: ${ds(i)}
|
|
156
|
-
SSH: ${ds(r)}`)}}}async function qe(e){let t=ce(e,"SKILL.md"),s;try{s=await fs(t,"utf-8")}catch{throw new Error("Not a valid skill: SKILL.md not found in repository root")}let i=Z(s),n=e.split(/[/\\]/).pop()||"unknown",r=i.name||n,o=ae(i);return P(`install: validated skill "${r}" v${o}`),{name:r,version:o,description:(i.description||"").replace(/\s*\n\s*/g," ").trim(),effort:i.effort||i["metadata.effort"]||void 0}}async function gs(e,t=5){let s=[];try{let n=await fs(ce(e,"SKILL.md"),"utf-8"),r=Z(n);s.push({relPath:"",name:r.name||ia(e),version:ae(r),description:(r.description||"").replace(/\s*\n\s*/g," ").trim(),effort:r.effort||r["metadata.effort"]||void 0,license:(r.license||"").trim(),creator:(r["metadata.creator"]||"").trim(),compatibility:(r.compatibility||"").trim(),allowedTools:_i(r),tokenCount:bt(n)})}catch{}async function i(n,r,o){let a;try{a=await xf(n)}catch{return}for(let l of a){if(l===".git"||l==="node_modules")continue;let c=ce(n,l);try{if(!(await sa(c)).isDirectory())continue}catch{continue}let f=r?`${r}/${l}`:l,d=o+1,p=ce(c,"SKILL.md");try{let m=await fs(p,"utf-8"),y=Z(m);s.push({relPath:f,name:y.name||l,version:ae(y),description:(y.description||"").replace(/\s*\n\s*/g," ").trim(),effort:y.effort||y["metadata.effort"]||void 0,license:(y.license||"").trim(),creator:(y["metadata.creator"]||"").trim(),compatibility:(y.compatibility||"").trim(),allowedTools:_i(y),tokenCount:bt(m)})}catch{d<t&&await i(c,f,d)}}}return await i(e,"",0),s.sort((n,r)=>n.name.localeCompare(r.name)),s}async function Df(e,t=Se){let s=ce(e,"scripts"),i=ce(s,"package.json");try{await ms(i)}catch{P(`install: no scripts/package.json in ${e}; skipping npm install`);return}P(`install: installing script dependencies in ${s}`);try{await t("npm",["install"],{cwd:s,timeout:12e4})}catch(n){throw new Error(`Installed skill, but failed to install dependencies in scripts/: ${n.stderr||n.message}`)}}var Ff=[{category:"Shell commands",pattern:/\b(bash|sh\s+-c)\b/},{category:"Shell commands",pattern:/\bexec\(/},{category:"Shell commands",pattern:/\bchild_process\b/},{category:"Shell commands",pattern:/\bBun\.spawn\b/},{category:"Code execution",pattern:/\beval\(/},{category:"Code execution",pattern:/\bFunction\(/},{category:"Code execution",pattern:/\bnew\s+Function\b/},{category:"Credentials",pattern:/\b(API_KEY|SECRET|TOKEN|PASSWORD)\s*[=:]/},{category:"External URLs",pattern:/https?:\/\//}];async function oa(e){let t=[],s=await us(e);for(let{relPath:i,content:n}of s){let r=n.split(`
|
|
157
|
-
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of Ff)if(l.test(r[o])){let c=r[o].trim();t.push({category:a,file:i,line:o+1,match:c.length>100?c.slice(0,100)+"\u2026":c})}}return t}async function ys(e){let t=e.source.isLocal?`local:${e.source.localPath}`:`github:${e.source.owner}/${e.source.repo}${e.source.ref?`#${e.source.ref}`:""}${e.source.subpath?`:${e.source.subpath}`:""}`;if(e.force)try{await ms(e.targetDir),await ps(e.targetDir,{recursive:!0,force:!0})}catch{}let s=e.sourceDir;try{await Ef(s,e.targetDir,{recursive:!0})}catch(a){throw new Error(`Failed to install: ${a.message}`)}let i=ce(e.targetDir,".git");try{await ps(i,{recursive:!0,force:!0})}catch{}P(`install: copied files to ${e.targetDir}`);let n=ce(e.targetDir,"SKILL.md");try{await ms(n)}catch{throw new Error("Installation verification failed: SKILL.md not found at target")}await Df(e.targetDir);let r=await fs(n,"utf-8"),o=Z(r);return{success:!0,path:e.targetDir,name:o.name||e.skillName,version:ae(o),provider:e.providerLabel,source:t}}async function aa(e,t){let s=await ys(e);for(let i of t){if(i.name===e.providerName)continue;let n=e.scope==="project"?i.project:i.global,r=oe(n),o=ce(r,e.skillName);await Pf(r,{recursive:!0});try{if((await Cf(o)).isSymbolicLink())await ps(o);else{P(`install: skipping ${o} \u2014 existing non-symlink directory`);continue}}catch{}let a=Nf(r,e.targetDir);await Af(a,o,"dir"),P(`install: symlinked ${o} -> ${a}`)}return s.provider=`All (${t.map(i=>i.label).join(", ")})`,s}async function le(e){try{await ps(e,{recursive:!0,force:!0})}catch{}}async function la(){try{await Se("npx",["--version"]),P("install: npx available")}catch{throw new Error("npx is required for Vercel method installation. Install Node.js from https://nodejs.org")}}async function ca(e,t){let s=["--yes","skills","add",e];t&&s.push("--skill",t),P(`install: running npx ${s.join(" ")}`);try{let i=await Se("npx",s,{timeout:12e4});return{stdout:i.stdout,stderr:i.stderr}}catch(i){let n=i.stderr||i.message||"";throw new Error(`npx skills add failed: ${n}`)}}function ua(e){if(e.isLocal)return e.localPath;let t=`https://github.com/${e.owner}/${e.repo}`;return e.ref?`${t}/tree/${e.ref}${e.subpath?`/${e.subpath}`:""}`:t}async function Ze(e,t,s){let i=e.providers.filter(m=>m.enabled);if(t==="all"){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");return{provider:i.find(y=>y.name==="agents")||i[0],allProviders:i}}if(t){let m=e.providers.find(y=>y.name===t);if(!m){let y=e.providers.map(h=>h.name).join(", ");throw new Error(`Unknown provider: "${t}". Valid providers: ${y}, all`)}if(!m.enabled)throw new Error(`Provider "${t}" is disabled. Enable it in your config or choose another provider.`);return{provider:m,allProviders:null}}if(i.length===1)return{provider:i[0],allProviders:null};if(!s){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");let m=i.map(y=>y.name).join(", ");throw new Error(`--tool (or --provider) is required in non-interactive mode. Available: ${m}, all`)}let n=e.preferences.selectedTools,o=n&&n.length>0?new Set(n):null,a=e.providers.map(m=>({label:`${m.label} (${m.name})`,hint:m.global,checked:o?o.has(m.name):m.name==="agents"})),l=await Xe({items:a});if(l.length===0)throw new Error("No tools selected. Aborting.");let c=l.map(m=>e.providers[m]),f=c.map(m=>m.name),{saveSelectedTools:d}=await import("./config-FRM3YOMA.js");return await d(f),c.length===1?{provider:c[0],allProviders:null}:{provider:c.find(m=>m.name==="agents")||c[0],allProviders:c}}function en(e,t,s,i,n,r,o="global"){let a=o==="project"?n.project:n.global,l=oe(a),c=ce(l,i);return{source:e,tempDir:t,sourceDir:s,targetDir:c,skillName:i,force:r,providerName:n.name,providerLabel:n.label,scope:o}}async function da(e,t){try{if(await ms(e),P(`install: target ${e} \u2014 conflict (exists)${t?", force overwrite":""}`),!t)throw new Error(`Skill already exists at: ${e}
|
|
158
|
-
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;P(`install: target ${e} \u2014 no conflict`)}}var eu=mo(Dr(),1);import{readFile as dy}from"fs/promises";import{join as fy}from"path";var Zc=500;function py(e){let t=e.split(`
|
|
159
|
-
`),s=!1,i=!1;for(let n of t){if(n.trim()==="---")if(s){i=!0;continue}else{s=!0;continue}if(i&&n.trim().length>0)return!0}return!1}function my(e){let t=e.split(`
|
|
141
|
+
`,s)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let s=ur(t),i=Nt(s);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let s=ur(t),i=Nt(s);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,s){return this.type!=="comment"||this.indent<=s?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Pd.Parser=Mo});var Rd=N(Es=>{"use strict";var Id=So(),Ow=gs(),xs=ws(),Mw=wn(),Dw=B(),_w=Oo(),Cd=Do();function Ld(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new _w.LineCounter||null,prettyErrors:t}}function Fw(e,t={}){let{lineCounter:s,prettyErrors:i}=Ld(t),r=new Cd.Parser(s?.addNewLine),n=new Id.Composer(t),o=Array.from(n.compose(r.parse(e)));if(i&&s)for(let a of o)a.errors.forEach(xs.prettifyError(e,s)),a.warnings.forEach(xs.prettifyError(e,s));return o.length>0?o:Object.assign([],{empty:!0},n.streamInfo())}function Ad(e,t={}){let{lineCounter:s,prettyErrors:i}=Ld(t),r=new Cd.Parser(s?.addNewLine),n=new Id.Composer(t),o=null;for(let a of n.compose(r.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new xs.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&s&&(o.errors.forEach(xs.prettifyError(e,s)),o.warnings.forEach(xs.prettifyError(e,s))),o}function jw(e,t,s){let i;typeof t=="function"?i=t:s===void 0&&t&&typeof t=="object"&&(s=t);let r=Ad(e,s);if(!r)return null;if(r.warnings.forEach(n=>Mw.warn(r.options.logLevel,n)),r.errors.length>0){if(r.options.logLevel!=="silent")throw r.errors[0];r.errors=[]}return r.toJS(Object.assign({reviver:i},s))}function qw(e,t,s){let i=null;if(typeof t=="function"||Array.isArray(t)?i=t:s===void 0&&t&&(s=t),typeof s=="string"&&(s=s.length),typeof s=="number"){let r=Math.round(s);s=r<1?void 0:r>8?{indent:8}:{indent:r}}if(e===void 0){let{keepUndefined:r}=s??t??{};if(!r)return}return Dw.isDocument(e)&&!i?e.toString(s):new Ow.Document(e,i,s).toString(s)}Es.parse=jw;Es.parseAllDocuments=Fw;Es.parseDocument=Ad;Es.stringify=qw});var Fo=N(V=>{"use strict";var Bw=So(),Uw=gs(),Vw=to(),_o=ws(),Kw=es(),Xe=B(),Gw=He(),Hw=X(),Jw=We(),Ww=Ye(),Yw=lr(),zw=No(),Xw=Oo(),Qw=Do(),fr=Rd(),Nd=zt();V.Composer=Bw.Composer;V.Document=Uw.Document;V.Schema=Vw.Schema;V.YAMLError=_o.YAMLError;V.YAMLParseError=_o.YAMLParseError;V.YAMLWarning=_o.YAMLWarning;V.Alias=Kw.Alias;V.isAlias=Xe.isAlias;V.isCollection=Xe.isCollection;V.isDocument=Xe.isDocument;V.isMap=Xe.isMap;V.isNode=Xe.isNode;V.isPair=Xe.isPair;V.isScalar=Xe.isScalar;V.isSeq=Xe.isSeq;V.Pair=Gw.Pair;V.Scalar=Hw.Scalar;V.YAMLMap=Jw.YAMLMap;V.YAMLSeq=Ww.YAMLSeq;V.CST=Yw;V.Lexer=zw.Lexer;V.LineCounter=Xw.LineCounter;V.Parser=Qw.Parser;V.parse=fr.parse;V.parseAllDocuments=fr.parseAllDocuments;V.parseDocument=fr.parseDocument;V.stringify=fr.stringify;V.visit=Nd.visit;V.visitAsync=Nd.visitAsync});import{access as mh,realpath as hh,stat as gh}from"fs/promises";import{constants as yh}from"fs";import{delimiter as bh,resolve as wh,sep as kh}from"path";var vh="asm";function Sh(e){if(!e)return[];let t=new Set,s=[];for(let i of e.split(bh)){let r=i.trim();if(!r)continue;let n=r.endsWith(kh)?r.slice(0,-1):r;t.has(n)||(t.add(n),s.push(n))}return s}async function $h(e){try{if(!(await gh(e)).isFile())return!1}catch{return!1}try{return await mh(e,yh.X_OK),!0}catch{return!1}}async function xh(e){try{return await hh(e)}catch{return e}}async function Eh(e=process.env.PATH){let t=new Set,s=[];for(let i of Sh(e)){let r=wh(i,vh);if(!await $h(r))continue;let n=await xh(r);t.has(n)||(t.add(n),s.push({path:r,realPath:n}))}return s}async function mi(e=process.env.PATH){let t=await Eh(e);if(t.length===0)return{resolved:null,shadowed:[]};let[s,...i]=t;return{resolved:s,shadowed:i}}var Od=ml(Fo(),1);import{readFile as Zw}from"fs/promises";import{join as ek}from"path";var Td=500;function tk(e){let t=e.split(`
|
|
142
|
+
`),s=!1,i=!1;for(let r of t){if(r.trim()==="---")if(s){i=!0;continue}else{s=!0;continue}if(i&&r.trim().length>0)return!0}return!1}function sk(e){let t=e.split(`
|
|
160
143
|
`),s=-1;for(let i=0;i<t.length;i++)if(t[i].trim()==="---")if(s===-1)s=i+1;else return t.slice(s,i).join(`
|
|
161
|
-
`);return null}function
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
license: ""
|
|
167
|
-
metadata:
|
|
168
|
-
version: 0.1.0
|
|
169
|
-
creator: ""
|
|
170
|
-
---
|
|
171
|
-
|
|
172
|
-
# ${e}
|
|
144
|
+
`);return null}function ik(e){let t=sk(e);if(t===null)return null;try{return(0,Od.parse)(t),null}catch(s){return s.message||"invalid YAML"}}async function Md(e){let t=[];(!e.description||e.description.trim()==="")&&t.push({category:"missing-description",message:"Skill has no description in SKILL.md frontmatter"}),(!e.version||e.version==="0.0.0")&&t.push({category:"missing-version",message:"Skill has no version (or default 0.0.0) in SKILL.md frontmatter"});try{let i=e._skillMdContent!==void 0?e._skillMdContent:await Zw(ek(e.path,"SKILL.md"),"utf-8");tk(i)||t.push({category:"empty-body",message:"SKILL.md contains only frontmatter with no body content"});let r=ik(i);r&&t.push({category:"invalid-yaml",message:`SKILL.md has invalid YAML frontmatter: ${r}`})}catch{}let s=e.fileCount;return s!==void 0&&s>Td&&t.push({category:"high-file-count",message:`Skill has ${s} files (threshold: ${Td})`}),t}function rk(e){switch(e){case"dangerous":return 3;case"warning":return 2;case"caution":return 1;default:return 0}}function pr(e){return{verdict:e.every(t=>t.verdict==="safe")?"safe":e.some(t=>t.verdict==="dangerous")?"dangerous":"warning",findings:e.map(t=>({skill:t.skillName,verdict:t.verdict,verdict_reason:t.verdictReason,total_files:t.totalFiles,total_lines:t.totalLines})),risk_score:e.reduce((t,s)=>t+rk(s.verdict),0)}}function $(e){console.error(l.red(`Error: ${e}`))}async function Ps(e){await Promise.all(e.map(async t=>{t.warnings=await Md(t)}))}function K(){return new Promise(e=>{let t="",s=!1;function i(){process.stdin.removeListener("data",n),process.stdin.removeListener("end",o),process.stdin.pause(),clearTimeout(a)}function r(c){s||(s=!0,i(),e(c))}function n(c){t+=c,t.includes(`
|
|
145
|
+
`)&&r(t.trim())}function o(){r(t.trim())}let a=setTimeout(()=>{r(t.trim())},3e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",n),process.stdin.on("end",o),process.stdin.resume()})}function mr(e,t){let s=new Map;for(let r of t){let n=s.get(r.realPath)??[];n.push(r),s.set(r.realPath,n)}let i=new Map;for(let r of e)i.has(r.realPath)||i.set(r.realPath,{realPath:r.realPath,representative:r,siblings:s.get(r.realPath)??[r]});return[...i.values()]}import{readFile as nk,writeFile as ok,mkdir as ak,rename as _d,copyFile as lk,access as ck,realpath as uk}from"node:fs/promises";import{join as Fd,dirname as dk}from"node:path";function Dd(){return{version:1,disabled:{}}}async function Is(e){let t=e??Zr(),s;try{s=await nk(t,"utf-8")}catch(i){if(i?.code==="ENOENT")return A("skill-state: file not found, returning empty state"),Dd();throw i}try{let i=JSON.parse(s);if(!i||typeof i!="object"||i.version!==1||typeof i.disabled!="object"||i.disabled===null)throw new Error("invalid schema");return i}catch{let i=t+".bak";A(`skill-state: parse error, backing up to ${i}`);try{await lk(t,i)}catch{}return console.error(`Warning: skill-state.json was corrupted. Backup saved to ${i}. Starting fresh.`),Dd()}}async function jo(e,t){let s=t??Zr();await ak(dk(s),{recursive:!0}),await ok(s,JSON.stringify(e,null,2)+`
|
|
146
|
+
`,"utf-8")}function jd(e,t,s,i){let r=e.disabled[t]??={},n=r[s]??={};n[i]=!0}function qd(e,t,s,i){let r=e.disabled[t];if(!r)return;let n=r[s];n&&(delete n[i],Object.keys(n).length===0&&delete r[s],Object.keys(r).length===0&&delete e.disabled[t])}function fk(e){return e.replace(/[.+?^${}()|[\]\\]/g,"\\$&")}function pk(e){if(e==="*"||e==="all")return{kind:"all",test:()=>!0};if(e.includes("*")){let t=new RegExp("^"+fk(e).replace(/\*/g,".*")+"$");return{kind:"wildcard",test:s=>t.test(s)}}return e.endsWith(":")||e.endsWith("-")?{kind:"prefix",test:t=>t.startsWith(e)}:{kind:"exact",test:t=>t===e}}function qo(e,t){let s=pk(t);return e.filter(i=>s.test(i.name)||s.test(i.dirName))}function Bd(e){return Fd(e,"SKILL.md")}function gr(e){return Fd(e,"SKILL.md.disabled")}async function hr(e){try{return await ck(e),!0}catch{return!1}}async function Ud(e){try{return await uk(e)}catch{return e}}async function Vd(e){let t=await Ud(e),s=Bd(t),i=gr(t);return!await hr(s)&&await hr(i)?!1:(await _d(s,i),!0)}async function Kd(e){let t=await Ud(e),s=Bd(t),i=gr(t);return!await hr(i)&&await hr(s)?!1:(await _d(i,s),!0)}var Y={SKILL_NOT_FOUND:"SKILL_NOT_FOUND",AUDIT_FAILED:"AUDIT_FAILED",INSTALL_FAILED:"INSTALL_FAILED",PUBLISH_FAILED:"PUBLISH_FAILED",NETWORK_ERROR:"NETWORK_ERROR",INVALID_ARGUMENT:"INVALID_ARGUMENT",UNKNOWN_ERROR:"UNKNOWN_ERROR"};function me(){let e=console.log,t=console.info,s=(...i)=>process.stderr.write(i.map(String).join(" ")+`
|
|
147
|
+
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function Gd(e){return{timestamp:new Date().toISOString(),asm_version:Al,duration_ms:Math.round(performance.now()-e)}}function G(e,t,s){let i={version:1,command:e,status:"ok",data:t,meta:Gd(s)},r=process.stdout.isTTY?2:0;return JSON.stringify(i,null,r)}function z(e,t,s,i,r){let n={version:1,command:e,status:"error",error:{code:t,message:s,...r!==void 0?{details:r}:{}},meta:Gd(i)},o=process.stdout.isTTY?2:0;return JSON.stringify(n,null,o)}import{readFile as mk,realpath as hk}from"fs/promises";import{existsSync as gk}from"fs";import{join as yk}from"path";function bk(){console.log(`${l.bold("Usage:")} asm disable <target> [options]
|
|
148
|
+
asm disable --all [options]
|
|
173
149
|
|
|
174
|
-
|
|
175
|
-
|
|
150
|
+
Disable skills without uninstalling them. Disabling renames a skill's
|
|
151
|
+
${l.dim("SKILL.md")} to ${l.dim("SKILL.md.disabled")} so neither asm nor your agent sees it.
|
|
152
|
+
The directory stays intact; ${l.bold("asm enable")} reverses it.
|
|
176
153
|
|
|
177
|
-
|
|
154
|
+
${l.dim("Note: skills installed to several tools at once share one SKILL.md")}
|
|
155
|
+
${l.dim("(siblings are symlinks), so disabling one affects all of them \u2014 asm warns")}
|
|
156
|
+
${l.dim("and records every sibling. Separately-installed copies stay independent.")}
|
|
178
157
|
|
|
179
|
-
|
|
158
|
+
${l.bold("Targets:")}
|
|
159
|
+
<name> Exact skill name or directory name
|
|
160
|
+
'<glob>*' Glob match (${l.dim("* matches any characters")})
|
|
161
|
+
<prefix>: | <prefix>- Prefix match (e.g. ${l.dim("openspec:")}, ${l.dim("asc-")})
|
|
180
162
|
|
|
181
|
-
|
|
163
|
+
${l.bold("Options:")}
|
|
164
|
+
--all, -a Disable every matching skill
|
|
165
|
+
-p, --tool <name> Limit to one tool/provider (e.g. claude, codex)
|
|
166
|
+
-s, --scope <s> Filter: global, local, project, or both (default: both)
|
|
167
|
+
-y, --yes Skip confirmation prompt
|
|
168
|
+
--json Output result as JSON
|
|
169
|
+
--machine Tab-separated output
|
|
170
|
+
--no-color Disable ANSI colors
|
|
171
|
+
-V, --verbose Show debug output
|
|
182
172
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
`)}import{access as ib,lstat as nb,mkdir as rb,readdir as ob,readFile as bu,rm as ab,stat as wu,symlink as lb}from"fs/promises";import{join as hi}from"path";async function Br(e){let t;try{t=await wu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=hi(e,"SKILL.md"),i;try{i=await bu(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=Z(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ae(n)}}async function vu(e,t,s,i){let n=hi(t,s),r=!1;try{await ib(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await ab(n,{recursive:!0,force:!0})}await rb(t,{recursive:!0}),await lb(e,n,"dir")}async function Ur(e){let t;try{t=await wu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=await ob(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=hi(e,n);try{if(!(await nb(r)).isDirectory())continue}catch{continue}let o=hi(r,"SKILL.md");try{let a=await bu(o,"utf-8"),l=Z(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ae(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as Rb,writeFile as Lb,readdir as Tu,access as Mu,mkdir as Ob,rm as Tb}from"fs/promises";import{join as Ge,resolve as Du,dirname as Mb}from"path";import{homedir as Db}from"os";import{fileURLToPath as Fb}from"url";import{readdir as cb,readFile as ub}from"fs/promises";import{join as db}from"path";function Kr(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var fb=10,pb=5,mb=3,hb=1;function gb(e,t){let s=Kr(e),i=Kr(t.name),n=Kr(t.description),r=0;for(let o of s)i.has(o)&&(r+=fb),n.has(o)&&(r+=mb),t.name.toLowerCase().includes(o)&&(r+=pb),t.description.toLowerCase().includes(o)&&(r+=hb);return r}async function ku(e){let t=new Map,s;try{s=await cb(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=db(e,i);try{let r=await ub(n,"utf-8"),o=JSON.parse(r);for(let a of o.skills)"license"in a||(a.license=""),"creator"in a||(a.creator=""),"compatibility"in a||(a.compatibility=""),"allowedTools"in a||(a.allowedTools=[]),"verified"in a||(a.verified=!1);t.set(`${o.owner}/${o.repo}`,o)}catch{}}return t}async function dt(){let e=await ku(bo()),t=await ku(yt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var yb=["license","creator","version"];function Su(e){return yb.includes(e)}function $u(e,t){return e[t]||""}function bb(e,t){if(t.has){for(let s of t.has)if(Su(s)&&!$u(e,s))return!1}if(t.missing){for(let s of t.missing)if(Su(s)&&$u(e,s))return!1}return!0}function xu(e){let t=[];return e.license||t.push("license"),e.creator||t.push("creator"),(!e.version||e.version==="0.0.0")&&t.push("version"),t}async function gi(e,t=20,s){let i=await dt(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!bb(a,s))continue;let l=r?1:gb(e,a);l>0&&n.push({skill:a,repo:{owner:o.owner,repo:o.repo},score:l})}return n.sort((o,a)=>a.score-o.score),n.slice(0,t)}async function Eu(){return(await dt()).reduce((t,s)=>t+s.skillCount,0)}import{readdir as wb,readFile as Cu,stat as Pu}from"fs/promises";import{join as Vr}from"path";var vb=[{id:"marketing",title:"Marketing Skills",description:"Marketing, growth, SEO, ASO, affiliate, sales, and conversion skills.",tags:["marketing","growth","seo"],keywords:["marketing","growth","seo","aso","affiliate","sales","copy","copywriting","conversion","cro","brand","social","campaign"]},{id:"writing",title:"Writing Skills",description:"Writing, editing, documentation, publishing, and content-production skills.",tags:["writing","content","docs"],keywords:["write","writing","writer","blog","article","content","docs","documentation","draft","copy","readme","paper","thesis","proposal"]},{id:"research",title:"Research Skills",description:"Research, academic, literature-review, citation, paper, and analysis skills.",tags:["research","academic","analysis"],keywords:["research","academic","scholar","paper","literature","citation","review","analysis","summar","evaluate","verify"]},{id:"engineering",title:"Engineering Skills",description:"Coding, debugging, testing, architecture, review, and software engineering skills.",tags:["engineering","coding","testing"],keywords:["code","coding","debug","test","testing","coverage","review","refactor","architecture","typescript","python","javascript","build","cli","api"]},{id:"frontend-design",title:"Frontend & Design Skills",description:"Frontend, UI, UX, visual design, component, theme, and landing-page skills.",tags:["frontend","design","ui"],keywords:["frontend","ui","ux","design","component","react","css","html","figma","theme","landing","layout","visual","brand","logo"]},{id:"devops",title:"DevOps Skills",description:"Deployment, CI/CD, infrastructure, cloud, Docker, Kubernetes, and automation skills.",tags:["devops","infra","automation"],keywords:["devops","deploy","deployment","ci","cd","pipeline","docker","kubernetes","terraform","ansible","cloud","infra","infrastructure","workflow","release"]},{id:"data-ai",title:"Data & AI Skills",description:"Data, analytics, AI, model, prompt, agent, and automation skills.",tags:["data","ai","agents"],keywords:["data","analytics","analysis","ai","agent","llm","model","prompt","openai","claude","gemini","automation","dataset","sql"]},{id:"product-business",title:"Product & Business Skills",description:"Product, strategy, PRD, planning, finance, resume, and business workflow skills.",tags:["product","business","planning"],keywords:["product","prd","strategy","planning","business","finance","resume","career","startup","market","competitor","customer","sales"]}],Au=2,kb=80,Sb=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],$b=["bundles","data/bundles",".asm/bundles"];function Xt(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Nu(e,t,s){let i=Xt(e),n=Xt(t),r=Xt(s),o=`${i}-${n}`;return r.startsWith(o)?r:`${o}-${r}`}function xb(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function Eb(e,t){let s=xb(e);return t.keywords.some(i=>s.includes(i))}function Iu(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function Cb(e){let t=new Set,s=[];for(let i of e){let n=`${i.installUrl||""}\0${i.name}`;t.has(n)||(t.add(n),s.push(i))}return s}function Ru(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function Jr(e){let t=[];if(!e.skills||e.skills.length<Au)return t;for(let s of vb){let i=e.skills.filter(r=>Eb(r,s)).slice(0,kb);if(i.length<Au)continue;let n=Nu(e.owner,e.repo,s.id);t.push({version:1,name:n,description:`${s.description} Derived from ${e.owner}/${e.repo}.`,author:`ASM (${e.owner}/${e.repo})`,createdAt:e.updatedAt,tags:["repo-derived","inferred",...s.tags,Xt(e.owner),Xt(e.repo)],skills:Ru(i.map(Iu)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function Ab(e,t,s){if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e,n=Array.isArray(i.skills)?i.skills:[];if(n.length===0)return null;let r=new Map(t.skills.map(l=>[l.name,l])),o=Cb(n.map(l=>{if(typeof l=="string"){let p=r.get(l);return p?Iu(p):null}if(!l||typeof l!="object"||Array.isArray(l))return null;let c=l,f=typeof c.name=="string"?c.name:"";if(!f)return null;let d=r.get(f);return d?{name:d.name,installUrl:d.installUrl,description:typeof c.description=="string"&&c.description?c.description:d.description||void 0,version:typeof c.version=="string"&&c.version?c.version:d.version||void 0}:null}).filter(l=>l!==null));if(o.length===0)return null;let a=typeof i.name=="string"&&i.name?i.name:s.replace(/\.json$/,"");return{version:1,name:Nu(t.owner,t.repo,a),description:typeof i.description=="string"&&i.description?i.description:`Bundle from ${t.owner}/${t.repo}.`,author:typeof i.author=="string"&&i.author?i.author:`ASM (${t.owner}/${t.repo})`,createdAt:typeof i.createdAt=="string"&&i.createdAt?i.createdAt:t.updatedAt,tags:Array.isArray(i.tags)?["repo-derived","explicit",...i.tags.filter(l=>typeof l=="string")]:["repo-derived","explicit"],skills:Ru(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function Pb(e){try{return(await Pu(e)).isFile()}catch{return!1}}async function Nb(e){try{return(await Pu(e)).isDirectory()}catch{return!1}}async function Ib(e){let t=[];for(let s of Sb){let i=Vr(e,s);if(await Pb(i))try{t.push({relPath:s,data:JSON.parse(await Cu(i,"utf-8"))})}catch{}}for(let s of $b){let i=Vr(e,s);if(!await Nb(i))continue;let n=[];try{n=await wb(i)}catch{continue}for(let r of n.filter(o=>o.endsWith(".json")).sort()){let o=`${s}/${r}`;try{t.push({relPath:o,data:JSON.parse(await Cu(Vr(i,r),"utf-8"))})}catch{}}}return t}async function Lu(e,t){let s=[],i=await Ib(e);for(let n of i){let r=n.data,o=Array.isArray(r?.bundles)?r.bundles:[r];for(let a of o){let l=Ab(a,t,n.relPath);l&&s.push(l)}}return yi(s)}function yi(e){let t=new Map;for(let s of e){let i=t.get(s.name);(!i||s.explicit&&!i.explicit)&&t.set(s.name,s)}return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}function Ou(e){let t=e.bundles||[],s=Jr(e);return yi([...t,...s])}var _b=Fb(import.meta.url),jb=Mb(_b),We=Ge(Db(),".config","agent-skill-manager","bundles"),bi=Du(jb,"..","data","bundles");function qb(e){let t=[];if(typeof e!="object"||e===null||Array.isArray(e))return{valid:!1,errors:["Bundle must be a JSON object."]};let s=e;if(s.version!==1&&t.push(`Unsupported bundle version: ${JSON.stringify(s.version)}. Expected 1.`),(typeof s.name!="string"||!s.name)&&t.push("Missing or empty 'name' field."),(typeof s.description!="string"||!s.description)&&t.push("Missing or empty 'description' field."),(typeof s.author!="string"||!s.author)&&t.push("Missing or empty 'author' field."),typeof s.createdAt!="string"&&t.push("Missing or invalid 'createdAt' field."),!Array.isArray(s.skills))return t.push("Missing or invalid 'skills' array."),{valid:!1,errors:t};s.skills.length===0&&t.push("Bundle must contain at least one skill.");for(let i=0;i<s.skills.length;i++){let n=s.skills[i];if(typeof n!="object"||n===null){t.push(`skills[${i}]: must be an object.`);continue}let r=n;(typeof r.name!="string"||!r.name)&&t.push(`skills[${i}]: missing or empty 'name'.`),(typeof r.installUrl!="string"||!r.installUrl)&&t.push(`skills[${i}]: missing or empty 'installUrl'.`)}return s.tags!==void 0&&(Array.isArray(s.tags)?s.tags.some(i=>typeof i!="string")&&t.push("'tags' must contain only strings."):t.push("'tags' must be an array of strings if provided.")),{valid:t.length===0,errors:t}}function Fu(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function _u(e,t){let s=t??await De(),i=s.skills[e.name]||s.skills[e.dirName],n;return e.isSymlink&&e.symlinkTarget?n=e.symlinkTarget:i?.source?n=i.source:n=e.path,{name:e.name,installUrl:n,description:e.description||void 0,version:e.version||void 0}}async function Bb(){await Ob(We,{recursive:!0})}function es(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(t=t.replace(/^\.+|\.+$/g,""),!t||t==="."||t==="..")throw new Error("Invalid bundle name: results in an empty filename after sanitization.");return t}async function Hr(e){await Bb();let t=`${es(e.name)}.json`,s=Ge(We,t);return await Lb(s,JSON.stringify(e,null,2)+`
|
|
186
|
-
|
|
187
|
-
${
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
Security verdict: ${r}
|
|
193
|
-
|
|
194
|
-
Proceed? [y/N] `);let ke=await new Promise(de=>{let fe="",Me=Mi=>{fe+=Mi.toString(),fe.includes(`
|
|
195
|
-
`)&&(process.stdin.removeListener("data",Me),process.stdin.pause(),de(fe.trim()))};process.stdin.resume(),process.stdin.on("data",Me)});if(ke.toLowerCase()!=="y"&&ke.toLowerCase()!=="yes")return{success:!1,manifest:h,prUrl:null,error:"Publish aborted by user.",securityVerdict:r,securityReport:n}}P(`publish: forking ${ze}`),await H(["gh","repo","fork",ze,"--clone=false"]);let b=`publish/${y}/${s.name}`,w=`manifests/${y}/${s.name}.json`,k=JSON.stringify(h,null,2)+`
|
|
196
|
-
`,S=Buffer.from(k,"utf-8").toString("base64"),{stdout:v,exitCode:C}=await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/main`,"--jq",".object.sha"]);if(C!==0)return{success:!1,manifest:h,prUrl:null,error:`Failed to read fork's main branch. Ensure the fork exists at ${y}/asm-registry.`,securityVerdict:r,securityReport:n};let E=v.trim(),{exitCode:x}=await H(["gh","api",`repos/${y}/asm-registry/git/refs`,"-X","POST","-f",`ref=refs/heads/${b}`,"-f",`sha=${E}`]);x!==0&&await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/${b}`,"-X","PATCH","-f",`sha=${E}`,"-f","force=true"]);let{stderr:j,exitCode:R}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}`,"-X","PUT","-f",`message=Publish ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`]);if(R!==0){let{stdout:B,exitCode:ie}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}?ref=${b}`,"-q",".sha"]),ke=B.trim();if(ie===0&&ke){let{exitCode:de}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}`,"-X","PUT","-f",`message=Update ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`,"-f",`sha=${ke}`]);if(de!==0)return{success:!1,manifest:h,prUrl:null,error:"Failed to write manifest to registry fork.",securityVerdict:r,securityReport:n}}else return{success:!1,manifest:h,prUrl:null,error:`Failed to write manifest to registry fork. ${j}`,securityVerdict:r,securityReport:n}}let M=Yr(s.name),T=Yr(s.description),K=Yr(s.license),I=`Publish ${y}/${ki(s.name)}`,N=[`## Skill: ${M}`,"",`**Author:** ${y}`,`**Version:** ${s.version}`,`**Description:** ${T}`,`**License:** ${K}`,`**Repository:** ${a}`,`**Commit:** \`${o}\``,`**Security verdict:** ${r}`,"","---","","*This PR was generated by `asm publish`.*"].join(`
|
|
197
|
-
`),{stdout:F,stderr:O,exitCode:D}=await H(["gh","pr","create","--repo",ze,"--head",`${y}:${b}`,"--title",I,"--body",N]),Q=null;if(D===0)Q=F.trim();else{let B=O.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/);B&&(Q=B[0])}return Q?{success:!0,manifest:h,prUrl:Q,error:null,securityVerdict:r,securityReport:n}:{success:!1,manifest:h,prUrl:null,error:`Failed to create PR against ${ze}. ${O}`,securityVerdict:r,securityReport:n}}function Yu(e){let t=e.manifest;return t?["",` gh CLI is unavailable (${e.fallbackReason}).`," To publish manually:","",` 1. Fork ${ze} on GitHub`,` 2. Create branch: publish/${t.author}/${t.name}`,` 3. Add file: manifests/${t.author}/${t.name}.json`," 4. Paste the manifest below into that file",` 5. Open a PR against ${ze}`,"",' Run "asm doctor" to fix your environment.',""," Generated manifest:",JSON.stringify(t,null,2).split(`
|
|
198
|
-
`).map(i=>` ${i}`).join(`
|
|
199
|
-
`)].join(`
|
|
200
|
-
`):""}import{execFile as fw}from"child_process";import{promisify as pw}from"util";import{rm as Si,rename as zu,cp as Qu,access as mw,mkdir as hw}from"fs/promises";import{join as $i}from"path";import{homedir as Xu}from"os";var zr=pw(fw);async function gw(e,t,s){let i=new Array(e.length),n=0;async function r(){for(;n<e.length;){let a=n++;i[a]=await s(e[a])}}let o=[];for(let a=0;a<Math.min(t,e.length);a++)o.push(r());return await Promise.all(o),i}async function yw(e,t){try{let s=["ls-remote",e];t?s.push(t):s.push("HEAD");let{stdout:i}=await zr("git",s,{timeout:1e4}),n=i.split(`
|
|
201
|
-
`)[0];if(!n)return null;let r=n.split(/\s+/)[0];return r&&/^[0-9a-f]{40}$/.test(r)?r:null}catch(s){return P(`updater: git ls-remote failed for ${e}: ${s}`),null}}function Qr(e){return e.sourceType?e.sourceType:e.source.startsWith("local:")?"local":"github"}function Zu(e){if(e.startsWith("github:")){let t=e.slice(7),s=t.indexOf("#");return s!==-1&&(t=t.slice(0,s)),`https://github.com/${t}.git`}return e.startsWith("file://")?e:null}function bw(e){if(!e.startsWith("github:"))return null;let t=e.slice(7),s=t.indexOf("#");s!==-1&&(t=t.slice(0,s));let i=t.split("/");return i.length<2||!i[0]||!i[1]?null:{owner:i[0],repo:i[1]}}async function Xr(e){let t=e?.readLockFn??De,s=e?.fetchRegistryIndexFn??jr,i=e?.lock??await t(),n=Object.entries(i.skills);if(n.length===0)return{entries:[],outdatedCount:0,upToDateCount:0,untrackedCount:0,errorCount:0};let r=null;n.some(([,l])=>Qr(l)==="registry"||l.registryName)&&(r=await s());let a=await gw(n,5,async([l,c])=>{let f=Qr(c);if(!c.commitHash||c.commitHash==="unknown")return{name:l,installedCommit:c.commitHash||"unknown",latestCommit:"unknown",source:c.source,sourceType:f,status:"untracked"};if(f==="local")return{name:l,installedCommit:c.commitHash,latestCommit:c.commitHash,source:c.source,sourceType:f,status:"up-to-date"};if(f==="registry"&&r){let y=c.registryName||l,h=r.manifests.find(g=>g.name.toLowerCase()===y.toLowerCase());if(h){let g=h.commit!==c.commitHash;return{name:l,installedCommit:ye(c.commitHash),latestCommit:ye(h.commit),source:c.source,sourceType:f,status:g?"outdated":"up-to-date"}}}let d=Zu(c.source);if(!d)return{name:l,installedCommit:ye(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:f,status:"error",error:"Cannot determine remote URL"};let p=await yw(d,c.ref);if(!p)return{name:l,installedCommit:ye(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:f,status:"error",error:"Failed to fetch remote commit"};let m=p!==c.commitHash;return{name:l,installedCommit:ye(c.commitHash),latestCommit:ye(p),source:c.source,sourceType:f,status:m?"outdated":"up-to-date"}});return{entries:a,outdatedCount:a.filter(l=>l.status==="outdated").length,upToDateCount:a.filter(l=>l.status==="up-to-date").length,untrackedCount:a.filter(l=>l.status==="untracked").length,errorCount:a.filter(l=>l.status==="error").length}}async function ww(e,t,s,i){if(Qr(t)==="local")return{name:e,status:"skipped",reason:"Local skill (not updatable)"};let r=Zu(t.source);if(!r)return{name:e,status:"failed",reason:"Cannot determine remote URL"};let o=$i(Xu(),".config","agent-skill-manager",".tmp",`${e}-${Date.now()}`);try{let a=$i(Xu(),".config","agent-skill-manager",".tmp");await hw(a,{recursive:!0}),P(`updater: cloning latest ${e} to ${o}`);let l=["clone","--depth","1"];t.ref&&t.ref!=="HEAD"&&l.push("--branch",t.ref),l.push(r,o);try{await zr("git",l,{timeout:6e4})}catch(v){return{name:e,status:"failed",reason:`Clone failed: ${v.stderr||v.message}`}}let c=null;try{let{stdout:v}=await zr("git",["rev-parse","HEAD"],{cwd:o,timeout:5e3});c=v.trim()}catch{return{name:e,status:"failed",reason:"Could not read new commit"}}if(c===t.commitHash)return{name:e,status:"skipped",reason:"Already up to date"};P(`updater: running security audit on ${e}`);let f="safe";try{let v=i?.auditFn??Te,C=bw(t.source);if(f=(await v(o,e,C?.owner,C?.repo)).verdict,f==="dangerous")return{name:e,status:"skipped",reason:"Security audit: dangerous \u2014 update blocked",securityVerdict:f};if(f==="warning"||f==="caution"){if(!s)return{name:e,status:"skipped",reason:`Security audit: ${f} \u2014 use --yes to override`,securityVerdict:f};P(`updater: security audit ${f} for ${e} \u2014 proceeding (--yes)`)}}catch(v){return P(`updater: security audit failed for ${e}: ${v.message}`),{name:e,status:"failed",reason:`Security audit failed \u2014 skipping update: ${v.message}`}}let d=i?.loadConfigFn??U,p=i?.resolveProviderPathFn??oe,y=(await d()).providers.find(v=>v.name===t.provider),h=y?y.global:`~/.${t.provider}/skills`,g=p(h),b=$i(g,e),w=$i(o,".git");try{await Si(w,{recursive:!0,force:!0})}catch{}try{await mw(b)}catch{let v=i?.writeLockEntryFn??wt;return await Qu(o,b,{recursive:!0}),await v(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:ye(t.commitHash),newCommit:ye(c),securityVerdict:f}}let k=`${b}.bak-${Date.now()}`;try{await zu(b,k),await Qu(o,b,{recursive:!0}),await Si(k,{recursive:!0,force:!0})}catch(v){try{await Si(b,{recursive:!0,force:!0}),await zu(k,b)}catch{}return{name:e,status:"failed",reason:`Atomic swap failed: ${v.message}`}}return await(i?.writeLockEntryFn??wt)(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:ye(t.commitHash),newCommit:ye(c),securityVerdict:f}}finally{try{await Si(o,{recursive:!0,force:!0})}catch{}}}async function ed(e,t,s){let i=s?.readLockFn??De,n=s?.checkOutdatedFn??Xr,r=s?.updateSkillFn??ww,o=await i(),a=await n({lock:o}),l=a.entries.filter(d=>d.status==="outdated"),c=[];if(e&&e.length>0){let d=new Set(e.map(p=>p.toLowerCase()));l=l.filter(p=>d.has(p.name.toLowerCase()));for(let p of e)l.find(m=>m.name.toLowerCase()===p.toLowerCase())||(a.entries.find(y=>y.name.toLowerCase()===p.toLowerCase())?P(`updater: skill "${p}" is already up to date`):(P(`updater: skill "${p}" not found in lock file`),c.push(p)))}if(l.length===0)return{results:[],updatedCount:0,skippedCount:0,failedCount:0,...c.length>0?{warnings:c}:{}};let f=[];for(let d of l){let p=o.skills[d.name];if(!p)continue;let m=await r(d.name,p,t);f.push(m)}return{results:f,updatedCount:f.filter(d=>d.status==="updated").length,skippedCount:f.filter(d=>d.status==="skipped").length,failedCount:f.filter(d=>d.status==="failed").length,...c.length>0?{warnings:c}:{}}}function ye(e){return!e||e==="unknown"?"unknown":e.slice(0,7)}function td(e,t){if(e.entries.length===0)return"No skills installed.";let s=d=>d,i=t?u.red:s,n=t?u.green:s,r=t?u.yellow:s,o=t?u.dim:s,a=`${"Skill".padEnd(22)}${"Installed".padEnd(14)}${"Latest".padEnd(14)}Source`,l="\u2500".repeat(60),c=[a,l];for(let d of e.entries){let p=d.name.padEnd(22),m=d.installedCommit.padEnd(14),y,h;switch(d.status){case"outdated":y=i(d.latestCommit.padEnd(14)),h=d.sourceType;break;case"up-to-date":y=n(d.latestCommit.padEnd(14)),h=o("(up to date)");break;case"untracked":y=r("untracked".padEnd(14)),h=r("untracked");break;case"error":y=o("error".padEnd(14)),h=o(d.error||"error");break}c.push(`${p}${m}${y}${h}`)}c.push("");let f=[];return e.outdatedCount>0&&f.push(i(`${e.outdatedCount} outdated`)),e.upToDateCount>0&&f.push(n(`${e.upToDateCount} up to date`)),e.untrackedCount>0&&f.push(r(`${e.untrackedCount} untracked`)),e.errorCount>0&&f.push(o(`${e.errorCount} error`)),c.push(f.join(", ")),c.join(`
|
|
202
|
-
`)}function sd(e){return JSON.stringify({skills:e.entries.map(t=>({name:t.name,installed:t.installedCommit,latest:t.latestCommit,source:t.sourceType,status:t.status,...t.error?{error:t.error}:{}})),summary:{outdated:e.outdatedCount,upToDate:e.upToDateCount,untracked:e.untrackedCount,errors:e.errorCount}},null,2)}function id(e){return JSON.stringify({results:e.results.map(t=>({name:t.name,status:t.status,...t.reason?{reason:t.reason}:{},...t.oldCommit?{oldCommit:t.oldCommit}:{},...t.newCommit?{newCommit:t.newCommit}:{},...t.securityVerdict?{securityVerdict:t.securityVerdict}:{}})),summary:{updated:e.updatedCount,skipped:e.skippedCount,failed:e.failedCount}},null,2)}import{execFile as Lw}from"child_process";import{promisify as Ow}from"util";import{access as nd,readFile as od,readdir as Tw,writeFile as Mw,rm as Dw,stat as ad}from"fs/promises";import{join as Zr}from"path";import{homedir as Fw}from"os";import{constants as rd}from"fs";import{access as vw,realpath as kw,stat as Sw}from"fs/promises";import{constants as $w}from"fs";import{delimiter as xw,resolve as Ew,sep as Cw}from"path";var Aw="asm";function Pw(e){if(!e)return[];let t=new Set,s=[];for(let i of e.split(xw)){let n=i.trim();if(!n)continue;let r=n.endsWith(Cw)?n.slice(0,-1):n;t.has(r)||(t.add(r),s.push(r))}return s}async function Nw(e){try{if(!(await Sw(e)).isFile())return!1}catch{return!1}try{return await vw(e,$w.X_OK),!0}catch{return!1}}async function Iw(e){try{return await kw(e)}catch{return e}}async function Rw(e=process.env.PATH){let t=new Set,s=[];for(let i of Pw(e)){let n=Ew(i,Aw);if(!await Nw(n))continue;let r=await Iw(n);t.has(r)||(t.add(r),s.push({path:n,realPath:r}))}return s}async function xi(e=process.env.PATH){let t=await Rw(e);if(t.length===0)return{resolved:null,shadowed:[]};let[s,...i]=t;return{resolved:s,shadowed:i}}var pt=Ow(Lw);async function _w(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("git",["--version"],{timeout:5e3});return{name:"Git available",status:"pass",message:s.trim().replace("git version ","")}}catch{return{name:"Git available",status:"fail",message:"git not found",fix:"Install git: https://git-scm.com/downloads"}}}async function jw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("git",["--version"],{timeout:5e3}),i=s.match(/(\d+)\.(\d+)/);if(!i)return{name:"Git version",status:"warn",message:"Could not parse git version",fix:"Upgrade git: https://git-scm.com/downloads"};let n=parseInt(i[1],10),r=parseInt(i[2],10);return n>2||n===2&&r>=20?{name:"Git version",status:"pass",message:`${n}.${r} (>= 2.20)`}:{name:"Git version",status:"fail",message:`${n}.${r} (requires >= 2.20)`,fix:"Upgrade git: https://git-scm.com/downloads"}}catch{return{name:"Git version",status:"pass",message:"Skipped \u2014 git not available"}}}async function qw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("gh",["--version"],{timeout:5e3}),i=s.trim().split(`
|
|
203
|
-
`)[0],n=i.match(/(\d+\.\d+\.\d+)/);return{name:"GitHub CLI available",status:"pass",message:n?n[1]:i}}catch{return{name:"GitHub CLI available",status:"fail",message:"gh not found",fix:"Install GitHub CLI: https://cli.github.com"}}}async function Bw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("gh",["auth","status"],{timeout:1e4}),i=s.match(/Logged in to .+ account (\S+)/);return{name:"GitHub CLI authenticated",status:"pass",message:i?i[1]:"authenticated"}}catch(s){let n=(s?.stderr??"").match(/Logged in to .+ account (\S+)/);return n?{name:"GitHub CLI authenticated",status:"pass",message:n[1]}:{name:"GitHub CLI authenticated",status:"fail",message:"Not authenticated",fix:"Run: gh auth login"}}}async function Uw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("node",["--version"],{timeout:5e3}),i=s.trim().replace(/^v/,"");return parseInt(i.split(".")[0],10)>=18?{name:"Node.js version",status:"pass",message:i}:{name:"Node.js version",status:"fail",message:`${i} (requires >= 18.0)`,fix:"Upgrade Node.js: https://nodejs.org"}}catch{return{name:"Node.js version",status:"fail",message:"node not found",fix:"Install Node.js >= 18: https://nodejs.org"}}}async function Kw(e){try{let t=Zr(e,".asm-doctor-write-test");return await Mw(t,"test","utf-8"),await Dw(t),{writable:!0,exists:!0}}catch{}try{return await nd(e,rd.W_OK),{writable:!0,exists:!0}}catch{}try{return await nd(e,rd.F_OK),{writable:!1,exists:!0}}catch{return{writable:!0,exists:!1}}}async function Vw(e){let t=e.providers.filter(r=>r.enabled),s=0,i=0;for(let r of t){let o=oe(r.global);i++,(await Kw(o)).writable&&s++}if(s===i)return{name:"Agent directories writable",status:"pass",message:`${s}/${i} providers`};let n=i-s;return{name:"Agent directories writable",status:"warn",message:`${s}/${i} providers (${n} not writable)`,fix:"Fix permissions on agent skill directories"}}async function Jw(){let e=gt();try{let t=await od(e,"utf-8"),s=JSON.parse(t),i=[];return s.version===void 0&&i.push("version"),Array.isArray(s.providers)||i.push("providers"),i.length>0?{name:"Config file valid",status:"fail",message:`Missing required fields: ${i.join(", ")}`,fix:"Run: asm init"}:{name:"Config file valid",status:"pass",message:"OK"}}catch(t){return t?.code==="ENOENT"?{name:"Config file valid",status:"pass",message:"No config file (using defaults)"}:{name:"Config file valid",status:"fail",message:"Corrupted or unreadable config",fix:"Run: asm init, or delete corrupted config"}}}async function Hw(){let e=yo();try{let t=await od(e,"utf-8"),s=JSON.parse(t);if(s.version!==1||typeof s.skills!="object")return{name:"Lock file integrity",status:"fail",message:"Invalid lock file schema",fix:"Run: asm install to regenerate"};let i=s.skills,n=Object.entries(i),r=["source","installedAt","provider"],o=[];for(let[a,l]of n){if(typeof l!="object"||l===null){o.push(a);continue}let c=l;for(let f of r)if(!c[f]){o.push(a);break}}return o.length>0?{name:"Lock file integrity",status:"warn",message:`${n.length} skills tracked, ${o.length} with missing fields`,fix:"Run: asm install to regenerate"}:{name:"Lock file integrity",status:"pass",message:`${n.length} skills tracked`}}catch(t){return t?.code==="ENOENT"?{name:"Lock file integrity",status:"pass",message:"No lock file (first-time user)"}:{name:"Lock file integrity",status:"fail",message:"Corrupted lock file",fix:"Run: asm install to regenerate"}}}async function Ww(){try{let e=await fetch(Fr,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return e.ok?{name:"Registry reachable",status:"pass",message:"OK"}:{name:"Registry reachable",status:"fail",message:`HTTP ${e.status}`,fix:"Check network connection or proxy settings"}}catch{return{name:"Registry reachable",status:"fail",message:"Network error",fix:"Check network connection or proxy settings"}}}async function Gw(e,t){let s=Object.entries(t.skills);if(s.length===0)return{name:"Installed skills intact",status:"pass",message:"No skills in lock file"};let i=[];for(let[o,a]of s){let l=e.providers.find(d=>d.name===a.provider);if(!l){i.push(o);continue}let c=oe(l.global),f=Zr(c,o);try{(await ad(f)).isDirectory()||i.push(o)}catch{i.push(o)}}if(i.length===0)return{name:"Installed skills intact",status:"pass",message:`${s.length} skills verified`};let n=i[0],r=i.length>1?` (+${i.length-1} more)`:"";return{name:"Installed skills intact",status:"fail",message:`Missing: ${n}${r}`,fix:`Run: asm update ${n}`}}async function Yw(e,t){let s=new Set(Object.keys(t.skills)),i=[];for(let n of e.providers.filter(r=>r.enabled)){let r=oe(n.global);try{let o=await Tw(r);for(let a of o)try{(await ad(Zr(r,a))).isDirectory()&&!s.has(a)&&i.push(a)}catch{}}catch{}}return i.length===0?{name:"No orphaned skills",status:"pass",message:"OK"}:{name:"No orphaned skills",status:"warn",message:`${i.length} skill(s) without lock entries`,fix:"Run: asm list to review"}}async function zw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("df",["-Pk",Fw()],{timeout:5e3}),i=s.trim().split(`
|
|
204
|
-
`);if(i.length<2)return{name:"Disk space",status:"warn",message:"Could not parse df output"};let n=i[1].split(/\s+/),r=parseInt(n[3],10);if(isNaN(r))return{name:"Disk space",status:"warn",message:"Could not parse available space"};let o=r/1024,a=o/1024;return o>100?{name:"Disk space",status:"pass",message:`OK (${a>=1?`${a.toFixed(1)} GB free`:`${Math.round(o)} MB free`})`}:{name:"Disk space",status:"fail",message:`${Math.round(o)} MB free (requires > 100 MB)`,fix:"Free disk space in home directory"}}catch{return{name:"Disk space",status:"warn",message:"Could not check disk space"}}}async function Qw(){try{let e=await xi();if(e.shadowed.length===0)return e.resolved?{name:"No PATH shadowing",status:"pass",message:`single install at ${e.resolved.path}`}:{name:"No PATH shadowing",status:"pass",message:"asm not yet on PATH"};let t=e.resolved,s=e.shadowed[0].path,i=e.shadowed.length>1?` (+${e.shadowed.length-1} more)`:"";return{name:"No PATH shadowing",status:"warn",message:`resolved ${t.path}, shadowed ${s}${i}`,fix:"Remove the duplicate install (`npm uninstall -g agent-skill-manager`) and keep only one."}}catch(e){return{name:"No PATH shadowing",status:"warn",message:`Could not scan PATH: ${e?.message??e}`}}}async function ld(){let e=await U(),t=await De(),i=(await Promise.allSettled([_w(),jw(),qw(),Bw(),Uw(),Vw(e),Jw(),Hw(),Ww(),Gw(e,t),Yw(e,t),zw(),Qw()])).map((a,l)=>a.status==="fulfilled"?a.value:{name:["Git available","Git version","GitHub CLI available","GitHub CLI authenticated","Node.js version","Agent directories writable","Config file valid","Lock file integrity","Registry reachable","Installed skills intact","No orphaned skills","Disk space","No PATH shadowing"][l],status:"fail",message:`Check threw: ${a.reason}`}),n=i.filter(a=>a.status==="pass").length,r=i.filter(a=>a.status==="warn").length,o=i.filter(a=>a.status==="fail").length;return{checks:i,passed:n,warnings:r,failures:o}}var Xw={pass:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function cd(e){let t=["Checking your environment...",""];for(let s of e.checks){let n=` ${Xw[s.status]} ${s.name}${s.message?` (${s.message})`:""}`;if(t.push(n),s.fix&&s.status!=="pass"){let r;s.fix.startsWith("Run: ")?r=s.fix:/^[a-z/~]/.test(s.fix)?r=`Run: ${s.fix}`:r=`Fix: ${s.fix}`,t.push(` \u2192 ${r}`)}}return t.push(""),t.push(`${e.passed} passed, ${e.warnings} warning${e.warnings!==1?"s":""}, ${e.failures} error${e.failures!==1?"s":""}`),t.join(`
|
|
205
|
-
`)}function ud(e){return JSON.stringify({checks:e.checks.map(t=>({name:t.name,status:t.status,message:t.message,...t.fix?{fix:t.fix}:{}})),summary:{passed:e.passed,warnings:e.warnings,failures:e.failures}},null,2)}import{readFile as to,writeFile as Zw,stat as mt,copyFile as ev,readdir as hd}from"fs/promises";import{join as ht,resolve as io,basename as ve,isAbsolute as no}from"path";var so="Relocate `README.md` out of the skill root so SKILL.md remains the sole top-level document (e.g., move it to `docs/README.md`).",dd=["name","description","version","license","author","creator","compatibility","allowed-tools","effort","tags","metadata"],fd=["add","analyze","audit","build","check","configure","convert","create","debug","deploy","detect","edit","evaluate","explain","export","extract","fetch","find","fix","format","generate","identify","improve","index","inspect","install","list","manage","migrate","optimize","parse","plan","prepare","publish","refactor","remove","rename","report","research","review","run","scaffold","scan","score","search","set","setup","show","summarize","sync","test","transform","translate","update","validate","verify","write"],tv=["confirm","confirmation","error","errors","fail","failure","caution","warning","prerequisite","prerequisites","requires","requirements","rollback","dry-run","dry run","safety","validate","validation","check","backup"],sv=["acceptance criteria","expected output","expected result","edge case","edge cases","test","tests","testing","verify","verification","assert","example input","example output","given","then"],iv=["reference","references","see","template","templates","script","scripts","helper","helpers","link"],nv=["when to use","quick start","overview","instructions","steps","workflow","phases","progressive"];function gd(e){let t=e.split(`
|
|
206
|
-
`);if(t.length===0||t[0].trim()!=="---")return{rawFrontmatter:null,body:e};for(let s=1;s<t.length;s++)if(t[s].trim()==="---"){let i=t.slice(1,s).join(`
|
|
207
|
-
`),n=t.slice(s+1).join(`
|
|
208
|
-
`);return{rawFrontmatter:i,body:n}}return{rawFrontmatter:t.slice(1).join(`
|
|
209
|
-
`),body:""}}function yd(e){return e?e.split(`
|
|
210
|
-
`).length:0}function ro(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function rv(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function Ei(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function ov(e){return/```[\s\S]+?```/m.test(e)}function av(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function lv(e,t,s,i){let n=[],r=[],o=0;s!==null?(o+=2,n.push("Has YAML frontmatter block.")):(n.push("SKILL.md has no YAML frontmatter."),r.push("Add a YAML frontmatter block delimited by `---` with at least `name` and `description` fields."));let a=!!(e.name&&e.name.trim()),l=!!(e.description&&e.description.trim());a?o+=1.5:(n.push("Missing required field: name."),r.push("Add `name:` to frontmatter (use the skill directory name).")),l?o+=1.5:(n.push("Missing required field: description."),r.push("Add a one-line `description:` to frontmatter."));let c=ae(e);c&&c!=="0.0.0"?o+=1:(n.push("Missing or default version."),r.push("Set `metadata.version` (or top-level `version`) using semver (e.g. 0.1.0).")),!!(e.author||e["metadata.author"]||e.creator||e["metadata.creator"])?o+=1:(n.push("Missing `author`."),r.push("Add an `author` field so users know who authored and maintains the skill.")),!!e.license?o+=1:(n.push("Missing `license`."),r.push("Add a `license` field (e.g. `license: MIT`)."));let m=t.trim().length>=20,y=rv(t,1);if(m?(o+=1,n.push("Body has meaningful content.")):(n.push("Body content is too short (<20 chars of instructions)."),r.push("Flesh out the markdown body with at least one paragraph of instructions for the agent.")),y?(o+=1,n.push("Body uses markdown headings.")):(n.push("Body has no markdown headings."),r.push("Add section headings (e.g. `## When to Use`, `## Instructions`) so the agent can navigate the skill quickly.")),i){let h=i.find(g=>g.toLowerCase()==="readme.md");h&&(n.push(`\`${h}\` found at skill root; move it to a subdirectory (e.g., \`docs/README.md\`).`),r.push(so))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function cv(e,t){let s=[],i=[],n=0,r=(e.description||"").trim();if(!r)return s.push("No description."),i.push("Write a one-sentence description that says specifically what the skill does and when to use it."),{id:"description",name:"Description quality",score:0,max:10,findings:s,suggestions:i};let o=ro(r);s.push(`Description is ${o} words.`),o>=8&&o<=40?n+=4:o>=5&&o<8?(n+=2,i.push("Lengthen the description slightly so it names both the action and the trigger (aim for 8\u201320 words).")):o>=41&&o<=60?(n+=2,i.push("Trim the description \u2014 aim for under 40 words. Move the long version to the markdown body.")):o>60?(n+=0,i.push("Description is too long. Keep it under 40 words; put detail in the body.")):(n+=0,i.push("Description is too short. Aim for 8\u201320 words."));let a=r.split(/\s+/)[0]?.toLowerCase().replace(/[^\w-]/g,"");return!!(a&&(fd.includes(a)||fd.includes(a.replace(/s$/,""))))?(n+=3,s.push("Starts with an action verb.")):(s.push(`Does not start with a recognized action verb (got "${a??""}").`),i.push('Start the description with an imperative action verb (e.g. "Generate...", "Analyze...", "Review...").')),/\buse when\b|\btrigger\b|\bwhen\b|\bfor\b/i.test(r)||/\b(before|after|during)\b/i.test(r)?(n+=3,s.push("Mentions a trigger or use-case signal.")):(s.push("No explicit trigger / use-case phrase."),i.push('Name the trigger in the description \u2014 e.g. "Use when...", "for reviewing...", "before publishing...".')),{id:"description",name:"Description quality",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function uv(e,t){let s=[],i=[],n=0,r=Ei(t,nv);r.length>=2?(n+=3,s.push(`Progressive disclosure cues present: ${r.slice(0,3).join(", ")}.`)):r.length===1?(n+=1,i.push('Add clearer section labels \u2014 e.g. "## When to Use" and "## Instructions" \u2014 to support progressive disclosure.')):i.push('Structure the body with "## When to Use" and "## Instructions" sections so the agent reads only what it needs.'),av(t)?(n+=2,s.push("Uses lists or numbered steps.")):(s.push("No lists or steps detected."),i.push("Use bulleted or numbered steps to narrow the agent's degrees of freedom."));let o=ov(t),a=/\bexample\b/i.test(t);o&&a?(n+=2,s.push("Includes example code block.")):o||a?(n+=1,i.push('Back up examples with fenced code blocks labelled under "## Example" so the agent sees concrete input/output.')):i.push('Add an "## Example" section with a fenced code block showing the desired output.');let l=(t.match(/^\s*[-*0-9.]*\s*(Do|Use|Run|Call|Check|Validate|Return|Emit|Write|Read|Ask|Confirm|Avoid|Never|Always)\b/gim)||[]).length;l>=3?(n+=2,s.push(`Uses imperative voice (${l} cues).`)):l>=1?(n+=1,i.push("Favor imperative voice (Do / Use / Avoid / Never) to narrow the agent's choices.")):i.push('Rewrite instructions in the imperative mood \u2014 e.g. "Run `git status` first" instead of "you might want to run".');let c=ro(t);return c>=80&&c<=3e3?(n+=1,s.push(`Body length within healthy range (${c} words).`)):c<80?(s.push(`Body is very short (${c} words).`),i.push("Expand the instructions; an underspecified skill gives the agent too much freedom.")):(s.push(`Body is very long (${c} words).`),i.push("Split large content into referenced files; keep SKILL.md focused under ~3000 words.")),{id:"prompt-engineering",name:"Prompt engineering",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function dv(e,t){let s=[],i=[],n=0,r=ro(t);s.push(`Body is ${r} words.`),r>=120&&r<=1500?n+=4:r>=60&&r<120?(n+=2,i.push("Expand instructions slightly \u2014 too little context can push the agent to improvise.")):r>1500&&r<=3e3?(n+=2,i.push("Consider moving large sections into referenced files (e.g. `references/*.md`) and linking them instead of inlining.")):r>3e3&&(n+=0,i.push("Body is over 3000 words \u2014 split long content into referenced files or templates."));let o=Ei(t,iv);o.length>=2?(n+=3,s.push(`References external files or links (${o.slice(0,3).join(", ")}).`)):o.length===1?(n+=1,i.push('Link out to supporting files (e.g. "see `references/examples.md`") instead of inlining them.')):i.push('Offload verbose content to referenced files and link to them ("see `./templates/x.md`").');let l=(t.match(/```[\s\S]+?```/g)||[]).filter(c=>yd(c)>60);return l.length===0?(n+=2,s.push("No oversized code blocks.")):(s.push(`${l.length} code block(s) longer than 60 lines.`),i.push("Move large code blocks into referenced template files; link to them from SKILL.md.")),/\btoken\b|\bbudget\b|\bcontext window\b/i.test(t)&&(n+=1,s.push("Mentions tokens/budget/context window.")),{id:"context-efficiency",name:"Context efficiency",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function fv(e,t){let s=[],i=[],n=0,r=Ei(t,tv);r.length>=4?(n+=4,s.push(`Covers multiple safety cues (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=2,s.push(`Mentions a few safety cues: ${r.join(", ")}.`),i.push("Add explicit error-handling and confirmation steps so the agent knows how to recover from failures.")):r.length===1?(n+=1,i.push('Expand the safety section \u2014 include prerequisites, validation steps, and what to do "on error".')):i.push("Describe prerequisites, confirmation prompts, and error-handling steps to reduce blast radius.");let o=/\b(rm\s|delete|remove|drop|force|overwrite|destructive)\b/i.test(t),a=/\bconfirm\b|\bdry-?run\b|\bare you sure\b|\bbackup\b/i.test(t);return o&&a?(n+=3,s.push("Destructive actions paired with confirmation/dry-run.")):o?(s.push("References destructive actions without explicit confirmation/dry-run."),i.push("Pair any destructive command with an explicit confirmation prompt, dry-run flag, or backup step.")):n+=1.5,/\bprerequisit/i.test(t)||/\brequire/i.test(t)||/\bdepend/i.test(t)?(n+=3,s.push("Declares prerequisites or requirements.")):(s.push("No prerequisites / requirements section."),i.push('Add a "## Prerequisites" block listing required tools, credentials, and environment state.')),{id:"safety",name:"Safety & guardrails",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function pv(e,t){let s=[],i=[],n=0,r=Ei(t,sv);return r.length>=4?(n+=5,s.push(`Many testability cues present (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=3,s.push(`Some testability cues: ${r.join(", ")}.`),i.push('Add an "## Acceptance Criteria" block listing verifiable outputs or checklist items.')):r.length===1?(n+=1,i.push('Add concrete "expected output" examples so the agent can self-check.')):i.push('Add a "## Acceptance Criteria" section with testable statements (e.g. "produces a JSON report with overall_score").'),/expected\s+(output|result|response)/i.test(t)?(n+=3,s.push("Describes expected output/result.")):i.push('Include an "Expected output" example so reviewers and the agent can verify correctness.'),/\bedge case|gotcha|pitfall|limitation/i.test(t)?(n+=2,s.push("Mentions edge cases or limitations.")):i.push('Add a short "Edge cases" list to describe inputs the skill should reject or handle carefully.'),{id:"testability",name:"Testability",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function mv(e,t){let s=[],i=[],n=0,r=(e.name||"").trim();if(r){let l=/^[a-z][a-z0-9-]*$/.test(r),c=r.length<=40;l&&c?(n+=4,s.push(`name "${r}" follows kebab-case convention.`)):(l||(s.push(`name "${r}" is not lowercase kebab-case.`),i.push(`Rename to lowercase kebab-case (e.g. "${r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}").`)),c||s.push(`name is ${r.length} chars; keep it <= 40.`))}else i.push("Add a kebab-case `name` (e.g. `my-skill`).");let o=t.match(/^#{1,6}\s+(.+)$/gm)||[];return o.length>0&&(o.filter(f=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(f)).length/o.length>=.5?(n+=3,s.push("Most headings use action/imperative labels.")):(n+=1,i.push("Rename body headings to action-oriented labels (e.g. `## Instructions`, `## When to Use`)."))),/(?:\s\s|\bTODO\b|\bFIXME\b|\?{2,})/.test(e.description||"")?i.push("Clean up description \u2014 remove TODOs, FIXMEs, double spaces, or trailing punctuation."):(n+=2,s.push("Description looks clean (no TODO/FIXME/stray noise).")),{id:"naming",name:"Naming & conventions",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function ss(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=Z(t),{rawFrontmatter:o,body:a}=gd(t),l=[lv(r,a,o,n),cv(r,a),uv(r,a),dv(r,a),fv(r,a),pv(r,a),mv(r,a)];if(r.name&&ve(s)===r.name){let g=l.find(b=>b.id==="naming");g.score<g.max&&(g.score=Math.min(g.max,g.score+1),g.findings.push("Directory name matches frontmatter `name`."))}let c=l.reduce((g,b)=>g+b.score,0),f=l.reduce((g,b)=>g+b.max,0),d=Math.round(c/f*100),p="F";d>=90?p="A":d>=80?p="B":d>=65?p="C":d>=50&&(p="D");let m=[];l.find(g=>g.id==="structure")?.suggestions.includes(so)&&m.push(so);let h=[...l].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of h){for(let b of g.suggestions){if(m.length>=3)break;m.includes(b)||m.push(b)}if(m.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:l,overallScore:d,grade:p,topSuggestions:m,frontmatter:r}}async function bd(e){let t=no(e)?e:io(e),s;try{s=await mt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await to(i,"utf-8"),ss({content:n,skillPath:ve(t)==="SKILL.md"?ve(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=ht(t,"SKILL.md");try{n=await to(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await hd(t)}catch{r=void 0}return ss({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function hv(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function gv(e){let t=e.split(`
|
|
211
|
-
`),s=[],i=[],n=0;for(;n<t.length;){let c=t[n];if(!c.trim()){n++;continue}let d=c.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!d)return{newFrontmatter:e,changed:!1};let p=d[1],m=d[2];if(m===""||m===">"||m==="|"){let y=[c];for(n++;n<t.length;){let h=t[n];if(h.trim()===""){y.push(h),n++;continue}if(/^\s+/.test(h))y.push(h),n++;else break}i.push({key:p,text:y.join(`
|
|
212
|
-
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let f=dd.indexOf(c);return f===-1?dd.length+1:f},o=[...s].sort((c,f)=>{let d=r(c.key),p=r(f.key);return d!==p?d-p:s.indexOf(c)-s.indexOf(f)}),a=o.some((c,f)=>c!==s[f]);return{newFrontmatter:[...o.map(c=>c.text),...i.map(c=>c.text)].join(`
|
|
213
|
-
`),changed:a}}function yv(e,t={}){let s=[],i=[],n=e.replace(/\r\n/g,`
|
|
214
|
-
`);n!==e&&s.push({id:"normalise-line-endings",description:"Convert CRLF line endings to LF."});let r=n.split(`
|
|
215
|
-
`),o=r.map(g=>g.replace(/[ \t]+$/g,""));o.some((g,b)=>g!==r[b])&&s.push({id:"strip-trailing-whitespace",description:"Strip trailing whitespace from lines."}),n=o.join(`
|
|
216
|
-
`);let{rawFrontmatter:a,body:l}=gd(n),c=Z(n);if(a===null)return i.push({id:"missing-frontmatter",description:"SKILL.md has no frontmatter \u2014 not auto-fixable (requires author decisions)."}),{newContent:n,applied:s,skipped:i};let f=a;if(!!(c.version||c["metadata.version"])||(f=eo(f,"version","0.1.0"),s.push({id:"add-missing-version",description:"Add `version: 0.1.0`."})),!!!(c.author||c["metadata.author"]||c.creator||c["metadata.creator"])){let g=t.gitAuthor?.trim();g?(f=eo(f,"author",g),s.push({id:"add-missing-author",description:`Add \`author: ${g}\` from git config.`})):i.push({id:"add-missing-author",description:"Missing `author` \u2014 no git user.name found to fill in safely."})}if(!c.effort){let g=hv(yd(l));f=eo(f,"effort",g),s.push({id:"infer-missing-effort",description:`Infer \`effort: ${g}\` from body size.`})}c.description||i.push({id:"missing-description",description:"Missing `description` \u2014 content-level fix, left to the author."});let m=gv(f);m.changed&&(s.push({id:"reorder-frontmatter",description:"Reorder frontmatter fields to canonical order."}),f=m.newFrontmatter);let y=l.replace(/^\n+/,""),h=`---
|
|
217
|
-
${f.replace(/^\n+|\n+$/g,"")}
|
|
218
|
-
---
|
|
173
|
+
${l.bold("Examples:")}
|
|
174
|
+
asm disable code-review ${l.dim("# one skill")}
|
|
175
|
+
asm disable 'workflow*' ${l.dim("# glob")}
|
|
176
|
+
asm disable '*-review' ${l.dim("# glob suffix")}
|
|
177
|
+
asm disable openspec: ${l.dim("# prefix (colon)")}
|
|
178
|
+
asm disable asc- ${l.dim("# prefix (hyphen)")}
|
|
179
|
+
asm disable --all ${l.dim("# everything")}
|
|
180
|
+
asm disable code-review --tool claude --scope local`)}function wk(){console.log(`${l.bold("Usage:")} asm enable <target> [options]
|
|
181
|
+
asm enable --all [options]
|
|
219
182
|
|
|
220
|
-
${
|
|
221
|
-
|
|
222
|
-
`),e.replace(/\r\n/g,`
|
|
223
|
-
`),{newContent:h,applied:s,skipped:i}}function eo(e,t,s){if(new RegExp(`^${t}:\\s*`,"m").test(e))return e;let n=/[:#{}\[\],&*?|<>=!%@`"']/.test(s)?JSON.stringify(s):s,r=e.length===0||e.endsWith(`
|
|
224
|
-
`)?"":`
|
|
225
|
-
`;return`${e}${r}${t}: ${n}
|
|
226
|
-
`}function bv(e,t,s="SKILL.md"){if(e===t)return"";let i=e.split(`
|
|
227
|
-
`),n=t.split(`
|
|
228
|
-
`),r=[`--- a/${s}`,`+++ b/${s}`],o=0;for(;o<i.length&&o<n.length&&i[o]===n[o];)o++;let a=0;for(;a<i.length-o&&a<n.length-o&&i[i.length-1-a]===n[n.length-1-a];)a++;let l=i.slice(o,i.length-a),c=n.slice(o,n.length-a),f=o+1,d=o+1;r.push(`@@ -${f},${l.length} +${d},${c.length} @@`);let p=i.slice(Math.max(0,o-3),o).map(y=>` ${y}`),m=i.slice(i.length-a,Math.min(i.length,i.length-a+3)).map(y=>` ${y}`);r.push(...p);for(let y of l)r.push(`-${y}`);for(let y of c)r.push(`+${y}`);return r.push(...m),r.join(`
|
|
229
|
-
`)}async function wd(e,t){let s=no(e)?e:io(e),i,n=await mt(s).catch(()=>null);if(!n)throw new Error(`Skill path does not exist: ${s}`);if(n.isFile())i=s;else if(n.isDirectory())i=ht(s,"SKILL.md");else throw new Error(`Skill path is not a directory or file: ${s}`);let r;try{r=await to(i,"utf-8")}catch{throw new Error(`SKILL.md not found at ${i}.`)}let o=yv(r,{gitAuthor:t.gitAuthor}),a=bv(r,o.newContent),l=null;return!t.dryRun&&o.newContent!==r&&(l=`${i}.bak`,await ev(i,l),await Zw(i,o.newContent,"utf-8")),{report:ss({content:t.dryRun?r:o.newContent,skillPath:s,skillMdPath:i}),applied:o.applied,skipped:o.skipped,diff:a,dryRun:t.dryRun,backupPath:l,skillMdPath:i}}async function vd(){try{let{stdout:e,exitCode:t}=await H(["git","config","--global","--get","user.name"]);if(t!==0)return null;let s=e.trim();return s||null}catch{return null}}function wv(e,t,s=20){let i=Math.round(e/t*s);return"\u2588".repeat(i)+"\u2591".repeat(Math.max(0,s-i))}function Ci(e){let t=[];t.push(`Skill evaluation: ${e.skillPath}`),t.push(`SKILL.md: ${e.skillMdPath}`),t.push(""),t.push(`Overall score: ${e.overallScore}/100 (${e.grade})`);let s=(e.providers??[]).filter(i=>i.id!=="quality");for(let i of s){let n=i.passed?"pass":"fail",r=`${i.id}@${i.version}`;t.push(` ${r}: ${i.score}/100 ${n}`)}t.push(""),t.push("Categories:");for(let i of e.categories)t.push(` ${i.name.padEnd(28)} ${String(i.score).padStart(2)}/${i.max} ${wv(i.score,i.max)}`);if(t.push(""),e.topSuggestions.length>0){t.push("Top suggestions:");for(let i of e.topSuggestions)t.push(` \u2022 ${i}`)}else t.push("No suggestions \u2014 skill looks great.");for(let i of s){let n=vv(i.raw);if(n&&n.length>0){t.push(""),t.push(`${i.id}@${i.version} breakdown:`);for(let r of n){let o=r.passed?"\u221A":r.severity==="warning"?"\u26A0":"\xD7";t.push(` ${o} ${r.label}`),r.passed||t.push(` [${r.severity}] ${r.message}`)}continue}if(i.findings.length!==0){t.push(""),t.push(`${i.id}@${i.version} findings:`);for(let r of i.findings)t.push(` [${r.severity}] ${r.message}`)}}return t.join(`
|
|
230
|
-
`)}function vv(e){if(!e||typeof e!="object")return null;let t=e.checks;if(!Array.isArray(t))return null;let s=[];for(let i of t){if(!i||typeof i!="object")return null;let n=i;if(typeof n.id!="string"||typeof n.label!="string"||typeof n.passed!="boolean"||typeof n.message!="string"||n.severity!=="error"&&n.severity!=="warning")return null;s.push({id:n.id,label:n.label,passed:n.passed,severity:n.severity,message:n.message})}return s}function kd(e){return JSON.stringify(e,null,2)}function Sd(e){let t=[];if(e.applied.length===0&&e.skipped.length===0)return t.push("No fixes needed \u2014 SKILL.md is already clean."),t.join(`
|
|
231
|
-
`);if(e.applied.length>0){t.push(`${e.dryRun?"Would apply":"Applied"} ${e.applied.length} fix(es):`);for(let s of e.applied)t.push(` \u2022 ${s.description}`)}if(e.skipped.length>0){t.push(""),t.push(`Skipped ${e.skipped.length} issue(s) (not auto-fixable):`);for(let s of e.skipped)t.push(` \u2022 ${s.description}`)}return e.diff&&(t.push(""),t.push("Diff:"),t.push(e.diff)),!e.dryRun&&e.backupPath&&(t.push(""),t.push(`Backup: ${e.backupPath}`)),t.join(`
|
|
232
|
-
`)}async function kv(e){let t;try{t=await hd(e)}catch{return[]}let s=[];for(let i of t){if(i.startsWith(".")||i==="node_modules"||i==="dist"||i==="build")continue;let n=ht(e,i),r;try{r=await mt(n)}catch{continue}if(!r.isDirectory())continue;let o=ht(n,"SKILL.md");try{(await mt(o)).isFile()&&s.push(n)}catch{}}return s.sort((i,n)=>ve(i).localeCompare(ve(n))),s}async function pd(e){let t=ht(e,"SKILL.md");try{if((await mt(t)).isFile())return{kind:"single",skillDirs:[e]}}catch{}let s=await kv(e);return s.length>0?{kind:"collection",skillDirs:s}:{kind:"none",skillDirs:[]}}function oo(e){return e?!!(e.startsWith("github:")||/^https?:\/\/github\.com\//i.test(e)):!1}function md(e){return{skillPath:e,skillMdPath:ht(e,"SKILL.md"),label:ve(e)}}async function $d(e,t={}){if(!e)throw new Error("resolveEvalInput: input must be a non-empty string");if(oo(e)){if(!t.fetchRemote)throw new Error(`Remote evaluation is not available in this context: "${e}"`);let r=await t.fetchRemote(e),o;try{o=await pd(r.rootDir)}catch(a){throw await r.cleanup().catch(()=>{}),a}if(o.kind==="none")throw await r.cleanup().catch(()=>{}),new Error(`No SKILL.md found at ${r.rootDir} (source: ${e}). The location is neither a single skill nor a skill collection.`);return{targets:o.skillDirs.map(md),isCollection:o.kind==="collection",cleanup:r.cleanup,provenance:{input:e,remote:!0,sourceRef:r.sourceRef,commitSha:r.commitSha,tempPath:r.rootDir}}}let s=no(e)?e:io(e),i;try{i=await mt(s)}catch{throw new Error(`Skill path does not exist: ${s}`)}if(i.isFile())return{targets:[{skillPath:ve(s)==="SKILL.md"?ve(s):s,skillMdPath:s,label:ve(s)}],isCollection:!1,cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}};if(!i.isDirectory())throw new Error(`Skill path is not a directory or file: ${s}`);let n=await pd(s);if(n.kind==="none")throw new Error(`No SKILL.md found in ${s}. Pass a skill directory, a SKILL.md file, or a collection root with SKILL.md in its children.`);return{targets:n.skillDirs.map(md),isCollection:n.kind==="collection",cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}}}function xd(e){let t=e.filter(f=>f.report!==null),s=e.length,i=s-t.length;if(t.length===0)return{total:s,succeeded:0,failed:i,meanScore:null,top:null,bottom:null};let n=t.map(f=>f.report.overallScore),r=n.reduce((f,d)=>f+d,0)/n.length,o=Math.round(r),a=[...t].sort((f,d)=>d.report.overallScore-f.report.overallScore),l=a[0],c=a[a.length-1];return{total:s,succeeded:t.length,failed:i,meanScore:o,top:{label:l.label,score:l.report.overallScore},bottom:{label:c.label,score:c.report.overallScore}}}async function Ed(e,t,s){let i=new Array(e.length),n=0,r=Math.max(1,Math.floor(t)),o=[],a=Math.min(r,e.length);for(let l=0;l<a;l++)o.push((async()=>{for(;;){let c=n++;if(c>=e.length)break;i[c]=await s(e[c],c)}})());return await Promise.all(o),i}function Cd(e,t=28){let s=[];return s.push(""),s.push("Batch summary:"),s.push(` Skills evaluated: ${e.aggregate.succeeded}/${e.aggregate.total}`+(e.aggregate.failed>0?` (${e.aggregate.failed} failed)`:"")),e.aggregate.meanScore!==null&&s.push(` Mean score: ${e.aggregate.meanScore}/100`),e.aggregate.top&&s.push(` Top: ${e.aggregate.top.label} (${e.aggregate.top.score}/100)`),e.aggregate.bottom&&e.aggregate.bottom.label!==e.aggregate.top?.label&&s.push(` Bottom: ${e.aggregate.bottom.label} (${e.aggregate.bottom.score}/100)`),e.provenance.remote&&(e.provenance.sourceRef&&s.push(` Source: ${e.provenance.sourceRef}`),e.provenance.commitSha&&s.push(` Commit: ${e.provenance.commitSha}`),e.provenance.tempPath&&s.push(` Fetched to: ${e.provenance.tempPath}`)),s.join(`
|
|
233
|
-
`)}function Ad(e){return{provenance:{input:e.provenance.input,remote:e.provenance.remote,source_ref:e.provenance.sourceRef??null,commit_sha:e.provenance.commitSha??null,temp_path:e.provenance.tempPath??null},aggregate:{total:e.aggregate.total,succeeded:e.aggregate.succeeded,failed:e.aggregate.failed,mean_score:e.aggregate.meanScore,top:e.aggregate.top,bottom:e.aggregate.bottom},results:e.results.map(t=>({label:t.label,skill_path:t.skillPath,error:t.error,report:t.report?Ai(t.report,null):null}))}}function Ai(e,t=null){return{skill_path:e.skillPath,skill_md_path:e.skillMdPath,overall_score:e.overallScore,grade:e.grade,categories:e.categories.map(s=>({id:s.id,name:s.name,score:s.score,max:s.max,findings:s.findings,suggestions:s.suggestions})),top_suggestions:e.topSuggestions,providers:e.providers?.map(s=>({id:s.id,version:s.version,schemaVersion:s.schemaVersion,score:s.score,passed:s.passed,categories:s.categories.map(i=>({id:i.id,name:i.name,score:i.score,max:i.max,findings:i.findings??[]})),findings:s.findings}))??[],fix:t?{dry_run:t.dryRun,applied:t.applied,skipped:t.skipped,backup_path:t.backupPath,diff:t.diff}:null}}var Sv=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function $v(e){if(typeof e!="string")return null;let t=Sv.exec(e.trim());if(!t)return null;let[,s,i,n,r]=t;return{major:Number(s),minor:Number(i),patch:Number(n),prerelease:r?r.split("."):[]}}function xv(e,t){let s=$v(e);if(!s)throw new Error(`invalid semver: ${t} "${e}"`);return s}var ao=new Map;function lo(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("register: provider.id is required");if(xv(e.version,`provider ${e.id} version`),typeof e.schemaVersion!="number"||!Number.isInteger(e.schemaVersion))throw new Error(`register: provider ${e.id} schemaVersion must be an integer`);let t=ao.get(e.id)??[];if(t.some(s=>s.version===e.version))throw new Error(`register: provider ${e.id}@${e.version} already registered`);t.push(e),ao.set(e.id,t)}function Pi(){let e=[];for(let t of ao.values())for(let s of t)e.push(s);return e}import{stat as Ev}from"fs/promises";var Pd="quality",Nd="1.0.0",Id=1;function Cv(e){return e.topSuggestions.map(t=>({severity:"info",message:t}))}function Av(e){return e.categories.map(t=>({id:t.id,name:t.name,score:t.score,max:t.max}))}var Rd={id:Pd,version:Nd,schemaVersion:Id,description:"Static linter for SKILL.md structure, description, and safety.",async applicable(e){try{return(await Ev(e.skillMdPath)).isFile()?{ok:!0}:{ok:!1,reason:`${e.skillMdPath} is not a file`}}catch{return{ok:!1,reason:`SKILL.md not found at ${e.skillMdPath}`}}},async run(e,t){let s=await bd(e.skillPath);return{providerId:Pd,providerVersion:Nd,schemaVersion:Id,score:s.overallScore,passed:s.grade!=="F",categories:Av(s),findings:Cv(s),raw:s,startedAt:"",durationMs:0}}};var Dd=mo(Dr(),1);import{readFile as Pv,stat as Nv}from"fs/promises";import{basename as Iv}from"path";var Ld="skill-best-practice",Od="1.1.0",Td=1,Rv=new Set(["name","description","license","allowed-tools","metadata","compatibility","effort"]),Md=new Set(["low","medium","high","xhigh","max"]),co=250,Lv=/^\d+\.\d+\.\d+$/;function Ov(e){if(!e.startsWith("---"))return null;let t=e.split(`
|
|
234
|
-
`);if(t.length<3||t[0]?.trim()!=="---")return null;let s=t.findIndex((i,n)=>n>0&&i.trim()==="---");return s===-1?null:t.slice(1,s).join(`
|
|
235
|
-
`)}function Ni(e){return{severity:e.severity,message:e.message,code:e.id,categoryId:"validation"}}function W(e,t,s,i,n,r){e.push({id:t,label:s,passed:i,severity:n,message:r})}function Ii(e,t,s){return{skillPath:e.skillPath,skillMdPath:e.skillMdPath,validatedAt:new Date().toISOString(),checkCount:t.length,passedChecks:t.filter(i=>i.passed).length,checks:t,frontmatter:s}}async function Tv(e){let t=await Pv(e.skillMdPath,"utf-8"),s=[],i=Ov(t);if(i===null){W(s,"missing-frontmatter","Frontmatter exists",!1,"error","SKILL.md must start with a YAML frontmatter block.");let E=Ii(e,s,null);return{score:0,passed:!1,findings:s.map(Ni),raw:E}}W(s,"frontmatter-present","Frontmatter exists",!0,"error","SKILL.md contains a YAML frontmatter block.");let n;try{n=(0,Dd.parse)(i)}catch(E){W(s,"invalid-yaml","Frontmatter parses as YAML",!1,"error",`Invalid YAML in frontmatter: ${E?.message??String(E)}`);let x=Ii(e,s,null);return{score:0,passed:!1,findings:s.map(Ni),raw:x}}if(!n||typeof n!="object"||Array.isArray(n)){W(s,"frontmatter-not-object","Frontmatter is a mapping",!1,"error","Frontmatter must parse to a YAML object.");let E=Ii(e,s,null);return{score:0,passed:!1,findings:s.map(Ni),raw:E}}let r=n;W(s,"frontmatter-object","Frontmatter is a mapping",!0,"error","Frontmatter parses to a YAML object.");let o=Object.keys(r).filter(E=>!Rv.has(E));W(s,"allowed-keys","Allowed top-level keys only",o.length===0,"error",o.length===0?"Frontmatter uses only the allowed top-level keys.":`Unexpected frontmatter key(s): ${o.sort().join(", ")}.`);let a=r.name,l=typeof a=="string"?a.trim():"";if(W(s,"name-present","Name is present and non-empty",l.length>0,"error",l.length>0?"Frontmatter includes a non-empty `name`.":"Frontmatter must include a non-empty string `name`."),l.length>0){let E=/^[a-z0-9-]+$/.test(l)&&!l.startsWith("-")&&!l.endsWith("-")&&!l.includes("--")&&l.length<=64;W(s,"name-kebab-case","Name follows skill-best-practice naming rules",E,"error",E?"Name follows the skill-best-practice kebab-case naming rules.":"Name must be kebab-case, avoid consecutive/edge hyphens, and stay within 64 characters.")}let c=r.description,f=typeof c=="string"?c.trim():"";if(W(s,"description-present","Description is present and non-empty",f.length>0,"error",f.length>0?"Frontmatter includes a non-empty `description`.":"Frontmatter must include a non-empty string `description`."),f.length>0){let E=!f.includes(`
|
|
236
|
-
`)&&!f.includes("\r")&&!f.includes("<")&&!f.includes(">")&&f.length<=1024;W(s,"description-shape","Description follows skill-best-practice formatting rules",E,"error",E?"Description is single-line, angle-bracket free, and within 1024 characters.":"Description must be a single line, avoid angle brackets, and stay within 1024 characters.");let x=f.length<=co;W(s,"description-runtime-budget","Description fits the runtime context budget",x,"warning",x?`Description is ${f.length} chars (target \u2264 ${co}).`:`Description is ${f.length} chars; target \u2264 ${co}. The /skills listing truncates tail-first, often chopping the negative-trigger clause.`)}let d=r.effort;W(s,"effort-enum","Effort uses the supported enum",d===void 0||typeof d=="string"&&Md.has(d.trim()),"error",d===void 0||typeof d=="string"&&Md.has(d.trim())?"Effort is omitted or uses a supported value.":"Effort must be one of: low, medium, high, xhigh, max.");let p=r.compatibility;if(p!==void 0){let E=typeof p=="string"&&p.length<=500;W(s,"compatibility-shape","Compatibility is a short string",E,"error",E?"Compatibility is a valid short string.":"Compatibility must be a string no longer than 500 characters.")}let m=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:null,y=m?.version,h=typeof y=="string"||typeof y=="number"?String(y).trim():"",g=h.length>0;if(W(s,"metadata-version-present","metadata.version is present",g,"error",g?"Frontmatter declares `metadata.version`.":"Frontmatter must declare `metadata.version` (start new skills at 1.0.0)."),g){let E=Lv.test(h);W(s,"metadata-version-semver","metadata.version follows MAJOR.MINOR.PATCH",E,"error",E?"`metadata.version` follows semantic versioning.":`\`metadata.version\` must follow semantic versioning (e.g. 1.0.0); got "${h}".`)}let b=m?.author,w=typeof b=="string"&&b.trim().length>0;if(W(s,"metadata-author-present","metadata.author is present",w,"warning",w?"Frontmatter declares `metadata.author`.":"Add `metadata.author` (recommended for published skills) so users know who maintains the skill."),l.length>0){let E=Iv(e.skillPath),x=E===l;W(s,"name-matches-directory","Name matches the parent directory",x,"error",x?"Frontmatter `name` matches the skill directory.":`Frontmatter \`name\` ("${l}") must match the parent directory ("${E}").`)}let k=/don'?t use (?:for|when|if|on)|not (?:for|intended for|suitable for|meant for)\b|skip (?:for|when|if)|avoid (?:using )?(?:for|when|on)|never (?:use )?for\b|only (?:use )?for\b/i.test(f);W(s,"negative-trigger-clause","Description includes a negative-trigger clause",k,"warning",k?"Description names adjacent cases that should not trigger the skill.":"Description appears to lack a negative-trigger clause; consider naming adjacent cases that should not trigger the skill.");let S=Ii(e,s,r),v=S.checkCount===0?100:Math.round(S.passedChecks/S.checkCount*100),C=s.filter(E=>!E.passed).map(Ni);return{score:v,passed:C.every(E=>E.severity!=="error"),findings:C,raw:S}}var Fd={id:Ld,version:Od,schemaVersion:Td,description:"Deterministic SKILL.md best-practice validation (rules aligned with the skill-creator standard, v1.7.1).",async applicable(e){try{return(await Nv(e.skillMdPath)).isFile()?{ok:!0}:{ok:!1,reason:`${e.skillMdPath} is not a file`}}catch{return{ok:!1,reason:`SKILL.md not found at ${e.skillMdPath}`}}},async run(e,t){let s=await Tv(e);return{providerId:Ld,providerVersion:Od,schemaVersion:Td,score:s.score,passed:s.passed,categories:[{id:"validation",name:"Deterministic validation",score:s.raw.passedChecks,max:s.raw.checkCount,findings:s.findings.length>0?s.findings:void 0}],findings:s.findings,raw:s.raw,startedAt:"",durationMs:0}}};function _d(){lo(Rd),lo(Fd)}var jd=!1;function Ri(){jd||(_d(),jd=!0)}function Li(){return Ri(),Pi()}function qd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Bd(e,t,s,i,n){let r={severity:"error",message:i,code:n};return{providerId:e.id,providerVersion:e.version,schemaVersion:e.schemaVersion,score:0,passed:!1,categories:[],findings:[r],raw:void 0,startedAt:t,durationMs:s}}async function Oi(e,t,s={}){let i=new Date().toISOString(),n=performance.now(),r={id:e.id,version:e.version,schemaVersion:e.schemaVersion},o=new AbortController;s.signal&&(s.signal.aborted?o.abort(s.signal.reason):s.signal.addEventListener("abort",()=>o.abort(s.signal?.reason)));let a=null;typeof s.timeoutMs=="number"&&s.timeoutMs>0&&(a=setTimeout(()=>o.abort(new Error("timeout")),s.timeoutMs));let l={...s,signal:o.signal};try{let c=await Promise.race([e.run(t,l).then(p=>({kind:"ok",value:p})),new Promise(p=>{if(o.signal.aborted){p({kind:"timeout"});return}o.signal.addEventListener("abort",()=>p({kind:"timeout"}))})]),f=Math.max(0,Math.round(performance.now()-n));if(c.kind==="timeout"){let p=o.signal.reason,m=p instanceof Error&&p.message==="timeout"?`provider timed out after ${s.timeoutMs}ms`:`provider aborted: ${qd(p)}`;return Bd(r,i,f,m,p instanceof Error&&p.message==="timeout"?"timeout":"aborted")}let d=c.value;return{...d,providerId:r.id,providerVersion:r.version,schemaVersion:d.schemaVersion??r.schemaVersion,startedAt:i,durationMs:f}}catch(c){let f=Math.max(0,Math.round(performance.now()-n));return Bd(r,i,f,qd(c),"provider-threw")}finally{a&&clearTimeout(a)}}function Mv(e){return e>=90?"A":e>=80?"B":e>=65?"C":e>=50?"D":"F"}function Ud(e){return{id:e.providerId,version:e.providerVersion,schemaVersion:e.schemaVersion,score:e.score,passed:e.passed,categories:e.categories,findings:e.findings,raw:e.raw}}function Kd(e,t){return{providerId:e.providerId,providerVersion:e.providerVersion,schemaVersion:e.schemaVersion,passed:e.passed,overallScore:e.score,grade:Mv(e.score),categories:e.categories.map(s=>({id:s.id,name:s.name,score:s.score,max:s.max})),evaluatedAt:e.startedAt,evaluatedVersion:t}}function is(e){return[...e].sort((t,s)=>t.id==="quality"&&s.id!=="quality"?-1:s.id==="quality"&&t.id!=="quality"?1:t.id.localeCompare(s.id))}var te={SKILL_NOT_FOUND:"SKILL_NOT_FOUND",AUDIT_FAILED:"AUDIT_FAILED",INSTALL_FAILED:"INSTALL_FAILED",PUBLISH_FAILED:"PUBLISH_FAILED",NETWORK_ERROR:"NETWORK_ERROR",INVALID_ARGUMENT:"INVALID_ARGUMENT",UNKNOWN_ERROR:"UNKNOWN_ERROR"};function Qe(){let e=console.log,t=console.info,s=(...i)=>process.stderr.write(i.map(String).join(" ")+`
|
|
237
|
-
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function Vd(e){return{timestamp:new Date().toISOString(),asm_version:Bo,duration_ms:Math.round(performance.now()-e)}}function X(e,t,s){let i={version:1,command:e,status:"ok",data:t,meta:Vd(s)},n=process.stdout.isTTY?2:0;return JSON.stringify(i,null,n)}function se(e,t,s,i,n){let r={version:1,command:e,status:"error",error:{code:t,message:s,...n!==void 0?{details:n}:{}},meta:Vd(i)},o=process.stdout.isTTY?2:0;return JSON.stringify(r,null,o)}import{writeFile as _v,mkdir as jv,unlink as qv,readFile as Bv,readdir as Uv}from"fs/promises";import{join as ns}from"path";function uo(e){return e==="skills"||e.startsWith("skills/")?{priority:1,root:"skills/"}:e===".claude/skills"||e.startsWith(".claude/skills/")?{priority:2,root:".claude/skills/"}:e===".agent/skills"||e.startsWith(".agent/skills/")?{priority:3,root:".agent/skills/"}:e===".agents/skills"||e.startsWith(".agents/skills/")?{priority:3,root:".agents/skills/"}:{priority:4,root:"(other)"}}function Jd(e){let t=new Map;for(let r of e){let o=t.get(r.name);o?o.push(r):t.set(r.name,[r])}let s=[],i=[],n=new Set;for(let r of e){if(n.has(r.name))continue;n.add(r.name);let o=t.get(r.name);if(o.length===1){s.push(o[0]);continue}let a=0,l=uo(o[0].relPath);for(let f=1;f<o.length;f++){let d=uo(o[f].relPath);d.priority<l.priority&&(a=f,l=d)}let c=o[a];s.push(c),i.push({name:r.name,kept:{relPath:c.relPath,root:l.root},dropped:o.filter((f,d)=>d!==a).map(f=>({relPath:f.relPath,root:uo(f.relPath).root})),reason:l.priority===4?"first occurrence (no priority match)":`${l.root} priority`})}return{kept:s,decisions:i}}var Dv=[{label:"obfuscation:atob",pattern:/\batob\s*\(/},{label:"obfuscation:base64",pattern:/(?:^|[=:\s])[A-Za-z0-9+/]{40,}={1,2}(?:\s|$)/m},{label:"obfuscation:hex-escape",pattern:/\\x[0-9a-fA-F]{2}(?:\\x[0-9a-fA-F]{2}){3,}/},{label:"credential-leak:api-key",pattern:/\bAPI_KEY\s*=\s*['"][^'"]+['"]/},{label:"credential-leak:secret",pattern:/\bSECRET_KEY\s*=\s*['"][^'"]+['"]/},{label:"credential-leak:password",pattern:/\bPASSWORD\s*=\s*['"][^'"]+['"]/}];function Hd(e,t){let s=[];(!e.name||!e.name.trim())&&s.push("missing frontmatter field: name"),(!e.description||!e.description.trim())&&s.push("missing frontmatter field: description"),Fv(t).trim().length<20&&s.push("SKILL.md body too short (less than 20 chars of instructions)");for(let{label:n,pattern:r}of Dv)r.test(t)&&s.push(`malicious pattern detected: ${n}`);return{verified:s.length===0,reasons:s}}function Fv(e){let t=e.trimStart();if(!t.startsWith("---"))return t;let s=t.indexOf(`
|
|
238
|
-
---`,3);return s===-1?"":t.slice(s+4)}async function Kv(){let e=yt();return await jv(e,{recursive:!0}),e}function Vv(e,t){return`github:${e.owner}/${e.repo}${e.ref?`#${e.ref}`:""}${t?`:${t}`:""}`}async function Wd(e){await _e();let t;try{t=Fe(e)}catch(i){return{success:!1,repoIndex:null,error:i.message}}if(t.isLocal)return{success:!1,repoIndex:null,error:"Local paths are not supported for indexing. Use a GitHub source instead."};P(`ingester: cloning ${t.owner}/${t.repo}`);let s=null;try{s=await je(t),P(`ingester: discovering skills in ${s}`);let i=await gs(s);P(`ingester: found ${i.length} skills`);let{kept:n,decisions:r}=Jd(i);for(let f of r){let d=f.dropped.map(p=>p.relPath).join(", ");P(`ingester: dedupe "${f.name}": kept ${f.kept.relPath} (${f.reason}); dropped ${d}`)}r.length>0&&P(`ingester: deduped ${i.length} -> ${n.length} skills (${r.length} name collision${r.length===1?"":"s"})`);let o=[];for(let f of n){let d=ns(s,f.relPath,"SKILL.md"),p="";try{p=await Bv(d,"utf-8")}catch{P(`ingester: could not read SKILL.md at ${d}`)}let m=Hd(f,p);m.verified||P(`ingester: ${f.name} not verified: ${m.reasons.join(", ")}`);let y=typeof f.tokenCount=="number"?f.tokenCount:p?bt(p):void 0,h,g;if(p){let b;try{b=await Uv(ns(s,f.relPath))}catch{b=void 0}try{let w=ss({content:p,skillPath:f.relPath||f.name,skillMdPath:d,rootEntries:b});h={overallScore:w.overallScore,grade:w.grade,categories:w.categories.map(k=>({id:k.id,name:k.name,score:k.score,max:k.max})),evaluatedAt:w.evaluatedAt,evaluatedVersion:f.version||void 0}}catch(w){P(`ingester: eval failed for ${f.name}: ${w}`)}try{let w={skillPath:ns(s,f.relPath),skillMdPath:d},S=(await Promise.all(is(Li()).map(async v=>(await v.applicable(w,{})).ok?Oi(v,w):null))).filter(v=>v!==null).map(v=>Kd(v,f.version||void 0));S.length>0&&(g=Object.fromEntries(S.filter(v=>v.providerId).map(v=>[v.providerId,v])))}catch(w){P(`ingester: provider eval failed for ${f.name}: ${w}`)}}o.push({name:f.name,description:f.description,version:f.version,license:f.license,creator:f.creator,compatibility:f.compatibility,allowedTools:f.allowedTools,installUrl:Vv(t,f.relPath),relPath:f.relPath,verified:m.verified,tokenCount:y,evalSummary:h,evalSummaries:g})}let a={repoUrl:t.cloneUrl,owner:t.owner,repo:t.repo,updatedAt:new Date().toISOString(),skillCount:o.length,skills:o};a.bundles=yi([...await Lu(s,a),...Jr(a)]);let l=await Kv(),c=ns(l,`${t.owner}_${t.repo}.json`);return await _v(c,JSON.stringify(a,null,2)+`
|
|
239
|
-
`,"utf-8"),P(`ingester: wrote index to ${c}`),{success:!0,repoIndex:a}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await le(s)}}async function Gd(){return(await dt()).map(t=>({owner:t.owner,repo:t.repo,skillCount:t.skillCount,updatedAt:t.updatedAt})).sort((t,s)=>s.skillCount-t.skillCount)}async function Yd(e,t){let s=yt(),i=ns(s,`${e}_${t}.json`);try{return await qv(i),!0}catch{return!1}}import{join as fo,resolve as zd}from"path";function Gv(e){switch(e){case"dangerous":return 3;case"warning":return 2;case"caution":return 1;default:return 0}}function po(e){return{verdict:e.every(t=>t.verdict==="safe")?"safe":e.some(t=>t.verdict==="dangerous")?"dangerous":"warning",findings:e.map(t=>({skill:t.skillName,verdict:t.verdict,verdict_reason:t.verdictReason,total_files:t.totalFiles,total_lines:t.totalLines})),risk_score:e.reduce((t,s)=>t+Gv(s.verdict),0)}}function Yv(e){let t=e.slice(2),s={command:null,subcommand:null,positional:[],flags:{help:!1,version:!1,json:!1,yes:!1,noColor:!1,scope:"both",sort:"name",provider:null,name:null,force:!1,path:null,all:!1,verbose:!1,flat:!1,transport:"auto",method:"default",installed:!1,available:!1,has:[],missing:[],dryRun:!1,machine:!1,noCache:!1,fix:!1,compact:!1,summary:!1,groupBy:null,limit:0,concurrency:0,keep:!1,add:null,remove:null,description:null,author:null,tags:null,predefined:!1}},i=0;for(;i<t.length;){let n=t[i];if(n==="--help"||n==="-h")s.flags.help=!0;else if(n==="--version"||n==="-v")s.flags.version=!0;else if(n==="--json")s.flags.json=!0;else if(n==="--yes"||n==="-y")s.flags.yes=!0;else if(n==="--no-color")s.flags.noColor=!0;else if(n==="--scope"||n==="-s"){i++;let r=t[i],o=r==="local"?"project":r;o==="global"||o==="project"||o==="both"?s.flags.scope=o:($(`Invalid scope: "${r}". Must be global, local, project, or both.`),process.exit(2))}else if(n==="--sort"){i++;let r=t[i];r==="name"||r==="version"||r==="location"?s.flags.sort=r:($(`Invalid sort: "${r}". Must be name, version, or location.`),process.exit(2))}else if(n==="--provider"||n==="-p"||n==="--tool")i++,s.flags.provider=t[i]||null;else if(n==="--name")i++,s.flags.name=t[i]||null;else if(n==="--force"||n==="-f")s.flags.force=!0;else if(n==="--path")i++,s.flags.path=t[i]||null;else if(n==="--all")s.flags.all=!0;else if(n==="--verbose"||n==="-V")s.flags.verbose=!0;else if(n==="--flat")s.flags.flat=!0;else if(n==="--compact")s.flags.compact=!0;else if(n==="--summary")s.flags.summary=!0;else if(n==="--group-by"){i++;let r=t[i];r==="tool"||r==="scope"||r==="effort"?s.flags.groupBy=r:($(`Invalid --group-by: "${r}". Must be tool, scope, or effort.`),process.exit(2))}else if(n==="--limit"){i++;let r=t[i],o=Number(r);(!Number.isFinite(o)||o<0||!Number.isInteger(o))&&($(`Invalid --limit: "${r}". Must be a non-negative integer (0 means no limit).`),process.exit(2)),s.flags.limit=o}else if(n==="--installed")s.flags.installed=!0;else if(n==="--available")s.flags.available=!0;else if(n==="--concurrency"){i++;let r=t[i],o=Number(r);(!Number.isFinite(o)||o<1||!Number.isInteger(o))&&($(`Invalid --concurrency: "${r}". Must be a positive integer.`),process.exit(2)),s.flags.concurrency=o}else if(n==="--keep")s.flags.keep=!0;else if(n==="--transport"||n==="-t"){i++;let r=t[i];r==="https"||r==="ssh"||r==="auto"?s.flags.transport=r:($(`Invalid transport: "${r}". Must be https, ssh, or auto.`),process.exit(2))}else if(n==="--method"||n==="-m"){i++;let r=t[i];r==="default"||r==="vercel"?s.flags.method=r:($(`Invalid method: "${r}". Must be default or vercel.`),process.exit(2))}else n==="--skill"?(i++,s.flags.path=t[i]||null):n==="--dry-run"?s.flags.dryRun=!0:n==="--fix"?s.flags.fix=!0:n==="--machine"?s.flags.machine=!0:n==="--no-cache"?s.flags.noCache=!0:n==="--has"?(i++,t[i]&&s.flags.has.push(t[i])):n==="--missing"?(i++,t[i]&&s.flags.missing.push(t[i])):n==="--add"?(i++,s.flags.add=t[i]||null):n==="--remove"?(i++,s.flags.remove=t[i]||null):n==="--description"?(i++,s.flags.description=t[i]||null):n==="--author"?(i++,s.flags.author=t[i]||null):n==="--tags"?(i++,s.flags.tags=t[i]||null):n==="--predefined"?s.flags.predefined=!0:n.startsWith("-")?($(`Unknown option: ${n}`),console.error('Run "asm --help" for usage.'),process.exit(2)):s.command?s.subcommand?s.positional.push(n):s.subcommand=n:s.command=n;i++}return s}function $(e){console.error(u.red(`Error: ${e}`))}function zv(){console.log(`${u.blueBold("agent-skill-manager")} (${u.bold("asm")}) ${Ji}
|
|
183
|
+
Re-enable skills previously disabled with ${l.bold("asm disable")}. Enabling renames
|
|
184
|
+
${l.dim("SKILL.md.disabled")} back to ${l.dim("SKILL.md")} so asm and your agent see it again.
|
|
240
185
|
|
|
241
|
-
|
|
186
|
+
${l.dim("Note: a skill shared across tools via symlinks re-enables for every tool")}
|
|
187
|
+
${l.dim("at once (one shared SKILL.md); asm warns and clears state for all siblings.")}
|
|
242
188
|
|
|
243
|
-
${
|
|
244
|
-
|
|
245
|
-
|
|
189
|
+
${l.bold("Targets:")}
|
|
190
|
+
<name> Exact skill name or directory name
|
|
191
|
+
'<glob>*' Glob match (${l.dim("* matches any characters")})
|
|
192
|
+
<prefix>: | <prefix>- Prefix match (e.g. ${l.dim("openspec:")}, ${l.dim("asc-")})
|
|
246
193
|
|
|
247
|
-
${
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
audit security <name> Run security audit on a skill (or GitHub source)
|
|
257
|
-
export Export skill inventory as JSON manifest
|
|
258
|
-
import <file> Import skills from a previously exported manifest
|
|
259
|
-
init <name> Scaffold a new skill with SKILL.md template
|
|
260
|
-
stats Show aggregate skill metrics dashboard
|
|
261
|
-
link <path> Symlink a local skill directory into an agent
|
|
262
|
-
outdated Show which installed skills have newer versions
|
|
263
|
-
update [name...] Update outdated skills with security re-audit
|
|
264
|
-
publish [path] Validate, audit, and submit a skill to the registry
|
|
265
|
-
eval <skill-path> Evaluate a skill against best practices and score it
|
|
266
|
-
eval-providers list List registered eval providers (id, version, schema, \u2026)
|
|
267
|
-
bundle Manage skill bundles (create, install, list, show, remove)
|
|
268
|
-
index Manage skill index (ingest, search, list)
|
|
269
|
-
doctor Run environment health checks and diagnostics
|
|
270
|
-
config show Print current config
|
|
271
|
-
config path Print config file path
|
|
272
|
-
config reset Reset config to defaults
|
|
273
|
-
config edit Open config in $EDITOR
|
|
194
|
+
${l.bold("Options:")}
|
|
195
|
+
--all, -a Enable every matching disabled skill
|
|
196
|
+
-p, --tool <name> Limit to one tool/provider (e.g. claude, codex)
|
|
197
|
+
-s, --scope <s> Filter: global, local, project, or both (default: both)
|
|
198
|
+
-y, --yes Skip confirmation prompt
|
|
199
|
+
--json Output result as JSON
|
|
200
|
+
--machine Tab-separated output
|
|
201
|
+
--no-color Disable ANSI colors
|
|
202
|
+
-V, --verbose Show debug output
|
|
274
203
|
|
|
275
|
-
${
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
--
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
--no-color Disable ANSI colors
|
|
283
|
-
--sort <field> Sort by: name, version, or location (default: name)
|
|
284
|
-
--flat Show one row per tool instance (list, search)
|
|
285
|
-
-y, --yes Skip confirmation prompts
|
|
286
|
-
-V, --verbose Show debug output`)}function Qv(){console.log(`${u.bold("Usage:")} asm list [options]
|
|
204
|
+
${l.bold("Examples:")}
|
|
205
|
+
asm enable code-review
|
|
206
|
+
asm enable '*-review'
|
|
207
|
+
asm enable openspec:
|
|
208
|
+
asm enable --all`)}async function Bo(e,t,s,i,r){let n=new Map(e.providers.map(a=>[a.name,a])),o=[];for(let[a,c]of Object.entries(t.disabled))for(let[u,f]of Object.entries(c)){if(i&&u!==i)continue;let d=n.get(u);if(d)for(let p of["global","project"]){if(!f[p]||s==="global"&&p!=="global"||s==="project"&&p!=="project"||r?.has(`${a}||${u}||${p}`))continue;let m=p==="global"?d.global:d.project;if(!m)continue;let y=se(m),h=yk(y,a),g=gr(h);if(!gk(g))continue;let b={};try{b=W(await mk(g,"utf-8"))}catch{}let k=h;try{k=await hk(h)}catch{}o.push({name:b.name||a,version:b["metadata.version"]||b.version||"0.0.0",description:(b.description||"").replace(/\s*\n\s*/g," ").trim(),creator:b["metadata.creator"]||"",license:(b.license||"").trim(),compatibility:(b.compatibility||"").trim(),allowedTools:[],modelInvocable:Ht(b),userInvocable:Jt(b),dirName:a,path:h,originalPath:h,location:`${p}-${u}`,scope:p,provider:u,providerLabel:d.label,isSymlink:!1,symlinkTarget:null,realPath:k,disabled:!0})}}return o}function Hd(e,t){if(e.flags.json)console.log(JSON.stringify(t,null,2));else if(e.flags.machine)for(let s of t)console.log([s.name,s.provider,s.scope,s.action].join(" "))}async function Jd(e){if(e.flags.help){bk();return}let t=e.subcommand;if(!t&&!e.flags.all){$("Missing target. Provide a skill name/pattern or use --all."),process.exitCode=2;return}if(t&&e.flags.all){$("Provide either a target or --all, not both."),process.exitCode=2;return}let s=await j(),i=e.flags.provider,r=(await H(s,e.flags.scope)).filter(d=>d.provider!=="plugin"&&d.provider!=="codex-plugin"),n=i?r.filter(d=>d.provider===i):r,o=e.flags.all?n:qo(n,t);if(o.length===0){let d=t?` for '${t}'`:"";console.log(l.dim(`No matching active skills${d}.`));return}let a=mr(o,r),c=new Set(o.map(d=>`${d.realPath}||${d.provider}||${d.scope}`));if(!e.flags.json&&!e.flags.machine){let d=a.reduce((p,m)=>p+m.siblings.length,0);console.log(l.bold(`Will disable ${d} skill instance(s):`));for(let p of a){for(let m of p.siblings){let y=c.has(`${m.realPath}||${m.provider}||${m.scope}`)?"":l.yellow(" (shared via symlink)");console.log(` ${l.dim("\u2022")} ${m.name} (${m.provider}, ${m.scope})${y}`)}p.siblings.length>1&&console.log(l.yellow(` \u26A0 ${p.representative.name} shares one SKILL.md across ${p.siblings.length} tools \u2014 disabling affects all of them.`))}if(!e.flags.yes&&process.stdin.isTTY){process.stdout.write(`
|
|
209
|
+
${l.bold("Proceed?")} [y/N] `);let p=await K();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let u=await Is(),f=[];try{for(let d of a){await Vd(d.representative.path);for(let p of d.siblings)jd(u,p.dirName,p.provider,p.scope),f.push({name:p.name,provider:p.provider,scope:p.scope,action:"disabled"}),!e.flags.json&&!e.flags.machine&&console.log(`${l.green("\u2713")} disabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await jo(u)}Hd(e,f)}async function Wd(e){if(e.flags.help){wk();return}let t=e.subcommand;if(!t&&!e.flags.all){$("Missing target. Provide a skill name/pattern or use --all."),process.exitCode=2;return}if(t&&e.flags.all){$("Provide either a target or --all, not both."),process.exitCode=2;return}let s=await j(),i=e.flags.provider,r=await Is(),n=await Bo(s,r,e.flags.scope),o=i?n.filter(d=>d.provider===i):n,a=e.flags.all?o:qo(o,t);if(a.length===0){let d=t?` for '${t}'`:"";console.log(l.dim(`No matching disabled skills${d}.`));return}let c=mr(a,n),u=new Set(a.map(d=>`${d.realPath}||${d.provider}||${d.scope}`));if(!e.flags.json&&!e.flags.machine){let d=c.reduce((p,m)=>p+m.siblings.length,0);console.log(l.bold(`Will enable ${d} skill instance(s):`));for(let p of c){for(let m of p.siblings){let y=u.has(`${m.realPath}||${m.provider}||${m.scope}`)?"":l.yellow(" (shared via symlink)");console.log(` ${l.dim("\u2022")} ${m.name} (${m.provider}, ${m.scope})${y}`)}p.siblings.length>1&&console.log(l.yellow(` \u26A0 ${p.representative.name} shares one SKILL.md across ${p.siblings.length} tools \u2014 enabling affects all of them.`))}if(!e.flags.yes&&process.stdin.isTTY){process.stdout.write(`
|
|
210
|
+
${l.bold("Proceed?")} [y/N] `);let p=await K();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let f=[];try{for(let d of c){await Kd(d.representative.path);for(let p of d.siblings)qd(r,p.dirName,p.provider,p.scope),f.push({name:p.name,provider:p.provider,scope:p.scope,action:"enabled"}),!e.flags.json&&!e.flags.machine&&console.log(`${l.green("\u2713")} enabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await jo(r)}Hd(e,f)}function kk(){console.log(`${l.bold("Usage:")} asm list [options]
|
|
287
211
|
|
|
288
212
|
List all discovered skills. By default, skills installed across multiple
|
|
289
213
|
tools are grouped into a single row with tool badges. When more than
|
|
290
|
-
${
|
|
214
|
+
${Xr} skills are present, a compact summary is
|
|
291
215
|
automatically prepended above the table.
|
|
292
216
|
|
|
293
|
-
${
|
|
217
|
+
${l.bold("Options:")}
|
|
294
218
|
--sort <field> Sort by: name, version, or location (default: name)
|
|
295
219
|
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
296
220
|
-p, --tool <p> Filter by tool (claude, codex, openclaw, agents)
|
|
@@ -299,253 +223,297 @@ ${u.bold("Options:")}
|
|
|
299
223
|
--summary Print only the summary (counts by tool/scope/effort)
|
|
300
224
|
--group-by <axis> Group rows under headers (axis: tool | scope | effort)
|
|
301
225
|
--limit <N> Limit rendered rows (0 = no limit)
|
|
226
|
+
--model-invocable Only skills the model can invoke
|
|
227
|
+
--user-invocable Only skills the user can invoke (slash command)
|
|
302
228
|
--json Output as JSON array
|
|
303
229
|
--machine Output in stable machine-readable v1 envelope format
|
|
304
230
|
--no-color Disable ANSI colors
|
|
305
231
|
-V, --verbose Show debug output
|
|
306
232
|
|
|
307
|
-
${
|
|
308
|
-
asm list ${
|
|
309
|
-
asm list --flat ${
|
|
310
|
-
asm list --compact ${
|
|
311
|
-
asm list --summary ${
|
|
312
|
-
asm list --group-by tool ${
|
|
313
|
-
asm list --group-by scope ${
|
|
314
|
-
asm list --group-by effort ${
|
|
315
|
-
asm list --limit 20 ${
|
|
316
|
-
asm list -p claude ${
|
|
317
|
-
asm list -s project ${
|
|
318
|
-
asm list --sort version ${
|
|
319
|
-
asm list --json ${
|
|
320
|
-
asm list --machine ${
|
|
233
|
+
${l.bold("Examples:")}
|
|
234
|
+
asm list ${l.dim("List all skills (grouped)")}
|
|
235
|
+
asm list --flat ${l.dim("One row per tool instance")}
|
|
236
|
+
asm list --compact ${l.dim("One line per skill (dense)")}
|
|
237
|
+
asm list --summary ${l.dim("Counts by tool/scope/effort only")}
|
|
238
|
+
asm list --group-by tool ${l.dim("Group rows under tool headers")}
|
|
239
|
+
asm list --group-by scope ${l.dim("Group rows under scope headers")}
|
|
240
|
+
asm list --group-by effort ${l.dim("Group rows under effort headers")}
|
|
241
|
+
asm list --limit 20 ${l.dim("Show first 20 rows only")}
|
|
242
|
+
asm list -p claude ${l.dim("Only Claude Code skills")}
|
|
243
|
+
asm list -s project ${l.dim("Only project-scoped skills")}
|
|
244
|
+
asm list --sort version ${l.dim("Sort by version")}
|
|
245
|
+
asm list --json ${l.dim("Output as JSON")}
|
|
246
|
+
asm list --machine ${l.dim("Machine-readable v1 envelope output")}`)}async function Yd(e){if(e.flags.help){kk();return}let t=performance.now(),s=await j(),i=await H(s,e.flags.scope),r=await Is(),n=new Set(i.map(c=>`${c.dirName}||${c.provider}||${c.scope}`)),o=await Bo(s,r,e.flags.scope,e.flags.provider,n);i=[...i,...o],e.flags.provider&&e.command==="list"&&(i=i.filter(c=>c.provider===e.flags.provider)),(e.flags.modelInvocable||e.flags.userInvocable)&&(i=i.filter(c=>kt(c,{modelInvocable:e.flags.modelInvocable,userInvocable:e.flags.userInvocable}))),await Ps(i);let a=li(i,e.flags.sort);if(e.flags.machine){let c=a.map(u=>({name:u.name,version:u.version,description:u.description,scope:u.scope,provider:u.provider,path:u.path}));console.log(G("list",c,t));return}if(e.flags.json)console.log(U(a));else if(e.flags.flat){let c=ri(a),u=a.filter(f=>f.warnings&&f.warnings.length>0);u.length>0&&(c+=`
|
|
247
|
+
${l.yellow(`${u.length} skill${u.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(c)}else if(e.flags.summary)console.log(Qr(a));else if(e.flags.groupBy){let{skills:c,hint:u}=ni(a,e.flags.limit);console.log(wl(c,e.flags.groupBy)),u&&console.log(u)}else if(e.flags.compact){let{skills:c,hint:u}=ni(a,e.flags.limit);console.log(bl(c)),u&&console.log(u)}else{let c=[];a.length>Xr&&(c.push(Qr(a,{showHint:!1})),c.push(""));let{skills:u,hint:f}=ni(a,e.flags.limit);c.push(kl(u)),f&&c.push(f),console.log(c.join(`
|
|
248
|
+
`))}}import{readdir as vk,readFile as Sk}from"fs/promises";import{join as $k}from"path";function Uo(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var xk=10,Ek=5,Pk=3,Ik=1;function Ck(e,t){let s=Uo(e),i=Uo(t.name),r=Uo(t.description),n=0;for(let o of s)i.has(o)&&(n+=xk),r.has(o)&&(n+=Pk),t.name.toLowerCase().includes(o)&&(n+=Ek),t.description.toLowerCase().includes(o)&&(n+=Ik);return n}async function zd(e){let t=new Map,s;try{s=await vk(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let r=$k(e,i);try{let n=await Sk(r,"utf-8"),o=JSON.parse(n);for(let a of o.skills){let c=a;(!("license"in c)||c.license===void 0)&&(c.license=""),(!("creator"in c)||c.creator===void 0)&&(c.creator=""),(!("compatibility"in c)||c.compatibility===void 0)&&(c.compatibility=""),(!("allowedTools"in c)||c.allowedTools===void 0)&&(c.allowedTools=[]),(!("verified"in c)||c.verified===void 0)&&(c.verified=!1)}t.set(`${o.owner}/${o.repo}`,o)}catch{}}return t}async function Pe(){let e=await zd(Pl()),t=await zd(Yt()),s=new Map(e);for(let[i,r]of t)s.set(i,r);return Array.from(s.values())}var Lk=["license","creator","version"];function Xd(e){return Lk.includes(e)}function Qd(e,t){return e[t]||""}function Ak(e,t){if(!kt(e,t))return!1;if(t.has){for(let s of t.has)if(Xd(s)&&!Qd(e,s))return!1}if(t.missing){for(let s of t.missing)if(Xd(s)&&Qd(e,s))return!1}return!0}function Zd(e){let t=[];return e.license||t.push("license"),e.creator||t.push("creator"),(!e.version||e.version==="0.0.0")&&t.push("version"),t}async function Cs(e,t=20,s){let i=await Pe(),r=[],n=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!Ak(a,s))continue;let c=n?1:Ck(e,a);c>0&&r.push({skill:a,repo:{owner:o.owner,repo:o.repo},score:c})}return r.sort((o,a)=>a.score-o.score),r.slice(0,t)}async function Rk(){let e=await Pe(),t=[];for(let s of e)for(let i of s.skills)t.push({skill:i,repo:{owner:s.owner,repo:s.repo}});return t}async function ef(){return(await Pe()).reduce((t,s)=>t+s.skillCount,0)}async function tf(e,t){let s=e.trim().toLowerCase();if(!s)return{status:"none"};let r=(t??await Rk()).filter(a=>a.skill.name.toLowerCase()===s);if(r.length===0)return{status:"none"};let n=new Set,o=[];for(let a of r){let c=`${a.repo.owner}/${a.repo.repo}:${a.skill.relPath}`;n.has(c)||(n.add(c),o.push(a))}return o.length===1?{status:"found",match:o[0]}:{status:"ambiguous",matches:o}}function Nk(){console.log(`${l.bold("Usage:")} asm search <query> [options]
|
|
321
249
|
|
|
322
250
|
Search both installed skills and the skill index. Results show installation
|
|
323
251
|
status and include copy-paste install commands for available skills.
|
|
324
252
|
|
|
325
|
-
${
|
|
253
|
+
${l.bold("Options:")}
|
|
326
254
|
--sort <field> Sort by: name, version, or location (default: name)
|
|
327
255
|
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
328
256
|
-p, --tool <p> Filter by tool (claude, codex, openclaw, agents)
|
|
329
257
|
--installed Show only installed skills
|
|
330
258
|
--available Show only available (not installed) skills
|
|
259
|
+
--model-invocable Only skills the model can invoke
|
|
260
|
+
--user-invocable Only skills the user can invoke (slash command)
|
|
331
261
|
--flat Show one row per tool instance (ungrouped)
|
|
332
262
|
--json Output as JSON array
|
|
333
263
|
--machine Output in stable machine-readable v1 envelope format
|
|
334
264
|
--no-color Disable ANSI colors
|
|
335
265
|
-V, --verbose Show debug output
|
|
336
266
|
|
|
337
|
-
${
|
|
338
|
-
asm search code ${
|
|
339
|
-
asm search review -p claude ${
|
|
340
|
-
asm search "test" --installed ${
|
|
341
|
-
asm search "test" --available ${
|
|
342
|
-
asm search openspec --json ${
|
|
343
|
-
asm search openspec --machine ${
|
|
267
|
+
${l.bold("Examples:")}
|
|
268
|
+
asm search code ${l.dim("Search installed and available skills")}
|
|
269
|
+
asm search review -p claude ${l.dim("Search within Claude Code only")}
|
|
270
|
+
asm search "test" --installed ${l.dim("Search installed skills only")}
|
|
271
|
+
asm search "test" --available ${l.dim("Search available skills only")}
|
|
272
|
+
asm search openspec --json ${l.dim("Output matches as JSON")}
|
|
273
|
+
asm search openspec --machine ${l.dim("Machine-readable v1 envelope output")}`)}async function sf(e){if(e.flags.help){Nk();return}let t=e.flags.machine?me():void 0,s=performance.now(),i=e.subcommand;i||(e.flags.machine&&(t?.(),console.log(z("search",Y.INVALID_ARGUMENT,"Missing required argument: <query>",s)),process.exit(2)),$("Missing required argument: <query>"),console.error('Run "asm search --help" for usage.'),process.exit(2));let r=!e.flags.available,n=!e.flags.installed,o=[];if(r){let f=await j(),d=await H(f,e.flags.scope);e.flags.provider&&(d=d.filter(m=>m.provider===e.flags.provider)),(e.flags.modelInvocable||e.flags.userInvocable)&&(d=d.filter(m=>kt(m,{modelInvocable:e.flags.modelInvocable,userInvocable:e.flags.userInvocable})));let p=Cl(d,i);o=li(p,e.flags.sort)}let a=[];if(n&&(a=await Cs(i,20,e.flags.modelInvocable||e.flags.userInvocable?{modelInvocable:e.flags.modelInvocable||void 0,userInvocable:e.flags.userInvocable||void 0}:void 0),o.length>0)){let f=new Set(o.map(d=>d.name.toLowerCase()));a=a.filter(d=>!f.has(d.skill.name.toLowerCase()))}if(e.flags.machine){t?.();let f=o.map(p=>({name:p.name,description:p.description,source:"installed",url:null,match_count:1})),d=a.map(p=>({name:p.skill.name,description:p.skill.description,source:"index",url:p.skill.installUrl,match_count:1}));console.log(G("search",[...f,...d],s));return}if(e.flags.json){let f=o.map(p=>({name:p.name,description:p.description,version:p.version,scope:p.scope,provider:p.provider,status:"installed"})),d=a.map(p=>({name:p.skill.name,description:p.skill.description,version:p.skill.version,repo:`${p.repo.owner}/${p.repo.repo}`,installCommand:`asm install ${p.skill.installUrl}`,status:"available"}));console.log(U([...f,...d]));return}let c=o.length>0,u=a.length>0;if(!c&&!u){console.error(`No skills matching "${i}".`),console.error(l.dim("Try ingesting more repos with: asm index ingest <repo>"));return}if(c&&(console.error(l.bold(`Installed skills matching "${i}":
|
|
274
|
+
`)),e.flags.flat?console.log(ri(o)):console.log(vl(o,i))),u){c&&console.error("");let f=Sl(a.map(d=>({name:d.skill.name,version:d.skill.version,description:d.skill.description,verified:d.skill.verified,repoLabel:`${d.repo.owner}/${d.repo.repo}`,installUrl:d.skill.installUrl,invocability:hl(d.skill.modelInvocable,d.skill.userInvocable)})),i);console.error(f)}}function Tk(){console.log(`${l.bold("Usage:")} asm inspect <skill-name> [options]
|
|
344
275
|
|
|
345
276
|
Show detailed information for a skill. The <skill-name> is the directory name.
|
|
346
277
|
Shows version, description, file count, and all provider installations.
|
|
347
278
|
|
|
348
|
-
${
|
|
279
|
+
${l.bold("Options:")}
|
|
349
280
|
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
350
281
|
--json Output as JSON object
|
|
351
282
|
--no-color Disable ANSI colors
|
|
352
283
|
-V, --verbose Show debug output
|
|
353
284
|
|
|
354
|
-
${
|
|
355
|
-
asm inspect code-review ${
|
|
356
|
-
asm inspect code-review --json ${
|
|
357
|
-
asm inspect code-review -s global ${
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
asm uninstall code-review -s project ${u.dim("Remove project copy only")}
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
security <name|source> Run security audit on an installed skill or GitHub source
|
|
285
|
+
${l.bold("Examples:")}
|
|
286
|
+
asm inspect code-review ${l.dim("Show details for code-review")}
|
|
287
|
+
asm inspect code-review --json ${l.dim("Output as JSON")}
|
|
288
|
+
asm inspect code-review -s global ${l.dim("Global installations only")}`)}async function rf(e){if(e.flags.help){Tk();return}let t=e.subcommand;t||($("Missing required argument: <skill-name>"),console.error('Run "asm inspect --help" for usage.'),process.exit(2));let s=await j(),r=(await H(s,e.flags.scope)).filter(n=>n.dirName===t);r.length===0&&($(`Skill "${t}" not found.`),console.error(l.dim(`Try ${l.bold("asm list")} to see all skills or ${l.bold(`asm search "${t}"`)} to search.`)),process.exit(1)),await Ps(r),e.flags.json?console.log(U(r.length===1?r[0]:r)):console.log(await Ll(r))}var Tt=class extends Error{candidates;constructor(t,s){super(t),this.name="AmbiguousGetError",this.candidates=s}};import{readFile as Ur}from"fs/promises";import{execFile as Ok}from"child_process";import{promisify as Mk}from"util";import{mkdtemp as nf,readdir as Dk,readFile as br,rm as wr,cp as _k,access as Ko,stat as cf,lstat as Fk,mkdir as jk}from"fs/promises";import{join as Ie,resolve as Ls,relative as qk,basename as uf,sep as Bk}from"path";import{homedir as of}from"os";import{tmpdir as af}from"os";var Ot=Mk(Ok),Uk=/^[a-zA-Z0-9_-]+$/,Vk=/^[a-zA-Z0-9._-]+$/,Kk=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,lf=128,Gk=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function ct(e){return e.startsWith("/")||e.startsWith("./")||e.startsWith(".\\")||e.startsWith("../")||e.startsWith("..\\")||e.startsWith("~/")||e.startsWith("~\\")||e==="~"||e==="."||e===".."||/^[a-zA-Z]:[/\\]/.test(e)}async function Rs(e){if(!e.includes("/")&&!e.includes("\\"))return!1;try{return(await cf(Ls(e))).isDirectory()}catch{return!1}}function df(e){let t;e==="~"?t=of():e.startsWith("~/")||e.startsWith("~\\")?t=Ls(of(),e.slice(2)):t=Ls(e);let s=uf(t);return A(`install: parsed local source -> path=${t}`),{owner:"local",repo:s,ref:null,subpath:null,cloneUrl:"",sshCloneUrl:"",isLocal:!0,localPath:t}}function ce(e){if(ct(e))return df(e);let t=Gk.exec(e);if(t){let[,d,p,m]=t,y=p.endsWith(".git")?p.slice(0,-4):p;e=`github:${d}/${y}${m?`#${m}`:""}`}if(!e.startsWith("github:"))throw new Error(`Invalid source format. Got: "${e}"
|
|
289
|
+
Supported formats:
|
|
290
|
+
github:owner/repo[#ref]
|
|
291
|
+
github:owner/repo#ref:path
|
|
292
|
+
https://github.com/owner/repo
|
|
293
|
+
https://github.com/owner/repo/tree/branch/path/to/skill
|
|
294
|
+
/path/to/local/skill
|
|
295
|
+
./relative/path/to/skill`);let s=e.slice(7),i=s.indexOf("#"),r,n=null,o=null;if(i!==-1){r=s.slice(0,i);let d=s.slice(i+1);if(!d)throw new Error("Invalid source: ref cannot be empty after #");let p=d.indexOf(":");if(p!==-1){if(n=d.slice(0,p),!n)throw new Error("Invalid source: ref cannot be empty before :");o=d.slice(p+1)||null}else n=d}else{let d=s.indexOf(":");d!==-1?(r=s.slice(0,d),o=s.slice(d+1)||null):r=s}let a=r.indexOf("/");if(a===-1)throw new Error(`Invalid source: format must be github:owner/repo. Got: "${e}"`);let c=r.slice(0,a),u=r.slice(a+1);if(!c)throw new Error("Invalid source: owner cannot be empty");if(!u)throw new Error("Invalid source: repo cannot be empty");if(!Uk.test(c))throw new Error(`Invalid source: owner contains invalid characters: "${c}". Allowed: [a-zA-Z0-9_-]`);if(!Vk.test(u))throw new Error(`Invalid source: repo contains invalid characters: "${u}". Allowed: [a-zA-Z0-9._-]`);let f={owner:c,repo:u,ref:n,subpath:o,cloneUrl:`https://github.com/${c}/${u}.git`,sshCloneUrl:`git@github.com:${c}/${u}.git`};return A(`install: parsed source -> owner=${c} repo=${u} ref=${n} subpath=${o}`),f}function As(e){return!!e&&e.split(/[/\\]/).includes("..")}function he(e,t){if(As(e.subpath)||As(e.ref))throw new Error(`Invalid source: the subpath in "${t}" escapes the repository.`)}function Fe(e,t,s){let i=Ls(e),r=Ls(t);if(r!==i&&!r.startsWith(i+Bk))throw new Error(`Invalid source: the subpath in "${s}" escapes the repository.`)}async function ut(e){if(e.subpath!==null||!e.ref||!e.ref.includes("/"))return e;try{let{stdout:t}=await Ot("git",["ls-remote","--heads","--tags",e.cloneUrl],{timeout:15e3}),s=new Set;for(let r of t.split(`
|
|
296
|
+
`)){let n=r.match(/\trefs\/(?:heads|tags)\/(.+)$/);n&&s.add(n[1])}let i=e.ref.split("/");for(let r=1;r<i.length;r++){let n=i.slice(0,r).join("/");if(s.has(n)){let o=i.slice(r).join("/");return A(`install: resolved ref="${n}" subpath="${o}"`),{...e,ref:n,subpath:o||null}}}}catch(t){A(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function ge(e){if(!e)throw new Error("Invalid skill name: name cannot be empty");if(e.includes("\0"))throw new Error("Invalid skill name: contains unsafe characters (null byte)");if(e.includes(".."))throw new Error("Invalid skill name: contains unsafe characters (..)");if(e.includes("/")||e.includes("\\"))throw new Error("Invalid skill name: contains unsafe characters (path separator)");if(e.startsWith("."))throw new Error("Invalid skill name: must not start with a dot");if(e.length>lf)throw new Error(`Invalid skill name: exceeds maximum length of ${lf} characters`);if(!Kk.test(e))throw new Error(`Invalid skill name: "${e}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return e}function kr(e){let t=e.split(/[/\\]/).filter(Boolean),s=t.length>0?t[t.length-1]:e;return ge(s)}function Go(e,t=kr){let s=new Map;for(let i of e){let r=t(i),n=s.get(r);n?n.push(i):s.set(r,[i])}return[...s.entries()].filter(([,i])=>i.length>1).map(([i,r])=>({name:i,paths:r}))}async function Ce(){try{await Ot("git",["--version"]),A("install: git available")}catch{throw new Error("git is required for installing skills. Install git from https://git-scm.com")}}function ff(e){if(e.killed)return!1;let t=(e.stderr||e.message||"").toLowerCase();return t.includes("authentication failed")||t.includes("could not read username")||t.includes("repository not found")||t.includes("returned error: 403")||t.includes("returned error: 401")||t.includes("terminal prompts disabled")||t.includes("permission denied")}function yr(e){return e.killed?"Clone timed out after 60 seconds":`Clone failed: ${e.stderr||e.message}`}async function Vo(e,t,s){if(t!==null&&/^[0-9a-f]{40}$/i.test(t))return await Ot("git",["clone","--no-checkout",e,s],{timeout:6e4}),await Ot("git",["checkout",t],{cwd:s,timeout:3e4}),s;let r=["clone","--depth","1"];return t&&r.push("--branch",t),r.push(e,s),await Ot("git",r,{timeout:6e4}),s}async function Le(e,t="auto"){A(`install: cloning ${e.owner}/${e.repo}${e.ref?` (ref: ${e.ref})`:""} (transport: ${t})`);let s=await nf(Ie(af(),"asm-install-"));if(t==="ssh"||t==="https"){let i=t==="ssh"?e.sshCloneUrl:e.cloneUrl;try{return await Vo(i,e.ref,s)}catch(r){await Q(s);let n=r;throw new Error(yr(n),{cause:r})}}try{return await Vo(e.cloneUrl,e.ref,s)}catch(i){if(!ff(i))throw await Q(s),new Error(yr(i),{cause:i});A("install: HTTPS clone failed with auth error, retrying with SSH..."),await Q(s);let r=await nf(Ie(af(),"asm-install-"));try{return await Vo(e.sshCloneUrl,e.ref,r)}catch(n){throw await Q(r),new Error(`Clone failed with both transports:
|
|
297
|
+
HTTPS: ${yr(i)}
|
|
298
|
+
SSH: ${yr(n)}`,{cause:n})}}}async function ye(e){let t=Ie(e,"SKILL.md"),s;try{s=await br(t,"utf-8")}catch{throw new Error("Not a valid skill: SKILL.md not found in repository root")}let i=W(s),r=e.split(/[/\\]/).pop()||"unknown",n=i.name||r,o=de(i);return A(`install: validated skill "${n}" v${o}`),{name:n,version:o,description:(i.description||"").replace(/\s*\n\s*/g," ").trim(),effort:i.effort||i["metadata.effort"]||void 0}}async function dt(e,t=5){let s=[];try{let r=await br(Ie(e,"SKILL.md"),"utf-8"),n=W(r);s.push({relPath:"",name:n.name||uf(e),version:de(n),description:(n.description||"").replace(/\s*\n\s*/g," ").trim(),effort:n.effort||n["metadata.effort"]||void 0,license:(n.license||"").trim(),creator:(n["metadata.creator"]||"").trim(),compatibility:(n.compatibility||"").trim(),allowedTools:Yr(n),modelInvocable:Ht(n),userInvocable:Jt(n),tokenCount:je(r)})}catch{}async function i(r,n,o){let a;try{a=await Dk(r)}catch{return}for(let c of a){if(c===".git"||c==="node_modules")continue;let u=Ie(r,c);try{if(!(await cf(u)).isDirectory())continue}catch{continue}let f=n?`${n}/${c}`:c,d=o+1,p=Ie(u,"SKILL.md");try{let m=await br(p,"utf-8"),y=W(m);s.push({relPath:f,name:y.name||c,version:de(y),description:(y.description||"").replace(/\s*\n\s*/g," ").trim(),effort:y.effort||y["metadata.effort"]||void 0,license:(y.license||"").trim(),creator:(y["metadata.creator"]||"").trim(),compatibility:(y.compatibility||"").trim(),allowedTools:Yr(y),modelInvocable:Ht(y),userInvocable:Jt(y),tokenCount:je(m)})}catch{d<t&&await i(u,f,d)}}}return await i(e,"",0),s.sort((r,n)=>r.name.localeCompare(n.name)),s}async function pf(e,t=Ot){let s=Ie(e,"scripts"),i=Ie(s,"package.json");try{await Ko(i)}catch{A(`install: no scripts/package.json in ${e}; skipping npm install`);return}A(`install: installing script dependencies in ${s}`);try{await t("npm",["install"],{cwd:s,timeout:12e4})}catch(r){let n=r;throw new Error(`Installed skill, but failed to install dependencies in scripts/: ${n.stderr||n.message}`,{cause:r})}}var Hk=[{category:"Shell commands",pattern:/\b(bash|sh\s+-c)\b/},{category:"Shell commands",pattern:/\bexec\(/},{category:"Shell commands",pattern:/\bchild_process\b/},{category:"Shell commands",pattern:/\bBun\.spawn\b/},{category:"Code execution",pattern:/\beval\(/},{category:"Code execution",pattern:/\bFunction\(/},{category:"Code execution",pattern:/\bnew\s+Function\b/},{category:"Credentials",pattern:/\b(API_KEY|SECRET|TOKEN|PASSWORD)\s*[=:]/},{category:"External URLs",pattern:/https?:\/\//}];async function Ns(e){let t=[],s=await ui(e);for(let{relPath:i,content:r}of s){let n=r.split(`
|
|
299
|
+
`);for(let o=0;o<n.length;o++)for(let{category:a,pattern:c}of Hk)if(c.test(n[o])){let u=n[o].trim();t.push({category:a,file:i,line:o+1,match:u.length>100?u.slice(0,100)+"\u2026":u})}}return t}var Jk=["Shell commands","Code execution","Credentials"],Wk=["External URLs"];function Ts(e){return e.some(t=>Jk.includes(t.category))?"high":e.some(t=>Wk.includes(t.category))?"medium":"safe"}async function Mt(e){let t=e.source.isLocal?`local:${e.source.localPath}`:`github:${e.source.owner}/${e.source.repo}${e.source.ref?`#${e.source.ref}`:""}${e.source.subpath?`:${e.source.subpath}`:""}`;if(e.force)try{await Ko(e.targetDir),await wr(e.targetDir,{recursive:!0,force:!0})}catch{}let s=e.sourceDir;try{await _k(s,e.targetDir,{recursive:!0})}catch(a){let c=a instanceof Error?a.message:String(a);throw new Error(`Failed to install: ${c}`,{cause:a})}let i=Ie(e.targetDir,".git");try{await wr(i,{recursive:!0,force:!0})}catch{}A(`install: copied files to ${e.targetDir}`);let r=Ie(e.targetDir,"SKILL.md");try{await Ko(r)}catch{throw new Error("Installation verification failed: SKILL.md not found at target")}await pf(e.targetDir);let n=await br(r,"utf-8"),o=W(n);return{success:!0,path:e.targetDir,name:o.name||e.skillName,version:de(o),provider:e.providerLabel,source:t}}async function Ho(e,t){let s=await Mt(e);for(let i of t){if(i.name===e.providerName)continue;let r=e.scope==="project"?i.project:i.global,n=se(r),o=Ie(n,e.skillName);await jk(n,{recursive:!0});try{if((await Fk(o)).isSymbolicLink())await wr(o);else{A(`install: skipping ${o} \u2014 existing non-symlink directory`);continue}}catch{}let a=qk(n,e.targetDir);await qe(a,o),A(`install: symlinked ${o} -> ${a}`)}return s.provider=`All (${t.map(i=>i.label).join(", ")})`,s}async function Q(e){try{await wr(e,{recursive:!0,force:!0})}catch{}}import{execFile as tv}from"child_process";import{promisify as sv}from"util";import{readFile as iv,access as Xo}from"fs/promises";import{existsSync as rv}from"fs";import{join as pt,dirname as nv}from"path";var Wo=class{selected;cursor;scrollOffset;pageSize;itemCount;filter;searchActive;filteredMap;constructor(t,s){this.selected=t.map(i=>i.checked),this.cursor=1,this.scrollOffset=0,this.pageSize=s,this.itemCount=t.length,this.filter="",this.searchActive=!1,this.filteredMap=t.map((i,r)=>r)}get totalRows(){return this.filteredMap.length+1}applyFilter(t){if(this.filter==="")this.filteredMap=t.map((s,i)=>i);else{let s=this.filter.toLowerCase();this.filteredMap=[];for(let i=0;i<t.length;i++)(t[i].label.toLowerCase()+" "+(t[i].hint?.toLowerCase()??"")).includes(s)&&this.filteredMap.push(i)}this.cursor>=this.totalRows&&(this.cursor=Math.max(0,this.totalRows-1)),this.scrollOffset>0&&this.scrollOffset>=this.totalRows&&(this.scrollOffset=Math.max(0,this.totalRows-this.pageSize))}cursorToOriginalIndex(){return this.cursor===0?-1:this.filteredMap[this.cursor-1]??-1}toggleCurrent(){if(this.cursor===0)this.toggleAll();else{let t=this.cursorToOriginalIndex();t>=0&&(this.selected[t]=!this.selected[t])}}toggleAll(){let t=this.filteredMap,i=!t.every(r=>this.selected[r]);for(let r of t)this.selected[r]=i}moveUp(){this.cursor>0?this.cursor--:this.cursor=this.totalRows-1,this.adjustScroll()}moveDown(){this.cursor<this.totalRows-1?this.cursor++:this.cursor=0,this.adjustScroll()}getSelectedIndices(){let t=[];for(let s=0;s<this.selected.length;s++)this.selected[s]&&t.push(s);return t}getVisibleRange(){let t=this.scrollOffset,s=Math.min(this.scrollOffset+this.pageSize,this.totalRows);return{start:t,end:s}}adjustScroll(){this.cursor<this.scrollOffset?this.scrollOffset=this.cursor:this.cursor>=this.scrollOffset+this.pageSize&&(this.scrollOffset=this.cursor-this.pageSize+1)}};function Yk(e,t,s){let i=[];if(e.searchActive||e.filter!==""){let u=l.cyan("/"),f=e.filter,d=e.searchActive?l.cyan("\u2588"):"";i.push(` ${u}${f}${d}`),e.filteredMap.length===0&&i.push(l.dim(" No matches found")),i.push("")}let{start:r,end:n}=e.getVisibleRange();r>0&&i.push(l.dim(` ... ${r} more above`));for(let u=r;u<n;u++){let d=u===e.cursor?l.cyan(">"):" ";if(u===0){let p=e.filteredMap,y=p.length>0&&p.every(g=>e.selected[g])?l.green("[*]"):"[ ]",h=e.filter!==""?`Select All Matching (${e.filteredMap.length})`:"Select All / Deselect All";i.push(`${d} ${y} ${l.bold(h)}`)}else{let p=e.filteredMap[u-1],m=t[p],h=e.selected[p]?l.green("[*]"):"[ ]",g=`${d} ${h} `,b=7,k=l.bold(m.label),S=m.label.length;if(m.hint){let v=s-b-S-2;if(v>10){let x=Jo(m.hint,v);i.push(`${g}${k} ${l.dim(x)}`)}else{let x=Jo(m.label,s-b);i.push(`${g}${l.bold(x)}`)}}else{let v=Jo(m.label,s-b);i.push(`${g}${l.bold(v)}`)}}}let o=e.totalRows-n;o>0&&i.push(l.dim(` ... ${o} more below`));let a=e.getSelectedIndices().length,c=e.filter!==""?` matching: ${e.filteredMap.length}/${e.itemCount}`:"";return i.push(""),e.searchActive?i.push(l.dim(` ${a} of ${e.itemCount} selected${c} | Type to filter Esc Clear Enter Done searching`)):i.push(l.dim(` ${a} of ${e.itemCount} selected${c} | \u2191/\u2193 Navigate Space Toggle a All / Search Enter Confirm Esc Cancel`)),i}function Jo(e,t){return t<=0?"":e.length<=t?e:t<=3?e.slice(0,t):e.slice(0,t-3)+"..."}async function ft(e){let{items:t}=e,s=e.pageSize??Math.min(t.length+1,15),i=new Wo(t,s),r=process.stderr,n=process.stdin,o=r.columns||80;typeof n.setRawMode=="function"&&n.setRawMode(!0),n.resume(),n.setEncoding("utf-8"),r.write("\x1B[?25l");let a=0;function c(){let u=Yk(i,t,o);a>0&&r.write(`\x1B[${a}F`);let f=Math.max(u.length,a),d="";for(let p=0;p<f;p++)d+=`\x1B[2K${p<u.length?u[p]:""}
|
|
300
|
+
`;r.write(d),a=f}return c(),new Promise(u=>{let f="",d=null;function p(){n.removeListener("data",h),typeof n.setRawMode=="function"&&n.setRawMode(!1),n.pause(),r.write("\x1B[?25h"),d&&clearTimeout(d)}function m(g){p(),u(g)}function y(g){if(i.searchActive){if(g==="\x1B"){i.searchActive=!1,i.filter="",i.applyFilter(t),c();return}if(g==="\r"||g===`
|
|
301
|
+
`){i.searchActive=!1,c();return}if(g==="\x7F"||g==="\b"){i.filter.length>0?(i.filter=i.filter.slice(0,-1),i.applyFilter(t)):i.searchActive=!1,c();return}if(g===""){p(),process.kill(process.pid,"SIGINT");return}if(g==="\x1B[A"){i.moveUp(),c();return}if(g==="\x1B[B"){i.moveDown(),c();return}if(g===" "){i.toggleCurrent(),c();return}if(g.length===1&&g>=" "&&g<="~"){i.filter+=g,i.applyFilter(t),c();return}return}switch(g){case"\x1B[A":case"k":i.moveUp(),c();break;case"\x1B[B":case"j":i.moveDown(),c();break;case" ":i.toggleCurrent(),c();break;case"a":i.toggleAll(),c();break;case"/":i.searchActive=!0,c();break;case"\r":case`
|
|
302
|
+
`:m(i.getSelectedIndices());break;case"\x1B":i.filter!==""?(i.filter="",i.applyFilter(t),c()):m([]);break;case"\x7F":case"\b":i.filter.length>0&&(i.filter=i.filter.slice(0,-1),i.applyFilter(t),c());break;case"":p(),process.kill(process.pid,"SIGINT");break}}function h(g){if(f.length>0){if(f+=g,d&&clearTimeout(d),f.length>=3&&f[1]==="["){let k=f.slice(0,3),S=f.slice(3);f="",y(k),S&&h(S);return}let b=f;f="",y("\x1B");for(let k=1;k<b.length;k++)y(b[k]);return}for(let b=0;b<g.length;b++){let k=g[b];if(k==="\x1B"){let S=g.slice(b);if(S.length>=3&&S[1]==="[")y(S.slice(0,3)),b+=2;else if(S.length>=2){f=S,d=setTimeout(()=>{let v=f;f="",y("\x1B");for(let x=1;x<v.length;x++)y(v[x])},50);return}else{f="\x1B",d=setTimeout(()=>{f="",y("\x1B")},50);return}}else y(k)}}n.on("data",h)})}import{access as zk,lstat as Xk,mkdir as Qk,readdir as Zk,readFile as mf,rm as ev,stat as hf}from"fs/promises";import{join as vr}from"path";async function Yo(e){let t;try{t=await hf(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=vr(e,"SKILL.md"),i;try{i=await mf(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let r=W(i);if(!r.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:r.name,version:de(r)}}async function Sr(e,t,s,i){let r=vr(t,s),n=!1;try{await zk(r),n=!0}catch{}if(n){if(!i)throw new Error(`Target already exists: ${r}. Use --force to overwrite.`);await ev(r,{recursive:!0,force:!0})}await Qk(t,{recursive:!0}),await qe(e,r)}async function zo(e){let t;try{t=await hf(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=await Zk(e),i=[];for(let r of s){if(r.startsWith(".")||r==="node_modules")continue;let n=vr(e,r);try{if(!(await Xk(n)).isDirectory())continue}catch{continue}let o=vr(n,"SKILL.md");try{let a=await mf(o,"utf-8"),c=W(a);c.name&&i.push({absPath:n,dirName:r,name:c.name,version:de(c)})}catch{}}return i.sort((r,n)=>r.name.localeCompare(n.name)),i}var gf=sv(tv);function yf(e=nv(process.execPath)){let t=[pt(e,"node_modules","npm","bin","npx-cli.js"),pt(e,"..","lib","node_modules","npm","bin","npx-cli.js"),pt(e,"..","libexec","lib","node_modules","npm","bin","npx-cli.js")];for(let s of t)if(rv(s))return s;return null}function bf(e,t={}){if(process.platform==="win32"){let s=yf();if(s)return gf(process.execPath,[s,...e],t)}return gf("npx",e,t)}async function Qo(){try{await bf(["--version"]),A("install: npx available")}catch{throw new Error("npx is required for Vercel method installation. Install Node.js from https://nodejs.org")}}async function Zo(e,t){let s=["--yes","skills","add",e];t&&s.push("--skill",t),A(`install: running npx ${s.join(" ")}`);try{let i=await bf(s,{timeout:12e4});return{stdout:i.stdout,stderr:i.stderr}}catch(i){let r=i,n=r.stderr||r.message||"";throw new Error(`npx skills add failed: ${n}`,{cause:i})}}function ea(e){if(e.isLocal)return e.localPath;let t=`https://github.com/${e.owner}/${e.repo}`;return e.ref?`${t}/tree/${e.ref}${e.subpath?`/${e.subpath}`:""}`:t}async function be(e,t,s){let i=e.providers.filter(m=>m.enabled);if(t==="all"){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");return{provider:i.find(y=>y.name==="agents")||i[0],allProviders:i}}if(t){let m=e.providers.find(y=>y.name===t);if(!m){let y=e.providers.map(h=>h.name).join(", ");throw new Error(`Unknown provider: "${t}". Valid providers: ${y}, all`)}if(!m.enabled)throw new Error(`Provider "${t}" is disabled. Enable it in your config or choose another provider.`);return{provider:m,allProviders:null}}if(i.length===1)return{provider:i[0],allProviders:null};if(!s){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");let m=i.map(y=>y.name).join(", ");throw new Error(`--tool (or --provider) is required in non-interactive mode. Available: ${m}, all`)}let r=e.preferences.selectedTools,o=r&&r.length>0?new Set(r):null,a=e.providers.map(m=>({label:`${m.label} (${m.name})`,hint:m.global,checked:o?o.has(m.name):m.name==="agents"})),c=await ft({items:a});if(c.length===0)throw new Error("No tools selected. Aborting.");let u=c.map(m=>e.providers[m]),f=u.map(m=>m.name),{saveSelectedTools:d}=await import("./config-AZYQEQOQ.js");return await d(f),u.length===1?{provider:u[0],allProviders:null}:{provider:u.find(m=>m.name==="agents")||u[0],allProviders:u}}function Os(e,t,s,i,r,n,o="global"){let a=o==="project"?r.project:r.global,c=se(a),u=pt(c,i);return{source:e,tempDir:t,sourceDir:s,targetDir:u,skillName:i,force:n,providerName:r.name,providerLabel:r.label,scope:o}}async function ta(e,t){try{if(await Xo(e),A(`install: target ${e} \u2014 conflict (exists)${t?", force overwrite":""}`),!t)throw new Error(`Skill already exists at: ${e}
|
|
303
|
+
Use --force to overwrite.`)}catch(s){if(s instanceof Error&&s.message?.includes("--force"))throw s;A(`install: target ${e} \u2014 no conflict`)}}async function sa(e,t,s){for(let i of s.providers){if(!i.enabled||i.name===t)continue;let r=se(i.global),n=pt(r,e);try{await Xo(n);let o=pt(n,"SKILL.md");await Xo(o);let a=await iv(o,"utf-8");if((W(a).name||n.split(/[/\\]/).pop()||"")===e)return A(`install: cross-tool link found \u2014 "${e}" already installed in ${i.label} at ${n}`),{existingProvider:i.name,existingProviderLabel:i.label,existingPath:n,isLocalSource:!1}}catch{continue}}return null}async function ia(e,t,s,i,r,n=!1){let o=r.providers.find(f=>f.name===s);if(!o)throw new Error(`Target provider "${s}" not found in config.`);let a=i==="project"?o.project:o.global,c=se(a),u=pt(c,e);return await Sr(t,c,e,n),A(`install: linked "${e}" from ${t} -> ${u}`),u}import{join as pv}from"path";import{readFile as ov,writeFile as av,mkdir as lv}from"fs/promises";import{dirname as cv}from"path";async function uv(e){try{let t=await ov(e,"utf-8"),s=JSON.parse(t);return!s.fetched_at||s.data===void 0||s.data===null?null:s}catch{return null}}async function dv(e,t,s){let i={fetched_at:new Date().toISOString(),ttl_seconds:s,data:t};try{await lv(cv(e),{recursive:!0}),await av(e,JSON.stringify(i,null,2),"utf-8"),A(`http: wrote cache -> ${e}`)}catch(r){A(`http: failed to write cache: ${r}`)}}function fv(e){let t=new Date(e.fetched_at).getTime();return(Date.now()-t)/1e3<e.ttl_seconds}async function wf(e,t,s={}){let i=s.ttl??3600,r=s.noCache??!1,n=await uv(t);if(n&&!r&&fv(n))return A(`http: cache hit (fresh) -> ${t}`),n.data;try{A(`http: fetching -> ${e}`);let o=await fetch(e);if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);let a=await o.json();return await dv(t,a,i),a}catch(o){return A(`http: fetch failed: ${o}`),n?(A(`http: using stale cache as fallback -> ${t}`),n.data):null}}var mv=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,hv=/^[a-zA-Z0-9_-]+$/,Sf=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9._-]+$/,gv=/^[0-9a-f]{40}$/,yv=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/,bv=/^[a-z0-9-]+$/,wv=/^sha256:[0-9a-f]{64}$/,kf=["pass","warning","dangerous"];function $r(e){let t=[];if(!e||typeof e!="object"||Array.isArray(e))return[{field:"(root)",message:"manifest must be a non-null object"}];let s=e,i=new Set(["name","author","description","repository","commit","skill_path","version","license","tags","security_verdict","published_at","checksum"]);for(let o of Object.keys(s))i.has(o)||t.push({field:o,message:`unknown property "${o}" is not allowed`});let r=[{field:"name",pattern:mv,maxLength:128},{field:"author",pattern:hv,maxLength:39},{field:"description",maxLength:256},{field:"repository",pattern:Sf},{field:"commit",pattern:gv},{field:"published_at"}];for(let{field:o,pattern:a,maxLength:c}of r){let u=s[o];if(u==null){t.push({field:o,message:`required field "${o}" is missing`});continue}if(typeof u!="string"){t.push({field:o,message:`"${o}" must be a string`});continue}if(u.length===0){t.push({field:o,message:`"${o}" must not be empty`});continue}c&&u.length>c&&t.push({field:o,message:`"${o}" exceeds maximum length of ${c}`}),a&&!a.test(u)&&t.push({field:o,message:`"${o}" does not match required pattern`})}let n=s.security_verdict;if(n==null?t.push({field:"security_verdict",message:'required field "security_verdict" is missing'}):(typeof n!="string"||!kf.includes(n))&&t.push({field:"security_verdict",message:`"security_verdict" must be one of: ${kf.join(", ")}`}),typeof s.published_at=="string"&&s.published_at.length>0&&(/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[+-]\d{2}:\d{2})$/.test(s.published_at)||t.push({field:"published_at",message:'"published_at" must be a valid ISO 8601 date-time'})),s.version!==void 0&&(typeof s.version!="string"||!yv.test(s.version))&&t.push({field:"version",message:'"version" must be a valid semver string'}),s.license!==void 0&&(typeof s.license!="string"?t.push({field:"license",message:'"license" must be a string'}):s.license.length>64&&t.push({field:"license",message:'"license" exceeds maximum length of 64'})),s.tags!==void 0)if(!Array.isArray(s.tags))t.push({field:"tags",message:'"tags" must be an array'});else{s.tags.length>10&&t.push({field:"tags",message:'"tags" has more than 10 items'});let o=new Set;for(let a=0;a<s.tags.length;a++){let c=s.tags[a];if(typeof c!="string"){t.push({field:`tags[${a}]`,message:"tag must be a string"});continue}c.length>32&&t.push({field:`tags[${a}]`,message:`tag "${c}" exceeds maximum length of 32`}),bv.test(c)||t.push({field:`tags[${a}]`,message:`tag "${c}" does not match pattern (lowercase alphanumeric and hyphens)`}),o.has(c)&&t.push({field:`tags[${a}]`,message:`duplicate tag "${c}"`}),o.add(c)}}return s.checksum!==void 0&&(typeof s.checksum!="string"||!wv.test(s.checksum))&&t.push({field:"checksum",message:'"checksum" must match pattern sha256:<64-hex-chars>'}),s.skill_path!==void 0&&(typeof s.skill_path!="string"?t.push({field:"skill_path",message:'"skill_path" must be a string'}):s.skill_path.length===0?t.push({field:"skill_path",message:'"skill_path" must not be empty'}):s.skill_path.length>256?t.push({field:"skill_path",message:'"skill_path" exceeds maximum length of 256'}):/\.\.|^\//.test(s.skill_path)&&t.push({field:"skill_path",message:'"skill_path" must not contain ".." or start with "/"'})),t}function kv(e,t){let s=e.length,i=t.length;if(s===0)return i;if(i===0)return s;let r=new Array(i+1),n=new Array(i+1);for(let o=0;o<=i;o++)r[o]=o;for(let o=1;o<=s;o++){n[0]=o;for(let a=1;a<=i;a++){let c=e[o-1]===t[a-1]?0:1;n[a]=Math.min(r[a]+1,n[a-1]+1,r[a-1]+c)}[r,n]=[n,r]}return r[i]}function vv(e,t,s=2){let i=[];for(let r of t){if(e===r)continue;let n=kv(e,r);n<=s&&i.push({existingName:r,distance:n})}return i.sort((r,n)=>r.distance-n.distance)}var ra=process.env.ASM_REGISTRY_URL??"https://raw.githubusercontent.com/luongnv89/asm-registry/main/index.json";function Sv(){return process.env.ASM_REGISTRY_CACHE??pv(oi(),"registry-cache.json")}var $v=3600;function Qe(e){if(e.startsWith("github:")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("~/")||e==="~"||e==="."||e==="..")return!1;let t=(e.match(/\//g)||[]).length;if(t>1)return!1;if(t===1){let[s,i]=e.split("/");return/^[a-zA-Z0-9_-]+$/.test(s)&&/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(i)}return/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(e)}function na(e){return Qe(e)?e.includes("/"):!1}async function oa(e){let t=await wf(ra,Sv(),{ttl:$v,noCache:e?.noCache});if(!t)return null;if(typeof t!="object"||!Array.isArray(t.manifests)||typeof t.generated_at!="string")return A("registry: fetched index has invalid structure \u2014 discarding"),null;let s=[];for(let i of t.manifests){let r=$r(i);if(r.length>0){A(`registry: dropping invalid manifest entry (${i?.name??"unknown"}): ${r.map(n=>n.message).join(", ")}`);continue}if(!Sf.test(i.repository)){A(`registry: dropping manifest with unexpected repository URL: ${i.repository}`);continue}s.push(i)}return{generated_at:t.generated_at,manifests:s}}function xv(e,t){return t.manifests.filter(s=>s.name.toLowerCase()===e.toLowerCase())}function Ev(e,t,s){return s.manifests.find(i=>i.author.toLowerCase()===e.toLowerCase()&&i.name.toLowerCase()===t.toLowerCase())??null}function vf(e,t,s=5){return vv(e,t.manifests.map(r=>r.name),3).slice(0,s).map(r=>r.existingName)}async function xr(e,t){let s=await oa(t);if(!s)return A("registry: failed to fetch index \u2014 skipping registry resolution"),{resolved:null,multipleMatches:[],suggestions:[]};if(na(e)){let[n,o]=e.split("/"),a=Ev(n,o,s);if(a)return{resolved:{manifest:a,source:"registry"},multipleMatches:[],suggestions:[]};let c=vf(o,s);return{resolved:null,multipleMatches:[],suggestions:c}}let i=xv(e,s);if(i.length===1)return{resolved:{manifest:i[0],source:"registry"},multipleMatches:[],suggestions:[]};if(i.length>1)return{resolved:null,multipleMatches:i,suggestions:[]};let r=vf(e,s);return{resolved:null,multipleMatches:[],suggestions:r}}var Ef=[{category:"Network requests",description:"Commands or APIs that download or upload data over the network",pattern:/\bcurl\b/,severity:"critical",permissionType:"network"},{category:"Network requests",description:"Commands or APIs that download or upload data over the network",pattern:/\bwget\b/,severity:"critical",permissionType:"network"},{category:"Network requests",description:"Commands or APIs that download or upload data over the network",pattern:/\bfetch\s*\(/,severity:"warning",permissionType:"network"},{category:"Network requests",description:"Commands or APIs that download or upload data over the network",pattern:/\baxios\b/,severity:"warning",permissionType:"network"},{category:"Network requests",description:"Commands or APIs that download or upload data over the network",pattern:/\bhttp\.request\b/,severity:"warning",permissionType:"network"},{category:"Network requests",description:"Commands or APIs that download or upload data over the network",pattern:/\bXMLHttpRequest\b/,severity:"warning",permissionType:"network"},{category:"External URLs",description:"Hardcoded URLs that may indicate data exfiltration or remote payload loading",pattern:/https?:\/\/(?!github\.com|localhost|127\.0\.0\.1|example\.com)/,severity:"warning",permissionType:"network"},{category:"Shell execution",description:"Commands that execute shell processes or arbitrary system commands",pattern:/\bexec\s*\(/,severity:"critical",permissionType:"shell"},{category:"Shell execution",description:"Commands that execute shell processes or arbitrary system commands",pattern:/\bexecSync\b/,severity:"critical",permissionType:"shell"},{category:"Shell execution",description:"Commands that execute shell processes or arbitrary system commands",pattern:/\bchild_process\b/,severity:"critical",permissionType:"shell"},{category:"Shell execution",description:"Commands that execute shell processes or arbitrary system commands",pattern:/\bspawn\s*\(/,severity:"critical",permissionType:"shell"},{category:"Shell execution",description:"Commands that execute shell processes or arbitrary system commands",pattern:/\bBun\.spawn\b/,severity:"critical",permissionType:"shell"},{category:"Shell execution",description:"Commands that execute shell processes or arbitrary system commands",pattern:/\bshelljs\b/,severity:"critical",permissionType:"shell"},{category:"Shell execution",description:"Commands that execute shell processes or arbitrary system commands",pattern:/\b(?:bash|sh|zsh)\s+-c\b/,severity:"critical",permissionType:"shell"},{category:"Dynamic code execution",description:"Patterns that execute dynamically constructed code at runtime",pattern:/\beval\s*\(/,severity:"critical",permissionType:"code-execution"},{category:"Dynamic code execution",description:"Patterns that execute dynamically constructed code at runtime",pattern:/\bnew\s+Function\b/,severity:"critical",permissionType:"code-execution"},{category:"Dynamic code execution",description:"Patterns that execute dynamically constructed code at runtime",pattern:/\bFunction\s*\(/,severity:"critical",permissionType:"code-execution"},{category:"Dynamic code execution",description:"Patterns that execute dynamically constructed code at runtime",pattern:/\bimport\s*\(\s*[^'"]/,severity:"warning",permissionType:"code-execution"},{category:"File system access",description:"Operations that read, write, or modify files on disk",pattern:/\bfs\.(?:write|append|unlink|rm|mkdir|rename)\b/,severity:"warning",permissionType:"filesystem"},{category:"File system access",description:"Operations that read, write, or modify files on disk",pattern:/\bwriteFile(?:Sync)?\b/,severity:"warning",permissionType:"filesystem"},{category:"File system access",description:"Operations that read, write, or modify files on disk",pattern:/\brm\s+-rf?\b/,severity:"critical",permissionType:"filesystem"},{category:"File system access",description:"Operations that read, write, or modify files on disk",pattern:/\bchmod\b/,severity:"warning",permissionType:"filesystem"},{category:"Embedded credentials",description:"Hardcoded secrets, API keys, tokens, or passwords",pattern:/\b(?:API_KEY|SECRET_KEY|ACCESS_TOKEN|PRIVATE_KEY)\s*[=:]/,severity:"critical"},{category:"Embedded credentials",description:"Hardcoded secrets, API keys, tokens, or passwords",pattern:/\bPASSWORD\s*[=:]/,severity:"critical"},{category:"Embedded credentials",description:"Hardcoded secrets, API keys, tokens, or passwords",pattern:/(?:sk|pk)[-_](?:live|test)[-_][a-zA-Z0-9]{20,}/,severity:"critical"},{category:"Environment variable access",description:"Reading environment variables which may contain secrets or configuration",pattern:/\bprocess\.env\b/,severity:"info",permissionType:"environment"},{category:"Environment variable access",description:"Reading environment variables which may contain secrets or configuration",pattern:/\bBun\.env\b/,severity:"info",permissionType:"environment"},{category:"Obfuscation patterns",description:"Base64 encoding, hex strings, or other obfuscation techniques",pattern:/\batob\s*\(/,severity:"warning"},{category:"Obfuscation patterns",description:"Base64 encoding, hex strings, or other obfuscation techniques",pattern:/\bBuffer\.from\s*\([^,]+,\s*['"]base64['"]\)/,severity:"warning"},{category:"Obfuscation patterns",description:"Base64 encoding, hex strings, or other obfuscation techniques",pattern:/\\x[0-9a-fA-F]{2}(?:\\x[0-9a-fA-F]{2}){5,}/,severity:"warning"}];async function Pv(e,t){let s={owner:e,repo:t,profileUrl:`https://github.com/${e}`,reposUrl:`https://github.com/${e}?tab=repositories`,isOrganization:null,publicRepos:null,accountAge:null,fetchError:null};try{let i=await fetch(`https://api.github.com/users/${e}`,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"agent-skill-manager"},signal:AbortSignal.timeout(1e4)});if(!i.ok)return s.fetchError=`GitHub API returned ${i.status}`,s;let r=await i.json();if(s.isOrganization=r.type==="Organization",s.publicRepos=typeof r.public_repos=="number"?r.public_repos:null,typeof r.created_at=="string"){let n=new Date(r.created_at),o=new Date,a=Math.floor((o.getTime()-n.getTime())/(365.25*24*60*60*1e3)),c=Math.floor((o.getTime()-n.getTime())%(365.25*24*60*60*1e3)/(30.44*24*60*60*1e3));s.accountAge=a>0?`${a}y ${c}m`:`${c}m`}A(`security-audit: source analysis for ${e} -> repos=${s.publicRepos}, org=${s.isOrganization}, age=${s.accountAge}`)}catch(i){s.fetchError=i.message||"Failed to fetch GitHub profile",A(`security-audit: source analysis failed -> ${s.fetchError}`)}return s}function Iv(e){let t=new Map;for(let{relPath:r,content:n}of e){let o=n.split(`
|
|
304
|
+
`);for(let a=0;a<o.length;a++){let c=o[a],u=c.trim();for(let f of Ef)if(f.pattern.test(c)){let d=f.category;t.has(d)||t.set(d,{description:f.description,matches:[]});let p=u.length>120?u.slice(0,120)+"...":u;t.get(d).matches.push({file:r,line:a+1,match:p,severity:f.severity})}}}let s=[];for(let[r,n]of t)s.push({category:r,description:n.description,matches:n.matches});let i={critical:0,warning:1,info:2};return s.sort((r,n)=>{let o=Math.min(...r.matches.map(c=>i[c.severity])),a=Math.min(...n.matches.map(c=>i[c.severity]));return o-a}),s}function Cv(e){let t=new Map;for(let n of e)for(let o of n.matches)for(let a of Ef)if(a.permissionType&&a.category===n.category&&a.pattern.test(o.match)){let c=a.permissionType;t.has(c)||t.set(c,{evidence:[],categories:new Set});let u=t.get(c);u.evidence.push({file:o.file,line:o.line,match:o.match}),u.categories.add(n.category);break}let s={filesystem:"Skill reads, writes, or modifies files on disk. Verify it only accesses intended paths.",shell:"Skill executes shell commands or spawns processes. This allows arbitrary system access.",network:"Skill makes network requests or downloads external content. Data may be sent to remote servers.","code-execution":"Skill dynamically constructs and executes code. This can bypass static analysis.",environment:"Skill reads environment variables, which may contain secrets or API keys."},i=[];for(let[n,o]of t)i.push({type:n,evidence:o.evidence,reason:s[n]});let r={shell:0,"code-execution":1,network:2,filesystem:3,environment:4};return i.sort((n,o)=>(r[n.type]??99)-(r[o.type]??99)),i}function Lv(e,t,s){let i=0,r=0;for(let c of e)for(let u of c.matches)u.severity==="critical"&&i++,u.severity==="warning"&&r++;let n=t.some(c=>c.type==="shell"),o=t.some(c=>c.type==="code-execution"),a=t.some(c=>c.type==="network");return n&&a?{verdict:"dangerous",reason:"Skill has both shell execution and network access -- potential data exfiltration risk."}:o&&a?{verdict:"dangerous",reason:"Skill has dynamic code execution and network access -- potential remote code execution risk."}:i>=10?{verdict:"dangerous",reason:`${i} critical findings detected. High concentration of risky patterns.`}:n||o?{verdict:"warning",reason:n?"Skill executes shell commands. Review commands carefully before installing.":"Skill uses dynamic code execution. Review usage carefully."}:i>0?{verdict:"warning",reason:`${i} critical finding${i>1?"s":""} detected. Manual review recommended.`}:r>0?{verdict:"caution",reason:`${r} warning${r>1?"s":""} found. Generally acceptable but worth reviewing.`}:s&&s.publicRepos!==null&&s.publicRepos<3?{verdict:"caution",reason:"No code issues found, but the author has very few public repositories."}:{verdict:"safe",reason:"No suspicious patterns detected."}}async function Ne(e,t,s,i){A(`security-audit: scanning ${e}`);let r=await ui(e),n=r.reduce((d,p)=>d+p.lineCount,0),o=null;s&&i&&(o=await Pv(s,i));let a=Iv(r),c=Cv(a),{verdict:u,reason:f}=Lv(a,c,o);return{scannedAt:new Date().toISOString(),skillName:t,skillPath:e,source:o,codeScans:a,permissions:c,totalFiles:r.length,totalLines:n,verdict:u,verdictReason:f}}var D=l,mt=56,Av={"Shell execution":"shell","Dynamic code execution":"code-execution","Network requests":"network","External URLs":"network","File system access":"filesystem","Environment variable access":"environment","Embedded credentials":"credentials","Obfuscation patterns":"obfuscation"},$f={critical:0,warning:1,info:2};function Rv(e){switch(e){case"safe":return D.bgGreen(" SAFE ");case"caution":return D.bgCyan(" CAUTION ");case"warning":return D.bgYellow(" WARNING ");case"dangerous":return D.bgRed(" DANGEROUS ")}}function Nv(e){switch(e){case"safe":return D.green;case"caution":return D.cyan;case"warning":return D.yellow;case"dangerous":return D.red}}function Dt(e){switch(e){case"critical":return D.red("!!");case"warning":return D.yellow(" !");case"info":return D.dim(" i")}}function aa(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function Er(e){return e.toLocaleString("en-US")}function Pf(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function xf(e){return Pf(e).length}function Tv(e){let t=new Map;for(let s of e){let i=`${s.file}:${s.line}`,r=t.get(i);(!r||$f[s.severity]<$f[r.severity])&&t.set(i,s)}return Array.from(t.values())}function Ov(e){let t=new Map;for(let s of e){let i=t.get(s.file);i||(i={file:s.file,entries:[]},t.set(s.file,i)),i.entries.push({line:s.line,match:s.match,severity:s.severity})}return Array.from(t.values())}function _t(e){let t=[],s=Rv(e.verdict),i=Pf(s),r=` ${D.bold(e.skillName)}`,n=` ${e.skillName}`,o=mt-4,a=Math.max(1,o-n.length-i.length);if(t.push(""),t.push(D.dim(" +-- ")+D.bold("Security Audit")+D.dim(" "+"-".repeat(mt-19)+"+")),t.push(D.dim(" |")+r+" ".repeat(a)+s+D.dim("|")),t.push(D.dim(" |")+D.dim(` ${Er(e.totalFiles)} files | ${Er(e.totalLines)} lines`)+" ".repeat(Math.max(1,o-` ${Er(e.totalFiles)} files | ${Er(e.totalLines)} lines`.length))+D.dim("|")),t.push(D.dim(" +"+"-".repeat(mt-2)+"+")),e.source){let d=e.source;if(d.fetchError)t.push(` ${D.yellow("!")} Could not fetch profile: ${d.fetchError}`);else{let p=[];if(p.push(`${d.owner} ${d.isOrganization?D.cyan("(org)"):D.dim("(user)")}`),d.publicRepos!==null){let m=d.publicRepos,y=m<3?D.yellow(`${m} repos`):m<10?D.cyan(`${m} repos`):D.green(`${m} repos`);p.push(y)}d.accountAge&&p.push(d.accountAge),t.push(` ${D.dim("Author:")} ${p.join(D.dim(" | "))}`)}}if(t.push(""),e.codeScans.length===0)t.push(` ${D.green("*")} ${D.green("No suspicious patterns detected.")}`);else{let d=Nv(e.verdict),p=e.verdict==="dangerous"||e.verdict==="warning"?Dt("critical"):e.verdict==="caution"?Dt("warning"):Dt("info");t.push(` ${p} ${d(e.verdictReason)}`);let m=0,y=0,h=0;for(let S of e.codeScans)for(let v of S.matches)v.severity==="critical"?m++:v.severity==="warning"?y++:h++;let g=[];m>0&&g.push(D.red(`${m} critical`)),y>0&&g.push(D.yellow(`${y} warning`)),h>0&&g.push(D.dim(`${h} info`));let b=e.permissions.map(S=>S.type),k=b.length>0?D.dim(`Perms: ${b.join(", ")}`):"";t.push(` ${g.join(D.dim(" | "))} ${k}`)}if(t.push(""),e.codeScans.length>0){t.push(` ${D.bold("Findings")}`),t.push(D.dim(" "+"=".repeat(mt-2)));for(let d of e.codeScans){let p=Tv(d.matches),m=p.filter(O=>O.severity==="critical").length,y=p.filter(O=>O.severity==="warning").length,h=p.filter(O=>O.severity==="info").length,g=m>0?Dt("critical"):y>0?Dt("warning"):Dt("info"),b=[];m>0&&b.push(D.red(`${m} critical`)),y>0&&b.push(D.yellow(`${y} warning`)),h>0&&b.push(D.dim(`${h} info`));let k=Av[d.category],S=k?D.dim(`PERM: ${k}`):"",v=` ${g} ${D.bold(d.category)} (${b.join(", ")})`;if(S){let O=xf(v),w=xf(S),P=Math.max(2,mt-O-w);t.push(v+" ".repeat(P)+S)}else t.push(v);let x=Ov(p),I=Math.min(24,Math.max(...x.map(O=>O.file.length))),L=0,E=3;for(let O of x){if(L>=E)break;let w=aa(O.file,24),P=D.dim(w.padEnd(I));if(O.entries.length===1){let q=O.entries[0],ee=aa(q.match,50);t.push(` ${P} :${q.line} ${D.dim("--")} ${q.severity==="critical"?ee:D.dim(ee)}`),L++}else if(O.entries.length<=3){let q=O.entries.map(le=>`:${le.line}`).join(", "),ee=aa(O.entries[0].match,40);t.push(` ${P} ${q} ${D.dim("--")} ${D.dim(ee)}`),L++}else{let ee=O.entries.slice(0,3).map($e=>`:${$e.line}`).join(", "),le=O.entries.length-3;t.push(` ${P} ${ee} ${D.dim(`(+${le} more)`)}`),L++}}let F=x.length-Math.min(x.length,E);if(F>0){let O=p.length-x.slice(0,E).reduce((w,P)=>w+P.entries.length,0);O>0&&t.push(` ${D.dim(`... ${O} more in ${F} file${F>1?"s":""}`)}`)}t.push("")}}t.push(D.dim(" "+"=".repeat(mt-2)));let c=new Date(e.scannedAt),u=`${c.getFullYear()}-${String(c.getMonth()+1).padStart(2,"0")}-${String(c.getDate()).padStart(2,"0")} ${String(c.getHours()).padStart(2,"0")}:${String(c.getMinutes()).padStart(2,"0")}`,f=e.source&&!e.source.fetchError?`github.com/${e.source.owner}`:"";if(f){let d=Math.max(2,mt-2-u.length-f.length);t.push(D.dim(` ${u}${" ".repeat(d)}${f}`))}else t.push(D.dim(` ${u}`));return t.push(""),t.join(`
|
|
305
|
+
`)}function la(e){return JSON.stringify(e,null,2)}var Ms="Relocate `README.md` out of the skill root so SKILL.md remains the sole top-level document (e.g., move it to `docs/README.md`).",Pr=["name","description","version","license","author","creator","compatibility","allowed-tools","effort","tags","metadata"],If=["add","analyze","audit","build","check","configure","convert","create","debug","deploy","detect","edit","evaluate","explain","export","extract","fetch","find","fix","format","generate","identify","improve","index","inspect","install","list","manage","migrate","optimize","parse","plan","prepare","publish","refactor","remove","rename","report","research","review","run","scaffold","scan","score","search","set","setup","show","summarize","sync","test","transform","translate","update","validate","verify","write"],Mv=["confirm","confirmation","error","errors","fail","failure","caution","warning","prerequisite","prerequisites","requires","requirements","rollback","dry-run","dry run","safety","validate","validation","check","backup"],Dv=["acceptance criteria","expected output","expected result","edge case","edge cases","test","tests","testing","verify","verification","assert","example input","example output","given","then"],_v=["reference","references","see","template","templates","script","scripts","helper","helpers","link"],Fv=["when to use","quick start","overview","instructions","steps","workflow","phases","progressive"];function Ir(e){let t=e.split(`
|
|
306
|
+
`);if(t.length===0||t[0].trim()!=="---")return{rawFrontmatter:null,body:e};for(let s=1;s<t.length;s++)if(t[s].trim()==="---"){let i=t.slice(1,s).join(`
|
|
307
|
+
`),r=t.slice(s+1).join(`
|
|
308
|
+
`);return{rawFrontmatter:i,body:r}}return{rawFrontmatter:t.slice(1).join(`
|
|
309
|
+
`),body:""}}function ca(e){return e?e.split(`
|
|
310
|
+
`).length:0}function ua(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function jv(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function Cr(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function qv(e){return/```[\s\S]+?```/m.test(e)}function Bv(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function Cf(e,t,s,i){let r=[],n=[],o=0;s!==null?(o+=2,r.push("Has YAML frontmatter block.")):(r.push("SKILL.md has no YAML frontmatter."),n.push("Add a YAML frontmatter block delimited by `---` with at least `name` and `description` fields."));let a=!!(e.name&&e.name.trim()),c=!!(e.description&&e.description.trim());a?o+=1.5:(r.push("Missing required field: name."),n.push("Add `name:` to frontmatter (use the skill directory name).")),c?o+=1.5:(r.push("Missing required field: description."),n.push("Add a one-line `description:` to frontmatter."));let u=de(e);u&&u!=="0.0.0"?o+=1:(r.push("Missing or default version."),n.push("Set `metadata.version` (or top-level `version`) using semver (e.g. 0.1.0).")),!!(e.author||e["metadata.author"]||e.creator||e["metadata.creator"])?o+=1:(r.push("Missing `author`."),n.push("Add an `author` field so users know who authored and maintains the skill.")),!!e.license?o+=1:(r.push("Missing `license`."),n.push("Add a `license` field (e.g. `license: MIT`)."));let m=t.trim().length>=20,y=jv(t,1);if(m?(o+=1,r.push("Body has meaningful content.")):(r.push("Body content is too short (<20 chars of instructions)."),n.push("Flesh out the markdown body with at least one paragraph of instructions for the agent.")),y?(o+=1,r.push("Body uses markdown headings.")):(r.push("Body has no markdown headings."),n.push("Add section headings (e.g. `## When to Use`, `## Instructions`) so the agent can navigate the skill quickly.")),i){let h=i.find(g=>g.toLowerCase()==="readme.md");h&&(r.push(`\`${h}\` found at skill root; move it to a subdirectory (e.g., \`docs/README.md\`).`),n.push(Ms))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:r,suggestions:n}}function Lf(e,t){let s=[],i=[],r=0,n=(e.description||"").trim();if(!n)return s.push("No description."),i.push("Write a one-sentence description that says specifically what the skill does and when to use it."),{id:"description",name:"Description quality",score:0,max:10,findings:s,suggestions:i};let o=ua(n);s.push(`Description is ${o} words.`),o>=8&&o<=40?r+=4:o>=5&&o<8?(r+=2,i.push("Lengthen the description slightly so it names both the action and the trigger (aim for 8\u201320 words).")):o>=41&&o<=60?(r+=2,i.push("Trim the description \u2014 aim for under 40 words. Move the long version to the markdown body.")):o>60?(r+=0,i.push("Description is too long. Keep it under 40 words; put detail in the body.")):(r+=0,i.push("Description is too short. Aim for 8\u201320 words."));let a=n.split(/\s+/)[0]?.toLowerCase().replace(/[^\w-]/g,"");return!!(a&&(If.includes(a)||If.includes(a.replace(/s$/,""))))?(r+=3,s.push("Starts with an action verb.")):(s.push(`Does not start with a recognized action verb (got "${a??""}").`),i.push('Start the description with an imperative action verb (e.g. "Generate...", "Analyze...", "Review...").')),/\buse when\b|\btrigger\b|\bwhen\b|\bfor\b/i.test(n)||/\b(before|after|during)\b/i.test(n)?(r+=3,s.push("Mentions a trigger or use-case signal.")):(s.push("No explicit trigger / use-case phrase."),i.push('Name the trigger in the description \u2014 e.g. "Use when...", "for reviewing...", "before publishing...".')),{id:"description",name:"Description quality",score:Math.min(10,Math.round(r)),max:10,findings:s,suggestions:i}}function Af(e,t){let s=[],i=[],r=0,n=Cr(t,Fv);n.length>=2?(r+=3,s.push(`Progressive disclosure cues present: ${n.slice(0,3).join(", ")}.`)):n.length===1?(r+=1,i.push('Add clearer section labels \u2014 e.g. "## When to Use" and "## Instructions" \u2014 to support progressive disclosure.')):i.push('Structure the body with "## When to Use" and "## Instructions" sections so the agent reads only what it needs.'),Bv(t)?(r+=2,s.push("Uses lists or numbered steps.")):(s.push("No lists or steps detected."),i.push("Use bulleted or numbered steps to narrow the agent's degrees of freedom."));let o=qv(t),a=/\bexample\b/i.test(t);o&&a?(r+=2,s.push("Includes example code block.")):o||a?(r+=1,i.push('Back up examples with fenced code blocks labelled under "## Example" so the agent sees concrete input/output.')):i.push('Add an "## Example" section with a fenced code block showing the desired output.');let c=(t.match(/^\s*[-*0-9.]*\s*(Do|Use|Run|Call|Check|Validate|Return|Emit|Write|Read|Ask|Confirm|Avoid|Never|Always)\b/gim)||[]).length;c>=3?(r+=2,s.push(`Uses imperative voice (${c} cues).`)):c>=1?(r+=1,i.push("Favor imperative voice (Do / Use / Avoid / Never) to narrow the agent's choices.")):i.push('Rewrite instructions in the imperative mood \u2014 e.g. "Run `git status` first" instead of "you might want to run".');let u=ua(t);return u>=80&&u<=3e3?(r+=1,s.push(`Body length within healthy range (${u} words).`)):u<80?(s.push(`Body is very short (${u} words).`),i.push("Expand the instructions; an underspecified skill gives the agent too much freedom.")):(s.push(`Body is very long (${u} words).`),i.push("Split large content into referenced files; keep SKILL.md focused under ~3000 words.")),{id:"prompt-engineering",name:"Prompt engineering",score:Math.min(10,Math.round(r)),max:10,findings:s,suggestions:i}}function Rf(e,t){let s=[],i=[],r=0,n=ua(t);s.push(`Body is ${n} words.`),n>=120&&n<=1500?r+=4:n>=60&&n<120?(r+=2,i.push("Expand instructions slightly \u2014 too little context can push the agent to improvise.")):n>1500&&n<=3e3?(r+=2,i.push("Consider moving large sections into referenced files (e.g. `references/*.md`) and linking them instead of inlining.")):n>3e3&&(r+=0,i.push("Body is over 3000 words \u2014 split long content into referenced files or templates."));let o=Cr(t,_v);o.length>=2?(r+=3,s.push(`References external files or links (${o.slice(0,3).join(", ")}).`)):o.length===1?(r+=1,i.push('Link out to supporting files (e.g. "see `references/examples.md`") instead of inlining them.')):i.push('Offload verbose content to referenced files and link to them ("see `./templates/x.md`").');let c=(t.match(/```[\s\S]+?```/g)||[]).filter(u=>ca(u)>60);return c.length===0?(r+=2,s.push("No oversized code blocks.")):(s.push(`${c.length} code block(s) longer than 60 lines.`),i.push("Move large code blocks into referenced template files; link to them from SKILL.md.")),/\btoken\b|\bbudget\b|\bcontext window\b/i.test(t)&&(r+=1,s.push("Mentions tokens/budget/context window.")),{id:"context-efficiency",name:"Context efficiency",score:Math.min(10,Math.round(r)),max:10,findings:s,suggestions:i}}function Nf(e,t){let s=[],i=[],r=0,n=Cr(t,Mv);n.length>=4?(r+=4,s.push(`Covers multiple safety cues (${n.slice(0,4).join(", ")}).`)):n.length>=2?(r+=2,s.push(`Mentions a few safety cues: ${n.join(", ")}.`),i.push("Add explicit error-handling and confirmation steps so the agent knows how to recover from failures.")):n.length===1?(r+=1,i.push('Expand the safety section \u2014 include prerequisites, validation steps, and what to do "on error".')):i.push("Describe prerequisites, confirmation prompts, and error-handling steps to reduce blast radius.");let o=/\b(rm\s|delete|remove|drop|force|overwrite|destructive)\b/i.test(t),a=/\bconfirm\b|\bdry-?run\b|\bare you sure\b|\bbackup\b/i.test(t);return o&&a?(r+=3,s.push("Destructive actions paired with confirmation/dry-run.")):o?(s.push("References destructive actions without explicit confirmation/dry-run."),i.push("Pair any destructive command with an explicit confirmation prompt, dry-run flag, or backup step.")):r+=1.5,/\bprerequisit/i.test(t)||/\brequire/i.test(t)||/\bdepend/i.test(t)?(r+=3,s.push("Declares prerequisites or requirements.")):(s.push("No prerequisites / requirements section."),i.push('Add a "## Prerequisites" block listing required tools, credentials, and environment state.')),{id:"safety",name:"Safety & guardrails",score:Math.min(10,Math.round(r)),max:10,findings:s,suggestions:i}}function Tf(e,t){let s=[],i=[],r=0,n=Cr(t,Dv);return n.length>=4?(r+=5,s.push(`Many testability cues present (${n.slice(0,4).join(", ")}).`)):n.length>=2?(r+=3,s.push(`Some testability cues: ${n.join(", ")}.`),i.push('Add an "## Acceptance Criteria" block listing verifiable outputs or checklist items.')):n.length===1?(r+=1,i.push('Add concrete "expected output" examples so the agent can self-check.')):i.push('Add a "## Acceptance Criteria" section with testable statements (e.g. "produces a JSON report with overall_score").'),/expected\s+(output|result|response)/i.test(t)?(r+=3,s.push("Describes expected output/result.")):i.push('Include an "Expected output" example so reviewers and the agent can verify correctness.'),/\bedge case|gotcha|pitfall|limitation/i.test(t)?(r+=2,s.push("Mentions edge cases or limitations.")):i.push('Add a short "Edge cases" list to describe inputs the skill should reject or handle carefully.'),{id:"testability",name:"Testability",score:Math.min(10,Math.round(r)),max:10,findings:s,suggestions:i}}function Of(e,t){let s=[],i=[],r=0,n=(e.name||"").trim();if(n){let c=/^[a-z][a-z0-9-]*$/.test(n),u=n.length<=40;c&&u?(r+=4,s.push(`name "${n}" follows kebab-case convention.`)):(c||(s.push(`name "${n}" is not lowercase kebab-case.`),i.push(`Rename to lowercase kebab-case (e.g. "${n.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}").`)),u||s.push(`name is ${n.length} chars; keep it <= 40.`))}else i.push("Add a kebab-case `name` (e.g. `my-skill`).");let o=t.match(/^#{1,6}\s+(.+)$/gm)||[];return o.length>0&&(o.filter(f=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(f)).length/o.length>=.5?(r+=3,s.push("Most headings use action/imperative labels.")):(r+=1,i.push("Rename body headings to action-oriented labels (e.g. `## Instructions`, `## When to Use`)."))),/(?:\s\s|\bTODO\b|\bFIXME\b|\?{2,})/.test(e.description||"")?i.push("Clean up description \u2014 remove TODOs, FIXMEs, double spaces, or trailing punctuation."):(r+=2,s.push("Description looks clean (no TODO/FIXME/stray noise).")),{id:"naming",name:"Naming & conventions",score:Math.min(10,Math.round(r)),max:10,findings:s,suggestions:i}}import{readFile as fa,writeFile as Uv,stat as Mf,copyFile as Vv,readdir as Kv}from"fs/promises";import{join as Df,resolve as _f,basename as pa,isAbsolute as Ff}from"path";async function ne(e,t={}){if(e.length===0)throw new Error("runCommand requires a non-empty argv");let{spawn:s}=await import("child_process"),[i,...r]=e;return new Promise((n,o)=>{let a=s(i,r,{cwd:t.cwd,stdio:["ignore","pipe","pipe"]}),c="",u="",f=!1;a.stdout?.on("data",d=>{c+=d.toString()}),a.stderr?.on("data",d=>{u+=d.toString()}),a.on("error",d=>{if(f)return;if(f=!0,d.code==="ENOENT"){n({exitCode:127,stdout:c,stderr:d.message});return}o(d)}),a.on("close",d=>{f||(f=!0,n({exitCode:d??-1,stdout:c,stderr:u}))})})}function Ft(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:r}=e,n=W(t),{rawFrontmatter:o,body:a}=Ir(t),c=[Cf(n,a,o,r),Lf(n,a),Af(n,a),Rf(n,a),Nf(n,a),Tf(n,a),Of(n,a)];if(n.name&&pa(s)===n.name){let g=c.find(b=>b.id==="naming");g.score<g.max&&(g.score=Math.min(g.max,g.score+1),g.findings.push("Directory name matches frontmatter `name`."))}let u=c.reduce((g,b)=>g+b.score,0),f=c.reduce((g,b)=>g+b.max,0),d=Math.round(u/f*100),p="F";d>=90?p="A":d>=80?p="B":d>=65?p="C":d>=50&&(p="D");let m=[];c.find(g=>g.id==="structure")?.suggestions.includes(Ms)&&m.push(Ms);let h=[...c].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of h){for(let b of g.suggestions){if(m.length>=3)break;m.includes(b)||m.push(b)}if(m.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:c,overallScore:d,grade:p,topSuggestions:m,frontmatter:n}}async function ma(e){let t=Ff(e)?e:_f(e),s;try{s=await Mf(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,r;if(s.isFile())return i=t,r=await fa(i,"utf-8"),Ft({content:r,skillPath:pa(t)==="SKILL.md"?pa(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=Df(t,"SKILL.md");try{r=await fa(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let n;try{n=await Kv(t)}catch{n=void 0}return Ft({content:r,skillPath:t,skillMdPath:i,rootEntries:n})}function Gv(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function Hv(e){let t=e.split(`
|
|
311
|
+
`),s=[],i=[],r=0;for(;r<t.length;){let u=t[r];if(!u.trim()){r++;continue}let d=u.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!d)return{newFrontmatter:e,changed:!1};let p=d[1],m=d[2];if(m===""||m===">"||m==="|"){let y=[u];for(r++;r<t.length;){let h=t[r];if(h.trim()===""){y.push(h),r++;continue}if(/^\s+/.test(h))y.push(h),r++;else break}i.push({key:p,text:y.join(`
|
|
312
|
+
`)})}else s.push({key:p,text:u}),r++}let n=u=>{let f=Pr.indexOf(u);return f===-1?Pr.length+1:f},o=[...s].sort((u,f)=>{let d=n(u.key),p=n(f.key);return d!==p?d-p:s.indexOf(u)-s.indexOf(f)}),a=o.some((u,f)=>u!==s[f]);return{newFrontmatter:[...o.map(u=>u.text),...i.map(u=>u.text)].join(`
|
|
313
|
+
`),changed:a}}function jf(e,t={}){let s=[],i=[],r=e.replace(/\r\n/g,`
|
|
314
|
+
`);r!==e&&s.push({id:"normalise-line-endings",description:"Convert CRLF line endings to LF."});let n=r.split(`
|
|
315
|
+
`),o=n.map(g=>g.replace(/[ \t]+$/g,""));o.some((g,b)=>g!==n[b])&&s.push({id:"strip-trailing-whitespace",description:"Strip trailing whitespace from lines."}),r=o.join(`
|
|
316
|
+
`);let{rawFrontmatter:a,body:c}=Ir(r),u=W(r);if(a===null)return i.push({id:"missing-frontmatter",description:"SKILL.md has no frontmatter \u2014 not auto-fixable (requires author decisions)."}),{newContent:r,applied:s,skipped:i};let f=a;if(u.version||u["metadata.version"]||(f=da(f,"version","0.1.0"),s.push({id:"add-missing-version",description:"Add `version: 0.1.0`."})),!!!(u.author||u["metadata.author"]||u.creator||u["metadata.creator"])){let g=t.gitAuthor?.trim();g?(f=da(f,"author",g),s.push({id:"add-missing-author",description:`Add \`author: ${g}\` from git config.`})):i.push({id:"add-missing-author",description:"Missing `author` \u2014 no git user.name found to fill in safely."})}if(!u.effort){let g=Gv(ca(c));f=da(f,"effort",g),s.push({id:"infer-missing-effort",description:`Infer \`effort: ${g}\` from body size.`})}u.description||i.push({id:"missing-description",description:"Missing `description` \u2014 content-level fix, left to the author."});let m=Hv(f);m.changed&&(s.push({id:"reorder-frontmatter",description:"Reorder frontmatter fields to canonical order."}),f=m.newFrontmatter);let y=c.replace(/^\n+/,""),h=`---
|
|
317
|
+
${f.replace(/^\n+|\n+$/g,"")}
|
|
318
|
+
---
|
|
380
319
|
|
|
381
|
-
${
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
320
|
+
${y}`;return h.endsWith(`
|
|
321
|
+
`)||(h+=`
|
|
322
|
+
`),e.replace(/\r\n/g,`
|
|
323
|
+
`),{newContent:h,applied:s,skipped:i}}function da(e,t,s){if(new RegExp(`^${t}:\\s*`,"m").test(e))return e;let r=/[:#{}[\],&*?|<>=!%@`"']/.test(s)?JSON.stringify(s):s,n=e.length===0||e.endsWith(`
|
|
324
|
+
`)?"":`
|
|
325
|
+
`;return`${e}${n}${t}: ${r}
|
|
326
|
+
`}function Lr(e,t,s="SKILL.md"){if(e===t)return"";let i=e.split(`
|
|
327
|
+
`),r=t.split(`
|
|
328
|
+
`),n=[`--- a/${s}`,`+++ b/${s}`],o=0;for(;o<i.length&&o<r.length&&i[o]===r[o];)o++;let a=0;for(;a<i.length-o&&a<r.length-o&&i[i.length-1-a]===r[r.length-1-a];)a++;let c=i.slice(o,i.length-a),u=r.slice(o,r.length-a),f=o+1,d=o+1;n.push(`@@ -${f},${c.length} +${d},${u.length} @@`);let p=i.slice(Math.max(0,o-3),o).map(y=>` ${y}`),m=i.slice(i.length-a,Math.min(i.length,i.length-a+3)).map(y=>` ${y}`);n.push(...p);for(let y of c)n.push(`-${y}`);for(let y of u)n.push(`+${y}`);return n.push(...m),n.join(`
|
|
329
|
+
`)}async function ha(e,t){let s=Ff(e)?e:_f(e),i,r=await Mf(s).catch(()=>null);if(!r)throw new Error(`Skill path does not exist: ${s}`);if(r.isFile())i=s;else if(r.isDirectory())i=Df(s,"SKILL.md");else throw new Error(`Skill path is not a directory or file: ${s}`);let n;try{n=await fa(i,"utf-8")}catch{throw new Error(`SKILL.md not found at ${i}.`)}let o=jf(n,{gitAuthor:t.gitAuthor}),a=Lr(n,o.newContent),c=null;return!t.dryRun&&o.newContent!==n&&(c=`${i}.bak`,await Vv(i,c),await Uv(i,o.newContent,"utf-8")),{report:Ft({content:t.dryRun?n:o.newContent,skillPath:s,skillMdPath:i}),applied:o.applied,skipped:o.skipped,diff:a,dryRun:t.dryRun,backupPath:c,skillMdPath:i}}async function ga(){try{let{stdout:e,exitCode:t}=await ne(["git","config","--global","--get","user.name"]);if(t!==0)return null;let s=e.trim();return s||null}catch{return null}}function Jv(e,t,s=20){let i=Math.round(e/t*s);return"\u2588".repeat(i)+"\u2591".repeat(Math.max(0,s-i))}function Ds(e){let t=[];t.push(`Skill evaluation: ${e.skillPath}`),t.push(`SKILL.md: ${e.skillMdPath}`),t.push(""),t.push(`Overall score: ${e.overallScore}/100 (${e.grade})`);let s=(e.providers??[]).filter(i=>i.id!=="quality");for(let i of s){let r=i.passed?"pass":"fail",n=`${i.id}@${i.version}`;t.push(` ${n}: ${i.score}/100 ${r}`)}t.push(""),t.push("Categories:");for(let i of e.categories)t.push(` ${i.name.padEnd(28)} ${String(i.score).padStart(2)}/${i.max} ${Jv(i.score,i.max)}`);if(t.push(""),e.topSuggestions.length>0){t.push("Top suggestions:");for(let i of e.topSuggestions)t.push(` \u2022 ${i}`)}else t.push("No suggestions \u2014 skill looks great.");for(let i of s){let r=Wv(i.raw);if(r&&r.length>0){t.push(""),t.push(`${i.id}@${i.version} breakdown:`);for(let n of r){let o=n.passed?"\u221A":n.severity==="warning"?"\u26A0":"\xD7";t.push(` ${o} ${n.label}`),n.passed||t.push(` [${n.severity}] ${n.message}`)}continue}if(i.findings.length!==0){t.push(""),t.push(`${i.id}@${i.version} findings:`);for(let n of i.findings)t.push(` [${n.severity}] ${n.message}`)}}return t.join(`
|
|
330
|
+
`)}function Wv(e){if(!e||typeof e!="object")return null;let t=e.checks;if(!Array.isArray(t))return null;let s=[];for(let i of t){if(!i||typeof i!="object")return null;let r=i;if(typeof r.id!="string"||typeof r.label!="string"||typeof r.passed!="boolean"||typeof r.message!="string"||r.severity!=="error"&&r.severity!=="warning")return null;s.push({id:r.id,label:r.label,passed:r.passed,severity:r.severity,message:r.message})}return s}function ya(e){return JSON.stringify(e,null,2)}function ba(e){let t=[];if(e.applied.length===0&&e.skipped.length===0)return t.push("No fixes needed \u2014 SKILL.md is already clean."),t.join(`
|
|
331
|
+
`);if(e.applied.length>0){t.push(`${e.dryRun?"Would apply":"Applied"} ${e.applied.length} fix(es):`);for(let s of e.applied)t.push(` \u2022 ${s.description}`)}if(e.skipped.length>0){t.push(""),t.push(`Skipped ${e.skipped.length} issue(s) (not auto-fixable):`);for(let s of e.skipped)t.push(` \u2022 ${s.description}`)}return e.diff&&(t.push(""),t.push("Diff:"),t.push(e.diff)),!e.dryRun&&e.backupPath&&(t.push(""),t.push(`Backup: ${e.backupPath}`)),t.join(`
|
|
332
|
+
`)}import{stat as Ar,readdir as Yv}from"fs/promises";import{join as Rr,resolve as zv,basename as jt,isAbsolute as Xv}from"path";async function Bf(e){let t;try{t=await Yv(e)}catch{return[]}let s=[];for(let i of t){if(i.startsWith(".")||i==="node_modules"||i==="dist"||i==="build")continue;let r=Rr(e,i),n;try{n=await Ar(r)}catch{continue}if(!n.isDirectory())continue;let o=Rr(r,"SKILL.md");try{(await Ar(o)).isFile()&&s.push(r)}catch{}}return s.sort((i,r)=>jt(i).localeCompare(jt(r))),s}async function wa(e){let t=Rr(e,"SKILL.md");try{if((await Ar(t)).isFile())return{kind:"single",skillDirs:[e]}}catch{}let s=await Bf(e);return s.length>0?{kind:"collection",skillDirs:s}:{kind:"none",skillDirs:[]}}function qt(e){return e?!!(e.startsWith("github:")||/^https?:\/\/github\.com\//i.test(e)):!1}function qf(e){return{skillPath:e,skillMdPath:Rr(e,"SKILL.md"),label:jt(e)}}async function ka(e,t={}){if(!e)throw new Error("resolveEvalInput: input must be a non-empty string");if(qt(e)){if(!t.fetchRemote)throw new Error(`Remote evaluation is not available in this context: "${e}"`);let n=await t.fetchRemote(e),o;try{o=await wa(n.rootDir)}catch(a){throw await n.cleanup().catch(()=>{}),a}if(o.kind==="none")throw await n.cleanup().catch(()=>{}),new Error(`No SKILL.md found at ${n.rootDir} (source: ${e}). The location is neither a single skill nor a skill collection.`);return{targets:o.skillDirs.map(qf),isCollection:o.kind==="collection",cleanup:n.cleanup,provenance:{input:e,remote:!0,sourceRef:n.sourceRef,commitSha:n.commitSha,tempPath:n.rootDir}}}let s=Xv(e)?e:zv(e),i;try{i=await Ar(s)}catch{throw new Error(`Skill path does not exist: ${s}`)}if(i.isFile())return{targets:[{skillPath:jt(s)==="SKILL.md"?jt(s):s,skillMdPath:s,label:jt(s)}],isCollection:!1,cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}};if(!i.isDirectory())throw new Error(`Skill path is not a directory or file: ${s}`);let r=await wa(s);if(r.kind==="none")throw new Error(`No SKILL.md found in ${s}. Pass a skill directory, a SKILL.md file, or a collection root with SKILL.md in its children.`);return{targets:r.skillDirs.map(qf),isCollection:r.kind==="collection",cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}}}function va(e){let t=e.filter(f=>f.report!==null),s=e.length,i=s-t.length;if(t.length===0)return{total:s,succeeded:0,failed:i,meanScore:null,top:null,bottom:null};let r=t.map(f=>f.report.overallScore),n=r.reduce((f,d)=>f+d,0)/r.length,o=Math.round(n),a=[...t].sort((f,d)=>d.report.overallScore-f.report.overallScore),c=a[0],u=a[a.length-1];return{total:s,succeeded:t.length,failed:i,meanScore:o,top:{label:c.label,score:c.report.overallScore},bottom:{label:u.label,score:u.report.overallScore}}}async function _s(e,t,s){let i=new Array(e.length),r=0,n=!1,o,a=Math.max(1,Math.floor(t)),c=[],u=Math.min(a,e.length);for(let f=0;f<u;f++)c.push((async()=>{for(;!n;){let d=r++;if(d>=e.length)break;try{i[d]=await s(e[d],d)}catch(p){n||(n=!0,o=p);break}}})());if(await Promise.all(c),n)throw o;return i}function Sa(e,t=28){let s=[];return s.push(""),s.push("Batch summary:"),s.push(` Skills evaluated: ${e.aggregate.succeeded}/${e.aggregate.total}`+(e.aggregate.failed>0?` (${e.aggregate.failed} failed)`:"")),e.aggregate.meanScore!==null&&s.push(` Mean score: ${e.aggregate.meanScore}/100`),e.aggregate.top&&s.push(` Top: ${e.aggregate.top.label} (${e.aggregate.top.score}/100)`),e.aggregate.bottom&&e.aggregate.bottom.label!==e.aggregate.top?.label&&s.push(` Bottom: ${e.aggregate.bottom.label} (${e.aggregate.bottom.score}/100)`),e.provenance.remote&&(e.provenance.sourceRef&&s.push(` Source: ${e.provenance.sourceRef}`),e.provenance.commitSha&&s.push(` Commit: ${e.provenance.commitSha}`),e.provenance.tempPath&&s.push(` Fetched to: ${e.provenance.tempPath}`)),s.join(`
|
|
333
|
+
`)}function $a(e){return{provenance:{input:e.provenance.input,remote:e.provenance.remote,source_ref:e.provenance.sourceRef??null,commit_sha:e.provenance.commitSha??null,temp_path:e.provenance.tempPath??null},aggregate:{total:e.aggregate.total,succeeded:e.aggregate.succeeded,failed:e.aggregate.failed,mean_score:e.aggregate.meanScore,top:e.aggregate.top,bottom:e.aggregate.bottom},results:e.results.map(t=>({label:t.label,skill_path:t.skillPath,error:t.error,report:t.report?Fs(t.report,null):null}))}}function Fs(e,t=null){return{skill_path:e.skillPath,skill_md_path:e.skillMdPath,overall_score:e.overallScore,grade:e.grade,categories:e.categories.map(s=>({id:s.id,name:s.name,score:s.score,max:s.max,findings:s.findings,suggestions:s.suggestions})),top_suggestions:e.topSuggestions,providers:e.providers?.map(s=>({id:s.id,version:s.version,schemaVersion:s.schemaVersion,score:s.score,passed:s.passed,categories:s.categories.map(i=>({id:i.id,name:i.name,score:i.score,max:i.max,findings:i.findings??[]})),findings:s.findings}))??[],fix:t?{dry_run:t.dryRun,applied:t.applied,skipped:t.skipped,backup_path:t.backupPath,diff:t.diff}:null}}import{access as Zf,copyFile as oS,cp as aS,mkdtemp as ep,lstat as tp,mkdir as Ta,readdir as lS,readFile as Oa,readlink as cS,realpath as Vs,rename as Tr,rm as Ze}from"fs/promises";import{execFile as uS}from"child_process";import{createHash as dS}from"crypto";import{promisify as fS}from"util";import{dirname as Ks,isAbsolute as Ma,join as we,relative as sp,resolve as Se}from"path";import{execFile as Qv}from"child_process";import{promisify as Zv}from"util";import{join as eS}from"path";var tS=Zv(Qv),sS=["GIT_DIR","GIT_WORK_TREE","GIT_COMMON_DIR","GIT_INDEX_FILE","GIT_OBJECT_DIRECTORY","GIT_ALTERNATE_OBJECT_DIRECTORIES","GIT_IMPLICIT_WORK_TREE","GIT_GRAFT_FILE","GIT_SHALLOW_FILE","GIT_NO_REPLACE_OBJECTS","GIT_REPLACE_REF_BASE","GIT_PREFIX","GIT_INTERNAL_SUPER_PREFIX","GIT_CEILING_DIRECTORIES","GIT_DISCOVERY_ACROSS_FILESYSTEM","GIT_NAMESPACE","GIT_QUARANTINE_PATH","GIT_CONFIG","GIT_CONFIG_PARAMETERS","GIT_CONFIG_COUNT"];function Vf(e){let t={...process.env};for(let s of sS)delete t[s];for(let s of Object.keys(t))/^GIT_CONFIG_(?:KEY|VALUE)_\d+$/.test(s)&&delete t[s];return t.GIT_DEFAULT_HASH=e,t}var xa=new WeakMap;function Uf(e,t){return xa.set(e,t),e}function Kf(e){return e.normalize("NFC").toLowerCase().normalize("NFC")}async function Ea(e,t,s){let i=new Array(e.length),r=0;async function n(){for(;r<e.length;){let a=r++;i[a]=await s(e[a])}}let o=[];for(let a=0;a<Math.min(t,e.length);a++)o.push(n());return await Promise.all(o),i}async function Gf(e,t){try{let s=["ls-remote",e];t?s.push(t,`${t}^{}`):s.push("HEAD");let{stdout:i}=await tS("git",s,{timeout:1e4}),r=new Map;for(let n of i.split(`
|
|
334
|
+
`)){let[o,a]=n.trim().split(/\s+/);a&&o&&/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/.test(o)&&r.set(a,o)}return!t||t==="HEAD"?r.get("HEAD")??null:t.startsWith("refs/")?r.get(`${t}^{}`)??r.get(t)??null:r.get(`refs/heads/${t}`)??r.get(`refs/tags/${t}^{}`)??r.get(`refs/tags/${t}`)??null}catch(s){return A(`updater: git ls-remote failed for ${e}: ${s}`),null}}function js(e){return e.sourceType?e.sourceType:e.source.startsWith("local:")?"local":"github"}function Bt(e){if(e.startsWith("github:")){let t=e.slice(7),s=t.indexOf("#");return s!==-1&&(t=t.slice(0,s)),`https://github.com/${t}.git`}return e.startsWith("file://")?e:null}function Pa(e){if(!e.startsWith("github:"))return null;let t=e.slice(7),s=t.indexOf("#");s!==-1&&(t=t.slice(0,s));let i=t.split("/");return i.length<2||!i[0]||!i[1]?null:{owner:i[0],repo:i[1]}}function Hf(e,t){return t.skillPath?eS(e,t.skillPath):e}async function qs(e){let t=e?.readLockFn??Be,s=e?.fetchRegistryIndexFn??oa,i=e?.lock??await t(),r=Object.entries(i.skills);if(r.length===0)return{entries:[],outdatedCount:0,upToDateCount:0,untrackedCount:0,errorCount:0};let n=null;r.some(([,c])=>js(c)==="registry"||c.registryName)&&(n=await s());let a=await Ea(r,5,async([c,u])=>{let f=js(u);if(!u.commitHash||u.commitHash==="unknown")return{name:c,installedCommit:u.commitHash||"unknown",latestCommit:"unknown",source:u.source,sourceType:f,status:"untracked"};if(f==="local")return{name:c,installedCommit:u.commitHash,latestCommit:u.commitHash,source:u.source,sourceType:f,status:"up-to-date"};if(f==="registry"&&n){let y=u.registryName||c,h=n.manifests.find(g=>g.name.toLowerCase()===y.toLowerCase());if(h){let g=h.commit!==u.commitHash;return Uf({name:c,installedCommit:ve(u.commitHash),latestCommit:ve(h.commit),source:u.source,sourceType:f,status:g?"outdated":"up-to-date"},h.commit)}}let d=Bt(u.source);if(!d)return{name:c,installedCommit:ve(u.commitHash),latestCommit:"unknown",source:u.source,sourceType:f,status:"error",error:"Cannot determine remote URL"};let p=await Gf(d,u.ref);if(!p)return{name:c,installedCommit:ve(u.commitHash),latestCommit:"unknown",source:u.source,sourceType:f,status:"error",error:"Failed to fetch remote commit"};let m=p!==u.commitHash;return Uf({name:c,installedCommit:ve(u.commitHash),latestCommit:ve(p),source:u.source,sourceType:f,status:m?"outdated":"up-to-date"},p)});return{entries:a,outdatedCount:a.filter(c=>c.status==="outdated").length,upToDateCount:a.filter(c=>c.status==="up-to-date").length,untrackedCount:a.filter(c=>c.status==="untracked").length,errorCount:a.filter(c=>c.status==="error").length}}function ve(e){return!e||e==="unknown"?"unknown":e.slice(0,7)}import{execFile as iS}from"child_process";import{promisify as rS}from"util";import{join as Nr}from"path";import{homedir as Jf}from"os";import{mkdir as Wf,rm as ht,rename as Ia,cp as Yf,access as nS}from"fs/promises";var Bs=rS(iS);async function zf(e,t,s,i,r){if(js(t)==="local")return{name:e,status:"skipped",reason:"Local skill (not updatable)"};let o;if(r!==void 0){if(!/^(?:[0-9a-f]{40}|[0-9a-f]{64})$/i.test(r))return{name:e,status:"failed",reason:"Invalid known commit OID"};if(o=r.toLowerCase(),o===t.commitHash.toLowerCase())return{name:e,status:"skipped",reason:"Already up to date"}}let a=Bt(t.source);if(!a)return{name:e,status:"failed",reason:"Cannot determine remote URL"};let c=Nr(Jf(),".config","agent-skill-manager",".tmp",`${e}-${Date.now()}`);try{let u=Nr(Jf(),".config","agent-skill-manager",".tmp");if(await Wf(u,{recursive:!0}),A(`updater: fetching latest ${e} to ${c}`),o)try{let w=o.length===40?"sha1":"sha256",P=Vf(w);await Bs("git",["init",c],{timeout:1e4,env:P}),await Bs("git",["fetch","--depth","1",a,o],{cwd:c,timeout:6e4,env:P}),await Bs("git",["checkout","--detach",o],{cwd:c,timeout:1e4,env:P})}catch{return{name:e,status:"failed",reason:"Resolved commit is unavailable in the shallow fetch"}}else{let w=["clone","--depth","1"];t.ref&&t.ref!=="HEAD"&&w.push("--branch",t.ref),w.push(a,c);try{await Bs("git",w,{timeout:6e4})}catch(P){let q=P;return{name:e,status:"failed",reason:`Clone failed: ${q.stderr||q.message||String(P)}`}}}let f;if(o)f=o;else try{let{stdout:w}=await Bs("git",["rev-parse","HEAD"],{cwd:c,timeout:5e3});f=w.trim().toLowerCase()}catch{return{name:e,status:"failed",reason:"Could not read new commit"}}if(f===t.commitHash)return{name:e,status:"skipped",reason:"Already up to date"};let d=Hf(c,t);A(`updater: running security audit on ${e}`);let p="safe";try{let w=i?.auditFn??Ne,P=Pa(t.source);if(p=(await w(d,e,P?.owner,P?.repo)).verdict,p==="dangerous")return{name:e,status:"skipped",reason:"Security audit: dangerous \u2014 update blocked",securityVerdict:p};if(p==="warning"||p==="caution"){if(!s)return{name:e,status:"skipped",reason:`Security audit: ${p} \u2014 use --yes to override`,securityVerdict:p};A(`updater: security audit ${p} for ${e} \u2014 proceeding (--yes)`)}}catch(w){let P=w instanceof Error?w.message:String(w);return A(`updater: security audit failed for ${e}: ${P}`),{name:e,status:"failed",reason:`Security audit failed \u2014 skipping update: ${P}`}}let m=i?.loadConfigFn??j,y=i?.resolveProviderPathFn??se,g=(await m()).providers.find(w=>w.name===t.provider),b=t.scope??"global",k=g?b==="project"?g.project:g.global:`~/.${t.provider}/skills`,S=y(k),v=Nr(S,e),x=Nr(c,".git");try{await ht(x,{recursive:!0,force:!0})}catch{}let I=!0;try{await nS(v)}catch(w){if(!(w instanceof Error)||!("code"in w)||w.code!=="ENOENT"){let P=w instanceof Error?w.message:String(w);return{name:e,status:"failed",reason:`Cannot access installed skill: ${P}`}}I=!1}let L=i?.writeLockEntryFn??vt,E={...t,commitHash:f,installedAt:new Date().toISOString()};if(!I){try{await Wf(S,{recursive:!0}),await Yf(d,v,{recursive:!0})}catch(w){await ht(v,{recursive:!0,force:!0});let P=w instanceof Error?w.message:String(w);return{name:e,status:"failed",reason:`Atomic swap failed: ${P}`}}try{await L(e,E)}catch(w){try{await ht(v,{recursive:!0,force:!0})}catch(q){let ee=w instanceof Error?w.message:String(w),le=q instanceof Error?q.message:String(q);return{name:e,status:"failed",reason:`Lock file update failed: ${ee}. Removal of the new installation also failed: ${le}`}}let P=w instanceof Error?w.message:String(w);return{name:e,status:"failed",reason:`Lock file update failed: ${P}`}}return{name:e,status:"updated",oldCommit:ve(t.commitHash),newCommit:ve(f),securityVerdict:p}}let F=`${v}.bak-${Date.now()}`,O=!1;try{await Ia(v,F),O=!0,await Yf(d,v,{recursive:!0})}catch(w){if(O)try{await ht(v,{recursive:!0,force:!0}),await Ia(F,v),O=!1}catch(P){let q=w instanceof Error?w.message:String(w),ee=P instanceof Error?P.message:String(P);return{name:e,status:"failed",reason:`Atomic swap failed: ${q}. Restore also failed; backup preserved at ${F}: ${ee}`}}return{name:e,status:"failed",reason:`Atomic swap failed: ${w instanceof Error?w.message:String(w)}`}}try{await L(e,E)}catch(w){try{await ht(v,{recursive:!0,force:!0}),await Ia(F,v),O=!1}catch(q){let ee=w instanceof Error?w.message:String(w),le=q instanceof Error?q.message:String(q);return{name:e,status:"failed",reason:`Lock file update failed: ${ee}. Restore also failed; backup preserved at ${F}: ${le}`}}let P=w instanceof Error?w.message:String(w);return{name:e,status:"failed",reason:`Lock file update failed: ${P}`}}if(O)try{await ht(F,{recursive:!0,force:!0})}catch(w){A(`updater: failed to remove backup ${F}: ${w}`)}return{name:e,status:"updated",oldCommit:ve(t.commitHash),newCommit:ve(f),securityVerdict:p}}finally{try{await ht(c,{recursive:!0,force:!0})}catch{}}}async function Ca(e,t,s){let i=s?.readLockFn??Be,r=s?.checkOutdatedFn??qs,n=s?.updateSkillFn??zf,o=await i(),a=await r({lock:o}),c=a.entries.filter(g=>g.status==="outdated"),u=[];if(e&&e.length>0){let g=new Set(e.map(b=>b.toLowerCase()));c=c.filter(b=>g.has(b.name.toLowerCase()));for(let b of e)c.find(k=>k.name.toLowerCase()===b.toLowerCase())||(a.entries.find(S=>S.name.toLowerCase()===b.toLowerCase())?A(`updater: skill "${b}" is already up to date`):(A(`updater: skill "${b}" not found in lock file`),u.push(b)))}if(c.length===0)return{results:[],updatedCount:0,skippedCount:0,failedCount:0,...u.length>0?{warnings:u}:{}};let f=c.flatMap(g=>{let b=o.skills[g.name];return b?[{name:g.name,lockEntry:b,knownLatestCommit:xa.get(g)}]:[]}),d=s?.writeLockEntryFn??vt,p=Promise.resolve(),m=(g,b)=>{let k=p.then(()=>d(g,b));return p=k.then(()=>{},()=>{}),k},y=new Map;f.forEach((g,b)=>{let k=Kf(g.name),S=y.get(k)??[];S.push({...g,index:b}),y.set(k,S)});let h=new Array(f.length);return await Ea([...y.values()],4,async g=>{for(let b of g)try{h[b.index]=await n(b.name,b.lockEntry,t,{writeLockEntryFn:m},b.knownLatestCommit)}catch(k){let S=k instanceof Error?k.message:String(k);h[b.index]={name:b.name,status:"failed",reason:`Unexpected update failure: ${S}`}}}),{results:h,updatedCount:h.filter(g=>g.status==="updated").length,skippedCount:h.filter(g=>g.status==="skipped").length,failedCount:h.filter(g=>g.status==="failed").length,...u.length>0?{warnings:u}:{}}}function La(e,t){if(e.entries.length===0)return"No skills installed.";let s=d=>d,i=t?l.red:s,r=t?l.green:s,n=t?l.yellow:s,o=t?l.dim:s,a=`${"Skill".padEnd(22)}${"Installed".padEnd(14)}${"Latest".padEnd(14)}Source`,c="\u2500".repeat(60),u=[a,c];for(let d of e.entries){let p=d.name.padEnd(22),m=d.installedCommit.padEnd(14),y,h;switch(d.status){case"outdated":y=i(d.latestCommit.padEnd(14)),h=d.sourceType;break;case"up-to-date":y=r(d.latestCommit.padEnd(14)),h=o("(up to date)");break;case"untracked":y=n("untracked".padEnd(14)),h=n("untracked");break;case"error":y=o("error".padEnd(14)),h=o(d.error||"error");break}u.push(`${p}${m}${y}${h}`)}u.push("");let f=[];return e.outdatedCount>0&&f.push(i(`${e.outdatedCount} outdated`)),e.upToDateCount>0&&f.push(r(`${e.upToDateCount} up to date`)),e.untrackedCount>0&&f.push(n(`${e.untrackedCount} untracked`)),e.errorCount>0&&f.push(o(`${e.errorCount} error`)),u.push(f.join(", ")),u.join(`
|
|
335
|
+
`)}function Aa(e){return JSON.stringify({skills:e.entries.map(t=>({name:t.name,installed:t.installedCommit,latest:t.latestCommit,source:t.sourceType,status:t.status,...t.error?{error:t.error}:{}})),summary:{outdated:e.outdatedCount,upToDate:e.upToDateCount,untracked:e.untrackedCount,errors:e.errorCount}},null,2)}function Ra(e){return JSON.stringify({results:e.results.map(t=>({name:t.name,status:t.status,...t.reason?{reason:t.reason}:{},...t.oldCommit?{oldCommit:t.oldCommit}:{},...t.newCommit?{newCommit:t.newCommit}:{},...t.securityVerdict?{securityVerdict:t.securityVerdict}:{}})),summary:{updated:e.updatedCount,skipped:e.skippedCount,failed:e.failedCount}},null,2)}var Us=fS(uS),pS=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,Xf=128,mS=/^\d+\.\d+\.\d+(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?$/;function Na(){return{version:1,skills:{}}}async function Gs(e=st()){return Or(e)}async function gt(e=st()){let t=await Gs(e),s=[];for(let[i,r]of Object.entries(t.skills)){let n=!1;try{await Zf(we(r.libraryPath,"SKILL.md"))}catch{n=!0}s.push({dirName:i,...r,missing:n})}return s.sort((i,r)=>i.name.localeCompare(r.name)),s}function Hs(e,t){let s=e.find(r=>r.dirName===t);return s||(e.find(r=>r.name===t)??null)}function Z(e,t){return{name:e,status:"failed",reason:t}}async function ip(e,t,s){return e.sourceType!==t.sourceType||Se(e.libraryPath)!==Se(t.libraryPath)?!1:e.sourceType==="local"?s?await hS(e)===s:!1:e.source===t.source&&e.ref===t.ref&&e.skillPath===t.skillPath}function Da(e){return Z(e,`Library skill "${e}" changed while update was in progress. Run "asm library update ${e}" again.`)}function _a(e){let t=Date.parse(e??""),s=Number.isFinite(t)?Math.max(Date.now(),t+1):Date.now();return new Date(s).toISOString()}function Fa(e){if(!e.source.startsWith("local:"))return null;let t=e.source.slice(6);return t?Se(t):null}async function hS(e){let t=Fa(e);if(!t)throw new Error("Unsupported library source for update");let s=Mr(t,we(t,e.skillPath));if(!s)throw new Error("Invalid update metadata: skillPath escapes source root");let[i,r]=await Promise.all([Vs(t),Vs(s)]);if(!Js(i,r))throw new Error("Invalid update metadata: skillPath escapes source root");return r}async function Or(e){let t;try{t=await Oa(e,"utf-8")}catch(s){if(s instanceof Error&&"code"in s&&s.code==="ENOENT")return A("library: lock file not found, returning empty lock"),Na();throw s}try{let s=JSON.parse(t);if(!s||typeof s!="object"||Array.isArray(s)||s.version!==1||typeof s.skills!="object"||s.skills===null||Array.isArray(s.skills))throw new Error("invalid schema");return s}catch{let s=e+".bak";try{await oS(e,s)}catch{}return console.error(`Warning: library-lock.json was corrupted. Backup saved to ${s}. Starting fresh.`),Na()}}async function ja(e,t){await Tl(t,JSON.stringify(e,null,2)+`
|
|
336
|
+
`)}function rp(e){let t=e.name?.trim();if(!t)return{reason:"Invalid source SKILL.md: missing name"};let s=(e["metadata.version"]||e.version)?.trim();return s?mS.test(s)?{name:t,version:s}:{reason:"Invalid source SKILL.md: invalid version"}:{reason:"Invalid source SKILL.md: missing version"}}function Js(e,t){let s=Se(e),i=Se(t),r=sp(s,i);return r===""||!!r&&!r.startsWith("..")&&!Ma(r)}function Mr(e,t){let s=Se(e),i=Se(t);return Js(s,i)?i:null}async function gS(e){let t=Se(e);for(;;)try{return await Vs(t)}catch(s){if(!(s instanceof Error)||!("code"in s)||s.code!=="ENOENT")throw s;let i=Ks(t);if(i===t)throw s;t=i}}async function np(e,t){try{let[s,i]=await Promise.all([Vs(e),gS(t)]);return Js(s,i)}catch{return!1}}async function op(e){let t=dS("sha256");async function s(i,r){let n=await lS(i,{withFileTypes:!0});n.sort((o,a)=>o.name.localeCompare(a.name));for(let o of n){if(o.name===".git")continue;let a=r?we(r,o.name):o.name,c=we(i,o.name);o.isDirectory()?(t.update(`dir:${a}
|
|
337
|
+
`),await s(c,a)):o.isFile()&&(t.update(`file:${a}
|
|
338
|
+
`),t.update(await Oa(c)),t.update(`
|
|
339
|
+
`))}}return await s(e,""),t.digest("hex")}async function ap(e,t,s){let i=Bt(e.source);if(!i)return{reason:"Cannot determine remote URL"};let r=we(Ks(s),".tmp");await Ta(r,{recursive:!0});let n=await ep(we(r,`${t}-`)),o=e.ref&&e.ref!=="HEAD"?e.ref:null,a=!!o&&/^[0-9a-f]{40}$/i.test(o),c=["clone","--depth","1"];o&&!a&&c.push("--branch",o),c.push(i,n);try{await Us("git",c,{timeout:6e4})}catch(u){let f=u;return{tempDir:n,reason:`Clone failed: ${f.stderr||f.message||String(u)}`}}if(o&&a)try{await Us("git",["checkout",o],{cwd:n,timeout:3e4})}catch{try{await Us("git",["fetch","--depth","1","origin",o],{cwd:n,timeout:6e4}),await Us("git",["checkout","FETCH_HEAD"],{cwd:n,timeout:3e4})}catch(u){let f=u;return{tempDir:n,reason:`Checkout failed for ref ${o}: ${f.stderr||f.message||String(u)}`}}}try{let{stdout:u}=await Us("git",["rev-parse","HEAD"],{cwd:n,timeout:5e3}),f=u.trim();return/^[0-9a-f]{40}$/i.test(f)?{tempDir:n,commitHash:f}:{tempDir:n,reason:"Could not read new commit"}}catch{return{tempDir:n,reason:"Could not read new commit"}}}async function qa(e,t){let s=await ep(we(Ks(t),".library-update-"));try{return await aS(e,s,{recursive:!0}),await Ze(we(s,".git"),{recursive:!0,force:!0}),s}catch(i){throw await Ze(s,{recursive:!0,force:!0}),i}}async function Ba(e){let t=Ks(e.targetDir),s=null,i=!1;try{try{await lp(e.targetDir)&&(s=we(t,`.library-update-backup-${Date.now()}`),await Tr(e.targetDir,s)),await Tr(e.stagedDir,e.targetDir);try{return await e.writeLock(),null}catch(r){if(r instanceof Nl)return{name:"",status:"failed",reason:`Lock metadata and library files were published as the new generation, but parent-directory durability could not be confirmed: ${r.cause instanceof Error?r.cause.message:String(r.cause)}`};if(await Ze(e.targetDir,{recursive:!0,force:!0}),s)try{await Tr(s,e.targetDir),s=null}catch{return i=!0,{name:"",status:"failed",reason:`Updated library copy, but failed to write lock file: ${r instanceof Error?r.message??String(r):String(r)}. Restore of previous library copy also failed; backup preserved at ${s}.`}}return{name:"",status:"failed",reason:`Updated library copy, but failed to write lock file: ${r instanceof Error?r.message??String(r):String(r)}`}}}catch(r){if(s)try{await Tr(s,e.targetDir),s=null}catch{i=!0}return{name:"",status:"failed",reason:`Failed to refresh library skill: ${r instanceof Error?r.message??String(r):String(r)}`}}}finally{await Ze(e.stagedDir,{recursive:!0,force:!0}),s&&!i&&await Ze(s,{recursive:!0,force:!0})}}function yS(e,t){let s=sp(e,t);return s===""||!!s&&!s.startsWith("..")&&!Ma(s)}async function Qf(e){try{return{path:await Vs(e),exists:!0}}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return{path:Se(e),exists:!1};throw t}}async function Ua(e){let t=Ka(e.activationName),s=we(e.targetDir,t),i;try{i=await tp(s)}catch(p){throw p instanceof Error&&"code"in p&&p.code==="ENOENT"?new Error(`Skill "${t}" is not active for ${e.provider}/${e.scope}.`,{cause:p}):p}if(!i.isSymbolicLink())throw new Error(`Refusing to deactivate non-symlink target: ${s}.`);let r=await cS(s),n=Ma(r)?r:Se(Ks(s),r),o=e.librarySkillsDir??Me(),a=await Qf(n),c=await Qf(o),u=a.exists&&c.exists,f=u?a.path:Se(n),d=u?c.path:Se(o);if(!yS(d,f))throw new Error(`Refusing to deactivate symlink outside the ASM library: ${s}.`);return await Ze(s),{name:t,provider:e.provider,scope:e.scope,path:s,target:f}}async function Va(e){let t=Ka(e.activationName),s=we(e.targetDir,t);try{let i=await tp(s);if(!e.force)throw new Error(`Target already exists: ${s}. Use --force to overwrite.`);if(!i.isSymbolicLink())throw new Error(`Refusing to overwrite non-symlink target: ${s}.`);await Ze(s,{force:!0})}catch(i){if(!(i instanceof Error&&"code"in i&&i.code==="ENOENT"))throw i}return await Ta(e.targetDir,{recursive:!0}),await qe(e.libraryPath,s),{symlinkPath:s,targetPath:e.libraryPath}}async function lp(e){try{return await Zf(e),!0}catch(t){if(t instanceof Error&&"code"in t&&t.code==="ENOENT")return!1;throw t}}function Ka(e){if(!e)throw new Error("Invalid skill name: name cannot be empty");if(e.includes("\0"))throw new Error("Invalid skill name: contains unsafe characters (null byte)");if(e.includes(".."))throw new Error("Invalid skill name: contains unsafe characters (..)");if(e.includes("/")||e.includes("\\"))throw new Error("Invalid skill name: contains unsafe characters (path separator)");if(e.startsWith("."))throw new Error("Invalid skill name: must not start with a dot");if(e.length>Xf)throw new Error(`Invalid skill name: exceeds maximum length of ${Xf} characters`);if(!pS.test(e))throw new Error(`Invalid skill name: "${e}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return e}async function Ga(e,t={}){let s=t.skillsDir??Me(),i=t.lockPath??st(),r=Ka(e.libraryName),n=we(s,r);await Ta(s,{recursive:!0});let o=await qa(e.sourceDir,n);try{let a=await Oa(we(o,"SKILL.md"),"utf-8"),c=W(a),u=c.name||r,f=de(c);return await di(i,async()=>{let d=await Or(i);if(await lp(n)&&!e.force)throw new Error(`Library skill already exists: ${n}. Use --force to overwrite.`);let p={...d,skills:{...d.skills,[r]:{name:u,version:f,source:e.source,sourceType:e.sourceType,commitHash:e.commitHash,ref:e.ref,skillPath:e.skillPath,libraryPath:n,installedAt:_a(d.skills[r]?.installedAt)}}},m=await Ba({stagedDir:o,targetDir:n,writeLock:()=>ja(p,i)});if(m)throw new Error(m.reason??"Failed to install library skill")}),{name:u,version:f,libraryPath:n}}finally{await Ze(o,{recursive:!0,force:!0})}}import{readFile as bS,realpath as cp,rm as up}from"fs/promises";import{join as Ha}from"path";async function dp(e,t={},s){let i=t.lockPath??st(),r=t.skillsDir??Me(),n=s?.writeLibraryLockFn??ja,o=await Gs(i),a=o.skills[e]??null,c=Object.entries(o.skills).find(([,h])=>h.name===e)??null,u=a?[e,a]:c;if(!u)return Z(e,`Library skill "${e}" not found. Run "asm library list".`);let[f,d]=u,p={...d};if(!d.source||!d.source.trim())return Z(f,"Missing update metadata: source");if(!d.sourceType||!d.sourceType.trim())return Z(f,"Missing update metadata: sourceType");if(d.skillPath===void 0||d.skillPath===null)return Z(f,"Missing update metadata: skillPath");if(!d.libraryPath||!d.libraryPath.trim())return Z(f,"Missing update metadata: libraryPath");let m=null,y=null;try{let h,g=null;if(d.sourceType==="local"){let w=Fa(d);if(!w)return Z(f,`Unsupported library source for update: ${d.source}`);h=w}else if(d.sourceType==="github"||d.sourceType==="registry"){let w=await ap(d,f,i);if("reason"in w)return w.tempDir&&(m=w.tempDir),Z(f,w.reason);h=w.tempDir,m=w.tempDir,g=w.commitHash}else return Z(f,`Unsupported library source type for update: ${d.sourceType}`);let b=Mr(h,Ha(h,d.skillPath));if(!b)return Z(f,"Invalid update metadata: skillPath escapes source root");let k=Ha(b,"SKILL.md"),S,v;try{[S,v]=await Promise.all([cp(h),cp(b)])}catch(w){return Z(f,`Unable to read source SKILL.md at ${k}: ${w instanceof Error?w.message??String(w):String(w)}`)}if(!Js(S,v))return Z(f,"Invalid update metadata: skillPath escapes source root");d.sourceType==="local"&&(y=v);let x;try{x=await bS(k,"utf-8")}catch(w){return Z(f,`Unable to read source SKILL.md at ${k}: ${w instanceof Error?w.message??String(w):String(w)}`)}let I=W(x),L=rp(I);if("reason"in L)return Z(f,L.reason);let E=L.name,F=L.version;if(d.sourceType==="local"&&(g=await op(b)),!g)return Z(f,"Could not read new commit");let O=await qa(b,Ha(r,f));try{return await di(i,async()=>{let w=await Or(i),P=w.skills[f];if(!P)return Z(f,`Library skill "${f}" not found. Run "asm library list".`);let q=Mr(r,P.libraryPath);if(!q)return Z(f,"Invalid update metadata: libraryPath escapes library skills directory");if(!await np(r,q))return Z(f,"Invalid update metadata: libraryPath escapes library skills directory");let ee;try{ee=await ip(P,p,y)}catch{return Da(f)}let le=P.installedAt===p.installedAt;if(le&&ee&&P.commitHash===g)return{name:P.name,status:"skipped",oldVersion:P.version,newVersion:F,oldCommit:P.commitHash,newCommit:g};if(!le||!ee||P.commitHash!==p.commitHash)return Da(f);let $e={...w,skills:{...w.skills,[f]:{...P,name:E,version:F,commitHash:g,installedAt:_a(P.installedAt)}}},R=await Ba({stagedDir:O,targetDir:q,writeLock:()=>n($e,i)});return R?Z(f,R.reason??"Failed to update library skill"):{name:E,status:"updated",oldVersion:P.version,newVersion:F,oldCommit:P.commitHash,newCommit:g}})}finally{await up(O,{recursive:!0,force:!0})}}finally{m&&await up(m,{recursive:!0,force:!0})}}async function Ja(e,t={}){let s=t.lockPath??st(),i=await Gs(s),r=e===null?Object.keys(i.skills):e,n=[],o=[];for(let a of r){let c=await dp(a,t);c.status==="failed"&&c.reason?.includes('Run "asm library list"')&&n.push(c.reason),o.push(c)}return{results:o,updatedCount:o.filter(a=>a.status==="updated").length,skippedCount:o.filter(a=>a.status==="skipped").length,failedCount:o.filter(a=>a.status==="failed").length,warnings:n}}import{join as Vr}from"path";var wS=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function kS(e){if(typeof e!="string")return null;let t=wS.exec(e.trim());if(!t)return null;let[,s,i,r,n]=t;return{major:Number(s),minor:Number(i),patch:Number(r),prerelease:n?n.split("."):[]}}function vS(e,t){let s=kS(e);if(!s)throw new Error(`invalid semver: ${t} "${e}"`);return s}var Wa=new Map;function Ya(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("register: provider.id is required");if(vS(e.version,`provider ${e.id} version`),typeof e.schemaVersion!="number"||!Number.isInteger(e.schemaVersion))throw new Error(`register: provider ${e.id} schemaVersion must be an integer`);let t=Wa.get(e.id)??[];if(t.some(s=>s.version===e.version))throw new Error(`register: provider ${e.id}@${e.version} already registered`);t.push(e),Wa.set(e.id,t)}function Dr(){let e=[];for(let t of Wa.values())for(let s of t)e.push(s);return e}import{stat as SS}from"fs/promises";var fp="quality",pp="1.0.0",mp=1;function $S(e){return e.topSuggestions.map(t=>({severity:"info",message:t}))}function xS(e){return e.categories.map(t=>({id:t.id,name:t.name,score:t.score,max:t.max}))}var hp={id:fp,version:pp,schemaVersion:mp,description:"Static linter for SKILL.md structure, description, and safety.",async applicable(e){try{return(await SS(e.skillMdPath)).isFile()?{ok:!0}:{ok:!1,reason:`${e.skillMdPath} is not a file`}}catch{return{ok:!1,reason:`SKILL.md not found at ${e.skillMdPath}`}}},async run(e,t){let s=await ma(e.skillPath);return{providerId:fp,providerVersion:pp,schemaVersion:mp,score:s.overallScore,passed:s.grade!=="F",categories:xS(s),findings:$S(s),raw:s,startedAt:"",durationMs:0}}};var kp=ml(Fo(),1);import{readFile as ES,stat as PS}from"fs/promises";import{basename as IS}from"path";var gp="skill-best-practice",yp="1.1.0",bp=1,CS=new Set(["name","description","license","allowed-tools","metadata","compatibility","effort"]),wp=new Set(["low","medium","high","xhigh","max"]),za=250,LS=/^\d+\.\d+\.\d+$/;function AS(e){if(!e.startsWith("---"))return null;let t=e.split(`
|
|
340
|
+
`);if(t.length<3||t[0]?.trim()!=="---")return null;let s=t.findIndex((i,r)=>r>0&&i.trim()==="---");return s===-1?null:t.slice(1,s).join(`
|
|
341
|
+
`)}function _r(e){return{severity:e.severity,message:e.message,code:e.id,categoryId:"validation"}}function oe(e,t,s,i,r,n){e.push({id:t,label:s,passed:i,severity:r,message:n})}function Fr(e,t,s){return{skillPath:e.skillPath,skillMdPath:e.skillMdPath,validatedAt:new Date().toISOString(),checkCount:t.length,passedChecks:t.filter(i=>i.passed).length,checks:t,frontmatter:s}}async function RS(e){let t=await ES(e.skillMdPath,"utf-8"),s=[],i=AS(t);if(i===null){oe(s,"missing-frontmatter","Frontmatter exists",!1,"error","SKILL.md must start with a YAML frontmatter block.");let L=Fr(e,s,null);return{score:0,passed:!1,findings:s.map(_r),raw:L}}oe(s,"frontmatter-present","Frontmatter exists",!0,"error","SKILL.md contains a YAML frontmatter block.");let r;try{r=(0,kp.parse)(i)}catch(L){oe(s,"invalid-yaml","Frontmatter parses as YAML",!1,"error",`Invalid YAML in frontmatter: ${L?.message??String(L)}`);let E=Fr(e,s,null);return{score:0,passed:!1,findings:s.map(_r),raw:E}}if(!r||typeof r!="object"||Array.isArray(r)){oe(s,"frontmatter-not-object","Frontmatter is a mapping",!1,"error","Frontmatter must parse to a YAML object.");let L=Fr(e,s,null);return{score:0,passed:!1,findings:s.map(_r),raw:L}}let n=r;oe(s,"frontmatter-object","Frontmatter is a mapping",!0,"error","Frontmatter parses to a YAML object.");let o=Object.keys(n).filter(L=>!CS.has(L));oe(s,"allowed-keys","Allowed top-level keys only",o.length===0,"error",o.length===0?"Frontmatter uses only the allowed top-level keys.":`Unexpected frontmatter key(s): ${o.sort().join(", ")}.`);let a=n.name,c=typeof a=="string"?a.trim():"";if(oe(s,"name-present","Name is present and non-empty",c.length>0,"error",c.length>0?"Frontmatter includes a non-empty `name`.":"Frontmatter must include a non-empty string `name`."),c.length>0){let L=/^[a-z0-9-]+$/.test(c)&&!c.startsWith("-")&&!c.endsWith("-")&&!c.includes("--")&&c.length<=64;oe(s,"name-kebab-case","Name follows skill-best-practice naming rules",L,"error",L?"Name follows the skill-best-practice kebab-case naming rules.":"Name must be kebab-case, avoid consecutive/edge hyphens, and stay within 64 characters.")}let u=n.description,f=typeof u=="string"?u.trim():"";if(oe(s,"description-present","Description is present and non-empty",f.length>0,"error",f.length>0?"Frontmatter includes a non-empty `description`.":"Frontmatter must include a non-empty string `description`."),f.length>0){let L=!f.includes(`
|
|
342
|
+
`)&&!f.includes("\r")&&!f.includes("<")&&!f.includes(">")&&f.length<=1024;oe(s,"description-shape","Description follows skill-best-practice formatting rules",L,"error",L?"Description is single-line, angle-bracket free, and within 1024 characters.":"Description must be a single line, avoid angle brackets, and stay within 1024 characters.");let E=f.length<=za;oe(s,"description-runtime-budget","Description fits the runtime context budget",E,"warning",E?`Description is ${f.length} chars (target \u2264 ${za}).`:`Description is ${f.length} chars; target \u2264 ${za}. The /skills listing truncates tail-first, often chopping the negative-trigger clause.`)}let d=n.effort;oe(s,"effort-enum","Effort uses the supported enum",d===void 0||typeof d=="string"&&wp.has(d.trim()),"error",d===void 0||typeof d=="string"&&wp.has(d.trim())?"Effort is omitted or uses a supported value.":"Effort must be one of: low, medium, high, xhigh, max.");let p=n.compatibility;if(p!==void 0){let L=typeof p=="string"&&p.length<=500;oe(s,"compatibility-shape","Compatibility is a short string",L,"error",L?"Compatibility is a valid short string.":"Compatibility must be a string no longer than 500 characters.")}let m=n.metadata&&typeof n.metadata=="object"&&!Array.isArray(n.metadata)?n.metadata:null,y=m?.version,h=typeof y=="string"||typeof y=="number"?String(y).trim():"",g=h.length>0;if(oe(s,"metadata-version-present","metadata.version is present",g,"error",g?"Frontmatter declares `metadata.version`.":"Frontmatter must declare `metadata.version` (start new skills at 1.0.0)."),g){let L=LS.test(h);oe(s,"metadata-version-semver","metadata.version follows MAJOR.MINOR.PATCH",L,"error",L?"`metadata.version` follows semantic versioning.":`\`metadata.version\` must follow semantic versioning (e.g. 1.0.0); got "${h}".`)}let b=m?.author,k=typeof b=="string"&&b.trim().length>0;if(oe(s,"metadata-author-present","metadata.author is present",k,"warning",k?"Frontmatter declares `metadata.author`.":"Add `metadata.author` (recommended for published skills) so users know who maintains the skill."),c.length>0){let L=IS(e.skillPath),E=L===c;oe(s,"name-matches-directory","Name matches the parent directory",E,"error",E?"Frontmatter `name` matches the skill directory.":`Frontmatter \`name\` ("${c}") must match the parent directory ("${L}").`)}let S=/don'?t use (?:for|when|if|on)|not (?:for|intended for|suitable for|meant for)\b|skip (?:for|when|if)|avoid (?:using )?(?:for|when|on)|never (?:use )?for\b|only (?:use )?for\b/i.test(f);oe(s,"negative-trigger-clause","Description includes a negative-trigger clause",S,"warning",S?"Description names adjacent cases that should not trigger the skill.":"Description appears to lack a negative-trigger clause; consider naming adjacent cases that should not trigger the skill.");let v=Fr(e,s,n),x=v.checkCount===0?100:Math.round(v.passedChecks/v.checkCount*100),I=s.filter(L=>!L.passed).map(_r);return{score:x,passed:I.every(L=>L.severity!=="error"),findings:I,raw:v}}var vp={id:gp,version:yp,schemaVersion:bp,description:"Deterministic SKILL.md best-practice validation (rules aligned with the skill-creator standard, v1.7.1).",async applicable(e){try{return(await PS(e.skillMdPath)).isFile()?{ok:!0}:{ok:!1,reason:`${e.skillMdPath} is not a file`}}catch{return{ok:!1,reason:`SKILL.md not found at ${e.skillMdPath}`}}},async run(e,t){let s=await RS(e);return{providerId:gp,providerVersion:yp,schemaVersion:bp,score:s.score,passed:s.passed,categories:[{id:"validation",name:"Deterministic validation",score:s.raw.passedChecks,max:s.raw.checkCount,findings:s.findings.length>0?s.findings:void 0}],findings:s.findings,raw:s.raw,startedAt:"",durationMs:0}}};function Sp(){Ya(hp),Ya(vp)}var $p=!1;function jr(){$p||(Sp(),$p=!0)}function qr(){return jr(),Dr()}function xp(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Ep(e,t,s,i,r){let n={severity:"error",message:i,code:r};return{providerId:e.id,providerVersion:e.version,schemaVersion:e.schemaVersion,score:0,passed:!1,categories:[],findings:[n],raw:void 0,startedAt:t,durationMs:s}}async function Br(e,t,s={}){let i=new Date().toISOString(),r=performance.now(),n={id:e.id,version:e.version,schemaVersion:e.schemaVersion},o=new AbortController;s.signal&&(s.signal.aborted?o.abort(s.signal.reason):s.signal.addEventListener("abort",()=>o.abort(s.signal?.reason)));let a=null;typeof s.timeoutMs=="number"&&s.timeoutMs>0&&(a=setTimeout(()=>o.abort(new Error("timeout")),s.timeoutMs));let c={...s,signal:o.signal};try{let u=await Promise.race([e.run(t,c).then(p=>({kind:"ok",value:p})),new Promise(p=>{if(o.signal.aborted){p({kind:"timeout"});return}o.signal.addEventListener("abort",()=>p({kind:"timeout"}))})]),f=Math.max(0,Math.round(performance.now()-r));if(u.kind==="timeout"){let p=o.signal.reason,m=p instanceof Error&&p.message==="timeout"?`provider timed out after ${s.timeoutMs}ms`:`provider aborted: ${xp(p)}`;return Ep(n,i,f,m,p instanceof Error&&p.message==="timeout"?"timeout":"aborted")}let d=u.value;return{...d,providerId:n.id,providerVersion:n.version,schemaVersion:d.schemaVersion??n.schemaVersion,startedAt:i,durationMs:f}}catch(u){let f=Math.max(0,Math.round(performance.now()-r));return Ep(n,i,f,xp(u),"provider-threw")}finally{a&&clearTimeout(a)}}function NS(e){return e>=90?"A":e>=80?"B":e>=65?"C":e>=50?"D":"F"}function Pp(e){return{id:e.providerId,version:e.providerVersion,schemaVersion:e.schemaVersion,score:e.score,passed:e.passed,categories:e.categories,findings:e.findings,raw:e.raw}}function Ip(e,t){return{providerId:e.providerId,providerVersion:e.providerVersion,schemaVersion:e.schemaVersion,passed:e.passed,overallScore:e.score,grade:NS(e.score),categories:e.categories.map(s=>({id:s.id,name:s.name,score:s.score,max:s.max})),evaluatedAt:e.startedAt,evaluatedVersion:t}}function Ws(e){return[...e].sort((t,s)=>t.id==="quality"&&s.id!=="quality"?-1:s.id==="quality"&&t.id!=="quality"?1:t.id.localeCompare(s.id))}import{join as TS}from"path";function OS(){console.log(`${l.bold("Usage:")} asm eval <target> [options]
|
|
388
343
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
asm audit security code-review ${u.dim("Audit an installed skill")}
|
|
394
|
-
asm audit security github:user/repo ${u.dim("Audit a remote skill before installing")}
|
|
395
|
-
asm audit security --all ${u.dim("Audit all installed skills")}
|
|
396
|
-
asm audit security code-review --json ${u.dim("Output audit as JSON")}
|
|
397
|
-
asm audit security code-review --machine ${u.dim("Machine-readable v1 envelope output")}
|
|
398
|
-
asm audit security https://github.com/user/skills/tree/main/skills/agent-config
|
|
399
|
-
${u.dim("Audit a skill from a subfolder URL")}`)}function sk(){console.log(`${u.bold("Usage:")} asm publish [path] [options]
|
|
344
|
+
Evaluate a skill's SKILL.md against best practices and produce a scored quality
|
|
345
|
+
report with recommendations. Zero configuration \u2014 just point it at a skill
|
|
346
|
+
directory. Categories: structure, description quality, prompt engineering,
|
|
347
|
+
context efficiency, safety, testability, and naming conventions.
|
|
400
348
|
|
|
401
|
-
|
|
402
|
-
|
|
349
|
+
Accepts a local path, a GitHub shorthand, or a GitHub URL. When the target is a
|
|
350
|
+
collection (no SKILL.md at the root but each immediate child has one), every
|
|
351
|
+
child skill is evaluated and an aggregate summary is printed.
|
|
403
352
|
|
|
404
|
-
${
|
|
405
|
-
path
|
|
353
|
+
${l.bold("Arguments:")}
|
|
354
|
+
target Local path, github:owner/repo[#ref][:subpath], or
|
|
355
|
+
https://github.com/owner/repo[/tree/<ref>/<sub>]
|
|
406
356
|
|
|
407
|
-
${
|
|
408
|
-
--
|
|
409
|
-
--
|
|
410
|
-
|
|
411
|
-
--json Output result as JSON
|
|
357
|
+
${l.bold("Options:")}
|
|
358
|
+
--fix Apply deterministic auto-fixes to SKILL.md (creates .bak)
|
|
359
|
+
--dry-run With --fix, preview the diff without writing
|
|
360
|
+
--json Output report as JSON
|
|
412
361
|
--machine Output in stable machine-readable v1 envelope format
|
|
362
|
+
--concurrency N Cap parallel per-skill evals in batch mode (default: 4)
|
|
363
|
+
--keep Preserve the temp dir used for remote clones
|
|
364
|
+
-t, --transport M Git transport (auto|https|ssh) for remote targets
|
|
413
365
|
--no-color Disable ANSI colors
|
|
414
366
|
-V, --verbose Show debug output
|
|
415
367
|
|
|
416
|
-
${
|
|
417
|
-
asm
|
|
418
|
-
asm
|
|
419
|
-
asm
|
|
420
|
-
asm
|
|
421
|
-
asm
|
|
422
|
-
asm
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
${u.
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
${u.bold("Examples:")}
|
|
433
|
-
asm outdated ${u.dim("Show outdated skills")}
|
|
434
|
-
asm outdated --json ${u.dim("Output as JSON")}
|
|
435
|
-
asm outdated --machine ${u.dim("Machine-readable output")}`)}function nk(){console.log(`${u.bold("Usage:")} asm update [name...] [options]
|
|
436
|
-
|
|
437
|
-
Update outdated skills to their latest version with security re-audit.
|
|
368
|
+
${l.bold("Examples:")}
|
|
369
|
+
asm eval ./my-skill ${l.dim("Score a single skill")}
|
|
370
|
+
asm eval ./skills/ ${l.dim("Batch-score every skill in the dir")}
|
|
371
|
+
asm eval github:mattpocock/skills:grill-me ${l.dim("Fetch a remote skill and score it")}
|
|
372
|
+
asm eval github:mattpocock/skills ${l.dim("Batch-score a remote collection")}
|
|
373
|
+
asm eval https://github.com/mattpocock/skills/tree/main/grill-me
|
|
374
|
+
asm eval ./my-skill --json ${l.dim("Output report as JSON")}
|
|
375
|
+
asm eval ./my-skill --fix ${l.dim("Auto-fix deterministic issues")}
|
|
376
|
+
asm eval ./my-skill --fix --dry-run ${l.dim("Preview fixes as diff")}
|
|
377
|
+
asm eval ./my-skill --machine ${l.dim("Machine-readable v1 envelope")}
|
|
378
|
+
asm eval-providers list ${l.dim("List registered eval providers")}`)}function MS(e){let t=e.findings.find(s=>s.severity==="error"&&(s.code==="provider-threw"||s.code==="timeout"||s.code==="aborted"));if(t)throw new Error(t.message)}async function Xa(e,t,s){await Ce();let i=ce(e);if(i.isLocal)throw new Error(`fetchRemoteSkillDir received a local path: "${e}". This is a bug \u2014 local paths should use the non-remote branch.`);he(i,e),i=await ut(i);let r=await Le(i,t),n=i.subpath?TS(r,i.subpath):r;try{Fe(r,n,e)}catch(u){throw await Q(r),u}let o=null;try{let{execFile:u}=await import("child_process"),{promisify:f}=await import("util"),d=f(u),{stdout:p}=await d("git",["-C",r,"rev-parse","HEAD"],{timeout:5e3}),m=p.trim();/^[0-9a-f]{40}$/i.test(m)&&(o=m)}catch{}let a=`github:${i.owner}/${i.repo}${i.ref?`#${i.ref}`:""}${i.subpath?`:${i.subpath}`:""}`;return{rootDir:n,tempDir:r,cleanup:async()=>{s||await Q(r)},sourceRef:a,commitSha:o}}async function Cp(e){jr();try{let t={skillPath:e.skillPath,skillMdPath:e.skillMdPath},s=(await Promise.all(Ws(qr()).map(async n=>(await n.applicable(t,{})).ok?Br(n,t):null))).filter(n=>n!==null),i=s.find(n=>n.providerId==="quality");if(!i)throw new Error("quality provider did not produce a result");return MS(i),{report:{...i.raw,providers:Ws(s.map(Pp))},error:null}}catch(t){return{report:null,error:t?.message??String(t)}}}async function Lp(e){if(e.flags.help){OS();return}let t=e.flags.machine?me():void 0,s=performance.now(),i=e.subcommand;if(i||(e.flags.machine&&(t?.(),console.log(z("eval",Y.INVALID_ARGUMENT,"Missing required argument: <skill-path>",s)),process.exit(2)),$("Missing required argument: <skill-path>"),console.error('Run "asm eval --help" for usage.'),process.exit(2)),e.flags.fix){if(qt(i)){let n="--fix is only supported for local skill paths. Clone the repo first or run `asm install` to materialise it locally.";e.flags.machine&&(t?.(),console.log(z("eval",Y.INVALID_ARGUMENT,n,s)),process.exit(2)),$(n),process.exit(2)}try{let n=await ga(),o=await ha(i,{dryRun:e.flags.dryRun,gitAuthor:n});if(e.flags.machine){t?.(),console.log(G("eval",Fs(o.report,o),s));return}if(e.flags.json){console.log(JSON.stringify({report:o.report,fix:{dryRun:o.dryRun,applied:o.applied,skipped:o.skipped,backupPath:o.backupPath,diff:o.diff}},null,2));return}console.log(Ds(o.report)),console.log(""),console.log(ba(o));return}catch(n){e.flags.machine&&(t?.(),console.log(z("eval",Y.SKILL_NOT_FOUND,n?.message??String(n),s)),process.exit(1)),$(n?.message??String(n)),process.exit(1)}return}let r=null;try{r=await ka(i,{fetchRemote:n=>Xa(n,e.flags.transport,e.flags.keep)})}catch(n){e.flags.machine&&(t?.(),console.log(z("eval",Y.SKILL_NOT_FOUND,n?.message??String(n),s)),process.exit(1)),$(n?.message??String(n)),process.exit(1)}try{if(!r.isCollection&&r.targets.length===1){let u=r.targets[0],{report:f,error:d}=await Cp(u);if(!f)throw new Error(d??"eval failed");if(e.flags.machine){t?.();let p=Fs(f,null),m=r.provenance.remote?{...p,provenance:{input:r.provenance.input,remote:!0,source_ref:r.provenance.sourceRef??null,commit_sha:r.provenance.commitSha??null,temp_path:r.provenance.tempPath??null}}:p;console.log(G("eval",m,s));return}if(e.flags.json){r.provenance.remote?console.log(JSON.stringify({...f,provenance:{input:r.provenance.input,remote:!0,sourceRef:r.provenance.sourceRef??null,commitSha:r.provenance.commitSha??null,tempPath:r.provenance.tempPath??null}},null,2)):console.log(ya(f));return}console.log(Ds(f)),r.provenance.remote&&DS(r.provenance);return}let n=e.flags.concurrency||4;if(r.targets.length===0)throw new Error(`No skills to evaluate at "${i}" \u2014 the resolved location has no SKILL.md in itself or its immediate children.`);let o=await _s(r.targets,n,async u=>{let{report:f,error:d}=await Cp(u);return{label:u.label,skillPath:u.skillPath,report:f,error:d}}),a=va(o),c={provenance:r.provenance,aggregate:a,results:o};if(e.flags.machine){t?.(),console.log(G("eval",$a(c),s));return}if(e.flags.json){console.log(JSON.stringify({provenance:c.provenance,aggregate:c.aggregate,results:c.results.map(u=>({label:u.label,skillPath:u.skillPath,error:u.error,report:u.report}))},null,2));return}for(let u of c.results)u.report?console.log(Ds(u.report)):(console.log(`Skill evaluation: ${u.skillPath}`),console.log(` ${l.red("error:")} ${u.error??"unknown failure"}`)),console.log("");console.log(Sa(c)),r.provenance.remote&&e.flags.verbose}catch(n){e.flags.machine&&(t?.(),console.log(z("eval",Y.SKILL_NOT_FOUND,n?.message??String(n),s)),process.exit(1)),$(n?.message??String(n)),process.exit(1)}finally{if(r)try{await r.cleanup()}catch{}}}function DS(e){let t=[];t.push(""),t.push(l.dim("Fetched remote skill:")),e.sourceRef&&t.push(l.dim(` Source: ${e.sourceRef}`)),e.commitSha&&t.push(l.dim(` Commit: ${e.commitSha}`)),e.tempPath&&t.push(l.dim(` Temp: ${e.tempPath}`)),console.log(t.join(`
|
|
379
|
+
`))}function _S(){console.log(`${l.bold("Usage:")} asm eval-providers <subcommand> [options]
|
|
380
|
+
|
|
381
|
+
Manage evaluation providers registered with the ${l.bold("asm eval")} framework.
|
|
382
|
+
Providers implement the ${l.bold("EvalProvider")} contract (see src/eval/types.ts) and
|
|
383
|
+
are resolved by id and semver range.
|
|
438
384
|
|
|
439
|
-
${
|
|
440
|
-
|
|
385
|
+
${l.bold("Subcommands:")}
|
|
386
|
+
list List every registered (id, version) provider
|
|
441
387
|
|
|
442
|
-
${
|
|
443
|
-
|
|
444
|
-
--json Output as JSON
|
|
445
|
-
--machine Output in stable machine-readable format
|
|
388
|
+
${l.bold("Options:")}
|
|
389
|
+
--json Output as JSON (list)
|
|
446
390
|
--no-color Disable ANSI colors
|
|
447
391
|
-V, --verbose Show debug output
|
|
448
392
|
|
|
449
|
-
${
|
|
450
|
-
asm
|
|
451
|
-
asm
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
393
|
+
${l.bold("Examples:")}
|
|
394
|
+
asm eval-providers list ${l.dim("Show registered providers")}
|
|
395
|
+
asm eval-providers list --json ${l.dim("Machine-readable listing")}`)}async function Ap(e){if(e.flags.help){_S();return}let t=e.subcommand;switch(t||($("Missing subcommand. Use: list"),console.error('Run "asm eval-providers --help" for usage.'),process.exit(2)),t){case"list":{jr();let s=Dr();if(e.flags.json){console.log(U(s.map(a=>({id:a.id,version:a.version,schemaVersion:a.schemaVersion,description:a.description,requires:a.requires??[]}))));return}if(s.length===0){console.log("No eval providers registered.");return}let i=["id","version","schemaVersion","description","requires"],r=s.map(a=>[a.id,a.version,String(a.schemaVersion),a.description,a.requires&&a.requires.length>0?a.requires.join(","):"-"]),n=i.map((a,c)=>Math.max(a.length,...r.map(u=>u[c].length))),o=a=>a.map((c,u)=>c.padEnd(n[u])).join(" ");console.log(l.bold(o(i))),console.log(n.map(a=>"-".repeat(a)).join(" "));for(let a of r)console.log(o(a));return}default:$(`Unknown eval-providers subcommand: "${t}". Use: list`),console.error('Run "asm eval-providers --help" for usage.'),process.exit(2)}}function FS(){console.log(`${l.bold("Usage:")} asm get <skill> [options]
|
|
396
|
+
|
|
397
|
+
Resolve a skill and write its SKILL.md body to stdout. Nothing is installed:
|
|
398
|
+
no provider directory, no library entry, no residency in any system prompt.
|
|
399
|
+
Use it to pull a skill in for a single task and pay nothing afterwards.
|
|
400
|
+
|
|
401
|
+
<skill> is resolved in this order, and the rung that answered is reported:
|
|
402
|
+
1. installed a skill already present in one of your agents
|
|
403
|
+
2. library a library skill, including deactivated ones
|
|
404
|
+
3. index an indexed catalog skill (resolved by exact name)
|
|
405
|
+
4. registry the ASM registry, same route as \`asm install <name>\`
|
|
406
|
+
An explicit \`github:owner/repo[#ref][:path]\` shorthand, a GitHub URL, or a
|
|
407
|
+
local path skips the ladder and is fetched directly.
|
|
408
|
+
|
|
409
|
+
Index, registry and remote sources are fetched into a temp clone, scanned with
|
|
410
|
+
the same pre-install security scan \`asm install\` runs, and deleted. The body
|
|
411
|
+
goes to stdout; provenance and the security verdict go to stderr.
|
|
412
|
+
|
|
413
|
+
${l.bold("Options:")}
|
|
414
|
+
--json Output {name, description, tier, source, commit,
|
|
415
|
+
tokenCount, security, content} as a JSON object
|
|
416
|
+
--machine Stable machine-readable v1 envelope
|
|
417
|
+
--audit Also print the full security audit report (stderr),
|
|
418
|
+
for any resolved skill, not only fetched ones
|
|
419
|
+
-s, --scope <s> Filter installed lookup: global, project, or both
|
|
420
|
+
--transport <t> Clone transport for remote sources: auto, https, ssh
|
|
421
|
+
--no-cache Bypass the registry cache when resolving a name
|
|
422
|
+
--no-color Disable ANSI colors
|
|
464
423
|
-V, --verbose Show debug output
|
|
465
424
|
|
|
466
|
-
${
|
|
467
|
-
asm
|
|
468
|
-
asm
|
|
469
|
-
asm
|
|
470
|
-
|
|
471
|
-
`)
|
|
472
|
-
`)
|
|
473
|
-
${u.bold("Proceed with removal?")} [y/N] `);let m=await G();m.toLowerCase()!=="y"&&m.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let f;try{f=await qi(r,void 0,c?.needed?c:void 0)}catch(m){let y=Array.isArray(m?.log)?m.log:[];for(let h of y)console.error(h);$(m?.message||"Uninstall failed."),process.exit(1)}for(let m of f)console.error(m);let d=new Set(r.directories.map(m=>zd(m.path))),p=a.filter(m=>!d.has(zd(m.originalPath)));try{l&&p.length>0?c?.needed&&!c.repointOnly&&await Do(t,c.toProvider):await Mo(t)}catch{}console.error(u.green(`
|
|
474
|
-
Done.`))}function G(){return new Promise(e=>{let t="",s=!1;function i(){process.stdin.removeListener("data",r),process.stdin.removeListener("end",o),process.stdin.pause(),clearTimeout(a)}function n(l){s||(s=!0,i(),e(l))}function r(l){t+=l,t.includes(`
|
|
475
|
-
`)&&n(t.trim())}function o(){n(t.trim())}let a=setTimeout(()=>{n(t.trim())},3e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",r),process.stdin.on("end",o),process.stdin.resume()})}function uk(){console.log(`${u.bold("Usage:")} asm disable <target> [options]
|
|
476
|
-
asm disable --all [options]
|
|
477
|
-
|
|
478
|
-
Disable skills without uninstalling them. Disabling renames a skill's
|
|
479
|
-
${u.dim("SKILL.md")} to ${u.dim("SKILL.md.disabled")} so neither asm nor your agent sees it.
|
|
480
|
-
The directory stays intact; ${u.bold("asm enable")} reverses it.
|
|
481
|
-
|
|
482
|
-
${u.dim("Note: skills installed to several tools at once share one SKILL.md")}
|
|
483
|
-
${u.dim("(siblings are symlinks), so disabling one affects all of them \u2014 asm warns")}
|
|
484
|
-
${u.dim("and records every sibling. Separately-installed copies stay independent.")}
|
|
425
|
+
${l.bold("Examples:")}
|
|
426
|
+
asm get code-review ${l.dim("Print the body to stdout")}
|
|
427
|
+
asm get code-review > SKILL.md ${l.dim("Save it without installing")}
|
|
428
|
+
asm get github:owner/repo:skills/review ${l.dim("Fetch a remote skill")}
|
|
429
|
+
asm get owner/review --audit ${l.dim("Show the full security audit")}
|
|
430
|
+
asm get code-review --json ${l.dim("Structured output")}`)}function jS(e){return e==="high"?l.red("[!] High Risk"):e==="medium"?l.yellow("[~] Medium Risk"):l.green("[ok] Safe")}function qS(e){let t=[` ${l.bold(e.name)} ${l.dim(J(e.tokenCount))}`,` ${l.dim("source:")} ${e.source}${e.commit?` @ ${e.commit.slice(0,7)}`:""} ${l.dim(`(${e.tier})`)}`];if(e.security){let{risk:s,warnings:i,categories:r}=e.security,n=i?l.dim(` (${i} warning${i===1?"":"s"}: ${r.join(", ")})`):"";t.push(` ${l.dim("security:")} ${jS(s)}${n}`)}t.push(` ${l.dim("residency:")} ${l.dim("none \u2014 nothing was installed")}`),process.stderr.write(t.join(`
|
|
431
|
+
`)+`
|
|
485
432
|
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
433
|
+
`)}async function BS(e,t){try{let{name:s,description:i}=await ye(e);return{name:s,description:i}}catch(s){let i=(await dt(e)).filter(r=>r.relPath);if(i.length>0){let r=i.slice(0,5);throw new Error(`"${t}" holds ${i.length} skills, not one. Pick a skill:
|
|
434
|
+
`+r.map(n=>` asm get ${t}:${n.relPath}`).join(`
|
|
435
|
+
`),{cause:s})}throw s}}async function Qa(e,t,s){he(ce(t),t),process.stderr.write(l.dim(`Fetching ${t}\u2026
|
|
436
|
+
`));let i=await Xa(t,e.flags.transport,!1);try{let r=ce(t),n=`github:${r.owner}/${r.repo}${r.ref?`#${r.ref}`:""}`,{name:o,description:a}=await BS(i.rootDir,n),c=await Ur(Vr(i.rootDir,"SKILL.md"),"utf-8"),u=await Ns(i.rootDir),f={risk:Ts(u),warnings:u.length,categories:Array.from(new Set(u.map(d=>d.category))).sort()};return{result:{name:o,description:a,tier:s,source:i.sourceRef,commit:i.commitSha,tokenCount:je(c),security:f,content:c},cleanup:i.cleanup,dir:i.rootDir,owner:r.owner,repo:r.repo}}catch(r){throw await i.cleanup(),r}}function Za(e,t,s,i={}){let r=W(e);return{name:i.name||r.name||s.split(/[/\\]/).pop()||s,description:i.description??(r.description||"").replace(/\s*\n\s*/g," ").trim(),tier:t,source:s,commit:i.commit??null,tokenCount:i.tokenCount??je(e),security:null,content:e}}async function US(e,t){if(qt(t))return Qa(e,t,"remote");if(ct(t)||await Rs(t)){let a=ce(ct(t)?t:`./${t}`).localPath,c;try{c=await Ur(Vr(a,"SKILL.md"),"utf-8")}catch{throw new Error(`No SKILL.md found in "${a}".`)}return{result:Za(c,"local",a),cleanup:null,dir:a}}let s=await j(),i=await H(s,e.flags.scope),r=i.find(a=>a.dirName===t)??i.find(a=>a.name===t);if(r){let a=r._skillMdContent!==void 0?r._skillMdContent:await Ur(Vr(r.path,"SKILL.md"),"utf-8");return{result:Za(a,"installed",r.path,{name:r.name,description:r.description,tokenCount:r.tokenCount}),cleanup:null,dir:r.path}}let n=Hs(await gt(),t);if(n&&!n.missing){let a=await Ur(Vr(n.libraryPath,"SKILL.md"),"utf-8");return{result:Za(a,"library",n.libraryPath,{name:n.name,commit:n.commitHash||null}),cleanup:null,dir:n.libraryPath}}let o=await tf(t);if(o.status==="ambiguous")throw new Tt(`"${t}" matches ${o.matches.length} indexed skills.`,o.matches.map(a=>`${a.repo.owner}/${a.repo.repo} \u2014 asm get ${a.skill.installUrl}`));if(o.status==="found")return Qa(e,o.match.skill.installUrl,"index");if(Qe(t)){let{resolved:a,multipleMatches:c,suggestions:u}=await xr(t,{noCache:e.flags.noCache});if(a){let f=a.manifest,d=f.repository.replace("https://github.com/",""),p=f.skill_path?`github:${d}#${f.commit}:${f.skill_path}`:`github:${d}#${f.commit}`;return Qa(e,p,"registry")}if(c.length>0)throw new Tt(`"${t}" is published by ${c.length} authors.`,c.slice(0,5).map(f=>`${f.author}/${f.name} \u2014 asm get ${f.author}/${f.name}`));if(u.length>0)throw new Error(`Skill "${t}" not found. Did you mean: ${u.join(", ")}?`)}throw new Error(`Skill "${t}" not found installed, in the library, in the index, or in the registry.`)}async function Rp(e){if(e.flags.help){FS();return}let t=performance.now(),s=e.subcommand;s||($("Missing required argument: <skill>"),console.error('Run "asm get --help" for usage.'),process.exit(2));let i=me(),r=null;try{let n=await US(e,s);r=n.cleanup;let o=n.result;if(e.flags.audit){let a=await Ne(n.dir,o.name,n.owner,n.repo);process.stderr.write(_t(a)+`
|
|
437
|
+
`)}e.flags.machine?process.stdout.write(G("get",o,t)+`
|
|
438
|
+
`):e.flags.json?process.stdout.write(U(o)+`
|
|
439
|
+
`):(qS(o),process.stdout.write(o.content),o.content.endsWith(`
|
|
440
|
+
`)||process.stdout.write(`
|
|
441
|
+
`))}catch(n){let o=n?.message||String(n),a=n instanceof Tt?n.candidates:void 0;if(e.flags.machine)process.stdout.write(z("get",a?Y.INVALID_ARGUMENT:Y.SKILL_NOT_FOUND,o,t,a?{candidates:a}:void 0)+`
|
|
442
|
+
`);else if($(o),a)for(let c of a)process.stderr.write(` ${l.cyan("\u2022")} ${c}
|
|
443
|
+
`);else process.stderr.write(l.dim(`Try ${l.bold("asm list")} or ${l.bold(`asm search "${s}"`)}.
|
|
444
|
+
`));process.exitCode=1}finally{r&&await r(),i()}}import{resolve as Np}from"path";function VS(){console.log(`${l.bold("Usage:")} asm uninstall <skill-name> [options]
|
|
490
445
|
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
-p, --tool <name> Limit to one tool/provider (e.g. claude, codex)
|
|
494
|
-
-s, --scope <s> Filter: global, local, project, or both (default: both)
|
|
495
|
-
-y, --yes Skip confirmation prompt
|
|
496
|
-
--json Output result as JSON
|
|
497
|
-
--machine Tab-separated output
|
|
498
|
-
--no-color Disable ANSI colors
|
|
499
|
-
-V, --verbose Show debug output
|
|
446
|
+
Remove a skill and its associated rule files. Shows a removal plan
|
|
447
|
+
before proceeding and asks for confirmation.
|
|
500
448
|
|
|
501
|
-
${
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
asm disable --all ${u.dim("# everything")}
|
|
508
|
-
asm disable code-review --tool claude --scope local`)}function dk(){console.log(`${u.bold("Usage:")} asm enable <target> [options]
|
|
509
|
-
asm enable --all [options]
|
|
449
|
+
${l.bold("Options:")}
|
|
450
|
+
-y, --yes Skip confirmation prompt
|
|
451
|
+
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
452
|
+
-p, --tool <name> Filter by tool/provider (e.g., claude, codex)
|
|
453
|
+
--no-color Disable ANSI colors
|
|
454
|
+
-V, --verbose Show debug output
|
|
510
455
|
|
|
511
|
-
|
|
512
|
-
${
|
|
456
|
+
${l.bold("Examples:")}
|
|
457
|
+
asm uninstall code-review ${l.dim("Remove with confirmation")}
|
|
458
|
+
asm uninstall code-review -y ${l.dim("Remove without confirmation")}
|
|
459
|
+
asm uninstall code-review -s project ${l.dim("Remove project copy only")}
|
|
460
|
+
asm uninstall code-review -p claude ${l.dim("Remove from Claude only")}`)}async function Tp(e){if(e.flags.help){VS();return}let t=e.subcommand;t||($("Missing required argument: <skill-name>"),console.error('Run "asm uninstall --help" for usage.'),process.exit(2));let s=await j(),i=await H(s,e.flags.scope),r={};e.flags.provider&&(r.providerFilter=e.flags.provider),e.flags.scope&&e.flags.scope!=="both"&&(r.scopeFilter=e.flags.scope);let n=Fl(t,i,s,r),o=await ql(n);o.length===0&&($(`Skill "${t}" not found or nothing to remove.`),process.exit(1));let a=i.filter(m=>m.dirName===t),c=r.providerFilter,u=null;c&&(u=jl(n,a,c)),console.error(l.bold("Removal plan:")),console.error(` ${l.dim("Scope:")} ${r.scopeFilter||"both"}`),c&&(console.error(` ${l.dim("Tool:")} ${c}`),u?.needed&&console.error(` ${l.yellow("\u26A0 Real folder relocation:")} ${u.fromPath} \u2192 ${u.toPath} (${u.toProvider})`)),console.error("");for(let m of o)console.error(` ${l.red("\u2022")} ${yl(m)}`);if(!e.flags.yes){process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2)),process.stderr.write(`
|
|
461
|
+
${l.bold("Proceed with removal?")} [y/N] `);let m=await K();m.toLowerCase()!=="y"&&m.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let f;try{f=await fi(n,void 0,u?.needed?u:void 0)}catch(m){let y=Array.isArray(m?.log)?m.log:[];for(let h of y)console.error(h);$(m?.message||"Uninstall failed."),process.exit(1)}for(let m of f)console.error(m);let d=new Set(n.directories.map(m=>Np(m.path))),p=a.filter(m=>!d.has(Np(m.originalPath)));try{c&&p.length>0?u?.needed&&!u.repointOnly&&await Ml(t,u.toProvider):await Ol(t)}catch{}console.error(l.green(`
|
|
462
|
+
Done.`))}import{realpath as a$}from"fs/promises";import{resolve as Hp,sep as Jp}from"path";import{readdir as KS,stat as GS}from"fs/promises";import{join as HS}from"path";async function JS(e){let t=0;try{let i=(await KS(e,{recursive:!0})).map(async n=>{try{let o=await GS(HS(e,n));if(o.isFile())return o.size}catch{}return 0});t=(await Promise.all(i)).reduce((n,o)=>n+o,0)}catch{}return t}async function Dp(e,t){let s={},i={global:0,project:0},r={},n=0,o=0,a=e.map(async f=>{s[f.provider]=(s[f.provider]||0)+1,i[f.scope]++,n+=tt(f),o+=Gt(f);let d=await JS(f.path);return r[f.path]=d,d}),u=(await Promise.all(a)).reduce((f,d)=>f+d,0);return{totalSkills:e.length,byProvider:s,byScope:i,totalDiskBytes:u,perSkillDiskBytes:r,duplicateGroups:t.duplicateGroups.length,duplicateInstances:t.totalDuplicateInstances,totalResidentTokens:n,totalBodyTokens:o}}function WS(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Ut(e,t,s=20){let i=Math.round(e/t*s),r=s-i;return l.green("#".repeat(i))+l.dim("-".repeat(r))}var Op={claude:"Claude Code",codex:"Codex",openclaw:"OpenClaw",agents:"Agents"};function _p(e){let t=[];t.push(""),t.push(l.blueBold(" Skill Statistics")),t.push(l.dim(" "+"-".repeat(20))),t.push(""),t.push(` ${l.bold("Total:")} ${l.cyan(String(e.totalSkills))} skills`),t.push(` ${l.bold("Disk:")} ${l.cyan(WS(e.totalDiskBytes))}`),t.push(` ${l.bold("Resident:")} ${l.cyan(J(e.totalResidentTokens))} ${l.dim("(every message)")}`),t.push(` ${l.bold("Bodies:")} ${l.cyan(J(e.totalBodyTokens))} ${l.dim("(only when a skill fires)")}`),t.push(l.dim(` Run ${l.bold("asm stats --tokens")} for the attention budget`)),t.push(""),t.push(l.bold(" By Tool"));let s=Object.entries(e.byProvider).sort((c,u)=>u[1]-c[1]),i=Math.max(...s.map(([,c])=>c)),r=Math.max(...s.map(([c])=>(Op[c]||c).length));for(let[c,u]of s){let f=Op[c]||c,d=zr(c,f.padEnd(r)),p=String(u).padStart(4);t.push(` ${d} ${p} ${Ut(u,i)}`)}t.push(""),t.push(l.bold(" By Scope"));let n=Math.max(e.byScope.global,e.byScope.project),o=String(e.byScope.global).padStart(4),a=String(e.byScope.project).padStart(4);return t.push(` ${"global ".padEnd(r)} ${o} ${Ut(e.byScope.global,n)}`),t.push(` ${"project".padEnd(r)} ${a} ${Ut(e.byScope.project,n)}`),t.push(""),t.push(l.bold(" Duplicates")),e.duplicateGroups>0?(t.push(` ${l.yellow(`${e.duplicateGroups} group(s), ${e.duplicateInstances} total instance(s)`)}`),t.push(l.dim(` Run ${l.bold("asm audit")} to review`))):t.push(` ${l.green("None")}`),t.push(""),t.join(`
|
|
463
|
+
`)}var YS=10;function el(e){if(e.length===0)return 0;let t=[...e].sort((i,r)=>i-r),s=Math.floor(t.length/2);return t.length%2===1?t[s]:Math.round((t[s-1]+t[s])/2)}function Mp(e,t,s,i,r){let n=e.get(t);n||(n={key:t,label:s,skills:0,residentTokens:0,bodyTokens:0},e.set(t,n)),n.skills++,n.residentTokens+=i,n.bodyTokens+=r}function Fp(e,t=YS){let s=new Map,i=new Map,r=[],n=0,o=0;for(let f of e){let d=tt(f),p=Gt(f);n+=d,o+=p,Mp(s,f.provider,f.providerLabel||f.provider,d,p),Mp(i,f.scope,f.scope,d,p),r.push({name:f.name,dirName:f.dirName,provider:f.provider,providerLabel:f.providerLabel||f.provider,scope:f.scope,path:f.path,residentTokens:d,bodyTokens:p})}let a=[...r].sort((f,d)=>d.residentTokens-f.residentTokens||f.name.localeCompare(d.name)),c=t>0?t:a.length,u=a.slice(0,c);return{totalSkills:e.length,totalResidentTokens:n,totalBodyTokens:o,medianResidentTokens:el(r.map(f=>f.residentTokens)),byProvider:[...s.values()].sort((f,d)=>d.residentTokens-f.residentTokens||d.skills-f.skills),byScope:[...i.values()].sort((f,d)=>d.residentTokens-f.residentTokens),heaviestResident:u,heaviestResidentTotal:r.length,heaviestResidentTruncated:u.length<r.length}}function jp(e){let t=[];if(t.push(""),t.push(l.blueBold(" Attention Budget")),t.push(l.dim(" "+"-".repeat(40))),t.push(""),t.push(l.dim(` Resident = frontmatter descriptions, paid on every message.
|
|
464
|
+
Bodies = full SKILL.md, paid only when a skill fires.`)),t.push(""),e.totalSkills===0)return t.push(" No installed skills."),t.push(""),t.join(`
|
|
465
|
+
`);let s=[...e.byProvider.map(a=>["provider",a])],i=Math.max(8,...s.map(([,a])=>a.label.length),5),r=e.byProvider.map(a=>J(a.residentTokens)),n=Math.max(...r.map(a=>a.length),J(e.totalResidentTokens).length),o=" "+"Tool".padEnd(i)+" "+"Skills".padStart(6)+" "+"Resident".padStart(n)+" Bodies";t.push(l.bold(o));for(let a of e.byProvider)t.push(" "+zr(a.key,a.label.padEnd(i))+" "+String(a.skills).padStart(6)+" "+l.cyan(J(a.residentTokens).padStart(n))+" "+l.dim(J(a.bodyTokens)));t.push(l.dim(" "+"-".repeat(i+n+22))),t.push(" "+l.bold("Total".padEnd(i))+" "+String(e.totalSkills).padStart(6)+" "+l.cyan(J(e.totalResidentTokens).padStart(n))+" "+l.dim(J(e.totalBodyTokens))),t.push(""),t.push(l.bold(" By Scope"));for(let a of e.byScope)t.push(" "+a.label.padEnd(i)+" "+String(a.skills).padStart(6)+" "+l.cyan(J(a.residentTokens).padStart(n))+" "+l.dim(J(a.bodyTokens)));if(t.push(""),e.heaviestResident.length>0){t.push(l.bold(" Heaviest resident descriptions"));let a=Math.max(...e.heaviestResident.map(f=>f.name.length)),c=Math.max(...e.heaviestResident.map(f=>J(f.residentTokens).length));for(let f of e.heaviestResident)t.push(" "+f.name.padEnd(a)+" "+l.cyan(J(f.residentTokens).padStart(c))+" "+l.dim(`(${f.provider}, ${f.scope})`));let u=e.heaviestResidentTotal-e.heaviestResident.length;u>0&&t.push(l.dim(` \u2026 ${u} more not shown \u2014 use --json for the full list`)),t.push(""),t.push(l.dim(` Median resident cost: ${J(e.medianResidentTokens)}`)),t.push(l.dim(` Run ${l.bold("asm audit residency")} for demotion advice`)),t.push("")}return t.join(`
|
|
466
|
+
`)}function qp(e){let t=[];for(let s of e){let i={},r=0,n=0,o=0,a=0;for(let u of s.skills){let f=tl(u.name,u.description);for(let d of f)i[d]=(i[d]||0)+1;u.verified&&r++,n+=u.tokenCount??0,u.evalSummary&&(o+=u.evalSummary.overallScore,a++)}let c=a>0?Math.round(o/a):void 0;t.push({owner:s.owner,repo:s.repo,repoUrl:s.repoUrl,skillCount:s.skills.length,categories:i,verifiedCount:r,totalTokens:n,avgEvalScore:c})}return t.sort((s,i)=>i.skillCount-s.skillCount)}function Bp(e){let t=new Map;for(let i of e){let r=t.get(i.owner);r||(r={owner:i.owner,totalSkills:0,repos:[],categories:{},verifiedCount:0,totalTokens:0,topSkills:[]},t.set(i.owner,r)),r.repos.push(`${i.owner}/${i.repo}`);for(let n of i.skills){r.totalSkills++;let o=tl(n.name,n.description);for(let a of o)r.categories[a]=(r.categories[a]||0)+1;n.verified&&r.verifiedCount++,r.totalTokens+=n.tokenCount??0,r.topSkills.push({name:n.name,repo:`${i.owner}/${i.repo}`})}}let s=[];for(let[i,r]of t){let n=r.topSkills.sort((o,a)=>a.name.localeCompare(o.name)).slice(0,10);s.push({...r,topSkills:n})}return s.sort((i,r)=>r.totalSkills-i.totalSkills)}function Up(e){let t=0,s=0,i=0,r={},n=new Set;for(let o of e){n.add(o.owner),t+=o.skills.length;for(let a of o.skills){a.verified&&s++,i+=a.tokenCount??0;let c=tl(a.name,a.description);for(let u of c)r[u]=(r[u]||0)+1}}return{totalRepos:e.length,totalSkills:t,totalAuthors:n.size,categoryDistribution:r,verifiedCount:s,totalTokens:i,avgTokensPerSkill:t>0?Math.round(i/t):0}}function Vp(e){let t=[];t.push(""),t.push(l.blueBold(` Repo: ${e.owner}/${e.repo}`)),t.push(l.dim(" "+"-".repeat(40))),t.push(""),t.push(` ${l.bold("Skills: ")}${l.cyan(String(e.skillCount))}`),t.push(` ${l.bold("Verified: ")}${l.cyan(String(e.verifiedCount))}`),t.push(` ${l.bold("Tokens: ")}${l.cyan(J(e.totalTokens))}`),e.avgEvalScore!==void 0&&t.push(` ${l.bold("Avg Eval: ")}${l.cyan(String(e.avgEvalScore))}`),t.push("");let s=Object.entries(e.categories).sort((i,r)=>r[1]-i[1]);if(s.length>0){t.push(l.bold(" Categories"));let i=Math.max(...s.map(([,r])=>r));for(let[r,n]of s){let o=r.padEnd(18),a=String(n).padStart(4);t.push(` ${o} ${a} ${Ut(n,i,20)}`)}t.push("")}return t.push(""),t.join(`
|
|
467
|
+
`)}function Kp(e){let t=[];t.push(""),t.push(l.blueBold(` Author: ${e.owner}`)),t.push(l.dim(" "+"-".repeat(40))),t.push(""),t.push(` ${l.bold("Total Skills: ")}${l.cyan(String(e.totalSkills))}`),t.push(` ${l.bold("Repos: ")}${l.cyan(String(e.repos.length))}`),t.push(` ${l.bold("Verified: ")}${l.cyan(String(e.verifiedCount))}`),t.push(` ${l.bold("Tokens: ")}${l.cyan(J(e.totalTokens))}`),t.push("");let s=Object.entries(e.categories).sort((i,r)=>r[1]-i[1]);if(s.length>0){t.push(l.bold(" Categories"));let i=Math.max(...s.map(([,r])=>r));for(let[r,n]of s){let o=r.padEnd(18),a=String(n).padStart(4);t.push(` ${o} ${a} ${Ut(n,i,20)}`)}t.push("")}if(e.topSkills.length>0){t.push(l.bold(" Top Skills"));for(let i=0;i<e.topSkills.length;i++){let r=e.topSkills[i];t.push(` ${l.dim(`${i+1}.`)} ${l.cyan(r.name)} ${l.dim(`(${r.repo})`)}`)}t.push("")}return t.push(""),t.join(`
|
|
468
|
+
`)}function Gp(e){let t=[];t.push(""),t.push(l.blueBold(" Index Statistics")),t.push(l.dim(" "+"-".repeat(40))),t.push(""),t.push(` ${l.bold("Repos: ")}${l.cyan(String(e.totalRepos))}`),t.push(` ${l.bold("Skills: ")}${l.cyan(String(e.totalSkills))}`),t.push(` ${l.bold("Authors: ")}${l.cyan(String(e.totalAuthors))}`),t.push(` ${l.bold("Verified: ")}${l.cyan(String(e.verifiedCount))}`),t.push(` ${l.bold("Avg Tokens/Skill: ")}${l.cyan(J(e.avgTokensPerSkill))}`),t.push("");let s=Object.entries(e.categoryDistribution).sort((i,r)=>r[1]-i[1]);if(s.length>0){t.push(l.bold(" Category Distribution"));let i=Math.max(...s.map(([,r])=>r));for(let[r,n]of s){let o=r.padEnd(18),a=String(n).padStart(4);t.push(` ${o} ${a} ${Ut(n,i,20)}`)}t.push("")}return t.push(""),t.join(`
|
|
469
|
+
`)}function tl(e,t){let s=`${e??""} ${t??""}`.toLowerCase(),i=[],r={"ai-agents":["agent","llm","claude","gpt","prompt","openai","anthropic","model","skill-creator","mcp","orchestrat"],security:["security","auth","oauth","jwt","ssl","vulnerab","audit","pentest","owasp","encrypt","threat","cso"],devops:["docker","kubernetes","deploy","pipeline","terraform","ansible","github action","pre-commit","devops"],frontend:["ui","ux","css","html","react","vue","svelte","frontend","component","layout","landing page","web artifact","design system"],design:["design","visual","algorithmic art","generative art","canvas","color","logo","brand","theme","figma","typography","illustration"],backend:["api","rest","graphql","database","sql","postgres","redis","server","backend","microservice"],testing:["test","spec","e2e","unit test","coverage","mock","qa","benchmark","playwright"],coding:["code review","refactor","debug","lint","typescript","python","javascript","rust","golang","build","cli","optimizer"],writing:["write","blog","article","documentation","docs","draft","content","copy","proposal","readme","changelog"],mobile:["ios","android","mobile","xcode","swift","kotlin","flutter","app store","testflight","asc"],finance:["finance","trading","stock","crypto","payment","billing","fintech","invest","revenue"],marketing:["seo","aso","marketing","analytics","growth","conversion","affiliate","campaign","social media","reddit","twitter"],git:["git","commit","branch","pull request","pr review","merge"],productivity:["workflow","automation","task","schedule","pdf","xlsx","docx","pptx","spreadsheet","presentation"],research:["research","scholar","paper","academic","peer review","investigation"]};for(let[n,o]of Object.entries(r))for(let a of o)if(zS(s,a)){i.push(n);break}return i.length>0?i:["general"]}function zS(e,t){return t.length<=3?new RegExp(`\\b${t.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`).test(e):e.includes(t)}var XS=new Set(["plugin","codex-plugin"]),QS=40,ZS=2,e$=15,t$=3;function s$(e){let t=e.slice(0,t$).map(i=>`${i.provider}/${i.scope}`),s=e.length-t.length;return s>0?`${t.join(", ")}, +${s} more`:t.join(", ")}function i$(e,t){let s=Hp(e),i=Hp(t);return s===i?!1:i.startsWith(s.endsWith(Jp)?s:s+Jp)}function r$(){return[{id:"expensive-description",label:"Expensive residency",available:!0},{id:"redundant-activation",label:"Redundant activation",available:!0},{id:"trigger-collision",label:"Trigger collision",available:!1,reason:"needs trigger-overlap detection (issue #18)"},{id:"unused",label:"Unused",available:!1,reason:"needs skill usage statistics (issue #354)"}]}function n$(e,t){let s={command:`asm get ${e}`,hint:"read it on demand, zero residency"};if(t.length===1&&t[0].libraryLinked){let i=t[0];if(o$(i.provider))return{kind:"deactivate",command:`asm deactivate ${e} --provider ${i.provider} --scope ${i.scope}`,hint:"keep it in the library, activate when needed",reference:s}}return{kind:"disable",command:`asm disable ${e}`,hint:t.length>1?"reversible with asm enable; disables every ASM-managed copy of this skill name":"reversible with asm enable"}}function o$(e){return ai().providers.some(t=>t.name===e)}function Wp(e,t={}){let s=t.librarySkillsDir??"",i=t.limit??0,r=e.map(p=>tt(p)),n=r.reduce((p,m)=>p+m,0),o=el(r),a=e.filter(p=>!XS.has(p.provider)),c=e.length-a.length,u=new Map;for(let p of a){let m=p.dirName||p.name,y=u.get(m);y?y.push(p):u.set(m,[p])}let f=Math.max(QS,o*ZS),d=[];for(let[p,m]of u){let y=m[0],h=tt(y),g=m.reduce((v,x)=>v+tt(x),0),b=m.reduce((v,x)=>v+Gt(x),0),k=m.map(v=>({provider:v.provider,providerLabel:v.providerLabel||v.provider,scope:v.scope,path:v.path,libraryLinked:v.isSymlink&&s.length>0&&i$(s,v.realPath||v.path)})),S=[];if(h>=f&&h>0){let v=o>0?`${(h/o).toFixed(1)}x the median description`:"well above the rest of the installed set";S.push({id:"expensive-description",detail:`${J(h)} resident \xB7 ${v}`})}k.length>1&&S.push({id:"redundant-activation",detail:`resident in ${k.length} places (${s$(k)}) \xB7 each pays ${J(h)}`}),S.length!==0&&d.push({name:y.name,dirName:p,residentTokens:h,totalResidentTokens:g,bodyTokens:b,score:g,instances:k,reasons:S,action:n$(p,k)})}return d.sort((p,m)=>m.score-p.score||p.name.localeCompare(m.name)),{scannedAt:new Date().toISOString(),totalSkills:e.length,totalResidentTokens:n,medianResidentTokens:o,unmanagedSkills:c,candidates:i>0?d.slice(0,i):d,signals:r$()}}function Yp(e,t=e$){let s=[];if(s.push(""),s.push(l.blueBold(" Residency Audit")),s.push(l.dim(" "+"-".repeat(40))),s.push(""),e.totalSkills===0)return s.push(" No installed skills."),s.push(""),s.join(`
|
|
470
|
+
`);if(s.push(` ${l.bold("Resident total:")} ${l.cyan(J(e.totalResidentTokens))} `+l.dim(`across ${e.totalSkills} skill(s), every message`)),s.push(` ${l.bold("Median skill:")} ${l.cyan(J(e.medianResidentTokens))}`),s.push(""),e.candidates.length===0)s.push(` ${l.green("No demotion candidates.")}`),s.push("");else{let r=t>0?e.candidates.slice(0,t):e.candidates;s.push(l.bold(` Demotion candidates (${e.candidates.length})`)),s.push(l.dim(" Highest resident cost first.")),s.push("");for(let o of r){s.push(` ${l.cyan(o.name)} `+l.dim(`${J(o.totalResidentTokens)} total`));for(let a of o.reasons)s.push(l.dim(` ${a.detail}`));s.push(` ${l.yellow("\u2192")} ${l.bold(o.action.command)}`+l.dim(` (${o.action.hint})`)),o.action.reference&&s.push(` ${l.yellow("\u2192")} ${l.bold(o.action.reference.command)}`+l.dim(` (${o.action.reference.hint})`)),s.push("")}let n=e.candidates.length-r.length;n>0&&(s.push(l.dim(` \u2026 ${n} more not shown \u2014 use --json for the full list`)),s.push(""))}e.unmanagedSkills>0&&(s.push(l.dim(` ${e.unmanagedSkills} plugin-provided skill(s) are counted but not ASM-managed \u2014 no ASM command demotes them.`)),s.push(""));let i=e.signals.filter(r=>!r.available);if(i.length>0){s.push(l.dim(" Signals not yet available:"));for(let r of i)s.push(l.dim(` ${r.label} \u2014 ${r.reason}`));s.push("")}return s.push(l.dim(" Nothing was changed. Run a suggested command to demote.")),s.push(""),s.join(`
|
|
471
|
+
`)}function l$(){console.log(`${l.bold("Usage:")} asm audit [subcommand] [options]
|
|
513
472
|
|
|
514
|
-
|
|
515
|
-
${u.dim("at once (one shared SKILL.md); asm warns and clears state for all siblings.")}
|
|
473
|
+
Detect duplicate skills or run security audits on installed/remote skills.
|
|
516
474
|
|
|
517
|
-
${
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
475
|
+
${l.bold("Subcommands:")}
|
|
476
|
+
duplicates Find duplicate skills (default)
|
|
477
|
+
security <name|source> Run security audit on an installed skill or GitHub source
|
|
478
|
+
residency Rank installed skills that do not earn their resident context
|
|
521
479
|
|
|
522
|
-
${
|
|
523
|
-
--
|
|
524
|
-
|
|
525
|
-
-
|
|
526
|
-
-
|
|
527
|
-
--
|
|
528
|
-
|
|
529
|
-
--no-color Disable ANSI colors
|
|
530
|
-
-V, --verbose Show debug output
|
|
480
|
+
${l.bold("Options:")}
|
|
481
|
+
--json Output as JSON
|
|
482
|
+
--machine Output in stable machine-readable v1 envelope format
|
|
483
|
+
-y, --yes Auto-remove duplicates, keeping one instance per group
|
|
484
|
+
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
485
|
+
--no-color Disable ANSI colors
|
|
486
|
+
-V, --verbose Show debug output
|
|
531
487
|
|
|
532
|
-
${
|
|
533
|
-
asm
|
|
534
|
-
asm
|
|
535
|
-
asm
|
|
536
|
-
asm
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
488
|
+
${l.bold("Examples:")}
|
|
489
|
+
asm audit ${l.dim("Find duplicates")}
|
|
490
|
+
asm audit -y ${l.dim("Auto-remove duplicates")}
|
|
491
|
+
asm audit --json ${l.dim("Output as JSON")}
|
|
492
|
+
asm audit residency ${l.dim("Rank demotion candidates")}
|
|
493
|
+
asm audit residency --json ${l.dim("Residency report as JSON")}
|
|
494
|
+
asm audit security code-review ${l.dim("Audit an installed skill")}
|
|
495
|
+
asm audit security github:user/repo ${l.dim("Audit a remote skill before installing")}
|
|
496
|
+
asm audit security --all ${l.dim("Audit all installed skills")}
|
|
497
|
+
asm audit security code-review --json ${l.dim("Output audit as JSON")}
|
|
498
|
+
asm audit security code-review --machine ${l.dim("Machine-readable v1 envelope output")}
|
|
499
|
+
asm audit security https://github.com/user/skills/tree/main/skills/agent-config
|
|
500
|
+
${l.dim("Audit a skill from a subfolder URL")}`)}async function zp(e){if(e.flags.help){l$();return}let t=performance.now(),s=e.subcommand??"duplicates";if(s==="security"){await u$(e,t);return}if(s==="residency"){await c$(e,t);return}s!=="duplicates"&&($(`Unknown audit subcommand: "${s}". Use: duplicates, security, residency`),process.exit(2));let i=await j(),r=await H(i,"both"),n=pi(r);if(e.flags.machine){let o={duplicate_groups:n.duplicateGroups.map(a=>({name:a.key,count:a.instances.length,instances:a.instances.map(c=>({path:c.path,scope:c.scope,provider:c.provider}))})),total_duplicates:n.duplicateGroups.length};console.log(G("audit duplicates",o,t));return}if(e.flags.json){console.log(Vl(n));return}if(console.log(Ul(n)),e.flags.yes&&n.duplicateGroups.length>0){console.error(l.bold(`
|
|
501
|
+
Auto-removing duplicates...`));for(let o of n.duplicateGroups){let a=Bl(o.instances),c=a[0].path;for(let u=1;u<a.length;u++){let f=a[u],d=_l(f,i),p=await fi(d,c);for(let m of p)console.error(m)}}console.error(l.green(`
|
|
502
|
+
Done.`))}}async function c$(e,t){let s=await j(),i=await H(s,e.flags.scope),r=Me();try{r=await a$(r)}catch{}let n=Wp(i,{librarySkillsDir:r});if(e.flags.machine){console.log(G("audit residency",n,t));return}if(e.flags.json){console.log(U(n));return}console.log(Yp(n))}async function u$(e,t){let s=e.positional[0];e.flags.all?await d$(e,t):s?s.startsWith("github:")||s.startsWith("https://github.com/")?await f$(e,s,t):await p$(e,s,t):(e.flags.machine&&(console.log(z("audit security",Y.INVALID_ARGUMENT,"Missing target. Provide a skill name, GitHub source, or use --all.",t)),process.exit(2)),$(`Missing target. Provide a skill name, GitHub source, or use --all.
|
|
503
|
+
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function d$(e,t){let s=await j(),i=await H(s,e.flags.scope);if(i.length===0){e.flags.machine?console.log(G("audit security",[],t)):e.flags.json?console.log("[]"):console.log("No skills found to audit.");return}let r=new Set,n=i.filter(a=>r.has(a.realPath)?!1:(r.add(a.realPath),!0));console.error(`Auditing ${n.length} skill${n.length>1?"s":""}...
|
|
504
|
+
`);let o=[];for(let a of n){console.error(` Scanning ${l.bold(a.name)}...`);let c=await Ne(a.realPath,a.name);o.push(c)}if(e.flags.machine)console.log(G("audit security",pr(o),t));else if(e.flags.json)console.log(JSON.stringify(o,null,2));else{for(let c of o)console.log(_t(c));let a={safe:0,caution:0,warning:0,dangerous:0};for(let c of o)a[c.verdict]++;console.log(l.bold(`
|
|
505
|
+
Summary:`)),a.dangerous>0&&console.log(` ${l.red(`${a.dangerous} dangerous`)}`),a.warning>0&&console.log(` ${l.yellow(`${a.warning} warning`)}`),a.caution>0&&console.log(` ${a.caution} caution`),a.safe>0&&console.log(` ${l.green(`${a.safe} safe`)}`),console.log("")}}async function f$(e,t,s){let i=null;try{let r=ce(t);if(r.isLocal)throw new Error("Local paths are not supported for remote security audits. Use: asm audit security <installed-skill-name>");he(r,t),await Ce(),r=await ut(r),console.error(`Cloning ${t} for audit...`),i=await Le(r,e.flags.transport);let{join:n}=await import("path"),o=r.subpath?n(i,r.subpath):i;try{Fe(i,o,t)}catch(u){throw await Q(i),i=null,u}let{name:a}=await ye(o),c=await Ne(o,a,r.owner,r.repo);e.flags.machine?console.log(G("audit security",pr([c]),s)):e.flags.json?console.log(la(c)):console.log(_t(c))}catch(r){e.flags.machine&&(console.log(z("audit security",Y.AUDIT_FAILED,r.message,s)),process.exit(1)),$(r.message),process.exit(1)}finally{i&&await Q(i)}}async function p$(e,t,s){let i=await j(),n=(await H(i,e.flags.scope)).filter(c=>c.dirName===t);n.length===0&&(e.flags.machine&&(console.log(z("audit security",Y.SKILL_NOT_FOUND,`Skill "${t}" not found.`,s)),process.exit(1)),$(`Skill "${t}" not found. Use "asm list" to see installed skills.`),process.exit(1));let o=n[0];console.error(`Auditing installed skill: ${l.bold(o.name)}...
|
|
506
|
+
`);let a=await Ne(o.realPath,o.name);e.flags.machine?console.log(G("audit security",pr([a]),s)):e.flags.json?console.log(la(a)):console.log(_t(a))}import{relative as h$}from"path";import{relative as m$}from"path";function Xp(){console.log(`${l.bold("Usage:")} asm install <source> [options]
|
|
545
507
|
|
|
546
508
|
Install a skill from a GitHub repository, the curated registry, or a local path.
|
|
547
509
|
|
|
548
|
-
${
|
|
510
|
+
${l.bold("Cross-tool linking (issue #322):")}
|
|
511
|
+
If the skill is already installed in another tool, ASM offers two options:
|
|
512
|
+
1. Reinstall \u2014 download fresh from the index (gets latest version)
|
|
513
|
+
2. Link \u2014 symlink from the existing install (no download, shares files)
|
|
514
|
+
Skills installed from a local folder always reinstall (link does not apply).
|
|
515
|
+
|
|
516
|
+
${l.bold("Source Format:")}
|
|
549
517
|
code-review Install by name from the curated registry
|
|
550
518
|
author/code-review Install a scoped name (author/name) from registry
|
|
551
519
|
github:owner/repo Install from default branch
|
|
@@ -558,7 +526,7 @@ ${u.bold("Source Format:")}
|
|
|
558
526
|
./relative/path/to/skill Install from a local folder (relative path)
|
|
559
527
|
~/path/to/skill Install from a local folder (home-relative path)
|
|
560
528
|
|
|
561
|
-
${
|
|
529
|
+
${l.bold("Options:")}
|
|
562
530
|
-p, --tool <name> Target tool (claude, codex, openclaw, agents, all)
|
|
563
531
|
Use "all" to install to all tools (shared + symlinks)
|
|
564
532
|
-s, --scope <scope> Installation scope: global or project (default: prompt)
|
|
@@ -568,6 +536,7 @@ ${u.bold("Options:")}
|
|
|
568
536
|
--path <subdir> Install skill from a subdirectory of the repo
|
|
569
537
|
--skill <name> Alias for --path (Vercel skills CLI compatibility)
|
|
570
538
|
--all Install all skills found in the repo
|
|
539
|
+
--library Install into asm's neutral local library
|
|
571
540
|
-m, --method <method> Install method: default or vercel (default: default)
|
|
572
541
|
vercel delegates to npx skills add for tracking
|
|
573
542
|
-t, --transport <mode> Transport: https, ssh, or auto (default: auto)
|
|
@@ -580,195 +549,273 @@ ${u.bold("Options:")}
|
|
|
580
549
|
--no-color Disable ANSI colors
|
|
581
550
|
-V, --verbose Show debug output
|
|
582
551
|
|
|
583
|
-
${
|
|
584
|
-
asm install code-review ${
|
|
585
|
-
asm install luongnv89/code-review ${
|
|
586
|
-
asm install code-review --no-cache ${
|
|
552
|
+
${l.bold("Registry (bare name):")}
|
|
553
|
+
asm install code-review ${l.dim("(resolve from registry)")}
|
|
554
|
+
asm install luongnv89/code-review ${l.dim("(scoped name, no ambiguity)")}
|
|
555
|
+
asm install code-review --no-cache ${l.dim("(force fresh registry fetch)")}
|
|
587
556
|
|
|
588
|
-
${
|
|
589
|
-
asm install ./my-skill ${
|
|
590
|
-
asm install /home/user/skills/my-skill ${
|
|
591
|
-
asm install ~/skills/my-skill ${
|
|
592
|
-
asm install ../other-project/skill ${
|
|
593
|
-
asm install ./skills-dir --all ${
|
|
557
|
+
${l.bold("Local folder:")}
|
|
558
|
+
asm install ./my-skill ${l.dim("(relative path)")}
|
|
559
|
+
asm install /home/user/skills/my-skill ${l.dim("(absolute path)")}
|
|
560
|
+
asm install ~/skills/my-skill ${l.dim("(home-relative path)")}
|
|
561
|
+
asm install ../other-project/skill ${l.dim("(parent-relative path)")}
|
|
562
|
+
asm install ./skills-dir --all ${l.dim("(all skills in directory)")}
|
|
563
|
+
asm install ./skills-dir --library --all -y ${l.dim("(install to local library)")}
|
|
594
564
|
|
|
595
|
-
${
|
|
565
|
+
${l.bold("Single-skill repo:")}
|
|
596
566
|
asm install github:user/my-skill
|
|
597
567
|
asm install github:user/my-skill#v1.0.0 -p claude
|
|
598
568
|
asm install https://github.com/user/my-skill
|
|
599
|
-
asm install github:user/my-skill -p all ${
|
|
600
|
-
asm install github:user/private-skill -t ssh ${
|
|
569
|
+
asm install github:user/my-skill -p all ${l.dim("(install to all tools)")}
|
|
570
|
+
asm install github:user/private-skill -t ssh ${l.dim("(clone via SSH)")}
|
|
601
571
|
|
|
602
|
-
${
|
|
572
|
+
${l.bold("Multi-skill repo:")}
|
|
603
573
|
asm install github:user/skills --path skills/code-review
|
|
604
574
|
asm install github:user/skills --all -p claude -y
|
|
605
|
-
asm install github:user/skills --all -p all -y ${
|
|
575
|
+
asm install github:user/skills --all -p all -y ${l.dim("(all skills, all tools)")}
|
|
606
576
|
asm install https://github.com/user/skills --all
|
|
607
|
-
asm install github:user/skills ${
|
|
577
|
+
asm install github:user/skills ${l.dim("(interactive picker)")}
|
|
608
578
|
|
|
609
|
-
${
|
|
579
|
+
${l.bold("Subfolder URL:")}
|
|
610
580
|
asm install https://github.com/user/skills/tree/main/skills/agent-config
|
|
611
581
|
asm install github:user/skills#main:skills/agent-config
|
|
612
582
|
|
|
613
|
-
${
|
|
583
|
+
${l.bold("Vercel skills CLI:")}
|
|
614
584
|
asm install github:user/skills --method vercel --skill my-skill
|
|
615
585
|
asm install https://github.com/user/skills -m vercel --skill my-skill -y
|
|
616
|
-
${
|
|
617
|
-
${
|
|
618
|
-
${
|
|
619
|
-
${
|
|
620
|
-
${
|
|
621
|
-
${
|
|
622
|
-
${
|
|
623
|
-
Select a skill [1-${
|
|
624
|
-
Did you mean: ${
|
|
625
|
-
`);for(let
|
|
586
|
+
${l.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function Qp(e,t,s,i,r,n,o,a,c="global"){let u=await ye(i),f=await Ns(i),d=i===s?null:i.split(/[/\\]/).pop(),p=r||d||t.repo,m=ge(p),y=a.find(x=>x.name.toLowerCase()===u.name.toLowerCase()&&x.provider===o.name),h,g=null,b=!!y;y?y.version===u.version?h=e.flags.force?"REINSTALL":`UPDATE: ${y.version} (same version)`:h=`UPDATE: ${y.version} \u2192 ${u.version}`:(g=await sa(m,o.name,n),g?h="LINK_AVAILABLE":h="NEW");let k=Os(t,s,i,m,o,e.flags.force||b,c),S=Ts(f),v=S==="high"?l.red("[!] High Risk"):S==="medium"?l.yellow("[~] Medium Risk"):l.green("[ok] Safe");return{metadata:u,skillName:m,warnings:f,installStatus:h,riskLevel:S,riskLabel:v,plan:k,crossToolLink:g??null}}function Zp(e,t,s,i,r,n){let{metadata:o,warnings:a,installStatus:c,riskLabel:u,plan:f,crossToolLink:d}=e;if(r&&n){let p=l.dim(`[${n.index}/${n.total}]`),m=c==="NEW"?l.green(`[${c}]`):l.yellow(`[${c}]`);console.info(`${p} ${l.bold(o.name)} v${o.version} ${m} ${u}`)}else{let p=c==="NEW"?l.green(`[${c}]`):l.yellow(`[${c}]`);if(console.info(` ${l.bold(o.name)} v${o.version} ${p}`),c==="LINK_AVAILABLE"&&d&&console.info(` ${l.dim(`Already installed in ${d.existingProviderLabel}. `)}${l.cyan(`Run with --tool ${s.name} to link, or reinstall for a fresh copy.`)}`),console.info(`
|
|
587
|
+
${l.bold("Install preview:")}`),console.info(` ${l.bold("Name:")} ${o.name}`),console.info(` ${l.bold("Version:")} ${o.version}`),o.description&&console.info(` ${l.bold("Description:")} ${l.dim(o.description)}`),o.effort&&console.info(` ${l.bold("Effort:")} ${gl(o.effort)}`),console.info(` ${l.bold("Source:")} ${t}`),i?(console.info(` ${l.bold("Tool:")} All (${i.map(m=>m.label).join(", ")})`),console.info(` ${l.bold("Primary:")} ${s.label} (${s.name})`),console.info(` ${l.bold("Symlinks:")} ${i.filter(m=>m.name!==s.name).map(m=>m.label).join(", ")}`)):console.info(` ${l.bold("Tool:")} ${s.label} (${s.name})`),console.info(` ${l.bold("Scope:")} ${f.scope==="project"?"Project":"Global"}`),console.info(` ${l.bold("Target:")} ${f.targetDir}`),console.info(` ${l.bold("Status:")} ${p}`),console.info(` ${l.bold("Risk:")} ${u}`),a.length>0){console.info(`
|
|
588
|
+
${l.bold("Security warnings:")}`);let m=new Map;for(let y of a){let h=m.get(y.category)||[];h.push(y),m.set(y.category,h)}for(let[y,h]of m){let b=["Shell commands","Code execution","Credentials"].includes(y)?l.red(`[${y}]`):l.yellow(`[${y}]`);console.info(`
|
|
589
|
+
${b} ${l.dim(`(${h.length} match${h.length>1?"es":""})`)}`);for(let k of h.slice(0,5))console.info(` ${l.dim(`${k.file}:${k.line}`)} -- ${k.match}`);h.length>5&&console.info(l.dim(` ... and ${h.length-5} more`))}}}}async function em(e,t){return t?await Ho(e,t):await Mt(e)}async function tm(e){let{inspection:t,source:s,isLocal:i,resolutionSource:r,commitHash:n,scanBaseDir:o,force:a}=e,c=i?`local:${s.localPath}`:`github:${s.owner}/${s.repo}`,u=i?"local":r==="registry"?"registry":"github",f=ci(m$(o,t.plan.sourceDir)),d=await Ga({sourceDir:t.plan.sourceDir,libraryName:t.skillName,source:c,sourceType:u,commitHash:n||"unknown",ref:s.ref||"main",skillPath:f,force:a});return{success:!0,path:d.libraryPath,name:d.name,version:d.version,provider:"Library",source:c}}async function sl(e){if(e.flags.help){Xp();return}let t=e.flags.machine?me():void 0,s=performance.now(),i=e.flags.force,r=e.subcommand;r||($("Missing required argument: <source>"),console.error('Run "asm install --help" for usage.'),process.exit(2));let n=null,o="github",a=8,c=0,u=d=>(c++,`
|
|
590
|
+
${l.cyan(`[Step ${c}/${a}]`)} ${l.bold(d)}`),f=()=>{n?Q(n).finally(()=>process.exit(1)):process.exit(1)};process.on("SIGINT",f),process.on("SIGTERM",f);try{if(!ct(r)&&await Rs(r)&&(r=`./${r}`),Qe(r)){console.info(`
|
|
591
|
+
${l.cyan("\u25CF")} Resolving "${l.bold(r)}" from registry...`);let{resolved:R,multipleMatches:C,suggestions:_}=await xr(r,{noCache:e.flags.noCache});if(R){o="registry";let T=R.manifest,M=T.repository.replace("https://github.com/","");r=T.skill_path?`github:${M}#${T.commit}:${T.skill_path}`:`github:${M}#${T.commit}`,console.info(` ${l.green("\u2713")} Resolved: ${l.bold(`${T.author}/${T.name}`)} @ ${T.commit.slice(0,7)}`)}else if(C.length>0){console.info(`
|
|
592
|
+
${l.yellow("\u26A0")} Multiple skills found for "${l.bold(r)}":`);let T=C.slice(0,5);for(let Oe=0;Oe<T.length;Oe++){let et=T[Oe];console.info(` ${l.cyan(`${Oe+1}.`)} ${l.bold(`${et.author}/${et.name}`)} \u2014 ${et.description}`)}process.stdin.isTTY||($(`Ambiguous skill name "${r}". Use a scoped name: asm install author/name`),process.exit(2));let M=`
|
|
593
|
+
Select a skill [1-${T.length}]: `;process.stderr.write(M);let te=await new Promise(Oe=>{let et="",si=!1,fh=setTimeout(()=>{si||(si=!0,process.stdin.removeListener("data",Wr),Oe(et.trim()))},3e4);function Wr(ph){et=ph.toString().trim(),si||(si=!0,clearTimeout(fh),process.stdin.removeListener("data",Wr),Oe(et))}process.stdin.setEncoding("utf-8"),process.stdin.on("data",Wr)}),re=parseInt(te,10);(isNaN(re)||re<1||re>T.length)&&($("Invalid selection. Aborting."),process.exit(2));let ue=T[re-1];o="registry";let Kt=ue.repository.replace("https://github.com/","");r=ue.skill_path?`github:${Kt}#${ue.commit}:${ue.skill_path}`:`github:${Kt}#${ue.commit}`,console.info(` ${l.green("\u2713")} Selected: ${l.bold(`${ue.author}/${ue.name}`)} @ ${ue.commit.slice(0,7)}`)}else na(r)?($(`Skill "${r}" not found in the registry.`),_.length>0&&console.error(`
|
|
594
|
+
Did you mean: ${_.map(T=>l.cyan(T)).join(", ")}?`),process.exit(1)):(console.info(` ${l.dim("Not found in registry \u2014 trying existing sources...")}`),o="pre-indexed")}console.info(u("Parsing source"));let d=ce(r);if(!d.isLocal&&(he(d,r),As(e.flags.path)))throw new Error(`Invalid source: the subpath in "${e.flags.path}" escapes the repository.`);let p=!!d.isLocal;if(p){let R=d.localPath;console.info(` ${l.dim(`local: ${R}`)}`);let{stat:C}=await import("fs/promises");try{if(!(await C(R)).isDirectory())throw new Error(`Path is not a directory: ${R}`)}catch(_){throw _.code==="ENOENT"?new Error(`Path does not exist: ${R}`,{cause:_}):_}}else await Ce(),d=await ut(d),console.info(` ${l.dim(r)}`);if(e.flags.library&&e.flags.method==="vercel")throw new Error("--library cannot be combined with --method vercel because the Vercel installer writes to provider skill folders. Use the default method for library installs.");if(e.flags.method==="vercel"){console.info(u("Installing via Vercel skills CLI")),await Qo();let R=ea(d),C=e.flags.path||null;console.info(` ${l.dim(`npx skills add ${R}${C?` --skill ${C}`:""}`)}`);let{stdout:_,stderr:T}=await Zo(R,C);_.trim()&&console.info(` ${l.dim(_.trim())}`),T.trim()&&console.error(` ${l.dim(T.trim())}`),console.info(` ${l.green("\u2713")} Vercel skills CLI install completed`),e.flags.force=!0,console.info(` ${l.dim("Continuing with asm install to register in local inventory...")}`)}let m=await j(),y,h=null,g="global";if(e.flags.library){console.info(u("Selecting library"));let R=m.providers.find(C=>C.enabled)??m.providers[0];if(!R)throw new Error("No providers configured.");y=R,console.info(` ${l.dim(`library: ${Me()}`)}`)}else{console.info(u("Selecting provider"));let R=await be(m,e.flags.provider,!!process.stdin.isTTY);if(y=R.provider,h=R.allProviders,console.info(u("Selecting scope")),e.flags.scope==="global"||e.flags.scope==="project")g=e.flags.scope,console.info(` ${l.dim(`scope: ${g}`)}${g==="global"?` (${y.global})`:` (${y.project})`}`);else if(!process.stdin.isTTY||e.flags.yes)g="global",console.info(` ${l.dim("scope: global (default)")} (${y.global})`);else{let C=[{label:`Global (${y.global})`,hint:"Available in all projects",checked:!0},{label:`Project (${y.project})`,hint:"Available only in this project",checked:!1}];console.info("");let _=await ft({items:C});if(_.length===0)throw new Error("No scope selected. Aborting.");g=_[0]===0?"global":"project",console.info(` Selected: ${l.bold(g)} ${l.dim(`(${g==="global"?y.global:y.project})`)}`)}}if(p)console.info(u("Reading local source")),console.info(` ${l.dim(d.localPath)}`),n=null;else{console.info(u("Cloning repository"));let R=e.flags.transport,C=R==="ssh"?d.sshCloneUrl:R==="https"?d.cloneUrl:`${d.cloneUrl} ${l.dim("(auto)")}`;console.info(` ${C}${d.ref?` ${l.dim(`(ref: ${d.ref})`)}`:""}${d.subpath?` ${l.dim(`(path: ${d.subpath})`)}`:""}`),n=await Le(d,R)}let b=p?d.localPath:n;console.info(u("Scanning for skills"));let{join:k}=await import("path"),S=[],v=e.flags.path||d.subpath,x=[],I=!1,L=b,E="",F=!1;if(v){let R=k(b,v);if(!p)try{Fe(b,R,r)}catch(_){throw n&&(await Q(n),n=null),_}let C=!1;try{await ye(R),C=!0}catch{if(!e.flags.all)throw new Error(`No SKILL.md found at path "${v}" in the repository.`);let{stat:_}=await import("fs/promises");try{if(!(await _(R)).isDirectory())throw new Error(`No SKILL.md found at path "${v}" in the repository.`)}catch(T){throw T&&T.code==="ENOENT"?new Error(`No SKILL.md found at path "${v}" in the repository.`,{cause:T}):T}I=!0,L=R,E=v}C&&(console.info(` Found skill at ${l.bold(v)}`),x=[{skillDir:R,nameOverride:e.flags.name}])}else{try{await ye(b),F=!0}catch{}if(F&&!e.flags.all){let R=await ye(b);console.info(` Found: ${l.bold(R.name)} v${R.version}`),x=[{skillDir:b,nameOverride:e.flags.name}]}else F&&e.flags.all,I=!0}if(I){console.info(E?` No SKILL.md at ${l.bold(E)}. Scanning subdirectories...`:F?" Root SKILL.md found. Scanning for additional skills in subdirectories...":" No SKILL.md at root. Scanning subdirectories...");let R=await dt(L),C=E?R.map(M=>({...M,relPath:`${E}/${M.relPath}`})):R;if(C.length===0)throw new Error(E?`No skills found under path "${E}". Skills must have a SKILL.md file.`:"No skills found in this repository. Skills must have a SKILL.md file.");console.info(` Found ${l.bold(String(C.length))} skill(s):
|
|
595
|
+
`);for(let M=0;M<C.length;M++){let te=l.cyan(` ${String(M+1).padStart(String(C.length).length)})`);console.info(`${te} ${l.bold(C[M].name)} ${l.dim(`v${C[M].version}`)} ${l.dim(`(${C[M].relPath})`)}`),C[M].description&&console.info(` ${l.dim(C[M].description)}`)}console.info(u("Selecting skills")),c--;let _;if(e.flags.all&&(e.flags.yes||!process.stdin.isTTY))_=C.map(M=>M.relPath),console.info(` Selected all ${l.bold(String(_.length))} skills`);else if(process.stdin.isTTY)if(C.length===1)_=[C[0].relPath],console.info(` Auto-selected: ${l.bold(C[0].name)} ${l.dim(`v${C[0].version}`)}`);else{let M=C.map(re=>({label:re.name,hint:`v${re.version}${re.description?" "+re.description:""}`,checked:!!e.flags.all}));console.info("");let te=await ft({items:M});if(te.length===0)throw new Error("No skills selected. Aborting.");_=te.map(re=>C[re].relPath),console.info(` Selected ${l.bold(String(_.length))} skill(s)`)}else{$(`Repository contains ${C.length} skills. Use --path <subdir> to pick one or --all to install all.
|
|
626
596
|
Available skills:
|
|
627
|
-
${
|
|
628
|
-
`)}`),process.exit(2);return}let
|
|
629
|
-
`),
|
|
630
|
-
${
|
|
631
|
-
Choose one path per skill name or install with --path.`);throw
|
|
632
|
-
${
|
|
633
|
-
${
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
${
|
|
597
|
+
${C.map(M=>` --path ${M.relPath}`).join(`
|
|
598
|
+
`)}`),process.exit(2);return}let T=Go(_,M=>M===""?ge(d.repo):kr(M));if(T.length>0){let M=T.map(re=>` - ${re.name}: ${re.paths.map(ue=>`"${ue}"`).join(", ")}`).join(`
|
|
599
|
+
`),te=new Error(`Duplicate skill names detected in selection:
|
|
600
|
+
${M}
|
|
601
|
+
Choose one path per skill name or install with --path.`);throw te.duplicates=T,te}x=_.map(M=>({skillDir:k(b,M),nameOverride:_.length===1?e.flags.name:null})),c++}console.info(u("Inspecting skills"));let O=await H(m,"both"),w=[],P=x.length>1;for(let R=0;R<x.length;R++){let{skillDir:C,nameOverride:_}=x[R],T=await Qp(e,d,b,C,_,m,y,O,g);w.push(T),Zp(T,r,y,h,P,P?{index:R+1,total:x.length}:void 0)}if(P){console.info(""),console.info(` ${l.bold("Install settings:")}`),console.info(` ${l.bold("Source:")} ${r}`),console.info(h?` ${l.bold("Tool:")} All (${h.map(M=>M.label).join(", ")})`:` ${l.bold("Tool:")} ${y.label} (${y.name})`),console.info(` ${l.bold("Scope:")} ${g==="project"?"Project":"Global"}`);let R=w.filter(M=>M.riskLevel==="high").length,C=w.filter(M=>M.riskLevel==="medium").length,_=w.filter(M=>M.riskLevel==="safe").length,T=[];_>0&&T.push(l.green(`${_} Safe`)),C>0&&T.push(l.yellow(`${C} Medium Risk`)),R>0&&T.push(l.red(`${R} High Risk`)),console.info(` ${l.bold("Risk:")} ${T.join(", ")}`)}console.info(u("Installing"));let q=new Map;if(w.some(R=>R.installStatus==="LINK_AVAILABLE"&&R.crossToolLink)&&!e.flags.yes)if(process.stdin.isTTY)for(let R=0;R<w.length;R++){let C=w[R];if(C.installStatus!=="LINK_AVAILABLE"||!C.crossToolLink)continue;let _=C.crossToolLink;console.info(`
|
|
602
|
+
${l.yellow("\u26A0")} ${l.bold(C.metadata.name)} is already installed in ${_.existingProviderLabel}.`),console.info(` Existing: ${l.dim(_.existingPath)}`),console.info(`
|
|
603
|
+
${l.cyan("Option 1")} \u2014 ${l.bold("Reinstall")}: Download fresh from index (gets latest version)`),console.info(` ${l.cyan("Option 2")} \u2014 ${l.bold("Link")}: Symlink from existing install (no download, shares files)`),process.stderr.write(" Choose (1/2): ");let T=await K();T==="2"||T.toLowerCase()==="link"?(q.set(R,"link"),console.info(` ${l.green("\u2713")} Selected: Link from ${_.existingProviderLabel}`)):(q.set(R,"reinstall"),console.info(` ${l.green("\u2713")} Selected: Reinstall from index`))}else for(let R=0;R<w.length;R++)w[R].installStatus==="LINK_AVAILABLE"&&q.set(R,"link");if(!e.flags.yes&&w.some((C,_)=>C.installStatus!=="LINK_AVAILABLE"||q.get(_)==="reinstall")){let C=w.some(te=>te.riskLevel==="high");process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2));let _=P?`${w.length} skills`:`"${w[0].metadata.name}"`,T=C?`
|
|
604
|
+
${l.red("[!]")} ${l.bold(`Install ${_}? Some have high-risk patterns.`)} [y/N] `:`
|
|
605
|
+
${l.bold(`Install ${_}?`)} [Y/n] `;process.stderr.write(T);let M=await K();C?M.toLowerCase()!=="y"&&M.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)):(M.toLowerCase()==="n"||M.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let le=n?await Dl(n):null,$e=[];for(let R=0;R<w.length;R++){let C=w[R],_=P?l.dim(`[${R+1}/${w.length}]`)+" ":" ";if(q.get(R)==="link"&&C.crossToolLink){let T=C.crossToolLink;try{console.info(`${_}Linking ${l.bold(C.metadata.name)} from ${T.existingProviderLabel}...`);let M=await ia(C.skillName,T.existingPath,y.name,g,m,e.flags.force);S.push({success:!0,path:M,name:C.metadata.name,version:C.metadata.version,provider:`Linked from ${T.existingProviderLabel}`,source:`link:${T.existingPath}`}),console.info(`${_}${l.green("\u2713")} ${C.metadata.name} linked to ${l.dim(M)}`);try{await vt(C.metadata.name,{source:`link:${T.existingPath}`,commitHash:"linked",ref:null,installedAt:new Date().toISOString(),provider:y.name,sourceType:"local"})}catch{}}catch(M){$e.push({name:C.metadata.name,error:M.message}),console.error(`${_}${l.red("\u2717")} ${l.bold(C.metadata.name)} \u2014 ${l.red(M.message)}`)}continue}try{console.info(`${_}Installing ${l.bold(C.metadata.name)}...`);let T=e.flags.library?await tm({inspection:C,source:d,isLocal:p,resolutionSource:o,commitHash:le,scanBaseDir:b,force:i}):await em(C.plan,h);if(S.push(T),console.info(`${_}${l.green("\u2713")} ${C.metadata.name} installed to ${l.dim(T.path)}`),!e.flags.library)try{let M=p?`local:${d.localPath}`:`github:${d.owner}/${d.repo}`,te=p?"local":o==="registry"?"registry":"github";await vt(T.name,{source:M,commitHash:le||"unknown",ref:d.ref||"main",installedAt:new Date().toISOString(),provider:C.plan.providerName,scope:C.plan.scope,skillPath:ci(h$(C.plan.tempDir,C.plan.sourceDir)),targetDir:C.plan.targetDir,sourceType:te,...o==="registry"?{registryName:T.name}:{}})}catch{}}catch(T){$e.push({name:C.metadata.name,error:T.message}),console.error(`${_}${l.red("\u2717")} ${l.bold(C.metadata.name)} \u2014 ${l.red(T.message)}`)}}if(process.removeListener("SIGINT",f),process.removeListener("SIGTERM",f),$e.length>0){console.error(`
|
|
606
|
+
${l.yellow(`${$e.length} skill(s) failed to install:`)}`);for(let R of $e)console.error(` ${l.red("\u2717")} ${R.name}: ${R.error}`);e.flags.library&&(process.exitCode=1)}if(e.flags.machine){t?.();let R=S.map(C=>({name:C.name,path:C.path,version:C.version,provider:C.provider,source:C.source,resolution_source:o}));console.log(G("install",R.length===1?R[0]:R,s))}else if(e.flags.json){let R=S.map(C=>({...C,resolutionSource:o}));console.log(JSON.stringify(R.length===1?R[0]:R,null,2))}else S.length===1?console.error(l.green(`
|
|
607
|
+
Done! Installed "${S[0].name}" to ${S[0].path}`)):S.length>0&&console.error(`
|
|
608
|
+
${l.green(`Done! Installed ${S.length} skill(s) successfully.`)}`)}catch(d){if(process.removeListener("SIGINT",f),process.removeListener("SIGTERM",f),e.flags.machine)t?.(),console.log(z("install",Y.INSTALL_FAILED,d.message,s,d?.duplicates?{duplicates:d.duplicates}:void 0));else if(e.flags.json){let p={success:!1,error:d.message};d?.duplicates&&(p.duplicates=d.duplicates),console.log(JSON.stringify(p,null,2))}else $(d.message);process.exit(1)}finally{n&&await Q(n),t?.()}}function g$(){console.log(`${l.bold("Usage:")} asm activate <skill> -p <tool> -s <scope> [options]
|
|
609
|
+
|
|
610
|
+
Link a centrally installed library skill into a provider skill folder.
|
|
611
|
+
|
|
612
|
+
${l.bold("Options:")}
|
|
613
|
+
-p, --tool <name> Provider to activate into (e.g., claude, codex)
|
|
614
|
+
-s, --scope <scope> Activation scope: global or project
|
|
615
|
+
--name <name> Link name to create (default: library directory name)
|
|
616
|
+
-f, --force Replace an existing target
|
|
617
|
+
--json Output as JSON object
|
|
618
|
+
-V, --verbose Show debug output
|
|
619
|
+
|
|
620
|
+
${l.bold("Examples:")}
|
|
621
|
+
asm activate brainstorming -p codex -s project
|
|
622
|
+
asm activate brainstorming -p claude -s global --json`)}function y$(){console.log(`${l.bold("Usage:")} asm deactivate <skill> -p <tool> -s <global|project> [options]
|
|
623
|
+
|
|
624
|
+
Remove a centrally activated library skill from a provider skill folder.
|
|
625
|
+
|
|
626
|
+
${l.bold("Options:")}
|
|
627
|
+
-p, --tool <name> Provider to deactivate from (e.g., claude, codex)
|
|
628
|
+
-s, --scope <scope> Activation scope: global or project
|
|
629
|
+
--json Output as JSON object
|
|
630
|
+
-V, --verbose Show debug output
|
|
631
|
+
|
|
632
|
+
${l.bold("Examples:")}
|
|
633
|
+
asm deactivate brainstorming -p codex -s project
|
|
634
|
+
asm deactivate brainstorming -p claude -s global --json`)}async function sm(e){if(e.flags.help){g$();return}let t=e.subcommand;t||($("Missing skill name. Use: asm activate <skill>"),console.error('Run "asm activate --help" for usage.'),process.exit(2)),e.flags.scope==="both"&&($("Activation requires --scope global or --scope project."),process.exit(2));let s=await gt(),i=Hs(s,t);i||($(`Library skill "${t}" not found. Run "asm library list".`),process.exit(1)),i.missing&&($(`Library skill "${t}" is missing on disk: ${i.libraryPath}`),process.exit(1));let r=await j(),{provider:n}=await be(r,e.flags.provider,process.stdin.isTTY),o=e.flags.scope==="global"?n.global:n.project,a=se(o),c=e.flags.name||i.dirName,u=await Va({libraryPath:i.libraryPath,targetDir:a,activationName:c,force:e.flags.force}),f={name:c,skill:i.dirName,provider:n.name,scope:e.flags.scope,path:u.symlinkPath,target:u.targetPath};if(e.flags.json){console.log(JSON.stringify(f,null,2));return}console.log(`${l.green("\u2713")} activated ${c} (${n.name}/${e.flags.scope}) -> ${u.targetPath}`)}async function im(e){if(e.flags.help){y$();return}let t=e.subcommand;t||($("Missing skill name. Use: asm deactivate <skill>"),console.error('Run "asm deactivate --help" for usage.'),process.exit(2)),e.flags.scope==="both"&&($("Deactivation requires --scope global or --scope project."),process.exit(2));let s=await j(),i;try{i=(await be(s,e.flags.provider,process.stdin.isTTY)).provider}catch(r){let n=r instanceof Error?r.message:String(r);$(n),process.exit(2)}try{let r=e.flags.scope==="global"?i.global:i.project,n=se(r),o=await Ua({targetDir:n,activationName:t,provider:i.name,scope:e.flags.scope});if(e.flags.json){console.log(JSON.stringify(o,null,2));return}console.log(`${l.green("\u2713")} deactivated ${o.name} (${o.provider}/${o.scope}) -> ${o.target}`)}catch(r){let n=r instanceof Error?r.message:String(r);e.flags.json&&(console.log(JSON.stringify({error:n},null,2)),process.exit(1)),$(n),process.exit(1)}}function b$(){console.log(`${l.bold("Usage:")} asm library <subcommand> [options]
|
|
635
|
+
|
|
636
|
+
Manage centrally installed library skills.
|
|
637
|
+
|
|
638
|
+
${l.bold("Subcommands:")}
|
|
639
|
+
list List skills installed in the local library
|
|
640
|
+
update <skill> Update one local library skill
|
|
641
|
+
update --all Update all local library skills
|
|
642
|
+
|
|
643
|
+
${l.bold("Options:")}
|
|
644
|
+
--json Output as JSON
|
|
645
|
+
-V, --verbose Show debug output
|
|
646
|
+
|
|
647
|
+
${l.bold("Examples:")}
|
|
648
|
+
asm library list ${l.dim("List local library skills")}
|
|
649
|
+
asm library update brainstorming ${l.dim("Update one local library skill")}
|
|
650
|
+
asm library update --all --json ${l.dim("Update all and output as JSON")}`)}async function rm(e){if(e.flags.help){b$();return}if(e.subcommand==="update"){await v$(e);return}if(e.subcommand==="list"){let t=await gt();if(e.flags.json){console.log(JSON.stringify(t,null,2));return}w$(t);return}$("Missing or unknown library subcommand. Use: asm library list or asm library update"),console.error('Run "asm library --help" for usage.'),process.exit(2)}function w$(e){if(e.length===0){console.log(l.dim("No skills installed in the local library."));return}let t={name:Math.max(4,...e.map(r=>r.name.length)),version:Math.max(7,...e.map(r=>r.version.length)),source:Math.max(6,...e.map(r=>r.source.length)),path:Math.max(4,...e.map(r=>r.skillPath.length)),status:6},s=(r,n,o,a,c)=>[r.padEnd(t.name),n.padEnd(t.version),o.padEnd(t.source),a.padEnd(t.path),c.padEnd(t.status)].join(" "),i=[l.bold(s("Name","Version","Source","Path","Status")),...e.map(r=>s(r.name,r.version,r.source,r.skillPath,r.missing?"missing":"ok"))];console.log(i.join(`
|
|
651
|
+
`))}function k$(e){for(let t of e.results)t.status==="updated"?console.log(`${l.green("\u2713")} ${t.name}: ${t.oldVersion??"unknown"} -> ${t.newVersion??"unknown"}`):t.status==="skipped"?console.log(`${l.yellow("-")} ${t.name}: ${t.reason??"skipped"}`):console.log(`${l.red("x")} ${t.name}: ${t.reason??"failed"}`);console.log(`${e.updatedCount} updated, ${e.skippedCount} skipped, ${e.failedCount} failed`)}async function v$(e){let t=[...e.positional];!e.flags.all&&t.length===0&&($("Missing skill name. Use: asm library update <skill> or asm library update --all"),process.exit(2)),e.flags.all&&t.length>0&&($("Use either asm library update <skill> or asm library update --all, not both."),process.exit(2));let s=await Ja(e.flags.all?null:t);e.flags.json?console.log(JSON.stringify(s,null,2)):k$(s),s.failedCount>0&&process.exit(1)}function S$(){console.log(`${l.bold("Usage:")} asm config <subcommand>
|
|
652
|
+
|
|
653
|
+
Manage configuration. Config is stored at ~/.config/agent-skill-manager/.
|
|
654
|
+
|
|
655
|
+
${l.bold("Subcommands:")}
|
|
656
|
+
show Print current config as JSON
|
|
657
|
+
path Print config file path
|
|
658
|
+
reset Reset config to defaults (with confirmation)
|
|
659
|
+
edit Open config in $EDITOR
|
|
660
|
+
|
|
661
|
+
${l.bold("Options:")}
|
|
662
|
+
-V, --verbose Show debug output
|
|
663
|
+
|
|
664
|
+
${l.bold("Examples:")}
|
|
665
|
+
asm config show ${l.dim("View current config")}
|
|
666
|
+
asm config edit ${l.dim("Edit in $EDITOR")}
|
|
667
|
+
asm config reset -y ${l.dim("Reset without confirmation")}`)}async function nm(e){if(e.flags.help){S$();return}let t=e.subcommand;switch(t||($("Missing subcommand. Use: show, path, reset, or edit."),console.error('Run "asm config --help" for usage.'),process.exit(2)),t){case"show":{let s=await j();console.log(U(s));break}case"path":{console.log(Wt());break}case"reset":{if(!e.flags.yes){process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2)),process.stderr.write(`${l.bold("Reset config to defaults?")} [y/N] `);let i=await K();i.toLowerCase()!=="y"&&i.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let s=ai();await Il(s),console.error(l.green("Config reset to defaults."));break}case"edit":{let s=process.env.VISUAL||process.env.EDITOR||"vi",[i,r]=Kl(s),n=Wt();await j();let{spawn:o}=await import("child_process");await new Promise((a,c)=>{let u=o(i,[...r,n],{stdio:"inherit"});u.on("close",()=>a()),u.on("error",c)});break}default:$(`Unknown config subcommand: "${t}". Use: show, path, reset, or edit.`),process.exit(2)}}function om(e){let t=e.filter(s=>s.provider!=="plugin").map(s=>({name:s.name,version:s.version,dirName:s.dirName,provider:s.provider,scope:s.scope,path:s.path,isSymlink:s.isSymlink,symlinkTarget:s.symlinkTarget,effort:s.effort}));return{version:1,exportedAt:new Date().toISOString(),skills:t}}import{readFile as Ys,readdir as $$,access as mm,mkdir as x$,cp as il,rm as am,rename as lm,realpath as rl,stat as nl}from"fs/promises";import{join as ol,basename as E$,resolve as cm}from"path";function P$(e){let t=[];if(typeof e!="object"||e===null||Array.isArray(e))return{valid:!1,errors:["Manifest must be a JSON object."]};let s=e;if(s.version!==1&&t.push(`Unsupported manifest version: ${JSON.stringify(s.version)}. Expected 1.`),typeof s.exportedAt!="string"&&t.push("Missing or invalid 'exportedAt' field."),!Array.isArray(s.skills))return t.push("Missing or invalid 'skills' array."),{valid:!1,errors:t};for(let i=0;i<s.skills.length;i++){let r=s.skills[i];if(typeof r!="object"||r===null){t.push(`skills[${i}]: must be an object.`);continue}let n=r;(typeof n.name!="string"||!n.name)&&t.push(`skills[${i}]: missing or empty 'name'.`),(typeof n.dirName!="string"||!n.dirName)&&t.push(`skills[${i}]: missing or empty 'dirName'.`),(typeof n.provider!="string"||!n.provider)&&t.push(`skills[${i}]: missing or empty 'provider'.`),n.scope!=="global"&&n.scope!=="project"&&t.push(`skills[${i}]: invalid 'scope' "${String(n.scope)}". Must be "global" or "project".`)}return{valid:t.length===0,errors:t}}async function hm(e){let t;try{t=await Ys(e,"utf-8")}catch(r){throw r?.code==="ENOENT"?new Error(`Manifest file not found: ${e}`,{cause:r}):new Error(`Failed to read manifest file: ${r.message}`,{cause:r})}let s;try{s=JSON.parse(t)}catch{throw new Error("Manifest file is not valid JSON.")}let i=P$(s);if(!i.valid)throw new Error(`Invalid manifest:
|
|
668
|
+
${i.errors.join(`
|
|
669
|
+
`)}`);return s}async function I$(e){try{return await mm(e),!0}catch{return!1}}async function um(e,t){let s,i;try{[s,i]=await Promise.all([rl(e),rl(t)])}catch{s=cm(e),i=cm(t)}return process.platform==="win32"?s.toLowerCase()===i.toLowerCase():s===i}async function zs(e){let t=new Map,s=new Set;async function i(r,n){let o=await rl(r),a=process.platform==="win32"?o.toLowerCase():o;if(s.has(a))return;s.add(a);let c=await $$(r,{withFileTypes:!0});for(let u of c){if(u.name===".git")continue;let f=n?`${n}/${u.name}`:u.name,d=ol(r,u.name);if(u.isDirectory())await i(d,f);else if(u.isFile())t.set(f,d);else try{(await nl(d)).isDirectory()?await i(d,f):t.set(f,d)}catch{t.set(f,d)}}s.delete(a)}return await i(e,""),t}async function C$(e,t){try{let[s,i]=await Promise.all([zs(e),zs(t)]);if(s.size!==i.size)return!1;for(let[r,n]of s){let o=i.get(r);if(!o)return!1;let[a,c]=await Promise.all([Ys(n),Ys(o)]);if(!a.equals(c))return!1}return!0}catch{return!1}}async function dm(e){try{let t=await zs(e),s=0;for(let i of t.values())try{let r=await nl(i);r.mtimeMs>s&&(s=r.mtimeMs)}catch{}return s===0&&(s=(await nl(e)).mtimeMs),s}catch{return 0}}async function L$(e,t,s){let[i,r]=await Promise.all([dm(s),dm(t)]),o=i===0||r===0||Math.abs(i-r)<=2e3?"same":i>r?"local":"imported";return{skillName:e.name,provider:e.provider,scope:e.scope,targetDir:s,sourcePath:t,localModified:new Date(i).toISOString(),importedModified:new Date(r).toISOString(),newer:o}}async function al(e){let[t,s]=await Promise.all([zs(e.targetDir),zs(e.sourcePath)]),i=Array.from(new Set([...t.keys(),...s.keys()])).sort(),r=[];for(let n of i){let o=t.get(n),a=s.get(n);if(!a){r.push(`only in local: ${n}`);continue}if(!o){r.push(`only in imported: ${n}`);continue}let c=n.includes(".")?`.${n.split(".").pop().toLowerCase()}`:"";try{let[u,f]=await Promise.all([Ys(o),Ys(a)]);if(u.equals(f))continue;if(Rl.has(c)){r.push(`differs (binary): ${n}`);continue}if(u.length>tn||f.length>tn){r.push(`differs (too large to diff): ${n}`);continue}let d=Lr(u.toString("utf-8"),f.toString("utf-8"),n);d&&r.push(d)}catch{r.push(`differs (unreadable): ${n}`)}}return r.join(`
|
|
670
|
+
`)}async function fm(e,t){let s=`${e}.import-backup-${Date.now()}`;await lm(e,s);try{await t(),await am(s,{recursive:!0,force:!0})}catch(i){try{await am(e,{recursive:!0,force:!0}),await lm(s,e)}catch{}throw i}}function A$(e,t){return e.providers.find(s=>s.name===t&&s.enabled)}function R$(e,t,s,i){let r=A$(e,t);if(!r)return null;let n=s==="global"?r.global:r.project,o=se(n),a=E$(i);return!a||a==="."||a===".."?null:ol(o,a)}function pm(e,t){let s=e.find(i=>i.dirName===t.dirName&&i.provider===t.provider);return s||e.find(i=>i.dirName===t.dirName)||null}async function gm(e,t,s){let i=s?.config??await j(),r=s?.installedSkills??await H(i,"both"),n=[];for(let f of e.skills){if(t.scopeFilter!=="both"&&f.scope!==t.scopeFilter){A(`import: skipping "${f.name}" \u2014 scope "${f.scope}" filtered out`);continue}let d=R$(i,f.provider,f.scope,f.dirName);if(!d){n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"failed",reason:`Provider "${f.provider}" not found or not enabled.`});continue}let p=await I$(d);if(p&&!t.force&&!t.dryRun){let y=pm(r,f);if(!y||await um(y.realPath,d)||await C$(y.realPath,d)){n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"skipped",reason:"Already installed.",path:d});continue}let h=await L$(f,y.realPath,d),g=t.onConflict?await t.onConflict(h):"skip";if(g==="use-imported")try{await fm(d,()=>il(y.realPath,d,{recursive:!0})),A(`import: conflict resolved, copied "${f.name}" from ${y.realPath} to ${d}`),n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"installed",reason:"Conflict resolved: used imported version.",path:d,conflict:h})}catch(b){n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"failed",reason:`Copy failed: ${b.message}`,conflict:h})}else{let b=g==="keep-local"?"Conflict: kept local version.":t.onConflict?"Conflict: skipped.":h.newer==="local"?"Conflict: local version is newer. Use --force to overwrite.":h.newer==="imported"?"Conflict: imported version is newer. Use --force to overwrite.":"Conflict: contents differ. Use --force to overwrite.";n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"skipped",reason:b,path:d,conflict:h})}continue}if(p&&!t.force){n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"skipped",reason:"Already installed.",path:d});continue}if(t.dryRun){n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"dry-run",reason:p?"Would overwrite (--force).":"Would install.",path:d});continue}let m=pm(r,f);if(!m){n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"failed",reason:"No installed source found. Install the skill first with: asm install <source>"});continue}if(p&&await um(m.realPath,d)){n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"skipped",reason:"Already installed.",path:d});continue}try{await x$(ol(d,".."),{recursive:!0});let y=async()=>{if(f.isSymlink&&f.symlinkTarget)try{await mm(f.symlinkTarget),await qe(f.symlinkTarget,d),A(`import: symlinked "${f.name}" -> ${f.symlinkTarget} at ${d}`)}catch{await il(m.realPath,d,{recursive:!0}),A(`import: symlink target unreachable, copied "${f.name}" from ${m.realPath} to ${d}`)}else await il(m.realPath,d,{recursive:!0}),A(`import: copied "${f.name}" from ${m.realPath} to ${d}`)};p?await fm(d,y):await y(),n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"installed",path:d})}catch(y){n.push({skillName:f.name,provider:f.provider,scope:f.scope,status:"failed",reason:`Copy failed: ${y.message}`})}}let o=n.filter(f=>f.status==="installed").length,a=n.filter(f=>f.status==="skipped").length,c=n.filter(f=>f.status==="failed").length,u=n.filter(f=>f.conflict!==void 0).length;return{total:n.length,installed:o,skipped:a,failed:c,conflicts:u,results:n}}function N$(){console.log(`${l.bold("Usage:")} asm export [options]
|
|
637
671
|
|
|
638
672
|
Export skill inventory as a portable JSON manifest. Useful for backup,
|
|
639
673
|
sharing, or scripting.
|
|
640
674
|
|
|
641
|
-
${
|
|
675
|
+
${l.bold("Options:")}
|
|
642
676
|
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
643
677
|
--no-color Disable ANSI colors
|
|
644
678
|
-V, --verbose Show debug output
|
|
645
679
|
|
|
646
|
-
${
|
|
647
|
-
asm export ${
|
|
648
|
-
asm export -s global ${
|
|
649
|
-
asm export > skills.json ${
|
|
680
|
+
${l.bold("Examples:")}
|
|
681
|
+
asm export ${l.dim("Export all skills")}
|
|
682
|
+
asm export -s global ${l.dim("Export global skills only")}
|
|
683
|
+
asm export > skills.json ${l.dim("Save to file")}`)}async function ym(e){if(e.flags.help){N$();return}let t=await j(),s=await H(t,e.flags.scope),i=om(s);console.log(JSON.stringify(i,null,2))}function T$(){console.log(`${l.bold("Usage:")} asm import <file> [options]
|
|
650
684
|
|
|
651
685
|
Import skills from a previously exported JSON manifest. Recreates skill
|
|
652
686
|
installations based on the manifest metadata.
|
|
653
687
|
|
|
654
|
-
Skills that already exist
|
|
655
|
-
|
|
656
|
-
|
|
688
|
+
Skills that already exist with identical content are skipped. When an
|
|
689
|
+
existing skill differs from the imported version, the conflict is reported
|
|
690
|
+
with which side is newer; in a terminal you can resolve each conflict
|
|
691
|
+
(keep local, use imported, or skip), optionally viewing a diff. --force
|
|
692
|
+
overwrites all conflicts without asking. Skills whose source files cannot
|
|
693
|
+
be found locally are reported as failed \u2014 install them first with
|
|
694
|
+
"asm install".
|
|
657
695
|
|
|
658
|
-
${
|
|
696
|
+
${l.bold("Options:")}
|
|
659
697
|
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
660
|
-
-f, --force Overwrite existing skills
|
|
661
|
-
|
|
662
|
-
--
|
|
698
|
+
-f, --force Overwrite existing skills without conflict prompts
|
|
699
|
+
--diff Show unified diffs (cannot be combined with --force)
|
|
700
|
+
-y, --yes Skip prompts (conflicts are skipped and reported)
|
|
701
|
+
--json Output results as JSON (includes conflict details)
|
|
663
702
|
--no-color Disable ANSI colors
|
|
664
703
|
-V, --verbose Show debug output
|
|
665
704
|
|
|
666
|
-
${
|
|
667
|
-
asm import skills.json ${
|
|
668
|
-
asm import skills.json --
|
|
669
|
-
asm import skills.json
|
|
670
|
-
asm
|
|
671
|
-
asm
|
|
672
|
-
${
|
|
673
|
-
|
|
705
|
+
${l.bold("Examples:")}
|
|
706
|
+
asm import skills.json ${l.dim("Import from manifest")}
|
|
707
|
+
asm import skills.json --diff ${l.dim("Show diffs for conflicting skills")}
|
|
708
|
+
asm import skills.json --force ${l.dim("Overwrite existing skills")}
|
|
709
|
+
asm import skills.json -s global ${l.dim("Import only global skills")}
|
|
710
|
+
asm export > backup.json ${l.dim("Export first, then import later")}
|
|
711
|
+
asm import backup.json ${l.dim("Restore from backup")}`)}async function bm(e,t={}){let{showDiff:s=!1,readAnswer:i=K,renderDiff:r=al,writeLine:n=console.error,writePrompt:o=u=>process.stderr.write(u)}=t,a=u=>e.newer===u?` ${l.green("(newer)")}`:e.newer==="same"?"":` ${l.dim("(older)")}`;n(""),n(`${l.bold("Conflict:")} ${e.skillName} (${e.provider}/${e.scope})`),n(` local: ${e.localModified}${a("local")}`),n(` imported: ${e.importedModified}${a("imported")}`);let c=!1;if(s){let u=await r(e);n(u?`
|
|
712
|
+
${u}
|
|
713
|
+
`:" (no textual differences found)"),c=!0}for(;;){o(` [k] keep local [u] use imported [s] skip${c?"":" [d] show diff"} ${l.dim("[s]")} `);let u=(await i()).trim().toLowerCase();if(u==="k"||u==="keep")return"keep-local";if(u==="u"||u==="use")return"use-imported";if(u===""||u==="s"||u==="skip")return"skip";if(u==="d"||u==="diff"){let f=await r(e);n(f?`
|
|
714
|
+
${f}
|
|
715
|
+
`:" (no textual differences found)"),c=!0}}}async function wm(e,t=al,s=console.error){for(let i of e){if(!i.conflict)continue;let r=await t(i.conflict);s(`
|
|
716
|
+
${l.bold(`Conflict diff: ${i.skillName} (${i.provider}/${i.scope})`)} ${l.dim("local -> imported")}`),s(r||" (no textual differences found)")}}async function km(e){if(e.flags.help){T$();return}let t=e.subcommand;t||($("Missing required argument: <file>"),console.error('Run "asm import --help" for usage.'),process.exit(2)),e.flags.force&&e.flags.diff&&($("--force and --diff cannot be used together. Run without --force to inspect conflicts, or omit --diff to overwrite them."),process.exit(2));let{resolve:s}=await import("path"),i=s(t),r;try{r=await hm(i)}catch(d){$(d.message),process.exit(1)}let n=r.skills.length;if(n===0){e.flags.json?console.log(JSON.stringify({total:0,installed:0,skipped:0,failed:0,conflicts:0,results:[]},null,2)):console.log("Manifest contains no skills. Nothing to import.");return}let o=e.flags.scope==="both"?"all scopes":e.flags.scope;if(console.error(`${l.bold("Importing")} ${n} skill${n>1?"s":""} from ${l.dim(i)}`),console.error(` Scope filter: ${o}`),e.flags.force&&console.error(` ${l.yellow("Force mode: existing skills will be overwritten")}`),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
717
|
+
${l.bold("Proceed?")} [y/N] `);let d=await K();d.toLowerCase()!=="y"&&d.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=!e.flags.force&&!e.flags.yes&&!!process.stdin.isTTY,c=e.flags.diff,u=await gm(r,{force:e.flags.force,dryRun:!1,scopeFilter:e.flags.scope,onConflict:a?d=>bm(d,{showDiff:c}):void 0});if(c&&!a&&await wm(u.results),e.flags.json){console.log(JSON.stringify(u,null,2));return}if(u.total===0){console.error(`
|
|
718
|
+
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let d of u.results){let p=d.status==="installed"?l.green("+++"):d.status==="skipped"?l.yellow("---"):d.status==="dry-run"?l.cyan("~~~"):l.red("!!!"),m=d.reason?` ${l.dim(d.reason)}`:"",y=d.path?` ${l.dim(d.path)}`:"";console.error(` ${p} ${d.skillName} (${d.provider}/${d.scope})${m}${y}`)}console.error("");let f=u.conflicts>0?`, ${l.yellow(String(u.conflicts))} conflicts`:"";console.error(`${l.bold("Summary:")} ${u.total} total, ${l.green(String(u.installed))} installed, ${l.yellow(String(u.skipped))} skipped, ${l.red(String(u.failed))} failed${f}`),u.conflicts>0&&!a&&!e.flags.force&&console.error(l.dim("Conflicts were skipped. Re-run in a terminal to resolve each one, add --diff to inspect, or --force to overwrite all.")),u.failed>0&&(process.exitCode=1)}import{mkdir as O$,writeFile as M$,access as D$}from"fs/promises";import{join as _$}from"path";function F$(e){return`---
|
|
719
|
+
name: ${e}
|
|
720
|
+
description: ""
|
|
721
|
+
license: ""
|
|
722
|
+
metadata:
|
|
723
|
+
version: 0.1.0
|
|
724
|
+
creator: ""
|
|
725
|
+
---
|
|
726
|
+
|
|
727
|
+
# ${e}
|
|
728
|
+
|
|
729
|
+
Describe what this skill does here. This content will be loaded by the AI agent
|
|
730
|
+
as instructions for when and how to use this skill.
|
|
731
|
+
|
|
732
|
+
## When to Use
|
|
733
|
+
|
|
734
|
+
- Describe the trigger conditions for this skill
|
|
735
|
+
|
|
736
|
+
## Instructions
|
|
737
|
+
|
|
738
|
+
- Step-by-step instructions for the agent
|
|
739
|
+
`}async function vm(e,t){await O$(t,{recursive:!0});let s=_$(t,"SKILL.md"),i=F$(e);await M$(s,i,"utf-8")}async function Sm(e){try{return await D$(e),!0}catch{return!1}}function j$(){console.log(`${l.bold("Usage:")} asm init <name> [options]
|
|
674
740
|
|
|
675
741
|
Scaffold a new skill directory with a SKILL.md template. Creates a
|
|
676
742
|
ready-to-edit skill in the target tool's skill folder.
|
|
677
743
|
|
|
678
|
-
${
|
|
744
|
+
${l.bold("Options:")}
|
|
679
745
|
-p, --tool <name> Target tool (claude, codex, openclaw, agents)
|
|
680
746
|
--path <dir> Scaffold in specified directory instead of provider path
|
|
681
747
|
-f, --force Overwrite if skill already exists
|
|
682
748
|
--no-color Disable ANSI colors
|
|
683
749
|
-V, --verbose Show debug output
|
|
684
750
|
|
|
685
|
-
${
|
|
686
|
-
asm init my-skill ${
|
|
687
|
-
asm init my-skill -p claude ${
|
|
688
|
-
asm init my-skill --path ./skills ${
|
|
689
|
-
${
|
|
751
|
+
${l.bold("Examples:")}
|
|
752
|
+
asm init my-skill ${l.dim("Scaffold (interactive tool)")}
|
|
753
|
+
asm init my-skill -p claude ${l.dim("Scaffold in Claude Code")}
|
|
754
|
+
asm init my-skill --path ./skills ${l.dim("Scaffold in custom directory")}`)}async function $m(e){if(e.flags.help){j$();return}let t=e.subcommand;t||($("Missing required argument: <name>"),console.error('Run "asm init --help" for usage.'),process.exit(2));let s=ge(t),i;if(e.flags.path){let{resolve:r}=await import("path");i=r(e.flags.path)}else{let r=await j(),{provider:n}=await be(r,e.flags.provider,!!process.stdin.isTTY),{join:o}=await import("path"),{resolveProviderPath:a}=await import("./config-AZYQEQOQ.js"),c=a(r.providers.find(u=>u.name===n.name).global);i=o(c,s)}if(await Sm(i)&&!e.flags.force){process.stdin.isTTY||($(`Directory already exists: ${i}. Use --force to overwrite.`),process.exit(2)),process.stderr.write(`${l.yellow(`Directory already exists: ${i}`)}
|
|
755
|
+
${l.bold("Overwrite?")} [y/N] `);let r=await K();r.toLowerCase()!=="y"&&r.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await vm(s,i),console.error(l.green(`Done! Created skill "${s}" at ${i}`))}function q$(){console.log(`${l.bold("Usage:")} asm stats [subcommand] [options]
|
|
690
756
|
|
|
691
757
|
Show aggregate skill metrics with provider distribution charts,
|
|
692
|
-
scope breakdown, disk usage, and duplicate summary.
|
|
758
|
+
scope breakdown, disk usage, resident context cost, and duplicate summary.
|
|
759
|
+
|
|
760
|
+
${l.bold("Subcommands:")}
|
|
761
|
+
repo <owner/repo> Show per-repo stats from the skill index
|
|
762
|
+
author <owner> Show per-author stats from the skill index
|
|
763
|
+
index Show index-wide statistics
|
|
693
764
|
|
|
694
|
-
${
|
|
765
|
+
${l.bold("Options:")}
|
|
766
|
+
--tokens Attention budget: resident vs body tokens per tool/scope
|
|
695
767
|
--json Output as JSON
|
|
768
|
+
--machine Output in stable machine-readable v1 envelope format
|
|
696
769
|
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
697
770
|
--no-color Disable ANSI colors
|
|
698
771
|
-V, --verbose Show debug output
|
|
699
772
|
|
|
700
|
-
${
|
|
701
|
-
asm stats ${
|
|
702
|
-
asm stats
|
|
703
|
-
asm stats --json
|
|
773
|
+
${l.bold("Examples:")}
|
|
774
|
+
asm stats ${l.dim("Show installed skills dashboard")}
|
|
775
|
+
asm stats --tokens ${l.dim("Resident context cost per tool")}
|
|
776
|
+
asm stats --tokens --json ${l.dim("Attention budget as JSON")}
|
|
777
|
+
asm stats -s global ${l.dim("Global skills only")}
|
|
778
|
+
asm stats --json ${l.dim("Output raw data as JSON")}
|
|
779
|
+
asm stats --machine ${l.dim("Machine-readable v1 envelope output")}
|
|
780
|
+
asm stats repo anthropics/skills ${l.dim("Show indexed repo stats")}
|
|
781
|
+
asm stats author luongnv89 ${l.dim("Show indexed author stats")}
|
|
782
|
+
asm stats index ${l.dim("Show index-wide stats")}`)}async function xm(e){if(e.flags.help){q$();return}let t=e.subcommand;if(t==="repo"){await U$(e);return}if(t==="author"){await K$(e);return}if(t==="index"){await H$(e);return}let s=performance.now(),i=await j(),r=await H(i,e.flags.scope);if(e.flags.tokens){let a=Fp(r);if(e.flags.machine){console.log(G("stats tokens",a,s));return}if(e.flags.json){console.log(U(a));return}console.log(jp(a));return}if(r.length===0&&!e.flags.json&&!e.flags.machine){console.log(" No installed skills.");return}let n=pi(r),o=await Dp(r,n);if(e.flags.machine){let{perSkillDiskBytes:a,...c}=o;console.log(G("stats",e.flags.verbose?o:c,s));return}if(e.flags.json)if(e.flags.verbose)console.log(U(o));else{let{perSkillDiskBytes:a,...c}=o;console.log(U(c))}else console.log(_p(o))}function B$(){console.log(`${l.bold("Usage:")} asm stats repo <owner/repo> [options]
|
|
704
783
|
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
784
|
+
Show statistics for a specific indexed repository.
|
|
785
|
+
|
|
786
|
+
${l.bold("Arguments:")}
|
|
787
|
+
owner/repo Repository identifier (e.g. anthropics/skills)
|
|
708
788
|
|
|
709
|
-
${
|
|
789
|
+
${l.bold("Options:")}
|
|
710
790
|
--json Output as JSON
|
|
711
|
-
--machine Output in stable machine-readable v1 envelope format
|
|
712
791
|
--no-color Disable ANSI colors
|
|
713
|
-
-V, --verbose Show debug output
|
|
714
|
-
|
|
715
|
-
${u.bold("Examples:")}
|
|
716
|
-
asm doctor ${u.dim("Run all health checks")}
|
|
717
|
-
asm doctor --json ${u.dim("Output as JSON")}
|
|
718
|
-
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function Tk(e){if(e.flags.help){Ok();return}let t=performance.now(),s=await ld();if(e.flags.machine){let i={checks:s.checks.map(n=>({name:n.name,status:n.status,message:n.message,...n.fix?{fix:n.fix}:{}})),passed:s.passed,warnings:s.warnings,failures:s.failures};console.log(X("doctor",i,t))}else e.flags.json?console.log(ud(s)):console.log(cd(s));s.failures>0&&process.exit(1)}function Mk(){console.log(`${u.bold("Usage:")} asm eval <target> [options]
|
|
719
792
|
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
context efficiency, safety, testability, and naming conventions.
|
|
793
|
+
${l.bold("Examples:")}
|
|
794
|
+
asm stats repo anthropics/skills
|
|
795
|
+
asm stats repo luongnv89/asm --json`)}async function U$(e){if(e.flags.help){B$();return}let t=e.positional[0];t||($("Missing required argument: <owner/repo>"),console.error('Run "asm stats repo --help" for usage.'),process.exit(2));let[s,i]=t.split("/");(!s||!i)&&($(`Invalid repository: "${t}". Expected format: owner/repo`),process.exit(2));let n=(await Pe()).find(a=>a.owner===s&&a.repo===i);n||($(`Repository "${s}/${i}" not found in the skill index.`),console.error(l.dim('Run "asm index list" to see all indexed repositories.')),process.exit(1));let o=qp([n]);if(o.length===0){console.log(`No stats for "${s}/${i}".`);return}e.flags.json?console.log(U(o[0])):console.log(Vp(o[0]))}function V$(){console.log(`${l.bold("Usage:")} asm stats author <owner> [options]
|
|
724
796
|
|
|
725
|
-
|
|
726
|
-
collection (no SKILL.md at the root but each immediate child has one), every
|
|
727
|
-
child skill is evaluated and an aggregate summary is printed.
|
|
797
|
+
Show statistics for a specific author across all indexed repositories.
|
|
728
798
|
|
|
729
|
-
${
|
|
730
|
-
|
|
731
|
-
https://github.com/owner/repo[/tree/<ref>/<sub>]
|
|
799
|
+
${l.bold("Arguments:")}
|
|
800
|
+
owner Author/organization name (e.g. luongnv89)
|
|
732
801
|
|
|
733
|
-
${
|
|
734
|
-
--
|
|
735
|
-
--dry-run With --fix, preview the diff without writing
|
|
736
|
-
--json Output report as JSON
|
|
737
|
-
--machine Output in stable machine-readable v1 envelope format
|
|
738
|
-
--concurrency N Cap parallel per-skill evals in batch mode (default: 4)
|
|
739
|
-
--keep Preserve the temp dir used for remote clones
|
|
740
|
-
-t, --transport M Git transport (auto|https|ssh) for remote targets
|
|
802
|
+
${l.bold("Options:")}
|
|
803
|
+
--json Output as JSON
|
|
741
804
|
--no-color Disable ANSI colors
|
|
742
|
-
-V, --verbose Show debug output
|
|
743
805
|
|
|
744
|
-
${
|
|
745
|
-
asm
|
|
746
|
-
asm
|
|
747
|
-
asm eval github:mattpocock/skills:grill-me ${u.dim("Fetch a remote skill and score it")}
|
|
748
|
-
asm eval github:mattpocock/skills ${u.dim("Batch-score a remote collection")}
|
|
749
|
-
asm eval https://github.com/mattpocock/skills/tree/main/grill-me
|
|
750
|
-
asm eval ./my-skill --json ${u.dim("Output report as JSON")}
|
|
751
|
-
asm eval ./my-skill --fix ${u.dim("Auto-fix deterministic issues")}
|
|
752
|
-
asm eval ./my-skill --fix --dry-run ${u.dim("Preview fixes as diff")}
|
|
753
|
-
asm eval ./my-skill --machine ${u.dim("Machine-readable v1 envelope")}
|
|
754
|
-
asm eval-providers list ${u.dim("List registered eval providers")}`)}function Dk(e){let t=e.findings.find(s=>s.severity==="error"&&(s.code==="provider-threw"||s.code==="timeout"||s.code==="aborted"));if(t)throw new Error(t.message)}async function Fk(e,t,s){await _e();let i=Fe(e);if(i.isLocal)throw new Error(`fetchRemoteForEval received a local path: "${e}". This is a bug \u2014 local paths should use the non-remote branch.`);i=await hs(i);let n=await je(i,t),r=i.subpath?fo(n,i.subpath):n,o=null;try{let{execFile:c}=await import("child_process"),{promisify:f}=await import("util"),d=f(c),{stdout:p}=await d("git",["-C",n,"rev-parse","HEAD"],{timeout:5e3}),m=p.trim();/^[0-9a-f]{40}$/i.test(m)&&(o=m)}catch{}let a=`github:${i.owner}/${i.repo}${i.ref?`#${i.ref}`:""}${i.subpath?`:${i.subpath}`:""}`;return{rootDir:r,cleanup:async()=>{s||await le(n)},sourceRef:a,commitSha:o}}async function Qd(e){Ri();try{let t={skillPath:e.skillPath,skillMdPath:e.skillMdPath},s=(await Promise.all(is(Li()).map(async r=>(await r.applicable(t,{})).ok?Oi(r,t):null))).filter(r=>r!==null),i=s.find(r=>r.providerId==="quality");if(!i)throw new Error("quality provider did not produce a result");return Dk(i),{report:{...i.raw,providers:is(s.map(Ud))},error:null}}catch(t){return{report:null,error:t?.message??String(t)}}}async function _k(e){if(e.flags.help){Mk();return}let t=e.flags.machine?Qe():void 0,s=performance.now(),i=e.subcommand;if(i||(e.flags.machine&&(t?.(),console.log(se("eval",te.INVALID_ARGUMENT,"Missing required argument: <skill-path>",s)),process.exit(2)),$("Missing required argument: <skill-path>"),console.error('Run "asm eval --help" for usage.'),process.exit(2)),e.flags.fix){if(oo(i)){let r="--fix is only supported for local skill paths. Clone the repo first or run `asm install` to materialise it locally.";e.flags.machine&&(t?.(),console.log(se("eval",te.INVALID_ARGUMENT,r,s)),process.exit(2)),$(r),process.exit(2)}try{let r=await vd(),o=await wd(i,{dryRun:e.flags.dryRun,gitAuthor:r});if(e.flags.machine){t?.(),console.log(X("eval",Ai(o.report,o),s));return}if(e.flags.json){console.log(JSON.stringify({report:o.report,fix:{dryRun:o.dryRun,applied:o.applied,skipped:o.skipped,backupPath:o.backupPath,diff:o.diff}},null,2));return}console.log(Ci(o.report)),console.log(""),console.log(Sd(o));return}catch(r){e.flags.machine&&(t?.(),console.log(se("eval",te.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}return}let n=null;try{n=await $d(i,{fetchRemote:r=>Fk(r,e.flags.transport,e.flags.keep)})}catch(r){e.flags.machine&&(t?.(),console.log(se("eval",te.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}try{if(!n.isCollection&&n.targets.length===1){let c=n.targets[0],{report:f,error:d}=await Qd(c);if(!f)throw new Error(d??"eval failed");if(e.flags.machine){t?.();let p=Ai(f,null),m=n.provenance.remote?{...p,provenance:{input:n.provenance.input,remote:!0,source_ref:n.provenance.sourceRef??null,commit_sha:n.provenance.commitSha??null,temp_path:n.provenance.tempPath??null}}:p;console.log(X("eval",m,s));return}if(e.flags.json){n.provenance.remote?console.log(JSON.stringify({...f,provenance:{input:n.provenance.input,remote:!0,sourceRef:n.provenance.sourceRef??null,commitSha:n.provenance.commitSha??null,tempPath:n.provenance.tempPath??null}},null,2)):console.log(kd(f));return}console.log(Ci(f)),n.provenance.remote&&jk(n.provenance);return}let r=e.flags.concurrency||4;if(n.targets.length===0)throw new Error(`No skills to evaluate at "${i}" \u2014 the resolved location has no SKILL.md in itself or its immediate children.`);let o=await Ed(n.targets,r,async c=>{let{report:f,error:d}=await Qd(c);return{label:c.label,skillPath:c.skillPath,report:f,error:d}}),a=xd(o),l={provenance:n.provenance,aggregate:a,results:o};if(e.flags.machine){t?.(),console.log(X("eval",Ad(l),s));return}if(e.flags.json){console.log(JSON.stringify({provenance:l.provenance,aggregate:l.aggregate,results:l.results.map(c=>({label:c.label,skillPath:c.skillPath,error:c.error,report:c.report}))},null,2));return}for(let c of l.results)c.report?console.log(Ci(c.report)):(console.log(`Skill evaluation: ${c.skillPath}`),console.log(` ${u.red("error:")} ${c.error??"unknown failure"}`)),console.log("");console.log(Cd(l)),n.provenance.remote&&e.flags.verbose}catch(r){e.flags.machine&&(t?.(),console.log(se("eval",te.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}finally{if(n)try{await n.cleanup()}catch{}}}function jk(e){let t=[];t.push(""),t.push(u.dim("Fetched remote skill:")),e.sourceRef&&t.push(u.dim(` Source: ${e.sourceRef}`)),e.commitSha&&t.push(u.dim(` Commit: ${e.commitSha}`)),e.tempPath&&t.push(u.dim(` Temp: ${e.tempPath}`)),console.log(t.join(`
|
|
755
|
-
`))}function qk(){console.log(`${u.bold("Usage:")} asm eval-providers <subcommand> [options]
|
|
756
|
-
|
|
757
|
-
Manage evaluation providers registered with the ${u.bold("asm eval")} framework.
|
|
758
|
-
Providers implement the ${u.bold("EvalProvider")} contract (see src/eval/types.ts) and
|
|
759
|
-
are resolved by id and semver range.
|
|
806
|
+
${l.bold("Examples:")}
|
|
807
|
+
asm stats author anthropics
|
|
808
|
+
asm stats author luongnv89 --json`)}async function K$(e){if(e.flags.help){V$();return}let t=e.positional[0];t||($("Missing required argument: <owner>"),console.error('Run "asm stats author --help" for usage.'),process.exit(2));let s=await Pe(),r=Bp(s).find(n=>n.owner===t);r||($(`Author "${t}" not found in the skill index.`),console.error(l.dim('Run "asm stats index" to see all authors.')),process.exit(1)),e.flags.json?console.log(U(r)):console.log(Kp(r))}function G$(){console.log(`${l.bold("Usage:")} asm stats index [options]
|
|
760
809
|
|
|
761
|
-
|
|
762
|
-
list List every registered (id, version) provider
|
|
810
|
+
Show aggregate statistics across all indexed repositories.
|
|
763
811
|
|
|
764
|
-
${
|
|
765
|
-
--json Output as JSON
|
|
812
|
+
${l.bold("Options:")}
|
|
813
|
+
--json Output as JSON
|
|
766
814
|
--no-color Disable ANSI colors
|
|
767
|
-
-V, --verbose Show debug output
|
|
768
815
|
|
|
769
|
-
${
|
|
770
|
-
asm
|
|
771
|
-
asm
|
|
816
|
+
${l.bold("Examples:")}
|
|
817
|
+
asm stats index
|
|
818
|
+
asm stats index --json`)}async function H$(e){if(e.flags.help){G$();return}let t=await Pe();if(t.length===0){console.log("No indexed repositories found."),console.error(l.dim('Run "asm index ingest <repo>" to add repositories.'));return}let s=Up(t);e.flags.json?console.log(U(s)):console.log(Gp(s))}function J$(){console.log(`${l.bold("Usage:")} asm link <path> [<path2> ...] [options]
|
|
772
819
|
|
|
773
820
|
Symlink a local skill directory into an agent's skill folder. Useful
|
|
774
821
|
for local development \u2014 changes to the source are reflected immediately.
|
|
@@ -779,7 +826,7 @@ files, all discovered skills are linked in a single invocation.
|
|
|
779
826
|
|
|
780
827
|
Multiple paths can be provided to link several skills at once.
|
|
781
828
|
|
|
782
|
-
${
|
|
829
|
+
${l.bold("Options:")}
|
|
783
830
|
-p, --tool <name> Target tool (claude, codex, openclaw, agents)
|
|
784
831
|
--name <name> Override symlink name (single skill only)
|
|
785
832
|
-f, --force Overwrite if target already exists
|
|
@@ -787,50 +834,57 @@ ${u.bold("Options:")}
|
|
|
787
834
|
--no-color Disable ANSI colors
|
|
788
835
|
-V, --verbose Show debug output
|
|
789
836
|
|
|
790
|
-
${
|
|
791
|
-
asm link ./my-skill ${
|
|
792
|
-
asm link ./my-skill -p claude ${
|
|
793
|
-
asm link ./my-skill --name alias ${
|
|
794
|
-
asm link ./my-skills-folder ${
|
|
795
|
-
asm link ./skill1 ./skill2 ./skill3 -p claude ${
|
|
796
|
-
${
|
|
797
|
-
${
|
|
798
|
-
Done! Linked ${
|
|
799
|
-
${
|
|
800
|
-
${p.length} linked, ${m.length} failed.`)):console.error(
|
|
801
|
-
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}function
|
|
837
|
+
${l.bold("Examples:")}
|
|
838
|
+
asm link ./my-skill ${l.dim("Link (interactive tool)")}
|
|
839
|
+
asm link ./my-skill -p claude ${l.dim("Link to Claude Code")}
|
|
840
|
+
asm link ./my-skill --name alias ${l.dim("Link with custom name")}
|
|
841
|
+
asm link ./my-skills-folder ${l.dim("Link all skills in folder")}
|
|
842
|
+
asm link ./skill1 ./skill2 ./skill3 -p claude ${l.dim("Link multiple skills at once")}`)}async function W$(e,t){if(t)return!0;let{access:s}=await import("fs/promises"),i=!1;try{await s(e),i=!0}catch{}if(!i)return!1;if(!process.stdin.isTTY)throw new Error(`Target already exists: ${e}. Use --force to overwrite.`);process.stderr.write(`${l.yellow(`Target already exists: ${e}`)}
|
|
843
|
+
${l.bold("Overwrite?")} [y/N] `);let r=await K();return r.toLowerCase()!=="y"&&r.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function Kr(e,t,s,i){let{join:r}=await import("path"),n=r(t,s),o=await W$(n,i);return await Sr(e,t,s,o),{name:s,symlinkPath:n,targetPath:e}}async function Em(e){if(e.flags.help){J$();return}let t=[];if(e.subcommand&&t.push(e.subcommand),t.push(...e.positional),t.length===0&&($("Missing required argument: <path>"),console.error('Run "asm link --help" for usage.'),process.exit(2)),t.length>1){e.flags.name&&($("--name cannot be used when linking multiple paths. Link each skill individually to use --name."),process.exit(2));let y=await j(),{provider:h}=await be(y,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:g}=await import("./config-AZYQEQOQ.js"),b=g(y.providers.find(I=>I.name===h.name).global),{resolve:k,basename:S}=await import("path"),v=[],x=[];for(let I of t){let L=k(I),E=!1,F=null;try{await Yo(L),E=!0}catch(O){let w=O instanceof Error?O.message:String(O);w.startsWith("Path does not exist")||w.startsWith("Path is not a directory")||w.startsWith("No SKILL.md found")||(F=w)}if(F){x.push({name:I,error:F}),e.flags.json||console.error(l.red(` Failed to process "${I}": ${F}`));continue}if(E){let O=S(L);try{let w=await Kr(L,b,O,!!e.flags.force);v.push(w),e.flags.json||console.error(l.green(` Linked "${w.name}" -> ${w.targetPath}`))}catch(w){let P=w instanceof Error?w.message:String(w);x.push({name:O,error:P}),e.flags.json||console.error(l.red(` Failed to link "${O}": ${P}`))}}else{let O;try{O=await zo(L)}catch(w){let P=w instanceof Error?w.message:String(w),q=P;P.startsWith("Path does not exist")&&Qe(I)&&(q=`${P} \u2014 "${I}" looks like a registry name; try "asm install ${I}" first.`),x.push({name:I,error:q}),e.flags.json||console.error(l.red(` Failed to process "${I}": ${q}`));continue}if(O.length===0){let w=`No SKILL.md found in ${L} or its immediate subdirectories.`;x.push({name:I,error:w}),e.flags.json||console.error(l.red(` ${w}`));continue}for(let w of O)try{let P=await Kr(w.absPath,b,w.dirName,!!e.flags.force);v.push(P),e.flags.json||console.error(l.green(` Linked "${P.name}" -> ${P.targetPath}`))}catch(P){let q=P instanceof Error?P.message:String(P);x.push({name:w.name,error:q}),e.flags.json||console.error(l.red(` Failed to link "${w.name}": ${q}`))}}}e.flags.json?console.log(U({success:x.length===0,linked:v,failures:x})):x.length>0?console.error(l.yellow(`
|
|
844
|
+
${v.length} linked, ${x.length} failed.`)):console.error(l.green(`
|
|
845
|
+
Done! Linked ${v.length} skill(s) successfully.`)),x.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:r}=await import("path"),n=i(s),o=!1;try{await Yo(n),o=!0}catch(y){let h=y instanceof Error?y.message:String(y);h.startsWith("Path does not exist")||h.startsWith("Path is not a directory")||h.startsWith("No SKILL.md found")||($(h),process.exit(1))}let a=[];if(!o){try{a=await zo(n)}catch(y){let h=y instanceof Error?y.message:String(y);h.startsWith("Path does not exist")?($(`No such skill or path: ${s}`),Qe(s)?(console.error(` "${s}" looks like a registry name, not a local path.`),console.error(` Install it first: ${l.bold(`asm install ${s}`)}`),console.error(` Or pass a local path: ${l.bold(`asm link ./path/to/${s}`)}`)):console.error(' Pass a local directory containing SKILL.md, or run "asm install <name>" first.')):$(h),process.exit(1)}a.length===0&&($(`No SKILL.md found in ${n} or its immediate subdirectories.`),process.exit(1)),e.flags.name&&a.length>1&&($(`--name cannot be used when linking multiple skills (found ${a.length} skills). Link each skill individually to use --name.`),process.exit(2))}let c=await j(),{provider:u}=await be(c,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:f}=await import("./config-AZYQEQOQ.js"),d=f(c.providers.find(y=>y.name===u.name).global);if(o){let y=e.flags.name?ge(e.flags.name):r(n),h;try{h=await Kr(n,d,y,!!e.flags.force)}catch(g){let b=g instanceof Error?g.message:String(g);e.flags.json?console.log(U({success:!1,error:b})):$(b),process.exit(2)}e.flags.json?console.log(U({success:!0,...h})):(console.error(l.green(`Done! Linked "${h.name}" -> ${h.targetPath}`)),console.error(` Symlink: ${h.symlinkPath}`),console.error(l.dim(` If you move or delete the source, run "asm uninstall ${h.name}" to clean up.`)));return}console.error(`Found ${l.bold(String(a.length))} skill(s) in ${n}:`);for(let y of a)console.error(` ${l.bold(y.name)} ${l.dim(`v${y.version}`)} ${l.dim(`(${y.dirName}/)`)}`);if(process.stdin.isTTY&&!e.flags.force){process.stderr.write(`
|
|
846
|
+
${l.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await K();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],m=[];for(let y of a){let h=e.flags.name&&a.length===1?ge(e.flags.name):y.dirName;try{let g=await Kr(y.absPath,d,h,!!e.flags.force);p.push(g),e.flags.json||console.error(l.green(` Linked "${g.name}" -> ${g.targetPath}`))}catch(g){let b=g instanceof Error?g.message:String(g);m.push({name:y.name,error:b}),e.flags.json||console.error(l.red(` Failed to link "${y.name}": ${b}`))}}e.flags.json?console.log(U({success:m.length===0,linked:p,failures:m})):m.length>0?console.error(l.yellow(`
|
|
847
|
+
${p.length} linked, ${m.length} failed.`)):console.error(l.green(`
|
|
848
|
+
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}import{writeFile as cx,mkdir as ux,unlink as dx,readFile as fx,readdir as px}from"fs/promises";import{join as Qs}from"path";function ll(e){return e==="skills"||e.startsWith("skills/")?{priority:1,root:"skills/"}:e===".claude/skills"||e.startsWith(".claude/skills/")?{priority:2,root:".claude/skills/"}:e===".agent/skills"||e.startsWith(".agent/skills/")?{priority:3,root:".agent/skills/"}:e===".agents/skills"||e.startsWith(".agents/skills/")?{priority:3,root:".agents/skills/"}:{priority:4,root:"(other)"}}function Pm(e){let t=new Map;for(let n of e){let o=t.get(n.name);o?o.push(n):t.set(n.name,[n])}let s=[],i=[],r=new Set;for(let n of e){if(r.has(n.name))continue;r.add(n.name);let o=t.get(n.name);if(o.length===1){s.push(o[0]);continue}let a=0,c=ll(o[0].relPath);for(let f=1;f<o.length;f++){let d=ll(o[f].relPath);d.priority<c.priority&&(a=f,c=d)}let u=o[a];s.push(u),i.push({name:n.name,kept:{relPath:u.relPath,root:c.root},dropped:o.filter((f,d)=>d!==a).map(f=>({relPath:f.relPath,root:ll(f.relPath).root})),reason:c.priority===4?"first occurrence (no priority match)":`${c.root} priority`})}return{kept:s,decisions:i}}var Y$=[{label:"obfuscation:atob",pattern:/\batob\s*\(/},{label:"obfuscation:base64",pattern:/(?:^|[=:\s])[A-Za-z0-9+/]{40,}={1,2}(?:\s|$)/m},{label:"obfuscation:hex-escape",pattern:/\\x[0-9a-fA-F]{2}(?:\\x[0-9a-fA-F]{2}){3,}/},{label:"credential-leak:api-key",pattern:/\bAPI_KEY\s*=\s*['"][^'"]+['"]/},{label:"credential-leak:secret",pattern:/\bSECRET_KEY\s*=\s*['"][^'"]+['"]/},{label:"credential-leak:password",pattern:/\bPASSWORD\s*=\s*['"][^'"]+['"]/}];function Im(e,t){let s=[];(!e.name||!e.name.trim())&&s.push("missing frontmatter field: name"),(!e.description||!e.description.trim())&&s.push("missing frontmatter field: description"),z$(t).trim().length<20&&s.push("SKILL.md body too short (less than 20 chars of instructions)");for(let{label:r,pattern:n}of Y$)n.test(t)&&s.push(`malicious pattern detected: ${r}`);return{verified:s.length===0,reasons:s}}function z$(e){let t=e.trimStart();if(!t.startsWith("---"))return t;let s=t.indexOf(`
|
|
849
|
+
---`,3);return s===-1?"":t.slice(s+4)}import{readdir as X$,readFile as Cm,stat as Am}from"fs/promises";import{join as cl}from"path";var Q$=[{id:"marketing",title:"Marketing Skills",description:"Marketing, growth, SEO, ASO, affiliate, sales, and conversion skills.",tags:["marketing","growth","seo"],keywords:["marketing","growth","seo","aso","affiliate","sales","copy","copywriting","conversion","cro","brand","social","campaign"]},{id:"writing",title:"Writing Skills",description:"Writing, editing, documentation, publishing, and content-production skills.",tags:["writing","content","docs"],keywords:["write","writing","writer","blog","article","content","docs","documentation","draft","copy","readme","paper","thesis","proposal"]},{id:"research",title:"Research Skills",description:"Research, academic, literature-review, citation, paper, and analysis skills.",tags:["research","academic","analysis"],keywords:["research","academic","scholar","paper","literature","citation","review","analysis","summar","evaluate","verify"]},{id:"engineering",title:"Engineering Skills",description:"Coding, debugging, testing, architecture, review, and software engineering skills.",tags:["engineering","coding","testing"],keywords:["code","coding","debug","test","testing","coverage","review","refactor","architecture","typescript","python","javascript","build","cli","api"]},{id:"frontend-design",title:"Frontend & Design Skills",description:"Frontend, UI, UX, visual design, component, theme, and landing-page skills.",tags:["frontend","design","ui"],keywords:["frontend","ui","ux","design","component","react","css","html","figma","theme","landing","layout","visual","brand","logo"]},{id:"devops",title:"DevOps Skills",description:"Deployment, CI/CD, infrastructure, cloud, Docker, Kubernetes, and automation skills.",tags:["devops","infra","automation"],keywords:["devops","deploy","deployment","ci","cd","pipeline","docker","kubernetes","terraform","ansible","cloud","infra","infrastructure","workflow","release"]},{id:"data-ai",title:"Data & AI Skills",description:"Data, analytics, AI, model, prompt, agent, and automation skills.",tags:["data","ai","agents"],keywords:["data","analytics","analysis","ai","agent","llm","model","prompt","openai","claude","gemini","automation","dataset","sql"]},{id:"product-business",title:"Product & Business Skills",description:"Product, strategy, PRD, planning, finance, resume, and business workflow skills.",tags:["product","business","planning"],keywords:["product","prd","strategy","planning","business","finance","resume","career","startup","market","competitor","customer","sales"]}],Lm=2,Z$=80,ex=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],tx=["bundles","data/bundles",".asm/bundles"];function Xs(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Rm(e,t,s){let i=Xs(e),r=Xs(t),n=Xs(s),o=`${i}-${r}`;return n.startsWith(o)?n:`${o}-${n}`}function sx(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function ix(e,t){let s=sx(e);return t.keywords.some(i=>s.includes(i))}function Nm(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function rx(e){let t=new Set,s=[];for(let i of e){let r=`${i.installUrl||""}\0${i.name}`;t.has(r)||(t.add(r),s.push(i))}return s}function Tm(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function ul(e){let t=[];if(!e.skills||e.skills.length<Lm)return t;for(let s of Q$){let i=e.skills.filter(n=>ix(n,s)).slice(0,Z$);if(i.length<Lm)continue;let r=Rm(e.owner,e.repo,s.id);t.push({version:1,name:r,description:`${s.description} Derived from ${e.owner}/${e.repo}.`,author:`ASM (${e.owner}/${e.repo})`,createdAt:e.updatedAt,tags:["repo-derived","inferred",...s.tags,Xs(e.owner),Xs(e.repo)],skills:Tm(i.map(Nm)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function nx(e,t,s){if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e,r=Array.isArray(i.skills)?i.skills:[];if(r.length===0)return null;let n=new Map(t.skills.map(c=>[c.name,c])),o=rx(r.map(c=>{if(typeof c=="string"){let p=n.get(c);return p?Nm(p):null}if(!c||typeof c!="object"||Array.isArray(c))return null;let u=c,f=typeof u.name=="string"?u.name:"";if(!f)return null;let d=n.get(f);return d?{name:d.name,installUrl:d.installUrl,description:typeof u.description=="string"&&u.description?u.description:d.description||void 0,version:typeof u.version=="string"&&u.version?u.version:d.version||void 0}:null}).filter(c=>c!==null));if(o.length===0)return null;let a=typeof i.name=="string"&&i.name?i.name:s.replace(/\.json$/,"");return{version:1,name:Rm(t.owner,t.repo,a),description:typeof i.description=="string"&&i.description?i.description:`Bundle from ${t.owner}/${t.repo}.`,author:typeof i.author=="string"&&i.author?i.author:`ASM (${t.owner}/${t.repo})`,createdAt:typeof i.createdAt=="string"&&i.createdAt?i.createdAt:t.updatedAt,tags:Array.isArray(i.tags)?["repo-derived","explicit",...i.tags.filter(c=>typeof c=="string")]:["repo-derived","explicit"],skills:Tm(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function ox(e){try{return(await Am(e)).isFile()}catch{return!1}}async function ax(e){try{return(await Am(e)).isDirectory()}catch{return!1}}async function lx(e){let t=[];for(let s of ex){let i=cl(e,s);if(await ox(i))try{t.push({relPath:s,data:JSON.parse(await Cm(i,"utf-8"))})}catch{}}for(let s of tx){let i=cl(e,s);if(!await ax(i))continue;let r;try{r=await X$(i)}catch{continue}for(let n of r.filter(o=>o.endsWith(".json")).sort()){let o=`${s}/${n}`;try{t.push({relPath:o,data:JSON.parse(await Cm(cl(i,n),"utf-8"))})}catch{}}}return t}async function Om(e,t){let s=[],i=await lx(e);for(let r of i){let n=r.data,o=Array.isArray(n?.bundles)?n.bundles:[n];for(let a of o){let c=nx(a,t,r.relPath);c&&s.push(c)}}return Gr(s)}function Gr(e){let t=new Map;for(let s of e){let i=t.get(s.name);(!i||s.explicit&&!i.explicit)&&t.set(s.name,s)}return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}function Mm(e){let t=e.bundles||[],s=ul(e);return Gr([...t,...s])}var mx=8;async function hx(){let e=Yt();return await ux(e,{recursive:!0}),e}function gx(e,t){return`github:${e.owner}/${e.repo}${e.ref?`#${e.ref}`:""}${t?`:${t}`:""}`}async function Dm(e){await Ce();let t;try{t=ce(e)}catch(i){return{success:!1,repoIndex:null,error:i.message}}if(t.isLocal)return{success:!1,repoIndex:null,error:"Local paths are not supported for indexing. Use a GitHub source instead."};try{he(t,e)}catch(i){return{success:!1,repoIndex:null,error:i.message}}A(`ingester: cloning ${t.owner}/${t.repo}`);let s=null;try{s=await Le(t),A(`ingester: discovering skills in ${s}`);let i=await dt(s);A(`ingester: found ${i.length} skills`);let{kept:r,decisions:n}=Pm(i);for(let d of n){let p=d.dropped.map(m=>m.relPath).join(", ");A(`ingester: dedupe "${d.name}": kept ${d.kept.relPath} (${d.reason}); dropped ${p}`)}n.length>0&&A(`ingester: deduped ${i.length} -> ${r.length} skills (${n.length} name collision${n.length===1?"":"s"})`);let o=s,a=await _s(r,mx,async d=>{let p=Qs(o,d.relPath,"SKILL.md"),m="";try{m=await fx(p,"utf-8")}catch{A(`ingester: could not read SKILL.md at ${p}`)}let y=Im(d,m);y.verified||A(`ingester: ${d.name} not verified: ${y.reasons.join(", ")}`);let h=typeof d.tokenCount=="number"?d.tokenCount:m?je(m):void 0,g,b;if(m){let k;try{k=await px(Qs(o,d.relPath))}catch{k=void 0}try{let S=Ft({content:m,skillPath:d.relPath||d.name,skillMdPath:p,rootEntries:k});g={overallScore:S.overallScore,grade:S.grade,categories:S.categories.map(v=>({id:v.id,name:v.name,score:v.score,max:v.max})),evaluatedAt:S.evaluatedAt,evaluatedVersion:d.version||void 0}}catch(S){A(`ingester: eval failed for ${d.name}: ${S}`)}try{let S={skillPath:Qs(o,d.relPath),skillMdPath:p},x=(await Promise.all(Ws(qr()).map(async I=>(await I.applicable(S,{})).ok?Br(I,S):null))).filter(I=>I!==null).map(I=>Ip(I,d.version||void 0));x.length>0&&(b=Object.fromEntries(x.filter(I=>I.providerId).map(I=>[I.providerId,I])))}catch(S){A(`ingester: provider eval failed for ${d.name}: ${S}`)}}return{name:d.name,description:d.description,version:d.version,license:d.license,creator:d.creator,compatibility:d.compatibility,allowedTools:d.allowedTools,modelInvocable:d.modelInvocable!==!1,userInvocable:d.userInvocable!==!1,installUrl:gx(t,d.relPath),relPath:d.relPath,verified:y.verified,tokenCount:h,evalSummary:g,evalSummaries:b}}),c={repoUrl:t.cloneUrl,owner:t.owner,repo:t.repo,updatedAt:new Date().toISOString(),skillCount:a.length,skills:a};c.bundles=Gr([...await Om(s,c),...ul(c)]);let u=await hx(),f=Qs(u,`${t.owner}_${t.repo}.json`);return await cx(f,JSON.stringify(c,null,2)+`
|
|
850
|
+
`,"utf-8"),A(`ingester: wrote index to ${f}`),{success:!0,repoIndex:c}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await Q(s)}}async function _m(){return(await Pe()).map(t=>({owner:t.owner,repo:t.repo,skillCount:t.skillCount,updatedAt:t.updatedAt})).sort((t,s)=>s.skillCount-t.skillCount)}async function Fm(e,t){let s=Yt(),i=Qs(s,`${e}_${t}.json`);try{return await dx(i),!0}catch{return!1}}function yx(){console.log(`${l.bold("Usage:")} asm index <subcommand> [options]
|
|
802
851
|
|
|
803
852
|
Manage the skill index for searching available skills from indexed repos.
|
|
804
853
|
|
|
805
|
-
${
|
|
854
|
+
${l.bold("Subcommands:")}
|
|
806
855
|
ingest <repo> Ingest a skill repository into the index
|
|
807
856
|
search <query> Search indexed skills by name or description
|
|
808
857
|
list List all indexed repositories
|
|
809
858
|
remove <owner/repo> Remove a repo from the index
|
|
810
859
|
|
|
811
|
-
${
|
|
860
|
+
${l.bold("Options:")}
|
|
812
861
|
--json Output as JSON
|
|
813
862
|
--has <field> Only show skills that have <field> (license, creator, version)
|
|
814
863
|
--missing <field> Only show skills missing <field> (license, creator, version)
|
|
864
|
+
--model-invocable Only skills the model can invoke
|
|
865
|
+
--user-invocable Only skills the user can invoke
|
|
815
866
|
-y, --yes Skip confirmation prompts
|
|
816
867
|
--no-color Disable ANSI colors
|
|
817
868
|
-V, --verbose Show debug output
|
|
818
869
|
|
|
819
|
-
${
|
|
820
|
-
asm index ingest github:obra/superpowers ${
|
|
821
|
-
asm index search code review ${
|
|
822
|
-
asm index search marketing --has license ${
|
|
823
|
-
asm index search "" --missing creator ${
|
|
824
|
-
asm index list ${
|
|
825
|
-
asm index remove obra/superpowers ${
|
|
826
|
-
`));for(let o of
|
|
827
|
-
`)}}break}case"list":{let s=await
|
|
828
|
-
`));for(let
|
|
870
|
+
${l.bold("Examples:")}
|
|
871
|
+
asm index ingest github:obra/superpowers ${l.dim("Index superpowers repo")}
|
|
872
|
+
asm index search code review ${l.dim("Search for skills")}
|
|
873
|
+
asm index search marketing --has license ${l.dim("Only with license")}
|
|
874
|
+
asm index search "" --missing creator ${l.dim("Skills missing creator")}
|
|
875
|
+
asm index list ${l.dim("List indexed repos")}
|
|
876
|
+
asm index remove obra/superpowers ${l.dim("Remove from index")}`)}async function jm(e){if(e.flags.help){yx();return}let t=e.subcommand;switch(t||($("Missing subcommand. Use: ingest, search, list, or remove"),console.error('Run "asm index --help" for usage.'),process.exit(2)),t){case"ingest":{let s=e.positional[0];s||($("Missing required argument: <repo>"),console.error('Run "asm index --help" for usage.'),process.exit(2)),console.error(l.blueBold(`Ingesting ${s}...`));let i=await Dm(s);i.success||($(`Failed to ingest: ${i.error}`),process.exit(1)),i.repoIndex&&(e.flags.json?console.log(U({success:!0,owner:i.repoIndex.owner,repo:i.repoIndex.repo,skillCount:i.repoIndex.skillCount,updatedAt:i.repoIndex.updatedAt})):(console.error(l.green(`Successfully indexed ${i.repoIndex.owner}/${i.repoIndex.repo}`)),console.error(` Skills found: ${i.repoIndex.skillCount}`)));break}case"search":{let s=e.positional.join(" ");!s&&e.flags.has.length===0&&e.flags.missing.length===0&&!e.flags.modelInvocable&&!e.flags.userInvocable&&($("Missing required argument: <query>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let i={};e.flags.has.length>0&&(i.has=e.flags.has),e.flags.missing.length>0&&(i.missing=e.flags.missing),e.flags.modelInvocable&&(i.modelInvocable=!0),e.flags.userInvocable&&(i.userInvocable=!0);let n=i.has||i.missing||i.modelInvocable||i.userInvocable?await Cs(s||"",20,i):await Cs(s);if(n.length===0){e.flags.json?console.log(U([])):(console.info("No skills found matching your query."),console.error(l.dim("Try ingesting more repos with: asm index ingest <repo>")));return}if(e.flags.json)console.log(U(n.map(o=>({name:o.skill.name,description:o.skill.description,version:o.skill.version,license:o.skill.license||"",creator:o.skill.creator||"",compatibility:o.skill.compatibility||"",allowedTools:o.skill.allowedTools||[],verified:o.skill.verified===!0,installUrl:o.skill.installUrl,installCommand:`asm install ${o.skill.installUrl}`,repo:`${o.repo.owner}/${o.repo.repo}`}))));else{console.error(l.bold(`Found ${n.length} skills:
|
|
877
|
+
`));for(let o of n){let a=o.skill.verified?l.blue(" [verified]"):"";console.error(`${l.cyan(o.skill.name)} ${l.dim(`v${o.skill.version}`)}${a} ${l.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let u of $l(o.skill.description,80))console.error(` ${u}`);let c=Zd(o.skill);c.length>0&&console.error(` ${l.yellow(`\u26A0 Missing: ${c.join(", ")}`)}`),console.error(` ${l.green(`asm install ${o.skill.installUrl}`)}
|
|
878
|
+
`)}}break}case"list":{let s=await _m();if(s.length===0){e.flags.json?console.log(U([])):(console.info("No repositories indexed."),console.error(l.dim("Add repos with: asm index ingest <repo>")));return}let i=await ef();if(e.flags.json)console.log(U(s));else{console.error(l.bold(`Indexed Repositories (${i} total skills):
|
|
879
|
+
`));for(let r of s)console.error(`${l.cyan(`${r.owner}/${r.repo}`)} - ${r.skillCount} skills ${l.dim(`(${new Date(r.updatedAt).toLocaleDateString()})`)}`)}break}case"remove":{let s=e.positional[0];s||($("Missing required argument: <owner/repo>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let[i,r]=s.split("/");if((!i||!r)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${l.bold("Remove")} ${l.cyan(`${i}/${r}`)} ${l.bold("from index?")} [y/N] `);let o=await K();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await Fm(i,r)?console.error(l.green(`Removed ${i}/${r} from index`)):($(`Repository not found in index: ${i}/${r}`),process.exit(1));break}default:$(`Unknown subcommand: "${t}"`),console.error('Run "asm index --help" for usage.'),process.exit(2)}}import{readFile as bx,writeFile as wx,readdir as qm,access as Bm,mkdir as kx,rm as vx}from"fs/promises";import{join as bt,resolve as Um,dirname as Sx}from"path";import{fileURLToPath as $x}from"url";var xx=$x(import.meta.url),Ex=Sx(xx),Hr=Um(Ex,"..","data","bundles");function Px(e){let t=[];if(typeof e!="object"||e===null||Array.isArray(e))return{valid:!1,errors:["Bundle must be a JSON object."]};let s=e;if(s.version!==1&&t.push(`Unsupported bundle version: ${JSON.stringify(s.version)}. Expected 1.`),(typeof s.name!="string"||!s.name)&&t.push("Missing or empty 'name' field."),(typeof s.description!="string"||!s.description)&&t.push("Missing or empty 'description' field."),(typeof s.author!="string"||!s.author)&&t.push("Missing or empty 'author' field."),typeof s.createdAt!="string"&&t.push("Missing or invalid 'createdAt' field."),!Array.isArray(s.skills))return t.push("Missing or invalid 'skills' array."),{valid:!1,errors:t};s.skills.length===0&&t.push("Bundle must contain at least one skill.");for(let i=0;i<s.skills.length;i++){let r=s.skills[i];if(typeof r!="object"||r===null){t.push(`skills[${i}]: must be an object.`);continue}let n=r;(typeof n.name!="string"||!n.name)&&t.push(`skills[${i}]: missing or empty 'name'.`),(typeof n.installUrl!="string"||!n.installUrl)&&t.push(`skills[${i}]: missing or empty 'installUrl'.`)}return s.tags!==void 0&&(Array.isArray(s.tags)?s.tags.some(i=>typeof i!="string")&&t.push("'tags' must contain only strings."):t.push("'tags' must be an array of strings if provided.")),{valid:t.length===0,errors:t}}function Vm(e,t,s,i,r){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:r}}async function Km(e,t){let s=t??await Be(),i=s.skills[e.name]||s.skills[e.dirName],r;return e.isSymlink&&e.symlinkTarget?r=e.symlinkTarget:i?.source?r=i.source:r=e.path,{name:e.name,installUrl:r,description:e.description||void 0,version:e.version||void 0}}function yt(){return bt(oi(),"bundles")}async function Ix(){await kx(yt(),{recursive:!0})}function ei(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(t=t.replace(/^\.+|\.+$/g,""),!t||t==="."||t==="..")throw new Error("Invalid bundle name: results in an empty filename after sanitization.");return t}async function dl(e){await Ix();let t=`${ei(e.name)}.json`,s=bt(yt(),t);return await wx(s,JSON.stringify(e,null,2)+`
|
|
880
|
+
`,"utf-8"),A(`bundle: saved to ${s}`),s}async function Zs(e){let t;try{t=await bx(e,"utf-8")}catch(r){throw r?.code==="ENOENT"?new Error(`Bundle file not found: ${e}`,{cause:r}):new Error(`Failed to read bundle file: ${r.message}`,{cause:r})}let s;try{s=JSON.parse(t)}catch{throw new Error("Bundle file is not valid JSON.")}let i=Px(s);if(!i.valid)throw new Error(`Invalid bundle:
|
|
881
|
+
${i.errors.join(`
|
|
882
|
+
`)}`);return s}async function ti(e){if(e.includes("/")||e.includes("\\")||e.endsWith(".json")){let i=Um(e);return Zs(i)}let t=`${ei(e)}.json`,s=bt(yt(),t);try{return await Zs(s)}catch(i){if(i?.message?.includes("Bundle file not found")){let r=bt(Hr,t);try{return await Zs(r)}catch(n){if(n?.message?.includes("Bundle file not found")){let o=await Cx(e);if(o)return o;throw new Error(`Bundle file not found: ${s}`,{cause:n})}throw n}}throw i}}async function Gm(){let e=[];try{await Bm(Hr);let s;try{s=await qm(Hr)}catch{s=[]}for(let i of s){if(!i.endsWith(".json"))continue;let r=bt(Hr,i);try{let n=await Zs(r);e.push(n)}catch{A(`bundle: skipping invalid predefined file ${r}`)}}}catch{}e.push(...await Hm());let t=new Map;for(let s of e)t.has(s.name)||t.set(s.name,s);return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}async function Hm(){try{return(await Pe()).flatMap(t=>Mm(t))}catch(e){return A(`bundle: failed to load repo-derived bundles: ${e}`),[]}}async function Cx(e){let t=ei(e),s=await Hm();return s.find(i=>i.name===e)||s.find(i=>ei(i.name)===t)||null}async function Jm(){let e=[];try{await Bm(yt())}catch{return e}let t;try{t=await qm(yt())}catch{return e}for(let s of t){if(!s.endsWith(".json"))continue;let i=bt(yt(),s);try{let r=await Zs(i);e.push(r)}catch{A(`bundle: skipping invalid file ${i}`)}}return e.sort((s,i)=>s.name.localeCompare(i.name)),e}async function Wm(e){let t=`${ei(e)}.json`,s=bt(yt(),t);try{return await vx(s),A(`bundle: removed ${s}`),!0}catch(i){if(i?.code==="ENOENT")return!1;throw i}}import{join as Lx}from"path";function Ax(){console.log(`${l.bold("Usage:")} asm bundle <subcommand> [options]
|
|
829
883
|
|
|
830
884
|
Create, install, and manage curated skill bundles. A bundle is a reusable
|
|
831
885
|
recipe of skills for a particular workflow, domain, or project setup.
|
|
832
886
|
|
|
833
|
-
${
|
|
887
|
+
${l.bold("Subcommands:")}
|
|
834
888
|
create <name> Create a new bundle from installed skills
|
|
835
889
|
install <name|file> Install all skills from a bundle (supports pre-defined names)
|
|
836
890
|
list List all saved bundles
|
|
@@ -840,7 +894,7 @@ ${u.bold("Subcommands:")}
|
|
|
840
894
|
modify <name> Add/remove skills or update bundle metadata
|
|
841
895
|
export <name> [file] Export a bundle to a JSON file
|
|
842
896
|
|
|
843
|
-
${
|
|
897
|
+
${l.bold("Options:")}
|
|
844
898
|
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
845
899
|
-y, --yes Skip confirmation prompts
|
|
846
900
|
--json Output as JSON
|
|
@@ -848,27 +902,163 @@ ${u.bold("Options:")}
|
|
|
848
902
|
--no-color Disable ANSI colors
|
|
849
903
|
-V, --verbose Show debug output
|
|
850
904
|
|
|
851
|
-
${
|
|
852
|
-
asm bundle create my-workflow ${
|
|
853
|
-
asm bundle install my-workflow ${
|
|
854
|
-
asm bundle install frontend-dev ${
|
|
855
|
-
asm bundle install ./bundle.json ${
|
|
856
|
-
asm bundle list ${
|
|
857
|
-
asm bundle list --predefined ${
|
|
858
|
-
asm bundle list --json ${
|
|
859
|
-
asm bundle show my-workflow ${
|
|
860
|
-
asm bundle remove my-workflow ${
|
|
861
|
-
asm bundle modify my-workflow --add github:u/r ${
|
|
862
|
-
asm bundle modify my-workflow --remove skill ${
|
|
863
|
-
asm bundle export my-workflow ${
|
|
864
|
-
asm bundle export my-workflow out.json ${
|
|
865
|
-
`));let g=await
|
|
866
|
-
${
|
|
867
|
-
${
|
|
868
|
-
Installing ${
|
|
869
|
-
`));for(let
|
|
870
|
-
${
|
|
871
|
-
`));for(let
|
|
872
|
-
${
|
|
873
|
-
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(
|
|
874
|
-
|
|
905
|
+
${l.bold("Examples:")}
|
|
906
|
+
asm bundle create my-workflow ${l.dim("Create from installed skills")}
|
|
907
|
+
asm bundle install my-workflow ${l.dim("Install a saved bundle")}
|
|
908
|
+
asm bundle install frontend-dev ${l.dim("Install a pre-defined bundle")}
|
|
909
|
+
asm bundle install ./bundle.json ${l.dim("Install from file")}
|
|
910
|
+
asm bundle list ${l.dim("Show all saved bundles")}
|
|
911
|
+
asm bundle list --predefined ${l.dim("List pre-defined bundles")}
|
|
912
|
+
asm bundle list --json ${l.dim("List bundles as JSON")}
|
|
913
|
+
asm bundle show my-workflow ${l.dim("Show bundle details")}
|
|
914
|
+
asm bundle remove my-workflow ${l.dim("Remove a saved bundle")}
|
|
915
|
+
asm bundle modify my-workflow --add github:u/r ${l.dim("Add a skill to bundle")}
|
|
916
|
+
asm bundle modify my-workflow --remove skill ${l.dim("Remove a skill from bundle")}
|
|
917
|
+
asm bundle export my-workflow ${l.dim("Export to ./my-workflow.json")}
|
|
918
|
+
asm bundle export my-workflow out.json ${l.dim("Export bundle to file")}`)}async function Ym(e){if(e.flags.help){Ax();return}let t=e.subcommand;switch(t||($("Missing subcommand. Use: create, install, list, show, remove, modify, or export"),console.error('Run "asm bundle --help" for usage.'),process.exit(2)),t){case"create":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle create <name>"),process.exit(2));let i=await j(),r=await H(i,e.flags.scope);r.length===0&&($("No skills found to include in the bundle."),process.exit(1));let n=new Set,o=r.filter(h=>{let g=h.name.toLowerCase();return n.has(g)?!1:(n.add(g),!0)}),a=o;if(process.stdin.isTTY&&!e.flags.yes){let h=o.map(b=>({label:`${b.name} v${b.version}`,hint:b.description?b.description.slice(0,60)+(b.description.length>60?"...":""):`(${b.provider}/${b.scope})`,checked:!0}));console.error(l.bold(`Select skills for bundle "${s}":
|
|
919
|
+
`));let g=await ft({items:h});g.length===0&&($("No skills selected. Bundle not created."),process.exit(1)),a=g.map(b=>o[b])}let{readLock:c}=await import("./lock-NN2MADX7.js"),u=await c(),f=await Promise.all(a.map(h=>Km(h,u))),d=`Bundle of ${f.length} skills`,p="unknown";try{let{execFile:h}=await import("child_process"),{promisify:g}=await import("util"),k=(await g(h)("git",["config","user.name"],{encoding:"utf-8",timeout:5e3})).stdout.trim();k&&(p=k)}catch{}if(process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`
|
|
920
|
+
${l.bold("Description")} (optional, press Enter to skip): `);let h=await K();h.trim()&&(d=h.trim()),process.stderr.write(`${l.bold("Author")} (optional, press Enter to skip): `);let g=await K();g.trim()&&(p=g.trim())}let m=Vm(s,d,p,f),y=await dl(m);e.flags.json?console.log(JSON.stringify(m,null,2)):(console.error(l.green(`Bundle "${s}" created with ${f.length} skill(s).`)),console.error(` Saved to: ${l.dim(y)}`));break}case"install":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle install <name|file>"),process.exit(2));let i;try{i=await ti(s)}catch(d){$(d.message),process.exit(1)}console.error(`${l.bold("Bundle:")} ${i.name} (${i.skills.length} skills)`),i.description&&console.error(` ${l.dim(i.description)}`),console.error("");for(let d of i.skills){let p=d.version?` v${d.version}`:"";console.error(` ${l.cyan(d.name)}${l.dim(p)} ${l.dim(`-> ${d.installUrl}`)}`)}if(!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
921
|
+
${l.bold("Install all skills from this bundle?")} [y/N] `);let d=await K();d.toLowerCase()!=="y"&&d.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let r=[],n=await j(),{provider:o}=await be(n,e.flags.provider,!1),a=e.flags.scope==="global"||e.flags.scope==="project"?e.flags.scope:"global";for(let d of i.skills){console.error(`
|
|
922
|
+
Installing ${l.bold(d.name)}...`);try{(d.installUrl.startsWith("github:")||d.installUrl.startsWith("https://github.com/"))&&await Ce();let m=ce(d.installUrl),y=!!m.isLocal,h=null;try{let g,b;if(y)g=m.localPath,b=m.localPath;else{he(m,d.installUrl),h=await Le(m,e.flags.transport),g=h,b=m.subpath?Lx(h,m.subpath):h;try{Fe(h,b,d.installUrl)}catch(x){throw await Q(h),h=null,x}}let k=await ye(b),S=ge(d.name||k.name||m.repo),v=Os(m,g,b,S,o,e.flags.force,a);try{await ta(v.targetDir,v.force)}catch(x){if(x.message?.includes("--force")){r.push({name:d.name,status:"skipped",reason:"Already installed. Use --force to overwrite."}),console.error(` ${l.dim("---")} ${d.name} skipped (already installed)`);continue}throw x}await Mt(v),r.push({name:d.name,status:"installed"}),console.error(` ${l.green("+++")} ${d.name} installed`)}finally{h&&await Q(h)}}catch(p){r.push({name:d.name,status:"failed",reason:p.message}),console.error(` ${l.red("!!!")} ${d.name}: ${p.message}`)}}let c=r.filter(d=>d.status==="installed").length,u=r.filter(d=>d.status==="skipped").length,f=r.filter(d=>d.status==="failed").length;e.flags.json?console.log(JSON.stringify({bundleName:i.name,total:r.length,installed:c,skipped:u,failed:f,results:r},null,2)):(console.error(""),console.error(`${l.bold("Summary:")} ${r.length} total, ${l.green(String(c))} installed, `+(u>0?`${l.dim(String(u))} skipped, `:"")+`${l.red(String(f))} failed`)),f>0&&(process.exitCode=1);break}case"list":{if(!!e.flags.predefined){let r=await Gm();if(r.length===0){e.flags.json?console.log("[]"):console.log("No predefined bundles found.");return}if(e.flags.json)console.log(JSON.stringify(r,null,2));else{console.error(l.bold(`Pre-defined Bundles (${r.length}):
|
|
923
|
+
`));for(let n of r){let o=n.tags&&n.tags.length>0?` ${l.dim(`[${n.tags.join(", ")}]`)}`:"";console.error(` ${l.cyan(n.name)} ${l.dim(`(${n.skills.length} skills)`)}${o}`),n.description&&console.error(` ${l.dim(n.description)}`)}console.error(`
|
|
924
|
+
${l.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await Jm();if(i.length===0){e.flags.json?console.log("[]"):(console.log("No bundles found."),console.error(l.dim("Create one with: asm bundle create <name>")),console.error(l.dim("List pre-defined bundles with: asm bundle list --predefined")));return}if(e.flags.json)console.log(JSON.stringify(i,null,2));else{console.error(l.bold(`Saved Bundles (${i.length}):
|
|
925
|
+
`));for(let r of i){let n=r.tags&&r.tags.length>0?` ${l.dim(`[${r.tags.join(", ")}]`)}`:"";console.error(` ${l.cyan(r.name)} ${l.dim(`(${r.skills.length} skills)`)}${n}`),r.description&&console.error(` ${l.dim(r.description)}`),r.author&&console.error(` ${l.dim(`by ${r.author}`)}`)}}break}case"show":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle show <name|file>"),process.exit(2));let i;try{i=await ti(s)}catch(r){$(r.message),process.exit(1)}if(e.flags.json)console.log(JSON.stringify(i,null,2));else{console.error(l.bold(`Bundle: ${i.name}`)),i.description&&console.error(` ${i.description}`),i.author&&console.error(` ${l.dim(`Author: ${i.author}`)}`),console.error(` ${l.dim(`Created: ${new Date(i.createdAt).toLocaleString()}`)}`),i.tags&&i.tags.length>0&&console.error(` ${l.dim(`Tags: ${i.tags.join(", ")}`)}`),console.error(`
|
|
926
|
+
${l.bold(`Skills (${i.skills.length})`)}:`);for(let r of i.skills){let n=r.version?` v${r.version}`:"";console.error(` ${l.cyan(r.name)}${l.dim(n)}`),r.description&&console.error(` ${l.dim(r.description)}`),console.error(` ${l.dim(`install: ${r.installUrl}`)}`)}}break}case"remove":{let s=e.positional[0];if(s||($("Missing required argument: <name>"),console.error("Usage: asm bundle remove <name>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${l.bold("Remove bundle")} ${l.cyan(s)}${l.bold("?")} [y/N] `);let r=await K();r.toLowerCase()!=="y"&&r.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await Wm(s)}catch(r){$(r.message),process.exit(1)}i?console.error(l.green(`Bundle "${s}" removed.`)):($(`Bundle "${s}" not found.`),process.exit(1));break}case"modify":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle modify <name> [--add <installUrl>] [--remove <skillName>] [--description <desc>] [--author <author>] [--tags <tag,...>]"),process.exit(2));let i;try{i=await ti(s)}catch(d){$(d.message),process.exit(1)}let r=!1,n=e.flags.add;if(n){let d={name:n.split("/").pop()?.replace(/\.json$/,"")??n,installUrl:n};i.skills.push(d),r=!0,console.error(l.green(`Added skill from ${n}`))}let o=e.flags.remove;if(o){let d=i.skills.length;i.skills=i.skills.filter(p=>p.name.toLowerCase()!==o.toLowerCase()),i.skills.length<d?(r=!0,console.error(l.green(`Removed skill "${o}"`))):console.error(l.dim(`Skill "${o}" not found in bundle (no change)`))}let a=e.flags.description;a!==null&&(i.description=a,r=!0);let c=e.flags.author;c!==null&&(i.author=c,r=!0);let u=e.flags.tags;if(u!==null&&(i.tags=u.split(",").map(d=>d.trim()).filter(d=>d.length>0),r=!0),!r&&process.stdin.isTTY&&!e.flags.yes&&!n&&!o&&a===null&&c===null&&u===null){console.error(l.bold(`Modifying bundle "${i.name}"`)),console.error(` Current skills: ${i.skills.map(y=>y.name).join(", ")}`),console.error(` Description: ${i.description}`),console.error(` Author: ${i.author}`),console.error(` Tags: ${i.tags?.join(", ")??"(none)"}`),console.error(""),process.stderr.write(`${l.bold("New description")} (Enter to keep current): `);let d=await K();d.trim()&&(i.description=d.trim(),r=!0),process.stderr.write(`${l.bold("New author")} (Enter to keep current): `);let p=await K();p.trim()&&(i.author=p.trim(),r=!0),process.stderr.write(`${l.bold("New tags (comma-separated)")} (Enter to keep current): `);let m=await K();m.trim()&&(i.tags=m.split(",").map(y=>y.trim()).filter(y=>y.length>0),r=!0)}if(!r){console.error(l.dim("No changes made to bundle."));break}i.skills.length===0&&($("Bundle must contain at least one skill after modification."),process.exit(1));let f=await dl(i);e.flags.json?console.log(JSON.stringify(i,null,2)):(console.error(l.green(`Bundle "${i.name}" updated (${i.skills.length} skill(s)).`)),console.error(` Saved to: ${l.dim(f)}`));break}case"export":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle export <name> [output-file]"),process.exit(2));let i;try{i=await ti(s)}catch(c){$(c.message),process.exit(1)}let r=e.positional[1]??`./${s}.json`,{resolve:n}=await import("path"),o=n(r);if(!e.flags.force){let{access:c}=await import("fs/promises");try{if(await c(o),process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`File ${l.bold(o)} already exists. Overwrite? [y/N] `);let u=await K();u.toLowerCase()!=="y"&&u.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}else e.flags.yes||($(`File "${o}" already exists. Use --force to overwrite.`),process.exit(1))}catch{}}let{writeFile:a}=await import("fs/promises");await a(o,JSON.stringify(i,null,2)+`
|
|
927
|
+
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(l.green(`Exported to ${o}`));break}default:$(`Unknown subcommand: "${t}". Use: create, install, list, show, remove, modify, or export`),console.error('Run "asm bundle --help" for usage.'),process.exit(2)}}import{readFile as Rx,realpath as Nx}from"fs/promises";import{join as Tx,resolve as Ox,relative as Mx}from"path";function Jr(e){return e.replace(/\x1b\[[0-9;]*[a-zA-Z]/g,"").replace(/\x1b\][^\x07]*\x07/g,"").replace(/\x1b[^[\]]/g,"").replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F]/g,"")}function Dx(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/</g,"<").replace(/>/g,">").replace(/\|/g,"\\|")}function fl(e){return Dx(Jr(e))}var wt="luongnv89/asm-registry";async function _x(e){let t=Tx(e,"SKILL.md"),s;try{s=await Rx(t,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}. Run "asm init" to create one.`)}let i=W(s);if(!i.name)throw new Error("SKILL.md is missing required field: name");if(!i.description)throw new Error("SKILL.md is missing required field: description");let r=de(i),n=i.tags?i.tags.split(/[\s,]+/).map(o=>o.trim().toLowerCase()).filter(Boolean):[];return{name:i.name,description:i.description.replace(/\s*\n\s*/g," ").trim(),version:r,license:i.license||"MIT",creator:i.creator||"",tags:n}}async function Fx(e){let{exitCode:t}=await ne(["git","rev-parse","--git-dir"],{cwd:e});if(t!==0)throw new Error(`${e} is not inside a git repository.`)}async function jx(e){let{stdout:t,exitCode:s}=await ne(["git","rev-parse","HEAD"],{cwd:e});if(s!==0)throw new Error("Failed to get HEAD commit. Is this a git repository?");return t.trim()}async function qx(e){let{stdout:t,exitCode:s}=await ne(["git","rev-parse","--show-toplevel"],{cwd:e});if(s!==0)throw new Error("Failed to determine git repository root.");return t.trim()}async function Bx(e){let{stdout:t,exitCode:s}=await ne(["git","remote","get-url","origin"],{cwd:e});if(s!==0)throw new Error("No remote origin found. Add one with: git remote add origin <url>");let i=t.trim(),r=i.match(/^git@github\.com:([a-zA-Z0-9_-]+)\/([a-zA-Z0-9._-]+?)(?:\.git)?$/);return r?`https://github.com/${r[1]}/${r[2]}`:i.replace(/\.git$/,"")}async function Ux(){let{exitCode:e}=await ne(["gh","--version"]);if(e!==0)return{available:!1,authenticated:!1,login:null};let{exitCode:t}=await ne(["gh","auth","status"]);if(t!==0)return{available:!0,authenticated:!1,login:null};let{stdout:s,exitCode:i}=await ne(["gh","api","user","--jq",".login"]);return{available:!0,authenticated:!0,login:i===0?s.trim():null}}function Vx(e){switch(e){case"safe":case"caution":return"pass";case"warning":return"warning";case"dangerous":return"dangerous"}}function zm(e){let t={name:e.metadata.name,author:e.author,description:e.metadata.description,repository:e.repository,commit:e.commit,security_verdict:e.securityVerdict,published_at:new Date().toISOString()};return e.skillPath&&(t.skill_path=e.skillPath),e.metadata.version&&e.metadata.version!=="0.0.0"&&/^\d+\.\d+\.\d+/.test(e.metadata.version)&&(t.version=e.metadata.version),e.metadata.license&&(t.license=e.metadata.license),e.metadata.tags&&e.metadata.tags.length>0&&(t.tags=e.metadata.tags.slice(0,10)),t}function Kx(e){let t=zm({metadata:e.metadata,author:e.metadata.creator||"unknown",commit:e.commit,repository:e.repository,securityVerdict:e.registryVerdict}),s=$r(t);return s.length>0?{success:!1,manifest:t,prUrl:null,error:`Manifest validation failed: ${s.map(i=>`${i.field}: ${i.message}`).join("; ")}`,securityVerdict:e.registryVerdict,securityReport:e.securityReport}:{success:!0,manifest:t,prUrl:null,error:null,securityVerdict:e.registryVerdict,securityReport:e.securityReport,fallback:!0,fallbackReason:e.fallbackReason}}async function Xm(e){let t=Ox(e.path);A(`publish: starting for ${t}`),await Fx(t);let s=await _x(t);A(`publish: parsed metadata for "${s.name}"`);let r=await(e._auditFn??Ne)(t,s.name),n=Vx(r.verdict);if(n==="dangerous")return{success:!1,manifest:null,prUrl:null,error:`Security audit verdict: dangerous. ${r.verdictReason}`,securityVerdict:n,securityReport:r};if(n==="warning"&&!e.force)return{success:!1,manifest:null,prUrl:null,error:"Security audit verdict: warning. Use --force to override warnings.",securityVerdict:n,securityReport:r};let o=await jx(t),a=await Bx(t),c=await qx(t),u=await Nx(t),f=Mx(c,u),d=f&&f!=="."?f:void 0,m=await(e._checkGhCliFn??Ux)();if(!m.available||!m.authenticated){let T=m.available?"gh CLI not authenticated":"gh CLI not found";return Kx({metadata:s,commit:o,repository:a,registryVerdict:n,securityReport:r,fallbackReason:T})}if(!m.login)throw new Error("Could not determine GitHub username. The gh CLI is authenticated but the API call failed. Check your network connection and try again.");let y=m.login,h=zm({metadata:s,author:y,commit:o,repository:a,skillPath:d,securityVerdict:n}),g=$r(h);if(g.length>0)return{success:!1,manifest:h,prUrl:null,error:`Manifest validation failed: ${g.map(T=>`${T.field}: ${T.message}`).join("; ")}`,securityVerdict:n,securityReport:r};if(e.dryRun)return{success:!0,manifest:h,prUrl:null,error:null,securityVerdict:n,securityReport:r};if(!e.yes){if(!process.stdin.isTTY)return{success:!1,manifest:h,prUrl:null,error:"Cannot prompt for confirmation in non-interactive mode. Use --yes to skip.",securityVerdict:n,securityReport:r};let T=Jr(s.name),M=Jr(y);process.stderr.write(`
|
|
928
|
+
About to publish "${T}" by ${M} to ${wt}.
|
|
929
|
+
Security verdict: ${n}
|
|
930
|
+
|
|
931
|
+
Proceed? [y/N] `);let te=await new Promise(re=>{let ue="",Kt=Oe=>{ue+=Oe.toString(),ue.includes(`
|
|
932
|
+
`)&&(process.stdin.removeListener("data",Kt),process.stdin.pause(),re(ue.trim()))};process.stdin.resume(),process.stdin.on("data",Kt)});if(te.toLowerCase()!=="y"&&te.toLowerCase()!=="yes")return{success:!1,manifest:h,prUrl:null,error:"Publish aborted by user.",securityVerdict:n,securityReport:r}}A(`publish: forking ${wt}`),await ne(["gh","repo","fork",wt,"--clone=false"]);let b=`publish/${y}/${s.name}`,k=`manifests/${y}/${s.name}.json`,S=JSON.stringify(h,null,2)+`
|
|
933
|
+
`,v=Buffer.from(S,"utf-8").toString("base64"),{stdout:x,exitCode:I}=await ne(["gh","api",`repos/${y}/asm-registry/git/refs/heads/main`,"--jq",".object.sha"]);if(I!==0)return{success:!1,manifest:h,prUrl:null,error:`Failed to read fork's main branch. Ensure the fork exists at ${y}/asm-registry.`,securityVerdict:n,securityReport:r};let L=x.trim(),{exitCode:E}=await ne(["gh","api",`repos/${y}/asm-registry/git/refs`,"-X","POST","-f",`ref=refs/heads/${b}`,"-f",`sha=${L}`]);E!==0&&await ne(["gh","api",`repos/${y}/asm-registry/git/refs/heads/${b}`,"-X","PATCH","-f",`sha=${L}`,"-f","force=true"]);let{stderr:F,exitCode:O}=await ne(["gh","api",`repos/${y}/asm-registry/contents/${k}`,"-X","PUT","-f",`message=Publish ${y}/${s.name}`,"-f",`content=${v}`,"-f",`branch=${b}`]);if(O!==0){let{stdout:T,exitCode:M}=await ne(["gh","api",`repos/${y}/asm-registry/contents/${k}?ref=${b}`,"-q",".sha"]),te=T.trim();if(M===0&&te){let{exitCode:re}=await ne(["gh","api",`repos/${y}/asm-registry/contents/${k}`,"-X","PUT","-f",`message=Update ${y}/${s.name}`,"-f",`content=${v}`,"-f",`branch=${b}`,"-f",`sha=${te}`]);if(re!==0)return{success:!1,manifest:h,prUrl:null,error:"Failed to write manifest to registry fork.",securityVerdict:n,securityReport:r}}else return{success:!1,manifest:h,prUrl:null,error:`Failed to write manifest to registry fork. ${F}`,securityVerdict:n,securityReport:r}}let w=fl(s.name),P=fl(s.description),q=fl(s.license),ee=`Publish ${y}/${Jr(s.name)}`,le=[`## Skill: ${w}`,"",`**Author:** ${y}`,`**Version:** ${s.version}`,`**Description:** ${P}`,`**License:** ${q}`,`**Repository:** ${a}`,`**Commit:** \`${o}\``,`**Security verdict:** ${n}`,"","---","","*This PR was generated by `asm publish`.*"].join(`
|
|
934
|
+
`),{stdout:$e,stderr:R,exitCode:C}=await ne(["gh","pr","create","--repo",wt,"--head",`${y}:${b}`,"--title",ee,"--body",le]),_=null;if(C===0)_=$e.trim();else{let T=R.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/);T&&(_=T[0])}return _?{success:!0,manifest:h,prUrl:_,error:null,securityVerdict:n,securityReport:r}:{success:!1,manifest:h,prUrl:null,error:`Failed to create PR against ${wt}. ${R}`,securityVerdict:n,securityReport:r}}function Qm(e){let t=e.manifest;return t?["",` gh CLI is unavailable (${e.fallbackReason}).`," To publish manually:","",` 1. Fork ${wt} on GitHub`,` 2. Create branch: publish/${t.author}/${t.name}`,` 3. Add file: manifests/${t.author}/${t.name}.json`," 4. Paste the manifest below into that file",` 5. Open a PR against ${wt}`,"",' Run "asm doctor" to fix your environment.',""," Generated manifest:",JSON.stringify(t,null,2).split(`
|
|
935
|
+
`).map(i=>` ${i}`).join(`
|
|
936
|
+
`)].join(`
|
|
937
|
+
`):""}function Gx(){console.log(`${l.bold("Usage:")} asm publish [path] [options]
|
|
938
|
+
|
|
939
|
+
Validate a skill, run a security audit, generate a registry manifest,
|
|
940
|
+
and open a PR against the asm-registry.
|
|
941
|
+
|
|
942
|
+
${l.bold("Arguments:")}
|
|
943
|
+
path Path to skill directory (default: current directory)
|
|
944
|
+
|
|
945
|
+
${l.bold("Options:")}
|
|
946
|
+
--dry-run Print generated manifest without opening a PR
|
|
947
|
+
--force Override 'warning' security verdict (blocks 'dangerous')
|
|
948
|
+
-y, --yes Skip confirmation prompts
|
|
949
|
+
--json Output result as JSON
|
|
950
|
+
--machine Output in stable machine-readable v1 envelope format
|
|
951
|
+
--no-color Disable ANSI colors
|
|
952
|
+
-V, --verbose Show debug output
|
|
953
|
+
|
|
954
|
+
${l.bold("Examples:")}
|
|
955
|
+
asm publish ${l.dim("Publish skill in current directory")}
|
|
956
|
+
asm publish ./my-skill ${l.dim("Publish skill at the given path")}
|
|
957
|
+
asm publish --dry-run ${l.dim("Preview manifest without side effects")}
|
|
958
|
+
asm publish --force ${l.dim("Override warning-level security findings")}
|
|
959
|
+
asm publish --json ${l.dim("Output as JSON")}
|
|
960
|
+
asm publish --machine ${l.dim("Machine-readable v1 envelope output")}`)}async function Zm(e){if(e.flags.help){Gx();return}let t=e.flags.machine?me():void 0,s=performance.now(),i=e.subcommand||".";try{let r=await Xm({path:i,dryRun:e.flags.dryRun,force:e.flags.force,yes:e.flags.yes});if(e.flags.machine){t?.(),r.success||(console.log(z("publish",Y.PUBLISH_FAILED,r.error||"Publish failed",s,{manifest:r.manifest,security_verdict:r.securityVerdict,fallback:r.fallback??!1})),process.exit(1)),console.log(G("publish",{manifest:r.manifest,pr_url:r.prUrl,status:r.securityVerdict},s));return}if(e.flags.json){console.log(JSON.stringify({success:r.success,manifest:r.manifest,pr_url:r.prUrl,error:r.error,security_verdict:r.securityVerdict},null,2)),r.success||process.exit(1);return}if(r.success||($(r.error||"Publish failed."),process.exit(1)),r.fallback){console.log(l.yellow("Manifest generated (gh CLI unavailable):")),console.log(Qm(r));return}if(e.flags.dryRun){console.error(l.dim(`Dry run \u2014 no PR created.
|
|
961
|
+
`)),console.log(JSON.stringify(r.manifest,null,2));return}r.prUrl&&(console.error(l.green("Published successfully!")),console.error(""),console.error(` PR: ${r.prUrl}`),console.error(` Manifest: manifests/${r.manifest?.author}/${r.manifest?.name}.json`),console.error(` Security: ${r.securityVerdict}`),console.error(""),console.error(l.dim("The registry maintainers will review your submission.")))}catch(r){e.flags.machine&&(t?.(),console.log(z("publish",Y.PUBLISH_FAILED,r.message,s)),process.exit(1)),e.flags.json&&(console.log(JSON.stringify({success:!1,manifest:null,pr_url:null,error:r.message,security_verdict:null},null,2)),process.exit(1)),$(r.message),process.exit(1)}}function Hx(){console.log(`${l.bold("Usage:")} asm outdated [options]
|
|
962
|
+
|
|
963
|
+
Show which installed skills have newer versions available.
|
|
964
|
+
|
|
965
|
+
${l.bold("Options:")}
|
|
966
|
+
--json Output as JSON
|
|
967
|
+
--machine Output in stable machine-readable format
|
|
968
|
+
--no-color Disable ANSI colors
|
|
969
|
+
-V, --verbose Show debug output
|
|
970
|
+
|
|
971
|
+
${l.bold("Examples:")}
|
|
972
|
+
asm outdated ${l.dim("Show outdated skills")}
|
|
973
|
+
asm outdated --json ${l.dim("Output as JSON")}
|
|
974
|
+
asm outdated --machine ${l.dim("Machine-readable output")}`)}async function eh(e){if(e.flags.help){Hx();return}let t=e.flags.machine?me():void 0,s=performance.now();try{let i=await qs();if(e.flags.machine){t?.();let n=i.entries.map(o=>({name:o.name,installed_commit:o.installedCommit,latest_commit:o.latestCommit,source:o.sourceType,status:o.status}));console.log(G("outdated",n,s));return}if(e.flags.json){console.log(Aa(i));return}let r=!e.flags.noColor&&process.stdout.isTTY!==!1;console.log(La(i,r)),i.outdatedCount>0&&(process.exitCode=1)}catch(i){e.flags.machine&&(t?.(),console.log(z("outdated",Y.UNKNOWN_ERROR,i.message,s)),process.exit(1)),$(i.message),process.exit(1)}}function Jx(){console.log(`${l.bold("Usage:")} asm update [name...] [options]
|
|
975
|
+
|
|
976
|
+
Update outdated skills to their latest version with security re-audit.
|
|
977
|
+
|
|
978
|
+
${l.bold("Arguments:")}
|
|
979
|
+
name Specific skill(s) to update (default: all outdated)
|
|
980
|
+
|
|
981
|
+
${l.bold("Options:")}
|
|
982
|
+
-y, --yes Skip confirmation prompts
|
|
983
|
+
--json Output as JSON
|
|
984
|
+
--machine Output in stable machine-readable format
|
|
985
|
+
--no-color Disable ANSI colors
|
|
986
|
+
-V, --verbose Show debug output
|
|
987
|
+
|
|
988
|
+
${l.bold("Examples:")}
|
|
989
|
+
asm update ${l.dim("Update all outdated skills")}
|
|
990
|
+
asm update code-review ${l.dim("Update a specific skill")}
|
|
991
|
+
asm update --yes ${l.dim("Skip confirmation prompts")}
|
|
992
|
+
asm update --json ${l.dim("Output as JSON")}`)}async function th(e){if(e.flags.help){Jx();return}let t=e.flags.machine?me():void 0,s=performance.now(),i=[];e.subcommand&&i.push(e.subcommand),i.push(...e.positional);try{let r=await Ca(i.length>0?i:null,e.flags.yes);if(e.flags.machine){t?.();let o=r.results.map(a=>({name:a.name,status:a.status,reason:a.reason||null,old_commit:a.oldCommit||null,new_commit:a.newCommit||null,security_verdict:a.securityVerdict||null}));console.log(G("update",o,s));return}if(e.flags.json){console.log(Ra(r));return}if(r.results.length>0&&console.error(l.yellow("Note: project-scoped skill detection is not yet supported. All updates target the global skill path.")),r.warnings&&r.warnings.length>0)for(let o of r.warnings)console.error(l.yellow(`Warning: skill "${o}" not found in lock file \u2014 skipped`));if(r.results.length===0){console.log("All skills are up to date.");return}for(let o of r.results)switch(o.status){case"updated":console.log(`${l.green("\u2713")} ${o.name} ${l.dim(o.oldCommit||"")} \u2192 ${o.newCommit||""}`),o.securityVerdict==="warning"&&console.error(l.yellow(` \u26A0 Security audit returned warning for ${o.name} \u2014 updated because --yes was supplied`));break;case"skipped":console.log(`${l.yellow("\u25CB")} ${o.name} ${l.dim(o.reason||"skipped")}`);break;case"failed":console.log(`${l.red("\u2717")} ${o.name} ${l.dim(o.reason||"failed")}`);break}console.log("");let n=[];r.updatedCount>0&&n.push(l.green(`${r.updatedCount} updated`)),r.skippedCount>0&&n.push(l.yellow(`${r.skippedCount} skipped`)),r.failedCount>0&&n.push(l.red(`${r.failedCount} failed`)),console.log(n.join(", ")),r.failedCount>0&&(process.exitCode=1)}catch(r){e.flags.machine&&(t?.(),console.log(z("update",Y.UNKNOWN_ERROR,r.message,s)),process.exit(1)),$(r.message),process.exit(1)}}import{execFile as Wx}from"child_process";import{promisify as Yx}from"util";import{access as sh,readFile as rh,readdir as zx,writeFile as Xx,rm as Qx,stat as nh}from"fs/promises";import{join as pl}from"path";import{homedir as Zx}from"os";import{constants as ih}from"fs";var Vt=Yx(Wx);async function e0(e){let t=e?.execFn??Vt;try{let{stdout:s}=await t("git",["--version"],{timeout:5e3});return{name:"Git available",status:"pass",message:s.trim().replace("git version ","")}}catch{return{name:"Git available",status:"fail",message:"git not found",fix:"Install git: https://git-scm.com/downloads"}}}async function t0(e){let t=e?.execFn??Vt;try{let{stdout:s}=await t("git",["--version"],{timeout:5e3}),i=s.match(/(\d+)\.(\d+)/);if(!i)return{name:"Git version",status:"warn",message:"Could not parse git version",fix:"Upgrade git: https://git-scm.com/downloads"};let r=parseInt(i[1],10),n=parseInt(i[2],10);return r>2||r===2&&n>=20?{name:"Git version",status:"pass",message:`${r}.${n} (>= 2.20)`}:{name:"Git version",status:"fail",message:`${r}.${n} (requires >= 2.20)`,fix:"Upgrade git: https://git-scm.com/downloads"}}catch{return{name:"Git version",status:"pass",message:"Skipped \u2014 git not available"}}}async function s0(e){let t=e?.execFn??Vt;try{let{stdout:s}=await t("gh",["--version"],{timeout:5e3}),i=s.trim().split(`
|
|
993
|
+
`)[0],r=i.match(/(\d+\.\d+\.\d+)/);return{name:"GitHub CLI available",status:"pass",message:r?r[1]:i}}catch{return{name:"GitHub CLI available",status:"fail",message:"gh not found",fix:"Install GitHub CLI: https://cli.github.com"}}}async function i0(e){let t=e?.execFn??Vt;try{let{stdout:s}=await t("gh",["auth","status"],{timeout:1e4}),i=s.match(/Logged in to .+ account (\S+)/);return{name:"GitHub CLI authenticated",status:"pass",message:i?i[1]:"authenticated"}}catch(s){let r=(s?.stderr??"").match(/Logged in to .+ account (\S+)/);return r?{name:"GitHub CLI authenticated",status:"pass",message:r[1]}:{name:"GitHub CLI authenticated",status:"fail",message:"Not authenticated",fix:"Run: gh auth login"}}}async function r0(e){let t=e?.execFn??Vt;try{let{stdout:s}=await t("node",["--version"],{timeout:5e3}),i=s.trim().replace(/^v/,"");return parseInt(i.split(".")[0],10)>=22?{name:"Node.js version",status:"pass",message:i}:{name:"Node.js version",status:"fail",message:`${i} (requires >= 22.0)`,fix:"Upgrade Node.js: https://nodejs.org"}}catch{return{name:"Node.js version",status:"fail",message:"node not found",fix:"Install Node.js >= 22: https://nodejs.org"}}}async function n0(e){try{let t=pl(e,".asm-doctor-write-test");return await Xx(t,"test","utf-8"),await Qx(t),{writable:!0,exists:!0}}catch{}try{return await sh(e,ih.W_OK),{writable:!0,exists:!0}}catch{}try{return await sh(e,ih.F_OK),{writable:!1,exists:!0}}catch{return{writable:!0,exists:!1}}}async function o0(e){let t=e.providers.filter(n=>n.enabled),s=0,i=0;for(let n of t){let o=se(n.global);i++,(await n0(o)).writable&&s++}if(s===i)return{name:"Agent directories writable",status:"pass",message:`${s}/${i} providers`};let r=i-s;return{name:"Agent directories writable",status:"warn",message:`${s}/${i} providers (${r} not writable)`,fix:"Fix permissions on agent skill directories"}}async function a0(){let e=Wt();try{let t=await rh(e,"utf-8"),s=JSON.parse(t),i=[];return s.version===void 0&&i.push("version"),Array.isArray(s.providers)||i.push("providers"),i.length>0?{name:"Config file valid",status:"fail",message:`Missing required fields: ${i.join(", ")}`,fix:"Run: asm init"}:{name:"Config file valid",status:"pass",message:"OK"}}catch(t){return t?.code==="ENOENT"?{name:"Config file valid",status:"pass",message:"No config file (using defaults)"}:{name:"Config file valid",status:"fail",message:"Corrupted or unreadable config",fix:"Run: asm init, or delete corrupted config"}}}async function l0(){let e=El();try{let t=await rh(e,"utf-8"),s=JSON.parse(t);if(s.version!==1||typeof s.skills!="object")return{name:"Lock file integrity",status:"fail",message:"Invalid lock file schema",fix:"Run: asm install to regenerate"};let i=s.skills,r=Object.entries(i),n=["source","installedAt","provider"],o=[];for(let[a,c]of r){if(typeof c!="object"||c===null){o.push(a);continue}let u=c;for(let f of n)if(!u[f]){o.push(a);break}}return o.length>0?{name:"Lock file integrity",status:"warn",message:`${r.length} skills tracked, ${o.length} with missing fields`,fix:"Run: asm install to regenerate"}:{name:"Lock file integrity",status:"pass",message:`${r.length} skills tracked`}}catch(t){return t?.code==="ENOENT"?{name:"Lock file integrity",status:"pass",message:"No lock file (first-time user)"}:{name:"Lock file integrity",status:"fail",message:"Corrupted lock file",fix:"Run: asm install to regenerate"}}}async function c0(){try{let e=await fetch(ra,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return e.ok?{name:"Registry reachable",status:"pass",message:"OK"}:{name:"Registry reachable",status:"fail",message:`HTTP ${e.status}`,fix:"Check network connection or proxy settings"}}catch{return{name:"Registry reachable",status:"fail",message:"Network error",fix:"Check network connection or proxy settings"}}}async function u0(e,t){let s=Object.entries(t.skills);if(s.length===0)return{name:"Installed skills intact",status:"pass",message:"No skills in lock file"};let i=[];for(let[o,a]of s){let c=e.providers.find(d=>d.name===a.provider);if(!c){i.push(o);continue}let u=se(c.global),f=pl(u,o);try{(await nh(f)).isDirectory()||i.push(o)}catch{i.push(o)}}if(i.length===0)return{name:"Installed skills intact",status:"pass",message:`${s.length} skills verified`};let r=i[0],n=i.length>1?` (+${i.length-1} more)`:"";return{name:"Installed skills intact",status:"fail",message:`Missing: ${r}${n}`,fix:`Run: asm update ${r}`}}async function d0(e,t){let s=new Set(Object.keys(t.skills)),i=[];for(let r of e.providers.filter(n=>n.enabled)){let n=se(r.global);try{let o=await zx(n);for(let a of o)try{(await nh(pl(n,a))).isDirectory()&&!s.has(a)&&i.push(a)}catch{}}catch{}}return i.length===0?{name:"No orphaned skills",status:"pass",message:"OK"}:{name:"No orphaned skills",status:"warn",message:`${i.length} skill(s) without lock entries`,fix:"Run: asm list to review"}}async function f0(e){let t=e?.execFn??Vt;try{let{stdout:s}=await t("df",["-Pk",Zx()],{timeout:5e3}),i=s.trim().split(`
|
|
994
|
+
`);if(i.length<2)return{name:"Disk space",status:"warn",message:"Could not parse df output"};let r=i[1].split(/\s+/),n=parseInt(r[3],10);if(isNaN(n))return{name:"Disk space",status:"warn",message:"Could not parse available space"};let o=n/1024,a=o/1024;return o>100?{name:"Disk space",status:"pass",message:`OK (${a>=1?`${a.toFixed(1)} GB free`:`${Math.round(o)} MB free`})`}:{name:"Disk space",status:"fail",message:`${Math.round(o)} MB free (requires > 100 MB)`,fix:"Free disk space in home directory"}}catch{return{name:"Disk space",status:"warn",message:"Could not check disk space"}}}async function p0(){try{let e=await mi();if(e.shadowed.length===0)return e.resolved?{name:"No PATH shadowing",status:"pass",message:`single install at ${e.resolved.path}`}:{name:"No PATH shadowing",status:"pass",message:"asm not yet on PATH"};let t=e.resolved,s=e.shadowed[0].path,i=e.shadowed.length>1?` (+${e.shadowed.length-1} more)`:"";return{name:"No PATH shadowing",status:"warn",message:`resolved ${t.path}, shadowed ${s}${i}`,fix:"Remove the duplicate install (`npm uninstall -g agent-skill-manager`) and keep only one."}}catch(e){return{name:"No PATH shadowing",status:"warn",message:`Could not scan PATH: ${e?.message??e}`}}}async function oh(){let e=await j(),t=await Be(),i=(await Promise.allSettled([e0(),t0(),s0(),i0(),r0(),o0(e),a0(),l0(),c0(),u0(e,t),d0(e,t),f0(),p0()])).map((a,c)=>a.status==="fulfilled"?a.value:{name:["Git available","Git version","GitHub CLI available","GitHub CLI authenticated","Node.js version","Agent directories writable","Config file valid","Lock file integrity","Registry reachable","Installed skills intact","No orphaned skills","Disk space","No PATH shadowing"][c],status:"fail",message:`Check threw: ${a.reason}`}),r=i.filter(a=>a.status==="pass").length,n=i.filter(a=>a.status==="warn").length,o=i.filter(a=>a.status==="fail").length;return{checks:i,passed:r,warnings:n,failures:o}}var m0={pass:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function ah(e){let t=["Checking your environment...",""];for(let s of e.checks){let r=` ${m0[s.status]} ${s.name}${s.message?` (${s.message})`:""}`;if(t.push(r),s.fix&&s.status!=="pass"){let n;s.fix.startsWith("Run: ")?n=s.fix:/^[a-z/~]/.test(s.fix)?n=`Run: ${s.fix}`:n=`Fix: ${s.fix}`,t.push(` \u2192 ${n}`)}}return t.push(""),t.push(`${e.passed} passed, ${e.warnings} warning${e.warnings!==1?"s":""}, ${e.failures} error${e.failures!==1?"s":""}`),t.join(`
|
|
995
|
+
`)}function lh(e){return JSON.stringify({checks:e.checks.map(t=>({name:t.name,status:t.status,message:t.message,...t.fix?{fix:t.fix}:{}})),summary:{passed:e.passed,warnings:e.warnings,failures:e.failures}},null,2)}function h0(){console.log(`${l.bold("Usage:")} asm doctor [options]
|
|
996
|
+
|
|
997
|
+
Run environment health checks and diagnostics. Validates all
|
|
998
|
+
prerequisites for using asm \u2014 git, GitHub CLI, Node.js, config,
|
|
999
|
+
lock file, registry, installed skills, and disk space.
|
|
1000
|
+
|
|
1001
|
+
${l.bold("Options:")}
|
|
1002
|
+
--json Output as JSON
|
|
1003
|
+
--machine Output in stable machine-readable v1 envelope format
|
|
1004
|
+
--no-color Disable ANSI colors
|
|
1005
|
+
-V, --verbose Show debug output
|
|
1006
|
+
|
|
1007
|
+
${l.bold("Examples:")}
|
|
1008
|
+
asm doctor ${l.dim("Run all health checks")}
|
|
1009
|
+
asm doctor --json ${l.dim("Output as JSON")}
|
|
1010
|
+
asm doctor --machine ${l.dim("Machine-readable v1 envelope output")}`)}async function ch(e){if(e.flags.help){h0();return}let t=performance.now(),s=await oh();if(e.flags.machine){let i={checks:s.checks.map(r=>({name:r.name,status:r.status,message:r.message,...r.fix?{fix:r.fix}:{}})),passed:s.passed,warnings:s.warnings,failures:s.failures};console.log(G("doctor",i,t))}else e.flags.json?console.log(lh(s)):console.log(ah(s));s.failures>0&&process.exit(1)}function g0(e){let t=e.slice(2),s={command:null,subcommand:null,positional:[],flags:{help:!1,version:!1,json:!1,yes:!1,noColor:!1,scope:"both",sort:"name",provider:null,name:null,force:!1,path:null,all:!1,library:!1,verbose:!1,flat:!1,transport:"auto",method:"default",installed:!1,available:!1,has:[],missing:[],modelInvocable:!1,userInvocable:!1,dryRun:!1,diff:!1,machine:!1,noCache:!1,fix:!1,compact:!1,summary:!1,groupBy:null,limit:0,concurrency:0,keep:!1,tokens:!1,add:null,remove:null,description:null,author:null,tags:null,predefined:!1,audit:!1}},i=0;for(;i<t.length;){let r=t[i];if(r==="--help"||r==="-h")s.flags.help=!0;else if(r==="--version"||r==="-v")s.flags.version=!0;else if(r==="--json")s.flags.json=!0;else if(r==="--yes"||r==="-y")s.flags.yes=!0;else if(r==="--no-color")s.flags.noColor=!0;else if(r==="--scope"||r==="-s"){i++;let n=t[i],o=n==="local"?"project":n;o==="global"||o==="project"||o==="both"?s.flags.scope=o:(Te(`Invalid scope: "${n}". Must be global, local, project, or both.`),process.exit(2))}else if(r==="--sort"){i++;let n=t[i];n==="name"||n==="version"||n==="location"?s.flags.sort=n:(Te(`Invalid sort: "${n}". Must be name, version, or location.`),process.exit(2))}else if(r==="--provider"||r==="-p"||r==="--tool")i++,s.flags.provider=t[i]||null;else if(r==="--name")i++,s.flags.name=t[i]||null;else if(r==="--force"||r==="-f")s.flags.force=!0;else if(r==="--path")i++,s.flags.path=t[i]||null;else if(r==="--all")s.flags.all=!0;else if(r==="--library")s.flags.library=!0;else if(r==="--verbose"||r==="-V")s.flags.verbose=!0;else if(r==="--flat")s.flags.flat=!0;else if(r==="--compact")s.flags.compact=!0;else if(r==="--summary")s.flags.summary=!0;else if(r==="--group-by"){i++;let n=t[i];n==="tool"||n==="scope"||n==="effort"?s.flags.groupBy=n:(Te(`Invalid --group-by: "${n}". Must be tool, scope, or effort.`),process.exit(2))}else if(r==="--limit"){i++;let n=t[i],o=Number(n);(!Number.isFinite(o)||o<0||!Number.isInteger(o))&&(Te(`Invalid --limit: "${n}". Must be a non-negative integer (0 means no limit).`),process.exit(2)),s.flags.limit=o}else if(r==="--installed")s.flags.installed=!0;else if(r==="--available")s.flags.available=!0;else if(r==="--concurrency"){i++;let n=t[i],o=Number(n);(!Number.isFinite(o)||o<1||!Number.isInteger(o))&&(Te(`Invalid --concurrency: "${n}". Must be a positive integer.`),process.exit(2)),s.flags.concurrency=o}else if(r==="--keep")s.flags.keep=!0;else if(r==="--tokens")s.flags.tokens=!0;else if(r==="--transport"||r==="-t"){i++;let n=t[i];n==="https"||n==="ssh"||n==="auto"?s.flags.transport=n:(Te(`Invalid transport: "${n}". Must be https, ssh, or auto.`),process.exit(2))}else if(r==="--method"||r==="-m"){i++;let n=t[i];n==="default"||n==="vercel"?s.flags.method=n:(Te(`Invalid method: "${n}". Must be default or vercel.`),process.exit(2))}else r==="--skill"?(i++,s.flags.path=t[i]||null):r==="--dry-run"?s.flags.dryRun=!0:r==="--diff"?s.flags.diff=!0:r==="--fix"?s.flags.fix=!0:r==="--machine"?s.flags.machine=!0:r==="--no-cache"?s.flags.noCache=!0:r==="--has"?(i++,t[i]&&s.flags.has.push(t[i])):r==="--missing"?(i++,t[i]&&s.flags.missing.push(t[i])):r==="--model-invocable"?s.flags.modelInvocable=!0:r==="--user-invocable"?s.flags.userInvocable=!0:r==="--add"?(i++,s.flags.add=t[i]||null):r==="--remove"?(i++,s.flags.remove=t[i]||null):r==="--description"?(i++,s.flags.description=t[i]||null):r==="--author"?(i++,s.flags.author=t[i]||null):r==="--tags"?(i++,s.flags.tags=t[i]||null):r==="--predefined"?s.flags.predefined=!0:r==="--audit"?s.flags.audit=!0:r.startsWith("-")?(Te(`Unknown option: ${r}`),console.error('Run "asm --help" for usage.'),process.exit(2)):s.command?s.subcommand?s.positional.push(r):s.subcommand=r:s.command=r;i++}return s}function Te(e){console.error(l.red(`Error: ${e}`))}function y0(){console.log(`${l.blueBold("agent-skill-manager")} (${l.bold("asm")}) ${en()}
|
|
1011
|
+
|
|
1012
|
+
Interactive TUI and CLI for managing installed skills for AI coding agents.
|
|
1013
|
+
|
|
1014
|
+
${l.bold("Usage:")}
|
|
1015
|
+
asm Launch interactive TUI
|
|
1016
|
+
asm <command> [options] Run a CLI command
|
|
1017
|
+
|
|
1018
|
+
${l.bold("Commands:")}
|
|
1019
|
+
list List all discovered skills
|
|
1020
|
+
search <query> Search skills by name/description/tool
|
|
1021
|
+
inspect <skill-name> Show detailed info for a skill
|
|
1022
|
+
get <skill> Print a skill's SKILL.md body (installs nothing)
|
|
1023
|
+
uninstall <skill-name> Remove a skill (with confirmation)
|
|
1024
|
+
disable <target> Disable skill(s) without uninstalling
|
|
1025
|
+
enable <target> Re-enable disabled skill(s)
|
|
1026
|
+
install <source> Install a skill from GitHub or local path
|
|
1027
|
+
activate <skill> Link a library skill into a provider
|
|
1028
|
+
deactivate <skill> Remove a library activation from a provider
|
|
1029
|
+
library Manage centrally installed library skills
|
|
1030
|
+
audit Detect duplicate skills across tools
|
|
1031
|
+
audit security <name> Run security audit on a skill (or GitHub source)
|
|
1032
|
+
export Export skill inventory as JSON manifest
|
|
1033
|
+
import <file> Import skills from a previously exported manifest
|
|
1034
|
+
init <name> Scaffold a new skill with SKILL.md template
|
|
1035
|
+
stats Show aggregate skill metrics dashboard
|
|
1036
|
+
stats repo <repo> Show per-repo stats (indexed skills)
|
|
1037
|
+
stats author <owner> Show per-author stats (indexed skills)
|
|
1038
|
+
stats index Show index-wide statistics
|
|
1039
|
+
link <path> Symlink a local skill directory into an agent
|
|
1040
|
+
outdated Show which installed skills have newer versions
|
|
1041
|
+
update [name...] Update outdated skills with security re-audit
|
|
1042
|
+
publish [path] Validate, audit, and submit a skill to the registry
|
|
1043
|
+
eval <skill-path> Evaluate a skill against best practices and score it
|
|
1044
|
+
eval-providers list List registered eval providers (id, version, schema, \u2026)
|
|
1045
|
+
bundle Manage skill bundles (create, install, list, show, remove)
|
|
1046
|
+
index Manage skill index (ingest, search, list)
|
|
1047
|
+
doctor Run environment health checks and diagnostics
|
|
1048
|
+
config show Print current config
|
|
1049
|
+
config path Print config file path
|
|
1050
|
+
config reset Reset config to defaults
|
|
1051
|
+
config edit Open config in $EDITOR
|
|
1052
|
+
|
|
1053
|
+
${l.bold("Global Options:")}
|
|
1054
|
+
-h, --help Show help for any command
|
|
1055
|
+
-v, --version Print version and exit
|
|
1056
|
+
--json Output as JSON (list, search, inspect)
|
|
1057
|
+
--machine Stable machine-readable JSON envelope (v1)
|
|
1058
|
+
-s, --scope <scope> Filter: global, project, or both (default: both)
|
|
1059
|
+
-p, --tool <name> Filter by tool (list, search)
|
|
1060
|
+
--no-color Disable ANSI colors
|
|
1061
|
+
--sort <field> Sort by: name, version, or location (default: name)
|
|
1062
|
+
--flat Show one row per tool instance (list, search)
|
|
1063
|
+
-y, --yes Skip confirmation prompts
|
|
1064
|
+
-V, --verbose Show debug output`)}async function uh(e){let t=g0(e);if(t.flags.json&&t.flags.machine&&(Te("--json and --machine are mutually exclusive. Use one or the other."),process.exit(2)),t.flags.machine&&(t.flags.yes=!0),t.flags.noColor&&(globalThis.__CLI_NO_COLOR=!0),t.flags.verbose&&xl(!0),t.flags.version){console.log(`asm ${en()}`);let s=await mi();if(t.flags.verbose&&s.resolved&&(console.log(` path: ${s.resolved.path}`),s.resolved.realPath!==s.resolved.path&&console.log(` real: ${s.resolved.realPath}`)),s.shadowed.length>0&&s.resolved){console.error(""),console.error(l.yellow(`Warning: ${s.shadowed.length+1} \`asm\` binaries on PATH \u2014 you may be running a shadowed install.`)),console.error(` resolved: ${s.resolved.path}`);for(let i of s.shadowed)console.error(` shadowed: ${i.path}`);console.error(l.dim(" Remove the stale global install (npm uninstall -g agent-skill-manager) and keep only one.")),console.error(l.dim(" See: https://github.com/luongnv89/asm#troubleshooting"))}return}if(!t.command&&t.flags.help){y0();return}if(t.command)switch(t.command){case"list":await Yd(t);break;case"search":await sf(t);break;case"inspect":await rf(t);break;case"get":await Rp(t);break;case"uninstall":await Tp(t);break;case"disable":await Jd(t);break;case"enable":await Wd(t);break;case"audit":await zp(t);break;case"install":await sl(t);break;case"activate":await sm(t);break;case"deactivate":await im(t);break;case"library":await rm(t);break;case"config":await nm(t);break;case"export":await ym(t);break;case"import":await km(t);break;case"init":await $m(t);break;case"stats":await xm(t);break;case"link":await Em(t);break;case"index":await jm(t);break;case"bundle":await Ym(t);break;case"publish":await Zm(t);break;case"outdated":await eh(t);break;case"update":await th(t);break;case"doctor":await ch(t);break;case"eval":await Lp(t);break;case"eval-providers":await Ap(t);break;default:Te(`Unknown command: "${t.command}"`),console.error('Run "asm --help" for usage.'),process.exit(2)}}function dh(e){let t=e.slice(2);if(t.length===0)return!1;let s=["list","search","inspect","get","uninstall","audit","config","install","activate","deactivate","library","export","import","init","stats","link","index","bundle","publish","outdated","update","doctor","eval","eval-providers","disable","enable"],i=t[0];return!!(s.includes(i)||i==="--help"||i==="-h"||i==="--version"||i==="-v"||i.startsWith("-")||i.length>0)}if(dh(process.argv))await uh(process.argv).catch(e=>{console.error("Fatal error:",e),process.exit(1)});else{let{main:e}=await import("./src-BD3KFE5H.js");await e().catch(t=>{console.error("Fatal error:",t),process.exit(1)})}
|