agent-skill-manager 2.8.0 → 2.9.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 +9 -5
- package/dist/agent-skill-manager.js +249 -183
- package/dist/chunk-7DMA7RUC.js +19 -0
- package/dist/{chunk-NGQYBLQE.js → chunk-APSM2WG3.js} +1 -1
- package/dist/chunk-GHPE6SB3.js +3 -0
- package/dist/config-FRM3YOMA.js +2 -0
- package/dist/{lock-MDX7A2DF.js → lock-6S53S4SC.js} +1 -1
- package/dist/{src-S3FQI2MC.js → src-H2QOCGTV.js} +1 -1
- package/package.json +1 -1
- package/dist/chunk-54DE5T53.js +0 -19
- package/dist/chunk-6PA2GSCN.js +0 -3
- package/dist/config-7PXPKO4K.js +0 -2
|
@@ -1,76 +1,76 @@
|
|
|
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 Le,b as bt,c as
|
|
4
|
-
`)}};vt.defaultYaml={explicit:!1,version:"1.2"};vt.defaultTags={"!!":"tag:yaml.org,2002:"};
|
|
5
|
-
`)?
|
|
3
|
+
import{a as Le,b as bt,c as Oo,d as To,e as Mo}from"./chunk-APSM2WG3.js";import{A as Io,D as Ro,E as Lo,F as Y,G as qi,H as Do,J as Fo,K as _o,L as jo,M as Bi,N as qo,a as te,b as ue,c as yo,d as os,g as X,h as bo,i as Mi,j as wo,k as vo,l as ko,m as Di,n as So,o as u,p as $o,q as xo,r as Eo,s as Fi,t as _i,u as ji,v as Co,w as Ao,x as as,y as Po,z as No}from"./chunk-7DMA7RUC.js";import{a as fo,b as I,c as po,d as gt,e as mo,f as Ti,g as yt,h as ho,k as oe,l as B,m as go}from"./chunk-GHPE6SB3.js";import{a as rs,b as P,d as uo}from"./chunk-7BMOBFGJ.js";var j=P(z=>{"use strict";var Xi=Symbol.for("yaml.alias"),ca=Symbol.for("yaml.document"),ys=Symbol.for("yaml.map"),ua=Symbol.for("yaml.pair"),Zi=Symbol.for("yaml.scalar"),bs=Symbol.for("yaml.seq"),ye=Symbol.for("yaml.node.type"),Df=e=>!!e&&typeof e=="object"&&e[ye]===Xi,Ff=e=>!!e&&typeof e=="object"&&e[ye]===ca,_f=e=>!!e&&typeof e=="object"&&e[ye]===ys,jf=e=>!!e&&typeof e=="object"&&e[ye]===ua,da=e=>!!e&&typeof e=="object"&&e[ye]===Zi,qf=e=>!!e&&typeof e=="object"&&e[ye]===bs;function fa(e){if(e&&typeof e=="object")switch(e[ye]){case ys:case bs:return!0}return!1}function Bf(e){if(e&&typeof e=="object")switch(e[ye]){case Xi:case ys:case Zi:case bs:return!0}return!1}var Uf=e=>(da(e)||fa(e))&&!!e.anchor;z.ALIAS=Xi;z.DOC=ca;z.MAP=ys;z.NODE_TYPE=ye;z.PAIR=ua;z.SCALAR=Zi;z.SEQ=bs;z.hasAnchor=Uf;z.isAlias=Df;z.isCollection=fa;z.isDocument=Ff;z.isMap=_f;z.isNode=Bf;z.isPair=jf;z.isScalar=da;z.isSeq=qf});var wt=P(en=>{"use strict";var J=j(),se=Symbol("break visit"),pa=Symbol("skip children"),pe=Symbol("remove node");function ws(e,t){let s=ma(t);J.isDocument(e)?Ze(null,e.contents,s,Object.freeze([e]))===pe&&(e.contents=null):Ze(null,e,s,Object.freeze([]))}ws.BREAK=se;ws.SKIP=pa;ws.REMOVE=pe;function Ze(e,t,s,i){let n=ha(e,t,s,i);if(J.isNode(n)||J.isPair(n))return ga(e,i,n),Ze(e,n,s,i);if(typeof n!="symbol"){if(J.isCollection(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){let o=Ze(r,t.items[r],s,i);if(typeof o=="number")r=o-1;else{if(o===se)return se;o===pe&&(t.items.splice(r,1),r-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let r=Ze("key",t.key,s,i);if(r===se)return se;r===pe&&(t.key=null);let o=Ze("value",t.value,s,i);if(o===se)return se;o===pe&&(t.value=null)}}return n}async function vs(e,t){let s=ma(t);J.isDocument(e)?await et(null,e.contents,s,Object.freeze([e]))===pe&&(e.contents=null):await et(null,e,s,Object.freeze([]))}vs.BREAK=se;vs.SKIP=pa;vs.REMOVE=pe;async function et(e,t,s,i){let n=await ha(e,t,s,i);if(J.isNode(n)||J.isPair(n))return ga(e,i,n),et(e,n,s,i);if(typeof n!="symbol"){if(J.isCollection(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){let o=await et(r,t.items[r],s,i);if(typeof o=="number")r=o-1;else{if(o===se)return se;o===pe&&(t.items.splice(r,1),r-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let r=await et("key",t.key,s,i);if(r===se)return se;r===pe&&(t.key=null);let o=await et("value",t.value,s,i);if(o===se)return se;o===pe&&(t.value=null)}}return n}function ma(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 ha(e,t,s,i){if(typeof s=="function")return s(e,t,i);if(J.isMap(t))return s.Map?.(e,t,i);if(J.isSeq(t))return s.Seq?.(e,t,i);if(J.isPair(t))return s.Pair?.(e,t,i);if(J.isScalar(t))return s.Scalar?.(e,t,i);if(J.isAlias(t))return s.Alias?.(e,t,i)}function ga(e,t,s){let i=t[t.length-1];if(J.isCollection(i))i.items[e]=s;else if(J.isPair(i))e==="key"?i.key=s:i.value=s;else if(J.isDocument(i))i.contents=s;else{let n=J.isAlias(i)?"alias":"scalar";throw new Error(`Cannot replace node with ${n} parent`)}}en.visit=ws;en.visitAsync=vs});var tn=P(ba=>{"use strict";var ya=j(),Vf=wt(),Kf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Jf=e=>e.replace(/[!,[\]{}]/g,t=>Kf[t]),vt=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]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(s(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return s(0,"%YAML directive should contain exactly one part"),!1;let[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return s(6,`Unsupported YAML version ${r}`,o),!1}}default:return s(0,`Unknown directive ${n}`,!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,n]=t.match(/^(.*!)([^!]*)$/s);n||s(`The ${t} tag has no suffix`);let r=this.tags[i];if(r)try{return r+decodeURIComponent(n)}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+Jf(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),n;if(t&&i.length>0&&ya.isNode(t.contents)){let r={};Vf.visit(t.contents,(o,a)=>{ya.isNode(a)&&a.tag&&(r[a.tag]=!0)}),n=Object.keys(r)}else n=[];for(let[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!t||n.some(a=>a.startsWith(o)))&&s.push(`%TAG ${r} ${o}`);return s.join(`
|
|
4
|
+
`)}};vt.defaultYaml={explicit:!1,version:"1.2"};vt.defaultTags={"!!":"tag:yaml.org,2002:"};ba.Directives=vt});var ks=P(kt=>{"use strict";var wa=j(),Hf=wt();function Wf(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 va(e){let t=new Set;return Hf.visit(e,{Value(s,i){i.anchor&&t.add(i.anchor)}}),t}function ka(e,t){for(let s=1;;++s){let i=`${e}${s}`;if(!t.has(i))return i}}function Gf(e,t){let s=[],i=new Map,n=null;return{onAnchor:r=>{s.push(r),n??(n=va(e));let o=ka(t,n);return n.add(o),o},setAnchors:()=>{for(let r of s){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(wa.isScalar(o.node)||wa.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=r,a}}},sourceObjects:i}}kt.anchorIsValid=Wf;kt.anchorNames=va;kt.createNodeAnchors=Gf;kt.findNewAnchor=ka});var sn=P(Sa=>{"use strict";function St(e,t,s,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let o=i[n],a=St(e,i,String(n),o);a===void 0?delete i[n]:a!==o&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),o=St(e,i,n,r);o===void 0?i.delete(n):o!==r&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let r=St(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let o=St(e,i,n,r);o===void 0?delete i[n]:o!==r&&(i[n]=o)}return e.call(t,s,i)}Sa.applyReviver=St});var ke=P(xa=>{"use strict";var Yf=j();function $a(e,t,s){if(Array.isArray(e))return e.map((i,n)=>$a(i,String(n),s));if(e&&typeof e.toJSON=="function"){if(!s||!Yf.hasAnchor(e))return e.toJSON(t,s);let i={aliasCount:0,count:1,res:void 0};s.anchors.set(e,i),s.onCreate=r=>{i.res=r,delete s.onCreate};let n=e.toJSON(t,s);return s.onCreate&&s.onCreate(n),n}return typeof e=="bigint"&&!s?.keep?Number(e):e}xa.toJS=$a});var Ss=P(Ca=>{"use strict";var zf=sn(),Ea=j(),Qf=ke(),nn=class{constructor(t){Object.defineProperty(this,Ea.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:n,reviver:r}={}){if(!Ea.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=Qf.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof r=="function"?zf.applyReviver(r,{"":a},"",a):a}};Ca.NodeBase=nn});var $t=P(Aa=>{"use strict";var Xf=ks(),Zf=wt(),tt=j(),ep=Ss(),tp=ke(),rn=class extends ep.NodeBase{constructor(t){super(tt.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,s){let i;s?.aliasResolveCache?i=s.aliasResolveCache:(i=[],Zf.visit(t,{Node:(r,o)=>{(tt.isAlias(o)||tt.hasAnchor(o))&&i.push(o)}}),s&&(s.aliasResolveCache=i));let n;for(let r of i){if(r===this)break;r.anchor===this.source&&(n=r)}return n}toJSON(t,s){if(!s)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:r}=s,o=this.resolve(n,s);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=i.get(o);if(a||(tp.toJS(o,null,s),a=i.get(o)),a?.res===void 0){let l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(r>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=$s(n,o,i)),a.count*a.aliasCount>r)){let l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(t,s,i){let n=`*${this.source}`;if(t){if(Xf.anchorIsValid(this.source),t.options.verifyAliasOrder&&!t.anchors.has(this.source)){let r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(t.implicitKey)return`${n} `}return n}};function $s(e,t,s){if(tt.isAlias(t)){let i=t.resolve(e),n=s&&i&&s.get(i);return n?n.count*n.aliasCount:0}else if(tt.isCollection(t)){let i=0;for(let n of t.items){let r=$s(e,n,s);r>i&&(i=r)}return i}else if(tt.isPair(t)){let i=$s(e,t.key,s),n=$s(e,t.value,s);return Math.max(i,n)}return 1}Aa.Alias=rn});var V=P(on=>{"use strict";var sp=j(),ip=Ss(),np=ke(),rp=e=>!e||typeof e!="function"&&typeof e!="object",Se=class extends ip.NodeBase{constructor(t){super(sp.SCALAR),this.value=t}toJSON(t,s){return s?.keep?this.value:np.toJS(this.value,t,s)}toString(){return String(this.value)}};Se.BLOCK_FOLDED="BLOCK_FOLDED";Se.BLOCK_LITERAL="BLOCK_LITERAL";Se.PLAIN="PLAIN";Se.QUOTE_DOUBLE="QUOTE_DOUBLE";Se.QUOTE_SINGLE="QUOTE_SINGLE";on.Scalar=Se;on.isScalarValue=rp});var xt=P(Na=>{"use strict";var op=$t(),je=j(),Pa=V(),ap="tag:yaml.org,2002:";function lp(e,t,s){if(t){let i=s.filter(r=>r.tag===t),n=i.find(r=>!r.format)??i[0];if(!n)throw new Error(`Tag ${t} not found`);return n}return s.find(i=>i.identify?.(e)&&!i.format)}function cp(e,t,s){if(je.isDocument(e)&&(e=e.contents),je.isNode(e))return e;if(je.isPair(e)){let d=s.schema[je.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:n,onTagObj:r,schema:o,sourceObjects:a}=s,l;if(i&&e&&typeof e=="object"){if(l=a.get(e),l)return l.anchor??(l.anchor=n(e)),new op.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=ap+t.slice(2));let c=lp(e,t,o.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new Pa.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?o[je.MAP]:Symbol.iterator in Object(e)?o[je.SEQ]:o[je.MAP]}r&&(r(c),delete s.onTagObj);let f=c?.createNode?c.createNode(s.schema,e,s):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(s.schema,e,s):new Pa.Scalar(e);return t?f.tag=t:c.default||(f.tag=c.tag),l&&(l.node=f),f}Na.createNode=cp});var Es=P(xs=>{"use strict";var up=xt(),me=j(),dp=Ss();function an(e,t,s){let i=s;for(let n=t.length-1;n>=0;--n){let r=t[n];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){let o=[];o[r]=i,i=o}else i=new Map([[r,i]])}return up.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 Ia=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,ln=class extends dp.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=>me.isNode(i)||me.isPair(i)?i.clone(t):i),this.range&&(s.range=this.range.slice()),s}addIn(t,s){if(Ia(t))this.add(s);else{let[i,...n]=t,r=this.get(i,!0);if(me.isCollection(r))r.addIn(n,s);else if(r===void 0&&this.schema)this.set(i,an(this.schema,n,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(t){let[s,...i]=t;if(i.length===0)return this.delete(s);let n=this.get(s,!0);if(me.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}getIn(t,s){let[i,...n]=t,r=this.get(i,!0);return n.length===0?!s&&me.isScalar(r)?r.value:r:me.isCollection(r)?r.getIn(n,s):void 0}hasAllNullValues(t){return this.items.every(s=>{if(!me.isPair(s))return!1;let i=s.value;return i==null||t&&me.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 n=this.get(s,!0);return me.isCollection(n)?n.hasIn(i):!1}setIn(t,s){let[i,...n]=t;if(n.length===0)this.set(i,s);else{let r=this.get(i,!0);if(me.isCollection(r))r.setIn(n,s);else if(r===void 0&&this.schema)this.set(i,an(this.schema,n,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};xs.Collection=ln;xs.collectionFromPath=an;xs.isEmptyPath=Ia});var Et=P(Cs=>{"use strict";var fp=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function cn(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var pp=(e,t,s)=>e.endsWith(`
|
|
5
|
+
`)?cn(s,t):s.includes(`
|
|
6
6
|
`)?`
|
|
7
|
-
`+
|
|
8
|
-
`)s===
|
|
7
|
+
`+cn(s,t):(e.endsWith(" ")?"":" ")+s;Cs.indentComment=cn;Cs.lineComment=pp;Cs.stringifyComment=fp});var La=P(Ct=>{"use strict";var mp="flow",un="block",As="quoted";function hp(e,t,s="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!n||n<0)return e;n<r&&(r=0);let l=Math.max(1+r,1+n-t.length);if(e.length<=l)return e;let c=[],f={},d=n-t.length;typeof i=="number"&&(i>n-Math.max(2,r)?c.push(0):d=n-i);let p,m,y=!1,h=-1,g=-1,b=-1;s===un&&(h=Ra(e,h,t.length),h!==-1&&(d=h+l));for(let k;k=e[h+=1];){if(s===As&&k==="\\"){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(k===`
|
|
8
|
+
`)s===un&&(h=Ra(e,h,t.length)),d=h+t.length+l,p=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
|
|
9
9
|
`&&m!==" "){let S=e[h+1];S&&S!==" "&&S!==`
|
|
10
|
-
`&&S!==" "&&(p=h)}if(h>=d)if(p)c.push(p),d=p+l,p=void 0;else if(s===
|
|
11
|
-
${t}${e.slice(0,v)}`:(s===
|
|
12
|
-
${t}${e.slice(S+1,v)}`)}return w}function
|
|
13
|
-
`);i=t,n=t+1,r=e[n]}return i}
|
|
14
|
-
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function
|
|
10
|
+
`&&S!==" "&&(p=h)}if(h>=d)if(p)c.push(p),d=p+l,p=void 0;else if(s===As){for(;m===" "||m===" ";)m=k,k=e[h+=1],y=!0;let S=h>b+1?h-2:g-1;if(f[S])return e;c.push(S),f[S]=!0,d=S+l,p=void 0}else y=!0}m=k}if(y&&a&&a(),c.length===0)return e;o&&o();let w=e.slice(0,c[0]);for(let k=0;k<c.length;++k){let S=c[k],v=c[k+1]||e.length;S===0?w=`
|
|
11
|
+
${t}${e.slice(0,v)}`:(s===As&&f[S]&&(w+=`${e[S]}\\`),w+=`
|
|
12
|
+
${t}${e.slice(S+1,v)}`)}return w}function Ra(e,t,s){let i=t,n=t+1,r=e[n];for(;r===" "||r===" ";)if(t<n+s)r=e[++t];else{do r=e[++t];while(r&&r!==`
|
|
13
|
+
`);i=t,n=t+1,r=e[n]}return i}Ct.FOLD_BLOCK=un;Ct.FOLD_FLOW=mp;Ct.FOLD_QUOTED=As;Ct.foldFlowLines=hp});var Pt=P(Oa=>{"use strict";var de=V(),$e=La(),Ns=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Is=e=>/^(%|---|\.\.\.)/m.test(e);function gp(e,t,s){if(!t||t<0)return!1;let i=t-s,n=e.length;if(n<=i)return!1;for(let r=0,o=0;r<n;++r)if(e[r]===`
|
|
14
|
+
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function At(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(Is(e)?" ":""),o="",a=0;for(let l=0,c=s[l];c;c=s[++l])if(c===" "&&s[l+1]==="\\"&&s[l+2]==="n"&&(o+=s.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(s[l+1]){case"u":{o+=s.slice(a,l);let f=s.substr(l+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(l,6)}l+=5,a=l+1}break;case"n":if(i||s[l+2]==='"'||s.length<n)l+=1;else{for(o+=s.slice(a,l)+`
|
|
15
15
|
|
|
16
16
|
`;s[l+2]==="\\"&&s[l+3]==="n"&&s[l+4]!=='"';)o+=`
|
|
17
|
-
`,l+=2;o+=r,s[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+s.slice(a):s,i?o:$e.foldFlowLines(o,r,$e.FOLD_QUOTED,
|
|
18
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return
|
|
19
|
-
${s}`)+"'";return t.implicitKey?i:$e.foldFlowLines(i,s,$e.FOLD_FLOW,
|
|
17
|
+
`,l+=2;o+=r,s[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+s.slice(a):s,i?o:$e.foldFlowLines(o,r,$e.FOLD_QUOTED,Ns(t,!1))}function dn(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
18
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return At(e,t);let s=t.indent||(Is(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
19
|
+
${s}`)+"'";return t.implicitKey?i:$e.foldFlowLines(i,s,$e.FOLD_FLOW,Ns(t,!1))}function st(e,t){let{singleQuote:s}=t.options,i;if(s===!1)i=At;else{let n=e.includes('"'),r=e.includes("'");n&&!r?i=dn:r&&!n?i=At:i=s?dn:At}return i(e,t)}var fn;try{fn=new RegExp(`(^|(?<!
|
|
20
20
|
))
|
|
21
21
|
+(?!
|
|
22
|
-
|$)`,"g")}catch{
|
|
22
|
+
|$)`,"g")}catch{fn=/\n+(?!\n|$)/g}function Ps({comment:e,type:t,value:s},i,n,r){let{blockQuote:o,commentString:a,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(s))return st(s,i);let c=i.indent||(i.forceBlockIndent||Is(s)?" ":""),f=o==="literal"?!0:o==="folded"||t===de.Scalar.BLOCK_FOLDED?!1:t===de.Scalar.BLOCK_LITERAL?!0:!gp(s,l,c.length);if(!s)return f?`|
|
|
23
23
|
`:`>
|
|
24
24
|
`;let d,p;for(p=s.length;p>0;--p){let v=s[p-1];if(v!==`
|
|
25
25
|
`&&v!==" "&&v!==" ")break}let m=s.substring(p),y=m.indexOf(`
|
|
26
26
|
`);y===-1?d="-":s===m||y!==m.length-1?(d="+",r&&r()):d="",m&&(s=s.slice(0,-m.length),m[m.length-1]===`
|
|
27
|
-
`&&(m=m.slice(0,-1)),m=m.replace(
|
|
27
|
+
`&&(m=m.slice(0,-1)),m=m.replace(fn,`$&${c}`));let h=!1,g,b=-1;for(g=0;g<s.length;++g){let v=s[g];if(v===" ")h=!0;else if(v===`
|
|
28
28
|
`)b=g;else break}let w=s.substring(0,b<g?b+1:g);w&&(s=s.substring(w.length),w=w.replace(/\n+/g,`$&${c}`));let S=(h?c?"2":"1":"")+d;if(e&&(S+=" "+a(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let v=s.replace(/\n+/g,`
|
|
29
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
29
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),C=!1,E=Ns(i,!0);o!=="folded"&&t!==de.Scalar.BLOCK_FOLDED&&(E.onOverflow=()=>{C=!0});let x=$e.foldFlowLines(`${w}${v}${m}`,c,$e.FOLD_BLOCK,E);if(!C)return`>${S}
|
|
30
30
|
${c}${x}`}return s=s.replace(/\n+/g,`$&${c}`),`|${S}
|
|
31
|
-
${c}${w}${s}${m}`}function
|
|
31
|
+
${c}${w}${s}${m}`}function yp(e,t,s,i){let{type:n,value:r}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=t;if(a&&r.includes(`
|
|
32
32
|
`)||f&&/[[\]{},]/.test(r))return st(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||f||!r.includes(`
|
|
33
|
-
`)?st(r,t):
|
|
34
|
-
`))return
|
|
35
|
-
${l}`);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 st(r,t)}return a?d:$e.foldFlowLines(d,l,$e.FOLD_FLOW,
|
|
36
|
-
${t.indent}${a}`:a}
|
|
37
|
-
${a}:`):(g=`${g}:`,p&&(g+=It.lineComment(g,s.indent,c(p))));let b,w,k;be.isNode(t)?(b=!!t.spaceBefore,w=t.commentBefore,k=t.comment):(b=!1,w=null,k=null,t&&typeof t=="object"&&(t=o.createNode(t))),s.implicitKey=!1,!m&&!p&&be.isScalar(t)&&(s.indentAtStart=g.length+1),h=!1,!f&&l.length>=2&&!s.inFlow&&!m&&be.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(s.indent=s.indent.substring(2));let S=!1,v=
|
|
38
|
-
`:"",w){let E=c(w);
|
|
39
|
-
${It.indentComment(E,s.indent)}`}v===""&&!s.inFlow?
|
|
40
|
-
`&&k&&(
|
|
41
|
-
|
|
42
|
-
`):
|
|
33
|
+
`)?st(r,t):Ps(e,t,s,i);if(!a&&!f&&n!==de.Scalar.PLAIN&&r.includes(`
|
|
34
|
+
`))return Ps(e,t,s,i);if(Is(r)){if(l==="")return t.forceBlockIndent=!0,Ps(e,t,s,i);if(a&&l===c)return st(r,t)}let d=r.replace(/\n+/g,`$&
|
|
35
|
+
${l}`);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 st(r,t)}return a?d:$e.foldFlowLines(d,l,$e.FOLD_FLOW,Ns(t,!1))}function bp(e,t,s,i){let{implicitKey:n,inFlow:r}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;a!==de.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=de.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case de.Scalar.BLOCK_FOLDED:case de.Scalar.BLOCK_LITERAL:return n||r?st(o.value,t):Ps(o,t,s,i);case de.Scalar.QUOTE_DOUBLE:return At(o.value,t);case de.Scalar.QUOTE_SINGLE:return dn(o.value,t);case de.Scalar.PLAIN:return yp(o,t,s,i);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:d}=t.options,p=n&&f||d;if(c=l(p),c===null)throw new Error(`Unsupported default string type ${p}`)}return c}Oa.stringifyString=bp});var Nt=P(pn=>{"use strict";var wp=ks(),xe=j(),vp=Et(),kp=Pt();function Sp(e,t){let s=Object.assign({blockQuote:!0,commentString:vp.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 $p(e,t){if(t.tag){let n=e.filter(r=>r.tag===t.tag);if(n.length>0)return n.find(r=>r.format===t.format)??n[0]}let s,i;if(xe.isScalar(t)){i=t.value;let n=e.filter(r=>r.identify?.(i));if(n.length>1){let r=n.filter(o=>o.test);r.length>0&&(n=r)}s=n.find(r=>r.format===t.format)??n.find(r=>!r.format)}else i=t,s=e.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!s){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return s}function xp(e,t,{anchors:s,doc:i}){if(!i.directives)return"";let n=[],r=(xe.isScalar(e)||xe.isCollection(e))&&e.anchor;r&&wp.anchorIsValid(r)&&(s.add(r),n.push(`&${r}`));let o=e.tag??(t.default?null:t.tag);return o&&n.push(i.directives.tagString(o)),n.join(" ")}function Ep(e,t,s,i){if(xe.isPair(e))return e.toString(t,s,i);if(xe.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 n,r=xe.isNode(e)?e:t.doc.createNode(e,{onTagObj:l=>n=l});n??(n=$p(t.doc.schema.tags,r));let o=xp(r,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let a=typeof n.stringify=="function"?n.stringify(r,t,s,i):xe.isScalar(r)?kp.stringifyString(r,t,s,i):r.toString(t,s,i);return o?xe.isScalar(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
36
|
+
${t.indent}${a}`:a}pn.createStringifyContext=Sp;pn.stringify=Ep});var Fa=P(Da=>{"use strict";var be=j(),Ta=V(),Ma=Nt(),It=Et();function Cp({key:e,value:t},s,i,n){let{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:d}}=s,p=be.isNode(e)&&e.comment||null;if(d){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(be.isCollection(e)||!be.isNode(e)&&typeof e=="object"){let E="With simple keys, collection cannot be used as a key value";throw new Error(E)}}let m=!d&&(!e||p&&t==null&&!s.inFlow||be.isCollection(e)||(be.isScalar(e)?e.type===Ta.Scalar.BLOCK_FOLDED||e.type===Ta.Scalar.BLOCK_LITERAL:typeof e=="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!m&&(d||!r),indent:a+l});let y=!1,h=!1,g=Ma.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(r||t==null)return y&&i&&i(),g===""?"?":m?`? ${g}`:g}else if(r&&!d||t==null&&m)return g=`? ${g}`,p&&!y?g+=It.lineComment(g,s.indent,c(p)):h&&n&&n(),g;y&&(p=null),m?(p&&(g+=It.lineComment(g,s.indent,c(p))),g=`? ${g}
|
|
37
|
+
${a}:`):(g=`${g}:`,p&&(g+=It.lineComment(g,s.indent,c(p))));let b,w,k;be.isNode(t)?(b=!!t.spaceBefore,w=t.commentBefore,k=t.comment):(b=!1,w=null,k=null,t&&typeof t=="object"&&(t=o.createNode(t))),s.implicitKey=!1,!m&&!p&&be.isScalar(t)&&(s.indentAtStart=g.length+1),h=!1,!f&&l.length>=2&&!s.inFlow&&!m&&be.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(s.indent=s.indent.substring(2));let S=!1,v=Ma.stringify(t,s,()=>S=!0,()=>h=!0),C=" ";if(p||b||w){if(C=b?`
|
|
38
|
+
`:"",w){let E=c(w);C+=`
|
|
39
|
+
${It.indentComment(E,s.indent)}`}v===""&&!s.inFlow?C===`
|
|
40
|
+
`&&k&&(C=`
|
|
41
|
+
|
|
42
|
+
`):C+=`
|
|
43
43
|
${s.indent}`}else if(!m&&be.isCollection(t)){let E=v[0],x=v.indexOf(`
|
|
44
|
-
`),M=x!==-1,O=s.inFlow??t.flow??t.items.length===0;if(M||!O){let D=!1;if(M&&(E==="&"||E==="!")){let T=v.indexOf(" ");E==="&"&&T!==-1&&T<x&&v[T+1]==="!"&&(T=v.indexOf(" ",T+1)),(T===-1||x<T)&&(D=!0)}D||(
|
|
44
|
+
`),M=x!==-1,O=s.inFlow??t.flow??t.items.length===0;if(M||!O){let D=!1;if(M&&(E==="&"||E==="!")){let T=v.indexOf(" ");E==="&"&&T!==-1&&T<x&&v[T+1]==="!"&&(T=v.indexOf(" ",T+1)),(T===-1||x<T)&&(D=!0)}D||(C=`
|
|
45
45
|
${s.indent}`)}}else(v===""||v[0]===`
|
|
46
|
-
`)&&(
|
|
46
|
+
`)&&(C="");return g+=C+v,s.inFlow?S&&i&&i():k&&!S?g+=It.lineComment(g,s.indent,c(k)):h&&n&&n(),g}Da.stringifyPair=Cp});var hn=P(mn=>{"use strict";var _a=rs("process");function Ap(e,...t){e==="debug"&&console.log(...t)}function Pp(e,t){(e==="debug"||e==="warn")&&(typeof _a.emitWarning=="function"?_a.emitWarning(t):console.warn(t))}mn.debug=Ap;mn.warn=Pp});var Ts=P(Os=>{"use strict";var Rt=j(),ja=V(),Rs="<<",Ls={identify:e=>e===Rs||typeof e=="symbol"&&e.description===Rs,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ja.Scalar(Symbol(Rs)),{addToJSMap:qa}),stringify:()=>Rs},Np=(e,t)=>(Ls.identify(t)||Rt.isScalar(t)&&(!t.type||t.type===ja.Scalar.PLAIN)&&Ls.identify(t.value))&&e?.doc.schema.tags.some(s=>s.tag===Ls.tag&&s.default);function qa(e,t,s){if(s=e&&Rt.isAlias(s)?s.resolve(e.doc):s,Rt.isSeq(s))for(let i of s.items)gn(e,t,i);else if(Array.isArray(s))for(let i of s)gn(e,t,i);else gn(e,t,s)}function gn(e,t,s){let i=e&&Rt.isAlias(s)?s.resolve(e.doc):s;if(!Rt.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[r,o]of n)t instanceof Map?t.has(r)||t.set(r,o):t instanceof Set?t.add(r):Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}Os.addMergeToJSMap=qa;Os.isMergeKey=Np;Os.merge=Ls});var bn=P(Va=>{"use strict";var Ip=hn(),Ba=Ts(),Rp=Nt(),Ua=j(),yn=ke();function Lp(e,t,{key:s,value:i}){if(Ua.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,i);else if(Ba.isMergeKey(e,s))Ba.addMergeToJSMap(e,t,i);else{let n=yn.toJS(s,"",e);if(t instanceof Map)t.set(n,yn.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let r=Op(s,n,e),o=yn.toJS(i,r,e);r in t?Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[r]=o}}return t}function Op(e,t,s){if(t===null)return"";if(typeof t!="object")return String(t);if(Ua.isNode(e)&&s?.doc){let i=Rp.createStringifyContext(s.doc,{});i.anchors=new Set;for(let r of s.anchors.keys())i.anchors.add(r.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=e.toString(i);if(!s.mapKeyWarned){let r=JSON.stringify(n);r.length>40&&(r=r.substring(0,36)+'..."'),Ip.warn(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return n}return JSON.stringify(t)}Va.addPairToJSMap=Lp});var Ee=P(wn=>{"use strict";var Ka=xt(),Tp=Fa(),Mp=bn(),Ms=j();function Dp(e,t,s){let i=Ka.createNode(e,void 0,s),n=Ka.createNode(t,void 0,s);return new Ds(i,n)}var Ds=class e{constructor(t,s=null){Object.defineProperty(this,Ms.NODE_TYPE,{value:Ms.PAIR}),this.key=t,this.value=s}clone(t){let{key:s,value:i}=this;return Ms.isNode(s)&&(s=s.clone(t)),Ms.isNode(i)&&(i=i.clone(t)),new e(s,i)}toJSON(t,s){let i=s?.mapAsMap?new Map:{};return Mp.addPairToJSMap(s,i,this)}toString(t,s,i){return t?.doc?Tp.stringifyPair(this,t,s,i):JSON.stringify(this)}};wn.Pair=Ds;wn.createPair=Dp});var vn=P(Ha=>{"use strict";var qe=j(),Ja=Nt(),Fs=Et();function Fp(e,t,s){return(t.inFlow??e.flow?jp:_p)(e,t,s)}function _p({comment:e,items:t},s,{blockItemPrefix:i,flowChars:n,itemIndent:r,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=s,f=Object.assign({},s,{indent:r,type:null}),d=!1,p=[];for(let y=0;y<t.length;++y){let h=t[y],g=null;if(qe.isNode(h))!d&&h.spaceBefore&&p.push(""),_s(s,p,h.commentBefore,d),h.comment&&(g=h.comment);else if(qe.isPair(h)){let w=qe.isNode(h.key)?h.key:null;w&&(!d&&w.spaceBefore&&p.push(""),_s(s,p,w.commentBefore,d))}d=!1;let b=Ja.stringify(h,f,()=>g=null,()=>d=!0);g&&(b+=Fs.lineComment(b,r,c(g))),d&&g&&(d=!1),p.push(i+b)}let m;if(p.length===0)m=n.start+n.end;else{m=p[0];for(let y=1;y<p.length;++y){let h=p[y];m+=h?`
|
|
47
47
|
${l}${h}`:`
|
|
48
48
|
`}}return e?(m+=`
|
|
49
|
-
`+
|
|
50
|
-
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=d.reduce((w,k)=>w+k.length+2,2)+(b.length+2)>t.options.lineWidth)),c&&(b+=",")),g&&(b+=
|
|
49
|
+
`+Fs.indentComment(c(e),l),a&&a()):d&&o&&o(),m}function jp({items:e},t,{flowChars:s,itemIndent:i}){let{indent:n,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=t;i+=r;let l=Object.assign({},t,{indent:i,inFlow:!0,type:null}),c=!1,f=0,d=[];for(let y=0;y<e.length;++y){let h=e[y],g=null;if(qe.isNode(h))h.spaceBefore&&d.push(""),_s(t,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(qe.isPair(h)){let w=qe.isNode(h.key)?h.key:null;w&&(w.spaceBefore&&d.push(""),_s(t,d,w.commentBefore,!1),w.comment&&(c=!0));let k=qe.isNode(h.value)?h.value:null;k?(k.comment&&(g=k.comment),k.commentBefore&&(c=!0)):h.value==null&&w?.comment&&(g=w.comment)}g&&(c=!0);let b=Ja.stringify(h,l,()=>g=null);c||(c=d.length>f||b.includes(`
|
|
50
|
+
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=d.reduce((w,k)=>w+k.length+2,2)+(b.length+2)>t.options.lineWidth)),c&&(b+=",")),g&&(b+=Fs.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(!c){let y=d.reduce((h,g)=>h+g.length+2,2);c=t.options.lineWidth>0&&y>t.options.lineWidth}if(c){let y=p;for(let h of d)y+=h?`
|
|
51
51
|
${r}${n}${h}`:`
|
|
52
52
|
`;return`${y}
|
|
53
|
-
${n}${m}`}else return`${p}${o}${d.join(" ")}${o}${m}`}function
|
|
54
|
-
`:" ")}return
|
|
53
|
+
${n}${m}`}else return`${p}${o}${d.join(" ")}${o}${m}`}function _s({indent:e,options:{commentString:t}},s,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let r=Fs.indentComment(t(i),e);s.push(r.trimStart())}}Ha.stringifyCollection=Fp});var Ae=P(Sn=>{"use strict";var qp=vn(),Bp=bn(),Up=Es(),Ce=j(),js=Ee(),Vp=V();function Lt(e,t){let s=Ce.isScalar(t)?t.value:t;for(let i of e)if(Ce.isPair(i)&&(i.key===t||i.key===s||Ce.isScalar(i.key)&&i.key.value===s))return i}var kn=class extends Up.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Ce.MAP,t),this.items=[]}static from(t,s,i){let{keepUndefined:n,replacer:r}=i,o=new this(t),a=(l,c)=>{if(typeof r=="function")c=r.call(s,l,c);else if(Array.isArray(r)&&!r.includes(l))return;(c!==void 0||n)&&o.items.push(js.createPair(l,c,i))};if(s instanceof Map)for(let[l,c]of s)a(l,c);else if(s&&typeof s=="object")for(let l of Object.keys(s))a(l,s[l]);return typeof t.sortMapEntries=="function"&&o.items.sort(t.sortMapEntries),o}add(t,s){let i;Ce.isPair(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new js.Pair(t,t?.value):i=new js.Pair(t.key,t.value);let n=Lt(this.items,i.key),r=this.schema?.sortMapEntries;if(n){if(!s)throw new Error(`Key ${i.key} already set`);Ce.isScalar(n.value)&&Vp.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(r){let o=this.items.findIndex(a=>r(i,a)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){let s=Lt(this.items,t);return s?this.items.splice(this.items.indexOf(s),1).length>0:!1}get(t,s){let n=Lt(this.items,t)?.value;return(!s&&Ce.isScalar(n)?n.value:n)??void 0}has(t){return!!Lt(this.items,t)}set(t,s){this.add(new js.Pair(t,s),!0)}toJSON(t,s,i){let n=i?new i:s?.mapAsMap?new Map:{};s?.onCreate&&s.onCreate(n);for(let r of this.items)Bp.addPairToJSMap(s,n,r);return n}toString(t,s,i){if(!t)return JSON.stringify(this);for(let n of this.items)if(!Ce.isPair(n))throw new Error(`Map items must all be pairs; found ${JSON.stringify(n)} instead`);return!t.allNullValues&&this.hasAllNullValues(!1)&&(t=Object.assign({},t,{allNullValues:!0})),qp.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:s})}};Sn.YAMLMap=kn;Sn.findPair=Lt});var it=P(Ga=>{"use strict";var Kp=j(),Wa=Ae(),Jp={collection:"map",default:!0,nodeClass:Wa.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return Kp.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,s)=>Wa.YAMLMap.from(e,t,s)};Ga.map=Jp});var Pe=P(Ya=>{"use strict";var Hp=xt(),Wp=vn(),Gp=Es(),Bs=j(),Yp=V(),zp=ke(),$n=class extends Gp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Bs.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let s=qs(t);return typeof s!="number"?!1:this.items.splice(s,1).length>0}get(t,s){let i=qs(t);if(typeof i!="number")return;let n=this.items[i];return!s&&Bs.isScalar(n)?n.value:n}has(t){let s=qs(t);return typeof s=="number"&&s<this.items.length}set(t,s){let i=qs(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];Bs.isScalar(n)&&Yp.isScalarValue(s)?n.value=s:this.items[i]=s}toJSON(t,s){let i=[];s?.onCreate&&s.onCreate(i);let n=0;for(let r of this.items)i.push(zp.toJS(r,String(n++),s));return i}toString(t,s,i){return t?Wp.stringifyCollection(this,t,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(t.indent||"")+" ",onChompKeep:i,onComment:s}):JSON.stringify(this)}static from(t,s,i){let{replacer:n}=i,r=new this(t);if(s&&Symbol.iterator in Object(s)){let o=0;for(let a of s){if(typeof n=="function"){let l=s instanceof Set?a:String(o++);a=n.call(s,l,a)}r.items.push(Hp.createNode(a,void 0,i))}}return r}};function qs(e){let t=Bs.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}Ya.YAMLSeq=$n});var nt=P(Qa=>{"use strict";var Qp=j(),za=Pe(),Xp={collection:"seq",default:!0,nodeClass:za.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return Qp.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,s)=>za.YAMLSeq.from(e,t,s)};Qa.seq=Xp});var Ot=P(Xa=>{"use strict";var Zp=Pt(),em={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),Zp.stringifyString(e,t,s,i)}};Xa.string=em});var Us=P(tl=>{"use strict";var Za=V(),el={identify:e=>e==null,createNode:()=>new Za.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Za.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&el.test.test(e)?e:t.options.nullStr};tl.nullTag=el});var xn=P(il=>{"use strict";var tm=V(),sl={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new tm.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&sl.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?s.options.trueStr:s.options.falseStr}};il.boolTag=sl});var rt=P(nl=>{"use strict";function sm({format:e,minFractionDigits:t,tag:s,value:i}){if(typeof i=="bigint")return String(i);let n=typeof i=="number"?i:Number(i);if(!isFinite(n))return isNaN(n)?".nan":n<0?"-.inf":".inf";let r=Object.is(i,-0)?"-0":JSON.stringify(i);if(!e&&t&&(!s||s==="tag:yaml.org,2002:float")&&/^\d/.test(r)){let o=r.indexOf(".");o<0&&(o=r.length,r+=".");let a=t-(r.length-o-1);for(;a-- >0;)r+="0"}return r}nl.stringifyNumber=sm});var Cn=P(Vs=>{"use strict";var im=V(),En=rt(),nm={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:En.stringifyNumber},rm={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():En.stringifyNumber(e)}},om={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 im.Scalar(parseFloat(e)),s=e.indexOf(".");return s!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-s-1),t},stringify:En.stringifyNumber};Vs.float=om;Vs.floatExp=rm;Vs.floatNaN=nm});var Pn=P(Js=>{"use strict";var rl=rt(),Ks=e=>typeof e=="bigint"||Number.isInteger(e),An=(e,t,s,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),s);function ol(e,t,s){let{value:i}=e;return Ks(i)&&i>=0?s+i.toString(t):rl.stringifyNumber(e)}var am={identify:e=>Ks(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>An(e,2,8,s),stringify:e=>ol(e,8,"0o")},lm={identify:Ks,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>An(e,0,10,s),stringify:rl.stringifyNumber},cm={identify:e=>Ks(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>An(e,2,16,s),stringify:e=>ol(e,16,"0x")};Js.int=lm;Js.intHex=cm;Js.intOct=am});var ll=P(al=>{"use strict";var um=it(),dm=Us(),fm=nt(),pm=Ot(),mm=xn(),Nn=Cn(),In=Pn(),hm=[um.map,fm.seq,pm.string,dm.nullTag,mm.boolTag,In.intOct,In.int,In.intHex,Nn.floatNaN,Nn.floatExp,Nn.float];al.schema=hm});var dl=P(ul=>{"use strict";var gm=V(),ym=it(),bm=nt();function cl(e){return typeof e=="bigint"||Number.isInteger(e)}var Hs=({value:e})=>JSON.stringify(e),wm=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Hs},{identify:e=>e==null,createNode:()=>new gm.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Hs},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Hs},{identify:cl,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})=>cl(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:Hs}],vm={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},km=[ym.map,bm.seq].concat(wm,vm);ul.schema=km});var Ln=P(fl=>{"use strict";var Tt=rs("buffer"),Rn=V(),Sm=Pt(),$m={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Tt.Buffer=="function")return Tt.Buffer.from(e,"base64");if(typeof atob=="function"){let s=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(s.length);for(let n=0;n<s.length;++n)i[n]=s.charCodeAt(n);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,n,r){if(!s)return"";let o=s,a;if(typeof Tt.Buffer=="function")a=o instanceof Tt.Buffer?o.toString("base64"):Tt.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Rn.Scalar.BLOCK_LITERAL),t!==Rn.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let d=0,p=0;d<c;++d,p+=l)f[d]=a.substr(p,l);a=f.join(t===Rn.Scalar.BLOCK_LITERAL?`
|
|
54
|
+
`:" ")}return Sm.stringifyString({comment:e,type:t,value:a},i,n,r)}};fl.binary=$m});var Ys=P(Gs=>{"use strict";var Ws=j(),On=Ee(),xm=V(),Em=Pe();function pl(e,t){if(Ws.isSeq(e))for(let s=0;s<e.items.length;++s){let i=e.items[s];if(!Ws.isPair(i)){if(Ws.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new On.Pair(new xm.Scalar(null));if(i.commentBefore&&(n.key.commentBefore=n.key.commentBefore?`${i.commentBefore}
|
|
55
55
|
${n.key.commentBefore}`:i.commentBefore),i.comment){let r=n.value??n.key;r.comment=r.comment?`${i.comment}
|
|
56
|
-
${r.comment}`:i.comment}i=n}e.items[s]=Ks.isPair(i)?i:new Cn.Pair(i)}}else t("Expected a sequence for this tag");return e}function Xa(e,t,s){let{replacer:i}=s,n=new Xp.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(Cn.createPair(a,l,s))}return n}var Zp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Qa,createNode:Xa};Js.createPairs=Xa;Js.pairs=Zp;Js.resolvePairs=Qa});var In=P(Nn=>{"use strict";var Za=q(),Pn=ke(),Mt=Ce(),em=Pe(),el=Hs(),Be=class e extends em.YAMLSeq{constructor(){super(),this.add=Mt.YAMLMap.prototype.add.bind(this),this.delete=Mt.YAMLMap.prototype.delete.bind(this),this.get=Mt.YAMLMap.prototype.get.bind(this),this.has=Mt.YAMLMap.prototype.has.bind(this),this.set=Mt.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(Za.isPair(n)?(r=Pn.toJS(n.key,"",s),o=Pn.toJS(n.value,r,s)):r=Pn.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=el.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var tm={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=el.resolvePairs(e,t),i=[];for(let{key:n}of s.items)Za.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Be,s)},createNode:(e,t,s)=>Be.from(e,t,s)};Nn.YAMLOMap=Be;Nn.omap=tm});var rl=P(Rn=>{"use strict";var tl=V();function sl({value:e,source:t},s){return t&&(e?il:nl).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var il={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 tl.Scalar(!0),stringify:sl},nl={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 tl.Scalar(!1),stringify:sl};Rn.falseTag=nl;Rn.trueTag=il});var ol=P(Ws=>{"use strict";var sm=V(),Ln=rt(),im={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},nm={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():Ln.stringifyNumber(e)}},rm={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 sm.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:Ln.stringifyNumber};Ws.float=rm;Ws.floatExp=nm;Ws.floatNaN=im});var ll=P(_t=>{"use strict";var al=rt(),Dt=e=>typeof e=="bigint"||Number.isInteger(e);function Gs(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 On(e,t,s){let{value:i}=e;if(Dt(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return al.stringifyNumber(e)}var om={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Gs(e,2,2,s),stringify:e=>On(e,2,"0b")},am={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Gs(e,1,8,s),stringify:e=>On(e,8,"0")},lm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Gs(e,0,10,s),stringify:al.stringifyNumber},cm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Gs(e,2,16,s),stringify:e=>On(e,16,"0x")};_t.int=lm;_t.intBin=om;_t.intHex=cm;_t.intOct=am});var Mn=P(Tn=>{"use strict";var Qs=q(),Ys=Ee(),zs=Ce(),Ue=class e extends zs.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;Qs.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Ys.Pair(t.key,null):s=new Ys.Pair(t,null),zs.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=zs.findPair(this.items,t);return!s&&Qs.isPair(i)?Qs.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=zs.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Ys.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(Ys.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var um={collection:"map",identify:e=>e instanceof Set,nodeClass:Ue,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>Ue.from(e,t,s),resolve(e,t){if(Qs.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ue,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Tn.YAMLSet=Ue;Tn.set=um});var _n=P(Xs=>{"use strict";var dm=rt();function Dn(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 cl(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return dm.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 fm={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})=>Dn(e,s),stringify:cl},pm={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=>Dn(e,!1),stringify:cl},ul={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(ul.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=Dn(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$/,"")??""};Xs.floatTime=pm;Xs.intTime=fm;Xs.timestamp=ul});var pl=P(fl=>{"use strict";var mm=it(),hm=qs(),gm=nt(),ym=Ot(),bm=An(),dl=rl(),Fn=ol(),Zs=ll(),wm=Rs(),vm=In(),km=Hs(),Sm=Mn(),qn=_n(),$m=[mm.map,gm.seq,ym.string,hm.nullTag,dl.trueTag,dl.falseTag,Zs.intBin,Zs.intOct,Zs.int,Zs.intHex,Fn.floatNaN,Fn.floatExp,Fn.float,bm.binary,wm.merge,vm.omap,km.pairs,Sm.set,qn.intTime,qn.floatTime,qn.timestamp];fl.schema=$m});var $l=P(Un=>{"use strict";var yl=it(),xm=qs(),bl=nt(),Em=Ot(),Am=bn(),jn=vn(),Bn=Sn(),Cm=Ha(),Pm=Ya(),wl=An(),Ft=Rs(),vl=In(),kl=Hs(),ml=pl(),Sl=Mn(),ei=_n(),hl=new Map([["core",Cm.schema],["failsafe",[yl.map,bl.seq,Em.string]],["json",Pm.schema],["yaml11",ml.schema],["yaml-1.1",ml.schema]]),gl={binary:wl.binary,bool:Am.boolTag,float:jn.float,floatExp:jn.floatExp,floatNaN:jn.floatNaN,floatTime:ei.floatTime,int:Bn.int,intHex:Bn.intHex,intOct:Bn.intOct,intTime:ei.intTime,map:yl.map,merge:Ft.merge,null:xm.nullTag,omap:vl.omap,pairs:kl.pairs,seq:bl.seq,set:Sl.set,timestamp:ei.timestamp},Nm={"tag:yaml.org,2002:binary":wl.binary,"tag:yaml.org,2002:merge":Ft.merge,"tag:yaml.org,2002:omap":vl.omap,"tag:yaml.org,2002:pairs":kl.pairs,"tag:yaml.org,2002:set":Sl.set,"tag:yaml.org,2002:timestamp":ei.timestamp};function Im(e,t,s){let i=hl.get(t);if(i&&!e)return s&&!i.includes(Ft.merge)?i.concat(Ft.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(hl.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(Ft.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?gl[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(gl).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},[])}Un.coreKnownTags=Nm;Un.getTags=Im});var Jn=P(xl=>{"use strict";var Vn=q(),Rm=it(),Lm=nt(),Om=Ot(),ti=$l(),Tm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Kn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?ti.getTags(t,"compat"):t?ti.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?ti.coreKnownTags:{},this.tags=ti.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Vn.MAP,{value:Rm.map}),Object.defineProperty(this,Vn.SCALAR,{value:Om.string}),Object.defineProperty(this,Vn.SEQ,{value:Lm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Tm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};xl.Schema=Kn});var Al=P(El=>{"use strict";var Mm=q(),Hn=Nt(),qt=Et();function Dm(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=Hn.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(Mm.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=Hn.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(Hn.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
57
|
-
`)?(s.push("..."),s.push(
|
|
56
|
+
${r.comment}`:i.comment}i=n}e.items[s]=Ws.isPair(i)?i:new On.Pair(i)}}else t("Expected a sequence for this tag");return e}function ml(e,t,s){let{replacer:i}=s,n=new Em.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(On.createPair(a,l,s))}return n}var Cm={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:pl,createNode:ml};Gs.createPairs=ml;Gs.pairs=Cm;Gs.resolvePairs=pl});var Dn=P(Mn=>{"use strict";var hl=j(),Tn=ke(),Mt=Ae(),Am=Pe(),gl=Ys(),Be=class e extends Am.YAMLSeq{constructor(){super(),this.add=Mt.YAMLMap.prototype.add.bind(this),this.delete=Mt.YAMLMap.prototype.delete.bind(this),this.get=Mt.YAMLMap.prototype.get.bind(this),this.has=Mt.YAMLMap.prototype.has.bind(this),this.set=Mt.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(hl.isPair(n)?(r=Tn.toJS(n.key,"",s),o=Tn.toJS(n.value,r,s)):r=Tn.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=gl.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var Pm={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=gl.resolvePairs(e,t),i=[];for(let{key:n}of s.items)hl.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Be,s)},createNode:(e,t,s)=>Be.from(e,t,s)};Mn.YAMLOMap=Be;Mn.omap=Pm});var kl=P(Fn=>{"use strict";var yl=V();function bl({value:e,source:t},s){return t&&(e?wl:vl).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var wl={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 yl.Scalar(!0),stringify:bl},vl={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 yl.Scalar(!1),stringify:bl};Fn.falseTag=vl;Fn.trueTag=wl});var Sl=P(zs=>{"use strict";var Nm=V(),_n=rt(),Im={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:_n.stringifyNumber},Rm={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():_n.stringifyNumber(e)}},Lm={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 Nm.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:_n.stringifyNumber};zs.float=Lm;zs.floatExp=Rm;zs.floatNaN=Im});var xl=P(Ft=>{"use strict";var $l=rt(),Dt=e=>typeof e=="bigint"||Number.isInteger(e);function Qs(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 jn(e,t,s){let{value:i}=e;if(Dt(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return $l.stringifyNumber(e)}var Om={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Qs(e,2,2,s),stringify:e=>jn(e,2,"0b")},Tm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Qs(e,1,8,s),stringify:e=>jn(e,8,"0")},Mm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Qs(e,0,10,s),stringify:$l.stringifyNumber},Dm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Qs(e,2,16,s),stringify:e=>jn(e,16,"0x")};Ft.int=Mm;Ft.intBin=Om;Ft.intHex=Dm;Ft.intOct=Tm});var Bn=P(qn=>{"use strict";var ei=j(),Xs=Ee(),Zs=Ae(),Ue=class e extends Zs.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;ei.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Xs.Pair(t.key,null):s=new Xs.Pair(t,null),Zs.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=Zs.findPair(this.items,t);return!s&&ei.isPair(i)?ei.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=Zs.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Xs.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(Xs.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var Fm={collection:"map",identify:e=>e instanceof Set,nodeClass:Ue,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>Ue.from(e,t,s),resolve(e,t){if(ei.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ue,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};qn.YAMLSet=Ue;qn.set=Fm});var Vn=P(ti=>{"use strict";var _m=rt();function Un(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 El(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return _m.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 jm={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})=>Un(e,s),stringify:El},qm={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=>Un(e,!1),stringify:El},Cl={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(Cl.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=Un(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$/,"")??""};ti.floatTime=qm;ti.intTime=jm;ti.timestamp=Cl});var Nl=P(Pl=>{"use strict";var Bm=it(),Um=Us(),Vm=nt(),Km=Ot(),Jm=Ln(),Al=kl(),Kn=Sl(),si=xl(),Hm=Ts(),Wm=Dn(),Gm=Ys(),Ym=Bn(),Jn=Vn(),zm=[Bm.map,Vm.seq,Km.string,Um.nullTag,Al.trueTag,Al.falseTag,si.intBin,si.intOct,si.int,si.intHex,Kn.floatNaN,Kn.floatExp,Kn.float,Jm.binary,Hm.merge,Wm.omap,Gm.pairs,Ym.set,Jn.intTime,Jn.floatTime,Jn.timestamp];Pl.schema=zm});var jl=P(Gn=>{"use strict";var Ol=it(),Qm=Us(),Tl=nt(),Xm=Ot(),Zm=xn(),Hn=Cn(),Wn=Pn(),eh=ll(),th=dl(),Ml=Ln(),_t=Ts(),Dl=Dn(),Fl=Ys(),Il=Nl(),_l=Bn(),ii=Vn(),Rl=new Map([["core",eh.schema],["failsafe",[Ol.map,Tl.seq,Xm.string]],["json",th.schema],["yaml11",Il.schema],["yaml-1.1",Il.schema]]),Ll={binary:Ml.binary,bool:Zm.boolTag,float:Hn.float,floatExp:Hn.floatExp,floatNaN:Hn.floatNaN,floatTime:ii.floatTime,int:Wn.int,intHex:Wn.intHex,intOct:Wn.intOct,intTime:ii.intTime,map:Ol.map,merge:_t.merge,null:Qm.nullTag,omap:Dl.omap,pairs:Fl.pairs,seq:Tl.seq,set:_l.set,timestamp:ii.timestamp},sh={"tag:yaml.org,2002:binary":Ml.binary,"tag:yaml.org,2002:merge":_t.merge,"tag:yaml.org,2002:omap":Dl.omap,"tag:yaml.org,2002:pairs":Fl.pairs,"tag:yaml.org,2002:set":_l.set,"tag:yaml.org,2002:timestamp":ii.timestamp};function ih(e,t,s){let i=Rl.get(t);if(i&&!e)return s&&!i.includes(_t.merge)?i.concat(_t.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(Rl.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(_t.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?Ll[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Ll).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},[])}Gn.coreKnownTags=sh;Gn.getTags=ih});var Qn=P(ql=>{"use strict";var Yn=j(),nh=it(),rh=nt(),oh=Ot(),ni=jl(),ah=(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)?ni.getTags(t,"compat"):t?ni.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?ni.coreKnownTags:{},this.tags=ni.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Yn.MAP,{value:nh.map}),Object.defineProperty(this,Yn.SCALAR,{value:oh.string}),Object.defineProperty(this,Yn.SEQ,{value:rh.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?ah:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};ql.Schema=zn});var Ul=P(Bl=>{"use strict";var lh=j(),Xn=Nt(),jt=Et();function ch(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=Xn.createStringifyContext(e,t),{commentString:r}=n.options;if(e.commentBefore){s.length!==1&&s.unshift("");let l=r(e.commentBefore);s.unshift(jt.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(lh.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let f=r(e.contents.commentBefore);s.push(jt.indentComment(f,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Xn.stringify(e.contents,n,()=>a=null,l);a&&(c+=jt.lineComment(c,"",r(a))),(c[0]==="|"||c[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${c}`:s.push(c)}else s.push(Xn.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
57
|
+
`)?(s.push("..."),s.push(jt.indentComment(l,""))):s.push(`... ${l}`)}else s.push("...");else{let l=e.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&s[s.length-1]!==""&&s.push(""),s.push(jt.indentComment(r(l),"")))}return s.join(`
|
|
58
58
|
`)+`
|
|
59
|
-
`}
|
|
59
|
+
`}Bl.stringifyDocument=ch});var qt=P(Vl=>{"use strict";var uh=$t(),ot=Es(),le=j(),dh=Ee(),fh=ke(),ph=Qn(),mh=Ul(),Zn=ks(),hh=sn(),gh=xt(),er=tn(),tr=class e{constructor(t,s,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,le.NODE_TYPE,{value:le.DOC});let n=null;typeof s=="function"||Array.isArray(s)?n=s:i===void 0&&s&&(i=s,s=void 0);let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=r;let{version:o}=r;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new er.Directives({version:o}),this.setSchema(o,i),this.contents=t===void 0?null:this.createNode(t,n,i)}clone(){let t=Object.create(e.prototype,{[le.NODE_TYPE]:{value:le.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=le.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=Zn.anchorNames(this);t.anchor=!s||i.has(s)?Zn.findNewAnchor(s||"a",i):s}return new uh.Alias(t.anchor)}createNode(t,s,i){let n;if(typeof s=="function")t=s.call({"":t},"",t),n=s;else if(Array.isArray(s)){let g=w=>typeof w=="number"||w instanceof String||w instanceof Number,b=s.filter(g).map(String);b.length>0&&(s=s.concat(b)),n=s}else i===void 0&&s&&(i=s,s=void 0);let{aliasDuplicateObjects:r,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=i??{},{onAnchor:d,setAnchors:p,sourceObjects:m}=Zn.createNodeAnchors(this,o||"a"),y={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:m},h=gh.createNode(t,f,y);return a&&le.isCollection(h)&&(h.flow=!0),p(),h}createPair(t,s,i={}){let n=this.createNode(t,null,i),r=this.createNode(s,null,i);return new dh.Pair(n,r)}delete(t){return at(this.contents)?this.contents.delete(t):!1}deleteIn(t){return ot.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):at(this.contents)?this.contents.deleteIn(t):!1}get(t,s){return le.isCollection(this.contents)?this.contents.get(t,s):void 0}getIn(t,s){return ot.isEmptyPath(t)?!s&&le.isScalar(this.contents)?this.contents.value:this.contents:le.isCollection(this.contents)?this.contents.getIn(t,s):void 0}has(t){return le.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return ot.isEmptyPath(t)?this.contents!==void 0:le.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,s){this.contents==null?this.contents=ot.collectionFromPath(this.schema,[t],s):at(this.contents)&&this.contents.set(t,s)}setIn(t,s){ot.isEmptyPath(t)?this.contents=s:this.contents==null?this.contents=ot.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 er.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 er.Directives({version:t}),i={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,i=null;break;default:{let n=JSON.stringify(t);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${n}`)}}if(s.schema instanceof Object)this.schema=s.schema;else if(i)this.schema=new ph.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:n,onAnchor:r,reviver:o}={}){let a={anchors:new Map,doc:this,keep:!t,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof n=="number"?n:100},l=fh.toJS(this.contents,s??"",a);if(typeof r=="function")for(let{count:c,res:f}of a.anchors.values())r(f,c);return typeof o=="function"?hh.applyReviver(o,{"":l},"",l):l}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 mh.stringifyDocument(this,t)}};function at(e){if(le.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}Vl.Document=tr});var Vt=P(Ut=>{"use strict";var Bt=class extends Error{constructor(t,s,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=s}},sr=class extends Bt{constructor(t,s,i){super("YAMLParseError",t,s,i)}},ir=class extends Bt{constructor(t,s,i){super("YAMLWarning",t,s,i)}},yh=(e,t)=>s=>{if(s.pos[0]===-1)return;s.linePos=s.pos.map(a=>t.linePos(a));let{line:i,col:n}=s.linePos[0];s.message+=` at line ${i}, column ${n}`;let r=n-1,o=e.substring(t.lineStarts[i-1],t.lineStarts[i]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){let a=Math.min(r-39,o.length-79);o="\u2026"+o.substring(a),r-=a-1}if(o.length>80&&(o=o.substring(0,79)+"\u2026"),i>1&&/^ *$/.test(o.substring(0,r))){let a=e.substring(t.lineStarts[i-2],t.lineStarts[i-1]);a.length>80&&(a=a.substring(0,79)+`\u2026
|
|
60
60
|
`),o=a+o}if(/[^ ]/.test(o)){let a=1,l=s.linePos[1];l?.line===i&&l.col>n&&(a=Math.max(1,Math.min(l.col-n,80-r)));let c=" ".repeat(r)+"^".repeat(a);s.message+=`:
|
|
61
61
|
|
|
62
62
|
${o}
|
|
63
63
|
${c}
|
|
64
|
-
`}};Ut.YAMLError=Bt;Ut.YAMLParseError=
|
|
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
|
-
`+k.comment:w.comment=k.comment);let S=new
|
|
68
|
-
`+
|
|
69
|
-
`+E:x.comment=E,
|
|
70
|
-
`+M.comment:x.comment=M.comment);let D=new
|
|
71
|
-
`+g.comment:c.comment=g.comment),c.range=[i.offset,h,g.offset]}else c.range=[i.offset,h,h];return c}
|
|
64
|
+
`}};Ut.YAMLError=Bt;Ut.YAMLParseError=sr;Ut.YAMLWarning=ir;Ut.prettifyError=yh});var Kt=P(Kl=>{"use strict";function bh(e,{flow:t,indicator:s,next:i,offset:n,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",p="",m=!1,y=!1,h=null,g=null,b=null,w=null,k=null,S=null,v=null;for(let x of e)switch(y&&(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma"&&r(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),y=!1),h&&(c&&x.type!=="comment"&&x.type!=="newline"&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),x.type){case"space":!t&&(s!=="doc-start"||i?.type!=="flow-collection")&&x.source.includes(" ")&&(h=x),f=!0;break;case"comment":{f||r(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let M=x.source.substring(1)||" ";d?d+=p+M:d=M,p="",c=!1;break}case"newline":c?d?d+=x.source:(!S||s!=="seq-item-ind")&&(l=!0):p+=x.source,c=!0,m=!0,(g||b)&&(w=x),f=!0;break;case"anchor":g&&r(x,"MULTIPLE_ANCHORS","A node can have at most one anchor"),x.source.endsWith(":")&&r(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=x,v??(v=x.offset),c=!1,f=!1,y=!0;break;case"tag":{b&&r(x,"MULTIPLE_TAGS","A node can have at most one tag"),b=x,v??(v=x.offset),c=!1,f=!1,y=!0;break}case s:(g||b)&&r(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`),S&&r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${t??"collection"}`),S=x,c=s==="seq-item-ind"||s==="explicit-key-ind",f=!1;break;case"comma":if(t){k&&r(x,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),k=x,c=!1,f=!1;break}default:r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),c=!1,f=!1}let C=e[e.length-1],E=C?C.offset+C.source.length:n;return y&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&r(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(c&&h.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:l,comment:d,hasNewline:m,anchor:g,tag:b,newlineAfterProp:w,end:E,start:v??E}}Kl.resolveProps=bh});var ri=P(Jl=>{"use strict";function nr(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(nr(t.key)||nr(t.value))return!0}return!1;default:return!0}}Jl.containsNewline=nr});var rr=P(Hl=>{"use strict";var wh=ri();function vh(e,t,s){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&wh.containsNewline(t)&&s(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Hl.flowIndentCheck=vh});var or=P(Gl=>{"use strict";var Wl=j();function kh(e,t,s){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(r,o)=>r===o||Wl.isScalar(r)&&Wl.isScalar(o)&&r.value===o.value;return t.some(r=>n(r.key,s))}Gl.mapIncludes=kh});var ec=P(Zl=>{"use strict";var Yl=Ee(),Sh=Ae(),zl=Kt(),$h=ri(),Ql=rr(),xh=or(),Xl="All mapping items must start at the same column";function Eh({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??Sh.YAMLMap,a=new o(s.schema);s.atRoot&&(s.atRoot=!1);let l=i.offset,c=null;for(let f of i.items){let{start:d,key:p,sep:m,value:y}=f,h=zl.resolveProps(d,{indicator:"explicit-key-ind",next:p??m?.[0],offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0}),g=!h.found;if(g){if(p&&(p.type==="block-seq"?n(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&n(l,"BAD_INDENT",Xl)),!h.anchor&&!h.tag&&!m){c=h.end,h.comment&&(a.comment?a.comment+=`
|
|
66
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||$h.containsNewline(p))&&n(p??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&n(l,"BAD_INDENT",Xl);s.atKey=!0;let b=h.end,w=p?e(s,p,h,n):t(s,b,d,null,h,n);s.schema.compat&&Ql.flowIndentCheck(i.indent,p,n),s.atKey=!1,xh.mapIncludes(s,a.items,w)&&n(b,"DUPLICATE_KEY","Map keys must be unique");let k=zl.resolveProps(m??[],{indicator:"map-value-ind",next:y,offset:w.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(l=k.end,k.found){g&&(y?.type==="block-map"&&!k.hasNewline&&n(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),s.options.strict&&h.start<k.found.offset-1024&&n(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=y?e(s,y,k,n):t(s,l,m,null,k,n);s.schema.compat&&Ql.flowIndentCheck(i.indent,y,n),l=S.range[2];let v=new Yl.Pair(w,S);s.options.keepSourceTokens&&(v.srcToken=f),a.items.push(v)}else{g&&n(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(w.comment?w.comment+=`
|
|
67
|
+
`+k.comment:w.comment=k.comment);let S=new Yl.Pair(w);s.options.keepSourceTokens&&(S.srcToken=f),a.items.push(S)}}return c&&c<l&&n(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[i.offset,l,c??l],a}Zl.resolveBlockMap=Eh});var sc=P(tc=>{"use strict";var Ch=Pe(),Ah=Kt(),Ph=rr();function Nh({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??Ch.YAMLSeq,a=new o(s.schema);s.atRoot&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let l=i.offset,c=null;for(let{start:f,value:d}of i.items){let p=Ah.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||d)d?.type==="block-seq"?n(p.end,"BAD_INDENT","All sequence items must start at the same column"):n(l,"MISSING_CHAR","Sequence item without - indicator");else{c=p.end,p.comment&&(a.comment=p.comment);continue}let m=d?e(s,d,p,n):t(s,p.end,f,null,p,n);s.schema.compat&&Ph.flowIndentCheck(i.indent,d,n),l=m.range[2],a.items.push(m)}return a.range=[i.offset,l,c??l],a}tc.resolveBlockSeq=Nh});var lt=P(ic=>{"use strict";function Ih(e,t,s,i){let n="";if(e){let r=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{s&&!r&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=l),r=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:n,offset:t}}ic.resolveEnd=Ih});var ac=P(oc=>{"use strict";var Rh=j(),Lh=Ee(),nc=Ae(),Oh=Pe(),Th=lt(),rc=Kt(),Mh=ri(),Dh=or(),ar="Block collections are not allowed within flow collections",lr=e=>e&&(e.type==="block-map"||e.type==="block-seq");function Fh({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=i.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?nc.YAMLMap:Oh.YAMLSeq),c=new l(s.schema);c.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:w,key:k,sep:S,value:v}=b,C=rc.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:k??S?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!S&&!v){g===0&&C.comma?n(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<i.items.length-1&&n(C.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),C.comment&&(c.comment?c.comment+=`
|
|
68
|
+
`+C.comment:c.comment=C.comment),d=C.end;continue}!o&&s.options.strict&&Mh.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)C.comma&&n(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(C.comma||n(C.start,"MISSING_CHAR",`Missing , between ${a} items`),C.comment){let E="";e:for(let x of w)switch(x.type){case"comma":case"space":break;case"comment":E=x.source.substring(1);break e;default:break e}if(E){let x=c.items[c.items.length-1];Rh.isPair(x)&&(x=x.value??x.key),x.comment?x.comment+=`
|
|
69
|
+
`+E:x.comment=E,C.comment=C.comment.substring(E.length+1)}}if(!o&&!S&&!C.found){let E=v?e(s,v,C,n):t(s,C.end,S,null,C,n);c.items.push(E),d=E.range[2],lr(v)&&n(E.range,"BLOCK_IN_FLOW",ar)}else{s.atKey=!0;let E=C.end,x=k?e(s,k,C,n):t(s,E,w,null,C,n);lr(k)&&n(x.range,"BLOCK_IN_FLOW",ar),s.atKey=!1;let M=rc.resolveProps(S??[],{flow:a,indicator:"map-value-ind",next:v,offset:x.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(M.found){if(!o&&!C.found&&s.options.strict){if(S)for(let T of S){if(T===M.found)break;if(T.type==="newline"){n(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}C.start<M.found.offset-1024&&n(M.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else v&&("source"in v&&v.source?.[0]===":"?n(v,"MISSING_CHAR",`Missing space after : in ${a}`):n(M.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let O=v?e(s,v,M,n):M.found?t(s,M.end,S,null,M,n):null;O?lr(v)&&n(O.range,"BLOCK_IN_FLOW",ar):M.comment&&(x.comment?x.comment+=`
|
|
70
|
+
`+M.comment:x.comment=M.comment);let D=new Lh.Pair(x,O);if(s.options.keepSourceTokens&&(D.srcToken=b),o){let T=c;Dh.mapIncludes(s,T.items,x)&&n(E,"DUPLICATE_KEY","Map keys must be unique"),T.items.push(D)}else{let T=new nc.YAMLMap(s.schema);T.flow=!0,T.items.push(D);let A=(O??x).range;T.range=[x.range[0],A[1],A[2]],c.items.push(T)}d=O?O.range[2]:M.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}`;n(d,f?"MISSING_CHAR":"BAD_INDENT",b),m&&m.source.length!==1&&y.unshift(m)}if(y.length>0){let g=Th.resolveEnd(y,h,s.options.strict,n);g.comment&&(c.comment?c.comment+=`
|
|
71
|
+
`+g.comment:c.comment=g.comment),c.range=[i.offset,h,g.offset]}else c.range=[i.offset,h,h];return c}oc.resolveFlowCollection=Fh});var cc=P(lc=>{"use strict";var _h=j(),jh=V(),qh=Ae(),Bh=Pe(),Uh=ec(),Vh=sc(),Kh=ac();function cr(e,t,s,i,n,r){let o=s.type==="block-map"?Uh.resolveBlockMap(e,t,s,i,r):s.type==="block-seq"?Vh.resolveBlockSeq(e,t,s,i,r):Kh.resolveFlowCollection(e,t,s,i,r),a=o.constructor;return n==="!"||n===a.tagName?(o.tag=a.tagName,o):(n&&(o.tag=n),o)}function Jh(e,t,s,i,n){let r=i.tag,o=r?t.directives.tagName(r.source,p=>n(r,"TAG_RESOLVE_FAILED",p)):null;if(s.type==="block-seq"){let{anchor:p,newlineAfterProp:m}=i,y=p&&r?p.offset>r.offset?p:r:p??r;y&&(!m||m.offset<y.offset)&&n(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(!r||!o||o==="!"||o===qh.YAMLMap.tagName&&a==="map"||o===Bh.YAMLSeq.tagName&&a==="seq")return cr(e,t,s,n,o);let l=t.schema.tags.find(p=>p.tag===o&&p.collection===a);if(!l){let p=t.schema.knownTags[o];if(p?.collection===a)t.schema.tags.push(Object.assign({},p,{default:!1})),l=p;else return p?n(r,"BAD_COLLECTION_TYPE",`${p.tag} used for ${a} collection, but expects ${p.collection??"scalar"}`,!0):n(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),cr(e,t,s,n,o)}let c=cr(e,t,s,n,o,l),f=l.resolve?.(c,p=>n(r,"TAG_RESOLVE_FAILED",p),t.options)??c,d=_h.isNode(f)?f:new jh.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}lc.composeCollection=Jh});var dr=P(uc=>{"use strict";var ur=V();function Hh(e,t,s){let i=t.offset,n=Wh(t,e.options.strict,s);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let r=n.mode===">"?ur.Scalar.BLOCK_FOLDED:ur.Scalar.BLOCK_LITERAL,o=t.source?Gh(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=n.chomp==="+"&&o.length>0?`
|
|
72
72
|
`.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return t.source&&(g+=t.source.length),{value:h,type:r,comment:n.comment,range:[i,g,g]}}let l=t.indent+n.indent,c=t.offset+n.length,f=0;for(let h=0;h<a;++h){let[g,b]=o[h];if(b===""||b==="\r")n.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&s(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(l=g.length),f=h,l===0&&!e.atRoot&&s(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+b.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let d="",p="",m=!1;for(let h=0;h<f;++h)d+=o[h][0].slice(l)+`
|
|
73
|
-
`;for(let h=f;h<a;++h){let[g,b]=o[h];c+=g.length+b.length+1;let w=b[b.length-1]==="\r";if(w&&(b=b.slice(0,-1)),b&&g.length<l){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;s(c-b.length-(w?2:1),"BAD_INDENT",S),g=""}r===
|
|
73
|
+
`;for(let h=f;h<a;++h){let[g,b]=o[h];c+=g.length+b.length+1;let w=b[b.length-1]==="\r";if(w&&(b=b.slice(0,-1)),b&&g.length<l){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;s(c-b.length-(w?2:1),"BAD_INDENT",S),g=""}r===ur.Scalar.BLOCK_LITERAL?(d+=p+g.slice(l)+b,p=`
|
|
74
74
|
`):g.length>l||b[0]===" "?(p===" "?p=`
|
|
75
75
|
`:!m&&p===`
|
|
76
76
|
`&&(p=`
|
|
@@ -83,83 +83,84 @@ ${c}
|
|
|
83
83
|
`+o[h][0].slice(l);d[d.length-1]!==`
|
|
84
84
|
`&&(d+=`
|
|
85
85
|
`);break;default:d+=`
|
|
86
|
-
`}let y=i+n.length+t.source.length;return{value:d,type:r,comment:n.comment,range:[i,y,y]}}function
|
|
86
|
+
`}let y=i+n.length+t.source.length;return{value:d,type:r,comment:n.comment,range:[i,y,y]}}function Wh({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:n}=t[0],r=n[0],o=0,a="",l=-1;for(let p=1;p<n.length;++p){let m=n[p];if(!a&&(m==="-"||m==="+"))a=m;else{let y=Number(m);!o&&y?o=y:l===-1&&(l=e+p)}}l!==-1&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let c=!1,f="",d=n.length;for(let p=1;p<t.length;++p){let m=t[p];switch(m.type){case"space":c=!0;case"newline":d+=m.source.length;break;case"comment":s&&!c&&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:r,indent:o,chomp:a,comment:f,length:d}}function Gh(e){let t=e.split(/\n( *)/),s=t[0],i=s.match(/^( *)/),r=[i?.[1]?[i[1],s.slice(i[1].length)]:["",s]];for(let o=1;o<t.length;o+=2)r.push([t[o],t[o+1]]);return r}uc.resolveBlockScalar=Hh});var pr=P(fc=>{"use strict";var fr=V(),Yh=lt();function zh(e,t,s){let{offset:i,type:n,source:r,end:o}=e,a,l,c=(p,m,y)=>s(i+p,m,y);switch(n){case"scalar":a=fr.Scalar.PLAIN,l=Qh(r,c);break;case"single-quoted-scalar":a=fr.Scalar.QUOTE_SINGLE,l=Xh(r,c);break;case"double-quoted-scalar":a=fr.Scalar.QUOTE_DOUBLE,l=Zh(r,c);break;default:return s(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+r.length,i+r.length]}}let f=i+r.length,d=Yh.resolveEnd(o,f,t,s);return{value:l,type:a,comment:d.comment,range:[i,f,d.offset]}}function Qh(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}`),dc(e)}function Xh(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),dc(e.slice(1,-1)).replace(/''/g,"'")}function dc(e){let t,s;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
87
87
|
`,"sy"),s=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
88
88
|
`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,s=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let n=i[1],r=" ",o=t.lastIndex;for(s.lastIndex=o;i=s.exec(e);)i[1]===""?r===`
|
|
89
89
|
`?n+=r:r=`
|
|
90
|
-
`:(n+=r+i[1],r=" "),o=s.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),n+r+(i?.[1]??"")}function
|
|
90
|
+
`:(n+=r+i[1],r=" "),o=s.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),n+r+(i?.[1]??"")}function Zh(e,t){let s="";for(let i=1;i<e.length-1;++i){let n=e[i];if(!(n==="\r"&&e[i+1]===`
|
|
91
91
|
`))if(n===`
|
|
92
|
-
`){let{fold:r,offset:o}=
|
|
92
|
+
`){let{fold:r,offset:o}=eg(e,i);s+=r,i=o}else if(n==="\\"){let r=e[++i],o=tg[r];if(o)s+=o;else if(r===`
|
|
93
93
|
`)for(r=e[i+1];r===" "||r===" ";)r=e[++i+1];else if(r==="\r"&&e[i+1]===`
|
|
94
|
-
`)for(r=e[++i+1];r===" "||r===" ";)r=e[++i+1];else if(r==="x"||r==="u"||r==="U"){let a={x:2,u:4,U:8}[r];s+=
|
|
94
|
+
`)for(r=e[++i+1];r===" "||r===" ";)r=e[++i+1];else if(r==="x"||r==="u"||r==="U"){let a={x:2,u:4,U:8}[r];s+=sg(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(n===" "||n===" "){let r=i,o=e[i+1];for(;o===" "||o===" ";)o=e[++i+1];o!==`
|
|
95
95
|
`&&!(o==="\r"&&e[i+2]===`
|
|
96
|
-
`)&&(s+=i>r?e.slice(r,i+1):n)}else s+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),s}function
|
|
96
|
+
`)&&(s+=i>r?e.slice(r,i+1):n)}else s+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),s}function eg(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 tg={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 sg(e,t,s,i){let n=e.substr(t,s),o=n.length===s&&/^[0-9a-fA-F]+$/.test(n)?parseInt(n,16):NaN;if(isNaN(o)){let a=e.substr(t-2,s+2);return i(t-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}fc.resolveFlowScalar=zh});var hc=P(mc=>{"use strict";var Ve=j(),pc=V(),ig=dr(),ng=pr();function rg(e,t,s,i){let{value:n,type:r,comment:o,range:a}=t.type==="block-scalar"?ig.resolveBlockScalar(e,t,i):ng.resolveFlowScalar(t,e.options.strict,i),l=s?e.directives.tagName(s.source,d=>i(s,"TAG_RESOLVE_FAILED",d)):null,c;e.options.stringKeys&&e.atKey?c=e.schema[Ve.SCALAR]:l?c=og(e.schema,n,l,s,i):t.type==="scalar"?c=ag(e,n,t,i):c=e.schema[Ve.SCALAR];let f;try{let d=c.resolve(n,p=>i(s??t,"TAG_RESOLVE_FAILED",p),e.options);f=Ve.isScalar(d)?d:new pc.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(s??t,"TAG_RESOLVE_FAILED",p),f=new pc.Scalar(n)}return f.range=a,f.source=n,r&&(f.type=r),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function og(e,t,s,i,n){if(s==="!")return e[Ve.SCALAR];let r=[];for(let a of e.tags)if(!a.collection&&a.tag===s)if(a.default&&a.test)r.push(a);else return a;for(let a of r)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):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,s!=="tag:yaml.org,2002:str"),e[Ve.SCALAR])}function ag({atKey:e,directives:t,schema:s},i,n,r){let o=s.tags.find(a=>(a.default===!0||e&&a.default==="key")&&a.test?.test(i))||s[Ve.SCALAR];if(s.compat){let a=s.compat.find(l=>l.default&&l.test?.test(i))??s[Ve.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;r(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}mc.composeScalar=rg});var yc=P(gc=>{"use strict";function lg(e,t,s){if(t){s??(s=t.length);for(let i=s-1;i>=0;--i){let n=t[i];switch(n.type){case"space":case"comment":case"newline":e-=n.source.length;continue}for(n=t[++i];n?.type==="space";)e+=n.source.length,n=t[++i];break}}return e}gc.emptyScalarPosition=lg});var vc=P(hr=>{"use strict";var cg=$t(),ug=j(),dg=cc(),bc=hc(),fg=lt(),pg=yc(),mg={composeNode:wc,composeEmptyNode:mr};function wc(e,t,s,i){let n=e.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=s,c,f=!0;switch(t.type){case"alias":c=hg(e,t,i),(a||l)&&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":c=bc.composeScalar(e,t,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=dg.composeCollection(mg,e,t,s,i),a&&(c.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 c??(c=mr(e,t.offset,void 0,null,s,i)),a&&c.anchor===""&&i(a,"BAD_ALIAS","Anchor cannot be an empty string"),n&&e.options.stringKeys&&(!ug.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),r&&(c.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?c.comment=o:c.commentBefore=o),e.options.keepSourceTokens&&f&&(c.srcToken=t),c}function mr(e,t,s,i,{spaceBefore:n,comment:r,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:pg.emptyScalarPosition(t,s,i),indent:-1,source:""},d=bc.composeScalar(e,f,a,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),r&&(d.comment=r,d.range[2]=l),d}function hg({options:e},{offset:t,source:s,end:i},n){let r=new cg.Alias(s.substring(1));r.source===""&&n(t,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&n(t+s.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);let o=t+s.length,a=fg.resolveEnd(i,o,e.strict,n);return r.range=[t,o,a.offset],a.comment&&(r.comment=a.comment),r}hr.composeEmptyNode=mr;hr.composeNode=wc});var $c=P(Sc=>{"use strict";var gg=qt(),kc=vc(),yg=lt(),bg=Kt();function wg(e,t,{offset:s,start:i,value:n,end:r},o){let a=Object.assign({_directives:t},e),l=new gg.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=bg.resolveProps(i,{indicator:"doc-start",next:n??r?.[0],offset:s,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=n?kc.composeNode(c,n,f,o):kc.composeEmptyNode(c,f.end,i,null,f,o);let d=l.contents.range[2],p=yg.resolveEnd(r,d,!1,o);return p.comment&&(l.comment=p.comment),l.range=[s,d,p.offset],l}Sc.composeDoc=wg});var yr=P(Cc=>{"use strict";var vg=rs("process"),kg=tn(),Sg=qt(),Jt=Vt(),xc=j(),$g=$c(),xg=lt();function Ht(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 Ec(e){let t="",s=!1,i=!1;for(let n=0;n<e.length;++n){let r=e[n];switch(r[0]){case"#":t+=(t===""?"":i?`
|
|
102
102
|
|
|
103
103
|
`:`
|
|
104
|
-
`)+(r.substring(1)||" "),s=!0,i=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),s=!1;break;default:s||(i=!0),s=!1}}return{comment:t,afterEmptyLine:i}}var
|
|
105
|
-
${i}`:i;else if(n||t.directives.docStart||!r)t.commentBefore=i;else if(
|
|
104
|
+
`)+(r.substring(1)||" "),s=!0,i=!1;break;case"%":e[n+1]?.[0]!=="#"&&(n+=1),s=!1;break;default:s||(i=!0),s=!1}}return{comment:t,afterEmptyLine:i}}var gr=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(s,i,n,r)=>{let o=Ht(s);r?this.warnings.push(new Jt.YAMLWarning(o,i,n)):this.errors.push(new Jt.YAMLParseError(o,i,n))},this.directives=new kg.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,s){let{comment:i,afterEmptyLine:n}=Ec(this.prelude);if(i){let r=t.contents;if(s)t.comment=t.comment?`${t.comment}
|
|
105
|
+
${i}`:i;else if(n||t.directives.docStart||!r)t.commentBefore=i;else if(xc.isCollection(r)&&!r.flow&&r.items.length>0){let o=r.items[0];xc.isPair(o)&&(o=o.key);let a=o.commentBefore;o.commentBefore=a?`${i}
|
|
106
106
|
${a}`:i}else{let o=r.commentBefore;r.commentBefore=o?`${i}
|
|
107
|
-
${o}`:i}}s?(Array.prototype.push.apply(t.errors,this.errors),Array.prototype.push.apply(t.warnings,this.warnings)):(t.errors=this.errors,t.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:
|
|
108
|
-
${s.comment}`:s.comment}this.doc.range[2]=s.offset;break}default:this.errors.push(new Jt.YAMLParseError(Ht(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),n=new
|
|
107
|
+
${o}`:i}}s?(Array.prototype.push.apply(t.errors,this.errors),Array.prototype.push.apply(t.warnings,this.warnings)):(t.errors=this.errors,t.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Ec(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(t,s=!1,i=-1){for(let n of t)yield*this.next(n);yield*this.end(s,i)}*next(t){switch(vg.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(s,i,n)=>{let r=Ht(t);r[0]+=s,this.onError(r,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let s=$g.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 Jt.YAMLParseError(Ht(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 Jt.YAMLParseError(Ht(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let s=xg.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 Jt.YAMLParseError(Ht(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),n=new Sg.Document(void 0,i);this.atDirectives&&this.onError(s,"MISSING_CHAR","Missing directives-end indicator line"),n.range=[0,s,s],this.decorate(n,!1),yield n}}};Cc.Composer=gr});var Nc=P(oi=>{"use strict";var Eg=dr(),Cg=pr(),Ag=Vt(),Ac=Pt();function Pg(e,t=!0,s){if(e){let i=(n,r,o)=>{let a=typeof n=="number"?n:Array.isArray(n)?n[0]:n.offset;if(s)s(a,r,o);else throw new Ag.YAMLParseError([a,a+1],r,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Cg.resolveFlowScalar(e,t,i);case"block-scalar":return Eg.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function Ng(e,t){let{implicitKey:s=!1,indent:i,inFlow:n=!1,offset:r=-1,type:o="PLAIN"}=t,a=Ac.stringifyString({type:o,value:e},{implicitKey:s,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:i,source:`
|
|
109
109
|
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
|
|
110
110
|
`),f=a.substring(0,c),d=a.substring(c+1)+`
|
|
111
|
-
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return
|
|
112
|
-
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:r,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:i,source:a,end:l};default:return{type:"scalar",offset:r,indent:i,source:a,end:l}}}function
|
|
111
|
+
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return Pc(p,l)||p.push({type:"newline",offset:-1,indent:i,source:`
|
|
112
|
+
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:r,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:i,source:a,end:l};default:return{type:"scalar",offset:r,indent:i,source:a,end:l}}}function Ig(e,t,s={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:r=!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 c=e.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=Ac.stringifyString({type:o,value:t},{implicitKey:n||a===null,indent:a!==null&&a>0?" ".repeat(a):"",inFlow:r,options:{blockQuote:!0,lineWidth:-1}});switch(l[0]){case"|":case">":Rg(e,l);break;case'"':br(e,l,"double-quoted-scalar");break;case"'":br(e,l,"single-quoted-scalar");break;default:br(e,l,"scalar")}}function Rg(e,t){let s=t.indexOf(`
|
|
113
113
|
`),i=t.substring(0,s),n=t.substring(s+1)+`
|
|
114
|
-
`;if(e.type==="block-scalar"){let r=e.props[0];if(r.type!=="block-scalar-header")throw new Error("Invalid block scalar header");r.source=i,e.source=n}else{let{offset:r}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:r,indent:o,source:i}];
|
|
115
|
-
`});for(let l of Object.keys(e))l!=="type"&&l!=="offset"&&delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:n})}}function
|
|
116
|
-
`};delete e.items,Object.assign(e,{type:s,source:t,end:[n]});break}default:{let i="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(r=>r.type==="space"||r.type==="comment"||r.type==="newline"):[];for(let r of Object.keys(e))r!=="type"&&r!=="offset"&&delete e[r];Object.assign(e,{type:s,indent:i,source:t,end:n})}}}
|
|
114
|
+
`;if(e.type==="block-scalar"){let r=e.props[0];if(r.type!=="block-scalar-header")throw new Error("Invalid block scalar header");r.source=i,e.source=n}else{let{offset:r}=e,o="indent"in e?e.indent:-1,a=[{type:"block-scalar-header",offset:r,indent:o,source:i}];Pc(a,"end"in e?e.end:void 0)||a.push({type:"newline",offset:-1,indent:o,source:`
|
|
115
|
+
`});for(let l of Object.keys(e))l!=="type"&&l!=="offset"&&delete e[l];Object.assign(e,{type:"block-scalar",indent:o,props:a,source:n})}}function Pc(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 br(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),n=t.length;e.props[0].type==="block-scalar-header"&&(n-=e.props[0].source.length);for(let r of i)r.offset+=n;delete e.props,Object.assign(e,{type:s,source:t,end:i});break}case"block-map":case"block-seq":{let n={type:"newline",offset:e.offset+t.length,indent:e.indent,source:`
|
|
116
|
+
`};delete e.items,Object.assign(e,{type:s,source:t,end:[n]});break}default:{let i="indent"in e?e.indent:-1,n="end"in e&&Array.isArray(e.end)?e.end.filter(r=>r.type==="space"||r.type==="comment"||r.type==="newline"):[];for(let r of Object.keys(e))r!=="type"&&r!=="offset"&&delete e[r];Object.assign(e,{type:s,indent:i,source:t,end:n})}}}oi.createScalarToken=Ng;oi.resolveAsScalar=Pg;oi.setScalarValue=Ig});var Rc=P(Ic=>{"use strict";var Lg=e=>"type"in e?li(e):ai(e);function li(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=li(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=ai(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=ai(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=ai(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 ai({start:e,key:t,sep:s,value:i}){let n="";for(let r of e)n+=r.source;if(t&&(n+=li(t)),s)for(let r of s)n+=r.source;return i&&(n+=li(i)),n}Ic.stringify=Lg});var Mc=P(Tc=>{"use strict";var wr=Symbol("break visit"),Og=Symbol("skip children"),Lc=Symbol("remove item");function Ke(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),Oc(Object.freeze([]),e,t)}Ke.BREAK=wr;Ke.SKIP=Og;Ke.REMOVE=Lc;Ke.itemAtPath=(e,t)=>{let s=e;for(let[i,n]of t){let r=s?.[i];if(r&&"items"in r)s=r.items[n];else return}return s};Ke.parentCollection=(e,t)=>{let s=Ke.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],n=s?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function Oc(e,t,s){let i=s(t,e);if(typeof i=="symbol")return i;for(let n of["key","value"]){let r=t[n];if(r&&"items"in r){for(let o=0;o<r.items.length;++o){let a=Oc(Object.freeze(e.concat([[n,o]])),r.items[o],s);if(typeof a=="number")o=a-1;else{if(a===wr)return wr;a===Lc&&(r.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}Tc.visit=Ke});var ci=P(ie=>{"use strict";var vr=Nc(),Tg=Rc(),Mg=Mc(),kr="\uFEFF",Sr="",$r="",xr="",Dg=e=>!!e&&"items"in e,Fg=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function _g(e){switch(e){case kr:return"<BOM>";case Sr:return"<DOC>";case $r:return"<FLOW_END>";case xr:return"<SCALAR>";default:return JSON.stringify(e)}}function jg(e){switch(e){case kr:return"byte-order-mark";case Sr:return"doc-mode";case $r:return"flow-error-end";case xr: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}ie.createScalarToken=vr.createScalarToken;ie.resolveAsScalar=vr.resolveAsScalar;ie.setScalarValue=vr.setScalarValue;ie.stringify=Tg.stringify;ie.visit=Mg.visit;ie.BOM=kr;ie.DOCUMENT=Sr;ie.FLOW_END=$r;ie.SCALAR=xr;ie.isCollection=Dg;ie.isScalar=Fg;ie.prettyToken=_g;ie.tokenType=jg});var Ar=P(Fc=>{"use strict";var Wt=ci();function fe(e){switch(e){case void 0:case" ":case`
|
|
119
|
+
`:case"\r":case" ":return!0;default:return!1}}var Dc=new Set("0123456789ABCDEFabcdef"),qg=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ui=new Set(",[]{}"),Bg=new Set(` ,[]{}
|
|
120
|
+
\r `),Er=e=>!e||Bg.has(e),Cr=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
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 n=this.buffer[i+t+1];if(n===`
|
|
123
123
|
`||!n&&!this.atEnd)return t+i+1}return s===`
|
|
124
124
|
`||i>=this.indentNext||!s&&!this.atEnd?t+i:-1}if(s==="-"||s==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&fe(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]===Wt.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let s=t.length,i=t.indexOf("#");for(;i!==-1;){let r=t[i-1];if(r===" "||r===" "){s=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let r=t[s-1];if(r===" "||r===" ")s-=1;else break}let n=(yield*this.pushCount(s))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),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 Wt.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==="...")&&fe(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&&!fe(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===":")&&fe(s)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,yield*this.parseBlockStart()}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(
|
|
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]===Wt.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let s=t.length,i=t.indexOf("#");for(;i!==-1;){let r=t[i-1];if(r===" "||r===" "){s=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let r=t[s-1];if(r===" "||r===" ")s-=1;else break}let n=(yield*this.pushCount(s))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),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 Wt.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==="...")&&fe(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&&!fe(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===":")&&fe(s)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,yield*this.parseBlockStart()}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(Er),"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 n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&fe(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Wt.FLOW_END,yield*this.parseLineStart();let r=0;for(;n[r]===",";)r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),n[r]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-r),"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(Er),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||fe(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 r=0;for(;this.buffer[s-1-r]==="\\";)r+=1;if(r%2===0)break;s=this.buffer.indexOf('"',s+1)}let i=this.buffer.substring(0,s),n=i.indexOf(`
|
|
126
126
|
`,this.pos);if(n!==-1){for(;n!==-1;){let r=this.continueScalar(n+1);if(r===-1)break;n=i.indexOf(`
|
|
127
127
|
`,r)}n!==-1&&(s=n-(i[n-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=>fe(s)||s==="#")}*parseBlockScalar(){let t=this.pos-1,s=0,i;e:for(let r=this.pos;i=this.buffer[r];++r)switch(i){case" ":s+=1;break;case`
|
|
128
128
|
`:t=r,s=0;break;case"\r":{let o=this.buffer[r+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
129
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 r=this.continueScalar(t+1);if(r===-1)break;t=this.buffer.indexOf(`
|
|
130
130
|
`,r)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let n=t+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
|
|
131
131
|
`;)i=this.buffer[++n];t=n-1}else if(!this.blockScalarKeep)do{let r=t-1,o=this.buffer[r];o==="\r"&&(o=this.buffer[--r]);let a=r;for(;o===" ";)o=this.buffer[--r];if(o===`
|
|
132
|
-
`&&r>=this.pos&&r+1+s>a)t=r;else break}while(!0);return yield Wt.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,s=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let r=this.buffer[i+1];if(fe(r)||t&&
|
|
132
|
+
`&&r>=this.pos&&r+1+s>a)t=r;else break}while(!0);return yield Wt.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,s=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let r=this.buffer[i+1];if(fe(r)||t&&ui.has(r))break;s=i}else if(fe(n)){let r=this.buffer[i+1];if(n==="\r"&&(r===`
|
|
133
133
|
`?(i+=1,n=`
|
|
134
|
-
`,r=this.buffer[i+1]):s=i),r==="#"||t&&
|
|
135
|
-
`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&
|
|
134
|
+
`,r=this.buffer[i+1]):s=i),r==="#"||t&&ui.has(r))break;if(n===`
|
|
135
|
+
`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&ui.has(n))break;s=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Wt.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(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Er))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(fe(s)||t&&ui.has(s))return t?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,s=this.buffer[t];for(;!fe(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(qg.has(s))s=this.buffer[++t];else if(s==="%"&&Dc.has(this.buffer[t+1])&&Dc.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 n=s-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=s),n}*pushUntil(t){let s=this.pos,i=this.buffer[s];for(;!t(i);)i=this.buffer[++s];return yield*this.pushToIndex(s,!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 n=s-this.pos;return n>0&&(yield this.buffer.substr(this.pos,n),this.pos=s),n}*pushUntil(t){let s=this.pos,i=this.buffer[s];for(;!t(i);)i=this.buffer[++s];return yield*this.pushToIndex(s,!1)}};Fc.Lexer=Cr});var Nr=P(_c=>{"use strict";var Pr=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 r=s+i>>1;this.lineStarts[r]<t?s=r+1:i=r}if(this.lineStarts[s]===t)return{line:s+1,col:1};if(s===0)return{line:0,col:t};let n=this.lineStarts[s-1];return{line:s,col:t-n+1}}}};_c.LineCounter=Pr});var Rr=P(Vc=>{"use strict";var Ug=rs("process"),jc=ci(),Vg=Ar();function Ne(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function qc(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 Uc(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 di(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 ct(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 Bc(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!Ne(t.start,"explicit-key-ind")&&!Ne(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,Uc(t.value)?t.value.end?Array.prototype.push.apply(t.value.end,t.sep):t.value.end=t.sep:Array.prototype.push.apply(t.start,t.sep),delete t.sep)}var Ir=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 Vg.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,Ug.env.LOG_TOKENS&&console.log("|",jc.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let s=jc.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"&&Bc(s),i.type){case"document":i.value=s;break;case"block-scalar":i.props.push(s);break;case"block-map":{let n=i.items[i.items.length-1];if(n.value){i.items.push({start:[],key:s,sep:[]}),this.onKeyLine=!0;return}else if(n.sep)n.value=s;else{Object.assign(n,{key:s,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case"block-seq":{let n=i.items[i.items.length-1];n.value?i.items.push({start:[],value:s}):n.value=s;break}case"flow-collection":{let n=i.items[i.items.length-1];!n||n.value?i.items.push({start:[],key:s,sep:[]}):n.sep?n.value=s:Object.assign(n,{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 n=s.items[s.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&qc(n.start)===-1&&(s.indent===0||n.start.every(r=>r.type!=="comment"||r.indent<s.indent))&&(i.type==="document"?i.end=n.start:i.items.push({start:n.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":{qc(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=di(this.peek(2)),i=ct(s),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let r={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:i,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}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 n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,s.start),n.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,n=i&&(s.sep||s.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&s.sep&&!s.value){let o=[];for(let a=0;a<s.sep.length;++a){let l=s.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=s.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||s.value?(r.push(this.sourceToken),t.items.push({start:r}),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):n||s.value?(r.push(this.sourceToken),t.items.push({start:r,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(Ne(s.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(
|
|
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 n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,s.start),n.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,n=i&&(s.sep||s.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&s.sep&&!s.value){let o=[];for(let a=0;a<s.sep.length;++a){let l=s.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=s.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||s.value?(r.push(this.sourceToken),t.items.push({start:r}),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):n||s.value?(r.push(this.sourceToken),t.items.push({start:r,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(Ne(s.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Uc(s.key)&&!Ne(s.sep,"newline")){let o=ct(s.start),a=s.key,l=s.sep;l.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:l}]})}else r.length>0?s.sep=s.sep.concat(r,this.sourceToken):s.sep.push(this.sourceToken);else if(Ne(s.start,"newline"))Object.assign(s,{key:null,sep:[this.sourceToken]});else{let o=ct(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||n?t.items.push({start:r,key:null,sep:[this.sourceToken]}):Ne(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);n||s.value?(t.items.push({start:r,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&&!Ne(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:r});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 n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,s.start),n.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||Ne(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 n=this.flowScalar(this.type);!s||s.value?t.items.push({start:[],key:n,sep:[]}):s.sep?this.stack.push(n):Object.assign(s,{key:n,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 n=di(i),r=ct(n);Bc(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:r,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
|
-
|
|
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=di(t),i=ct(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=di(t),i=ct(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;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Vc.Parser=Ir});var Gc=P(Yt=>{"use strict";var Kc=yr(),Kg=qt(),Gt=Vt(),Jg=hn(),Hg=j(),Wg=Nr(),Jc=Rr();function Hc(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Wg.LineCounter||null,prettyErrors:t}}function Gg(e,t={}){let{lineCounter:s,prettyErrors:i}=Hc(t),n=new Jc.Parser(s?.addNewLine),r=new Kc.Composer(t),o=Array.from(r.compose(n.parse(e)));if(i&&s)for(let a of o)a.errors.forEach(Gt.prettifyError(e,s)),a.warnings.forEach(Gt.prettifyError(e,s));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function Wc(e,t={}){let{lineCounter:s,prettyErrors:i}=Hc(t),n=new Jc.Parser(s?.addNewLine),r=new Kc.Composer(t),o=null;for(let a of r.compose(n.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Gt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&s&&(o.errors.forEach(Gt.prettifyError(e,s)),o.warnings.forEach(Gt.prettifyError(e,s))),o}function Yg(e,t,s){let i;typeof t=="function"?i=t:s===void 0&&t&&typeof t=="object"&&(s=t);let n=Wc(e,s);if(!n)return null;if(n.warnings.forEach(r=>Jg.warn(n.options.logLevel,r)),n.errors.length>0){if(n.options.logLevel!=="silent")throw n.errors[0];n.errors=[]}return n.toJS(Object.assign({reviver:i},s))}function zg(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 n=Math.round(s);s=n<1?void 0:n>8?{indent:8}:{indent:n}}if(e===void 0){let{keepUndefined:n}=s??t??{};if(!n)return}return Hg.isDocument(e)&&!i?e.toString(s):new Kg.Document(e,i,s).toString(s)}Yt.parse=Yg;Yt.parseAllDocuments=Gg;Yt.parseDocument=Wc;Yt.stringify=zg});var Or=P(q=>{"use strict";var Qg=yr(),Xg=qt(),Zg=Qn(),Lr=Vt(),ey=$t(),Ie=j(),ty=Ee(),sy=V(),iy=Ae(),ny=Pe(),ry=ci(),oy=Ar(),ay=Nr(),ly=Rr(),fi=Gc(),Yc=wt();q.Composer=Qg.Composer;q.Document=Xg.Document;q.Schema=Zg.Schema;q.YAMLError=Lr.YAMLError;q.YAMLParseError=Lr.YAMLParseError;q.YAMLWarning=Lr.YAMLWarning;q.Alias=ey.Alias;q.isAlias=Ie.isAlias;q.isCollection=Ie.isCollection;q.isDocument=Ie.isDocument;q.isMap=Ie.isMap;q.isNode=Ie.isNode;q.isPair=Ie.isPair;q.isScalar=Ie.isScalar;q.isSeq=Ie.isSeq;q.Pair=ty.Pair;q.Scalar=sy.Scalar;q.YAMLMap=iy.YAMLMap;q.YAMLSeq=ny.YAMLSeq;q.CST=ry;q.Lexer=oy.Lexer;q.LineCounter=ay.LineCounter;q.Parser=ly.Parser;q.parse=fi.parse;q.parseAllDocuments=fi.parseAllDocuments;q.parseDocument=fi.parseDocument;q.stringify=fi.stringify;q.visit=Yc.visit;q.visitAsync=Yc.visitAsync});import{readFile as sf,writeFile as nf,mkdir as rf,rename as Uo,copyFile as of,access as af,realpath as lf}from"node:fs/promises";import{join as Vo,dirname as cf}from"node:path";function Bo(){return{version:1,disabled:{}}}async function cs(e){let t=e??Ti(),s;try{s=await sf(t,"utf-8")}catch(i){if(i?.code==="ENOENT")return I("skill-state: file not found, returning empty state"),Bo();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";I(`skill-state: parse error, backing up to ${i}`);try{await of(t,i)}catch{}return console.error(`Warning: skill-state.json was corrupted. Backup saved to ${i}. Starting fresh.`),Bo()}}async function Ui(e,t){let s=t??Ti();await rf(cf(s),{recursive:!0}),await nf(s,JSON.stringify(e,null,2)+`
|
|
142
|
+
`,"utf-8")}function Ko(e,t,s,i){let n=e.disabled[t]??={},r=n[s]??={};r[i]=!0}function Jo(e,t,s,i){let n=e.disabled[t];if(!n)return;let r=n[s];r&&(delete r[i],Object.keys(r).length===0&&delete n[s],Object.keys(n).length===0&&delete e.disabled[t])}function uf(e){return e.replace(/[.+?^${}()|[\]\\]/g,"\\$&")}function df(e){if(e==="*"||e==="all")return{kind:"all",test:()=>!0};if(e.includes("*")){let t=new RegExp("^"+uf(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 Vi(e,t){let s=df(t);return e.filter(i=>s.test(i.name)||s.test(i.dirName))}function Ho(e){return Vo(e,"SKILL.md")}function us(e){return Vo(e,"SKILL.md.disabled")}async function ls(e){try{return await af(e),!0}catch{return!1}}async function Wo(e){try{return await lf(e)}catch{return e}}async function Go(e){let t=await Wo(e),s=Ho(t),i=us(t);return!await ls(s)&&await ls(i)?!1:(await Uo(s,i),!0)}async function Yo(e){let t=await Wo(e),s=Ho(t),i=us(t);return!await ls(i)&&await ls(s)?!1:(await Uo(i,s),!0)}import{readFile as Uv,realpath as Vv}from"fs/promises";import{existsSync as Kv}from"fs";import{execFile as wf}from"child_process";import{promisify as vf}from"util";import{mkdtemp as zo,readdir as kf,readFile as Yi,rm as ps,cp as Sf,access as Wi,stat as ea,lstat as $f,symlink as xf,mkdir as Ef}from"fs/promises";import{join as ge,resolve as Gi,relative as Cf,basename as Af}from"path";import{homedir as Qo}from"os";import{tmpdir as Xo}from"os";import{readdir as ff,readFile as pf,stat as mf}from"fs/promises";import{join as hf}from"path";var gf=new Set([".png",".jpg",".jpeg",".gif",".ico",".bmp",".webp",".mp3",".mp4",".wav",".avi",".mov",".zip",".tar",".gz",".bz2",".7z",".exe",".dll",".so",".dylib",".woff",".woff2",".ttf",".eot",".pdf",".doc",".docx"]),yf=512*1024;async function ds(e){let t=[];async function s(i,n){let r;try{r=await ff(i)}catch{return}for(let o of r){if(o===".git"||o==="node_modules")continue;let a=hf(i,o),l=n?`${n}/${o}`:o;try{let c=await mf(a);if(c.isDirectory())await s(a,l);else if(c.isFile()){let f=o.includes(".")?`.${o.split(".").pop().toLowerCase()}`:"";if(gf.has(f)||c.size>yf)continue;try{let d=await pf(a,"utf-8");t.push({relPath:l,content:d,lineCount:d.split(`
|
|
143
|
+
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var Ji=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 bf(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=Ki(m.hint,S);i.push(`${g}${w} ${u.dim(v)}`)}else{let v=Ki(m.label,s-b);i.push(`${g}${u.bold(v)}`)}}else{let S=Ki(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 Ki(e,t){return t<=0?"":e.length<=t?e:t<=3?e.slice(0,t):e.slice(0,t-3)+"..."}async function Qe(e){let{items:t}=e,s=e.pageSize??Math.min(t.length+1,15),i=new Ji(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=bf(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]:""}
|
|
143
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===`
|
|
144
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`
|
|
145
|
-
`: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 Oe=
|
|
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 Oe=vf(wf),Pf=/^[a-zA-Z0-9_-]+$/,Nf=/^[a-zA-Z0-9._-]+$/,If=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,Zo=128,Rf=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function zi(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 ta(e){if(!e.includes("/")&&!e.includes("\\"))return!1;try{return(await ea(Gi(e))).isDirectory()}catch{return!1}}function Lf(e){let t;e==="~"?t=Qo():e.startsWith("~/")||e.startsWith("~\\")?t=Gi(Qo(),e.slice(2)):t=Gi(e);let s=Af(t);return I(`install: parsed local source -> path=${t}`),{owner:"local",repo:s,ref:null,subpath:null,cloneUrl:"",sshCloneUrl:"",isLocal:!0,localPath:t}}function Te(e){if(zi(e))return Lf(e);let t=Rf.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}"
|
|
146
147
|
Supported formats:
|
|
147
148
|
github:owner/repo[#ref]
|
|
148
149
|
github:owner/repo#ref:path
|
|
149
150
|
https://github.com/owner/repo
|
|
150
151
|
https://github.com/owner/repo/tree/branch/path/to/skill
|
|
151
152
|
/path/to/local/skill
|
|
152
|
-
./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(!
|
|
153
|
-
`)){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 I(`install: resolved ref="${r}" subpath="${o}"`),{...e,ref:r,subpath:o||null}}}}catch(t){I(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function Me(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>
|
|
154
|
-
HTTPS: ${
|
|
155
|
-
SSH: ${
|
|
156
|
-
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of
|
|
157
|
-
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;I(`install: target ${e} \u2014 no conflict`)}}var
|
|
158
|
-
`),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
|
|
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(!Pf.test(l))throw new Error(`Invalid source: owner contains invalid characters: "${l}". Allowed: [a-zA-Z0-9_-]`);if(!Nf.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 I(`install: parsed source -> owner=${l} repo=${c} ref=${r} subpath=${o}`),f}async function ms(e){if(e.subpath!==null||!e.ref||!e.ref.includes("/"))return e;try{let{stdout:t}=await Oe("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 I(`install: resolved ref="${r}" subpath="${o}"`),{...e,ref:r,subpath:o||null}}}}catch(t){I(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function Me(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>Zo)throw new Error(`Invalid skill name: exceeds maximum length of ${Zo} characters`);if(!If.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 Of(e){let t=e.split(/[/\\]/).filter(Boolean),s=t.length>0?t[t.length-1]:e;return Me(s)}function sa(e){let t=new Map;for(let s of e){let i=Of(s),n=t.get(i);n?n.push(s):t.set(i,[s])}return[...t.entries()].filter(([,s])=>s.length>1).map(([s,i])=>({name:s,paths:i}))}async function De(){try{await Oe("git",["--version"]),I("install: git available")}catch{throw new Error("git is required for installing skills. Install git from https://git-scm.com")}}function Tf(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 fs(e){return e.killed?"Clone timed out after 60 seconds":`Clone failed: ${e.stderr||e.message}`}async function Hi(e,t,s){if(t!==null&&/^[0-9a-f]{40}$/i.test(t))return await Oe("git",["clone","--no-checkout",e,s],{timeout:6e4}),await Oe("git",["checkout",t],{cwd:s,timeout:3e4}),s;let n=["clone","--depth","1"];return t&&n.push("--branch",t),n.push(e,s),await Oe("git",n,{timeout:6e4}),s}async function Fe(e,t="auto"){I(`install: cloning ${e.owner}/${e.repo}${e.ref?` (ref: ${e.ref})`:""} (transport: ${t})`);let s=await zo(ge(Xo(),"asm-install-"));if(t==="ssh"||t==="https"){let i=t==="ssh"?e.sshCloneUrl:e.cloneUrl;try{return await Hi(i,e.ref,s)}catch(n){throw await ae(s),new Error(fs(n))}}try{return await Hi(e.cloneUrl,e.ref,s)}catch(i){if(!Tf(i))throw await ae(s),new Error(fs(i));I("install: HTTPS clone failed with auth error, retrying with SSH..."),await ae(s);let n=await zo(ge(Xo(),"asm-install-"));try{return await Hi(e.sshCloneUrl,e.ref,n)}catch(r){throw await ae(n),new Error(`Clone failed with both transports:
|
|
155
|
+
HTTPS: ${fs(i)}
|
|
156
|
+
SSH: ${fs(r)}`)}}}async function _e(e){let t=ge(e,"SKILL.md"),s;try{s=await Yi(t,"utf-8")}catch{throw new Error("Not a valid skill: SKILL.md not found in repository root")}let i=te(s),n=e.split(/[/\\]/).pop()||"unknown",r=i.name||n,o=ue(i);return I(`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 hs(e,t=5){let s=[];async function i(n,r,o){let a;try{a=await kf(n)}catch{return}for(let l of a){if(l===".git"||l==="node_modules")continue;let c=ge(n,l);try{if(!(await ea(c)).isDirectory())continue}catch{continue}let f=r?`${r}/${l}`:l,d=o+1,p=ge(c,"SKILL.md");try{let m=await Yi(p,"utf-8"),y=te(m);s.push({relPath:f,name:y.name||l,version:ue(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:yo(y),tokenCount:os(m)})}catch{d<t&&await i(c,f,d)}}}return await i(e,"",0),s.sort((n,r)=>n.name.localeCompare(r.name)),s}var Mf=[{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 ia(e){let t=[],s=await ds(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 Mf)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 gs(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 Wi(e.targetDir),await ps(e.targetDir,{recursive:!0,force:!0})}catch{}let s=e.sourceDir;try{await Sf(s,e.targetDir,{recursive:!0})}catch(a){throw new Error(`Failed to install: ${a.message}`)}let i=ge(e.targetDir,".git");try{await ps(i,{recursive:!0,force:!0})}catch{}I(`install: copied files to ${e.targetDir}`);let n=ge(e.targetDir,"SKILL.md");try{await Wi(n)}catch{throw new Error("Installation verification failed: SKILL.md not found at target")}let r=await Yi(n,"utf-8"),o=te(r);return{success:!0,path:e.targetDir,name:o.name||e.skillName,version:ue(o),provider:e.providerLabel,source:t}}async function na(e,t){let s=await gs(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=ge(r,e.skillName);await Ef(r,{recursive:!0});try{if((await $f(o)).isSymbolicLink())await ps(o);else{I(`install: skipping ${o} \u2014 existing non-symlink directory`);continue}}catch{}let a=Cf(r,e.targetDir);await xf(a,o,"dir"),I(`install: symlinked ${o} -> ${a}`)}return s.provider=`All (${t.map(i=>i.label).join(", ")})`,s}async function ae(e){try{await ps(e,{recursive:!0,force:!0})}catch{}}async function ra(){try{await Oe("npx",["--version"]),I("install: npx available")}catch{throw new Error("npx is required for Vercel method installation. Install Node.js from https://nodejs.org")}}async function oa(e,t){let s=["--yes","skills","add",e];t&&s.push("--skill",t),I(`install: running npx ${s.join(" ")}`);try{let i=await Oe("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 aa(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 Xe(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 Qe({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 Qi(e,t,s,i,n,r,o="global"){let a=o==="project"?n.project:n.global,l=oe(a),c=ge(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 la(e,t){try{if(await Wi(e),I(`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;I(`install: target ${e} \u2014 no conflict`)}}var Qc=uo(Or(),1);import{readFile as cy}from"fs/promises";import{join as uy}from"path";var zc=500;function dy(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 fy(e){let t=e.split(`
|
|
159
160
|
`),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(`
|
|
160
|
-
`);return null}function
|
|
161
|
+
`);return null}function py(e){let t=fy(e);if(t===null)return null;try{return(0,Qc.parse)(t),null}catch(s){return s.message||"invalid YAML"}}async function Xc(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=uy(e.path,"SKILL.md"),n=await cy(i,"utf-8");dy(n)||t.push({category:"empty-body",message:"SKILL.md contains only frontmatter with no body content"});let r=py(n);r&&t.push({category:"invalid-yaml",message:`SKILL.md has invalid YAML frontmatter: ${r}`})}catch{}let s=e.fileCount;return s!==void 0&&s>zc&&t.push({category:"high-file-count",message:`Skill has ${s} files (threshold: ${zc})`}),t}import{join as ky}from"path";import{homedir as Sy}from"os";import{readFile as my,writeFile as hy,mkdir as gy}from"fs/promises";import{dirname as yy}from"path";async function by(e){try{let t=await my(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 wy(e,t,s){let i={fetched_at:new Date().toISOString(),ttl_seconds:s,data:t};try{await gy(yy(e),{recursive:!0}),await hy(e,JSON.stringify(i,null,2),"utf-8"),I(`http: wrote cache -> ${e}`)}catch(n){I(`http: failed to write cache: ${n}`)}}function vy(e){let t=new Date(e.fetched_at).getTime();return(Date.now()-t)/1e3<e.ttl_seconds}async function Zc(e,t,s={}){let i=s.ttl??3600,n=s.noCache??!1,r=await by(t);if(r&&!n&&vy(r))return I(`http: cache hit (fresh) -> ${t}`),r.data;try{I(`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 wy(t,a,i),a}catch(o){return I(`http: fetch failed: ${o}`),r?(I(`http: using stale cache as fallback -> ${t}`),r.data):null}}var $y=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,xy=/^[a-zA-Z0-9_-]+$/,su=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9._-]+$/,Ey=/^[0-9a-f]{40}$/,Cy=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/,Ay=/^[a-z0-9-]+$/,Py=/^sha256:[0-9a-f]{64}$/,eu=["pass","warning","dangerous"];function pi(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 n=[{field:"name",pattern:$y,maxLength:128},{field:"author",pattern:xy,maxLength:39},{field:"description",maxLength:256},{field:"repository",pattern:su},{field:"commit",pattern:Ey},{field:"published_at"}];for(let{field:o,pattern:a,maxLength:l}of n){let c=s[o];if(c==null){t.push({field:o,message:`required field "${o}" is missing`});continue}if(typeof c!="string"){t.push({field:o,message:`"${o}" must be a string`});continue}if(c.length===0){t.push({field:o,message:`"${o}" must not be empty`});continue}l&&c.length>l&&t.push({field:o,message:`"${o}" exceeds maximum length of ${l}`}),a&&!a.test(c)&&t.push({field:o,message:`"${o}" does not match required pattern`})}let r=s.security_verdict;if(r==null?t.push({field:"security_verdict",message:'required field "security_verdict" is missing'}):(typeof r!="string"||!eu.includes(r))&&t.push({field:"security_verdict",message:`"security_verdict" must be one of: ${eu.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"||!Cy.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 l=s.tags[a];if(typeof l!="string"){t.push({field:`tags[${a}]`,message:"tag must be a string"});continue}l.length>32&&t.push({field:`tags[${a}]`,message:`tag "${l}" exceeds maximum length of 32`}),Ay.test(l)||t.push({field:`tags[${a}]`,message:`tag "${l}" does not match pattern (lowercase alphanumeric and hyphens)`}),o.has(l)&&t.push({field:`tags[${a}]`,message:`duplicate tag "${l}"`}),o.add(l)}}return s.checksum!==void 0&&(typeof s.checksum!="string"||!Py.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 Ny(e,t){let s=e.length,i=t.length;if(s===0)return i;if(i===0)return s;let n=new Array(i+1),r=new Array(i+1);for(let o=0;o<=i;o++)n[o]=o;for(let o=1;o<=s;o++){r[0]=o;for(let a=1;a<=i;a++){let l=e[o-1]===t[a-1]?0:1;r[a]=Math.min(n[a]+1,r[a-1]+1,n[a-1]+l)}[n,r]=[r,n]}return n[i]}function Iy(e,t,s=2){let i=[];for(let n of t){if(e===n)continue;let r=Ny(e,n);r<=s&&i.push({existingName:n,distance:r})}return i.sort((n,r)=>n.distance-r.distance)}var Tr=process.env.ASM_REGISTRY_URL??"https://raw.githubusercontent.com/luongnv89/asm-registry/main/index.json",Ry=process.env.ASM_REGISTRY_CACHE??ky(Sy(),".config","agent-skill-manager","registry-cache.json"),Ly=3600;function zt(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 Mr(e){return zt(e)?e.includes("/"):!1}async function Dr(e){let t=await Zc(Tr,Ry,{ttl:Ly,noCache:e?.noCache});if(!t)return null;if(typeof t!="object"||!Array.isArray(t.manifests)||typeof t.generated_at!="string")return I("registry: fetched index has invalid structure \u2014 discarding"),null;let s=[];for(let i of t.manifests){let n=pi(i);if(n.length>0){I(`registry: dropping invalid manifest entry (${i?.name??"unknown"}): ${n.map(r=>r.message).join(", ")}`);continue}if(!su.test(i.repository)){I(`registry: dropping manifest with unexpected repository URL: ${i.repository}`);continue}s.push(i)}return{generated_at:t.generated_at,manifests:s}}function Oy(e,t){return t.manifests.filter(s=>s.name.toLowerCase()===e.toLowerCase())}function Ty(e,t,s){return s.manifests.find(i=>i.author.toLowerCase()===e.toLowerCase()&&i.name.toLowerCase()===t.toLowerCase())??null}function tu(e,t,s=5){return Iy(e,t.manifests.map(n=>n.name),3).slice(0,s).map(n=>n.existingName)}async function iu(e,t){let s=await Dr(t);if(!s)return I("registry: failed to fetch index \u2014 skipping registry resolution"),{resolved:null,multipleMatches:[],suggestions:[]};if(Mr(e)){let[r,o]=e.split("/"),a=Ty(r,o,s);if(a)return{resolved:{manifest:a,source:"registry"},multipleMatches:[],suggestions:[]};let l=tu(o,s);return{resolved:null,multipleMatches:[],suggestions:l}}let i=Oy(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 n=tu(e,s);return{resolved:null,multipleMatches:[],suggestions:n}}function nu(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 My,access as ou,mkdir as Dy,cp as ru,rm as Fy,symlink as _y}from"fs/promises";import{join as au,basename as jy}from"path";function qy(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 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.dirName!="string"||!r.dirName)&&t.push(`skills[${i}]: missing or empty 'dirName'.`),(typeof r.provider!="string"||!r.provider)&&t.push(`skills[${i}]: missing or empty 'provider'.`),r.scope!=="global"&&r.scope!=="project"&&t.push(`skills[${i}]: invalid 'scope' "${String(r.scope)}". Must be "global" or "project".`)}return{valid:t.length===0,errors:t}}async function lu(e){let t;try{t=await My(e,"utf-8")}catch(n){throw n?.code==="ENOENT"?new Error(`Manifest file not found: ${e}`):new Error(`Failed to read manifest file: ${n.message}`)}let s;try{s=JSON.parse(t)}catch{throw new Error("Manifest file is not valid JSON.")}let i=qy(s);if(!i.valid)throw new Error(`Invalid manifest:
|
|
161
162
|
${i.errors.join(`
|
|
162
|
-
`)}`);return s}async function
|
|
163
|
+
`)}`);return s}async function By(e){try{return await ou(e),!0}catch{return!1}}function Uy(e,t){return e.providers.find(s=>s.name===t&&s.enabled)}function Vy(e,t,s,i){let n=Uy(e,t);if(!n)return null;let r=s==="global"?n.global:n.project,o=oe(r),a=jy(i);return!a||a==="."||a===".."?null:au(o,a)}function Ky(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 cu(e,t,s){let i=s?.config??await B(),n=s?.installedSkills??await X(i,"both"),r=[];for(let c of e.skills){if(t.scopeFilter!=="both"&&c.scope!==t.scopeFilter){I(`import: skipping "${c.name}" \u2014 scope "${c.scope}" filtered out`);continue}let f=Vy(i,c.provider,c.scope,c.dirName);if(!f){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:`Provider "${c.provider}" not found or not enabled.`});continue}let d=await By(f);if(d&&!t.force){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"skipped",reason:"Already installed.",path:f});continue}if(t.dryRun){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"dry-run",reason:d?"Would overwrite (--force).":"Would install.",path:f});continue}let p=Ky(n,c);if(!p){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:"No installed source found. Install the skill first with: asm install <source>"});continue}try{if(await Dy(au(f,".."),{recursive:!0}),d&&await Fy(f,{recursive:!0,force:!0}),c.isSymlink&&c.symlinkTarget)try{await ou(c.symlinkTarget),await _y(c.symlinkTarget,f),I(`import: symlinked "${c.name}" -> ${c.symlinkTarget} at ${f}`)}catch{await ru(p.realPath,f,{recursive:!0}),I(`import: symlink target unreachable, copied "${c.name}" from ${p.realPath} to ${f}`)}else await ru(p.realPath,f,{recursive:!0}),I(`import: copied "${c.name}" from ${p.realPath} to ${f}`);r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"installed",path:f})}catch(m){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:`Copy failed: ${m.message}`})}}let o=r.filter(c=>c.status==="installed").length,a=r.filter(c=>c.status==="skipped").length,l=r.filter(c=>c.status==="failed").length;return{total:r.length,installed:o,skipped:a,failed:l,results:r}}import{mkdir as Jy,writeFile as Hy,access as Wy}from"fs/promises";import{join as Gy}from"path";function Yy(e){return`---
|
|
163
164
|
name: ${e}
|
|
164
165
|
description: ""
|
|
165
166
|
license: ""
|
|
@@ -180,62 +181,62 @@ as instructions for when and how to use this skill.
|
|
|
180
181
|
## Instructions
|
|
181
182
|
|
|
182
183
|
- Step-by-step instructions for the agent
|
|
183
|
-
`}async function
|
|
184
|
-
`)}import{access as Py,lstat as Ny,mkdir as Iy,readdir as Ry,readFile as Zc,rm as Ly,stat as eu,symlink as Oy}from"fs/promises";import{join as di}from"path";async function Lr(e){let t;try{t=await eu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=di(e,"SKILL.md"),i;try{i=await Zc(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=re(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ue(n)}}async function tu(e,t,s,i){let n=di(t,s),r=!1;try{await Py(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await Ly(n,{recursive:!0,force:!0})}await Iy(t,{recursive:!0}),await Oy(e,n,"dir")}async function Or(e){let t;try{t=await eu(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 Ry(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=di(e,n);try{if(!(await Ny(r)).isDirectory())continue}catch{continue}let o=di(r,"SKILL.md");try{let a=await Zc(o,"utf-8"),l=re(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ue(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as sb,writeFile as ib,readdir as hu,access as gu,mkdir as nb,rm as rb}from"fs/promises";import{join as He,resolve as yu,dirname as ob}from"path";import{homedir as ab}from"os";import{fileURLToPath as lb}from"url";import{readdir as Ty,readFile as My}from"fs/promises";import{join as Dy}from"path";function Tr(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var _y=10,Fy=5,qy=3,jy=1;function By(e,t){let s=Tr(e),i=Tr(t.name),n=Tr(t.description),r=0;for(let o of s)i.has(o)&&(r+=_y),n.has(o)&&(r+=qy),t.name.toLowerCase().includes(o)&&(r+=Fy),t.description.toLowerCase().includes(o)&&(r+=jy);return r}async function su(e){let t=new Map,s;try{s=await Ty(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=Dy(e,i);try{let r=await My(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 ut(){let e=await su(ao()),t=await su(yt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var Uy=["license","creator","version"];function iu(e){return Uy.includes(e)}function nu(e,t){return e[t]||""}function Vy(e,t){if(t.has){for(let s of t.has)if(iu(s)&&!nu(e,s))return!1}if(t.missing){for(let s of t.missing)if(iu(s)&&nu(e,s))return!1}return!0}function ru(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 fi(e,t=20,s){let i=await ut(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!Vy(a,s))continue;let l=r?1:By(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 ou(){return(await ut()).reduce((t,s)=>t+s.skillCount,0)}import{readdir as Ky,readFile as au,stat as cu}from"fs/promises";import{join as Mr}from"path";var Jy=[{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"]}],lu=2,Hy=80,Wy=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],Gy=["bundles","data/bundles",".asm/bundles"];function Qt(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function uu(e,t,s){let i=Qt(e),n=Qt(t),r=Qt(s),o=`${i}-${n}`;return r.startsWith(o)?r:`${o}-${r}`}function Yy(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function zy(e,t){let s=Yy(e);return t.keywords.some(i=>s.includes(i))}function du(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function Qy(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 fu(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function Dr(e){let t=[];if(!e.skills||e.skills.length<lu)return t;for(let s of Jy){let i=e.skills.filter(r=>zy(r,s)).slice(0,Hy);if(i.length<lu)continue;let n=uu(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,Qt(e.owner),Qt(e.repo)],skills:fu(i.map(du)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function Xy(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=Qy(n.map(l=>{if(typeof l=="string"){let p=r.get(l);return p?du(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:uu(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:fu(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function Zy(e){try{return(await cu(e)).isFile()}catch{return!1}}async function eb(e){try{return(await cu(e)).isDirectory()}catch{return!1}}async function tb(e){let t=[];for(let s of Wy){let i=Mr(e,s);if(await Zy(i))try{t.push({relPath:s,data:JSON.parse(await au(i,"utf-8"))})}catch{}}for(let s of Gy){let i=Mr(e,s);if(!await eb(i))continue;let n=[];try{n=await Ky(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 au(Mr(i,r),"utf-8"))})}catch{}}}return t}async function pu(e,t){let s=[],i=await tb(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=Xy(a,t,n.relPath);l&&s.push(l)}}return pi(s)}function pi(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 mu(e){let t=e.bundles||[],s=Dr(e);return pi([...t,...s])}var cb=lb(import.meta.url),ub=ob(cb),Je=He(ab(),".config","agent-skill-manager","bundles"),mi=yu(ub,"..","data","bundles");function db(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 bu(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function wu(e,t){let s=t??await Le(),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 fb(){await nb(Je,{recursive:!0})}function Zt(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 _r(e){await fb();let t=`${Zt(e.name)}.json`,s=He(Je,t);return await ib(s,JSON.stringify(e,null,2)+`
|
|
185
|
-
`,"utf-8"),I(`bundle: saved to ${s}`),s}async function Xt(e){let t;try{t=await
|
|
184
|
+
`}async function uu(e,t){await Jy(t,{recursive:!0});let s=Gy(t,"SKILL.md"),i=Yy(e);await Hy(s,i,"utf-8")}async function du(e){try{return await Wy(e),!0}catch{return!1}}import{readdir as zy,stat as Qy}from"fs/promises";import{join as Xy}from"path";async function Zy(e){let t=0;try{let i=(await zy(e,{recursive:!0})).map(async r=>{try{let o=await Qy(Xy(e,r));if(o.isFile())return o.size}catch{}return 0});t=(await Promise.all(i)).reduce((r,o)=>r+o,0)}catch{}return t}async function pu(e,t){let s={},i={global:0,project:0},n={},r=e.map(async l=>{s[l.provider]=(s[l.provider]||0)+1,i[l.scope]++;let c=await Zy(l.path);return n[l.path]=c,c}),a=(await Promise.all(r)).reduce((l,c)=>l+c,0);return{totalSkills:e.length,byProvider:s,byScope:i,totalDiskBytes:a,perSkillDiskBytes:n,duplicateGroups:t.duplicateGroups.length,duplicateInstances:t.totalDuplicateInstances}}function eb(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 Fr(e,t,s=20){let i=Math.round(e/t*s),n=s-i;return u.green("#".repeat(i))+u.dim("-".repeat(n))}var fu={claude:"Claude Code",codex:"Codex",openclaw:"OpenClaw",agents:"Agents"};function mu(e){let t=[];t.push(""),t.push(u.blueBold(" Skill Statistics")),t.push(u.dim(" "+"-".repeat(20))),t.push(""),t.push(` ${u.bold("Total:")} ${u.cyan(String(e.totalSkills))} skills`),t.push(` ${u.bold("Disk:")} ${u.cyan(eb(e.totalDiskBytes))}`),t.push(""),t.push(u.bold(" By Tool"));let s=Object.entries(e.byProvider).sort((l,c)=>c[1]-l[1]),i=Math.max(...s.map(([,l])=>l)),n=Math.max(...s.map(([l])=>(fu[l]||l).length));for(let[l,c]of s){let f=fu[l]||l,d=xo(l,f.padEnd(n)),p=String(c).padStart(4);t.push(` ${d} ${p} ${Fr(c,i)}`)}t.push(""),t.push(u.bold(" By Scope"));let r=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(n)} ${o} ${Fr(e.byScope.global,r)}`),t.push(` ${"project".padEnd(n)} ${a} ${Fr(e.byScope.project,r)}`),t.push(""),t.push(u.bold(" Duplicates")),e.duplicateGroups>0?(t.push(` ${u.yellow(`${e.duplicateGroups} group(s), ${e.duplicateInstances} total instance(s)`)}`),t.push(u.dim(` Run ${u.bold("asm audit")} to review`))):t.push(` ${u.green("None")}`),t.push(""),t.join(`
|
|
185
|
+
`)}import{access as tb,lstat as sb,mkdir as ib,readdir as nb,readFile as hu,rm as rb,stat as gu,symlink as ob}from"fs/promises";import{join as mi}from"path";async function _r(e){let t;try{t=await gu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=mi(e,"SKILL.md"),i;try{i=await hu(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=te(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ue(n)}}async function yu(e,t,s,i){let n=mi(t,s),r=!1;try{await tb(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await rb(n,{recursive:!0,force:!0})}await ib(t,{recursive:!0}),await ob(e,n,"dir")}async function jr(e){let t;try{t=await gu(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 nb(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=mi(e,n);try{if(!(await sb(r)).isDirectory())continue}catch{continue}let o=mi(r,"SKILL.md");try{let a=await hu(o,"utf-8"),l=te(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ue(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as Nb,writeFile as Ib,readdir as Ru,access as Lu,mkdir as Rb,rm as Lb}from"fs/promises";import{join as He,resolve as Ou,dirname as Ob}from"path";import{homedir as Tb}from"os";import{fileURLToPath as Mb}from"url";import{readdir as ab,readFile as lb}from"fs/promises";import{join as cb}from"path";function qr(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var ub=10,db=5,fb=3,pb=1;function mb(e,t){let s=qr(e),i=qr(t.name),n=qr(t.description),r=0;for(let o of s)i.has(o)&&(r+=ub),n.has(o)&&(r+=fb),t.name.toLowerCase().includes(o)&&(r+=db),t.description.toLowerCase().includes(o)&&(r+=pb);return r}async function bu(e){let t=new Map,s;try{s=await ab(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=cb(e,i);try{let r=await lb(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 ut(){let e=await bu(ho()),t=await bu(yt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var hb=["license","creator","version"];function wu(e){return hb.includes(e)}function vu(e,t){return e[t]||""}function gb(e,t){if(t.has){for(let s of t.has)if(wu(s)&&!vu(e,s))return!1}if(t.missing){for(let s of t.missing)if(wu(s)&&vu(e,s))return!1}return!0}function ku(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 hi(e,t=20,s){let i=await ut(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!gb(a,s))continue;let l=r?1:mb(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 Su(){return(await ut()).reduce((t,s)=>t+s.skillCount,0)}import{readdir as yb,readFile as $u,stat as Eu}from"fs/promises";import{join as Br}from"path";var bb=[{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"]}],xu=2,wb=80,vb=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],kb=["bundles","data/bundles",".asm/bundles"];function Qt(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Cu(e,t,s){let i=Qt(e),n=Qt(t),r=Qt(s),o=`${i}-${n}`;return r.startsWith(o)?r:`${o}-${r}`}function Sb(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function $b(e,t){let s=Sb(e);return t.keywords.some(i=>s.includes(i))}function Au(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function xb(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 Pu(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function Ur(e){let t=[];if(!e.skills||e.skills.length<xu)return t;for(let s of bb){let i=e.skills.filter(r=>$b(r,s)).slice(0,wb);if(i.length<xu)continue;let n=Cu(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,Qt(e.owner),Qt(e.repo)],skills:Pu(i.map(Au)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function Eb(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=xb(n.map(l=>{if(typeof l=="string"){let p=r.get(l);return p?Au(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:Cu(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:Pu(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function Cb(e){try{return(await Eu(e)).isFile()}catch{return!1}}async function Ab(e){try{return(await Eu(e)).isDirectory()}catch{return!1}}async function Pb(e){let t=[];for(let s of vb){let i=Br(e,s);if(await Cb(i))try{t.push({relPath:s,data:JSON.parse(await $u(i,"utf-8"))})}catch{}}for(let s of kb){let i=Br(e,s);if(!await Ab(i))continue;let n=[];try{n=await yb(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 $u(Br(i,r),"utf-8"))})}catch{}}}return t}async function Nu(e,t){let s=[],i=await Pb(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=Eb(a,t,n.relPath);l&&s.push(l)}}return gi(s)}function gi(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 Iu(e){let t=e.bundles||[],s=Ur(e);return gi([...t,...s])}var Db=Mb(import.meta.url),Fb=Ob(Db),Je=He(Tb(),".config","agent-skill-manager","bundles"),yi=Ou(Fb,"..","data","bundles");function _b(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 Tu(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function Mu(e,t){let s=t??await Le(),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 jb(){await Rb(Je,{recursive:!0})}function Zt(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 Vr(e){await jb();let t=`${Zt(e.name)}.json`,s=He(Je,t);return await Ib(s,JSON.stringify(e,null,2)+`
|
|
186
|
+
`,"utf-8"),I(`bundle: saved to ${s}`),s}async function Xt(e){let t;try{t=await Nb(e,"utf-8")}catch(n){throw n?.code==="ENOENT"?new Error(`Bundle file not found: ${e}`):new Error(`Failed to read bundle file: ${n.message}`)}let s;try{s=JSON.parse(t)}catch{throw new Error("Bundle file is not valid JSON.")}let i=_b(s);if(!i.valid)throw new Error(`Invalid bundle:
|
|
186
187
|
${i.errors.join(`
|
|
187
|
-
`)}`);return s}async function es(e){if(e.includes("/")||e.includes("\\")||e.endsWith(".json")){let i=
|
|
188
|
-
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let f of
|
|
189
|
-
`)}function
|
|
188
|
+
`)}`);return s}async function es(e){if(e.includes("/")||e.includes("\\")||e.endsWith(".json")){let i=Ou(e);return Xt(i)}let t=`${Zt(e)}.json`,s=He(Je,t);try{return await Xt(s)}catch(i){if(i?.message?.includes("Bundle file not found")){let n=He(yi,t);try{return await Xt(n)}catch(r){if(r?.message?.includes("Bundle file not found")){let o=await qb(e);if(o)return o;throw new Error(`Bundle file not found: ${s}`)}throw r}}throw i}}async function Du(){let e=[];try{await Lu(yi);let s;try{s=await Ru(yi)}catch{s=[]}for(let i of s){if(!i.endsWith(".json"))continue;let n=He(yi,i);try{let r=await Xt(n);e.push(r)}catch{I(`bundle: skipping invalid predefined file ${n}`)}}}catch{}e.push(...await Fu());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 Fu(){try{return(await ut()).flatMap(t=>Iu(t))}catch(e){return I(`bundle: failed to load repo-derived bundles: ${e}`),[]}}async function qb(e){let t=Zt(e),s=await Fu();return s.find(i=>i.name===e)||s.find(i=>Zt(i.name)===t)||null}async function _u(){let e=[];try{await Lu(Je)}catch{return e}let t;try{t=await Ru(Je)}catch{return e}for(let s of t){if(!s.endsWith(".json"))continue;let i=He(Je,s);try{let n=await Xt(i);e.push(n)}catch{I(`bundle: skipping invalid file ${i}`)}}return e.sort((s,i)=>s.name.localeCompare(i.name)),e}async function ju(e){let t=`${Zt(e)}.json`,s=He(Je,t);try{return await Lb(s),I(`bundle: removed ${s}`),!0}catch(i){if(i?.code==="ENOENT")return!1;throw i}}import{readFile as zb,realpath as Qb}from"fs/promises";import{join as Xb,resolve as Zb,relative as ew}from"path";var Uu=[{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 Bb(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 n=await i.json();if(s.isOrganization=n.type==="Organization",s.publicRepos=typeof n.public_repos=="number"?n.public_repos:null,typeof n.created_at=="string"){let r=new Date(n.created_at),o=new Date,a=Math.floor((o.getTime()-r.getTime())/(365.25*24*60*60*1e3)),l=Math.floor((o.getTime()-r.getTime())%(365.25*24*60*60*1e3)/(30.44*24*60*60*1e3));s.accountAge=a>0?`${a}y ${l}m`:`${l}m`}I(`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",I(`security-audit: source analysis failed -> ${s.fetchError}`)}return s}function Ub(e){let t=new Map;for(let{relPath:n,content:r}of e){let o=r.split(`
|
|
189
|
+
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let f of Uu)if(f.pattern.test(l)){let d=f.category;t.has(d)||t.set(d,{description:f.description,matches:[]});let p=c.length>120?c.slice(0,120)+"...":c;t.get(d).matches.push({file:n,line:a+1,match:p,severity:f.severity})}}}let s=[];for(let[n,r]of t)s.push({category:n,description:r.description,matches:r.matches});let i={critical:0,warning:1,info:2};return s.sort((n,r)=>{let o=Math.min(...n.matches.map(l=>i[l.severity])),a=Math.min(...r.matches.map(l=>i[l.severity]));return o-a}),s}function Vb(e){let t=new Map;for(let r of e)for(let o of r.matches)for(let a of Uu)if(a.permissionType&&a.category===r.category&&a.pattern.test(o.match)){let l=a.permissionType;t.has(l)||t.set(l,{evidence:[],categories:new Set});let c=t.get(l);c.evidence.push({file:o.file,line:o.line,match:o.match}),c.categories.add(r.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[r,o]of t)i.push({type:r,evidence:o.evidence,reason:s[r]});let n={shell:0,"code-execution":1,network:2,filesystem:3,environment:4};return i.sort((r,o)=>(n[r.type]??99)-(n[o.type]??99)),i}function Kb(e,t,s){let i=0,n=0;for(let l of e)for(let c of l.matches)c.severity==="critical"&&i++,c.severity==="warning"&&n++;let r=t.some(l=>l.type==="shell"),o=t.some(l=>l.type==="code-execution"),a=t.some(l=>l.type==="network");return r&&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.`}:r||o?{verdict:"warning",reason:r?"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.`}:n>0?{verdict:"caution",reason:`${n} warning${n>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 Re(e,t,s,i){I(`security-audit: scanning ${e}`);let n=await ds(e),r=n.reduce((d,p)=>d+p.lineCount,0),o=null;s&&i&&(o=await Bb(s,i));let a=Ub(n),l=Vb(a),{verdict:c,reason:f}=Kb(a,l,o);return{scannedAt:new Date().toISOString(),skillName:t,skillPath:e,source:o,codeScans:a,permissions:l,totalFiles:n.length,totalLines:r,verdict:c,verdictReason:f}}var R=u,We=56,Jb={"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"},qu={critical:0,warning:1,info:2};function Hb(e){switch(e){case"safe":return R.bgGreen(" SAFE ");case"caution":return R.bgCyan(" CAUTION ");case"warning":return R.bgYellow(" WARNING ");case"dangerous":return R.bgRed(" DANGEROUS ")}}function Wb(e){switch(e){case"safe":return R.green;case"caution":return R.cyan;case"warning":return R.yellow;case"dangerous":return R.red}}function dt(e){switch(e){case"critical":return R.red("!!");case"warning":return R.yellow(" !");case"info":return R.dim(" i")}}function Kr(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function bi(e){return e.toLocaleString("en-US")}function Vu(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Bu(e){return Vu(e).length}function Gb(e){let t=new Map;for(let s of e){let i=`${s.file}:${s.line}`,n=t.get(i);(!n||qu[s.severity]<qu[n.severity])&&t.set(i,s)}return Array.from(t.values())}function Yb(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 wi(e){let t=[],s=Hb(e.verdict),i=Vu(s),n=` ${R.bold(e.skillName)}`,r=` ${e.skillName}`,o=We-4,a=Math.max(1,o-r.length-i.length);if(t.push(""),t.push(R.dim(" +-- ")+R.bold("Security Audit")+R.dim(" "+"-".repeat(We-19)+"+")),t.push(R.dim(" |")+n+" ".repeat(a)+s+R.dim("|")),t.push(R.dim(" |")+R.dim(` ${bi(e.totalFiles)} files | ${bi(e.totalLines)} lines`)+" ".repeat(Math.max(1,o-` ${bi(e.totalFiles)} files | ${bi(e.totalLines)} lines`.length))+R.dim("|")),t.push(R.dim(" +"+"-".repeat(We-2)+"+")),e.source){let d=e.source;if(d.fetchError)t.push(` ${R.yellow("!")} Could not fetch profile: ${d.fetchError}`);else{let p=[];if(p.push(`${d.owner} ${d.isOrganization?R.cyan("(org)"):R.dim("(user)")}`),d.publicRepos!==null){let m=d.publicRepos,y=m<3?R.yellow(`${m} repos`):m<10?R.cyan(`${m} repos`):R.green(`${m} repos`);p.push(y)}d.accountAge&&p.push(d.accountAge),t.push(` ${R.dim("Author:")} ${p.join(R.dim(" | "))}`)}}if(t.push(""),e.codeScans.length===0)t.push(` ${R.green("*")} ${R.green("No suspicious patterns detected.")}`);else{let d=Wb(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 k of e.codeScans)for(let S of k.matches)S.severity==="critical"?m++:S.severity==="warning"?y++:h++;let g=[];m>0&&g.push(R.red(`${m} critical`)),y>0&&g.push(R.yellow(`${y} warning`)),h>0&&g.push(R.dim(`${h} info`));let b=e.permissions.map(k=>k.type),w=b.length>0?R.dim(`Perms: ${b.join(", ")}`):"";t.push(` ${g.join(R.dim(" | "))} ${w}`)}if(t.push(""),e.codeScans.length>0){t.push(` ${R.bold("Findings")}`),t.push(R.dim(" "+"=".repeat(We-2)));for(let d of e.codeScans){let p=Gb(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(R.red(`${m} critical`)),y>0&&b.push(R.yellow(`${y} warning`)),h>0&&b.push(R.dim(`${h} info`));let w=Jb[d.category],k=w?R.dim(`PERM: ${w}`):"",S=` ${g} ${R.bold(d.category)} (${b.join(", ")})`;if(k){let O=Bu(S),D=Bu(k),T=Math.max(2,We-O-D);t.push(S+" ".repeat(T)+k)}else t.push(S);let v=Yb(p),C=Math.min(24,Math.max(...v.map(O=>O.file.length))),E=0,x=3;for(let O of v){if(E>=x)break;let D=Kr(O.file,24),T=R.dim(D.padEnd(C));if(O.entries.length===1){let A=O.entries[0],N=Kr(A.match,50);t.push(` ${T} :${A.line} ${R.dim("--")} ${A.severity==="critical"?N:R.dim(N)}`),E++}else if(O.entries.length<=3){let A=O.entries.map(_=>`:${_.line}`).join(", "),N=Kr(O.entries[0].match,40);t.push(` ${T} ${A} ${R.dim("--")} ${R.dim(N)}`),E++}else{let N=O.entries.slice(0,3).map(L=>`:${L.line}`).join(", "),_=O.entries.length-3;t.push(` ${T} ${N} ${R.dim(`(+${_} more)`)}`),E++}}let M=v.length-Math.min(v.length,x);if(M>0){let O=p.length-v.slice(0,x).reduce((D,T)=>D+T.entries.length,0);O>0&&t.push(` ${R.dim(`... ${O} more in ${M} file${M>1?"s":""}`)}`)}t.push("")}}t.push(R.dim(" "+"=".repeat(We-2)));let l=new Date(e.scannedAt),c=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")} ${String(l.getHours()).padStart(2,"0")}:${String(l.getMinutes()).padStart(2,"0")}`,f=e.source&&!e.source.fetchError?`github.com/${e.source.owner}`:"";if(f){let d=Math.max(2,We-2-c.length-f.length);t.push(R.dim(` ${c}${" ".repeat(d)}${f}`))}else t.push(R.dim(` ${c}`));return t.push(""),t.join(`
|
|
190
|
+
`)}function Jr(e){return JSON.stringify(e,null,2)}async function H(e,t={}){if(e.length===0)throw new Error("runCommand requires a non-empty argv");let{spawn:s}=await import("child_process"),[i,...n]=e;return new Promise((r,o)=>{let a=s(i,n,{cwd:t.cwd,stdio:["ignore","pipe","pipe"]}),l="",c="",f=!1;a.stdout?.on("data",d=>{l+=d.toString()}),a.stderr?.on("data",d=>{c+=d.toString()}),a.on("error",d=>{if(f)return;if(f=!0,d.code==="ENOENT"){r({exitCode:127,stdout:l,stderr:d.message});return}o(d)}),a.on("close",d=>{f||(f=!0,r({exitCode:d??-1,stdout:l,stderr:c}))})})}function vi(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 tw(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/</g,"<").replace(/>/g,">").replace(/\|/g,"\\|")}function Hr(e){return tw(vi(e))}var Ge="luongnv89/asm-registry";async function sw(e){let t=Xb(e,"SKILL.md"),s;try{s=await zb(t,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}. Run "asm init" to create one.`)}let i=te(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 n=ue(i),r=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:n,license:i.license||"MIT",creator:i.creator||"",tags:r}}async function iw(e){let{exitCode:t}=await H(["git","rev-parse","--git-dir"],{cwd:e});if(t!==0)throw new Error(`${e} is not inside a git repository.`)}async function nw(e){let{stdout:t,exitCode:s}=await H(["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 rw(e){let{stdout:t,exitCode:s}=await H(["git","rev-parse","--show-toplevel"],{cwd:e});if(s!==0)throw new Error("Failed to determine git repository root.");return t.trim()}async function ow(e){let{stdout:t,exitCode:s}=await H(["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(),n=i.match(/^git@github\.com:([a-zA-Z0-9_-]+)\/([a-zA-Z0-9._-]+?)(?:\.git)?$/);return n?`https://github.com/${n[1]}/${n[2]}`:i.replace(/\.git$/,"")}async function aw(){let{exitCode:e}=await H(["gh","--version"]);if(e!==0)return{available:!1,authenticated:!1,login:null};let{exitCode:t}=await H(["gh","auth","status"]);if(t!==0)return{available:!0,authenticated:!1,login:null};let{stdout:s,exitCode:i}=await H(["gh","api","user","--jq",".login"]);return{available:!0,authenticated:!0,login:i===0?s.trim():null}}function lw(e){switch(e){case"safe":case"caution":return"pass";case"warning":return"warning";case"dangerous":return"dangerous"}}function Ku(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 cw(e){let t=Ku({metadata:e.metadata,author:e.metadata.creator||"unknown",commit:e.commit,repository:e.repository,securityVerdict:e.registryVerdict}),s=pi(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 Ju(e){let t=Zb(e.path);I(`publish: starting for ${t}`),await iw(t);let s=await sw(t);I(`publish: parsed metadata for "${s.name}"`);let n=await(e._auditFn??Re)(t,s.name),r=lw(n.verdict);if(r==="dangerous")return{success:!1,manifest:null,prUrl:null,error:`Security audit verdict: dangerous. ${n.verdictReason}`,securityVerdict:r,securityReport:n};if(r==="warning"&&!e.force)return{success:!1,manifest:null,prUrl:null,error:"Security audit verdict: warning. Use --force to override warnings.",securityVerdict:r,securityReport:n};let o=await nw(t),a=await ow(t),l=await rw(t),c=await Qb(t),f=ew(l,c),d=f&&f!=="."?f:void 0,m=await(e._checkGhCliFn??aw)();if(!m.available||!m.authenticated){let U=m.available?"gh CLI not authenticated":"gh CLI not found";return cw({metadata:s,commit:o,repository:a,registryVerdict:r,securityReport:n,fallbackReason:U})}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=Ku({metadata:s,author:y,commit:o,repository:a,skillPath:d,securityVerdict:r}),g=pi(h);if(g.length>0)return{success:!1,manifest:h,prUrl:null,error:`Manifest validation failed: ${g.map(U=>`${U.field}: ${U.message}`).join("; ")}`,securityVerdict:r,securityReport:n};if(e.dryRun)return{success:!0,manifest:h,prUrl:null,error:null,securityVerdict:r,securityReport:n};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:r,securityReport:n};let U=vi(s.name),ze=vi(y);process.stderr.write(`
|
|
190
191
|
About to publish "${U}" by ${ze} to ${Ge}.
|
|
191
192
|
Security verdict: ${r}
|
|
192
193
|
|
|
193
|
-
Proceed? [y/N] `);let
|
|
194
|
-
`)&&(process.stdin.removeListener("data",ns),process.stdin.pause(),
|
|
195
|
-
`,S=Buffer.from(k,"utf-8").toString("base64"),{stdout:v,exitCode:
|
|
196
|
-
`),{stdout:L,stderr:
|
|
194
|
+
Proceed? [y/N] `);let re=await new Promise(ce=>{let ve="",ns=ht=>{ve+=ht.toString(),ve.includes(`
|
|
195
|
+
`)&&(process.stdin.removeListener("data",ns),process.stdin.pause(),ce(ve.trim()))};process.stdin.resume(),process.stdin.on("data",ns)});if(re.toLowerCase()!=="y"&&re.toLowerCase()!=="yes")return{success:!1,manifest:h,prUrl:null,error:"Publish aborted by user.",securityVerdict:r,securityReport:n}}I(`publish: forking ${Ge}`),await H(["gh","repo","fork",Ge,"--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:M,exitCode:O}=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(O!==0){let{stdout:U,exitCode:ze}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}?ref=${b}`,"-q",".sha"]),re=U.trim();if(ze===0&&re){let{exitCode:ce}=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=${re}`]);if(ce!==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. ${M}`,securityVerdict:r,securityReport:n}}let D=Hr(s.name),T=Hr(s.description),A=Hr(s.license),N=`Publish ${y}/${vi(s.name)}`,_=[`## Skill: ${D}`,"",`**Author:** ${y}`,`**Version:** ${s.version}`,`**Description:** ${T}`,`**License:** ${A}`,`**Repository:** ${a}`,`**Commit:** \`${o}\``,`**Security verdict:** ${r}`,"","---","","*This PR was generated by `asm publish`.*"].join(`
|
|
197
|
+
`),{stdout:L,stderr:F,exitCode:ne}=await H(["gh","pr","create","--repo",Ge,"--head",`${y}:${b}`,"--title",N,"--body",_]),K=null;if(ne===0)K=L.trim();else{let U=F.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/);U&&(K=U[0])}return K?{success:!0,manifest:h,prUrl:K,error:null,securityVerdict:r,securityReport:n}:{success:!1,manifest:h,prUrl:null,error:`Failed to create PR against ${Ge}. ${F}`,securityVerdict:r,securityReport:n}}function Hu(e){let t=e.manifest;return t?["",` gh CLI is unavailable (${e.fallbackReason}).`," To publish manually:","",` 1. Fork ${Ge} 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 ${Ge}`,"",' Run "asm doctor" to fix your environment.',""," Generated manifest:",JSON.stringify(t,null,2).split(`
|
|
197
198
|
`).map(i=>` ${i}`).join(`
|
|
198
199
|
`)].join(`
|
|
199
|
-
`):""}import{execFile as
|
|
200
|
-
`)[0];if(!n)return null;let r=n.split(/\s+/)[0];return r&&/^[0-9a-f]{40}$/.test(r)?r:null}catch(s){return I(`updater: git ls-remote failed for ${e}: ${s}`),null}}function
|
|
201
|
-
`)}function
|
|
202
|
-
`)[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
|
|
203
|
-
`);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
|
|
204
|
-
`)}function
|
|
200
|
+
`):""}import{execFile as uw}from"child_process";import{promisify as dw}from"util";import{rm as ki,rename as Wu,cp as Gu,access as fw,mkdir as pw}from"fs/promises";import{join as Si}from"path";import{homedir as Yu}from"os";var Wr=dw(uw);async function mw(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 hw(e,t){try{let s=["ls-remote",e];t?s.push(t):s.push("HEAD");let{stdout:i}=await Wr("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 I(`updater: git ls-remote failed for ${e}: ${s}`),null}}function Gr(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 gw(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 Yr(e){let t=e?.readLockFn??Le,s=e?.fetchRegistryIndexFn??Dr,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])=>Gr(l)==="registry"||l.registryName)&&(r=await s());let a=await mw(n,5,async([l,c])=>{let f=Gr(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:he(c.commitHash),latestCommit:he(h.commit),source:c.source,sourceType:f,status:g?"outdated":"up-to-date"}}}let d=zu(c.source);if(!d)return{name:l,installedCommit:he(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:f,status:"error",error:"Cannot determine remote URL"};let p=await hw(d,c.ref);if(!p)return{name:l,installedCommit:he(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:he(c.commitHash),latestCommit:he(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 yw(e,t,s,i){if(Gr(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=Si(Yu(),".config","agent-skill-manager",".tmp",`${e}-${Date.now()}`);try{let a=Si(Yu(),".config","agent-skill-manager",".tmp");await pw(a,{recursive:!0}),I(`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 Wr("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 Wr("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"};I(`updater: running security audit on ${e}`);let f="safe";try{let v=i?.auditFn??Re,C=gw(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};I(`updater: security audit ${f} for ${e} \u2014 proceeding (--yes)`)}}catch(v){return I(`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??B,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=Si(g,e),w=Si(o,".git");try{await ki(w,{recursive:!0,force:!0})}catch{}try{await fw(b)}catch{let v=i?.writeLockEntryFn??bt;return await Gu(o,b,{recursive:!0}),await v(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:he(t.commitHash),newCommit:he(c),securityVerdict:f}}let k=`${b}.bak-${Date.now()}`;try{await Wu(b,k),await Gu(o,b,{recursive:!0}),await ki(k,{recursive:!0,force:!0})}catch(v){try{await ki(b,{recursive:!0,force:!0}),await Wu(k,b)}catch{}return{name:e,status:"failed",reason:`Atomic swap failed: ${v.message}`}}return await(i?.writeLockEntryFn??bt)(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:he(t.commitHash),newCommit:he(c),securityVerdict:f}}finally{try{await ki(o,{recursive:!0,force:!0})}catch{}}}async function Qu(e,t,s){let i=s?.readLockFn??Le,n=s?.checkOutdatedFn??Yr,r=s?.updateSkillFn??yw,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())?I(`updater: skill "${p}" is already up to date`):(I(`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 he(e){return!e||e==="unknown"?"unknown":e.slice(0,7)}function Xu(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 Zu(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 ed(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 Iw}from"child_process";import{promisify as Rw}from"util";import{access as td,readFile as id,readdir as Lw,writeFile as Ow,rm as Tw,stat as nd}from"fs/promises";import{join as zr}from"path";import{homedir as Mw}from"os";import{constants as sd}from"fs";import{access as bw,realpath as ww,stat as vw}from"fs/promises";import{constants as kw}from"fs";import{delimiter as Sw,resolve as $w,sep as xw}from"path";var Ew="asm";function Cw(e){if(!e)return[];let t=new Set,s=[];for(let i of e.split(Sw)){let n=i.trim();if(!n)continue;let r=n.endsWith(xw)?n.slice(0,-1):n;t.has(r)||(t.add(r),s.push(r))}return s}async function Aw(e){try{if(!(await vw(e)).isFile())return!1}catch{return!1}try{return await bw(e,kw.X_OK),!0}catch{return!1}}async function Pw(e){try{return await ww(e)}catch{return e}}async function Nw(e=process.env.PATH){let t=new Set,s=[];for(let i of Cw(e)){let n=$w(i,Ew);if(!await Aw(n))continue;let r=await Pw(n);t.has(r)||(t.add(r),s.push({path:n,realPath:r}))}return s}async function $i(e=process.env.PATH){let t=await Nw(e);if(t.length===0)return{resolved:null,shadowed:[]};let[s,...i]=t;return{resolved:s,shadowed:i}}var ft=Rw(Iw);async function Dw(e){let t=e?.execFn??ft;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 Fw(e){let t=e?.execFn??ft;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 _w(e){let t=e?.execFn??ft;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 jw(e){let t=e?.execFn??ft;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 qw(e){let t=e?.execFn??ft;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 Bw(e){try{let t=zr(e,".asm-doctor-write-test");return await Ow(t,"test","utf-8"),await Tw(t),{writable:!0,exists:!0}}catch{}try{return await td(e,sd.W_OK),{writable:!0,exists:!0}}catch{}try{return await td(e,sd.F_OK),{writable:!1,exists:!0}}catch{return{writable:!0,exists:!1}}}async function Uw(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 Bw(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 Vw(){let e=gt();try{let t=await id(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 Kw(){let e=mo();try{let t=await id(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 Jw(){try{let e=await fetch(Tr,{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 Hw(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 nd(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 Ww(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 Lw(r);for(let a of o)try{(await nd(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 Gw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("df",["-Pk",Mw()],{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 Yw(){try{let e=await $i();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 rd(){let e=await B(),t=await Le(),i=(await Promise.allSettled([Dw(),Fw(),_w(),jw(),qw(),Uw(e),Vw(),Kw(),Jw(),Hw(e,t),Ww(e,t),Gw(),Yw()])).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 zw={pass:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function od(e){let t=["Checking your environment...",""];for(let s of e.checks){let n=` ${zw[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 ad(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 Xr,writeFile as Qw,stat as pt,copyFile as Xw,readdir as fd}from"fs/promises";import{join as mt,resolve as eo,basename as we,isAbsolute as to}from"path";var Zr="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`).",ld=["name","description","version","license","author","creator","compatibility","allowed-tools","effort","tags","metadata"],cd=["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"],Zw=["confirm","confirmation","error","errors","fail","failure","caution","warning","prerequisite","prerequisites","requires","requirements","rollback","dry-run","dry run","safety","validate","validation","check","backup"],ev=["acceptance criteria","expected output","expected result","edge case","edge cases","test","tests","testing","verify","verification","assert","example input","example output","given","then"],tv=["reference","references","see","template","templates","script","scripts","helper","helpers","link"],sv=["when to use","quick start","overview","instructions","steps","workflow","phases","progressive"];function pd(e){let t=e.split(`
|
|
205
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(`
|
|
206
207
|
`),n=t.slice(s+1).join(`
|
|
207
208
|
`);return{rawFrontmatter:i,body:n}}return{rawFrontmatter:t.slice(1).join(`
|
|
208
|
-
`),body:""}}function
|
|
209
|
-
`).length:0}function zr(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function Iw(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function ki(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function Rw(e){return/```[\s\S]+?```/m.test(e)}function Lw(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function Ow(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=ue(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=Iw(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(Wr))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function Tw(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=zr(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&&(Wu.includes(a)||Wu.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 Mw(e,t){let s=[],i=[],n=0,r=ki(t,Nw);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.'),Lw(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=Rw(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=zr(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 Dw(e,t){let s=[],i=[],n=0,r=zr(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=ki(t,Pw);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=>Xu(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 _w(e,t){let s=[],i=[],n=0,r=ki(t,Aw);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 Fw(e,t){let s=[],i=[],n=0,r=ki(t,Cw);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 qw(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 ts(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=re(t),{rawFrontmatter:o,body:a}=Qu(t),l=[Ow(r,a,o,n),Tw(r,a),Mw(r,a),Dw(r,a),_w(r,a),Fw(r,a),qw(r,a)];if(r.name&&we(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(Wr)&&m.push(Wr);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 Zu(e){let t=Yr(e)?e:Gr(e),s;try{s=await pt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Hr(i,"utf-8"),ts({content:n,skillPath:we(t)==="SKILL.md"?we(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=mt(t,"SKILL.md");try{n=await Hr(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await zu(t)}catch{r=void 0}return ts({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function jw(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function Bw(e){let t=e.split(`
|
|
209
|
+
`),body:""}}function md(e){return e?e.split(`
|
|
210
|
+
`).length:0}function so(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function iv(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function xi(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function nv(e){return/```[\s\S]+?```/m.test(e)}function rv(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function ov(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=ue(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=iv(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(Zr))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function av(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=so(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&&(cd.includes(a)||cd.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 lv(e,t){let s=[],i=[],n=0,r=xi(t,sv);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.'),rv(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=nv(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=so(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 cv(e,t){let s=[],i=[],n=0,r=so(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=xi(t,tv);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=>md(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 uv(e,t){let s=[],i=[],n=0,r=xi(t,Zw);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 dv(e,t){let s=[],i=[],n=0,r=xi(t,ev);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 fv(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 ts(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=te(t),{rawFrontmatter:o,body:a}=pd(t),l=[ov(r,a,o,n),av(r,a),lv(r,a),cv(r,a),uv(r,a),dv(r,a),fv(r,a)];if(r.name&&we(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(Zr)&&m.push(Zr);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 hd(e){let t=to(e)?e:eo(e),s;try{s=await pt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Xr(i,"utf-8"),ts({content:n,skillPath:we(t)==="SKILL.md"?we(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=mt(t,"SKILL.md");try{n=await Xr(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await fd(t)}catch{r=void 0}return ts({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function pv(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function mv(e){let t=e.split(`
|
|
210
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(`
|
|
211
|
-
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let f=
|
|
212
|
-
`),changed:a}}function
|
|
212
|
+
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let f=ld.indexOf(c);return f===-1?ld.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 hv(e,t={}){let s=[],i=[],n=e.replace(/\r\n/g,`
|
|
213
214
|
`);n!==e&&s.push({id:"normalise-line-endings",description:"Convert CRLF line endings to LF."});let r=n.split(`
|
|
214
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(`
|
|
215
|
-
`);let{rawFrontmatter:a,body:l}=
|
|
216
|
+
`);let{rawFrontmatter:a,body:l}=pd(n),c=te(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=Qr(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=Qr(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=pv(md(l));f=Qr(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=mv(f);m.changed&&(s.push({id:"reorder-frontmatter",description:"Reorder frontmatter fields to canonical order."}),f=m.newFrontmatter);let y=l.replace(/^\n+/,""),h=`---
|
|
216
217
|
${f.replace(/^\n+|\n+$/g,"")}
|
|
217
218
|
---
|
|
218
219
|
|
|
219
220
|
${y}`;return h.endsWith(`
|
|
220
221
|
`)||(h+=`
|
|
221
222
|
`),e.replace(/\r\n/g,`
|
|
222
|
-
`),{newContent:h,applied:s,skipped:i}}function
|
|
223
|
+
`),{newContent:h,applied:s,skipped:i}}function Qr(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(`
|
|
223
224
|
`)?"":`
|
|
224
225
|
`;return`${e}${r}${t}: ${n}
|
|
225
|
-
`}function
|
|
226
|
+
`}function gv(e,t,s="SKILL.md"){if(e===t)return"";let i=e.split(`
|
|
226
227
|
`),n=t.split(`
|
|
227
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(`
|
|
228
|
-
`)}async function
|
|
229
|
-
`)}function
|
|
229
|
+
`)}async function gd(e,t){let s=to(e)?e:eo(e),i,n=await pt(s).catch(()=>null);if(!n)throw new Error(`Skill path does not exist: ${s}`);if(n.isFile())i=s;else if(n.isDirectory())i=mt(s,"SKILL.md");else throw new Error(`Skill path is not a directory or file: ${s}`);let r;try{r=await Xr(i,"utf-8")}catch{throw new Error(`SKILL.md not found at ${i}.`)}let o=hv(r,{gitAuthor:t.gitAuthor}),a=gv(r,o.newContent),l=null;return!t.dryRun&&o.newContent!==r&&(l=`${i}.bak`,await Xw(i,l),await Qw(i,o.newContent,"utf-8")),{report:ts({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 yd(){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 yv(e,t,s=20){let i=Math.round(e/t*s);return"\u2588".repeat(i)+"\u2591".repeat(Math.max(0,s-i))}function Ei(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} ${yv(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=bv(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 bv(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 bd(e){return JSON.stringify(e,null,2)}function wd(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(`
|
|
230
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(`
|
|
231
|
-
`)}async function
|
|
232
|
-
`)}function
|
|
232
|
+
`)}async function wv(e){let t;try{t=await fd(e)}catch{return[]}let s=[];for(let i of t){if(i.startsWith(".")||i==="node_modules"||i==="dist"||i==="build")continue;let n=mt(e,i),r;try{r=await pt(n)}catch{continue}if(!r.isDirectory())continue;let o=mt(n,"SKILL.md");try{(await pt(o)).isFile()&&s.push(n)}catch{}}return s.sort((i,n)=>we(i).localeCompare(we(n))),s}async function ud(e){let t=mt(e,"SKILL.md");try{if((await pt(t)).isFile())return{kind:"single",skillDirs:[e]}}catch{}let s=await wv(e);return s.length>0?{kind:"collection",skillDirs:s}:{kind:"none",skillDirs:[]}}function io(e){return e?!!(e.startsWith("github:")||/^https?:\/\/github\.com\//i.test(e)):!1}function dd(e){return{skillPath:e,skillMdPath:mt(e,"SKILL.md"),label:we(e)}}async function vd(e,t={}){if(!e)throw new Error("resolveEvalInput: input must be a non-empty string");if(io(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 ud(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(dd),isCollection:o.kind==="collection",cleanup:r.cleanup,provenance:{input:e,remote:!0,sourceRef:r.sourceRef,commitSha:r.commitSha,tempPath:r.rootDir}}}let s=to(e)?e:eo(e),i;try{i=await pt(s)}catch{throw new Error(`Skill path does not exist: ${s}`)}if(i.isFile())return{targets:[{skillPath:we(s)==="SKILL.md"?we(s):s,skillMdPath:s,label:we(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 ud(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(dd),isCollection:n.kind==="collection",cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}}}function kd(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 Sd(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 $d(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 xd(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?Ci(t.report,null):null}))}}function Ci(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 vv=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function kv(e){if(typeof e!="string")return null;let t=vv.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 Sv(e,t){let s=kv(e);if(!s)throw new Error(`invalid semver: ${t} "${e}"`);return s}var no=new Map;function ro(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("register: provider.id is required");if(Sv(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=no.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),no.set(e.id,t)}function Ai(){let e=[];for(let t of no.values())for(let s of t)e.push(s);return e}import{stat as $v}from"fs/promises";var Ed="quality",Cd="1.0.0",Ad=1;function xv(e){return e.topSuggestions.map(t=>({severity:"info",message:t}))}function Ev(e){return e.categories.map(t=>({id:t.id,name:t.name,score:t.score,max:t.max}))}var Pd={id:Ed,version:Cd,schemaVersion:Ad,description:"Static linter for SKILL.md structure, description, and safety.",async applicable(e){try{return(await $v(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 hd(e.skillPath);return{providerId:Ed,providerVersion:Cd,schemaVersion:Ad,score:s.overallScore,passed:s.grade!=="F",categories:Ev(s),findings:xv(s),raw:s,startedAt:"",durationMs:0}}};var Od=uo(Or(),1);import{readFile as Cv,stat as Av}from"fs/promises";import{basename as Pv}from"path";var Nd="skill-best-practice",Id="1.1.0",Rd=1,Nv=new Set(["name","description","license","allowed-tools","metadata","compatibility","effort"]),Ld=new Set(["low","medium","high","xhigh","max"]),oo=250,Iv=/^\d+\.\d+\.\d+$/;function Rv(e){if(!e.startsWith("---"))return null;let t=e.split(`
|
|
233
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(`
|
|
234
|
-
`)}function
|
|
235
|
-
`)&&!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<=
|
|
236
|
-
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function
|
|
237
|
-
---`,3);return s===-1?"":t.slice(s+4)}async function
|
|
238
|
-
`,"utf-8"),I(`ingester: wrote index to ${c}`),{success:!0,repoIndex:a}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await
|
|
235
|
+
`)}function Pi(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 Ni(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 Lv(e){let t=await Cv(e.skillMdPath,"utf-8"),s=[],i=Rv(t);if(i===null){W(s,"missing-frontmatter","Frontmatter exists",!1,"error","SKILL.md must start with a YAML frontmatter block.");let E=Ni(e,s,null);return{score:0,passed:!1,findings:s.map(Pi),raw:E}}W(s,"frontmatter-present","Frontmatter exists",!0,"error","SKILL.md contains a YAML frontmatter block.");let n;try{n=(0,Od.parse)(i)}catch(E){W(s,"invalid-yaml","Frontmatter parses as YAML",!1,"error",`Invalid YAML in frontmatter: ${E?.message??String(E)}`);let x=Ni(e,s,null);return{score:0,passed:!1,findings:s.map(Pi),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=Ni(e,s,null);return{score:0,passed:!1,findings:s.map(Pi),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=>!Nv.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<=oo;W(s,"description-runtime-budget","Description fits the runtime context budget",x,"warning",x?`Description is ${f.length} chars (target \u2264 ${oo}).`:`Description is ${f.length} chars; target \u2264 ${oo}. 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"&&Ld.has(d.trim()),"error",d===void 0||typeof d=="string"&&Ld.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=Iv.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=Pv(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=Ni(e,s,r),v=S.checkCount===0?100:Math.round(S.passedChecks/S.checkCount*100),C=s.filter(E=>!E.passed).map(Pi);return{score:v,passed:C.every(E=>E.severity!=="error"),findings:C,raw:S}}var Td={id:Nd,version:Id,schemaVersion:Rd,description:"Deterministic SKILL.md best-practice validation (rules aligned with the skill-creator standard, v1.7.1).",async applicable(e){try{return(await Av(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 Lv(e);return{providerId:Nd,providerVersion:Id,schemaVersion:Rd,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 Md(){ro(Pd),ro(Td)}var Dd=!1;function Ii(){Dd||(Md(),Dd=!0)}function Ri(){return Ii(),Ai()}function Fd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function _d(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 Li(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: ${Fd(p)}`;return _d(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 _d(r,i,f,Fd(c),"provider-threw")}finally{a&&clearTimeout(a)}}function Ov(e){return e>=90?"A":e>=80?"B":e>=65?"C":e>=50?"D":"F"}function jd(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 qd(e,t){return{providerId:e.providerId,providerVersion:e.providerVersion,schemaVersion:e.schemaVersion,passed:e.passed,overallScore:e.score,grade:Ov(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 ss(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 Z={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 Ye(){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 Bd(e){return{timestamp:new Date().toISOString(),asm_version:jo,duration_ms:Math.round(performance.now()-e)}}function Q(e,t,s){let i={version:1,command:e,status:"ok",data:t,meta:Bd(s)},n=process.stdout.isTTY?2:0;return JSON.stringify(i,null,n)}function ee(e,t,s,i,n){let r={version:1,command:e,status:"error",error:{code:t,message:s,...n!==void 0?{details:n}:{}},meta:Bd(i)},o=process.stdout.isTTY?2:0;return JSON.stringify(r,null,o)}import{writeFile as Dv,mkdir as Fv,unlink as _v,readFile as jv,readdir as qv}from"fs/promises";import{join as is}from"path";function ao(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 Ud(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=ao(o[0].relPath);for(let f=1;f<o.length;f++){let d=ao(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:ao(f.relPath).root})),reason:l.priority===4?"first occurrence (no priority match)":`${l.root} priority`})}return{kept:s,decisions:i}}var Tv=[{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 Vd(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"),Mv(t).trim().length<20&&s.push("SKILL.md body too short (less than 20 chars of instructions)");for(let{label:n,pattern:r}of Tv)r.test(t)&&s.push(`malicious pattern detected: ${n}`);return{verified:s.length===0,reasons:s}}function Mv(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 Bv(){let e=yt();return await Fv(e,{recursive:!0}),e}async function Kd(e){await De();let t;try{t=Te(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."};I(`ingester: cloning ${t.owner}/${t.repo}`);let s=null;try{s=await Fe(t),I(`ingester: discovering skills in ${s}`);let i=await hs(s);I(`ingester: found ${i.length} skills`);let{kept:n,decisions:r}=Ud(i);for(let f of r){let d=f.dropped.map(p=>p.relPath).join(", ");I(`ingester: dedupe "${f.name}": kept ${f.kept.relPath} (${f.reason}); dropped ${d}`)}r.length>0&&I(`ingester: deduped ${i.length} -> ${n.length} skills (${r.length} name collision${r.length===1?"":"s"})`);let o=[];for(let f of n){let d=is(s,f.relPath,"SKILL.md"),p="";try{p=await jv(d,"utf-8")}catch{I(`ingester: could not read SKILL.md at ${d}`)}let m=Vd(f,p);m.verified||I(`ingester: ${f.name} not verified: ${m.reasons.join(", ")}`);let y=typeof f.tokenCount=="number"?f.tokenCount:p?os(p):void 0,h,g;if(p){let b;try{b=await qv(is(s,f.relPath))}catch{b=void 0}try{let w=ts({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){I(`ingester: eval failed for ${f.name}: ${w}`)}try{let w={skillPath:is(s,f.relPath),skillMdPath:d},S=(await Promise.all(ss(Ri()).map(async v=>(await v.applicable(w,{})).ok?Li(v,w):null))).filter(v=>v!==null).map(v=>qd(v,f.version||void 0));S.length>0&&(g=Object.fromEntries(S.filter(v=>v.providerId).map(v=>[v.providerId,v])))}catch(w){I(`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:`github:${t.owner}/${t.repo}${t.ref?`#${t.ref}`:""}${f.relPath?`:${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=gi([...await Nu(s,a),...Ur(a)]);let l=await Bv(),c=is(l,`${t.owner}_${t.repo}.json`);return await Dv(c,JSON.stringify(a,null,2)+`
|
|
239
|
+
`,"utf-8"),I(`ingester: wrote index to ${c}`),{success:!0,repoIndex:a}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await ae(s)}}async function Jd(){return(await ut()).map(t=>({owner:t.owner,repo:t.repo,skillCount:t.skillCount,updatedAt:t.updatedAt})).sort((t,s)=>s.skillCount-t.skillCount)}async function Hd(e,t){let s=yt(),i=is(s,`${e}_${t}.json`);try{return await _v(i),!0}catch{return!1}}import{join as lo,resolve as Wd}from"path";function Jv(e){switch(e){case"dangerous":return 3;case"warning":return 2;case"caution":return 1;default:return 0}}function co(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+Jv(s.verdict),0)}}function Hv(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 Wv(){console.log(`${u.blueBold("agent-skill-manager")} (${u.bold("asm")}) ${Bi}
|
|
239
240
|
|
|
240
241
|
Interactive TUI and CLI for managing installed skills for AI coding agents.
|
|
241
242
|
|
|
@@ -248,6 +249,8 @@ ${u.bold("Commands:")}
|
|
|
248
249
|
search <query> Search skills by name/description/tool
|
|
249
250
|
inspect <skill-name> Show detailed info for a skill
|
|
250
251
|
uninstall <skill-name> Remove a skill (with confirmation)
|
|
252
|
+
disable <target> Disable skill(s) without uninstalling
|
|
253
|
+
enable <target> Re-enable disabled skill(s)
|
|
251
254
|
install <source> Install a skill from GitHub or local path
|
|
252
255
|
audit Detect duplicate skills across tools
|
|
253
256
|
audit security <name> Run security audit on a skill (or GitHub source)
|
|
@@ -280,11 +283,11 @@ ${u.bold("Global Options:")}
|
|
|
280
283
|
--sort <field> Sort by: name, version, or location (default: name)
|
|
281
284
|
--flat Show one row per tool instance (list, search)
|
|
282
285
|
-y, --yes Skip confirmation prompts
|
|
283
|
-
-V, --verbose Show debug output`)}function
|
|
286
|
+
-V, --verbose Show debug output`)}function Gv(){console.log(`${u.bold("Usage:")} asm list [options]
|
|
284
287
|
|
|
285
288
|
List all discovered skills. By default, skills installed across multiple
|
|
286
289
|
tools are grouped into a single row with tool badges. When more than
|
|
287
|
-
${
|
|
290
|
+
${_i} skills are present, a compact summary is
|
|
288
291
|
automatically prepended above the table.
|
|
289
292
|
|
|
290
293
|
${u.bold("Options:")}
|
|
@@ -314,7 +317,7 @@ ${u.bold("Examples:")}
|
|
|
314
317
|
asm list -s project ${u.dim("Only project-scoped skills")}
|
|
315
318
|
asm list --sort version ${u.dim("Sort by version")}
|
|
316
319
|
asm list --json ${u.dim("Output as JSON")}
|
|
317
|
-
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
320
|
+
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function Yv(){console.log(`${u.bold("Usage:")} asm search <query> [options]
|
|
318
321
|
|
|
319
322
|
Search both installed skills and the skill index. Results show installation
|
|
320
323
|
status and include copy-paste install commands for available skills.
|
|
@@ -337,7 +340,7 @@ ${u.bold("Examples:")}
|
|
|
337
340
|
asm search "test" --installed ${u.dim("Search installed skills only")}
|
|
338
341
|
asm search "test" --available ${u.dim("Search available skills only")}
|
|
339
342
|
asm search openspec --json ${u.dim("Output matches as JSON")}
|
|
340
|
-
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
343
|
+
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function zv(){console.log(`${u.bold("Usage:")} asm inspect <skill-name> [options]
|
|
341
344
|
|
|
342
345
|
Show detailed information for a skill. The <skill-name> is the directory name.
|
|
343
346
|
Shows version, description, file count, and all provider installations.
|
|
@@ -351,7 +354,7 @@ ${u.bold("Options:")}
|
|
|
351
354
|
${u.bold("Examples:")}
|
|
352
355
|
asm inspect code-review ${u.dim("Show details for code-review")}
|
|
353
356
|
asm inspect code-review --json ${u.dim("Output as JSON")}
|
|
354
|
-
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function
|
|
357
|
+
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function Qv(){console.log(`${u.bold("Usage:")} asm uninstall <skill-name> [options]
|
|
355
358
|
|
|
356
359
|
Remove a skill and its associated rule files. Shows a removal plan
|
|
357
360
|
before proceeding and asks for confirmation.
|
|
@@ -367,7 +370,7 @@ ${u.bold("Examples:")}
|
|
|
367
370
|
asm uninstall code-review ${u.dim("Remove with confirmation")}
|
|
368
371
|
asm uninstall code-review -y ${u.dim("Remove without confirmation")}
|
|
369
372
|
asm uninstall code-review -s project ${u.dim("Remove project copy only")}
|
|
370
|
-
asm uninstall code-review -p claude ${u.dim("Remove from Claude only")}`)}function
|
|
373
|
+
asm uninstall code-review -p claude ${u.dim("Remove from Claude only")}`)}function Xv(){console.log(`${u.bold("Usage:")} asm audit [subcommand] [options]
|
|
371
374
|
|
|
372
375
|
Detect duplicate skills or run security audits on installed/remote skills.
|
|
373
376
|
|
|
@@ -393,7 +396,7 @@ ${u.bold("Examples:")}
|
|
|
393
396
|
asm audit security code-review --json ${u.dim("Output audit as JSON")}
|
|
394
397
|
asm audit security code-review --machine ${u.dim("Machine-readable v1 envelope output")}
|
|
395
398
|
asm audit security https://github.com/user/skills/tree/main/skills/agent-config
|
|
396
|
-
${u.dim("Audit a skill from a subfolder URL")}`)}function
|
|
399
|
+
${u.dim("Audit a skill from a subfolder URL")}`)}function Zv(){console.log(`${u.bold("Usage:")} asm publish [path] [options]
|
|
397
400
|
|
|
398
401
|
Validate a skill, run a security audit, generate a registry manifest,
|
|
399
402
|
and open a PR against the asm-registry.
|
|
@@ -416,7 +419,7 @@ ${u.bold("Examples:")}
|
|
|
416
419
|
asm publish --dry-run ${u.dim("Preview manifest without side effects")}
|
|
417
420
|
asm publish --force ${u.dim("Override warning-level security findings")}
|
|
418
421
|
asm publish --json ${u.dim("Output as JSON")}
|
|
419
|
-
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
422
|
+
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function ek(){console.log(`${u.bold("Usage:")} asm outdated [options]
|
|
420
423
|
|
|
421
424
|
Show which installed skills have newer versions available.
|
|
422
425
|
|
|
@@ -429,7 +432,7 @@ ${u.bold("Options:")}
|
|
|
429
432
|
${u.bold("Examples:")}
|
|
430
433
|
asm outdated ${u.dim("Show outdated skills")}
|
|
431
434
|
asm outdated --json ${u.dim("Output as JSON")}
|
|
432
|
-
asm outdated --machine ${u.dim("Machine-readable output")}`)}function
|
|
435
|
+
asm outdated --machine ${u.dim("Machine-readable output")}`)}function tk(){console.log(`${u.bold("Usage:")} asm update [name...] [options]
|
|
433
436
|
|
|
434
437
|
Update outdated skills to their latest version with security re-audit.
|
|
435
438
|
|
|
@@ -447,7 +450,7 @@ ${u.bold("Examples:")}
|
|
|
447
450
|
asm update ${u.dim("Update all outdated skills")}
|
|
448
451
|
asm update code-review ${u.dim("Update a specific skill")}
|
|
449
452
|
asm update --yes ${u.dim("Skip confirmation prompts")}
|
|
450
|
-
asm update --json ${u.dim("Output as JSON")}`)}function
|
|
453
|
+
asm update --json ${u.dim("Output as JSON")}`)}function sk(){console.log(`${u.bold("Usage:")} asm config <subcommand>
|
|
451
454
|
|
|
452
455
|
Manage configuration. Config is stored at ~/.config/agent-skill-manager/.
|
|
453
456
|
|
|
@@ -463,19 +466,82 @@ ${u.bold("Options:")}
|
|
|
463
466
|
${u.bold("Examples:")}
|
|
464
467
|
asm config show ${u.dim("View current config")}
|
|
465
468
|
asm config edit ${u.dim("Edit in $EDITOR")}
|
|
466
|
-
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function
|
|
467
|
-
${u.yellow(`${
|
|
468
|
-
`))}}async function
|
|
469
|
-
`)),e.flags.flat?console.log(
|
|
470
|
-
${u.bold("Proceed with removal?")} [y/N] `);let m=await
|
|
471
|
-
Done.`))}function
|
|
472
|
-
`)&&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()})}
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
469
|
+
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function Yd(e){for(let t of e)t.warnings=await Xc(t)}async function ik(e){if(e.flags.help){Gv();return}let t=performance.now(),s=await B(),i=await X(s,e.flags.scope),n=await cs(),r=new Set(i.map(l=>`${l.dirName}||${l.provider}||${l.scope}`)),o=await zd(s,n,e.flags.scope,e.flags.provider,r);i=[...i,...o],e.flags.provider&&e.command==="list"&&(i=i.filter(l=>l.provider===e.flags.provider)),await Yd(i);let a=Mi(i,e.flags.sort);if(e.flags.machine){let l=a.map(c=>({name:c.name,version:c.version,description:c.description,scope:c.scope,provider:c.provider,path:c.path}));console.log(Q("list",l,t));return}if(e.flags.json)console.log(Y(a));else if(e.flags.flat){let l=Fi(a),c=a.filter(f=>f.warnings&&f.warnings.length>0);c.length>0&&(l+=`
|
|
470
|
+
${u.yellow(`${c.length} skill${c.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(l)}else if(e.flags.summary)console.log(ji(a));else if(e.flags.groupBy){let{skills:l,hint:c}=as(a,e.flags.limit);console.log(Ao(l,e.flags.groupBy)),c&&console.log(c)}else if(e.flags.compact){let{skills:l,hint:c}=as(a,e.flags.limit);console.log(Co(l)),c&&console.log(c)}else{let l=[];a.length>_i&&(l.push(ji(a,{showHint:!1})),l.push(""));let{skills:c,hint:f}=as(a,e.flags.limit);l.push(Po(c)),f&&l.push(f),console.log(l.join(`
|
|
471
|
+
`))}}async function nk(e){if(e.flags.help){Yv();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;i||(e.flags.machine&&(t?.(),console.log(ee("search",Z.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 n=!e.flags.available,r=!e.flags.installed,o=[];if(n){let f=await B(),d=await X(f,e.flags.scope);e.flags.provider&&(d=d.filter(m=>m.provider===e.flags.provider));let p=bo(d,i);o=Mi(p,e.flags.sort)}let a=[];if(r&&(a=await hi(i),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(Q("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(Y([...f,...d]));return}let l=o.length>0,c=a.length>0;if(!l&&!c){console.error(`No skills matching "${i}".`),console.error(u.dim("Try ingesting more repos with: asm index ingest <repo>"));return}if(l&&(console.error(u.bold(`Installed skills matching "${i}":
|
|
472
|
+
`)),e.flags.flat?console.log(Fi(o)):console.log(No(o,i))),c){l&&console.error("");let f=Io(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})),i);console.error(f)}}async function rk(e){if(e.flags.help){zv();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 B(),n=(await X(s,e.flags.scope)).filter(r=>r.dirName===t);n.length===0&&($(`Skill "${t}" not found.`),console.error(u.dim(`Try ${u.bold("asm list")} to see all skills or ${u.bold(`asm search "${t}"`)} to search.`)),process.exit(1)),await Yd(n),e.flags.json?console.log(Y(n.length===1?n[0]:n)):console.log(await Ro(n))}async function ok(e){if(e.flags.help){Qv();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 B(),i=await X(s,e.flags.scope),n={};e.flags.provider&&(n.providerFilter=e.flags.provider),e.flags.scope&&e.flags.scope!=="both"&&(n.scopeFilter=e.flags.scope);let r=vo(t,i,s,n),o=await So(r);o.length===0&&($(`Skill "${t}" not found or nothing to remove.`),process.exit(1));let a=i.filter(m=>m.dirName===t),l=n.providerFilter,c=null;l&&(c=ko(r,a,l)),console.error(u.bold("Removal plan:")),console.error(` ${u.dim("Scope:")} ${n.scopeFilter||"both"}`),l&&(console.error(` ${u.dim("Tool:")} ${l}`),c?.needed&&console.error(` ${u.yellow("\u26A0 Real folder relocation:")} ${c.fromPath} \u2192 ${c.toPath} (${c.toProvider})`)),console.error("");for(let m of o)console.error(` ${u.red("\u2022")} ${Eo(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(`
|
|
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 Di(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=>Wd(m.path))),p=a.filter(m=>!d.has(Wd(m.originalPath)));try{l&&p.length>0?c?.needed&&!c.repointOnly&&await To(t,c.toProvider):await Oo(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 ak(){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.")}
|
|
485
|
+
|
|
486
|
+
${u.bold("Targets:")}
|
|
487
|
+
<name> Exact skill name or directory name
|
|
488
|
+
'<glob>*' Glob match (${u.dim("* matches any characters")})
|
|
489
|
+
<prefix>: | <prefix>- Prefix match (e.g. ${u.dim("openspec:")}, ${u.dim("asc-")})
|
|
490
|
+
|
|
491
|
+
${u.bold("Options:")}
|
|
492
|
+
--all, -a Disable every matching skill
|
|
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
|
|
500
|
+
|
|
501
|
+
${u.bold("Examples:")}
|
|
502
|
+
asm disable code-review ${u.dim("# one skill")}
|
|
503
|
+
asm disable 'workflow*' ${u.dim("# glob")}
|
|
504
|
+
asm disable '*-review' ${u.dim("# glob suffix")}
|
|
505
|
+
asm disable openspec: ${u.dim("# prefix (colon)")}
|
|
506
|
+
asm disable asc- ${u.dim("# prefix (hyphen)")}
|
|
507
|
+
asm disable --all ${u.dim("# everything")}
|
|
508
|
+
asm disable code-review --tool claude --scope local`)}function lk(){console.log(`${u.bold("Usage:")} asm enable <target> [options]
|
|
509
|
+
asm enable --all [options]
|
|
510
|
+
|
|
511
|
+
Re-enable skills previously disabled with ${u.bold("asm disable")}. Enabling renames
|
|
512
|
+
${u.dim("SKILL.md.disabled")} back to ${u.dim("SKILL.md")} so asm and your agent see it again.
|
|
513
|
+
|
|
514
|
+
${u.dim("Note: a skill shared across tools via symlinks re-enables for every tool")}
|
|
515
|
+
${u.dim("at once (one shared SKILL.md); asm warns and clears state for all siblings.")}
|
|
516
|
+
|
|
517
|
+
${u.bold("Targets:")}
|
|
518
|
+
<name> Exact skill name or directory name
|
|
519
|
+
'<glob>*' Glob match (${u.dim("* matches any characters")})
|
|
520
|
+
<prefix>: | <prefix>- Prefix match (e.g. ${u.dim("openspec:")}, ${u.dim("asc-")})
|
|
521
|
+
|
|
522
|
+
${u.bold("Options:")}
|
|
523
|
+
--all, -a Enable every matching disabled skill
|
|
524
|
+
-p, --tool <name> Limit to one tool/provider (e.g. claude, codex)
|
|
525
|
+
-s, --scope <s> Filter: global, local, project, or both (default: both)
|
|
526
|
+
-y, --yes Skip confirmation prompt
|
|
527
|
+
--json Output result as JSON
|
|
528
|
+
--machine Tab-separated output
|
|
529
|
+
--no-color Disable ANSI colors
|
|
530
|
+
-V, --verbose Show debug output
|
|
531
|
+
|
|
532
|
+
${u.bold("Examples:")}
|
|
533
|
+
asm enable code-review
|
|
534
|
+
asm enable '*-review'
|
|
535
|
+
asm enable openspec:
|
|
536
|
+
asm enable --all`)}async function zd(e,t,s,i,n){let r=new Map(e.providers.map(a=>[a.name,a])),o=[];for(let[a,l]of Object.entries(t.disabled))for(let[c,f]of Object.entries(l)){if(i&&c!==i)continue;let d=r.get(c);if(d)for(let p of["global","project"]){if(!f[p]||s==="global"&&p!=="global"||s==="project"&&p!=="project"||n?.has(`${a}||${c}||${p}`))continue;let m=p==="global"?d.global:d.project;if(!m)continue;let y=oe(m),h=lo(y,a),g=us(h);if(!Kv(g))continue;let b={};try{b=te(await Uv(g,"utf-8"))}catch{}let w=h;try{w=await Vv(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:[],dirName:a,path:h,originalPath:h,location:`${p}-${c}`,scope:p,provider:c,providerLabel:d.label,isSymlink:!1,symlinkTarget:null,realPath:w,disabled:!0})}}return o}function Qd(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(" "))}function Xd(e,t){let s=new Map;for(let n of t){let r=s.get(n.realPath)??[];r.push(n),s.set(n.realPath,r)}let i=new Map;for(let n of e)i.has(n.realPath)||i.set(n.realPath,{realPath:n.realPath,representative:n,siblings:s.get(n.realPath)??[n]});return[...i.values()]}async function ck(e){if(e.flags.help){ak();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 B(),i=e.flags.provider,n=(await X(s,e.flags.scope)).filter(d=>d.provider!=="plugin"&&d.provider!=="codex-plugin"),r=i?n.filter(d=>d.provider===i):n,o=e.flags.all?r:Vi(r,t);if(o.length===0){let d=t?` for '${t}'`:"";console.log(u.dim(`No matching active skills${d}.`));return}let a=Xd(o,n),l=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(u.bold(`Will disable ${d} skill instance(s):`));for(let p of a){for(let m of p.siblings){let y=l.has(`${m.realPath}||${m.provider}||${m.scope}`)?"":u.yellow(" (shared via symlink)");console.log(` ${u.dim("\u2022")} ${m.name} (${m.provider}, ${m.scope})${y}`)}p.siblings.length>1&&console.log(u.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(`
|
|
537
|
+
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let c=await cs(),f=[];try{for(let d of a){await Go(d.representative.path);for(let p of d.siblings)Ko(c,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(`${u.green("\u2713")} disabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await Ui(c)}Qd(e,f)}async function uk(e){if(e.flags.help){lk();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 B(),i=e.flags.provider,n=await cs(),r=await zd(s,n,e.flags.scope),o=i?r.filter(d=>d.provider===i):r,a=e.flags.all?o:Vi(o,t);if(a.length===0){let d=t?` for '${t}'`:"";console.log(u.dim(`No matching disabled skills${d}.`));return}let l=Xd(a,r),c=new Set(a.map(d=>`${d.realPath}||${d.provider}||${d.scope}`));if(!e.flags.json&&!e.flags.machine){let d=l.reduce((p,m)=>p+m.siblings.length,0);console.log(u.bold(`Will enable ${d} skill instance(s):`));for(let p of l){for(let m of p.siblings){let y=c.has(`${m.realPath}||${m.provider}||${m.scope}`)?"":u.yellow(" (shared via symlink)");console.log(` ${u.dim("\u2022")} ${m.name} (${m.provider}, ${m.scope})${y}`)}p.siblings.length>1&&console.log(u.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(`
|
|
538
|
+
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let f=[];try{for(let d of l){await Yo(d.representative.path);for(let p of d.siblings)Jo(n,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(`${u.green("\u2713")} enabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await Ui(n)}Qd(e,f)}async function dk(e){if(e.flags.help){Xv();return}let t=performance.now(),s=e.subcommand??"duplicates";if(s==="security"){await fk(e,t);return}s!=="duplicates"&&($(`Unknown audit subcommand: "${s}". Use: duplicates, security`),process.exit(2));let i=await B(),n=await X(i,"both"),r=qi(n);if(e.flags.machine){let o={duplicate_groups:r.duplicateGroups.map(a=>({name:a.key,count:a.instances.length,instances:a.instances.map(l=>({path:l.path,scope:l.scope,provider:l.provider}))})),total_duplicates:r.duplicateGroups.length};console.log(Q("audit duplicates",o,t));return}if(e.flags.json){console.log(_o(r));return}if(console.log(Fo(r)),e.flags.yes&&r.duplicateGroups.length>0){console.error(u.bold(`
|
|
539
|
+
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a=Do(o.instances),l=a[0].path;for(let c=1;c<a.length;c++){let f=a[c],d=wo(f,i),p=await Di(d,l);for(let m of p)console.error(m)}}console.error(u.green(`
|
|
540
|
+
Done.`))}}async function fk(e,t){let s=e.positional[0];e.flags.all?await pk(e,t):s?s.startsWith("github:")||s.startsWith("https://github.com/")?await mk(e,s,t):await hk(e,s,t):(e.flags.machine&&(console.log(ee("audit security",Z.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.
|
|
541
|
+
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function pk(e,t){let s=await B(),i=await X(s,e.flags.scope);if(i.length===0){e.flags.machine?console.log(Q("audit security",[],t)):e.flags.json?console.log("[]"):console.log("No skills found to audit.");return}let n=new Set,r=i.filter(a=>n.has(a.realPath)?!1:(n.add(a.realPath),!0));console.error(`Auditing ${r.length} skill${r.length>1?"s":""}...
|
|
542
|
+
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await Re(a.realPath,a.name);o.push(l)}if(e.flags.machine)console.log(Q("audit security",co(o),t));else if(e.flags.json)console.log(JSON.stringify(o,null,2));else{for(let l of o)console.log(wi(l));let a={safe:0,caution:0,warning:0,dangerous:0};for(let l of o)a[l.verdict]++;console.log(u.bold(`
|
|
543
|
+
Summary:`)),a.dangerous>0&&console.log(` ${u.red(`${a.dangerous} dangerous`)}`),a.warning>0&&console.log(` ${u.yellow(`${a.warning} warning`)}`),a.caution>0&&console.log(` ${a.caution} caution`),a.safe>0&&console.log(` ${u.green(`${a.safe} safe`)}`),console.log("")}}async function mk(e,t,s){let i=null;try{let n=Te(t);if(n.isLocal)throw new Error("Local paths are not supported for remote security audits. Use: asm audit security <installed-skill-name>");await De(),n=await ms(n),console.error(`Cloning ${t} for audit...`),i=await Fe(n,e.flags.transport);let{join:r}=await import("path"),o=n.subpath?r(i,n.subpath):i,{name:a}=await _e(o),l=await Re(o,a,n.owner,n.repo);e.flags.machine?console.log(Q("audit security",co([l]),s)):e.flags.json?console.log(Jr(l)):console.log(wi(l))}catch(n){e.flags.machine&&(console.log(ee("audit security",Z.AUDIT_FAILED,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}finally{i&&await ae(i)}}async function hk(e,t,s){let i=await B(),r=(await X(i,e.flags.scope)).filter(l=>l.dirName===t);r.length===0&&(e.flags.machine&&(console.log(ee("audit security",Z.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=r[0];console.error(`Auditing installed skill: ${u.bold(o.name)}...
|
|
544
|
+
`);let a=await Re(o.realPath,o.name);e.flags.machine?console.log(Q("audit security",co([a]),s)):e.flags.json?console.log(Jr(a)):console.log(wi(a))}async function gk(e){if(e.flags.help){sk();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 B();console.log(Y(s));break}case"path":{console.log(gt());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(`${u.bold("Reset config to defaults?")} [y/N] `);let i=await G();i.toLowerCase()!=="y"&&i.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let s=po();await go(s),console.error(u.green("Config reset to defaults."));break}case"edit":{let s=process.env.VISUAL||process.env.EDITOR||"vi",[i,n]=qo(s),r=gt();await B();let{spawn:o}=await import("child_process");await new Promise((a,l)=>{let c=o(i,[...n,r],{stdio:"inherit"});c.on("close",()=>a()),c.on("error",l)});break}default:$(`Unknown config subcommand: "${t}". Use: show, path, reset, or edit.`),process.exit(2)}}function yk(){console.log(`${u.bold("Usage:")} asm install <source> [options]
|
|
479
545
|
|
|
480
546
|
Install a skill from a GitHub repository, the curated registry, or a local path.
|
|
481
547
|
|
|
@@ -547,27 +613,27 @@ ${u.bold("Subfolder URL:")}
|
|
|
547
613
|
${u.bold("Vercel skills CLI:")}
|
|
548
614
|
asm install github:user/skills --method vercel --skill my-skill
|
|
549
615
|
asm install https://github.com/user/skills -m vercel --skill my-skill -y
|
|
550
|
-
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function
|
|
551
|
-
${u.bold("Install preview:")}`),console.info(` ${u.bold("Name:")} ${o.name}`),console.info(` ${u.bold("Version:")} ${o.version}`),o.description&&console.info(` ${u.bold("Description:")} ${u.dim(o.description)}`),o.effort&&console.info(` ${u.bold("Effort:")} ${
|
|
616
|
+
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function bk(e,t,s,i,n,r,o,a,l="global"){let c=await _e(i),f=await ia(i),d=i===s?null:i.split(/[/\\]/).pop(),p=n||d||t.repo,m=Me(p),y=a.find(C=>C.name.toLowerCase()===c.name.toLowerCase()&&C.provider===o.name),h,g=!!y;y?y.version===c.version?h=e.flags.force?"REINSTALL":`UPDATE: ${y.version} (same version)`:h=`UPDATE: ${y.version} \u2192 ${c.version}`:h="NEW";let b=Qi(t,s,i,m,o,e.flags.force||g,l),w=f.some(C=>["Shell commands","Code execution","Credentials"].includes(C.category)),k=f.some(C=>["External URLs"].includes(C.category)),S=w?"high":k?"medium":"safe",v=w?u.red("[!] High Risk"):k?u.yellow("[~] Medium Risk"):u.green("[ok] Safe");return{metadata:c,skillName:m,warnings:f,installStatus:h,riskLevel:S,riskLabel:v,plan:b}}function wk(e,t,s,i,n,r){let{metadata:o,warnings:a,installStatus:l,riskLabel:c,plan:f}=e;if(n&&r){let d=u.dim(`[${r.index}/${r.total}]`),p=l==="NEW"?u.green(`[${l}]`):u.yellow(`[${l}]`);console.info(`${d} ${u.bold(o.name)} v${o.version} ${p} ${c}`)}else{let d=l==="NEW"?u.green(`[${l}]`):u.yellow(`[${l}]`);if(console.info(` ${u.bold(o.name)} v${o.version} ${d}`),console.info(`
|
|
617
|
+
${u.bold("Install preview:")}`),console.info(` ${u.bold("Name:")} ${o.name}`),console.info(` ${u.bold("Version:")} ${o.version}`),o.description&&console.info(` ${u.bold("Description:")} ${u.dim(o.description)}`),o.effort&&console.info(` ${u.bold("Effort:")} ${$o(o.effort)}`),console.info(` ${u.bold("Source:")} ${t}`),i?(console.info(` ${u.bold("Tool:")} All (${i.map(p=>p.label).join(", ")})`),console.info(` ${u.bold("Primary:")} ${s.label} (${s.name})`),console.info(` ${u.bold("Symlinks:")} ${i.filter(p=>p.name!==s.name).map(p=>p.label).join(", ")}`)):console.info(` ${u.bold("Tool:")} ${s.label} (${s.name})`),console.info(` ${u.bold("Scope:")} ${f.scope==="project"?"Project":"Global"}`),console.info(` ${u.bold("Target:")} ${f.targetDir}`),console.info(` ${u.bold("Status:")} ${d}`),console.info(` ${u.bold("Risk:")} ${c}`),a.length>0){console.info(`
|
|
552
618
|
${u.bold("Security warnings:")}`);let p=new Map;for(let m of a){let y=p.get(m.category)||[];y.push(m),p.set(m.category,y)}for(let[m,y]of p){let g=["Shell commands","Code execution","Credentials"].includes(m)?u.red(`[${m}]`):u.yellow(`[${m}]`);console.info(`
|
|
553
|
-
${g} ${u.dim(`(${y.length} match${y.length>1?"es":""})`)}`);for(let b of y.slice(0,5))console.info(` ${u.dim(`${b.file}:${b.line}`)} -- ${b.match}`);y.length>5&&console.info(u.dim(` ... and ${y.length-5} more`))}}}}async function
|
|
554
|
-
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(f)}`),c=()=>{n?
|
|
555
|
-
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:
|
|
556
|
-
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let L=N.slice(0,5);for(let
|
|
557
|
-
Select a skill [1-${L.length}]: `;process.stderr.write(
|
|
558
|
-
Did you mean: ${
|
|
559
|
-
`);for(let
|
|
619
|
+
${g} ${u.dim(`(${y.length} match${y.length>1?"es":""})`)}`);for(let b of y.slice(0,5))console.info(` ${u.dim(`${b.file}:${b.line}`)} -- ${b.match}`);y.length>5&&console.info(u.dim(` ... and ${y.length-5} more`))}}}}async function vk(e,t){return t?await na(e,t):await gs(e)}async function kk(e){if(e.flags.help){yk();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;i||($("Missing required argument: <source>"),console.error('Run "asm install --help" for usage.'),process.exit(2));let n=null,r="github",o=8,a=0,l=f=>(a++,`
|
|
620
|
+
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(f)}`),c=()=>{n?ae(n).finally(()=>process.exit(1)):process.exit(1)};process.on("SIGINT",c),process.on("SIGTERM",c);try{if(!zi(i)&&await ta(i)&&(i=`./${i}`),zt(i)){console.info(`
|
|
621
|
+
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:A,multipleMatches:N,suggestions:_}=await iu(i,{noCache:e.flags.noCache});if(A){r="registry";let L=A.manifest,F=L.repository.replace("https://github.com/","");i=L.skill_path?`github:${F}#${L.commit}:${L.skill_path}`:`github:${F}#${L.commit}`,console.info(` ${u.green("\u2713")} Resolved: ${u.bold(`${L.author}/${L.name}`)} @ ${L.commit.slice(0,7)}`)}else if(N.length>0){console.info(`
|
|
622
|
+
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let L=N.slice(0,5);for(let re=0;re<L.length;re++){let ce=L[re];console.info(` ${u.cyan(`${re+1}.`)} ${u.bold(`${ce.author}/${ce.name}`)} \u2014 ${ce.description}`)}process.stdin.isTTY||($(`Ambiguous skill name "${i}". Use a scoped name: asm install author/name`),process.exit(2));let F=`
|
|
623
|
+
Select a skill [1-${L.length}]: `;process.stderr.write(F);let ne=await new Promise(re=>{let ce="",ve=!1,ns=setTimeout(()=>{ve||(ve=!0,process.stdin.removeListener("data",ht),re(ce.trim()))},3e4);function ht(tf){ce=tf.toString().trim(),ve||(ve=!0,clearTimeout(ns),process.stdin.removeListener("data",ht),re(ce))}process.stdin.setEncoding("utf-8"),process.stdin.on("data",ht)}),K=parseInt(ne,10);(isNaN(K)||K<1||K>L.length)&&($("Invalid selection. Aborting."),process.exit(2));let U=L[K-1];r="registry";let ze=U.repository.replace("https://github.com/","");i=U.skill_path?`github:${ze}#${U.commit}:${U.skill_path}`:`github:${ze}#${U.commit}`,console.info(` ${u.green("\u2713")} Selected: ${u.bold(`${U.author}/${U.name}`)} @ ${U.commit.slice(0,7)}`)}else Mr(i)?($(`Skill "${i}" not found in the registry.`),_.length>0&&console.error(`
|
|
624
|
+
Did you mean: ${_.map(L=>u.cyan(L)).join(", ")}?`),process.exit(1)):(console.info(` ${u.dim("Not found in registry \u2014 trying existing sources...")}`),r="pre-indexed")}console.info(l("Parsing source"));let f=Te(i),d=!!f.isLocal;if(d){let A=f.localPath;console.info(` ${u.dim(`local: ${A}`)}`);let{stat:N}=await import("fs/promises");try{if(!(await N(A)).isDirectory())throw new Error(`Path is not a directory: ${A}`)}catch(_){throw _.code==="ENOENT"?new Error(`Path does not exist: ${A}`):_}}else await De(),f=await ms(f),console.info(` ${u.dim(i)}`);if(e.flags.method==="vercel"){console.info(l("Installing via Vercel skills CLI")),await ra();let A=aa(f),N=e.flags.path||null;console.info(` ${u.dim(`npx skills add ${A}${N?` --skill ${N}`:""}`)}`);let{stdout:_,stderr:L}=await oa(A,N);_.trim()&&console.info(` ${u.dim(_.trim())}`),L.trim()&&console.error(` ${u.dim(L.trim())}`),console.info(` ${u.green("\u2713")} Vercel skills CLI install completed`),e.flags.force=!0,console.info(` ${u.dim("Continuing with asm install to register in local inventory...")}`)}console.info(l("Selecting provider"));let p=await B(),{provider:m,allProviders:y}=await Xe(p,e.flags.provider,!!process.stdin.isTTY);console.info(l("Selecting scope"));let h;if(e.flags.scope==="global"||e.flags.scope==="project")h=e.flags.scope,console.info(` ${u.dim(`scope: ${h}`)}${h==="global"?` (${m.global})`:` (${m.project})`}`);else if(!process.stdin.isTTY||e.flags.yes)h="global",console.info(` ${u.dim("scope: global (default)")} (${m.global})`);else{let A=[{label:`Global (${m.global})`,hint:"Available in all projects",checked:!0},{label:`Project (${m.project})`,hint:"Available only in this project",checked:!1}];console.info("");let N=await Qe({items:A});if(N.length===0)throw new Error("No scope selected. Aborting.");h=N[0]===0?"global":"project",console.info(` Selected: ${u.bold(h)} ${u.dim(`(${h==="global"?m.global:m.project})`)}`)}if(d)console.info(l("Reading local source")),console.info(` ${u.dim(f.localPath)}`),n=null;else{console.info(l("Cloning repository"));let A=e.flags.transport,N=A==="ssh"?f.sshCloneUrl:A==="https"?f.cloneUrl:`${f.cloneUrl} ${u.dim("(auto)")}`;console.info(` ${N}${f.ref?` ${u.dim(`(ref: ${f.ref})`)}`:""}${f.subpath?` ${u.dim(`(path: ${f.subpath})`)}`:""}`),n=await Fe(f,A)}let g=d?f.localPath:n;console.info(l("Scanning for skills"));let{join:b}=await import("path"),w=[],k=e.flags.path||f.subpath,S=[],v=!1,C=g,E="";if(k){let A=b(g,k),N=!1;try{await _e(A),N=!0}catch{if(!e.flags.all)throw new Error(`No SKILL.md found at path "${k}" in the repository.`);let{stat:_}=await import("fs/promises");try{if(!(await _(A)).isDirectory())throw new Error(`No SKILL.md found at path "${k}" in the repository.`)}catch(L){throw L&&L.code==="ENOENT"?new Error(`No SKILL.md found at path "${k}" in the repository.`):L}v=!0,C=A,E=k}N&&(console.info(` Found skill at ${u.bold(k)}`),S=[{skillDir:A,nameOverride:e.flags.name}])}else{let A=!1;try{await _e(g),A=!0}catch{}if(A){let N=await _e(g);console.info(` Found: ${u.bold(N.name)} v${N.version}`),S=[{skillDir:g,nameOverride:e.flags.name}]}else v=!0}if(v){console.info(E?` No SKILL.md at ${u.bold(E)}. Scanning subdirectories...`:" No SKILL.md at root. Scanning subdirectories...");let A=await hs(C),N=E?A.map(F=>({...F,relPath:`${E}/${F.relPath}`})):A;if(N.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 ${u.bold(String(N.length))} skill(s):
|
|
625
|
+
`);for(let F=0;F<N.length;F++){let ne=u.cyan(` ${String(F+1).padStart(String(N.length).length)})`);console.info(`${ne} ${u.bold(N[F].name)} ${u.dim(`v${N[F].version}`)} ${u.dim(`(${N[F].relPath})`)}`),N[F].description&&console.info(` ${u.dim(N[F].description)}`)}console.info(l("Selecting skills")),a--;let _;if(e.flags.all&&(e.flags.yes||!process.stdin.isTTY))_=N.map(F=>F.relPath),console.info(` Selected all ${u.bold(String(_.length))} skills`);else if(process.stdin.isTTY)if(N.length===1)_=[N[0].relPath],console.info(` Auto-selected: ${u.bold(N[0].name)} ${u.dim(`v${N[0].version}`)}`);else{let F=N.map(K=>({label:K.name,hint:`v${K.version}${K.description?" "+K.description:""}`,checked:!!e.flags.all}));console.info("");let ne=await Qe({items:F});if(ne.length===0)throw new Error("No skills selected. Aborting.");_=ne.map(K=>N[K].relPath),console.info(` Selected ${u.bold(String(_.length))} skill(s)`)}else{$(`Repository contains ${N.length} skills. Use --path <subdir> to pick one or --all to install all.
|
|
560
626
|
Available skills:
|
|
561
|
-
${N.map(
|
|
562
|
-
`)}`),process.exit(2);return}let L=
|
|
563
|
-
`),
|
|
564
|
-
${
|
|
565
|
-
Choose one path per skill name or install with --path.`);throw
|
|
627
|
+
${N.map(F=>` --path ${F.relPath}`).join(`
|
|
628
|
+
`)}`),process.exit(2);return}let L=sa(_);if(L.length>0){let F=L.map(K=>` - ${K.name}: ${K.paths.map(U=>`"${U}"`).join(", ")}`).join(`
|
|
629
|
+
`),ne=new Error(`Duplicate skill names detected in selection:
|
|
630
|
+
${F}
|
|
631
|
+
Choose one path per skill name or install with --path.`);throw ne.duplicates=L,ne}S=_.map(F=>({skillDir:b(g,F),nameOverride:_.length===1?e.flags.name:null})),a++}console.info(l("Inspecting skills"));let x=await X(p,"both"),M=[],O=S.length>1;for(let A=0;A<S.length;A++){let{skillDir:N,nameOverride:_}=S[A],L=await bk(e,f,g,N,_,p,m,x,h);M.push(L),wk(L,i,m,y,O,O?{index:A+1,total:S.length}:void 0)}if(O){console.info(""),console.info(` ${u.bold("Install settings:")}`),console.info(` ${u.bold("Source:")} ${i}`),console.info(y?` ${u.bold("Tool:")} All (${y.map(F=>F.label).join(", ")})`:` ${u.bold("Tool:")} ${m.label} (${m.name})`),console.info(` ${u.bold("Scope:")} ${h==="project"?"Project":"Global"}`);let A=M.filter(F=>F.riskLevel==="high").length,N=M.filter(F=>F.riskLevel==="medium").length,_=M.filter(F=>F.riskLevel==="safe").length,L=[];_>0&&L.push(u.green(`${_} Safe`)),N>0&&L.push(u.yellow(`${N} Medium Risk`)),A>0&&L.push(u.red(`${A} High Risk`)),console.info(` ${u.bold("Risk:")} ${L.join(", ")}`)}if(console.info(l("Installing")),!e.flags.yes){let A=M.some(F=>F.riskLevel==="high");process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2));let N=O?`${M.length} skills`:`"${M[0].metadata.name}"`,_=A?`
|
|
566
632
|
${u.red("[!]")} ${u.bold(`Install ${N}? Some have high-risk patterns.`)} [y/N] `:`
|
|
567
|
-
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(
|
|
568
|
-
${u.yellow(`${T.length} skill(s) failed to install:`)}`);for(let
|
|
633
|
+
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(_);let L=await G();A?L.toLowerCase()!=="y"&&L.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)):(L.toLowerCase()==="n"||L.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let D=n?await Mo(n):null,T=[];for(let A=0;A<M.length;A++){let N=M[A],_=O?u.dim(`[${A+1}/${M.length}]`)+" ":" ";try{console.info(`${_}Installing ${u.bold(N.metadata.name)}...`);let L=await vk(N.plan,y);w.push(L),console.info(`${_}${u.green("\u2713")} ${N.metadata.name} installed to ${u.dim(N.plan.targetDir)}`);try{let F=d?`local:${f.localPath}`:`github:${f.owner}/${f.repo}`,ne=d?"local":r==="registry"?"registry":"github";await bt(L.name,{source:F,commitHash:D||"unknown",ref:f.ref||"main",installedAt:new Date().toISOString(),provider:N.plan.providerName,sourceType:ne,...r==="registry"?{registryName:L.name}:{}})}catch{}}catch(L){T.push({name:N.metadata.name,error:L.message}),console.error(`${_}${u.red("\u2717")} ${u.bold(N.metadata.name)} \u2014 ${u.red(L.message)}`)}}if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),T.length>0){console.error(`
|
|
634
|
+
${u.yellow(`${T.length} skill(s) failed to install:`)}`);for(let A of T)console.error(` ${u.red("\u2717")} ${A.name}: ${A.error}`)}if(e.flags.machine){t?.();let A=w.map(N=>({name:N.name,path:N.path,version:N.version,provider:N.provider,source:N.source,resolution_source:r}));console.log(Q("install",A.length===1?A[0]:A,s))}else if(e.flags.json){let A=w.map(N=>({...N,resolutionSource:r}));console.log(JSON.stringify(A.length===1?A[0]:A,null,2))}else w.length===1?console.error(u.green(`
|
|
569
635
|
Done! Installed "${w[0].name}" to ${w[0].path}`)):w.length>0&&console.error(`
|
|
570
|
-
${u.green(`Done! Installed ${w.length} skill(s) successfully.`)}`)}catch(f){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(
|
|
636
|
+
${u.green(`Done! Installed ${w.length} skill(s) successfully.`)}`)}catch(f){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(ee("install",Z.INSTALL_FAILED,f.message,s,f?.duplicates?{duplicates:f.duplicates}:void 0));else if(e.flags.json){let d={success:!1,error:f.message};f?.duplicates&&(d.duplicates=f.duplicates),console.log(JSON.stringify(d,null,2))}else $(f.message);process.exit(1)}finally{n&&await ae(n),t?.()}}function Sk(){console.log(`${u.bold("Usage:")} asm export [options]
|
|
571
637
|
|
|
572
638
|
Export skill inventory as a portable JSON manifest. Useful for backup,
|
|
573
639
|
sharing, or scripting.
|
|
@@ -580,7 +646,7 @@ ${u.bold("Options:")}
|
|
|
580
646
|
${u.bold("Examples:")}
|
|
581
647
|
asm export ${u.dim("Export all skills")}
|
|
582
648
|
asm export -s global ${u.dim("Export global skills only")}
|
|
583
|
-
asm export > skills.json ${u.dim("Save to file")}`)}async function
|
|
649
|
+
asm export > skills.json ${u.dim("Save to file")}`)}async function $k(e){if(e.flags.help){Sk();return}let t=await B(),s=await X(t,e.flags.scope),i=nu(s);console.log(JSON.stringify(i,null,2))}function xk(){console.log(`${u.bold("Usage:")} asm import <file> [options]
|
|
584
650
|
|
|
585
651
|
Import skills from a previously exported JSON manifest. Recreates skill
|
|
586
652
|
installations based on the manifest metadata.
|
|
@@ -602,9 +668,9 @@ ${u.bold("Examples:")}
|
|
|
602
668
|
asm import skills.json --force ${u.dim("Overwrite existing skills")}
|
|
603
669
|
asm import skills.json -s global ${u.dim("Import only global skills")}
|
|
604
670
|
asm export > backup.json ${u.dim("Export first, then import later")}
|
|
605
|
-
asm import backup.json ${u.dim("Restore from backup")}`)}async function
|
|
606
|
-
${u.bold("Proceed?")} [y/N] `);let l=await
|
|
607
|
-
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let l of a.results){let c=l.status==="installed"?u.green("+++"):l.status==="skipped"?u.yellow("---"):l.status==="dry-run"?u.cyan("~~~"):u.red("!!!"),f=l.reason?` ${u.dim(l.reason)}`:"",d=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${f}${d}`)}console.error(""),console.error(`${u.bold("Summary:")} ${a.total} total, ${u.green(String(a.installed))} installed, ${u.yellow(String(a.skipped))} skipped, ${u.red(String(a.failed))} failed`),a.failed>0&&(process.exitCode=1)}function
|
|
671
|
+
asm import backup.json ${u.dim("Restore from backup")}`)}async function Ek(e){if(e.flags.help){xk();return}let t=e.subcommand;t||($("Missing required argument: <file>"),console.error('Run "asm import --help" for usage.'),process.exit(2));let{resolve:s}=await import("path"),i=s(t),n;try{n=await lu(i)}catch(l){$(l.message),process.exit(1)}let r=n.skills.length;if(r===0){e.flags.json?console.log(JSON.stringify({total:0,installed:0,skipped:0,failed: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(`${u.bold("Importing")} ${r} skill${r>1?"s":""} from ${u.dim(i)}`),console.error(` Scope filter: ${o}`),e.flags.force&&console.error(` ${u.yellow("Force mode: existing skills will be overwritten")}`),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
672
|
+
${u.bold("Proceed?")} [y/N] `);let l=await G();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await cu(n,{force:e.flags.force,dryRun:!1,scopeFilter:e.flags.scope});if(e.flags.json){console.log(JSON.stringify(a,null,2));return}if(a.total===0){console.error(`
|
|
673
|
+
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let l of a.results){let c=l.status==="installed"?u.green("+++"):l.status==="skipped"?u.yellow("---"):l.status==="dry-run"?u.cyan("~~~"):u.red("!!!"),f=l.reason?` ${u.dim(l.reason)}`:"",d=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${f}${d}`)}console.error(""),console.error(`${u.bold("Summary:")} ${a.total} total, ${u.green(String(a.installed))} installed, ${u.yellow(String(a.skipped))} skipped, ${u.red(String(a.failed))} failed`),a.failed>0&&(process.exitCode=1)}function Ck(){console.log(`${u.bold("Usage:")} asm init <name> [options]
|
|
608
674
|
|
|
609
675
|
Scaffold a new skill directory with a SKILL.md template. Creates a
|
|
610
676
|
ready-to-edit skill in the target tool's skill folder.
|
|
@@ -619,8 +685,8 @@ ${u.bold("Options:")}
|
|
|
619
685
|
${u.bold("Examples:")}
|
|
620
686
|
asm init my-skill ${u.dim("Scaffold (interactive tool)")}
|
|
621
687
|
asm init my-skill -p claude ${u.dim("Scaffold in Claude Code")}
|
|
622
|
-
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function
|
|
623
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await
|
|
688
|
+
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function Ak(e){if(e.flags.help){Ck();return}let t=e.subcommand;t||($("Missing required argument: <name>"),console.error('Run "asm init --help" for usage.'),process.exit(2));let s=Me(t),i;if(e.flags.path){let{resolve:n}=await import("path");i=n(e.flags.path)}else{let n=await B(),{provider:r}=await Xe(n,e.flags.provider,!!process.stdin.isTTY),{join:o}=await import("path"),{resolveProviderPath:a}=await import("./config-FRM3YOMA.js"),l=a(n.providers.find(c=>c.name===r.name).global);i=o(l,s)}if(await du(i)&&!e.flags.force){process.stdin.isTTY||($(`Directory already exists: ${i}. Use --force to overwrite.`),process.exit(2)),process.stderr.write(`${u.yellow(`Directory already exists: ${i}`)}
|
|
689
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await uu(s,i),console.error(u.green(`Done! Created skill "${s}" at ${i}`))}function Pk(){console.log(`${u.bold("Usage:")} asm stats [options]
|
|
624
690
|
|
|
625
691
|
Show aggregate skill metrics with provider distribution charts,
|
|
626
692
|
scope breakdown, disk usage, and duplicate summary.
|
|
@@ -634,7 +700,7 @@ ${u.bold("Options:")}
|
|
|
634
700
|
${u.bold("Examples:")}
|
|
635
701
|
asm stats ${u.dim("Show full dashboard")}
|
|
636
702
|
asm stats -s global ${u.dim("Global skills only")}
|
|
637
|
-
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function
|
|
703
|
+
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function Nk(e){if(e.flags.help){Pk();return}let t=await B(),s=await X(t,e.flags.scope);if(s.length===0){console.log("No skills found.");return}let i=qi(s),n=await pu(s,i);if(e.flags.json)if(e.flags.verbose)console.log(Y(n));else{let{perSkillDiskBytes:r,...o}=n;console.log(Y(o))}else console.log(mu(n))}function Ik(){console.log(`${u.bold("Usage:")} asm doctor [options]
|
|
638
704
|
|
|
639
705
|
Run environment health checks and diagnostics. Validates all
|
|
640
706
|
prerequisites for using asm \u2014 git, GitHub CLI, Node.js, config,
|
|
@@ -649,7 +715,7 @@ ${u.bold("Options:")}
|
|
|
649
715
|
${u.bold("Examples:")}
|
|
650
716
|
asm doctor ${u.dim("Run all health checks")}
|
|
651
717
|
asm doctor --json ${u.dim("Output as JSON")}
|
|
652
|
-
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function
|
|
718
|
+
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function Rk(e){if(e.flags.help){Ik();return}let t=performance.now(),s=await rd();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(Q("doctor",i,t))}else e.flags.json?console.log(ad(s)):console.log(od(s));s.failures>0&&process.exit(1)}function Lk(){console.log(`${u.bold("Usage:")} asm eval <target> [options]
|
|
653
719
|
|
|
654
720
|
Evaluate a skill's SKILL.md against best practices and produce a scored quality
|
|
655
721
|
report with recommendations. Zero configuration \u2014 just point it at a skill
|
|
@@ -685,8 +751,8 @@ ${u.bold("Examples:")}
|
|
|
685
751
|
asm eval ./my-skill --fix ${u.dim("Auto-fix deterministic issues")}
|
|
686
752
|
asm eval ./my-skill --fix --dry-run ${u.dim("Preview fixes as diff")}
|
|
687
753
|
asm eval ./my-skill --machine ${u.dim("Machine-readable v1 envelope")}
|
|
688
|
-
asm eval-providers list ${u.dim("List registered eval providers")}`)}function
|
|
689
|
-
`))}function
|
|
754
|
+
asm eval-providers list ${u.dim("List registered eval providers")}`)}function Ok(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 Tk(e,t,s){await De();let i=Te(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 ms(i);let n=await Fe(i,t),r=i.subpath?lo(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 ae(n)},sourceRef:a,commitSha:o}}async function Gd(e){Ii();try{let t={skillPath:e.skillPath,skillMdPath:e.skillMdPath},s=(await Promise.all(ss(Ri()).map(async r=>(await r.applicable(t,{})).ok?Li(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 Ok(i),{report:{...i.raw,providers:ss(s.map(jd))},error:null}}catch(t){return{report:null,error:t?.message??String(t)}}}async function Mk(e){if(e.flags.help){Lk();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;if(i||(e.flags.machine&&(t?.(),console.log(ee("eval",Z.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(io(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(ee("eval",Z.INVALID_ARGUMENT,r,s)),process.exit(2)),$(r),process.exit(2)}try{let r=await yd(),o=await gd(i,{dryRun:e.flags.dryRun,gitAuthor:r});if(e.flags.machine){t?.(),console.log(Q("eval",Ci(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(Ei(o.report)),console.log(""),console.log(wd(o));return}catch(r){e.flags.machine&&(t?.(),console.log(ee("eval",Z.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 vd(i,{fetchRemote:r=>Tk(r,e.flags.transport,e.flags.keep)})}catch(r){e.flags.machine&&(t?.(),console.log(ee("eval",Z.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 Gd(c);if(!f)throw new Error(d??"eval failed");if(e.flags.machine){t?.();let p=Ci(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(Q("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(bd(f));return}console.log(Ei(f)),n.provenance.remote&&Dk(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 Sd(n.targets,r,async c=>{let{report:f,error:d}=await Gd(c);return{label:c.label,skillPath:c.skillPath,report:f,error:d}}),a=kd(o),l={provenance:n.provenance,aggregate:a,results:o};if(e.flags.machine){t?.(),console.log(Q("eval",xd(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(Ei(c.report)):(console.log(`Skill evaluation: ${c.skillPath}`),console.log(` ${u.red("error:")} ${c.error??"unknown failure"}`)),console.log("");console.log($d(l)),n.provenance.remote&&e.flags.verbose}catch(r){e.flags.machine&&(t?.(),console.log(ee("eval",Z.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 Dk(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 Fk(){console.log(`${u.bold("Usage:")} asm eval-providers <subcommand> [options]
|
|
690
756
|
|
|
691
757
|
Manage evaluation providers registered with the ${u.bold("asm eval")} framework.
|
|
692
758
|
Providers implement the ${u.bold("EvalProvider")} contract (see src/eval/types.ts) and
|
|
@@ -702,7 +768,7 @@ ${u.bold("Options:")}
|
|
|
702
768
|
|
|
703
769
|
${u.bold("Examples:")}
|
|
704
770
|
asm eval-providers list ${u.dim("Show registered providers")}
|
|
705
|
-
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function
|
|
771
|
+
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function _k(e){if(e.flags.help){Fk();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":{Ii();let s=Ai();if(e.flags.json){console.log(Y(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"],n=s.map(a=>[a.id,a.version,String(a.schemaVersion),a.description,a.requires&&a.requires.length>0?a.requires.join(","):"-"]),r=i.map((a,l)=>Math.max(a.length,...n.map(c=>c[l].length))),o=a=>a.map((l,c)=>l.padEnd(r[c])).join(" ");console.log(u.bold(o(i))),console.log(r.map(a=>"-".repeat(a)).join(" "));for(let a of n)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 jk(){console.log(`${u.bold("Usage:")} asm link <path> [<path2> ...] [options]
|
|
706
772
|
|
|
707
773
|
Symlink a local skill directory into an agent's skill folder. Useful
|
|
708
774
|
for local development \u2014 changes to the source are reflected immediately.
|
|
@@ -726,13 +792,13 @@ ${u.bold("Examples:")}
|
|
|
726
792
|
asm link ./my-skill -p claude ${u.dim("Link to Claude Code")}
|
|
727
793
|
asm link ./my-skill --name alias ${u.dim("Link with custom name")}
|
|
728
794
|
asm link ./my-skills-folder ${u.dim("Link all skills in folder")}
|
|
729
|
-
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function
|
|
730
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await
|
|
795
|
+
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function qk(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(`${u.yellow(`Target already exists: ${e}`)}
|
|
796
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await G();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function Oi(e,t,s,i){let{join:n}=await import("path"),r=n(t,s),o=await qk(r,i);return await yu(e,t,s,o),{name:s,symlinkPath:r,targetPath:e}}async function Bk(e){if(e.flags.help){jk();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 B(),{provider:h}=await Xe(y,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:g}=await import("./config-FRM3YOMA.js"),b=g(y.providers.find(C=>C.name===h.name).global),{resolve:w,basename:k}=await import("path"),S=[],v=[];for(let C of t){let E=w(C),x=!1,M=null;try{await _r(E),x=!0}catch(O){let D=O instanceof Error?O.message:String(O);D.startsWith("Path does not exist")||D.startsWith("Path is not a directory")||D.startsWith("No SKILL.md found")||(M=D)}if(M){v.push({name:C,error:M}),e.flags.json||console.error(u.red(` Failed to process "${C}": ${M}`));continue}if(x){let O=k(E);try{let D=await Oi(E,b,O,!!e.flags.force);S.push(D),e.flags.json||console.error(u.green(` Linked "${D.name}" -> ${D.targetPath}`))}catch(D){let T=D instanceof Error?D.message:String(D);v.push({name:O,error:T}),e.flags.json||console.error(u.red(` Failed to link "${O}": ${T}`))}}else{let O=[];try{O=await jr(E)}catch(D){let T=D instanceof Error?D.message:String(D),A=T;T.startsWith("Path does not exist")&&zt(C)&&(A=`${T} \u2014 "${C}" looks like a registry name; try "asm install ${C}" first.`),v.push({name:C,error:A}),e.flags.json||console.error(u.red(` Failed to process "${C}": ${A}`));continue}if(O.length===0){let D=`No SKILL.md found in ${E} or its immediate subdirectories.`;v.push({name:C,error:D}),e.flags.json||console.error(u.red(` ${D}`));continue}for(let D of O)try{let T=await Oi(D.absPath,b,D.dirName,!!e.flags.force);S.push(T),e.flags.json||console.error(u.green(` Linked "${T.name}" -> ${T.targetPath}`))}catch(T){let A=T instanceof Error?T.message:String(T);v.push({name:D.name,error:A}),e.flags.json||console.error(u.red(` Failed to link "${D.name}": ${A}`))}}}e.flags.json?console.log(Y({success:v.length===0,linked:S,failures:v})):v.length>0?console.error(u.yellow(`
|
|
731
797
|
${S.length} linked, ${v.length} failed.`)):console.error(u.green(`
|
|
732
|
-
Done! Linked ${S.length} skill(s) successfully.`)),v.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await
|
|
733
|
-
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await
|
|
798
|
+
Done! Linked ${S.length} skill(s) successfully.`)),v.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await _r(r),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 jr(r)}catch(y){let h=y instanceof Error?y.message:String(y);h.startsWith("Path does not exist")?($(`No such skill or path: ${s}`),zt(s)?(console.error(` "${s}" looks like a registry name, not a local path.`),console.error(` Install it first: ${u.bold(`asm install ${s}`)}`),console.error(` Or pass a local path: ${u.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 ${r} 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 l=await B(),{provider:c}=await Xe(l,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:f}=await import("./config-FRM3YOMA.js"),d=f(l.providers.find(y=>y.name===c.name).global);if(o){let y=e.flags.name?Me(e.flags.name):n(r),h;try{h=await Oi(r,d,y,!!e.flags.force)}catch(g){let b=g instanceof Error?g.message:String(g);e.flags.json?console.log(Y({success:!1,error:b})):$(b),process.exit(2)}e.flags.json?console.log(Y({success:!0,...h})):(console.error(u.green(`Done! Linked "${h.name}" -> ${h.targetPath}`)),console.error(` Symlink: ${h.symlinkPath}`),console.error(u.dim(` If you move or delete the source, run "asm uninstall ${h.name}" to clean up.`)));return}console.error(`Found ${u.bold(String(a.length))} skill(s) in ${r}:`);for(let y of a)console.error(` ${u.bold(y.name)} ${u.dim(`v${y.version}`)} ${u.dim(`(${y.dirName}/)`)}`);if(process.stdin.isTTY&&!e.flags.force){process.stderr.write(`
|
|
799
|
+
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await G();(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?Me(e.flags.name):y.dirName;try{let g=await Oi(y.absPath,d,h,!!e.flags.force);p.push(g),e.flags.json||console.error(u.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(u.red(` Failed to link "${y.name}": ${b}`))}}e.flags.json?console.log(Y({success:m.length===0,linked:p,failures:m})):m.length>0?console.error(u.yellow(`
|
|
734
800
|
${p.length} linked, ${m.length} failed.`)):console.error(u.green(`
|
|
735
|
-
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}function
|
|
801
|
+
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}function Uk(){console.log(`${u.bold("Usage:")} asm index <subcommand> [options]
|
|
736
802
|
|
|
737
803
|
Manage the skill index for searching available skills from indexed repos.
|
|
738
804
|
|
|
@@ -756,10 +822,10 @@ ${u.bold("Examples:")}
|
|
|
756
822
|
asm index search marketing --has license ${u.dim("Only with license")}
|
|
757
823
|
asm index search "" --missing creator ${u.dim("Skills missing creator")}
|
|
758
824
|
asm index list ${u.dim("List indexed repos")}
|
|
759
|
-
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function
|
|
760
|
-
`));for(let o of r){let a=o.skill.verified?u.blue(" [verified]"):"";console.error(`${u.cyan(o.skill.name)} ${u.dim(`v${o.skill.version}`)}${a} ${u.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let c of
|
|
761
|
-
`)}}break}case"list":{let s=await
|
|
762
|
-
`));for(let n of s)console.error(`${u.cyan(`${n.owner}/${n.repo}`)} - ${n.skillCount} skills ${u.dim(`(${new Date(n.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,n]=s.split("/");if((!i||!n)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove")} ${u.cyan(`${i}/${n}`)} ${u.bold("from index?")} [y/N] `);let o=await
|
|
825
|
+
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function Vk(e){if(e.flags.help){Uk();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(u.blueBold(`Ingesting ${s}...`));let i=await Kd(s);i.success||($(`Failed to ingest: ${i.error}`),process.exit(1)),i.repoIndex&&(e.flags.json?console.log(Y({success:!0,owner:i.repoIndex.owner,repo:i.repoIndex.repo,skillCount:i.repoIndex.skillCount,updatedAt:i.repoIndex.updatedAt})):(console.error(u.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&&($("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);let r=i.has||i.missing?await hi(s||"",20,i):await hi(s);if(r.length===0){e.flags.json?console.log(Y([])):(console.info("No skills found matching your query."),console.error(u.dim("Try ingesting more repos with: asm index ingest <repo>")));return}if(e.flags.json)console.log(Y(r.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(u.bold(`Found ${r.length} skills:
|
|
826
|
+
`));for(let o of r){let a=o.skill.verified?u.blue(" [verified]"):"";console.error(`${u.cyan(o.skill.name)} ${u.dim(`v${o.skill.version}`)}${a} ${u.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let c of Lo(o.skill.description,80))console.error(` ${c}`);let l=ku(o.skill);l.length>0&&console.error(` ${u.yellow(`\u26A0 Missing: ${l.join(", ")}`)}`),console.error(` ${u.green(`asm install ${o.skill.installUrl}`)}
|
|
827
|
+
`)}}break}case"list":{let s=await Jd();if(s.length===0){e.flags.json?console.log(Y([])):(console.info("No repositories indexed."),console.error(u.dim("Add repos with: asm index ingest <repo>")));return}let i=await Su();if(e.flags.json)console.log(Y(s));else{console.error(u.bold(`Indexed Repositories (${i} total skills):
|
|
828
|
+
`));for(let n of s)console.error(`${u.cyan(`${n.owner}/${n.repo}`)} - ${n.skillCount} skills ${u.dim(`(${new Date(n.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,n]=s.split("/");if((!i||!n)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove")} ${u.cyan(`${i}/${n}`)} ${u.bold("from index?")} [y/N] `);let o=await G();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await Hd(i,n)?console.error(u.green(`Removed ${i}/${n} from index`)):($(`Repository not found in index: ${i}/${n}`),process.exit(1));break}default:$(`Unknown subcommand: "${t}"`),console.error('Run "asm index --help" for usage.'),process.exit(2)}}function Kk(){console.log(`${u.bold("Usage:")} asm bundle <subcommand> [options]
|
|
763
829
|
|
|
764
830
|
Create, install, and manage curated skill bundles. A bundle is a reusable
|
|
765
831
|
recipe of skills for a particular workflow, domain, or project setup.
|
|
@@ -795,14 +861,14 @@ ${u.bold("Examples:")}
|
|
|
795
861
|
asm bundle modify my-workflow --add github:u/r ${u.dim("Add a skill to bundle")}
|
|
796
862
|
asm bundle modify my-workflow --remove skill ${u.dim("Remove a skill from bundle")}
|
|
797
863
|
asm bundle export my-workflow ${u.dim("Export to ./my-workflow.json")}
|
|
798
|
-
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function
|
|
799
|
-
`));let g=await Qe({items:h});g.length===0&&($("No skills selected. Bundle not created."),process.exit(1)),a=g.map(b=>o[b])}let{readLock:l}=await import("./lock-
|
|
800
|
-
${u.bold("Description")} (optional, press Enter to skip): `);let h=await
|
|
801
|
-
${u.bold("Install all skills from this bundle?")} [y/N] `);let d=await
|
|
802
|
-
Installing ${u.bold(d.name)}...`);try{(d.installUrl.startsWith("github:")||d.installUrl.startsWith("https://github.com/"))&&await De();let m=Te(d.installUrl),y=!!m.isLocal,h=null;try{let g,b;y?(g=m.localPath,b=m.localPath):(h=await
|
|
864
|
+
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function Jk(e){if(e.flags.help){Kk();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 B(),n=await X(i,e.flags.scope);n.length===0&&($("No skills found to include in the bundle."),process.exit(1));let r=new Set,o=n.filter(h=>{let g=h.name.toLowerCase();return r.has(g)?!1:(r.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(u.bold(`Select skills for bundle "${s}":
|
|
865
|
+
`));let g=await Qe({items:h});g.length===0&&($("No skills selected. Bundle not created."),process.exit(1)),a=g.map(b=>o[b])}let{readLock:l}=await import("./lock-6S53S4SC.js"),c=await l(),f=await Promise.all(a.map(h=>Mu(h,c))),d=`Bundle of ${f.length} skills`,p="unknown";try{let{execSync:h}=await import("child_process"),g=h("git config user.name",{encoding:"utf-8"}).trim();g&&(p=g)}catch{}if(process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`
|
|
866
|
+
${u.bold("Description")} (optional, press Enter to skip): `);let h=await G();h.trim()&&(d=h.trim()),process.stderr.write(`${u.bold("Author")} (optional, press Enter to skip): `);let g=await G();g.trim()&&(p=g.trim())}let m=Tu(s,d,p,f),y=await Vr(m);e.flags.json?console.log(JSON.stringify(m,null,2)):(console.error(u.green(`Bundle "${s}" created with ${f.length} skill(s).`)),console.error(` Saved to: ${u.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 es(s)}catch(d){$(d.message),process.exit(1)}console.error(`${u.bold("Bundle:")} ${i.name} (${i.skills.length} skills)`),i.description&&console.error(` ${u.dim(i.description)}`),console.error("");for(let d of i.skills){let p=d.version?` v${d.version}`:"";console.error(` ${u.cyan(d.name)}${u.dim(p)} ${u.dim(`-> ${d.installUrl}`)}`)}if(!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
867
|
+
${u.bold("Install all skills from this bundle?")} [y/N] `);let d=await G();d.toLowerCase()!=="y"&&d.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let n=[],r=await B(),{provider:o}=await Xe(r,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(`
|
|
868
|
+
Installing ${u.bold(d.name)}...`);try{(d.installUrl.startsWith("github:")||d.installUrl.startsWith("https://github.com/"))&&await De();let m=Te(d.installUrl),y=!!m.isLocal,h=null;try{let g,b;y?(g=m.localPath,b=m.localPath):(h=await Fe(m,e.flags.transport),g=h,b=m.subpath?lo(h,m.subpath):h);let w=await _e(b),k=Me(d.name||w.name||m.repo),S=Qi(m,g,b,k,o,e.flags.force,a);try{await la(S.targetDir,S.force)}catch(v){if(v.message?.includes("--force")){n.push({name:d.name,status:"skipped",reason:"Already installed. Use --force to overwrite."}),console.error(` ${u.dim("---")} ${d.name} skipped (already installed)`);continue}throw v}await gs(S),n.push({name:d.name,status:"installed"}),console.error(` ${u.green("+++")} ${d.name} installed`)}finally{h&&await ae(h)}}catch(p){n.push({name:d.name,status:"failed",reason:p.message}),console.error(` ${u.red("!!!")} ${d.name}: ${p.message}`)}}let l=n.filter(d=>d.status==="installed").length,c=n.filter(d=>d.status==="skipped").length,f=n.filter(d=>d.status==="failed").length;e.flags.json?console.log(JSON.stringify({bundleName:i.name,total:n.length,installed:l,skipped:c,failed:f,results:n},null,2)):(console.error(""),console.error(`${u.bold("Summary:")} ${n.length} total, ${u.green(String(l))} installed, `+(c>0?`${u.dim(String(c))} skipped, `:"")+`${u.red(String(f))} failed`)),f>0&&(process.exitCode=1);break}case"list":{if(!!e.flags.predefined){let n=await Du();if(n.length===0){e.flags.json?console.log("[]"):console.log("No predefined bundles found.");return}if(e.flags.json)console.log(JSON.stringify(n,null,2));else{console.error(u.bold(`Pre-defined Bundles (${n.length}):
|
|
803
869
|
`));for(let r of n){let o=r.tags&&r.tags.length>0?` ${u.dim(`[${r.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(r.name)} ${u.dim(`(${r.skills.length} skills)`)}${o}`),r.description&&console.error(` ${u.dim(r.description)}`)}console.error(`
|
|
804
|
-
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await
|
|
870
|
+
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await _u();if(i.length===0){e.flags.json?console.log("[]"):(console.log("No bundles found."),console.error(u.dim("Create one with: asm bundle create <name>")),console.error(u.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(u.bold(`Saved Bundles (${i.length}):
|
|
805
871
|
`));for(let n of i){let r=n.tags&&n.tags.length>0?` ${u.dim(`[${n.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(n.name)} ${u.dim(`(${n.skills.length} skills)`)}${r}`),n.description&&console.error(` ${u.dim(n.description)}`),n.author&&console.error(` ${u.dim(`by ${n.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 es(s)}catch(n){$(n.message),process.exit(1)}if(e.flags.json)console.log(JSON.stringify(i,null,2));else{console.error(u.bold(`Bundle: ${i.name}`)),i.description&&console.error(` ${i.description}`),i.author&&console.error(` ${u.dim(`Author: ${i.author}`)}`),console.error(` ${u.dim(`Created: ${new Date(i.createdAt).toLocaleString()}`)}`),i.tags&&i.tags.length>0&&console.error(` ${u.dim(`Tags: ${i.tags.join(", ")}`)}`),console.error(`
|
|
806
|
-
${u.bold(`Skills (${i.skills.length})`)}:`);for(let n of i.skills){let r=n.version?` v${n.version}`:"";console.error(` ${u.cyan(n.name)}${u.dim(r)}`),n.description&&console.error(` ${u.dim(n.description)}`),console.error(` ${u.dim(`install: ${n.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(`${u.bold("Remove bundle")} ${u.cyan(s)}${u.bold("?")} [y/N] `);let n=await
|
|
807
|
-
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(u.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)}}async function
|
|
808
|
-
`)),console.log(JSON.stringify(n.manifest,null,2));return}n.prUrl&&(console.error(u.green("Published successfully!")),console.error(""),console.error(` PR: ${n.prUrl}`),console.error(` Manifest: manifests/${n.manifest?.author}/${n.manifest?.name}.json`),console.error(` Security: ${n.securityVerdict}`),console.error(""),console.error(u.dim("The registry maintainers will review your submission.")))}catch(n){let r={success:!1,manifest:null,prUrl:null,error:n.message,securityVerdict:"pass",securityReport:{scannedAt:new Date().toISOString(),skillName:"",skillPath:"",source:null,codeScans:[],permissions:[],totalFiles:0,totalLines:0,verdict:"safe",verdictReason:""}};e.flags.machine&&(t?.(),console.log(
|
|
872
|
+
${u.bold(`Skills (${i.skills.length})`)}:`);for(let n of i.skills){let r=n.version?` v${n.version}`:"";console.error(` ${u.cyan(n.name)}${u.dim(r)}`),n.description&&console.error(` ${u.dim(n.description)}`),console.error(` ${u.dim(`install: ${n.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(`${u.bold("Remove bundle")} ${u.cyan(s)}${u.bold("?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await ju(s)}catch(n){$(n.message),process.exit(1)}i?console.error(u.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 es(s)}catch(d){$(d.message),process.exit(1)}let n=!1,r=e.flags.add;if(r){let d={name:r.split("/").pop()?.replace(/\.json$/,"")??r,installUrl:r};i.skills.push(d),n=!0,console.error(u.green(`Added skill from ${r}`))}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?(n=!0,console.error(u.green(`Removed skill "${o}"`))):console.error(u.dim(`Skill "${o}" not found in bundle (no change)`))}let a=e.flags.description;a!==null&&(i.description=a,n=!0);let l=e.flags.author;l!==null&&(i.author=l,n=!0);let c=e.flags.tags;if(c!==null&&(i.tags=c.split(",").map(d=>d.trim()).filter(d=>d.length>0),n=!0),!n&&process.stdin.isTTY&&!e.flags.yes&&!r&&!o&&a===null&&l===null&&c===null){console.error(u.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(`${u.bold("New description")} (Enter to keep current): `);let d=await G();d.trim()&&(i.description=d.trim(),n=!0),process.stderr.write(`${u.bold("New author")} (Enter to keep current): `);let p=await G();p.trim()&&(i.author=p.trim(),n=!0),process.stderr.write(`${u.bold("New tags (comma-separated)")} (Enter to keep current): `);let m=await G();m.trim()&&(i.tags=m.split(",").map(y=>y.trim()).filter(y=>y.length>0),n=!0)}if(!n){console.error(u.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 Vr(i);e.flags.json?console.log(JSON.stringify(i,null,2)):(console.error(u.green(`Bundle "${i.name}" updated (${i.skills.length} skill(s)).`)),console.error(` Saved to: ${u.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 es(s)}catch(l){$(l.message),process.exit(1)}let n=e.positional[1]??`./${s}.json`,{resolve:r}=await import("path"),o=r(n);if(!e.flags.force){let{access:l}=await import("fs/promises");try{if(await l(o),process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`File ${u.bold(o)} already exists. Overwrite? [y/N] `);let c=await G();c.toLowerCase()!=="y"&&c.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)+`
|
|
873
|
+
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(u.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)}}async function Hk(e){if(e.flags.help){Zv();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand||".";try{let n=await Ju({path:i,dryRun:e.flags.dryRun,force:e.flags.force,yes:e.flags.yes});if(e.flags.machine){t?.(),n.success||(console.log(ee("publish",Z.PUBLISH_FAILED,n.error||"Publish failed",s,{manifest:n.manifest,security_verdict:n.securityVerdict,fallback:n.fallback??!1})),process.exit(1)),console.log(Q("publish",{manifest:n.manifest,pr_url:n.prUrl,status:n.securityVerdict},s));return}if(e.flags.json){console.log(JSON.stringify({success:n.success,manifest:n.manifest,pr_url:n.prUrl,error:n.error,security_verdict:n.securityVerdict},null,2)),n.success||process.exit(1);return}if(n.success||($(n.error||"Publish failed."),process.exit(1)),n.fallback){console.log(u.yellow("Manifest generated (gh CLI unavailable):")),console.log(Hu(n));return}if(e.flags.dryRun){console.error(u.dim(`Dry run \u2014 no PR created.
|
|
874
|
+
`)),console.log(JSON.stringify(n.manifest,null,2));return}n.prUrl&&(console.error(u.green("Published successfully!")),console.error(""),console.error(` PR: ${n.prUrl}`),console.error(` Manifest: manifests/${n.manifest?.author}/${n.manifest?.name}.json`),console.error(` Security: ${n.securityVerdict}`),console.error(""),console.error(u.dim("The registry maintainers will review your submission.")))}catch(n){let r={success:!1,manifest:null,prUrl:null,error:n.message,securityVerdict:"pass",securityReport:{scannedAt:new Date().toISOString(),skillName:"",skillPath:"",source:null,codeScans:[],permissions:[],totalFiles:0,totalLines:0,verdict:"safe",verdictReason:""}};e.flags.machine&&(t?.(),console.log(ee("publish",Z.PUBLISH_FAILED,n.message,s)),process.exit(1)),e.flags.json&&(console.log(JSON.stringify({success:!1,manifest:null,pr_url:null,error:n.message,security_verdict:null},null,2)),process.exit(1)),$(n.message),process.exit(1)}}async function Wk(e){if(e.flags.help){ek();return}let t=e.flags.machine?Ye():void 0,s=performance.now();try{let i=await Yr();if(e.flags.machine){t?.();let r=i.entries.map(o=>({name:o.name,installed_commit:o.installedCommit,latest_commit:o.latestCommit,source:o.sourceType,status:o.status}));console.log(Q("outdated",r,s));return}if(e.flags.json){console.log(Zu(i));return}let n=!e.flags.noColor&&process.stdout.isTTY!==!1;console.log(Xu(i,n)),i.outdatedCount>0&&(process.exitCode=1)}catch(i){e.flags.machine&&(t?.(),console.log(ee("outdated",Z.UNKNOWN_ERROR,i.message,s)),process.exit(1)),$(i.message),process.exit(1)}}async function Gk(e){if(e.flags.help){tk();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=[];e.subcommand&&i.push(e.subcommand),i.push(...e.positional);try{let n=await Qu(i.length>0?i:null,e.flags.yes);if(e.flags.machine){t?.();let o=n.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(Q("update",o,s));return}if(e.flags.json){console.log(ed(n));return}if(n.results.length>0&&console.error(u.yellow("Note: project-scoped skill detection is not yet supported. All updates target the global skill path.")),n.warnings&&n.warnings.length>0)for(let o of n.warnings)console.error(u.yellow(`Warning: skill "${o}" not found in lock file \u2014 skipped`));if(n.results.length===0){console.log("All skills are up to date.");return}for(let o of n.results)switch(o.status){case"updated":console.log(`${u.green("\u2713")} ${o.name} ${u.dim(o.oldCommit||"")} \u2192 ${o.newCommit||""}`),o.securityVerdict==="warning"&&console.error(u.yellow(` \u26A0 Security audit returned warning for ${o.name} \u2014 updated because --yes was supplied`));break;case"skipped":console.log(`${u.yellow("\u25CB")} ${o.name} ${u.dim(o.reason||"skipped")}`);break;case"failed":console.log(`${u.red("\u2717")} ${o.name} ${u.dim(o.reason||"failed")}`);break}console.log("");let r=[];n.updatedCount>0&&r.push(u.green(`${n.updatedCount} updated`)),n.skippedCount>0&&r.push(u.yellow(`${n.skippedCount} skipped`)),n.failedCount>0&&r.push(u.red(`${n.failedCount} failed`)),console.log(r.join(", ")),n.failedCount>0&&(process.exitCode=1)}catch(n){e.flags.machine&&(t?.(),console.log(ee("update",Z.UNKNOWN_ERROR,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}}async function Zd(e){let t=Hv(e);if(t.flags.json&&t.flags.machine&&($("--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&&fo(!0),t.flags.version){console.log(`asm ${Bi}`);let s=await $i();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(u.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(u.dim(" Remove the stale global install (npm uninstall -g agent-skill-manager) and keep only one.")),console.error(u.dim(" See: https://github.com/luongnv89/asm#troubleshooting"))}return}if(!t.command&&t.flags.help){Wv();return}if(t.command)switch(t.command){case"list":await ik(t);break;case"search":await nk(t);break;case"inspect":await rk(t);break;case"uninstall":await ok(t);break;case"disable":await ck(t);break;case"enable":await uk(t);break;case"audit":await dk(t);break;case"install":await kk(t);break;case"config":await gk(t);break;case"export":await $k(t);break;case"import":await Ek(t);break;case"init":await Ak(t);break;case"stats":await Nk(t);break;case"link":await Bk(t);break;case"index":await Vk(t);break;case"bundle":await Jk(t);break;case"publish":await Hk(t);break;case"outdated":await Wk(t);break;case"update":await Gk(t);break;case"doctor":await Rk(t);break;case"eval":await Mk(t);break;case"eval-providers":await _k(t);break;default:$(`Unknown command: "${t.command}"`),console.error('Run "asm --help" for usage.'),process.exit(2)}}function ef(e){let t=e.slice(2);if(t.length===0)return!1;let s=["list","search","inspect","uninstall","audit","config","install","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(ef(process.argv))await Zd(process.argv);else{let{main:e}=await import("./src-H2QOCGTV.js");await e().catch(t=>{console.error("Fatal error:",t),process.exit(1)})}
|