agent-skill-manager 2.6.0 → 2.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,89 +1,89 @@
|
|
|
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 Re,b as yt,c as
|
|
4
|
-
`)}};wt.defaultYaml={explicit:!1,version:"1.2"};wt.defaultTags={"!!":"tag:yaml.org,2002:"};
|
|
5
|
-
`)?
|
|
3
|
+
import{a as Re,b as yt,c as vo,d as ko}from"./chunk-PVEAYTE2.js";import{C as bo,D as wo,E as W,F as Oi,G as So,I as $o,J as xo,K as Eo,L as Ti,M as Co,a as re,b as ue,c as no,d as is,g as ee,h as ro,i as Pi,j as oo,k as ao,l as Ni,m as lo,n as u,o as co,p as uo,q as fo,r as Ii,s as Li,t as Ri,u as po,v as mo,w as ns,x as ho,y as go,z as yo}from"./chunk-JCZ5QZVC.js";import{a as Zr,b as I,c as eo,d as ht,e as to,f as gt,g as so,j as ce,k as B,l as io}from"./chunk-GOI5LV72.js";import{a as ss,b as P,d as Xr}from"./chunk-7BMOBFGJ.js";var F=P(Y=>{"use strict";var Vi=Symbol.for("yaml.alias"),jo=Symbol.for("yaml.document"),fs=Symbol.for("yaml.map"),Bo=Symbol.for("yaml.pair"),Ki=Symbol.for("yaml.scalar"),ds=Symbol.for("yaml.seq"),ye=Symbol.for("yaml.node.type"),Jf=e=>!!e&&typeof e=="object"&&e[ye]===Vi,Hf=e=>!!e&&typeof e=="object"&&e[ye]===jo,Gf=e=>!!e&&typeof e=="object"&&e[ye]===fs,Wf=e=>!!e&&typeof e=="object"&&e[ye]===Bo,Uo=e=>!!e&&typeof e=="object"&&e[ye]===Ki,Yf=e=>!!e&&typeof e=="object"&&e[ye]===ds;function Vo(e){if(e&&typeof e=="object")switch(e[ye]){case fs:case ds:return!0}return!1}function zf(e){if(e&&typeof e=="object")switch(e[ye]){case Vi:case fs:case Ki:case ds:return!0}return!1}var Qf=e=>(Uo(e)||Vo(e))&&!!e.anchor;Y.ALIAS=Vi;Y.DOC=jo;Y.MAP=fs;Y.NODE_TYPE=ye;Y.PAIR=Bo;Y.SCALAR=Ki;Y.SEQ=ds;Y.hasAnchor=Qf;Y.isAlias=Jf;Y.isCollection=Vo;Y.isDocument=Hf;Y.isMap=Gf;Y.isNode=zf;Y.isPair=Wf;Y.isScalar=Uo;Y.isSeq=Yf});var bt=P(Ji=>{"use strict";var J=F(),te=Symbol("break visit"),Ko=Symbol("skip children"),pe=Symbol("remove node");function ps(e,t){let s=Jo(t);J.isDocument(e)?Ze(null,e.contents,s,Object.freeze([e]))===pe&&(e.contents=null):Ze(null,e,s,Object.freeze([]))}ps.BREAK=te;ps.SKIP=Ko;ps.REMOVE=pe;function Ze(e,t,s,i){let n=Ho(e,t,s,i);if(J.isNode(n)||J.isPair(n))return Go(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===te)return te;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===te)return te;r===pe&&(t.key=null);let o=Ze("value",t.value,s,i);if(o===te)return te;o===pe&&(t.value=null)}}return n}async function ms(e,t){let s=Jo(t);J.isDocument(e)?await et(null,e.contents,s,Object.freeze([e]))===pe&&(e.contents=null):await et(null,e,s,Object.freeze([]))}ms.BREAK=te;ms.SKIP=Ko;ms.REMOVE=pe;async function et(e,t,s,i){let n=await Ho(e,t,s,i);if(J.isNode(n)||J.isPair(n))return Go(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===te)return te;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===te)return te;r===pe&&(t.key=null);let o=await et("value",t.value,s,i);if(o===te)return te;o===pe&&(t.value=null)}}return n}function Jo(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 Ho(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 Go(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`)}}Ji.visit=ps;Ji.visitAsync=ms});var Hi=P(Yo=>{"use strict";var Wo=F(),Xf=bt(),Zf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},ed=e=>e.replace(/[!,[\]{}]/g,t=>Zf[t]),wt=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+ed(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&&Wo.isNode(t.contents)){let r={};Xf.visit(t.contents,(o,a)=>{Wo.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
|
+
`)}};wt.defaultYaml={explicit:!1,version:"1.2"};wt.defaultTags={"!!":"tag:yaml.org,2002:"};Yo.Directives=wt});var hs=P(vt=>{"use strict";var zo=F(),td=bt();function sd(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 Qo(e){let t=new Set;return td.visit(e,{Value(s,i){i.anchor&&t.add(i.anchor)}}),t}function Xo(e,t){for(let s=1;;++s){let i=`${e}${s}`;if(!t.has(i))return i}}function id(e,t){let s=[],i=new Map,n=null;return{onAnchor:r=>{s.push(r),n??(n=Qo(e));let o=Xo(t,n);return n.add(o),o},setAnchors:()=>{for(let r of s){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(zo.isScalar(o.node)||zo.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}}vt.anchorIsValid=sd;vt.anchorNames=Qo;vt.createNodeAnchors=id;vt.findNewAnchor=Xo});var Gi=P(Zo=>{"use strict";function kt(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=kt(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=kt(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=kt(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=kt(e,i,n,r);o===void 0?delete i[n]:o!==r&&(i[n]=o)}return e.call(t,s,i)}Zo.applyReviver=kt});var ke=P(ta=>{"use strict";var nd=F();function ea(e,t,s){if(Array.isArray(e))return e.map((i,n)=>ea(i,String(n),s));if(e&&typeof e.toJSON=="function"){if(!s||!nd.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}ta.toJS=ea});var gs=P(ia=>{"use strict";var rd=Gi(),sa=F(),od=ke(),Wi=class{constructor(t){Object.defineProperty(this,sa.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(!sa.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=od.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof r=="function"?rd.applyReviver(r,{"":a},"",a):a}};ia.NodeBase=Wi});var St=P(na=>{"use strict";var ad=hs(),ld=bt(),tt=F(),cd=gs(),ud=ke(),Yi=class extends cd.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=[],ld.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||(ud.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=ys(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(ad.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 ys(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=ys(e,n,s);r>i&&(i=r)}return i}else if(tt.isPair(t)){let i=ys(e,t.key,s),n=ys(e,t.value,s);return Math.max(i,n)}return 1}na.Alias=Yi});var V=P(zi=>{"use strict";var fd=F(),dd=gs(),pd=ke(),md=e=>!e||typeof e!="function"&&typeof e!="object",Se=class extends dd.NodeBase{constructor(t){super(fd.SCALAR),this.value=t}toJSON(t,s){return s?.keep?this.value:pd.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";zi.Scalar=Se;zi.isScalarValue=md});var $t=P(oa=>{"use strict";var hd=St(),Fe=F(),ra=V(),gd="tag:yaml.org,2002:";function yd(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 bd(e,t,s){if(Fe.isDocument(e)&&(e=e.contents),Fe.isNode(e))return e;if(Fe.isPair(e)){let f=s.schema[Fe.MAP].createNode?.(s.schema,null,s);return f.items.push(e),f}(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 hd.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=gd+t.slice(2));let c=yd(e,t,o.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let f=new ra.Scalar(e);return l&&(l.node=f),f}c=e instanceof Map?o[Fe.MAP]:Symbol.iterator in Object(e)?o[Fe.SEQ]:o[Fe.MAP]}r&&(r(c),delete s.onTagObj);let d=c?.createNode?c.createNode(s.schema,e,s):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(s.schema,e,s):new ra.Scalar(e);return t?d.tag=t:c.default||(d.tag=c.tag),l&&(l.node=d),d}oa.createNode=bd});var ws=P(bs=>{"use strict";var wd=$t(),me=F(),vd=gs();function Qi(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 wd.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 aa=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,Xi=class extends vd.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(aa(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,Qi(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,Qi(this.schema,n,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};bs.Collection=Xi;bs.collectionFromPath=Qi;bs.isEmptyPath=aa});var xt=P(vs=>{"use strict";var kd=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function Zi(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var Sd=(e,t,s)=>e.endsWith(`
|
|
5
|
+
`)?Zi(s,t):s.includes(`
|
|
6
6
|
`)?`
|
|
7
|
-
`+
|
|
8
|
-
`)s===
|
|
9
|
-
`&&
|
|
10
|
-
`&&S!==" "&&(p=
|
|
11
|
-
${t}${e.slice(0,k)}`:(s===
|
|
12
|
-
${t}${e.slice(S+1,k)}`)}return v}function
|
|
13
|
-
`);i=t,n=t+1,r=e[n]}return i}Et.FOLD_BLOCK=
|
|
14
|
-
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function Ct(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(
|
|
7
|
+
`+Zi(s,t):(e.endsWith(" ")?"":" ")+s;vs.indentComment=Zi;vs.lineComment=Sd;vs.stringifyComment=kd});var ca=P(Et=>{"use strict";var $d="flow",en="block",ks="quoted";function xd(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=[],d={},f=n-t.length;typeof i=="number"&&(i>n-Math.max(2,r)?c.push(0):f=n-i);let p,h,y=!1,m=-1,g=-1,b=-1;s===en&&(m=la(e,m,t.length),m!==-1&&(f=m+l));for(let w;w=e[m+=1];){if(s===ks&&w==="\\"){switch(g=m,e[m+1]){case"x":m+=3;break;case"u":m+=5;break;case"U":m+=9;break;default:m+=1}b=m}if(w===`
|
|
8
|
+
`)s===en&&(m=la(e,m,t.length)),f=m+t.length+l,p=void 0;else{if(w===" "&&h&&h!==" "&&h!==`
|
|
9
|
+
`&&h!==" "){let S=e[m+1];S&&S!==" "&&S!==`
|
|
10
|
+
`&&S!==" "&&(p=m)}if(m>=f)if(p)c.push(p),f=p+l,p=void 0;else if(s===ks){for(;h===" "||h===" ";)h=w,w=e[m+=1],y=!0;let S=m>b+1?m-2:g-1;if(d[S])return e;c.push(S),d[S]=!0,f=S+l,p=void 0}else y=!0}h=w}if(y&&a&&a(),c.length===0)return e;o&&o();let v=e.slice(0,c[0]);for(let w=0;w<c.length;++w){let S=c[w],k=c[w+1]||e.length;S===0?v=`
|
|
11
|
+
${t}${e.slice(0,k)}`:(s===ks&&d[S]&&(v+=`${e[S]}\\`),v+=`
|
|
12
|
+
${t}${e.slice(S+1,k)}`)}return v}function la(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}Et.FOLD_BLOCK=en;Et.FOLD_FLOW=$d;Et.FOLD_QUOTED=ks;Et.foldFlowLines=xd});var At=P(ua=>{"use strict";var fe=V(),$e=ca(),$s=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),xs=e=>/^(%|---|\.\.\.)/m.test(e);function Ed(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 Ct(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(xs(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 d=s.substr(l+2,4);switch(d){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:d.substr(0,2)==="00"?o+="\\x"+d.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 Ct(e,t);let s=t.indent||(
|
|
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,$s(t,!1))}function tn(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
18
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return Ct(e,t);let s=t.indent||(xs(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
19
|
+
${s}`)+"'";return t.implicitKey?i:$e.foldFlowLines(i,s,$e.FOLD_FLOW,$s(t,!1))}function st(e,t){let{singleQuote:s}=t.options,i;if(s===!1)i=Ct;else{let n=e.includes('"'),r=e.includes("'");n&&!r?i=tn:r&&!n?i=Ct:i=s?tn:Ct}return i(e,t)}var sn;try{sn=new RegExp(`(^|(?<!
|
|
20
20
|
))
|
|
21
21
|
+(?!
|
|
22
|
-
|$)`,"g")}catch{
|
|
22
|
+
|$)`,"g")}catch{sn=/\n+(?!\n|$)/g}function Ss({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||xs(s)?" ":""),d=o==="literal"?!0:o==="folded"||t===fe.Scalar.BLOCK_FOLDED?!1:t===fe.Scalar.BLOCK_LITERAL?!0:!Ed(s,l,c.length);if(!s)return d?`|
|
|
23
23
|
`:`>
|
|
24
24
|
`;let f,p;for(p=s.length;p>0;--p){let k=s[p-1];if(k!==`
|
|
25
|
-
`&&k!==" "&&k!==" ")break}let
|
|
26
|
-
`);y===-1?f="-":s===
|
|
27
|
-
`&&(
|
|
28
|
-
`)b=g;else break}let v=s.substring(0,b<g?b+1:g);v&&(s=s.substring(v.length),v=v.replace(/\n+/g,`$&${c}`));let S=(
|
|
29
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
30
|
-
${c}${
|
|
31
|
-
${c}${v}${s}${
|
|
25
|
+
`&&k!==" "&&k!==" ")break}let h=s.substring(p),y=h.indexOf(`
|
|
26
|
+
`);y===-1?f="-":s===h||y!==h.length-1?(f="+",r&&r()):f="",h&&(s=s.slice(0,-h.length),h[h.length-1]===`
|
|
27
|
+
`&&(h=h.slice(0,-1)),h=h.replace(sn,`$&${c}`));let m=!1,g,b=-1;for(g=0;g<s.length;++g){let k=s[g];if(k===" ")m=!0;else if(k===`
|
|
28
|
+
`)b=g;else break}let v=s.substring(0,b<g?b+1:g);v&&(s=s.substring(v.length),v=v.replace(/\n+/g,`$&${c}`));let S=(m?c?"2":"1":"")+f;if(e&&(S+=" "+a(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!d){let k=s.replace(/\n+/g,`
|
|
29
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),C=!1,E=$s(i,!0);o!=="folded"&&t!==fe.Scalar.BLOCK_FOLDED&&(E.onOverflow=()=>{C=!0});let x=$e.foldFlowLines(`${v}${k}${h}`,c,$e.FOLD_BLOCK,E);if(!C)return`>${S}
|
|
30
|
+
${c}${x}`}return s=s.replace(/\n+/g,`$&${c}`),`|${S}
|
|
31
|
+
${c}${v}${s}${h}`}function Cd(e,t,s,i){let{type:n,value:r}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:d}=t;if(a&&r.includes(`
|
|
32
32
|
`)||d&&/[[\]{},]/.test(r))return st(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||d||!r.includes(`
|
|
33
|
-
`)?st(r,t):
|
|
34
|
-
`))return
|
|
35
|
-
${l}`);if(o){let p=
|
|
36
|
-
${t.indent}${a}`:a}
|
|
37
|
-
${a}:`):(g=`${g}:`,p&&(g+=Nt.lineComment(g,s.indent,c(p))));let b,v,w;be.isNode(t)?(b=!!t.spaceBefore,v=t.commentBefore,w=t.comment):(b=!1,v=null,w=null,t&&typeof t=="object"&&(t=o.createNode(t))),s.implicitKey=!1,!
|
|
38
|
-
`:"",v){let
|
|
39
|
-
${Nt.indentComment(
|
|
40
|
-
`&&w&&(
|
|
41
|
-
|
|
42
|
-
`):
|
|
43
|
-
${s.indent}`}else if(!
|
|
44
|
-
`),
|
|
33
|
+
`)?st(r,t):Ss(e,t,s,i);if(!a&&!d&&n!==fe.Scalar.PLAIN&&r.includes(`
|
|
34
|
+
`))return Ss(e,t,s,i);if(xs(r)){if(l==="")return t.forceBlockIndent=!0,Ss(e,t,s,i);if(a&&l===c)return st(r,t)}let f=r.replace(/\n+/g,`$&
|
|
35
|
+
${l}`);if(o){let p=m=>m.default&&m.tag!=="tag:yaml.org,2002:str"&&m.test?.test(f),{compat:h,tags:y}=t.doc.schema;if(y.some(p)||h?.some(p))return st(r,t)}return a?f:$e.foldFlowLines(f,l,$e.FOLD_FLOW,$s(t,!1))}function Ad(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!==fe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=fe.Scalar.QUOTE_DOUBLE);let l=d=>{switch(d){case fe.Scalar.BLOCK_FOLDED:case fe.Scalar.BLOCK_LITERAL:return n||r?st(o.value,t):Ss(o,t,s,i);case fe.Scalar.QUOTE_DOUBLE:return Ct(o.value,t);case fe.Scalar.QUOTE_SINGLE:return tn(o.value,t);case fe.Scalar.PLAIN:return Cd(o,t,s,i);default:return null}},c=l(a);if(c===null){let{defaultKeyType:d,defaultStringType:f}=t.options,p=n&&d||f;if(c=l(p),c===null)throw new Error(`Unsupported default string type ${p}`)}return c}ua.stringifyString=Ad});var Pt=P(nn=>{"use strict";var Pd=hs(),xe=F(),Nd=xt(),Id=At();function Ld(e,t){let s=Object.assign({blockQuote:!0,commentString:Nd.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 Rd(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 Od(e,t,{anchors:s,doc:i}){if(!i.directives)return"";let n=[],r=(xe.isScalar(e)||xe.isCollection(e))&&e.anchor;r&&Pd.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 Td(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=Rd(t.doc.schema.tags,r));let o=Od(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)?Id.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}nn.createStringifyContext=Ld;nn.stringify=Td});var ma=P(pa=>{"use strict";var be=F(),fa=V(),da=Pt(),Nt=xt();function Md({key:e,value:t},s,i,n){let{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:d,simpleKeys:f}}=s,p=be.isNode(e)&&e.comment||null;if(f){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 h=!f&&(!e||p&&t==null&&!s.inFlow||be.isCollection(e)||(be.isScalar(e)?e.type===fa.Scalar.BLOCK_FOLDED||e.type===fa.Scalar.BLOCK_LITERAL:typeof e=="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!h&&(f||!r),indent:a+l});let y=!1,m=!1,g=da.stringify(e,s,()=>y=!0,()=>m=!0);if(!h&&!s.inFlow&&g.length>1024){if(f)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");h=!0}if(s.inFlow){if(r||t==null)return y&&i&&i(),g===""?"?":h?`? ${g}`:g}else if(r&&!f||t==null&&h)return g=`? ${g}`,p&&!y?g+=Nt.lineComment(g,s.indent,c(p)):m&&n&&n(),g;y&&(p=null),h?(p&&(g+=Nt.lineComment(g,s.indent,c(p))),g=`? ${g}
|
|
37
|
+
${a}:`):(g=`${g}:`,p&&(g+=Nt.lineComment(g,s.indent,c(p))));let b,v,w;be.isNode(t)?(b=!!t.spaceBefore,v=t.commentBefore,w=t.comment):(b=!1,v=null,w=null,t&&typeof t=="object"&&(t=o.createNode(t))),s.implicitKey=!1,!h&&!p&&be.isScalar(t)&&(s.indentAtStart=g.length+1),m=!1,!d&&l.length>=2&&!s.inFlow&&!h&&be.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(s.indent=s.indent.substring(2));let S=!1,k=da.stringify(t,s,()=>S=!0,()=>m=!0),C=" ";if(p||b||v){if(C=b?`
|
|
38
|
+
`:"",v){let E=c(v);C+=`
|
|
39
|
+
${Nt.indentComment(E,s.indent)}`}k===""&&!s.inFlow?C===`
|
|
40
|
+
`&&w&&(C=`
|
|
41
|
+
|
|
42
|
+
`):C+=`
|
|
43
|
+
${s.indent}`}else if(!h&&be.isCollection(t)){let E=k[0],x=k.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=k.indexOf(" ");E==="&"&&T!==-1&&T<x&&k[T+1]==="!"&&(T=k.indexOf(" ",T+1)),(T===-1||x<T)&&(D=!0)}D||(C=`
|
|
45
45
|
${s.indent}`)}}else(k===""||k[0]===`
|
|
46
|
-
`)&&(
|
|
47
|
-
${l}${
|
|
48
|
-
`}}return e?(
|
|
49
|
-
`+
|
|
50
|
-
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=f.reduce((v,w)=>v+w.length+2,2)+(b.length+2)>t.options.lineWidth)),c&&(b+=",")),g&&(b+=
|
|
51
|
-
${r}${n}${
|
|
46
|
+
`)&&(C="");return g+=C+k,s.inFlow?S&&i&&i():w&&!S?g+=Nt.lineComment(g,s.indent,c(w)):m&&n&&n(),g}pa.stringifyPair=Md});var on=P(rn=>{"use strict";var ha=ss("process");function Dd(e,...t){e==="debug"&&console.log(...t)}function _d(e,t){(e==="debug"||e==="warn")&&(typeof ha.emitWarning=="function"?ha.emitWarning(t):console.warn(t))}rn.debug=Dd;rn.warn=_d});var Ps=P(As=>{"use strict";var It=F(),ga=V(),Es="<<",Cs={identify:e=>e===Es||typeof e=="symbol"&&e.description===Es,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new ga.Scalar(Symbol(Es)),{addToJSMap:ya}),stringify:()=>Es},qd=(e,t)=>(Cs.identify(t)||It.isScalar(t)&&(!t.type||t.type===ga.Scalar.PLAIN)&&Cs.identify(t.value))&&e?.doc.schema.tags.some(s=>s.tag===Cs.tag&&s.default);function ya(e,t,s){if(s=e&&It.isAlias(s)?s.resolve(e.doc):s,It.isSeq(s))for(let i of s.items)an(e,t,i);else if(Array.isArray(s))for(let i of s)an(e,t,i);else an(e,t,s)}function an(e,t,s){let i=e&&It.isAlias(s)?s.resolve(e.doc):s;if(!It.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}As.addMergeToJSMap=ya;As.isMergeKey=qd;As.merge=Cs});var cn=P(va=>{"use strict";var Fd=on(),ba=Ps(),jd=Pt(),wa=F(),ln=ke();function Bd(e,t,{key:s,value:i}){if(wa.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,i);else if(ba.isMergeKey(e,s))ba.addMergeToJSMap(e,t,i);else{let n=ln.toJS(s,"",e);if(t instanceof Map)t.set(n,ln.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let r=Ud(s,n,e),o=ln.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 Ud(e,t,s){if(t===null)return"";if(typeof t!="object")return String(t);if(wa.isNode(e)&&s?.doc){let i=jd.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)+'..."'),Fd.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=Bd});var Ee=P(un=>{"use strict";var ka=$t(),Vd=ma(),Kd=cn(),Ns=F();function Jd(e,t,s){let i=ka.createNode(e,void 0,s),n=ka.createNode(t,void 0,s);return new Is(i,n)}var Is=class e{constructor(t,s=null){Object.defineProperty(this,Ns.NODE_TYPE,{value:Ns.PAIR}),this.key=t,this.value=s}clone(t){let{key:s,value:i}=this;return Ns.isNode(s)&&(s=s.clone(t)),Ns.isNode(i)&&(i=i.clone(t)),new e(s,i)}toJSON(t,s){let i=s?.mapAsMap?new Map:{};return Kd.addPairToJSMap(s,i,this)}toString(t,s,i){return t?.doc?Vd.stringifyPair(this,t,s,i):JSON.stringify(this)}};un.Pair=Is;un.createPair=Jd});var fn=P($a=>{"use strict";var je=F(),Sa=Pt(),Ls=xt();function Hd(e,t,s){return(t.inFlow??e.flow?Wd:Gd)(e,t,s)}function Gd({comment:e,items:t},s,{blockItemPrefix:i,flowChars:n,itemIndent:r,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=s,d=Object.assign({},s,{indent:r,type:null}),f=!1,p=[];for(let y=0;y<t.length;++y){let m=t[y],g=null;if(je.isNode(m))!f&&m.spaceBefore&&p.push(""),Rs(s,p,m.commentBefore,f),m.comment&&(g=m.comment);else if(je.isPair(m)){let v=je.isNode(m.key)?m.key:null;v&&(!f&&v.spaceBefore&&p.push(""),Rs(s,p,v.commentBefore,f))}f=!1;let b=Sa.stringify(m,d,()=>g=null,()=>f=!0);g&&(b+=Ls.lineComment(b,r,c(g))),f&&g&&(f=!1),p.push(i+b)}let h;if(p.length===0)h=n.start+n.end;else{h=p[0];for(let y=1;y<p.length;++y){let m=p[y];h+=m?`
|
|
47
|
+
${l}${m}`:`
|
|
48
|
+
`}}return e?(h+=`
|
|
49
|
+
`+Ls.indentComment(c(e),l),a&&a()):f&&o&&o(),h}function Wd({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,d=0,f=[];for(let y=0;y<e.length;++y){let m=e[y],g=null;if(je.isNode(m))m.spaceBefore&&f.push(""),Rs(t,f,m.commentBefore,!1),m.comment&&(g=m.comment);else if(je.isPair(m)){let v=je.isNode(m.key)?m.key:null;v&&(v.spaceBefore&&f.push(""),Rs(t,f,v.commentBefore,!1),v.comment&&(c=!0));let w=je.isNode(m.value)?m.value:null;w?(w.comment&&(g=w.comment),w.commentBefore&&(c=!0)):m.value==null&&v?.comment&&(g=v.comment)}g&&(c=!0);let b=Sa.stringify(m,l,()=>g=null);c||(c=f.length>d||b.includes(`
|
|
50
|
+
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=f.reduce((v,w)=>v+w.length+2,2)+(b.length+2)>t.options.lineWidth)),c&&(b+=",")),g&&(b+=Ls.lineComment(b,i,a(g))),f.push(b),d=f.length}let{start:p,end:h}=s;if(f.length===0)return p+h;if(!c){let y=f.reduce((m,g)=>m+g.length+2,2);c=t.options.lineWidth>0&&y>t.options.lineWidth}if(c){let y=p;for(let m of f)y+=m?`
|
|
51
|
+
${r}${n}${m}`:`
|
|
52
52
|
`;return`${y}
|
|
53
|
-
${n}${
|
|
54
|
-
`:" ")}return Lp.stringifyString({comment:e,type:t,value:a},i,n,r)}};
|
|
53
|
+
${n}${h}`}else return`${p}${o}${f.join(" ")}${o}${h}`}function Rs({indent:e,options:{commentString:t}},s,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let r=Ls.indentComment(t(i),e);s.push(r.trimStart())}}$a.stringifyCollection=Hd});var Ae=P(pn=>{"use strict";var Yd=fn(),zd=cn(),Qd=ws(),Ce=F(),Os=Ee(),Xd=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 dn=class extends Qd.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(Os.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 Os.Pair(t,t?.value):i=new Os.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)&&Xd.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 Os.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)zd.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})),Yd.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:s})}};pn.YAMLMap=dn;pn.findPair=Lt});var it=P(Ea=>{"use strict";var Zd=F(),xa=Ae(),ep={collection:"map",default:!0,nodeClass:xa.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return Zd.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,s)=>xa.YAMLMap.from(e,t,s)};Ea.map=ep});var Pe=P(Ca=>{"use strict";var tp=$t(),sp=fn(),ip=ws(),Ms=F(),np=V(),rp=ke(),mn=class extends ip.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Ms.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let s=Ts(t);return typeof s!="number"?!1:this.items.splice(s,1).length>0}get(t,s){let i=Ts(t);if(typeof i!="number")return;let n=this.items[i];return!s&&Ms.isScalar(n)?n.value:n}has(t){let s=Ts(t);return typeof s=="number"&&s<this.items.length}set(t,s){let i=Ts(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];Ms.isScalar(n)&&np.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(rp.toJS(r,String(n++),s));return i}toString(t,s,i){return t?sp.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(tp.createNode(a,void 0,i))}}return r}};function Ts(e){let t=Ms.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}Ca.YAMLSeq=mn});var nt=P(Pa=>{"use strict";var op=F(),Aa=Pe(),ap={collection:"seq",default:!0,nodeClass:Aa.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return op.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,s)=>Aa.YAMLSeq.from(e,t,s)};Pa.seq=ap});var Rt=P(Na=>{"use strict";var lp=At(),cp={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),lp.stringifyString(e,t,s,i)}};Na.string=cp});var Ds=P(Ra=>{"use strict";var Ia=V(),La={identify:e=>e==null,createNode:()=>new Ia.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new Ia.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&La.test.test(e)?e:t.options.nullStr};Ra.nullTag=La});var hn=P(Ta=>{"use strict";var up=V(),Oa={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new up.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&Oa.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?s.options.trueStr:s.options.falseStr}};Ta.boolTag=Oa});var rt=P(Ma=>{"use strict";function fp({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}Ma.stringifyNumber=fp});var yn=P(_s=>{"use strict";var dp=V(),gn=rt(),pp={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:gn.stringifyNumber},mp={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():gn.stringifyNumber(e)}},hp={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 dp.Scalar(parseFloat(e)),s=e.indexOf(".");return s!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-s-1),t},stringify:gn.stringifyNumber};_s.float=hp;_s.floatExp=mp;_s.floatNaN=pp});var wn=P(Fs=>{"use strict";var Da=rt(),qs=e=>typeof e=="bigint"||Number.isInteger(e),bn=(e,t,s,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),s);function _a(e,t,s){let{value:i}=e;return qs(i)&&i>=0?s+i.toString(t):Da.stringifyNumber(e)}var gp={identify:e=>qs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>bn(e,2,8,s),stringify:e=>_a(e,8,"0o")},yp={identify:qs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>bn(e,0,10,s),stringify:Da.stringifyNumber},bp={identify:e=>qs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>bn(e,2,16,s),stringify:e=>_a(e,16,"0x")};Fs.int=yp;Fs.intHex=bp;Fs.intOct=gp});var Fa=P(qa=>{"use strict";var wp=it(),vp=Ds(),kp=nt(),Sp=Rt(),$p=hn(),vn=yn(),kn=wn(),xp=[wp.map,kp.seq,Sp.string,vp.nullTag,$p.boolTag,kn.intOct,kn.int,kn.intHex,vn.floatNaN,vn.floatExp,vn.float];qa.schema=xp});var Ua=P(Ba=>{"use strict";var Ep=V(),Cp=it(),Ap=nt();function ja(e){return typeof e=="bigint"||Number.isInteger(e)}var js=({value:e})=>JSON.stringify(e),Pp=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:js},{identify:e=>e==null,createNode:()=>new Ep.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:js},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:js},{identify:ja,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})=>ja(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:js}],Np={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Ip=[Cp.map,Ap.seq].concat(Pp,Np);Ba.schema=Ip});var $n=P(Va=>{"use strict";var Ot=ss("buffer"),Sn=V(),Lp=At(),Rp={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Ot.Buffer=="function")return Ot.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 Ot.Buffer=="function")a=o instanceof Ot.Buffer?o.toString("base64"):Ot.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=Sn.Scalar.BLOCK_LITERAL),t!==Sn.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),d=new Array(c);for(let f=0,p=0;f<c;++f,p+=l)d[f]=a.substr(p,l);a=d.join(t===Sn.Scalar.BLOCK_LITERAL?`
|
|
54
|
+
`:" ")}return Lp.stringifyString({comment:e,type:t,value:a},i,n,r)}};Va.binary=Rp});var Vs=P(Us=>{"use strict";var Bs=F(),xn=Ee(),Op=V(),Tp=Pe();function Ka(e,t){if(Bs.isSeq(e))for(let s=0;s<e.items.length;++s){let i=e.items[s];if(!Bs.isPair(i)){if(Bs.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new xn.Pair(new Op.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]=js.isPair(i)?i:new $n.Pair(i)}}else t("Expected a sequence for this tag");return e}function Ha(e,t,s){let{replacer:i}=s,n=new Tp.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($n.createPair(a,l,s))}return n}var Mp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ja,createNode:Ha};Bs.createPairs=Ha;Bs.pairs=Mp;Bs.resolvePairs=Ja});var Cn=C(En=>{"use strict";var Ga=q(),xn=ke(),Tt=Ae(),Dp=Pe(),Ya=Us(),Be=class e extends Dp.YAMLSeq{constructor(){super(),this.add=Tt.YAMLMap.prototype.add.bind(this),this.delete=Tt.YAMLMap.prototype.delete.bind(this),this.get=Tt.YAMLMap.prototype.get.bind(this),this.has=Tt.YAMLMap.prototype.has.bind(this),this.set=Tt.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(Ga.isPair(n)?(r=xn.toJS(n.key,"",s),o=xn.toJS(n.value,r,s)):r=xn.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=Ya.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var _p={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=Ya.resolvePairs(e,t),i=[];for(let{key:n}of s.items)Ga.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)};En.YAMLOMap=Be;En.omap=_p});var Za=C(An=>{"use strict";var Wa=V();function za({value:e,source:t},s){return t&&(e?Qa:Xa).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var Qa={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 Wa.Scalar(!0),stringify:za},Xa={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 Wa.Scalar(!1),stringify:za};An.falseTag=Xa;An.trueTag=Qa});var el=C(Vs=>{"use strict";var qp=V(),Pn=rt(),Fp={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:Pn.stringifyNumber},jp={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():Pn.stringifyNumber(e)}},Bp={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 qp.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:Pn.stringifyNumber};Vs.float=Bp;Vs.floatExp=jp;Vs.floatNaN=Fp});var sl=C(Dt=>{"use strict";var tl=rt(),Mt=e=>typeof e=="bigint"||Number.isInteger(e);function Ks(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 Nn(e,t,s){let{value:i}=e;if(Mt(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return tl.stringifyNumber(e)}var Up={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Ks(e,2,2,s),stringify:e=>Nn(e,2,"0b")},Vp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Ks(e,1,8,s),stringify:e=>Nn(e,8,"0")},Kp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Ks(e,0,10,s),stringify:tl.stringifyNumber},Jp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Ks(e,2,16,s),stringify:e=>Nn(e,16,"0x")};Dt.int=Kp;Dt.intBin=Up;Dt.intHex=Jp;Dt.intOct=Vp});var Ln=C(In=>{"use strict";var Gs=q(),Js=Ee(),Hs=Ae(),Ue=class e extends Hs.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;Gs.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Js.Pair(t.key,null):s=new Js.Pair(t,null),Hs.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=Hs.findPair(this.items,t);return!s&&Gs.isPair(i)?Gs.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=Hs.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Js.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(Js.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var Hp={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(Gs.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}};In.YAMLSet=Ue;In.set=Hp});var On=C(Ys=>{"use strict";var Gp=rt();function Rn(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 il(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Gp.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 Yp={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})=>Rn(e,s),stringify:il},Wp={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=>Rn(e,!1),stringify:il},nl={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(nl.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,n,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,i-1,n,r||0,o||0,a||0,l),d=t[8];if(d&&d!=="Z"){let f=Rn(d,!1);Math.abs(f)<30&&(f*=60),c-=6e4*f}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Ys.floatTime=Wp;Ys.intTime=Yp;Ys.timestamp=nl});var al=C(ol=>{"use strict";var zp=it(),Qp=Ms(),Xp=nt(),Zp=Rt(),em=Sn(),rl=Za(),Tn=el(),Ws=sl(),tm=As(),sm=Cn(),im=Us(),nm=Ln(),Mn=On(),rm=[zp.map,Xp.seq,Zp.string,Qp.nullTag,rl.trueTag,rl.falseTag,Ws.intBin,Ws.intOct,Ws.int,Ws.intHex,Tn.floatNaN,Tn.floatExp,Tn.float,em.binary,tm.merge,sm.omap,im.pairs,nm.set,Mn.intTime,Mn.floatTime,Mn.timestamp];ol.schema=rm});var yl=C(qn=>{"use strict";var fl=it(),om=Ms(),dl=nt(),am=Rt(),lm=mn(),Dn=gn(),_n=bn(),cm=ja(),um=Va(),pl=Sn(),_t=As(),ml=Cn(),hl=Us(),ll=al(),gl=Ln(),zs=On(),cl=new Map([["core",cm.schema],["failsafe",[fl.map,dl.seq,am.string]],["json",um.schema],["yaml11",ll.schema],["yaml-1.1",ll.schema]]),ul={binary:pl.binary,bool:lm.boolTag,float:Dn.float,floatExp:Dn.floatExp,floatNaN:Dn.floatNaN,floatTime:zs.floatTime,int:_n.int,intHex:_n.intHex,intOct:_n.intOct,intTime:zs.intTime,map:fl.map,merge:_t.merge,null:om.nullTag,omap:ml.omap,pairs:hl.pairs,seq:dl.seq,set:gl.set,timestamp:zs.timestamp},fm={"tag:yaml.org,2002:binary":pl.binary,"tag:yaml.org,2002:merge":_t.merge,"tag:yaml.org,2002:omap":ml.omap,"tag:yaml.org,2002:pairs":hl.pairs,"tag:yaml.org,2002:set":gl.set,"tag:yaml.org,2002:timestamp":zs.timestamp};function dm(e,t,s){let i=cl.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(cl.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"?ul[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(ul).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}qn.coreKnownTags=fm;qn.getTags=dm});var Bn=C(bl=>{"use strict";var Fn=q(),pm=it(),mm=nt(),hm=Rt(),Qs=yl(),gm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,jn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?Qs.getTags(t,"compat"):t?Qs.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?Qs.coreKnownTags:{},this.tags=Qs.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Fn.MAP,{value:pm.map}),Object.defineProperty(this,Fn.SCALAR,{value:hm.string}),Object.defineProperty(this,Fn.SEQ,{value:mm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?gm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};bl.Schema=jn});var vl=C(wl=>{"use strict";var ym=q(),Un=Pt(),qt=xt();function bm(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=Un.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(ym.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let d=r(e.contents.commentBefore);s.push(qt.indentComment(d,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Un.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(Un.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
56
|
+
${r.comment}`:i.comment}i=n}e.items[s]=Bs.isPair(i)?i:new xn.Pair(i)}}else t("Expected a sequence for this tag");return e}function Ja(e,t,s){let{replacer:i}=s,n=new Tp.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(xn.createPair(a,l,s))}return n}var Mp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ka,createNode:Ja};Us.createPairs=Ja;Us.pairs=Mp;Us.resolvePairs=Ka});var An=P(Cn=>{"use strict";var Ha=F(),En=ke(),Tt=Ae(),Dp=Pe(),Ga=Vs(),Be=class e extends Dp.YAMLSeq{constructor(){super(),this.add=Tt.YAMLMap.prototype.add.bind(this),this.delete=Tt.YAMLMap.prototype.delete.bind(this),this.get=Tt.YAMLMap.prototype.get.bind(this),this.has=Tt.YAMLMap.prototype.has.bind(this),this.set=Tt.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(Ha.isPair(n)?(r=En.toJS(n.key,"",s),o=En.toJS(n.value,r,s)):r=En.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=Ga.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var _p={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=Ga.resolvePairs(e,t),i=[];for(let{key:n}of s.items)Ha.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)};Cn.YAMLOMap=Be;Cn.omap=_p});var Xa=P(Pn=>{"use strict";var Wa=V();function Ya({value:e,source:t},s){return t&&(e?za:Qa).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var za={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 Wa.Scalar(!0),stringify:Ya},Qa={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 Wa.Scalar(!1),stringify:Ya};Pn.falseTag=Qa;Pn.trueTag=za});var Za=P(Ks=>{"use strict";var qp=V(),Nn=rt(),Fp={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:Nn.stringifyNumber},jp={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():Nn.stringifyNumber(e)}},Bp={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 qp.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:Nn.stringifyNumber};Ks.float=Bp;Ks.floatExp=jp;Ks.floatNaN=Fp});var tl=P(Dt=>{"use strict";var el=rt(),Mt=e=>typeof e=="bigint"||Number.isInteger(e);function Js(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 In(e,t,s){let{value:i}=e;if(Mt(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return el.stringifyNumber(e)}var Up={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Js(e,2,2,s),stringify:e=>In(e,2,"0b")},Vp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Js(e,1,8,s),stringify:e=>In(e,8,"0")},Kp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Js(e,0,10,s),stringify:el.stringifyNumber},Jp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Js(e,2,16,s),stringify:e=>In(e,16,"0x")};Dt.int=Kp;Dt.intBin=Up;Dt.intHex=Jp;Dt.intOct=Vp});var Rn=P(Ln=>{"use strict";var Ws=F(),Hs=Ee(),Gs=Ae(),Ue=class e extends Gs.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;Ws.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Hs.Pair(t.key,null):s=new Hs.Pair(t,null),Gs.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=Gs.findPair(this.items,t);return!s&&Ws.isPair(i)?Ws.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=Gs.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Hs.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(Hs.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var Hp={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(Ws.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}};Ln.YAMLSet=Ue;Ln.set=Hp});var Tn=P(Ys=>{"use strict";var Gp=rt();function On(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 sl(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Gp.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 Wp={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})=>On(e,s),stringify:sl},Yp={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=>On(e,!1),stringify:sl},il={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(il.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),d=t[8];if(d&&d!=="Z"){let f=On(d,!1);Math.abs(f)<30&&(f*=60),c-=6e4*f}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Ys.floatTime=Yp;Ys.intTime=Wp;Ys.timestamp=il});var ol=P(rl=>{"use strict";var zp=it(),Qp=Ds(),Xp=nt(),Zp=Rt(),em=$n(),nl=Xa(),Mn=Za(),zs=tl(),tm=Ps(),sm=An(),im=Vs(),nm=Rn(),Dn=Tn(),rm=[zp.map,Xp.seq,Zp.string,Qp.nullTag,nl.trueTag,nl.falseTag,zs.intBin,zs.intOct,zs.int,zs.intHex,Mn.floatNaN,Mn.floatExp,Mn.float,em.binary,tm.merge,sm.omap,im.pairs,nm.set,Dn.intTime,Dn.floatTime,Dn.timestamp];rl.schema=rm});var gl=P(Fn=>{"use strict";var ul=it(),om=Ds(),fl=nt(),am=Rt(),lm=hn(),_n=yn(),qn=wn(),cm=Fa(),um=Ua(),dl=$n(),_t=Ps(),pl=An(),ml=Vs(),al=ol(),hl=Rn(),Qs=Tn(),ll=new Map([["core",cm.schema],["failsafe",[ul.map,fl.seq,am.string]],["json",um.schema],["yaml11",al.schema],["yaml-1.1",al.schema]]),cl={binary:dl.binary,bool:lm.boolTag,float:_n.float,floatExp:_n.floatExp,floatNaN:_n.floatNaN,floatTime:Qs.floatTime,int:qn.int,intHex:qn.intHex,intOct:qn.intOct,intTime:Qs.intTime,map:ul.map,merge:_t.merge,null:om.nullTag,omap:pl.omap,pairs:ml.pairs,seq:fl.seq,set:hl.set,timestamp:Qs.timestamp},fm={"tag:yaml.org,2002:binary":dl.binary,"tag:yaml.org,2002:merge":_t.merge,"tag:yaml.org,2002:omap":pl.omap,"tag:yaml.org,2002:pairs":ml.pairs,"tag:yaml.org,2002:set":hl.set,"tag:yaml.org,2002:timestamp":Qs.timestamp};function dm(e,t,s){let i=ll.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(ll.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"?cl[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(cl).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Fn.coreKnownTags=fm;Fn.getTags=dm});var Un=P(yl=>{"use strict";var jn=F(),pm=it(),mm=nt(),hm=Rt(),Xs=gl(),gm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Bn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?Xs.getTags(t,"compat"):t?Xs.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?Xs.coreKnownTags:{},this.tags=Xs.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,jn.MAP,{value:pm.map}),Object.defineProperty(this,jn.SCALAR,{value:hm.string}),Object.defineProperty(this,jn.SEQ,{value:mm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?gm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};yl.Schema=Bn});var wl=P(bl=>{"use strict";var ym=F(),Vn=Pt(),qt=xt();function bm(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=Vn.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(ym.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let d=r(e.contents.commentBefore);s.push(qt.indentComment(d,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Vn.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(Vn.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
57
57
|
`)?(s.push("..."),s.push(qt.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(qt.indentComment(r(l),"")))}return s.join(`
|
|
58
58
|
`)+`
|
|
59
|
-
`}
|
|
59
|
+
`}bl.stringifyDocument=bm});var Ft=P(vl=>{"use strict";var wm=St(),ot=ws(),ae=F(),vm=Ee(),km=ke(),Sm=Un(),$m=wl(),Kn=hs(),xm=Gi(),Em=$t(),Jn=Hi(),Hn=class e{constructor(t,s,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ae.NODE_TYPE,{value:ae.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 Jn.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,{[ae.NODE_TYPE]:{value:ae.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=ae.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=Kn.anchorNames(this);t.anchor=!s||i.has(s)?Kn.findNewAnchor(s||"a",i):s}return new wm.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=v=>typeof v=="number"||v instanceof String||v 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:d}=i??{},{onAnchor:f,setAnchors:p,sourceObjects:h}=Kn.createNodeAnchors(this,o||"a"),y={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:f,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:h},m=Em.createNode(t,d,y);return a&&ae.isCollection(m)&&(m.flow=!0),p(),m}createPair(t,s,i={}){let n=this.createNode(t,null,i),r=this.createNode(s,null,i);return new vm.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 ae.isCollection(this.contents)?this.contents.get(t,s):void 0}getIn(t,s){return ot.isEmptyPath(t)?!s&&ae.isScalar(this.contents)?this.contents.value:this.contents:ae.isCollection(this.contents)?this.contents.getIn(t,s):void 0}has(t){return ae.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return ot.isEmptyPath(t)?this.contents!==void 0:ae.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 Jn.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 Jn.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 Sm.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=km.toJS(this.contents,s??"",a);if(typeof r=="function")for(let{count:c,res:d}of a.anchors.values())r(d,c);return typeof o=="function"?xm.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 $m.stringifyDocument(this,t)}};function at(e){if(ae.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}vl.Document=Hn});var Ut=P(Bt=>{"use strict";var jt=class extends Error{constructor(t,s,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=s}},Gn=class extends jt{constructor(t,s,i){super("YAMLParseError",t,s,i)}},Wn=class extends jt{constructor(t,s,i){super("YAMLWarning",t,s,i)}},Cm=(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
|
-
`}};Bt.YAMLError=jt;Bt.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(Yn(t.key)||Yn(t.value))return!0}return!1;default:return!0}}
|
|
66
|
-
`+
|
|
67
|
-
`+w.comment:v.comment=w.comment);let S=new
|
|
68
|
-
`+
|
|
69
|
-
`+x
|
|
70
|
-
`+
|
|
71
|
-
`+g.comment:c.comment=g.comment),c.range=[i.offset,
|
|
72
|
-
`.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return t.source&&(g+=t.source.length),{value:
|
|
73
|
-
`;for(let
|
|
64
|
+
`}};Bt.YAMLError=jt;Bt.YAMLParseError=Gn;Bt.YAMLWarning=Wn;Bt.prettifyError=Cm});var Vt=P(kl=>{"use strict";function Am(e,{flow:t,indicator:s,next:i,offset:n,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,d=a,f="",p="",h=!1,y=!1,m=null,g=null,b=null,v=null,w=null,S=null,k=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),m&&(c&&x.type!=="comment"&&x.type!=="newline"&&r(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),m=null),x.type){case"space":!t&&(s!=="doc-start"||i?.type!=="flow-collection")&&x.source.includes(" ")&&(m=x),d=!0;break;case"comment":{d||r(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let M=x.source.substring(1)||" ";f?f+=p+M:f=M,p="",c=!1;break}case"newline":c?f?f+=x.source:(!S||s!=="seq-item-ind")&&(l=!0):p+=x.source,c=!0,h=!0,(g||b)&&(v=x),d=!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,k??(k=x.offset),c=!1,d=!1,y=!0;break;case"tag":{b&&r(x,"MULTIPLE_TAGS","A node can have at most one tag"),b=x,k??(k=x.offset),c=!1,d=!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",d=!1;break;case"comma":if(t){w&&r(x,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),w=x,c=!1,d=!1;break}default:r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),c=!1,d=!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"),m&&(c&&m.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&r(m,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:w,found:S,spaceBefore:l,comment:f,hasNewline:h,anchor:g,tag:b,newlineAfterProp:v,end:E,start:k??E}}kl.resolveProps=Am});var Zs=P(Sl=>{"use strict";function Yn(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(Yn(t.key)||Yn(t.value))return!0}return!1;default:return!0}}Sl.containsNewline=Yn});var zn=P($l=>{"use strict";var Pm=Zs();function Nm(e,t,s){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&Pm.containsNewline(t)&&s(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}$l.flowIndentCheck=Nm});var Qn=P(El=>{"use strict";var xl=F();function Im(e,t,s){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(r,o)=>r===o||xl.isScalar(r)&&xl.isScalar(o)&&r.value===o.value;return t.some(r=>n(r.key,s))}El.mapIncludes=Im});var Ll=P(Il=>{"use strict";var Cl=Ee(),Lm=Ae(),Al=Vt(),Rm=Zs(),Pl=zn(),Om=Qn(),Nl="All mapping items must start at the same column";function Tm({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??Lm.YAMLMap,a=new o(s.schema);s.atRoot&&(s.atRoot=!1);let l=i.offset,c=null;for(let d of i.items){let{start:f,key:p,sep:h,value:y}=d,m=Al.resolveProps(f,{indicator:"explicit-key-ind",next:p??h?.[0],offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0}),g=!m.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",Nl)),!m.anchor&&!m.tag&&!h){c=m.end,m.comment&&(a.comment?a.comment+=`
|
|
66
|
+
`+m.comment:a.comment=m.comment);continue}(m.newlineAfterProp||Rm.containsNewline(p))&&n(p??f[f.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else m.found?.indent!==i.indent&&n(l,"BAD_INDENT",Nl);s.atKey=!0;let b=m.end,v=p?e(s,p,m,n):t(s,b,f,null,m,n);s.schema.compat&&Pl.flowIndentCheck(i.indent,p,n),s.atKey=!1,Om.mapIncludes(s,a.items,v)&&n(b,"DUPLICATE_KEY","Map keys must be unique");let w=Al.resolveProps(h??[],{indicator:"map-value-ind",next:y,offset:v.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(l=w.end,w.found){g&&(y?.type==="block-map"&&!w.hasNewline&&n(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),s.options.strict&&m.start<w.found.offset-1024&&n(v.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,w,n):t(s,l,h,null,w,n);s.schema.compat&&Pl.flowIndentCheck(i.indent,y,n),l=S.range[2];let k=new Cl.Pair(v,S);s.options.keepSourceTokens&&(k.srcToken=d),a.items.push(k)}else{g&&n(v.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),w.comment&&(v.comment?v.comment+=`
|
|
67
|
+
`+w.comment:v.comment=w.comment);let S=new Cl.Pair(v);s.options.keepSourceTokens&&(S.srcToken=d),a.items.push(S)}}return c&&c<l&&n(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[i.offset,l,c??l],a}Il.resolveBlockMap=Tm});var Ol=P(Rl=>{"use strict";var Mm=Pe(),Dm=Vt(),_m=zn();function qm({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??Mm.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:d,value:f}of i.items){let p=Dm.resolveProps(d,{indicator:"seq-item-ind",next:f,offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||f)f?.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 h=f?e(s,f,p,n):t(s,p.end,d,null,p,n);s.schema.compat&&_m.flowIndentCheck(i.indent,f,n),l=h.range[2],a.items.push(h)}return a.range=[i.offset,l,c??l],a}Rl.resolveBlockSeq=qm});var lt=P(Tl=>{"use strict";function Fm(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 d=l.substring(1)||" ";n?n+=o+d:n=d,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}}Tl.resolveEnd=Fm});var ql=P(_l=>{"use strict";var jm=F(),Bm=Ee(),Ml=Ae(),Um=Pe(),Vm=lt(),Dl=Vt(),Km=Zs(),Jm=Qn(),Xn="Block collections are not allowed within flow collections",Zn=e=>e&&(e.type==="block-map"||e.type==="block-seq");function Hm({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=i.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?Ml.YAMLMap:Um.YAMLSeq),c=new l(s.schema);c.flow=!0;let d=s.atRoot;d&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let f=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let b=i.items[g],{start:v,key:w,sep:S,value:k}=b,C=Dl.resolveProps(v,{flow:a,indicator:"explicit-key-ind",next:w??S?.[0],offset:f,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!S&&!k){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),f=C.end;continue}!o&&s.options.strict&&Km.containsNewline(w)&&n(w,"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 v)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];jm.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=k?e(s,k,C,n):t(s,C.end,S,null,C,n);c.items.push(E),f=E.range[2],Zn(k)&&n(E.range,"BLOCK_IN_FLOW",Xn)}else{s.atKey=!0;let E=C.end,x=w?e(s,w,C,n):t(s,E,v,null,C,n);Zn(w)&&n(x.range,"BLOCK_IN_FLOW",Xn),s.atKey=!1;let M=Dl.resolveProps(S??[],{flow:a,indicator:"map-value-ind",next:k,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 k&&("source"in k&&k.source?.[0]===":"?n(k,"MISSING_CHAR",`Missing space after : in ${a}`):n(M.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let O=k?e(s,k,M,n):M.found?t(s,M.end,S,null,M,n):null;O?Zn(k)&&n(O.range,"BLOCK_IN_FLOW",Xn):M.comment&&(x.comment?x.comment+=`
|
|
70
|
+
`+M.comment:x.comment=M.comment);let D=new Bm.Pair(x,O);if(s.options.keepSourceTokens&&(D.srcToken=b),o){let T=c;Jm.mapIncludes(s,T.items,x)&&n(E,"DUPLICATE_KEY","Map keys must be unique"),T.items.push(D)}else{let T=new Ml.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)}f=O?O.range[2]:M.end}}let p=o?"}":"]",[h,...y]=i.end,m=f;if(h?.source===p)m=h.offset+h.source.length;else{let g=a[0].toUpperCase()+a.substring(1),b=d?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;n(f,d?"MISSING_CHAR":"BAD_INDENT",b),h&&h.source.length!==1&&y.unshift(h)}if(y.length>0){let g=Vm.resolveEnd(y,m,s.options.strict,n);g.comment&&(c.comment?c.comment+=`
|
|
71
|
+
`+g.comment:c.comment=g.comment),c.range=[i.offset,m,g.offset]}else c.range=[i.offset,m,m];return c}_l.resolveFlowCollection=Hm});var jl=P(Fl=>{"use strict";var Gm=F(),Wm=V(),Ym=Ae(),zm=Pe(),Qm=Ll(),Xm=Ol(),Zm=ql();function er(e,t,s,i,n,r){let o=s.type==="block-map"?Qm.resolveBlockMap(e,t,s,i,r):s.type==="block-seq"?Xm.resolveBlockSeq(e,t,s,i,r):Zm.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 eh(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:h}=i,y=p&&r?p.offset>r.offset?p:r:p??r;y&&(!h||h.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===Ym.YAMLMap.tagName&&a==="map"||o===zm.YAMLSeq.tagName&&a==="seq")return er(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),er(e,t,s,n,o)}let c=er(e,t,s,n,o,l),d=l.resolve?.(c,p=>n(r,"TAG_RESOLVE_FAILED",p),t.options)??c,f=Gm.isNode(d)?d:new Wm.Scalar(d);return f.range=c.range,f.tag=o,l?.format&&(f.format=l.format),f}Fl.composeCollection=eh});var sr=P(Bl=>{"use strict";var tr=V();function th(e,t,s){let i=t.offset,n=sh(t,e.options.strict,s);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let r=n.mode===">"?tr.Scalar.BLOCK_FOLDED:tr.Scalar.BLOCK_LITERAL,o=t.source?ih(t.source):[],a=o.length;for(let m=o.length-1;m>=0;--m){let g=o[m][1];if(g===""||g==="\r")a=m;else break}if(a===0){let m=n.chomp==="+"&&o.length>0?`
|
|
72
|
+
`.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return t.source&&(g+=t.source.length),{value:m,type:r,comment:n.comment,range:[i,g,g]}}let l=t.indent+n.indent,c=t.offset+n.length,d=0;for(let m=0;m<a;++m){let[g,b]=o[m];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),d=m,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 m=o.length-1;m>=a;--m)o[m][0].length>l&&(a=m+1);let f="",p="",h=!1;for(let m=0;m<d;++m)f+=o[m][0].slice(l)+`
|
|
73
|
+
`;for(let m=d;m<a;++m){let[g,b]=o[m];c+=g.length+b.length+1;let v=b[b.length-1]==="\r";if(v&&(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-(v?2:1),"BAD_INDENT",S),g=""}r===tr.Scalar.BLOCK_LITERAL?(f+=p+g.slice(l)+b,p=`
|
|
74
74
|
`):g.length>l||b[0]===" "?(p===" "?p=`
|
|
75
|
-
`:!
|
|
75
|
+
`:!h&&p===`
|
|
76
76
|
`&&(p=`
|
|
77
77
|
|
|
78
78
|
`),f+=p+g.slice(l)+b,p=`
|
|
79
|
-
`,
|
|
79
|
+
`,h=!0):b===""?p===`
|
|
80
80
|
`?f+=`
|
|
81
81
|
`:p=`
|
|
82
|
-
`:(f+=p+b,p=" ",
|
|
83
|
-
`+o[
|
|
82
|
+
`:(f+=p+b,p=" ",h=!1)}switch(n.chomp){case"-":break;case"+":for(let m=a;m<o.length;++m)f+=`
|
|
83
|
+
`+o[m][0].slice(l);f[f.length-1]!==`
|
|
84
84
|
`&&(f+=`
|
|
85
85
|
`);break;default:f+=`
|
|
86
|
-
`}let y=i+n.length+t.source.length;return{value:f,type:r,comment:n.comment,range:[i,y,y]}}function sh({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
|
|
86
|
+
`}let y=i+n.length+t.source.length;return{value:f,type:r,comment:n.comment,range:[i,y,y]}}function sh({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 h=n[p];if(!a&&(h==="-"||h==="+"))a=h;else{let y=Number(h);!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,d="",f=n.length;for(let p=1;p<t.length;++p){let h=t[p];switch(h.type){case"space":c=!0;case"newline":f+=h.source.length;break;case"comment":s&&!c&&i(h,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),f+=h.source.length,d=h.source.substring(1);break;case"error":i(h,"UNEXPECTED_TOKEN",h.message),f+=h.source.length;break;default:{let y=`Unexpected token in block scalar header: ${h.type}`;i(h,"UNEXPECTED_TOKEN",y);let m=h.source;m&&typeof m=="string"&&(f+=m.length)}}}return{mode:r,indent:o,chomp:a,comment:d,length:f}}function ih(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}Bl.resolveBlockScalar=th});var nr=P(Vl=>{"use strict";var ir=V(),nh=lt();function rh(e,t,s){let{offset:i,type:n,source:r,end:o}=e,a,l,c=(p,h,y)=>s(i+p,h,y);switch(n){case"scalar":a=ir.Scalar.PLAIN,l=oh(r,c);break;case"single-quoted-scalar":a=ir.Scalar.QUOTE_SINGLE,l=ah(r,c);break;case"double-quoted-scalar":a=ir.Scalar.QUOTE_DOUBLE,l=lh(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 d=i+r.length,f=nh.resolveEnd(o,d,t,s);return{value:l,type:a,comment:f.comment,range:[i,d,f.offset]}}function oh(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}`),Ul(e)}function ah(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),Ul(e.slice(1,-1)).replace(/''/g,"'")}function Ul(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=`
|
|
@@ -98,68 +98,68 @@ ${c}
|
|
|
98
98
|
`);)i===`
|
|
99
99
|
`&&(s+=`
|
|
100
100
|
`),t+=1,i=e[t+1];return s||(s=" "),{fold:s,offset:t}}var uh={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 fh(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)}
|
|
101
|
+
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function fh(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)}Vl.resolveFlowScalar=rh});var Hl=P(Jl=>{"use strict";var Ve=F(),Kl=V(),dh=sr(),ph=nr();function mh(e,t,s,i){let{value:n,type:r,comment:o,range:a}=t.type==="block-scalar"?dh.resolveBlockScalar(e,t,i):ph.resolveFlowScalar(t,e.options.strict,i),l=s?e.directives.tagName(s.source,f=>i(s,"TAG_RESOLVE_FAILED",f)):null,c;e.options.stringKeys&&e.atKey?c=e.schema[Ve.SCALAR]:l?c=hh(e.schema,n,l,s,i):t.type==="scalar"?c=gh(e,n,t,i):c=e.schema[Ve.SCALAR];let d;try{let f=c.resolve(n,p=>i(s??t,"TAG_RESOLVE_FAILED",p),e.options);d=Ve.isScalar(f)?f:new Kl.Scalar(f)}catch(f){let p=f instanceof Error?f.message:String(f);i(s??t,"TAG_RESOLVE_FAILED",p),d=new Kl.Scalar(n)}return d.range=a,d.source=n,r&&(d.type=r),l&&(d.tag=l),c.format&&(d.format=c.format),o&&(d.comment=o),d}function hh(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 gh({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),d=`Value may be parsed as either ${l} or ${c}`;r(n,"TAG_RESOLVE_FAILED",d,!0)}}return o}Jl.composeScalar=mh});var Wl=P(Gl=>{"use strict";function yh(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}Gl.emptyScalarPosition=yh});var Ql=P(or=>{"use strict";var bh=St(),wh=F(),vh=jl(),Yl=Hl(),kh=lt(),Sh=Wl(),$h={composeNode:zl,composeEmptyNode:rr};function zl(e,t,s,i){let n=e.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=s,c,d=!0;switch(t.type){case"alias":c=xh(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=Yl.composeScalar(e,t,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=vh.composeCollection($h,e,t,s,i),a&&(c.anchor=a.source.substring(1))}catch(f){let p=f instanceof Error?f.message:String(f);i(t,"RESOURCE_EXHAUSTION",p)}break;default:{let f=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",f),d=!1}}return c??(c=rr(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&&(!wh.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&&d&&(c.srcToken=t),c}function rr(e,t,s,i,{spaceBefore:n,comment:r,anchor:o,tag:a,end:l},c){let d={type:"scalar",offset:Sh.emptyScalarPosition(t,s,i),indent:-1,source:""},f=Yl.composeScalar(e,d,a,c);return o&&(f.anchor=o.source.substring(1),f.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(f.spaceBefore=!0),r&&(f.comment=r,f.range[2]=l),f}function xh({options:e},{offset:t,source:s,end:i},n){let r=new bh.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=kh.resolveEnd(i,o,e.strict,n);return r.range=[t,o,a.offset],a.comment&&(r.comment=a.comment),r}or.composeEmptyNode=rr;or.composeNode=zl});var ec=P(Zl=>{"use strict";var Eh=Ft(),Xl=Ql(),Ch=lt(),Ah=Vt();function Ph(e,t,{offset:s,start:i,value:n,end:r},o){let a=Object.assign({_directives:t},e),l=new Eh.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},d=Ah.resolveProps(i,{indicator:"doc-start",next:n??r?.[0],offset:s,onError:o,parentIndent:0,startOnNewline:!0});d.found&&(l.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!d.hasNewline&&o(d.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=n?Xl.composeNode(c,n,d,o):Xl.composeEmptyNode(c,d.end,i,null,d,o);let f=l.contents.range[2],p=Ch.resolveEnd(r,f,!1,o);return p.comment&&(l.comment=p.comment),l.range=[s,f,p.offset],l}Zl.composeDoc=Ph});var lr=P(ic=>{"use strict";var Nh=ss("process"),Ih=Hi(),Lh=Ft(),Kt=Ut(),tc=F(),Rh=ec(),Oh=lt();function Jt(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 sc(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 ar=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(s,i,n,r)=>{let o=Jt(s);r?this.warnings.push(new Kt.YAMLWarning(o,i,n)):this.errors.push(new Kt.YAMLParseError(o,i,n))},this.directives=new Ih.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,s){let{comment:i,afterEmptyLine:n}=sc(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(tc.isCollection(r)&&!r.flow&&r.items.length>0){let o=r.items[0];tc.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 Kt.YAMLParseError(Jt(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 Lh.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}}};
|
|
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:sc(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(Nh.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(s,i,n)=>{let r=Jt(t);r[0]+=s,this.onError(r,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let s=Rh.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 Kt.YAMLParseError(Jt(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 Kt.YAMLParseError(Jt(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let s=Oh.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 Kt.YAMLParseError(Jt(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 Lh.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}}};ic.Composer=ar});var oc=P(ei=>{"use strict";var Th=sr(),Mh=nr(),Dh=Ut(),nc=At();function _h(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 Dh.YAMLParseError([a,a+1],r,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Mh.resolveFlowScalar(e,t,i);case"block-scalar":return Th.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function qh(e,t){let{implicitKey:s=!1,indent:i,inFlow:n=!1,offset:r=-1,type:o="PLAIN"}=t,a=nc.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
|
`),d=a.substring(0,c),f=a.substring(c+1)+`
|
|
111
|
-
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:d}];return
|
|
112
|
-
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:f}}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 Fh(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=
|
|
111
|
+
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:d}];return rc(p,l)||p.push({type:"newline",offset:-1,indent:i,source:`
|
|
112
|
+
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:f}}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 Fh(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=nc.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">":jh(e,l);break;case'"':cr(e,l,"double-quoted-scalar");break;case"'":cr(e,l,"single-quoted-scalar");break;default:cr(e,l,"scalar")}}function jh(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}];rc(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 rc(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 cr(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})}}}ei.createScalarToken=qh;ei.resolveAsScalar=_h;ei.setScalarValue=Fh});var lc=P(ac=>{"use strict";var Bh=e=>"type"in e?si(e):ti(e);function si(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=si(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=ti(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=ti(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=ti(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 ti({start:e,key:t,sep:s,value:i}){let n="";for(let r of e)n+=r.source;if(t&&(n+=si(t)),s)for(let r of s)n+=r.source;return i&&(n+=si(i)),n}ac.stringify=Bh});var dc=P(fc=>{"use strict";var ur=Symbol("break visit"),Uh=Symbol("skip children"),cc=Symbol("remove item");function Ke(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),uc(Object.freeze([]),e,t)}Ke.BREAK=ur;Ke.SKIP=Uh;Ke.REMOVE=cc;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 uc(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=uc(Object.freeze(e.concat([[n,o]])),r.items[o],s);if(typeof a=="number")o=a-1;else{if(a===ur)return ur;a===cc&&(r.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}fc.visit=Ke});var ii=P(se=>{"use strict";var fr=oc(),Vh=lc(),Kh=dc(),dr="\uFEFF",pr="",mr="",hr="",Jh=e=>!!e&&"items"in e,Hh=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function Gh(e){switch(e){case dr:return"<BOM>";case pr:return"<DOC>";case mr:return"<FLOW_END>";case hr:return"<SCALAR>";default:return JSON.stringify(e)}}function Wh(e){switch(e){case dr:return"byte-order-mark";case pr:return"doc-mode";case mr:return"flow-error-end";case hr: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}se.createScalarToken=
|
|
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}se.createScalarToken=fr.createScalarToken;se.resolveAsScalar=fr.resolveAsScalar;se.setScalarValue=fr.setScalarValue;se.stringify=Vh.stringify;se.visit=Kh.visit;se.BOM=dr;se.DOCUMENT=pr;se.FLOW_END=mr;se.SCALAR=hr;se.isCollection=Jh;se.isScalar=Hh;se.prettyToken=Gh;se.tokenType=Wh});var br=P(mc=>{"use strict";var Ht=ii();function de(e){switch(e){case void 0:case" ":case`
|
|
119
|
+
`:case"\r":case" ":return!0;default:return!1}}var pc=new Set("0123456789ABCDEFabcdef"),Yh=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ni=new Set(",[]{}"),zh=new Set(` ,[]{}
|
|
120
|
+
\r `),gr=e=>!e||zh.has(e),yr=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==="...")&&de(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]===Ht.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 Ht.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==="...")&&de(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&&!de(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===":")&&de(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]===Ht.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 Ht.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==="...")&&de(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&&!de(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===":")&&de(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(gr),"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("..."))&&de(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Ht.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(gr),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||de(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=>de(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 Ht.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(de(r)||t&&
|
|
132
|
+
`&&r>=this.pos&&r+1+s>a)t=r;else break}while(!0);return yield Ht.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(de(r)||t&&ni.has(r))break;s=i}else if(de(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&&ni.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&&ni.has(n))break;s=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Ht.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(gr))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(de(s)||t&&ni.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(;!de(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(Yh.has(s))s=this.buffer[++t];else if(s==="%"&&pc.has(this.buffer[t+1])&&pc.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)}};mc.Lexer=yr});var vr=P(hc=>{"use strict";var wr=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}}}};hc.LineCounter=wr});var Sr=P(vc=>{"use strict";var Qh=ss("process"),gc=ii(),Xh=br();function Ne(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function yc(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 wc(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 ri(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,wc(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 kr=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 Xh.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,Qh.env.LOG_TOKENS&&console.log("|",gc.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let s=gc.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&&yc(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":{yc(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=ri(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(wc(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=ri(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
|
-
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var
|
|
143
|
-
`;n.write(f),a=d}return l(),new Promise(c=>{let d="",f=null;function p(){r.removeListener("data",
|
|
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=ri(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=ri(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=kr});var Ec=P(Wt=>{"use strict";var kc=lr(),Zh=Ft(),Gt=Ut(),eg=on(),tg=F(),sg=vr(),Sc=Sr();function $c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new sg.LineCounter||null,prettyErrors:t}}function ig(e,t={}){let{lineCounter:s,prettyErrors:i}=$c(t),n=new Sc.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 xc(e,t={}){let{lineCounter:s,prettyErrors:i}=$c(t),n=new Sc.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 ng(e,t,s){let i;typeof t=="function"?i=t:s===void 0&&t&&typeof t=="object"&&(s=t);let n=xc(e,s);if(!n)return null;if(n.warnings.forEach(r=>eg.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 rg(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 tg.isDocument(e)&&!i?e.toString(s):new Zh.Document(e,i,s).toString(s)}Wt.parse=ng;Wt.parseAllDocuments=ig;Wt.parseDocument=xc;Wt.stringify=rg});var xr=P(j=>{"use strict";var og=lr(),ag=Ft(),lg=Un(),$r=Ut(),cg=St(),Ie=F(),ug=Ee(),fg=V(),dg=Ae(),pg=Pe(),mg=ii(),hg=br(),gg=vr(),yg=Sr(),oi=Ec(),Cc=bt();j.Composer=og.Composer;j.Document=ag.Document;j.Schema=lg.Schema;j.YAMLError=$r.YAMLError;j.YAMLParseError=$r.YAMLParseError;j.YAMLWarning=$r.YAMLWarning;j.Alias=cg.Alias;j.isAlias=Ie.isAlias;j.isCollection=Ie.isCollection;j.isDocument=Ie.isDocument;j.isMap=Ie.isMap;j.isNode=Ie.isNode;j.isPair=Ie.isPair;j.isScalar=Ie.isScalar;j.isSeq=Ie.isSeq;j.Pair=ug.Pair;j.Scalar=fg.Scalar;j.YAMLMap=dg.YAMLMap;j.YAMLSeq=pg.YAMLSeq;j.CST=mg;j.Lexer=hg.Lexer;j.LineCounter=gg.LineCounter;j.Parser=yg.Parser;j.parse=oi.parse;j.parseAllDocuments=oi.parseAllDocuments;j.parseDocument=oi.parseDocument;j.stringify=oi.stringify;j.visit=Cc.visit;j.visitAsync=Cc.visitAsync});import{execFile as Pf}from"child_process";import{promisify as Nf}from"util";import{mkdtemp as Ao,readdir as If,readFile as ji,rm as as,cp as Lf,access as qi,stat as Lo,lstat as Rf,symlink as Of,mkdir as Tf}from"fs/promises";import{join as ge,resolve as Fi,relative as Mf,basename as Df}from"path";import{homedir as Po}from"os";import{tmpdir as No}from"os";import{readdir as kf,readFile as Sf,stat as $f}from"fs/promises";import{join as xf}from"path";var Ef=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"]),Cf=512*1024;async function rs(e){let t=[];async function s(i,n){let r;try{r=await kf(i)}catch{return}for(let o of r){if(o===".git"||o==="node_modules")continue;let a=xf(i,o),l=n?`${n}/${o}`:o;try{let c=await $f(a);if(c.isDirectory())await s(a,l);else if(c.isFile()){let d=o.includes(".")?`.${o.split(".").pop().toLowerCase()}`:"";if(Ef.has(d)||c.size>Cf)continue;try{let f=await Sf(a,"utf-8");t.push({relPath:l,content:f,lineCount:f.split(`
|
|
142
|
+
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var Di=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 Af(e,t,s){let i=[];if(e.searchActive||e.filter!==""){let c=u.cyan("/"),d=e.filter,f=e.searchActive?u.cyan("\u2588"):"";i.push(` ${c}${d}${f}`),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 f=c===e.cursor?u.cyan(">"):" ";if(c===0){let p=e.filteredMap,y=p.length>0&&p.every(g=>e.selected[g])?u.green("[*]"):"[ ]",m=e.filter!==""?`Select All Matching (${e.filteredMap.length})`:"Select All / Deselect All";i.push(`${f} ${y} ${u.bold(m)}`)}else{let p=e.filteredMap[c-1],h=t[p],m=e.selected[p]?u.green("[*]"):"[ ]",g=`${f} ${m} `,b=7,v=u.bold(h.label),w=h.label.length;if(h.hint){let S=s-b-w-2;if(S>10){let k=Mi(h.hint,S);i.push(`${g}${v} ${u.dim(k)}`)}else{let k=Mi(h.label,s-b);i.push(`${g}${u.bold(k)}`)}}else{let S=Mi(h.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 Mi(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 Di(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=Af(i,t,o);a>0&&n.write(`\x1B[${a}F`);let d=Math.max(c.length,a),f="";for(let p=0;p<d;p++)f+=`\x1B[2K${p<c.length?c[p]:""}
|
|
143
|
+
`;n.write(f),a=d}return l(),new Promise(c=>{let d="",f=null;function p(){r.removeListener("data",m),typeof r.setRawMode=="function"&&r.setRawMode(!1),r.pause(),n.write("\x1B[?25h"),f&&clearTimeout(f)}function h(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
144
|
`){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
|
-
`:
|
|
145
|
+
`:h(i.getSelectedIndices());break;case"\x1B":i.filter!==""?(i.filter="",i.applyFilter(t),l()):h([]);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 m(g){if(d.length>0){if(d+=g,f&&clearTimeout(f),d.length>=3&&d[1]==="["){let v=d.slice(0,3),w=d.slice(3);d="",y(v),w&&m(w);return}let b=d;d="",y("\x1B");for(let v=1;v<b.length;v++)y(b[v]);return}for(let b=0;b<g.length;b++){let v=g[b];if(v==="\x1B"){let w=g.slice(b);if(w.length>=3&&w[1]==="[")y(w.slice(0,3)),b+=2;else if(w.length>=2){d=w,f=setTimeout(()=>{let S=d;d="",y("\x1B");for(let k=1;k<S.length;k++)y(S[k])},50);return}else{d="\x1B",f=setTimeout(()=>{d="",y("\x1B")},50);return}}else y(v)}}r.on("data",m)})}var Oe=Nf(Pf),_f=/^[a-zA-Z0-9_-]+$/,qf=/^[a-zA-Z0-9._-]+$/,Ff=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,Io=128,jf=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function Bi(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 Ro(e){if(!e.includes("/")&&!e.includes("\\"))return!1;try{return(await Lo(Fi(e))).isDirectory()}catch{return!1}}function Bf(e){let t;e==="~"?t=Po():e.startsWith("~/")||e.startsWith("~\\")?t=Fi(Po(),e.slice(2)):t=Fi(e);let s=Df(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(Bi(e))return Bf(e);let t=jf.exec(e);if(t){let[,f,p,h]=t,y=p.endsWith(".git")?p.slice(0,-4):p;e=`github:${f}/${y}${h?`#${h}`:""}`}if(!e.startsWith("github:"))throw new Error(`Invalid source format. Got: "${e}"
|
|
146
146
|
Supported formats:
|
|
147
147
|
github:owner/repo[#ref]
|
|
148
148
|
github:owner/repo#ref:path
|
|
149
149
|
https://github.com/owner/repo
|
|
150
150
|
https://github.com/owner/repo/tree/branch/path/to/skill
|
|
151
151
|
/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 f=s.slice(i+1);if(!f)throw new Error("Invalid source: ref cannot be empty after #");let p=f.indexOf(":");if(p!==-1){if(r=f.slice(0,p),!r)throw new Error("Invalid source: ref cannot be empty before :");o=f.slice(p+1)||null}else r=f}else{let f=s.indexOf(":");f!==-1?(n=s.slice(0,f),o=s.slice(f+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(!_f.test(l))throw new Error(`Invalid source: owner contains invalid characters: "${l}". Allowed: [a-zA-Z0-9_-]`);if(!qf.test(c))throw new Error(`Invalid source: repo contains invalid characters: "${c}". Allowed: [a-zA-Z0-9._-]`);let d={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}`),d}async function
|
|
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 Kf)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
|
|
157
|
-
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;I(`install: target ${e} \u2014 no conflict`)}}var
|
|
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 f=s.slice(i+1);if(!f)throw new Error("Invalid source: ref cannot be empty after #");let p=f.indexOf(":");if(p!==-1){if(r=f.slice(0,p),!r)throw new Error("Invalid source: ref cannot be empty before :");o=f.slice(p+1)||null}else r=f}else{let f=s.indexOf(":");f!==-1?(n=s.slice(0,f),o=s.slice(f+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(!_f.test(l))throw new Error(`Invalid source: owner contains invalid characters: "${l}". Allowed: [a-zA-Z0-9_-]`);if(!qf.test(c))throw new Error(`Invalid source: repo contains invalid characters: "${c}". Allowed: [a-zA-Z0-9._-]`);let d={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}`),d}async function ls(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(`
|
|
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>Io)throw new Error(`Invalid skill name: exceeds maximum length of ${Io} characters`);if(!Ff.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 Uf(e){let t=e.split(/[/\\]/).filter(Boolean),s=t.length>0?t[t.length-1]:e;return Me(s)}function Oo(e){let t=new Map;for(let s of e){let i=Uf(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 Vf(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 os(e){return e.killed?"Clone timed out after 60 seconds":`Clone failed: ${e.stderr||e.message}`}async function _i(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 _e(e,t="auto"){I(`install: cloning ${e.owner}/${e.repo}${e.ref?` (ref: ${e.ref})`:""} (transport: ${t})`);let s=await Ao(ge(No(),"asm-install-"));if(t==="ssh"||t==="https"){let i=t==="ssh"?e.sshCloneUrl:e.cloneUrl;try{return await _i(i,e.ref,s)}catch(n){throw await oe(s),new Error(os(n))}}try{return await _i(e.cloneUrl,e.ref,s)}catch(i){if(!Vf(i))throw await oe(s),new Error(os(i));I("install: HTTPS clone failed with auth error, retrying with SSH..."),await oe(s);let n=await Ao(ge(No(),"asm-install-"));try{return await _i(e.sshCloneUrl,e.ref,n)}catch(r){throw await oe(n),new Error(`Clone failed with both transports:
|
|
154
|
+
HTTPS: ${os(i)}
|
|
155
|
+
SSH: ${os(r)}`)}}}async function qe(e){let t=ge(e,"SKILL.md"),s;try{s=await ji(t,"utf-8")}catch{throw new Error("Not a valid skill: SKILL.md not found in repository root")}let i=re(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 cs(e,t=5){let s=[];async function i(n,r,o){let a;try{a=await If(n)}catch{return}for(let l of a){if(l===".git"||l==="node_modules")continue;let c=ge(n,l);try{if(!(await Lo(c)).isDirectory())continue}catch{continue}let d=r?`${r}/${l}`:l,f=o+1,p=ge(c,"SKILL.md");try{let h=await ji(p,"utf-8"),y=re(h);s.push({relPath:d,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:no(y),tokenCount:is(h)})}catch{f<t&&await i(c,d,f)}}}return await i(e,"",0),s.sort((n,r)=>n.name.localeCompare(r.name)),s}var Kf=[{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 To(e){let t=[],s=await rs(e);for(let{relPath:i,content:n}of s){let r=n.split(`
|
|
156
|
+
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of Kf)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 us(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 qi(e.targetDir),await as(e.targetDir,{recursive:!0,force:!0})}catch{}let s=e.sourceDir;try{await Lf(s,e.targetDir,{recursive:!0})}catch(a){throw new Error(`Failed to install: ${a.message}`)}let i=ge(e.targetDir,".git");try{await as(i,{recursive:!0,force:!0})}catch{}I(`install: copied files to ${e.targetDir}`);let n=ge(e.targetDir,"SKILL.md");try{await qi(n)}catch{throw new Error("Installation verification failed: SKILL.md not found at target")}let r=await ji(n,"utf-8"),o=re(r);return{success:!0,path:e.targetDir,name:o.name||e.skillName,version:ue(o),provider:e.providerLabel,source:t}}async function Mo(e,t){let s=await us(e);for(let i of t){if(i.name===e.providerName)continue;let n=e.scope==="project"?i.project:i.global,r=ce(n),o=ge(r,e.skillName);await Tf(r,{recursive:!0});try{if((await Rf(o)).isSymbolicLink())await as(o);else{I(`install: skipping ${o} \u2014 existing non-symlink directory`);continue}}catch{}let a=Mf(r,e.targetDir);await Of(a,o,"dir"),I(`install: symlinked ${o} -> ${a}`)}return s.provider=`All (${t.map(i=>i.label).join(", ")})`,s}async function oe(e){try{await as(e,{recursive:!0,force:!0})}catch{}}async function Do(){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 _o(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 qo(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(h=>h.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 h=e.providers.find(y=>y.name===t);if(!h){let y=e.providers.map(m=>m.name).join(", ");throw new Error(`Unknown provider: "${t}". Valid providers: ${y}, all`)}if(!h.enabled)throw new Error(`Provider "${t}" is disabled. Enable it in your config or choose another provider.`);return{provider:h,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 h=i.map(y=>y.name).join(", ");throw new Error(`--tool (or --provider) is required in non-interactive mode. Available: ${h}, all`)}let n=e.preferences.selectedTools,o=n&&n.length>0?new Set(n):null,a=e.providers.map(h=>({label:`${h.label} (${h.name})`,hint:h.global,checked:o?o.has(h.name):h.name==="agents"})),l=await Qe({items:a});if(l.length===0)throw new Error("No tools selected. Aborting.");let c=l.map(h=>e.providers[h]),d=c.map(h=>h.name),{saveSelectedTools:f}=await import("./config-55HAAFSH.js");return await f(d),c.length===1?{provider:c[0],allProviders:null}:{provider:c.find(h=>h.name==="agents")||c[0],allProviders:c}}function Ui(e,t,s,i,n,r,o="global"){let a=o==="project"?n.project:n.global,l=ce(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 Fo(e,t){try{if(await qi(e),I(`install: target ${e} \u2014 conflict (exists)${t?", force overwrite":""}`),!t)throw new Error(`Skill already exists at: ${e}
|
|
157
|
+
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;I(`install: target ${e} \u2014 no conflict`)}}var Pc=Xr(xr(),1);import{readFile as bg}from"fs/promises";import{join as wg}from"path";var Ac=500;function vg(e){let t=e.split(`
|
|
158
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 kg(e){let t=e.split(`
|
|
159
159
|
`),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 Sg(e){let t=kg(e);if(t===null)return null;try{return(0,
|
|
160
|
+
`);return null}function Sg(e){let t=kg(e);if(t===null)return null;try{return(0,Pc.parse)(t),null}catch(s){return s.message||"invalid YAML"}}async function Nc(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=wg(e.path,"SKILL.md"),n=await bg(i,"utf-8");vg(n)||t.push({category:"empty-body",message:"SKILL.md contains only frontmatter with no body content"});let r=Sg(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>Ac&&t.push({category:"high-file-count",message:`Skill has ${s} files (threshold: ${Ac})`}),t}import{join as Ig}from"path";import{homedir as Lg}from"os";import{readFile as $g,writeFile as xg,mkdir as Eg}from"fs/promises";import{dirname as Cg}from"path";async function Ag(e){try{let t=await $g(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 Pg(e,t,s){let i={fetched_at:new Date().toISOString(),ttl_seconds:s,data:t};try{await Eg(Cg(e),{recursive:!0}),await xg(e,JSON.stringify(i,null,2),"utf-8"),I(`http: wrote cache -> ${e}`)}catch(n){I(`http: failed to write cache: ${n}`)}}function Ng(e){let t=new Date(e.fetched_at).getTime();return(Date.now()-t)/1e3<e.ttl_seconds}async function Ic(e,t,s={}){let i=s.ttl??3600,n=s.noCache??!1,r=await Ag(t);if(r&&!n&&Ng(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 Pg(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 Rg=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,Og=/^[a-zA-Z0-9_-]+$/,Oc=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9._-]+$/,Tg=/^[0-9a-f]{40}$/,Mg=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/,Dg=/^[a-z0-9-]+$/,_g=/^sha256:[0-9a-f]{64}$/,Lc=["pass","warning","dangerous"];function ai(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:Rg,maxLength:128},{field:"author",pattern:Og,maxLength:39},{field:"description",maxLength:256},{field:"repository",pattern:Oc},{field:"commit",pattern:Tg},{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"||!Lc.includes(r))&&t.push({field:"security_verdict",message:`"security_verdict" must be one of: ${Lc.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"||!Mg.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`}),Dg.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"||!_g.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 qg(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 Fg(e,t,s=2){let i=[];for(let n of t){if(e===n)continue;let r=qg(e,n);r<=s&&i.push({existingName:n,distance:r})}return i.sort((n,r)=>n.distance-r.distance)}var Er=process.env.ASM_REGISTRY_URL??"https://raw.githubusercontent.com/luongnv89/asm-registry/main/index.json",jg=process.env.ASM_REGISTRY_CACHE??Ig(Lg(),".config","agent-skill-manager","registry-cache.json"),Bg=3600;function Yt(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 Cr(e){return Yt(e)?e.includes("/"):!1}async function Ar(e){let t=await Ic(Er,jg,{ttl:Bg,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=ai(i);if(n.length>0){I(`registry: dropping invalid manifest entry (${i?.name??"unknown"}): ${n.map(r=>r.message).join(", ")}`);continue}if(!Oc.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 Ug(e,t){return t.manifests.filter(s=>s.name.toLowerCase()===e.toLowerCase())}function Vg(e,t,s){return s.manifests.find(i=>i.author.toLowerCase()===e.toLowerCase()&&i.name.toLowerCase()===t.toLowerCase())??null}function Rc(e,t,s=5){return Fg(e,t.manifests.map(n=>n.name),3).slice(0,s).map(n=>n.existingName)}async function Tc(e,t){let s=await Ar(t);if(!s)return I("registry: failed to fetch index \u2014 skipping registry resolution"),{resolved:null,multipleMatches:[],suggestions:[]};if(Cr(e)){let[r,o]=e.split("/"),a=Vg(r,o,s);if(a)return{resolved:{manifest:a,source:"registry"},multipleMatches:[],suggestions:[]};let l=Rc(o,s);return{resolved:null,multipleMatches:[],suggestions:l}}let i=Ug(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=Rc(e,s);return{resolved:null,multipleMatches:[],suggestions:n}}function Mc(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 Kg,access as _c,mkdir as Jg,cp as Dc,rm as Hg,symlink as Gg}from"fs/promises";import{join as qc,basename as Wg}from"path";function Yg(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 Fc(e){let t;try{t=await Kg(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=Yg(s);if(!i.valid)throw new Error(`Invalid manifest:
|
|
161
161
|
${i.errors.join(`
|
|
162
|
-
`)}`);return s}async function zg(e){try{return await
|
|
162
|
+
`)}`);return s}async function zg(e){try{return await _c(e),!0}catch{return!1}}function Qg(e,t){return e.providers.find(s=>s.name===t&&s.enabled)}function Xg(e,t,s,i){let n=Qg(e,t);if(!n)return null;let r=s==="global"?n.global:n.project,o=ce(r),a=Wg(i);return!a||a==="."||a===".."?null:qc(o,a)}function Zg(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 jc(e,t,s){let i=s?.config??await B(),n=s?.installedSkills??await ee(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 d=Xg(i,c.provider,c.scope,c.dirName);if(!d){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:`Provider "${c.provider}" not found or not enabled.`});continue}let f=await zg(d);if(f&&!t.force){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"skipped",reason:"Already installed.",path:d});continue}if(t.dryRun){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"dry-run",reason:f?"Would overwrite (--force).":"Would install.",path:d});continue}let p=Zg(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 Jg(qc(d,".."),{recursive:!0}),f&&await Hg(d,{recursive:!0,force:!0}),c.isSymlink&&c.symlinkTarget)try{await _c(c.symlinkTarget),await Gg(c.symlinkTarget,d),I(`import: symlinked "${c.name}" -> ${c.symlinkTarget} at ${d}`)}catch{await Dc(p.realPath,d,{recursive:!0}),I(`import: symlink target unreachable, copied "${c.name}" from ${p.realPath} to ${d}`)}else await Dc(p.realPath,d,{recursive:!0}),I(`import: copied "${c.name}" from ${p.realPath} to ${d}`);r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"installed",path:d})}catch(h){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:`Copy failed: ${h.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 ey,writeFile as ty,access as sy}from"fs/promises";import{join as iy}from"path";function ny(e){return`---
|
|
163
163
|
name: ${e}
|
|
164
164
|
description: ""
|
|
165
165
|
license: ""
|
|
@@ -180,62 +180,62 @@ as instructions for when and how to use this skill.
|
|
|
180
180
|
## Instructions
|
|
181
181
|
|
|
182
182
|
- Step-by-step instructions for the agent
|
|
183
|
-
`}async function
|
|
184
|
-
`)}import{access as uy,lstat as
|
|
185
|
-
`,"utf-8"),I(`bundle: saved to ${s}`),s}async function
|
|
183
|
+
`}async function Bc(e,t){await ey(t,{recursive:!0});let s=iy(t,"SKILL.md"),i=ny(e);await ty(s,i,"utf-8")}async function Uc(e){try{return await sy(e),!0}catch{return!1}}import{readdir as ry,stat as oy}from"fs/promises";import{join as ay}from"path";async function ly(e){let t=0;try{let i=(await ry(e,{recursive:!0})).map(async r=>{try{let o=await oy(ay(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 Kc(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 ly(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 cy(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 Pr(e,t,s=20){let i=Math.round(e/t*s),n=s-i;return u.green("#".repeat(i))+u.dim("-".repeat(n))}var Vc={claude:"Claude Code",codex:"Codex",openclaw:"OpenClaw",agents:"Agents"};function Jc(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(cy(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])=>(Vc[l]||l).length));for(let[l,c]of s){let d=Vc[l]||l,f=uo(l,d.padEnd(n)),p=String(c).padStart(4);t.push(` ${f} ${p} ${Pr(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} ${Pr(e.byScope.global,r)}`),t.push(` ${"project".padEnd(n)} ${a} ${Pr(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(`
|
|
184
|
+
`)}import{access as uy,lstat as fy,mkdir as dy,readdir as py,readFile as Hc,rm as my,stat as Gc,symlink as hy}from"fs/promises";import{join as li}from"path";async function Nr(e){let t;try{t=await Gc(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=li(e,"SKILL.md"),i;try{i=await Hc(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 Wc(e,t,s,i){let n=li(t,s),r=!1;try{await uy(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await my(n,{recursive:!0,force:!0})}await dy(t,{recursive:!0}),await hy(e,n,"dir")}async function Ir(e){let t;try{t=await Gc(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 py(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=li(e,n);try{if(!(await fy(r)).isDirectory())continue}catch{continue}let o=li(r,"SKILL.md");try{let a=await Hc(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 gy,writeFile as yy,readdir as Yc,access as zc,mkdir as by,rm as wy}from"fs/promises";import{join as He,resolve as Qc,dirname as vy}from"path";import{homedir as ky}from"os";import{fileURLToPath as Sy}from"url";var $y=Sy(import.meta.url),xy=vy($y),Je=He(ky(),".config","agent-skill-manager","bundles"),ci=Qc(xy,"..","data","bundles");function Ey(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 Xc(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function Zc(e,t){let s=t??await Re(),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 Cy(){await by(Je,{recursive:!0})}function Lr(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 Rr(e){await Cy();let t=`${Lr(e.name)}.json`,s=He(Je,t);return await yy(s,JSON.stringify(e,null,2)+`
|
|
185
|
+
`,"utf-8"),I(`bundle: saved to ${s}`),s}async function zt(e){let t;try{t=await gy(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=Ey(s);if(!i.valid)throw new Error(`Invalid bundle:
|
|
186
186
|
${i.errors.join(`
|
|
187
|
-
`)}`);return s}async function
|
|
188
|
-
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let d of ru)if(d.pattern.test(l)){let f=d.category;t.has(f)||t.set(f,{description:d.description,matches:[]});let p=c.length>120?c.slice(0,120)+"...":c;t.get(f).matches.push({file:n,line:a+1,match:p,severity:d.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
|
|
189
|
-
`)}function
|
|
190
|
-
About to publish "${U}" by ${ze} to ${
|
|
187
|
+
`)}`);return s}async function Qt(e){if(e.includes("/")||e.includes("\\")||e.endsWith(".json")){let i=Qc(e);return zt(i)}let t=`${Lr(e)}.json`,s=He(Je,t);try{return await zt(s)}catch(i){if(i?.message?.includes("Bundle file not found")){let n=He(ci,t);try{return await zt(n)}catch(r){throw r?.message?.includes("Bundle file not found")?new Error(`Bundle file not found: ${s}`):r}}throw i}}async function eu(){let e=[];try{await zc(ci)}catch{return e}let t;try{t=await Yc(ci)}catch{return e}for(let s of t){if(!s.endsWith(".json"))continue;let i=He(ci,s);try{let n=await zt(i);e.push(n)}catch{I(`bundle: skipping invalid predefined file ${i}`)}}return e.sort((s,i)=>s.name.localeCompare(i.name)),e}async function tu(){let e=[];try{await zc(Je)}catch{return e}let t;try{t=await Yc(Je)}catch{return e}for(let s of t){if(!s.endsWith(".json"))continue;let i=He(Je,s);try{let n=await zt(i);e.push(n)}catch{I(`bundle: skipping invalid file ${i}`)}}return e.sort((s,i)=>s.name.localeCompare(i.name)),e}async function su(e){let t=`${Lr(e)}.json`,s=He(Je,t);try{return await wy(s),I(`bundle: removed ${s}`),!0}catch(i){if(i?.code==="ENOENT")return!1;throw i}}import{readFile as Dy,realpath as _y}from"fs/promises";import{join as qy,resolve as Fy,relative as jy}from"path";var ru=[{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 Ay(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 Py(e){let t=new Map;for(let{relPath:n,content:r}of e){let o=r.split(`
|
|
188
|
+
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let d of ru)if(d.pattern.test(l)){let f=d.category;t.has(f)||t.set(f,{description:d.description,matches:[]});let p=c.length>120?c.slice(0,120)+"...":c;t.get(f).matches.push({file:n,line:a+1,match:p,severity:d.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 Ny(e){let t=new Map;for(let r of e)for(let o of r.matches)for(let a of ru)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 Iy(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 Le(e,t,s,i){I(`security-audit: scanning ${e}`);let n=await rs(e),r=n.reduce((f,p)=>f+p.lineCount,0),o=null;s&&i&&(o=await Ay(s,i));let a=Py(n),l=Ny(a),{verdict:c,reason:d}=Iy(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:d}}var L=u,Ge=56,Ly={"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"},iu={critical:0,warning:1,info:2};function Ry(e){switch(e){case"safe":return L.bgGreen(" SAFE ");case"caution":return L.bgCyan(" CAUTION ");case"warning":return L.bgYellow(" WARNING ");case"dangerous":return L.bgRed(" DANGEROUS ")}}function Oy(e){switch(e){case"safe":return L.green;case"caution":return L.cyan;case"warning":return L.yellow;case"dangerous":return L.red}}function ut(e){switch(e){case"critical":return L.red("!!");case"warning":return L.yellow(" !");case"info":return L.dim(" i")}}function Or(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function ui(e){return e.toLocaleString("en-US")}function ou(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function nu(e){return ou(e).length}function Ty(e){let t=new Map;for(let s of e){let i=`${s.file}:${s.line}`,n=t.get(i);(!n||iu[s.severity]<iu[n.severity])&&t.set(i,s)}return Array.from(t.values())}function My(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 fi(e){let t=[],s=Ry(e.verdict),i=ou(s),n=` ${L.bold(e.skillName)}`,r=` ${e.skillName}`,o=Ge-4,a=Math.max(1,o-r.length-i.length);if(t.push(""),t.push(L.dim(" +-- ")+L.bold("Security Audit")+L.dim(" "+"-".repeat(Ge-19)+"+")),t.push(L.dim(" |")+n+" ".repeat(a)+s+L.dim("|")),t.push(L.dim(" |")+L.dim(` ${ui(e.totalFiles)} files | ${ui(e.totalLines)} lines`)+" ".repeat(Math.max(1,o-` ${ui(e.totalFiles)} files | ${ui(e.totalLines)} lines`.length))+L.dim("|")),t.push(L.dim(" +"+"-".repeat(Ge-2)+"+")),e.source){let f=e.source;if(f.fetchError)t.push(` ${L.yellow("!")} Could not fetch profile: ${f.fetchError}`);else{let p=[];if(p.push(`${f.owner} ${f.isOrganization?L.cyan("(org)"):L.dim("(user)")}`),f.publicRepos!==null){let h=f.publicRepos,y=h<3?L.yellow(`${h} repos`):h<10?L.cyan(`${h} repos`):L.green(`${h} repos`);p.push(y)}f.accountAge&&p.push(f.accountAge),t.push(` ${L.dim("Author:")} ${p.join(L.dim(" | "))}`)}}if(t.push(""),e.codeScans.length===0)t.push(` ${L.green("*")} ${L.green("No suspicious patterns detected.")}`);else{let f=Oy(e.verdict),p=e.verdict==="dangerous"||e.verdict==="warning"?ut("critical"):e.verdict==="caution"?ut("warning"):ut("info");t.push(` ${p} ${f(e.verdictReason)}`);let h=0,y=0,m=0;for(let w of e.codeScans)for(let S of w.matches)S.severity==="critical"?h++:S.severity==="warning"?y++:m++;let g=[];h>0&&g.push(L.red(`${h} critical`)),y>0&&g.push(L.yellow(`${y} warning`)),m>0&&g.push(L.dim(`${m} info`));let b=e.permissions.map(w=>w.type),v=b.length>0?L.dim(`Perms: ${b.join(", ")}`):"";t.push(` ${g.join(L.dim(" | "))} ${v}`)}if(t.push(""),e.codeScans.length>0){t.push(` ${L.bold("Findings")}`),t.push(L.dim(" "+"=".repeat(Ge-2)));for(let f of e.codeScans){let p=Ty(f.matches),h=p.filter(O=>O.severity==="critical").length,y=p.filter(O=>O.severity==="warning").length,m=p.filter(O=>O.severity==="info").length,g=h>0?ut("critical"):y>0?ut("warning"):ut("info"),b=[];h>0&&b.push(L.red(`${h} critical`)),y>0&&b.push(L.yellow(`${y} warning`)),m>0&&b.push(L.dim(`${m} info`));let v=Ly[f.category],w=v?L.dim(`PERM: ${v}`):"",S=` ${g} ${L.bold(f.category)} (${b.join(", ")})`;if(w){let O=nu(S),D=nu(w),T=Math.max(2,Ge-O-D);t.push(S+" ".repeat(T)+w)}else t.push(S);let k=My(p),C=Math.min(24,Math.max(...k.map(O=>O.file.length))),E=0,x=3;for(let O of k){if(E>=x)break;let D=Or(O.file,24),T=L.dim(D.padEnd(C));if(O.entries.length===1){let A=O.entries[0],N=Or(A.match,50);t.push(` ${T} :${A.line} ${L.dim("--")} ${A.severity==="critical"?N:L.dim(N)}`),E++}else if(O.entries.length<=3){let A=O.entries.map(q=>`:${q.line}`).join(", "),N=Or(O.entries[0].match,40);t.push(` ${T} ${A} ${L.dim("--")} ${L.dim(N)}`),E++}else{let N=O.entries.slice(0,3).map(R=>`:${R.line}`).join(", "),q=O.entries.length-3;t.push(` ${T} ${N} ${L.dim(`(+${q} more)`)}`),E++}}let M=k.length-Math.min(k.length,x);if(M>0){let O=p.length-k.slice(0,x).reduce((D,T)=>D+T.entries.length,0);O>0&&t.push(` ${L.dim(`... ${O} more in ${M} file${M>1?"s":""}`)}`)}t.push("")}}t.push(L.dim(" "+"=".repeat(Ge-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")}`,d=e.source&&!e.source.fetchError?`github.com/${e.source.owner}`:"";if(d){let f=Math.max(2,Ge-2-c.length-d.length);t.push(L.dim(` ${c}${" ".repeat(f)}${d}`))}else t.push(L.dim(` ${c}`));return t.push(""),t.join(`
|
|
189
|
+
`)}function Tr(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="",d=!1;a.stdout?.on("data",f=>{l+=f.toString()}),a.stderr?.on("data",f=>{c+=f.toString()}),a.on("error",f=>{if(d)return;if(d=!0,f.code==="ENOENT"){r({exitCode:127,stdout:l,stderr:f.message});return}o(f)}),a.on("close",f=>{d||(d=!0,r({exitCode:f??-1,stdout:l,stderr:c}))})})}function di(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 By(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/</g,"<").replace(/>/g,">").replace(/\|/g,"\\|")}function Mr(e){return By(di(e))}var We="luongnv89/asm-registry";async function Uy(e){let t=qy(e,"SKILL.md"),s;try{s=await Dy(t,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}. Run "asm init" to create one.`)}let i=re(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 Vy(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 Ky(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 Jy(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 Hy(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 Gy(){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 Wy(e){switch(e){case"safe":case"caution":return"pass";case"warning":return"warning";case"dangerous":return"dangerous"}}function au(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 Yy(e){let t=au({metadata:e.metadata,author:e.metadata.creator||"unknown",commit:e.commit,repository:e.repository,securityVerdict:e.registryVerdict}),s=ai(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 lu(e){let t=Fy(e.path);I(`publish: starting for ${t}`),await Vy(t);let s=await Uy(t);I(`publish: parsed metadata for "${s.name}"`);let n=await(e._auditFn??Le)(t,s.name),r=Wy(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 Ky(t),a=await Hy(t),l=await Jy(t),c=await _y(t),d=jy(l,c),f=d&&d!=="."?d:void 0,h=await(e._checkGhCliFn??Gy)();if(!h.available||!h.authenticated){let U=h.available?"gh CLI not authenticated":"gh CLI not found";return Yy({metadata:s,commit:o,repository:a,registryVerdict:r,securityReport:n,fallbackReason:U})}if(!h.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=h.login,m=au({metadata:s,author:y,commit:o,repository:a,skillPath:f,securityVerdict:r}),g=ai(m);if(g.length>0)return{success:!1,manifest:m,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:m,prUrl:null,error:null,securityVerdict:r,securityReport:n};if(!e.yes){if(!process.stdin.isTTY)return{success:!1,manifest:m,prUrl:null,error:"Cannot prompt for confirmation in non-interactive mode. Use --yes to skip.",securityVerdict:r,securityReport:n};let U=di(s.name),ze=di(y);process.stderr.write(`
|
|
190
|
+
About to publish "${U}" by ${ze} to ${We}.
|
|
191
191
|
Security verdict: ${r}
|
|
192
192
|
|
|
193
|
-
Proceed? [y/N] `);let ne=await new Promise(le=>{let ve="",
|
|
194
|
-
`)&&(process.stdin.removeListener("data",
|
|
195
|
-
`,S=Buffer.from(w,"utf-8").toString("base64"),{stdout:k,exitCode:
|
|
196
|
-
`),{stdout:
|
|
193
|
+
Proceed? [y/N] `);let ne=await new Promise(le=>{let ve="",ts=mt=>{ve+=mt.toString(),ve.includes(`
|
|
194
|
+
`)&&(process.stdin.removeListener("data",ts),process.stdin.pause(),le(ve.trim()))};process.stdin.resume(),process.stdin.on("data",ts)});if(ne.toLowerCase()!=="y"&&ne.toLowerCase()!=="yes")return{success:!1,manifest:m,prUrl:null,error:"Publish aborted by user.",securityVerdict:r,securityReport:n}}I(`publish: forking ${We}`),await H(["gh","repo","fork",We,"--clone=false"]);let b=`publish/${y}/${s.name}`,v=`manifests/${y}/${s.name}.json`,w=JSON.stringify(m,null,2)+`
|
|
195
|
+
`,S=Buffer.from(w,"utf-8").toString("base64"),{stdout:k,exitCode:C}=await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/main`,"--jq",".object.sha"]);if(C!==0)return{success:!1,manifest:m,prUrl:null,error:`Failed to read fork's main branch. Ensure the fork exists at ${y}/asm-registry.`,securityVerdict:r,securityReport:n};let E=k.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/${v}`,"-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/${v}?ref=${b}`,"-q",".sha"]),ne=U.trim();if(ze===0&&ne){let{exitCode:le}=await H(["gh","api",`repos/${y}/asm-registry/contents/${v}`,"-X","PUT","-f",`message=Update ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`,"-f",`sha=${ne}`]);if(le!==0)return{success:!1,manifest:m,prUrl:null,error:"Failed to write manifest to registry fork.",securityVerdict:r,securityReport:n}}else return{success:!1,manifest:m,prUrl:null,error:`Failed to write manifest to registry fork. ${M}`,securityVerdict:r,securityReport:n}}let D=Mr(s.name),T=Mr(s.description),A=Mr(s.license),N=`Publish ${y}/${di(s.name)}`,q=[`## 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(`
|
|
196
|
+
`),{stdout:R,stderr:_,exitCode:ie}=await H(["gh","pr","create","--repo",We,"--head",`${y}:${b}`,"--title",N,"--body",q]),K=null;if(ie===0)K=R.trim();else{let U=_.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/);U&&(K=U[0])}return K?{success:!0,manifest:m,prUrl:K,error:null,securityVerdict:r,securityReport:n}:{success:!1,manifest:m,prUrl:null,error:`Failed to create PR against ${We}. ${_}`,securityVerdict:r,securityReport:n}}function cu(e){let t=e.manifest;return t?["",` gh CLI is unavailable (${e.fallbackReason}).`," To publish manually:","",` 1. Fork ${We} 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 ${We}`,"",' Run "asm doctor" to fix your environment.',""," Generated manifest:",JSON.stringify(t,null,2).split(`
|
|
197
197
|
`).map(i=>` ${i}`).join(`
|
|
198
198
|
`)].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 gu(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 yu(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
|
|
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 xu(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
|
|
199
|
+
`):""}import{execFile as zy}from"child_process";import{promisify as Qy}from"util";import{rm as pi,rename as uu,cp as fu,access as Xy,mkdir as Zy}from"fs/promises";import{join as mi}from"path";import{homedir as du}from"os";var Dr=Qy(zy);async function eb(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 tb(e,t){try{let s=["ls-remote",e];t?s.push(t):s.push("HEAD");let{stdout:i}=await Dr("git",s,{timeout:1e4}),n=i.split(`
|
|
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 _r(e){return e.sourceType?e.sourceType:e.source.startsWith("local:")?"local":"github"}function pu(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 sb(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 qr(e){let t=e?.readLockFn??Re,s=e?.fetchRegistryIndexFn??Ar,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])=>_r(l)==="registry"||l.registryName)&&(r=await s());let a=await eb(n,5,async([l,c])=>{let d=_r(c);if(!c.commitHash||c.commitHash==="unknown")return{name:l,installedCommit:c.commitHash||"unknown",latestCommit:"unknown",source:c.source,sourceType:d,status:"untracked"};if(d==="local")return{name:l,installedCommit:c.commitHash,latestCommit:c.commitHash,source:c.source,sourceType:d,status:"up-to-date"};if(d==="registry"&&r){let y=c.registryName||l,m=r.manifests.find(g=>g.name.toLowerCase()===y.toLowerCase());if(m){let g=m.commit!==c.commitHash;return{name:l,installedCommit:he(c.commitHash),latestCommit:he(m.commit),source:c.source,sourceType:d,status:g?"outdated":"up-to-date"}}}let f=pu(c.source);if(!f)return{name:l,installedCommit:he(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:d,status:"error",error:"Cannot determine remote URL"};let p=await tb(f,c.ref);if(!p)return{name:l,installedCommit:he(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:d,status:"error",error:"Failed to fetch remote commit"};let h=p!==c.commitHash;return{name:l,installedCommit:he(c.commitHash),latestCommit:he(p),source:c.source,sourceType:d,status:h?"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 ib(e,t,s,i){if(_r(t)==="local")return{name:e,status:"skipped",reason:"Local skill (not updatable)"};let r=pu(t.source);if(!r)return{name:e,status:"failed",reason:"Cannot determine remote URL"};let o=mi(du(),".config","agent-skill-manager",".tmp",`${e}-${Date.now()}`);try{let a=mi(du(),".config","agent-skill-manager",".tmp");await Zy(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 Dr("git",l,{timeout:6e4})}catch(k){return{name:e,status:"failed",reason:`Clone failed: ${k.stderr||k.message}`}}let c=null;try{let{stdout:k}=await Dr("git",["rev-parse","HEAD"],{cwd:o,timeout:5e3});c=k.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 d="safe";try{let k=i?.auditFn??Le,C=sb(t.source);if(d=(await k(o,e,C?.owner,C?.repo)).verdict,d==="dangerous")return{name:e,status:"skipped",reason:"Security audit: dangerous \u2014 update blocked",securityVerdict:d};if(d==="warning"||d==="caution"){if(!s)return{name:e,status:"skipped",reason:`Security audit: ${d} \u2014 use --yes to override`,securityVerdict:d};I(`updater: security audit ${d} for ${e} \u2014 proceeding (--yes)`)}}catch(k){return I(`updater: security audit failed for ${e}: ${k.message}`),{name:e,status:"failed",reason:`Security audit failed \u2014 skipping update: ${k.message}`}}let f=i?.loadConfigFn??B,p=i?.resolveProviderPathFn??ce,y=(await f()).providers.find(k=>k.name===t.provider),m=y?y.global:`~/.${t.provider}/skills`,g=p(m),b=mi(g,e),v=mi(o,".git");try{await pi(v,{recursive:!0,force:!0})}catch{}try{await Xy(b)}catch{let k=i?.writeLockEntryFn??yt;return await fu(o,b,{recursive:!0}),await k(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:he(t.commitHash),newCommit:he(c),securityVerdict:d}}let w=`${b}.bak-${Date.now()}`;try{await uu(b,w),await fu(o,b,{recursive:!0}),await pi(w,{recursive:!0,force:!0})}catch(k){try{await pi(b,{recursive:!0,force:!0}),await uu(w,b)}catch{}return{name:e,status:"failed",reason:`Atomic swap failed: ${k.message}`}}return await(i?.writeLockEntryFn??yt)(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:he(t.commitHash),newCommit:he(c),securityVerdict:d}}finally{try{await pi(o,{recursive:!0,force:!0})}catch{}}}async function mu(e,t,s){let i=s?.readLockFn??Re,n=s?.checkOutdatedFn??qr,r=s?.updateSkillFn??ib,o=await i(),a=await n({lock:o}),l=a.entries.filter(f=>f.status==="outdated"),c=[];if(e&&e.length>0){let f=new Set(e.map(p=>p.toLowerCase()));l=l.filter(p=>f.has(p.name.toLowerCase()));for(let p of e)l.find(h=>h.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 d=[];for(let f of l){let p=o.skills[f.name];if(!p)continue;let h=await r(f.name,p,t);d.push(h)}return{results:d,updatedCount:d.filter(f=>f.status==="updated").length,skippedCount:d.filter(f=>f.status==="skipped").length,failedCount:d.filter(f=>f.status==="failed").length,...c.length>0?{warnings:c}:{}}}function he(e){return!e||e==="unknown"?"unknown":e.slice(0,7)}function hu(e,t){if(e.entries.length===0)return"No skills installed.";let s=f=>f,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 f of e.entries){let p=f.name.padEnd(22),h=f.installedCommit.padEnd(14),y,m;switch(f.status){case"outdated":y=i(f.latestCommit.padEnd(14)),m=f.sourceType;break;case"up-to-date":y=n(f.latestCommit.padEnd(14)),m=o("(up to date)");break;case"untracked":y=r("untracked".padEnd(14)),m=r("untracked");break;case"error":y=o("error".padEnd(14)),m=o(f.error||"error");break}c.push(`${p}${h}${y}${m}`)}c.push("");let d=[];return e.outdatedCount>0&&d.push(i(`${e.outdatedCount} outdated`)),e.upToDateCount>0&&d.push(n(`${e.upToDateCount} up to date`)),e.untrackedCount>0&&d.push(r(`${e.untrackedCount} untracked`)),e.errorCount>0&&d.push(o(`${e.errorCount} error`)),c.push(d.join(", ")),c.join(`
|
|
201
|
+
`)}function gu(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 yu(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 gb}from"child_process";import{promisify as yb}from"util";import{access as bu,readFile as vu,readdir as bb,writeFile as wb,rm as vb,stat as ku}from"fs/promises";import{join as Fr}from"path";import{homedir as kb}from"os";import{constants as wu}from"fs";import{access as nb,realpath as rb,stat as ob}from"fs/promises";import{constants as ab}from"fs";import{delimiter as lb,resolve as cb,sep as ub}from"path";var fb="asm";function db(e){if(!e)return[];let t=new Set,s=[];for(let i of e.split(lb)){let n=i.trim();if(!n)continue;let r=n.endsWith(ub)?n.slice(0,-1):n;t.has(r)||(t.add(r),s.push(r))}return s}async function pb(e){try{if(!(await ob(e)).isFile())return!1}catch{return!1}try{return await nb(e,ab.X_OK),!0}catch{return!1}}async function mb(e){try{return await rb(e)}catch{return e}}async function hb(e=process.env.PATH){let t=new Set,s=[];for(let i of db(e)){let n=cb(i,fb);if(!await pb(n))continue;let r=await mb(n);t.has(r)||(t.add(r),s.push({path:n,realPath:r}))}return s}async function hi(e=process.env.PATH){let t=await hb(e);if(t.length===0)return{resolved:null,shadowed:[]};let[s,...i]=t;return{resolved:s,shadowed:i}}var ft=yb(gb);async function Sb(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 $b(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 xb(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("gh",["--version"],{timeout:5e3}),i=s.trim().split(`
|
|
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 Eb(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 Cb(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 Ab(e){try{let t=Fr(e,".asm-doctor-write-test");return await wb(t,"test","utf-8"),await vb(t),{writable:!0,exists:!0}}catch{}try{return await bu(e,wu.W_OK),{writable:!0,exists:!0}}catch{}try{return await bu(e,wu.F_OK),{writable:!1,exists:!0}}catch{return{writable:!0,exists:!1}}}async function Pb(e){let t=e.providers.filter(r=>r.enabled),s=0,i=0;for(let r of t){let o=ce(r.global);i++,(await Ab(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 Nb(){let e=ht();try{let t=await vu(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 Ib(){let e=to();try{let t=await vu(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 d of r)if(!c[d]){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 Lb(){try{let e=await fetch(Er,{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 Rb(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(f=>f.name===a.provider);if(!l){i.push(o);continue}let c=ce(l.global),d=Fr(c,o);try{(await ku(d)).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 Ob(e,t){let s=new Set(Object.keys(t.skills)),i=[];for(let n of e.providers.filter(r=>r.enabled)){let r=ce(n.global);try{let o=await bb(r);for(let a of o)try{(await ku(Fr(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 Tb(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("df",["-Pk",kb()],{timeout:5e3}),i=s.trim().split(`
|
|
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 Mb(){try{let e=await hi();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 (e.g. `bun remove -g agent-skill-manager` or `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 Su(){let e=await B(),t=await Re(),i=(await Promise.allSettled([Sb(),$b(),xb(),Eb(),Cb(),Pb(e),Nb(),Ib(),Lb(),Rb(e,t),Ob(e,t),Tb(),Mb()])).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 Db={pass:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function $u(e){let t=["Checking your environment...",""];for(let s of e.checks){let n=` ${Db[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(`
|
|
204
|
+
`)}function xu(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 Br,writeFile as _b,stat as dt,copyFile as qb,readdir as Nu}from"fs/promises";import{join as pt,resolve as Vr,basename as we,isAbsolute as Kr}from"path";var Ur="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`).",Eu=["name","description","version","license","author","creator","compatibility","allowed-tools","effort","tags","metadata"],Cu=["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"],Fb=["confirm","confirmation","error","errors","fail","failure","caution","warning","prerequisite","prerequisites","requires","requirements","rollback","dry-run","dry run","safety","validate","validation","check","backup"],jb=["acceptance criteria","expected output","expected result","edge case","edge cases","test","tests","testing","verify","verification","assert","example input","example output","given","then"],Bb=["reference","references","see","template","templates","script","scripts","helper","helpers","link"],Ub=["when to use","quick start","overview","instructions","steps","workflow","phases","progressive"];function Iu(e){let t=e.split(`
|
|
205
205
|
`);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
206
|
`),n=t.slice(s+1).join(`
|
|
207
207
|
`);return{rawFrontmatter:i,body:n}}return{rawFrontmatter:t.slice(1).join(`
|
|
208
208
|
`),body:""}}function Lu(e){return e?e.split(`
|
|
209
|
-
`).length:0}function Hr(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function Ub(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function hi(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function Vb(e){return/```[\s\S]+?```/m.test(e)}function Kb(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function Jb(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=Ub(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(Vr))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function Hb(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=Hr(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&&(Cu.includes(a)||Cu.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 Gb(e,t){let s=[],i=[],n=0,r=hi(t,Bb);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.'),Kb(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=Vb(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=Hr(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 Yb(e,t){let s=[],i=[],n=0,r=Hr(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=hi(t,jb);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=>Lu(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 Wb(e,t){let s=[],i=[],n=0,r=hi(t,qb);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 zb(e,t){let s=[],i=[],n=0,r=hi(t,Fb);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 Qb(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(d=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(d)).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 Qt(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=re(t),{rawFrontmatter:o,body:a}=Iu(t),l=[Jb(r,a,o,n),Hb(r,a),Gb(r,a),Yb(r,a),Wb(r,a),zb(r,a),Qb(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),d=l.reduce((g,b)=>g+b.max,0),f=Math.round(c/d*100),p="F";f>=90?p="A":f>=80?p="B":f>=65?p="C":f>=50&&(p="D");let m=[];l.find(g=>g.id==="structure")?.suggestions.includes(Vr)&&m.push(Vr);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:f,grade:p,topSuggestions:m,frontmatter:r}}async function Ru(e){let t=Jr(e)?e:Kr(e),s;try{s=await dt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Ur(i,"utf-8"),Qt({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=pt(t,"SKILL.md");try{n=await Ur(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await Nu(t)}catch{r=void 0}return Qt({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function Xb(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function Zb(e){let t=e.split(`
|
|
210
|
-
`),s=[],i=[],n=0;for(;n<t.length;){let c=t[n];if(!c.trim()){n++;continue}let f=c.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!f)return{newFrontmatter:e,changed:!1};let p=f[1],
|
|
209
|
+
`).length:0}function Jr(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function Vb(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function gi(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function Kb(e){return/```[\s\S]+?```/m.test(e)}function Jb(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function Hb(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 h=t.trim().length>=20,y=Vb(t,1);if(h?(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 m=i.find(g=>g.toLowerCase()==="readme.md");m&&(n.push(`\`${m}\` found at skill root; move it to a subdirectory (e.g., \`docs/README.md\`).`),r.push(Ur))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function Gb(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=Jr(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&&(Cu.includes(a)||Cu.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 Wb(e,t){let s=[],i=[],n=0,r=gi(t,Ub);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.'),Jb(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=Kb(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=Jr(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 Yb(e,t){let s=[],i=[],n=0,r=Jr(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=gi(t,Bb);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=>Lu(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 zb(e,t){let s=[],i=[],n=0,r=gi(t,Fb);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 Qb(e,t){let s=[],i=[],n=0,r=gi(t,jb);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 Xb(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(d=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(d)).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 Xt(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=re(t),{rawFrontmatter:o,body:a}=Iu(t),l=[Hb(r,a,o,n),Gb(r,a),Wb(r,a),Yb(r,a),zb(r,a),Qb(r,a),Xb(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),d=l.reduce((g,b)=>g+b.max,0),f=Math.round(c/d*100),p="F";f>=90?p="A":f>=80?p="B":f>=65?p="C":f>=50&&(p="D");let h=[];l.find(g=>g.id==="structure")?.suggestions.includes(Ur)&&h.push(Ur);let m=[...l].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of m){for(let b of g.suggestions){if(h.length>=3)break;h.includes(b)||h.push(b)}if(h.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:l,overallScore:f,grade:p,topSuggestions:h,frontmatter:r}}async function Ru(e){let t=Kr(e)?e:Vr(e),s;try{s=await dt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Br(i,"utf-8"),Xt({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=pt(t,"SKILL.md");try{n=await Br(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await Nu(t)}catch{r=void 0}return Xt({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function Zb(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function ew(e){let t=e.split(`
|
|
210
|
+
`),s=[],i=[],n=0;for(;n<t.length;){let c=t[n];if(!c.trim()){n++;continue}let f=c.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!f)return{newFrontmatter:e,changed:!1};let p=f[1],h=f[2];if(h===""||h===">"||h==="|"){let y=[c];for(n++;n<t.length;){let m=t[n];if(m.trim()===""){y.push(m),n++;continue}if(/^\s+/.test(m))y.push(m),n++;else break}i.push({key:p,text:y.join(`
|
|
211
211
|
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let d=Eu.indexOf(c);return d===-1?Eu.length+1:d},o=[...s].sort((c,d)=>{let f=r(c.key),p=r(d.key);return f!==p?f-p:s.indexOf(c)-s.indexOf(d)}),a=o.some((c,d)=>c!==s[d]);return{newFrontmatter:[...o.map(c=>c.text),...i.map(c=>c.text)].join(`
|
|
212
|
-
`),changed:a}}function
|
|
212
|
+
`),changed:a}}function tw(e,t={}){let s=[],i=[],n=e.replace(/\r\n/g,`
|
|
213
213
|
`);n!==e&&s.push({id:"normalise-line-endings",description:"Convert CRLF line endings to LF."});let r=n.split(`
|
|
214
214
|
`),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}=Iu(n),c=re(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 d=a;if(!!(c.version||c["metadata.version"])||(d=
|
|
215
|
+
`);let{rawFrontmatter:a,body:l}=Iu(n),c=re(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 d=a;if(!!(c.version||c["metadata.version"])||(d=jr(d,"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?(d=jr(d,"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=Zb(Lu(l));d=jr(d,"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 h=ew(d);h.changed&&(s.push({id:"reorder-frontmatter",description:"Reorder frontmatter fields to canonical order."}),d=h.newFrontmatter);let y=l.replace(/^\n+/,""),m=`---
|
|
216
216
|
${d.replace(/^\n+|\n+$/g,"")}
|
|
217
217
|
---
|
|
218
218
|
|
|
219
|
-
${y}`;return
|
|
220
|
-
`)||(
|
|
219
|
+
${y}`;return m.endsWith(`
|
|
220
|
+
`)||(m+=`
|
|
221
221
|
`),e.replace(/\r\n/g,`
|
|
222
|
-
`),{newContent:
|
|
222
|
+
`),{newContent:m,applied:s,skipped:i}}function jr(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
223
|
`)?"":`
|
|
224
224
|
`;return`${e}${r}${t}: ${n}
|
|
225
|
-
`}function
|
|
225
|
+
`}function sw(e,t,s="SKILL.md"){if(e===t)return"";let i=e.split(`
|
|
226
226
|
`),n=t.split(`
|
|
227
|
-
`),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),d=o+1,f=o+1;r.push(`@@ -${d},${l.length} +${f},${c.length} @@`);let p=i.slice(Math.max(0,o-3),o).map(y=>` ${y}`),
|
|
228
|
-
`)}async function Ou(e,t){let s=
|
|
229
|
-
`)}function
|
|
227
|
+
`),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),d=o+1,f=o+1;r.push(`@@ -${d},${l.length} +${f},${c.length} @@`);let p=i.slice(Math.max(0,o-3),o).map(y=>` ${y}`),h=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(...h),r.join(`
|
|
228
|
+
`)}async function Ou(e,t){let s=Kr(e)?e:Vr(e),i,n=await dt(s).catch(()=>null);if(!n)throw new Error(`Skill path does not exist: ${s}`);if(n.isFile())i=s;else if(n.isDirectory())i=pt(s,"SKILL.md");else throw new Error(`Skill path is not a directory or file: ${s}`);let r;try{r=await Br(i,"utf-8")}catch{throw new Error(`SKILL.md not found at ${i}.`)}let o=tw(r,{gitAuthor:t.gitAuthor}),a=sw(r,o.newContent),l=null;return!t.dryRun&&o.newContent!==r&&(l=`${i}.bak`,await qb(i,l),await _b(i,o.newContent,"utf-8")),{report:Xt({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 Tu(){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 iw(e,t,s=20){let i=Math.round(e/t*s);return"\u2588".repeat(i)+"\u2591".repeat(Math.max(0,s-i))}function yi(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} ${iw(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=nw(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(`
|
|
229
|
+
`)}function nw(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 Mu(e){return JSON.stringify(e,null,2)}function Du(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
230
|
`);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 Bu(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?
|
|
231
|
+
`)}async function rw(e){let t;try{t=await Nu(e)}catch{return[]}let s=[];for(let i of t){if(i.startsWith(".")||i==="node_modules"||i==="dist"||i==="build")continue;let n=pt(e,i),r;try{r=await dt(n)}catch{continue}if(!r.isDirectory())continue;let o=pt(n,"SKILL.md");try{(await dt(o)).isFile()&&s.push(n)}catch{}}return s.sort((i,n)=>we(i).localeCompare(we(n))),s}async function Au(e){let t=pt(e,"SKILL.md");try{if((await dt(t)).isFile())return{kind:"single",skillDirs:[e]}}catch{}let s=await rw(e);return s.length>0?{kind:"collection",skillDirs:s}:{kind:"none",skillDirs:[]}}function Hr(e){return e?!!(e.startsWith("github:")||/^https?:\/\/github\.com\//i.test(e)):!1}function Pu(e){return{skillPath:e,skillMdPath:pt(e,"SKILL.md"),label:we(e)}}async function _u(e,t={}){if(!e)throw new Error("resolveEvalInput: input must be a non-empty string");if(Hr(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 Au(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(Pu),isCollection:o.kind==="collection",cleanup:r.cleanup,provenance:{input:e,remote:!0,sourceRef:r.sourceRef,commitSha:r.commitSha,tempPath:r.rootDir}}}let s=Kr(e)?e:Vr(e),i;try{i=await dt(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 Au(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(Pu),isCollection:n.kind==="collection",cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}}}function qu(e){let t=e.filter(d=>d.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(d=>d.report.overallScore),r=n.reduce((d,f)=>d+f,0)/n.length,o=Math.round(r),a=[...t].sort((d,f)=>f.report.overallScore-d.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 Fu(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 ju(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(`
|
|
232
|
+
`)}function Bu(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?bi(t.report,null):null}))}}function bi(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 ow=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function aw(e){if(typeof e!="string")return null;let t=ow.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 lw(e,t){let s=aw(e);if(!s)throw new Error(`invalid semver: ${t} "${e}"`);return s}var Gr=new Map;function Wr(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("register: provider.id is required");if(lw(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=Gr.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),Gr.set(e.id,t)}function wi(){let e=[];for(let t of Gr.values())for(let s of t)e.push(s);return e}import{stat as cw}from"fs/promises";var Uu="quality",Vu="1.0.0",Ku=1;function uw(e){return e.topSuggestions.map(t=>({severity:"info",message:t}))}function fw(e){return e.categories.map(t=>({id:t.id,name:t.name,score:t.score,max:t.max}))}var Ju={id:Uu,version:Vu,schemaVersion:Ku,description:"Static linter for SKILL.md structure, description, and safety.",async applicable(e){try{return(await cw(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 Ru(e.skillPath);return{providerId:Uu,providerVersion:Vu,schemaVersion:Ku,score:s.overallScore,passed:s.grade!=="F",categories:fw(s),findings:uw(s),raw:s,startedAt:"",durationMs:0}}};var zu=Xr(xr(),1);import{readFile as dw,stat as pw}from"fs/promises";import{basename as mw}from"path";var Hu="skill-best-practice",Gu="1.1.0",Wu=1,hw=new Set(["name","description","license","allowed-tools","metadata","compatibility","effort"]),Yu=new Set(["low","medium","high","xhigh","max"]),Yr=250,gw=/^\d+\.\d+\.\d+$/;function yw(e){if(!e.startsWith("---"))return null;let t=e.split(`
|
|
233
233
|
`);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
|
-
`)&&!d.includes("\r")&&!d.includes("<")&&!d.includes(">")&&d.length<=1024;G(s,"description-shape","Description follows skill-best-practice formatting rules",
|
|
236
|
-
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function rf(e){return{timestamp:new Date().toISOString(),asm_version:
|
|
237
|
-
---`,3);return s===-1?"":t.slice(s+4)}async function
|
|
238
|
-
`,"utf-8"),I(`ingester: wrote index to ${a}`),{success:!0,repoIndex:r}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await oe(s)}}async function pf(){return(await
|
|
234
|
+
`)}function vi(e){return{severity:e.severity,message:e.message,code:e.id,categoryId:"validation"}}function G(e,t,s,i,n,r){e.push({id:t,label:s,passed:i,severity:n,message:r})}function ki(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 bw(e){let t=await dw(e.skillMdPath,"utf-8"),s=[],i=yw(t);if(i===null){G(s,"missing-frontmatter","Frontmatter exists",!1,"error","SKILL.md must start with a YAML frontmatter block.");let E=ki(e,s,null);return{score:0,passed:!1,findings:s.map(vi),raw:E}}G(s,"frontmatter-present","Frontmatter exists",!0,"error","SKILL.md contains a YAML frontmatter block.");let n;try{n=(0,zu.parse)(i)}catch(E){G(s,"invalid-yaml","Frontmatter parses as YAML",!1,"error",`Invalid YAML in frontmatter: ${E?.message??String(E)}`);let x=ki(e,s,null);return{score:0,passed:!1,findings:s.map(vi),raw:x}}if(!n||typeof n!="object"||Array.isArray(n)){G(s,"frontmatter-not-object","Frontmatter is a mapping",!1,"error","Frontmatter must parse to a YAML object.");let E=ki(e,s,null);return{score:0,passed:!1,findings:s.map(vi),raw:E}}let r=n;G(s,"frontmatter-object","Frontmatter is a mapping",!0,"error","Frontmatter parses to a YAML object.");let o=Object.keys(r).filter(E=>!hw.has(E));G(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(G(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;G(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,d=typeof c=="string"?c.trim():"";if(G(s,"description-present","Description is present and non-empty",d.length>0,"error",d.length>0?"Frontmatter includes a non-empty `description`.":"Frontmatter must include a non-empty string `description`."),d.length>0){let E=!d.includes(`
|
|
235
|
+
`)&&!d.includes("\r")&&!d.includes("<")&&!d.includes(">")&&d.length<=1024;G(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=d.length<=Yr;G(s,"description-runtime-budget","Description fits the runtime context budget",x,"warning",x?`Description is ${d.length} chars (target \u2264 ${Yr}).`:`Description is ${d.length} chars; target \u2264 ${Yr}. The /skills listing truncates tail-first, often chopping the negative-trigger clause.`)}let f=r.effort;G(s,"effort-enum","Effort uses the supported enum",f===void 0||typeof f=="string"&&Yu.has(f.trim()),"error",f===void 0||typeof f=="string"&&Yu.has(f.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;G(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 h=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:null,y=h?.version,m=typeof y=="string"||typeof y=="number"?String(y).trim():"",g=m.length>0;if(G(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=gw.test(m);G(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 "${m}".`)}let b=h?.author,v=typeof b=="string"&&b.trim().length>0;if(G(s,"metadata-author-present","metadata.author is present",v,"warning",v?"Frontmatter declares `metadata.author`.":"Add `metadata.author` (recommended for published skills) so users know who maintains the skill."),l.length>0){let E=mw(e.skillPath),x=E===l;G(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 w=/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(d);G(s,"negative-trigger-clause","Description includes a negative-trigger clause",w,"warning",w?"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=ki(e,s,r),k=S.checkCount===0?100:Math.round(S.passedChecks/S.checkCount*100),C=s.filter(E=>!E.passed).map(vi);return{score:k,passed:C.every(E=>E.severity!=="error"),findings:C,raw:S}}var Qu={id:Hu,version:Gu,schemaVersion:Wu,description:"Deterministic SKILL.md best-practice validation (rules aligned with the skill-creator standard, v1.7.1).",async applicable(e){try{return(await pw(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 bw(e);return{providerId:Hu,providerVersion:Gu,schemaVersion:Wu,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 Xu(){Wr(Ju),Wr(Qu)}var Zu=!1;function Si(){Zu||(Xu(),Zu=!0)}function $i(){return Si(),wi()}function ef(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function tf(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 xi(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"}))})]),d=Math.max(0,Math.round(performance.now()-n));if(c.kind==="timeout"){let p=o.signal.reason,h=p instanceof Error&&p.message==="timeout"?`provider timed out after ${s.timeoutMs}ms`:`provider aborted: ${ef(p)}`;return tf(r,i,d,h,p instanceof Error&&p.message==="timeout"?"timeout":"aborted")}let f=c.value;return{...f,providerId:r.id,providerVersion:r.version,schemaVersion:f.schemaVersion??r.schemaVersion,startedAt:i,durationMs:d}}catch(c){let d=Math.max(0,Math.round(performance.now()-n));return tf(r,i,d,ef(c),"provider-threw")}finally{a&&clearTimeout(a)}}function ww(e){return e>=90?"A":e>=80?"B":e>=65?"C":e>=50?"D":"F"}function sf(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 nf(e,t){return{providerId:e.providerId,providerVersion:e.providerVersion,schemaVersion:e.schemaVersion,passed:e.passed,overallScore:e.score,grade:ww(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 Zt(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 X={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(" ")+`
|
|
236
|
+
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function rf(e){return{timestamp:new Date().toISOString(),asm_version:Eo,duration_ms:Math.round(performance.now()-e)}}function z(e,t,s){let i={version:1,command:e,status:"ok",data:t,meta:rf(s)},n=process.stdout.isTTY?2:0;return JSON.stringify(i,null,n)}function Z(e,t,s,i,n){let r={version:1,command:e,status:"error",error:{code:t,message:s,...n!==void 0?{details:n}:{}},meta:rf(i)},o=process.stdout.isTTY?2:0;return JSON.stringify(r,null,o)}import{writeFile as Rw,mkdir as Ow,unlink as Tw,readFile as Mw,readdir as Dw}from"fs/promises";import{join as es}from"path";import{readdir as vw,readFile as kw}from"fs/promises";import{join as Sw}from"path";function zr(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var $w=10,xw=5,Ew=3,Cw=1;function Aw(e,t){let s=zr(e),i=zr(t.name),n=zr(t.description),r=0;for(let o of s)i.has(o)&&(r+=$w),n.has(o)&&(r+=Ew),t.name.toLowerCase().includes(o)&&(r+=xw),t.description.toLowerCase().includes(o)&&(r+=Cw);return r}async function of(e){let t=new Map,s;try{s=await vw(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=Sw(e,i);try{let r=await kw(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 Ei(){let e=await of(so()),t=await of(gt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var Pw=["license","creator","version"];function af(e){return Pw.includes(e)}function lf(e,t){return e[t]||""}function Nw(e,t){if(t.has){for(let s of t.has)if(af(s)&&!lf(e,s))return!1}if(t.missing){for(let s of t.missing)if(af(s)&&lf(e,s))return!1}return!0}function cf(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 Ci(e,t=20,s){let i=await Ei(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!Nw(a,s))continue;let l=r?1:Aw(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 uf(){return(await Ei()).reduce((t,s)=>t+s.skillCount,0)}var Iw=[{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 ff(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"),Lw(t).trim().length<20&&s.push("SKILL.md body too short (less than 20 chars of instructions)");for(let{label:n,pattern:r}of Iw)r.test(t)&&s.push(`malicious pattern detected: ${n}`);return{verified:s.length===0,reasons:s}}function Lw(e){let t=e.trimStart();if(!t.startsWith("---"))return t;let s=t.indexOf(`
|
|
237
|
+
---`,3);return s===-1?"":t.slice(s+4)}async function _w(){let e=gt();return await Ow(e,{recursive:!0}),e}async function df(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 _e(t),I(`ingester: discovering skills in ${s}`);let i=await cs(s);I(`ingester: found ${i.length} skills`);let n=[];for(let l of i){let c=es(s,l.relPath,"SKILL.md"),d="";try{d=await Mw(c,"utf-8")}catch{I(`ingester: could not read SKILL.md at ${c}`)}let f=ff(l,d);f.verified||I(`ingester: ${l.name} not verified: ${f.reasons.join(", ")}`);let p=typeof l.tokenCount=="number"?l.tokenCount:d?is(d):void 0,h,y;if(d){let m;try{m=await Dw(es(s,l.relPath))}catch{m=void 0}try{let g=Xt({content:d,skillPath:l.relPath||l.name,skillMdPath:c,rootEntries:m});h={overallScore:g.overallScore,grade:g.grade,categories:g.categories.map(b=>({id:b.id,name:b.name,score:b.score,max:b.max})),evaluatedAt:g.evaluatedAt,evaluatedVersion:l.version||void 0}}catch(g){I(`ingester: eval failed for ${l.name}: ${g}`)}try{let g={skillPath:es(s,l.relPath),skillMdPath:c},v=(await Promise.all(Zt($i()).map(async w=>(await w.applicable(g,{})).ok?xi(w,g):null))).filter(w=>w!==null).map(w=>nf(w,l.version||void 0));v.length>0&&(y=Object.fromEntries(v.filter(w=>w.providerId).map(w=>[w.providerId,w])))}catch(g){I(`ingester: provider eval failed for ${l.name}: ${g}`)}}n.push({name:l.name,description:l.description,version:l.version,license:l.license,creator:l.creator,compatibility:l.compatibility,allowedTools:l.allowedTools,installUrl:`github:${t.owner}/${t.repo}${t.ref?`#${t.ref}`:""}${l.relPath?`:${l.relPath}`:""}`,relPath:l.relPath,verified:f.verified,tokenCount:p,evalSummary:h,evalSummaries:y})}let r={repoUrl:t.cloneUrl,owner:t.owner,repo:t.repo,updatedAt:new Date().toISOString(),skillCount:n.length,skills:n},o=await _w(),a=es(o,`${t.owner}_${t.repo}.json`);return await Rw(a,JSON.stringify(r,null,2)+`
|
|
238
|
+
`,"utf-8"),I(`ingester: wrote index to ${a}`),{success:!0,repoIndex:r}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await oe(s)}}async function pf(){return(await Ei()).map(t=>({owner:t.owner,repo:t.repo,skillCount:t.skillCount,updatedAt:t.updatedAt})).sort((t,s)=>s.skillCount-t.skillCount)}async function mf(e,t){let s=gt(),i=es(s,`${e}_${t}.json`);try{return await Tw(i),!0}catch{return!1}}import{join as gf}from"path";function qw(e){switch(e){case"dangerous":return 3;case"warning":return 2;case"caution":return 1;default:return 0}}function Qr(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+qw(s.verdict),0)}}function Fw(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];r==="global"||r==="project"||r==="both"?s.flags.scope=r:($(`Invalid scope: "${r}". Must be global, 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 jw(){console.log(`${u.blueBold("agent-skill-manager")} (${u.bold("asm")}) ${Ti}
|
|
239
239
|
|
|
240
240
|
Interactive TUI and CLI for managing installed skills for AI coding agents.
|
|
241
241
|
|
|
@@ -280,11 +280,11 @@ ${u.bold("Global Options:")}
|
|
|
280
280
|
--sort <field> Sort by: name, version, or location (default: name)
|
|
281
281
|
--flat Show one row per tool instance (list, search)
|
|
282
282
|
-y, --yes Skip confirmation prompts
|
|
283
|
-
-V, --verbose Show debug output`)}function
|
|
283
|
+
-V, --verbose Show debug output`)}function Bw(){console.log(`${u.bold("Usage:")} asm list [options]
|
|
284
284
|
|
|
285
285
|
List all discovered skills. By default, skills installed across multiple
|
|
286
286
|
tools are grouped into a single row with tool badges. When more than
|
|
287
|
-
${
|
|
287
|
+
${Li} skills are present, a compact summary is
|
|
288
288
|
automatically prepended above the table.
|
|
289
289
|
|
|
290
290
|
${u.bold("Options:")}
|
|
@@ -314,7 +314,7 @@ ${u.bold("Examples:")}
|
|
|
314
314
|
asm list -s project ${u.dim("Only project-scoped skills")}
|
|
315
315
|
asm list --sort version ${u.dim("Sort by version")}
|
|
316
316
|
asm list --json ${u.dim("Output as JSON")}
|
|
317
|
-
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
317
|
+
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function Uw(){console.log(`${u.bold("Usage:")} asm search <query> [options]
|
|
318
318
|
|
|
319
319
|
Search both installed skills and the skill index. Results show installation
|
|
320
320
|
status and include copy-paste install commands for available skills.
|
|
@@ -337,7 +337,7 @@ ${u.bold("Examples:")}
|
|
|
337
337
|
asm search "test" --installed ${u.dim("Search installed skills only")}
|
|
338
338
|
asm search "test" --available ${u.dim("Search available skills only")}
|
|
339
339
|
asm search openspec --json ${u.dim("Output matches as JSON")}
|
|
340
|
-
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
340
|
+
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function Vw(){console.log(`${u.bold("Usage:")} asm inspect <skill-name> [options]
|
|
341
341
|
|
|
342
342
|
Show detailed information for a skill. The <skill-name> is the directory name.
|
|
343
343
|
Shows version, description, file count, and all provider installations.
|
|
@@ -351,7 +351,7 @@ ${u.bold("Options:")}
|
|
|
351
351
|
${u.bold("Examples:")}
|
|
352
352
|
asm inspect code-review ${u.dim("Show details for code-review")}
|
|
353
353
|
asm inspect code-review --json ${u.dim("Output as JSON")}
|
|
354
|
-
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function
|
|
354
|
+
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function Kw(){console.log(`${u.bold("Usage:")} asm uninstall <skill-name> [options]
|
|
355
355
|
|
|
356
356
|
Remove a skill and its associated rule files. Shows a removal plan
|
|
357
357
|
before proceeding and asks for confirmation.
|
|
@@ -365,7 +365,7 @@ ${u.bold("Options:")}
|
|
|
365
365
|
${u.bold("Examples:")}
|
|
366
366
|
asm uninstall code-review ${u.dim("Remove with confirmation")}
|
|
367
367
|
asm uninstall code-review -y ${u.dim("Remove without confirmation")}
|
|
368
|
-
asm uninstall code-review -s project ${u.dim("Remove project copy only")}`)}function
|
|
368
|
+
asm uninstall code-review -s project ${u.dim("Remove project copy only")}`)}function Jw(){console.log(`${u.bold("Usage:")} asm audit [subcommand] [options]
|
|
369
369
|
|
|
370
370
|
Detect duplicate skills or run security audits on installed/remote skills.
|
|
371
371
|
|
|
@@ -391,7 +391,7 @@ ${u.bold("Examples:")}
|
|
|
391
391
|
asm audit security code-review --json ${u.dim("Output audit as JSON")}
|
|
392
392
|
asm audit security code-review --machine ${u.dim("Machine-readable v1 envelope output")}
|
|
393
393
|
asm audit security https://github.com/user/skills/tree/main/skills/agent-config
|
|
394
|
-
${u.dim("Audit a skill from a subfolder URL")}`)}function
|
|
394
|
+
${u.dim("Audit a skill from a subfolder URL")}`)}function Hw(){console.log(`${u.bold("Usage:")} asm publish [path] [options]
|
|
395
395
|
|
|
396
396
|
Validate a skill, run a security audit, generate a registry manifest,
|
|
397
397
|
and open a PR against the asm-registry.
|
|
@@ -414,7 +414,7 @@ ${u.bold("Examples:")}
|
|
|
414
414
|
asm publish --dry-run ${u.dim("Preview manifest without side effects")}
|
|
415
415
|
asm publish --force ${u.dim("Override warning-level security findings")}
|
|
416
416
|
asm publish --json ${u.dim("Output as JSON")}
|
|
417
|
-
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
417
|
+
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function Gw(){console.log(`${u.bold("Usage:")} asm outdated [options]
|
|
418
418
|
|
|
419
419
|
Show which installed skills have newer versions available.
|
|
420
420
|
|
|
@@ -427,7 +427,7 @@ ${u.bold("Options:")}
|
|
|
427
427
|
${u.bold("Examples:")}
|
|
428
428
|
asm outdated ${u.dim("Show outdated skills")}
|
|
429
429
|
asm outdated --json ${u.dim("Output as JSON")}
|
|
430
|
-
asm outdated --machine ${u.dim("Machine-readable output")}`)}function
|
|
430
|
+
asm outdated --machine ${u.dim("Machine-readable output")}`)}function Ww(){console.log(`${u.bold("Usage:")} asm update [name...] [options]
|
|
431
431
|
|
|
432
432
|
Update outdated skills to their latest version with security re-audit.
|
|
433
433
|
|
|
@@ -461,19 +461,19 @@ ${u.bold("Options:")}
|
|
|
461
461
|
${u.bold("Examples:")}
|
|
462
462
|
asm config show ${u.dim("View current config")}
|
|
463
463
|
asm config edit ${u.dim("Edit in $EDITOR")}
|
|
464
|
-
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function yf(e){for(let t of e)t.warnings=await
|
|
465
|
-
${u.yellow(`${o.length} skill${o.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(r)}else if(e.flags.summary)console.log(
|
|
466
|
-
`))}}async function
|
|
467
|
-
`)),e.flags.flat?console.log(
|
|
468
|
-
${u.bold("Proceed with removal?")} [y/N] `);let a=await Q();a.toLowerCase()!=="y"&&a.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let o=await
|
|
464
|
+
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function yf(e){for(let t of e)t.warnings=await Nc(t)}async function zw(e){if(e.flags.help){Bw();return}let t=performance.now(),s=await B(),i=await ee(s,e.flags.scope);e.flags.provider&&e.command==="list"&&(i=i.filter(r=>r.provider===e.flags.provider)),await yf(i);let n=Pi(i,e.flags.sort);if(e.flags.machine){let r=n.map(o=>({name:o.name,version:o.version,description:o.description,scope:o.scope,provider:o.provider,path:o.path}));console.log(z("list",r,t));return}if(e.flags.json)console.log(W(n));else if(e.flags.flat){let r=Ii(n),o=n.filter(a=>a.warnings&&a.warnings.length>0);o.length>0&&(r+=`
|
|
465
|
+
${u.yellow(`${o.length} skill${o.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(r)}else if(e.flags.summary)console.log(Ri(n));else if(e.flags.groupBy){let{skills:r,hint:o}=ns(n,e.flags.limit);console.log(mo(r,e.flags.groupBy)),o&&console.log(o)}else if(e.flags.compact){let{skills:r,hint:o}=ns(n,e.flags.limit);console.log(po(r)),o&&console.log(o)}else{let r=[];n.length>Li&&(r.push(Ri(n,{showHint:!1})),r.push(""));let{skills:o,hint:a}=ns(n,e.flags.limit);r.push(ho(o)),a&&r.push(a),console.log(r.join(`
|
|
466
|
+
`))}}async function Qw(e){if(e.flags.help){Uw();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;i||(e.flags.machine&&(t?.(),console.log(Z("search",X.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 d=await B(),f=await ee(d,e.flags.scope);e.flags.provider&&(f=f.filter(h=>h.provider===e.flags.provider));let p=ro(f,i);o=Pi(p,e.flags.sort)}let a=[];if(r&&(a=await Ci(i),o.length>0)){let d=new Set(o.map(f=>f.name.toLowerCase()));a=a.filter(f=>!d.has(f.skill.name.toLowerCase()))}if(e.flags.machine){t?.();let d=o.map(p=>({name:p.name,description:p.description,source:"installed",url:null,match_count:1})),f=a.map(p=>({name:p.skill.name,description:p.skill.description,source:"index",url:p.skill.installUrl,match_count:1}));console.log(z("search",[...d,...f],s));return}if(e.flags.json){let d=o.map(p=>({name:p.name,description:p.description,version:p.version,scope:p.scope,provider:p.provider,status:"installed"})),f=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(W([...d,...f]));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}":
|
|
467
|
+
`)),e.flags.flat?console.log(Ii(o)):console.log(go(o,i))),c){l&&console.error("");let d=yo(a.map(f=>({name:f.skill.name,version:f.skill.version,description:f.skill.description,verified:f.skill.verified,repoLabel:`${f.repo.owner}/${f.repo.repo}`,installUrl:f.skill.installUrl})),i);console.error(d)}}async function Xw(e){if(e.flags.help){Vw();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 ee(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 yf(n),e.flags.json?console.log(W(n.length===1?n[0]:n)):console.log(await bo(n))}async function Zw(e){if(e.flags.help){Kw();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 ee(s,e.flags.scope),n=ao(t,i,s),r=await lo(n);r.length===0&&($(`Skill "${t}" not found or nothing to remove.`),process.exit(1)),console.error(u.bold("Removal plan:"));for(let a of r)console.error(` ${u.red("\u2022")} ${fo(a)}`);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(`
|
|
468
|
+
${u.bold("Proceed with removal?")} [y/N] `);let a=await Q();a.toLowerCase()!=="y"&&a.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let o=await Ni(n);for(let a of o)console.error(a);try{await vo(t)}catch{}console.error(u.green(`
|
|
469
469
|
Done.`))}function Q(){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(`
|
|
470
|
-
`)&&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()})}async function
|
|
471
|
-
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a
|
|
472
|
-
Done.`))}}async function
|
|
473
|
-
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function
|
|
474
|
-
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await Le(a.realPath,a.name);o.push(l)}if(e.flags.machine)console.log(z("audit security",
|
|
475
|
-
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
|
|
476
|
-
`);let a=await Le(o.realPath,o.name);e.flags.machine?console.log(z("audit security",
|
|
470
|
+
`)&&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()})}async function ev(e){if(e.flags.help){Jw();return}let t=performance.now(),s=e.subcommand??"duplicates";if(s==="security"){await tv(e,t);return}s!=="duplicates"&&($(`Unknown audit subcommand: "${s}". Use: duplicates, security`),process.exit(2));let i=await B(),n=await ee(i,"both"),r=Oi(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(z("audit duplicates",o,t));return}if(e.flags.json){console.log(xo(r));return}if(console.log($o(r)),e.flags.yes&&r.duplicateGroups.length>0){console.error(u.bold(`
|
|
471
|
+
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a=So(o.instances),l=a[0].path;for(let c=1;c<a.length;c++){let d=a[c],f=oo(d,i),p=await Ni(f,l);for(let h of p)console.error(h)}}console.error(u.green(`
|
|
472
|
+
Done.`))}}async function tv(e,t){let s=e.positional[0];e.flags.all?await sv(e,t):s?s.startsWith("github:")||s.startsWith("https://github.com/")?await iv(e,s,t):await nv(e,s,t):(e.flags.machine&&(console.log(Z("audit security",X.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.
|
|
473
|
+
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function sv(e,t){let s=await B(),i=await ee(s,e.flags.scope);if(i.length===0){e.flags.machine?console.log(z("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":""}...
|
|
474
|
+
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await Le(a.realPath,a.name);o.push(l)}if(e.flags.machine)console.log(z("audit security",Qr(o),t));else if(e.flags.json)console.log(JSON.stringify(o,null,2));else{for(let l of o)console.log(fi(l));let a={safe:0,caution:0,warning:0,dangerous:0};for(let l of o)a[l.verdict]++;console.log(u.bold(`
|
|
475
|
+
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 iv(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 ls(n),console.error(`Cloning ${t} for audit...`),i=await _e(n,e.flags.transport);let{join:r}=await import("path"),o=n.subpath?r(i,n.subpath):i,{name:a}=await qe(o),l=await Le(o,a,n.owner,n.repo);e.flags.machine?console.log(z("audit security",Qr([l]),s)):e.flags.json?console.log(Tr(l)):console.log(fi(l))}catch(n){e.flags.machine&&(console.log(Z("audit security",X.AUDIT_FAILED,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}finally{i&&await oe(i)}}async function nv(e,t,s){let i=await B(),r=(await ee(i,e.flags.scope)).filter(l=>l.dirName===t);r.length===0&&(e.flags.machine&&(console.log(Z("audit security",X.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)}...
|
|
476
|
+
`);let a=await Le(o.realPath,o.name);e.flags.machine?console.log(z("audit security",Qr([a]),s)):e.flags.json?console.log(Tr(a)):console.log(fi(a))}async function rv(e){if(e.flags.help){Yw();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(W(s));break}case"path":{console.log(ht());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 Q();i.toLowerCase()!=="y"&&i.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let s=eo();await io(s),console.error(u.green("Config reset to defaults."));break}case"edit":{let s=process.env.VISUAL||process.env.EDITOR||"vi",[i,n]=Co(s),r=ht();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 ov(){console.log(`${u.bold("Usage:")} asm install <source> [options]
|
|
477
477
|
|
|
478
478
|
Install a skill from a GitHub repository, the curated registry, or a local path.
|
|
479
479
|
|
|
@@ -545,27 +545,27 @@ ${u.bold("Subfolder URL:")}
|
|
|
545
545
|
${u.bold("Vercel skills CLI:")}
|
|
546
546
|
asm install github:user/skills --method vercel --skill my-skill
|
|
547
547
|
asm install https://github.com/user/skills -m vercel --skill my-skill -y
|
|
548
|
-
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function
|
|
549
|
-
${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:")} ${
|
|
550
|
-
${u.bold("Security warnings:")}`);let p=new Map;for(let
|
|
551
|
-
${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
|
|
552
|
-
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(d)}`),c=()=>{n?oe(n).finally(()=>process.exit(1)):process.exit(1)};process.on("SIGINT",c),process.on("SIGTERM",c);try{if(!
|
|
553
|
-
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:
|
|
554
|
-
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let
|
|
555
|
-
Select a skill [1-${
|
|
556
|
-
Did you mean: ${
|
|
557
|
-
`);for(let
|
|
548
|
+
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function av(e,t,s,i,n,r,o,a,l="global"){let c=await qe(i),d=await To(i),f=i===s?null:i.split(/[/\\]/).pop(),p=n||f||t.repo,h=Me(p),y=a.find(C=>C.name.toLowerCase()===c.name.toLowerCase()&&C.provider===o.name),m,g=!!y;y?y.version===c.version?m=e.flags.force?"REINSTALL":`UPDATE: ${y.version} (same version)`:m=`UPDATE: ${y.version} \u2192 ${c.version}`:m="NEW";let b=Ui(t,s,i,h,o,e.flags.force||g,l),v=d.some(C=>["Shell commands","Code execution","Credentials"].includes(C.category)),w=d.some(C=>["External URLs"].includes(C.category)),S=v?"high":w?"medium":"safe",k=v?u.red("[!] High Risk"):w?u.yellow("[~] Medium Risk"):u.green("[ok] Safe");return{metadata:c,skillName:h,warnings:d,installStatus:m,riskLevel:S,riskLabel:k,plan:b}}function lv(e,t,s,i,n,r){let{metadata:o,warnings:a,installStatus:l,riskLabel:c,plan:d}=e;if(n&&r){let f=u.dim(`[${r.index}/${r.total}]`),p=l==="NEW"?u.green(`[${l}]`):u.yellow(`[${l}]`);console.info(`${f} ${u.bold(o.name)} v${o.version} ${p} ${c}`)}else{let f=l==="NEW"?u.green(`[${l}]`):u.yellow(`[${l}]`);if(console.info(` ${u.bold(o.name)} v${o.version} ${f}`),console.info(`
|
|
549
|
+
${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:")} ${co(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:")} ${d.scope==="project"?"Project":"Global"}`),console.info(` ${u.bold("Target:")} ${d.targetDir}`),console.info(` ${u.bold("Status:")} ${f}`),console.info(` ${u.bold("Risk:")} ${c}`),a.length>0){console.info(`
|
|
550
|
+
${u.bold("Security warnings:")}`);let p=new Map;for(let h of a){let y=p.get(h.category)||[];y.push(h),p.set(h.category,y)}for(let[h,y]of p){let g=["Shell commands","Code execution","Credentials"].includes(h)?u.red(`[${h}]`):u.yellow(`[${h}]`);console.info(`
|
|
551
|
+
${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 cv(e,t){return t?await Mo(e,t):await us(e)}async function uv(e){if(e.flags.help){ov();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=d=>(a++,`
|
|
552
|
+
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(d)}`),c=()=>{n?oe(n).finally(()=>process.exit(1)):process.exit(1)};process.on("SIGINT",c),process.on("SIGTERM",c);try{if(!Bi(i)&&await Ro(i)&&(i=`./${i}`),Yt(i)){console.info(`
|
|
553
|
+
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:A,multipleMatches:N,suggestions:q}=await Tc(i,{noCache:e.flags.noCache});if(A){r="registry";let R=A.manifest,_=R.repository.replace("https://github.com/","");i=R.skill_path?`github:${_}#${R.commit}:${R.skill_path}`:`github:${_}#${R.commit}`,console.info(` ${u.green("\u2713")} Resolved: ${u.bold(`${R.author}/${R.name}`)} @ ${R.commit.slice(0,7)}`)}else if(N.length>0){console.info(`
|
|
554
|
+
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let R=N.slice(0,5);for(let ne=0;ne<R.length;ne++){let le=R[ne];console.info(` ${u.cyan(`${ne+1}.`)} ${u.bold(`${le.author}/${le.name}`)} \u2014 ${le.description}`)}process.stdin.isTTY||($(`Ambiguous skill name "${i}". Use a scoped name: asm install author/name`),process.exit(2));let _=`
|
|
555
|
+
Select a skill [1-${R.length}]: `;process.stderr.write(_);let ie=await new Promise(ne=>{let le="",ve=!1,ts=setTimeout(()=>{ve||(ve=!0,process.stdin.removeListener("data",mt),ne(le.trim()))},3e4);function mt(vf){le=vf.toString().trim(),ve||(ve=!0,clearTimeout(ts),process.stdin.removeListener("data",mt),ne(le))}process.stdin.setEncoding("utf-8"),process.stdin.on("data",mt)}),K=parseInt(ie,10);(isNaN(K)||K<1||K>R.length)&&($("Invalid selection. Aborting."),process.exit(2));let U=R[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 Cr(i)?($(`Skill "${i}" not found in the registry.`),q.length>0&&console.error(`
|
|
556
|
+
Did you mean: ${q.map(R=>u.cyan(R)).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 d=Te(i),f=!!d.isLocal;if(f){let A=d.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(q){throw q.code==="ENOENT"?new Error(`Path does not exist: ${A}`):q}}else await De(),d=await ls(d),console.info(` ${u.dim(i)}`);if(e.flags.method==="vercel"){console.info(l("Installing via Vercel skills CLI")),await Do();let A=qo(d),N=e.flags.path||null;console.info(` ${u.dim(`npx skills add ${A}${N?` --skill ${N}`:""}`)}`);let{stdout:q,stderr:R}=await _o(A,N);q.trim()&&console.info(` ${u.dim(q.trim())}`),R.trim()&&console.error(` ${u.dim(R.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:h,allProviders:y}=await Xe(p,e.flags.provider,!!process.stdin.isTTY);console.info(l("Selecting scope"));let m;if(e.flags.scope==="global"||e.flags.scope==="project")m=e.flags.scope,console.info(` ${u.dim(`scope: ${m}`)}${m==="global"?` (${h.global})`:` (${h.project})`}`);else if(!process.stdin.isTTY||e.flags.yes)m="global",console.info(` ${u.dim("scope: global (default)")} (${h.global})`);else{let A=[{label:`Global (${h.global})`,hint:"Available in all projects",checked:!0},{label:`Project (${h.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.");m=N[0]===0?"global":"project",console.info(` Selected: ${u.bold(m)} ${u.dim(`(${m==="global"?h.global:h.project})`)}`)}if(f)console.info(l("Reading local source")),console.info(` ${u.dim(d.localPath)}`),n=null;else{console.info(l("Cloning repository"));let A=e.flags.transport,N=A==="ssh"?d.sshCloneUrl:A==="https"?d.cloneUrl:`${d.cloneUrl} ${u.dim("(auto)")}`;console.info(` ${N}${d.ref?` ${u.dim(`(ref: ${d.ref})`)}`:""}${d.subpath?` ${u.dim(`(path: ${d.subpath})`)}`:""}`),n=await _e(d,A)}let g=f?d.localPath:n;console.info(l("Scanning for skills"));let{join:b}=await import("path"),v=[],w=e.flags.path||d.subpath,S=[],k=!1,C=g,E="";if(w){let A=b(g,w),N=!1;try{await qe(A),N=!0}catch{if(!e.flags.all)throw new Error(`No SKILL.md found at path "${w}" in the repository.`);let{stat:q}=await import("fs/promises");try{if(!(await q(A)).isDirectory())throw new Error(`No SKILL.md found at path "${w}" in the repository.`)}catch(R){throw R&&R.code==="ENOENT"?new Error(`No SKILL.md found at path "${w}" in the repository.`):R}k=!0,C=A,E=w}N&&(console.info(` Found skill at ${u.bold(w)}`),S=[{skillDir:A,nameOverride:e.flags.name}])}else{let A=!1;try{await qe(g),A=!0}catch{}if(A){let N=await qe(g);console.info(` Found: ${u.bold(N.name)} v${N.version}`),S=[{skillDir:g,nameOverride:e.flags.name}]}else k=!0}if(k){console.info(E?` No SKILL.md at ${u.bold(E)}. Scanning subdirectories...`:" No SKILL.md at root. Scanning subdirectories...");let A=await cs(C),N=E?A.map(_=>({..._,relPath:`${E}/${_.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):
|
|
557
|
+
`);for(let _=0;_<N.length;_++){let ie=u.cyan(` ${String(_+1).padStart(String(N.length).length)})`);console.info(`${ie} ${u.bold(N[_].name)} ${u.dim(`v${N[_].version}`)} ${u.dim(`(${N[_].relPath})`)}`),N[_].description&&console.info(` ${u.dim(N[_].description)}`)}console.info(l("Selecting skills")),a--;let q;if(e.flags.all&&(e.flags.yes||!process.stdin.isTTY))q=N.map(_=>_.relPath),console.info(` Selected all ${u.bold(String(q.length))} skills`);else if(process.stdin.isTTY)if(N.length===1)q=[N[0].relPath],console.info(` Auto-selected: ${u.bold(N[0].name)} ${u.dim(`v${N[0].version}`)}`);else{let _=N.map(K=>({label:K.name,hint:`v${K.version}${K.description?" "+K.description:""}`,checked:!!e.flags.all}));console.info("");let ie=await Qe({items:_});if(ie.length===0)throw new Error("No skills selected. Aborting.");q=ie.map(K=>N[K].relPath),console.info(` Selected ${u.bold(String(q.length))} skill(s)`)}else{$(`Repository contains ${N.length} skills. Use --path <subdir> to pick one or --all to install all.
|
|
558
558
|
Available skills:
|
|
559
|
-
${
|
|
560
|
-
`)}`),process.exit(2);return}let
|
|
559
|
+
${N.map(_=>` --path ${_.relPath}`).join(`
|
|
560
|
+
`)}`),process.exit(2);return}let R=Oo(q);if(R.length>0){let _=R.map(K=>` - ${K.name}: ${K.paths.map(U=>`"${U}"`).join(", ")}`).join(`
|
|
561
561
|
`),ie=new Error(`Duplicate skill names detected in selection:
|
|
562
|
-
${
|
|
563
|
-
Choose one path per skill name or install with --path.`);throw ie.duplicates=
|
|
564
|
-
${u.red("[!]")} ${u.bold(`Install ${
|
|
565
|
-
${u.bold(`Install ${
|
|
566
|
-
${u.yellow(`${
|
|
562
|
+
${_}
|
|
563
|
+
Choose one path per skill name or install with --path.`);throw ie.duplicates=R,ie}S=q.map(_=>({skillDir:b(g,_),nameOverride:q.length===1?e.flags.name:null})),a++}console.info(l("Inspecting skills"));let x=await ee(p,"both"),M=[],O=S.length>1;for(let A=0;A<S.length;A++){let{skillDir:N,nameOverride:q}=S[A],R=await av(e,d,g,N,q,p,h,x,m);M.push(R),lv(R,i,h,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(_=>_.label).join(", ")})`:` ${u.bold("Tool:")} ${h.label} (${h.name})`),console.info(` ${u.bold("Scope:")} ${m==="project"?"Project":"Global"}`);let A=M.filter(_=>_.riskLevel==="high").length,N=M.filter(_=>_.riskLevel==="medium").length,q=M.filter(_=>_.riskLevel==="safe").length,R=[];q>0&&R.push(u.green(`${q} Safe`)),N>0&&R.push(u.yellow(`${N} Medium Risk`)),A>0&&R.push(u.red(`${A} High Risk`)),console.info(` ${u.bold("Risk:")} ${R.join(", ")}`)}if(console.info(l("Installing")),!e.flags.yes){let A=M.some(_=>_.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}"`,q=A?`
|
|
564
|
+
${u.red("[!]")} ${u.bold(`Install ${N}? Some have high-risk patterns.`)} [y/N] `:`
|
|
565
|
+
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(q);let R=await Q();A?R.toLowerCase()!=="y"&&R.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)):(R.toLowerCase()==="n"||R.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let D=n?await ko(n):null,T=[];for(let A=0;A<M.length;A++){let N=M[A],q=O?u.dim(`[${A+1}/${M.length}]`)+" ":" ";try{console.info(`${q}Installing ${u.bold(N.metadata.name)}...`);let R=await cv(N.plan,y);v.push(R),console.info(`${q}${u.green("\u2713")} ${N.metadata.name} installed to ${u.dim(N.plan.targetDir)}`);try{let _=f?`local:${d.localPath}`:`github:${d.owner}/${d.repo}`,ie=f?"local":r==="registry"?"registry":"github";await yt(R.name,{source:_,commitHash:D||"unknown",ref:d.ref||"main",installedAt:new Date().toISOString(),provider:N.plan.providerName,sourceType:ie,...r==="registry"?{registryName:R.name}:{}})}catch{}}catch(R){T.push({name:N.metadata.name,error:R.message}),console.error(`${q}${u.red("\u2717")} ${u.bold(N.metadata.name)} \u2014 ${u.red(R.message)}`)}}if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),T.length>0){console.error(`
|
|
566
|
+
${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=v.map(N=>({name:N.name,path:N.path,version:N.version,provider:N.provider,source:N.source,resolution_source:r}));console.log(z("install",A.length===1?A[0]:A,s))}else if(e.flags.json){let A=v.map(N=>({...N,resolutionSource:r}));console.log(JSON.stringify(A.length===1?A[0]:A,null,2))}else v.length===1?console.error(u.green(`
|
|
567
567
|
Done! Installed "${v[0].name}" to ${v[0].path}`)):v.length>0&&console.error(`
|
|
568
|
-
${u.green(`Done! Installed ${v.length} skill(s) successfully.`)}`)}catch(d){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(Z("install",X.INSTALL_FAILED,d.message,s,d?.duplicates?{duplicates:d.duplicates}:void 0));else if(e.flags.json){let f={success:!1,error:d.message};d?.duplicates&&(f.duplicates=d.duplicates),console.log(JSON.stringify(f,null,2))}else
|
|
568
|
+
${u.green(`Done! Installed ${v.length} skill(s) successfully.`)}`)}catch(d){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(Z("install",X.INSTALL_FAILED,d.message,s,d?.duplicates?{duplicates:d.duplicates}:void 0));else if(e.flags.json){let f={success:!1,error:d.message};d?.duplicates&&(f.duplicates=d.duplicates),console.log(JSON.stringify(f,null,2))}else $(d.message);process.exit(1)}finally{n&&await oe(n),t?.()}}function fv(){console.log(`${u.bold("Usage:")} asm export [options]
|
|
569
569
|
|
|
570
570
|
Export skill inventory as a portable JSON manifest. Useful for backup,
|
|
571
571
|
sharing, or scripting.
|
|
@@ -578,7 +578,7 @@ ${u.bold("Options:")}
|
|
|
578
578
|
${u.bold("Examples:")}
|
|
579
579
|
asm export ${u.dim("Export all skills")}
|
|
580
580
|
asm export -s global ${u.dim("Export global skills only")}
|
|
581
|
-
asm export > skills.json ${u.dim("Save to file")}`)}async function
|
|
581
|
+
asm export > skills.json ${u.dim("Save to file")}`)}async function dv(e){if(e.flags.help){fv();return}let t=await B(),s=await ee(t,e.flags.scope),i=Mc(s);console.log(JSON.stringify(i,null,2))}function pv(){console.log(`${u.bold("Usage:")} asm import <file> [options]
|
|
582
582
|
|
|
583
583
|
Import skills from a previously exported JSON manifest. Recreates skill
|
|
584
584
|
installations based on the manifest metadata.
|
|
@@ -600,9 +600,9 @@ ${u.bold("Examples:")}
|
|
|
600
600
|
asm import skills.json --force ${u.dim("Overwrite existing skills")}
|
|
601
601
|
asm import skills.json -s global ${u.dim("Import only global skills")}
|
|
602
602
|
asm export > backup.json ${u.dim("Export first, then import later")}
|
|
603
|
-
asm import backup.json ${u.dim("Restore from backup")}`)}async function
|
|
604
|
-
${u.bold("Proceed?")} [y/N] `);let l=await Q();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await
|
|
605
|
-
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("!!!"),d=l.reason?` ${u.dim(l.reason)}`:"",f=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${d}${f}`)}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
|
|
603
|
+
asm import backup.json ${u.dim("Restore from backup")}`)}async function mv(e){if(e.flags.help){pv();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 Fc(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(`
|
|
604
|
+
${u.bold("Proceed?")} [y/N] `);let l=await Q();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await jc(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(`
|
|
605
|
+
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("!!!"),d=l.reason?` ${u.dim(l.reason)}`:"",f=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${d}${f}`)}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 hv(){console.log(`${u.bold("Usage:")} asm init <name> [options]
|
|
606
606
|
|
|
607
607
|
Scaffold a new skill directory with a SKILL.md template. Creates a
|
|
608
608
|
ready-to-edit skill in the target tool's skill folder.
|
|
@@ -617,8 +617,8 @@ ${u.bold("Options:")}
|
|
|
617
617
|
${u.bold("Examples:")}
|
|
618
618
|
asm init my-skill ${u.dim("Scaffold (interactive tool)")}
|
|
619
619
|
asm init my-skill -p claude ${u.dim("Scaffold in Claude Code")}
|
|
620
|
-
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function
|
|
621
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await Q();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await
|
|
620
|
+
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function gv(e){if(e.flags.help){hv();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-55HAAFSH.js"),l=a(n.providers.find(c=>c.name===r.name).global);i=o(l,s)}if(await Uc(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}`)}
|
|
621
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await Q();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await Bc(s,i),console.error(u.green(`Done! Created skill "${s}" at ${i}`))}function yv(){console.log(`${u.bold("Usage:")} asm stats [options]
|
|
622
622
|
|
|
623
623
|
Show aggregate skill metrics with provider distribution charts,
|
|
624
624
|
scope breakdown, disk usage, and duplicate summary.
|
|
@@ -632,7 +632,7 @@ ${u.bold("Options:")}
|
|
|
632
632
|
${u.bold("Examples:")}
|
|
633
633
|
asm stats ${u.dim("Show full dashboard")}
|
|
634
634
|
asm stats -s global ${u.dim("Global skills only")}
|
|
635
|
-
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function
|
|
635
|
+
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function bv(e){if(e.flags.help){yv();return}let t=await B(),s=await ee(t,e.flags.scope);if(s.length===0){console.log("No skills found.");return}let i=Oi(s),n=await Kc(s,i);if(e.flags.json)if(e.flags.verbose)console.log(W(n));else{let{perSkillDiskBytes:r,...o}=n;console.log(W(o))}else console.log(Jc(n))}function wv(){console.log(`${u.bold("Usage:")} asm doctor [options]
|
|
636
636
|
|
|
637
637
|
Run environment health checks and diagnostics. Validates all
|
|
638
638
|
prerequisites for using asm \u2014 git, GitHub CLI, Node.js, config,
|
|
@@ -647,7 +647,7 @@ ${u.bold("Options:")}
|
|
|
647
647
|
${u.bold("Examples:")}
|
|
648
648
|
asm doctor ${u.dim("Run all health checks")}
|
|
649
649
|
asm doctor --json ${u.dim("Output as JSON")}
|
|
650
|
-
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function
|
|
650
|
+
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function vv(e){if(e.flags.help){wv();return}let t=performance.now(),s=await Su();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(z("doctor",i,t))}else e.flags.json?console.log(xu(s)):console.log($u(s));s.failures>0&&process.exit(1)}function kv(){console.log(`${u.bold("Usage:")} asm eval <target> [options]
|
|
651
651
|
|
|
652
652
|
Evaluate a skill's SKILL.md against best practices and produce a scored quality
|
|
653
653
|
report with recommendations. Zero configuration \u2014 just point it at a skill
|
|
@@ -683,8 +683,8 @@ ${u.bold("Examples:")}
|
|
|
683
683
|
asm eval ./my-skill --fix ${u.dim("Auto-fix deterministic issues")}
|
|
684
684
|
asm eval ./my-skill --fix --dry-run ${u.dim("Preview fixes as diff")}
|
|
685
685
|
asm eval ./my-skill --machine ${u.dim("Machine-readable v1 envelope")}
|
|
686
|
-
asm eval-providers list ${u.dim("List registered eval providers")}`)}function
|
|
687
|
-
`))}function
|
|
686
|
+
asm eval-providers list ${u.dim("List registered eval providers")}`)}function Sv(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 $v(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 ls(i);let n=await _e(i,t),r=i.subpath?gf(n,i.subpath):n,o=null;try{let{execFile:c}=await import("child_process"),{promisify:d}=await import("util"),f=d(c),{stdout:p}=await f("git",["-C",n,"rev-parse","HEAD"],{timeout:5e3}),h=p.trim();/^[0-9a-f]{40}$/i.test(h)&&(o=h)}catch{}let a=`github:${i.owner}/${i.repo}${i.ref?`#${i.ref}`:""}${i.subpath?`:${i.subpath}`:""}`;return{rootDir:r,cleanup:async()=>{s||await oe(n)},sourceRef:a,commitSha:o}}async function hf(e){Si();try{let t={skillPath:e.skillPath,skillMdPath:e.skillMdPath},s=(await Promise.all(Zt($i()).map(async r=>(await r.applicable(t,{})).ok?xi(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 Sv(i),{report:{...i.raw,providers:Zt(s.map(sf))},error:null}}catch(t){return{report:null,error:t?.message??String(t)}}}async function xv(e){if(e.flags.help){kv();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;if(i||(e.flags.machine&&(t?.(),console.log(Z("eval",X.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(Hr(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(Z("eval",X.INVALID_ARGUMENT,r,s)),process.exit(2)),$(r),process.exit(2)}try{let r=await Tu(),o=await Ou(i,{dryRun:e.flags.dryRun,gitAuthor:r});if(e.flags.machine){t?.(),console.log(z("eval",bi(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(yi(o.report)),console.log(""),console.log(Du(o));return}catch(r){e.flags.machine&&(t?.(),console.log(Z("eval",X.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 _u(i,{fetchRemote:r=>$v(r,e.flags.transport,e.flags.keep)})}catch(r){e.flags.machine&&(t?.(),console.log(Z("eval",X.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:d,error:f}=await hf(c);if(!d)throw new Error(f??"eval failed");if(e.flags.machine){t?.();let p=bi(d,null),h=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(z("eval",h,s));return}if(e.flags.json){n.provenance.remote?console.log(JSON.stringify({...d,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(Mu(d));return}console.log(yi(d)),n.provenance.remote&&Ev(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 Fu(n.targets,r,async c=>{let{report:d,error:f}=await hf(c);return{label:c.label,skillPath:c.skillPath,report:d,error:f}}),a=qu(o),l={provenance:n.provenance,aggregate:a,results:o};if(e.flags.machine){t?.(),console.log(z("eval",Bu(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(yi(c.report)):(console.log(`Skill evaluation: ${c.skillPath}`),console.log(` ${u.red("error:")} ${c.error??"unknown failure"}`)),console.log("");console.log(ju(l)),n.provenance.remote&&e.flags.verbose}catch(r){e.flags.machine&&(t?.(),console.log(Z("eval",X.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 Ev(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(`
|
|
687
|
+
`))}function Cv(){console.log(`${u.bold("Usage:")} asm eval-providers <subcommand> [options]
|
|
688
688
|
|
|
689
689
|
Manage evaluation providers registered with the ${u.bold("asm eval")} framework.
|
|
690
690
|
Providers implement the ${u.bold("EvalProvider")} contract (see src/eval/types.ts) and
|
|
@@ -700,7 +700,7 @@ ${u.bold("Options:")}
|
|
|
700
700
|
|
|
701
701
|
${u.bold("Examples:")}
|
|
702
702
|
asm eval-providers list ${u.dim("Show registered providers")}
|
|
703
|
-
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function
|
|
703
|
+
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function Av(e){if(e.flags.help){Cv();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":{Si();let s=wi();if(e.flags.json){console.log(W(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 Pv(){console.log(`${u.bold("Usage:")} asm link <path> [<path2> ...] [options]
|
|
704
704
|
|
|
705
705
|
Symlink a local skill directory into an agent's skill folder. Useful
|
|
706
706
|
for local development \u2014 changes to the source are reflected immediately.
|
|
@@ -724,13 +724,13 @@ ${u.bold("Examples:")}
|
|
|
724
724
|
asm link ./my-skill -p claude ${u.dim("Link to Claude Code")}
|
|
725
725
|
asm link ./my-skill --name alias ${u.dim("Link with custom name")}
|
|
726
726
|
asm link ./my-skills-folder ${u.dim("Link all skills in folder")}
|
|
727
|
-
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function
|
|
728
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await Q();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function
|
|
727
|
+
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function Nv(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}`)}
|
|
728
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await Q();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function Ai(e,t,s,i){let{join:n}=await import("path"),r=n(t,s),o=await Nv(r,i);return await Wc(e,t,s,o),{name:s,symlinkPath:r,targetPath:e}}async function Iv(e){if(e.flags.help){Pv();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:m}=await Xe(y,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:g}=await import("./config-55HAAFSH.js"),b=g(y.providers.find(C=>C.name===m.name).global),{resolve:v,basename:w}=await import("path"),S=[],k=[];for(let C of t){let E=v(C),x=!1,M=null;try{await Nr(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){k.push({name:C,error:M}),e.flags.json||console.error(u.red(` Failed to process "${C}": ${M}`));continue}if(x){let O=w(E);try{let D=await Ai(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);k.push({name:O,error:T}),e.flags.json||console.error(u.red(` Failed to link "${O}": ${T}`))}}else{let O=[];try{O=await Ir(E)}catch(D){let T=D instanceof Error?D.message:String(D),A=T;T.startsWith("Path does not exist")&&Yt(C)&&(A=`${T} \u2014 "${C}" looks like a registry name; try "asm install ${C}" first.`),k.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.`;k.push({name:C,error:D}),e.flags.json||console.error(u.red(` ${D}`));continue}for(let D of O)try{let T=await Ai(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);k.push({name:D.name,error:A}),e.flags.json||console.error(u.red(` Failed to link "${D.name}": ${A}`))}}}e.flags.json?console.log(W({success:k.length===0,linked:S,failures:k})):k.length>0?console.error(u.yellow(`
|
|
729
729
|
${S.length} linked, ${k.length} failed.`)):console.error(u.green(`
|
|
730
|
-
Done! Linked ${S.length} skill(s) successfully.`)),k.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await
|
|
731
|
-
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await Q();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],
|
|
732
|
-
${p.length} linked, ${
|
|
733
|
-
Done! Linked ${p.length} skill(s) successfully.`)),
|
|
730
|
+
Done! Linked ${S.length} skill(s) successfully.`)),k.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await Nr(r),o=!0}catch(y){let m=y instanceof Error?y.message:String(y);m.startsWith("Path does not exist")||m.startsWith("Path is not a directory")||m.startsWith("No SKILL.md found")||($(m),process.exit(1))}let a=[];if(!o){try{a=await Ir(r)}catch(y){let m=y instanceof Error?y.message:String(y);m.startsWith("Path does not exist")?($(`No such skill or path: ${s}`),Yt(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.')):$(m),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:d}=await import("./config-55HAAFSH.js"),f=d(l.providers.find(y=>y.name===c.name).global);if(o){let y=e.flags.name?Me(e.flags.name):n(r),m;try{m=await Ai(r,f,y,!!e.flags.force)}catch(g){let b=g instanceof Error?g.message:String(g);e.flags.json?console.log(W({success:!1,error:b})):$(b),process.exit(2)}e.flags.json?console.log(W({success:!0,...m})):(console.error(u.green(`Done! Linked "${m.name}" -> ${m.targetPath}`)),console.error(` Symlink: ${m.symlinkPath}`),console.error(u.dim(` If you move or delete the source, run "asm uninstall ${m.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(`
|
|
731
|
+
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await Q();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],h=[];for(let y of a){let m=e.flags.name&&a.length===1?Me(e.flags.name):y.dirName;try{let g=await Ai(y.absPath,f,m,!!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);h.push({name:y.name,error:b}),e.flags.json||console.error(u.red(` Failed to link "${y.name}": ${b}`))}}e.flags.json?console.log(W({success:h.length===0,linked:p,failures:h})):h.length>0?console.error(u.yellow(`
|
|
732
|
+
${p.length} linked, ${h.length} failed.`)):console.error(u.green(`
|
|
733
|
+
Done! Linked ${p.length} skill(s) successfully.`)),h.length>0&&process.exit(1)}function Lv(){console.log(`${u.bold("Usage:")} asm index <subcommand> [options]
|
|
734
734
|
|
|
735
735
|
Manage the skill index for searching available skills from indexed repos.
|
|
736
736
|
|
|
@@ -754,10 +754,10 @@ ${u.bold("Examples:")}
|
|
|
754
754
|
asm index search marketing --has license ${u.dim("Only with license")}
|
|
755
755
|
asm index search "" --missing creator ${u.dim("Skills missing creator")}
|
|
756
756
|
asm index list ${u.dim("List indexed repos")}
|
|
757
|
-
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function
|
|
758
|
-
`));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
|
|
759
|
-
`)}}break}case"list":{let s=await pf();if(s.length===0){e.flags.json?console.log(
|
|
760
|
-
`));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||(
|
|
757
|
+
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function Rv(e){if(e.flags.help){Lv();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 df(s);i.success||($(`Failed to ingest: ${i.error}`),process.exit(1)),i.repoIndex&&(e.flags.json?console.log(W({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 Ci(s||"",20,i):await Ci(s);if(r.length===0){e.flags.json?console.log(W([])):(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(W(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:
|
|
758
|
+
`));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 wo(o.skill.description,80))console.error(` ${c}`);let l=cf(o.skill);l.length>0&&console.error(` ${u.yellow(`\u26A0 Missing: ${l.join(", ")}`)}`),console.error(` ${u.green(`asm install ${o.skill.installUrl}`)}
|
|
759
|
+
`)}}break}case"list":{let s=await pf();if(s.length===0){e.flags.json?console.log(W([])):(console.info("No repositories indexed."),console.error(u.dim("Add repos with: asm index ingest <repo>")));return}let i=await uf();if(e.flags.json)console.log(W(s));else{console.error(u.bold(`Indexed Repositories (${i} total skills):
|
|
760
|
+
`));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 Q();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await mf(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 Ov(){console.log(`${u.bold("Usage:")} asm bundle <subcommand> [options]
|
|
761
761
|
|
|
762
762
|
Create, install, and manage curated skill bundles. A bundle is a reusable
|
|
763
763
|
recipe of skills for a particular workflow, domain, or project setup.
|
|
@@ -793,14 +793,14 @@ ${u.bold("Examples:")}
|
|
|
793
793
|
asm bundle modify my-workflow --add github:u/r ${u.dim("Add a skill to bundle")}
|
|
794
794
|
asm bundle modify my-workflow --remove skill ${u.dim("Remove a skill from bundle")}
|
|
795
795
|
asm bundle export my-workflow ${u.dim("Export to ./my-workflow.json")}
|
|
796
|
-
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function
|
|
797
|
-
`));let g=await Qe({items:
|
|
798
|
-
${u.bold("Description")} (optional, press Enter to skip): `);let
|
|
796
|
+
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function Tv(e){if(e.flags.help){Ov();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 ee(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(m=>{let g=m.name.toLowerCase();return r.has(g)?!1:(r.add(g),!0)}),a=o;if(process.stdin.isTTY&&!e.flags.yes){let m=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}":
|
|
797
|
+
`));let g=await Qe({items:m});g.length===0&&($("No skills selected. Bundle not created."),process.exit(1)),a=g.map(b=>o[b])}let{readLock:l}=await import("./lock-SOHBB4N3.js"),c=await l(),d=await Promise.all(a.map(m=>Zc(m,c))),f=`Bundle of ${d.length} skills`,p="unknown";try{let{execSync:m}=await import("child_process"),g=m("git config user.name",{encoding:"utf-8"}).trim();g&&(p=g)}catch{}if(process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`
|
|
798
|
+
${u.bold("Description")} (optional, press Enter to skip): `);let m=await Q();m.trim()&&(f=m.trim()),process.stderr.write(`${u.bold("Author")} (optional, press Enter to skip): `);let g=await Q();g.trim()&&(p=g.trim())}let h=Xc(s,f,p,d),y=await Rr(h);e.flags.json?console.log(JSON.stringify(h,null,2)):(console.error(u.green(`Bundle "${s}" created with ${d.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 Qt(s)}catch(f){$(f.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 f of i.skills){let p=f.version?` v${f.version}`:"";console.error(` ${u.cyan(f.name)}${u.dim(p)} ${u.dim(`-> ${f.installUrl}`)}`)}if(!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
799
799
|
${u.bold("Install all skills from this bundle?")} [y/N] `);let f=await Q();f.toLowerCase()!=="y"&&f.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 f of i.skills){console.error(`
|
|
800
|
-
Installing ${u.bold(f.name)}...`);try{(f.installUrl.startsWith("github:")||f.installUrl.startsWith("https://github.com/"))&&await De();let
|
|
800
|
+
Installing ${u.bold(f.name)}...`);try{(f.installUrl.startsWith("github:")||f.installUrl.startsWith("https://github.com/"))&&await De();let h=Te(f.installUrl),y=!!h.isLocal,m=null;try{let g,b;y?(g=h.localPath,b=h.localPath):(m=await _e(h,e.flags.transport),g=m,b=h.subpath?gf(m,h.subpath):m);let v=await qe(b),w=Me(f.name||v.name||h.repo),S=Ui(h,g,b,w,o,e.flags.force,a);try{await Fo(S.targetDir,S.force)}catch(k){if(k.message?.includes("--force")){n.push({name:f.name,status:"skipped",reason:"Already installed. Use --force to overwrite."}),console.error(` ${u.dim("---")} ${f.name} skipped (already installed)`);continue}throw k}await us(S),n.push({name:f.name,status:"installed"}),console.error(` ${u.green("+++")} ${f.name} installed`)}finally{m&&await oe(m)}}catch(p){n.push({name:f.name,status:"failed",reason:p.message}),console.error(` ${u.red("!!!")} ${f.name}: ${p.message}`)}}let l=n.filter(f=>f.status==="installed").length,c=n.filter(f=>f.status==="skipped").length,d=n.filter(f=>f.status==="failed").length;e.flags.json?console.log(JSON.stringify({bundleName:i.name,total:n.length,installed:l,skipped:c,failed:d,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(d))} failed`)),d>0&&(process.exitCode=1);break}case"list":{if(!!e.flags.predefined){let n=await eu();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}):
|
|
801
801
|
`));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(`
|
|
802
802
|
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await tu();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}):
|
|
803
|
-
`));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||(
|
|
804
|
-
${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||(
|
|
805
|
-
`,"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
|
|
806
|
-
`)),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(Z("publish",X.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))
|
|
803
|
+
`));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 Qt(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(`
|
|
804
|
+
${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 Q();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await su(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 Qt(s)}catch(f){$(f.message),process.exit(1)}let n=!1,r=e.flags.add;if(r){let f={name:r.split("/").pop()?.replace(/\.json$/,"")??r,installUrl:r};i.skills.push(f),n=!0,console.error(u.green(`Added skill from ${r}`))}let o=e.flags.remove;if(o){let f=i.skills.length;i.skills=i.skills.filter(p=>p.name.toLowerCase()!==o.toLowerCase()),i.skills.length<f?(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(f=>f.trim()).filter(f=>f.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 f=await Q();f.trim()&&(i.description=f.trim(),n=!0),process.stderr.write(`${u.bold("New author")} (Enter to keep current): `);let p=await Q();p.trim()&&(i.author=p.trim(),n=!0),process.stderr.write(`${u.bold("New tags (comma-separated)")} (Enter to keep current): `);let h=await Q();h.trim()&&(i.tags=h.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 d=await Rr(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(d)}`));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 Qt(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 Q();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)+`
|
|
805
|
+
`,"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 Mv(e){if(e.flags.help){Hw();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand||".";try{let n=await lu({path:i,dryRun:e.flags.dryRun,force:e.flags.force,yes:e.flags.yes});if(e.flags.machine){t?.(),n.success||(console.log(Z("publish",X.PUBLISH_FAILED,n.error||"Publish failed",s,{manifest:n.manifest,security_verdict:n.securityVerdict,fallback:n.fallback??!1})),process.exit(1)),console.log(z("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(cu(n));return}if(e.flags.dryRun){console.error(u.dim(`Dry run \u2014 no PR created.
|
|
806
|
+
`)),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(Z("publish",X.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 Dv(e){if(e.flags.help){Gw();return}let t=e.flags.machine?Ye():void 0,s=performance.now();try{let i=await qr();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(z("outdated",r,s));return}if(e.flags.json){console.log(gu(i));return}let n=!e.flags.noColor&&process.stdout.isTTY!==!1;console.log(hu(i,n)),i.outdatedCount>0&&(process.exitCode=1)}catch(i){e.flags.machine&&(t?.(),console.log(Z("outdated",X.UNKNOWN_ERROR,i.message,s)),process.exit(1)),$(i.message),process.exit(1)}}async function _v(e){if(e.flags.help){Ww();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 mu(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(z("update",o,s));return}if(e.flags.json){console.log(yu(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(Z("update",X.UNKNOWN_ERROR,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}}async function bf(e){let t=Fw(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&&Zr(!0),t.flags.version){console.log(`asm ${Ti}`);let s=await hi();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(" Pick one package manager (npm OR bun) and remove the other install.")),console.error(u.dim(" See: https://github.com/luongnv89/asm#troubleshooting"))}return}if(!t.command&&t.flags.help){jw();return}if(t.command)switch(t.command){case"list":await zw(t);break;case"search":await Qw(t);break;case"inspect":await Xw(t);break;case"uninstall":await Zw(t);break;case"audit":await ev(t);break;case"install":await uv(t);break;case"config":await rv(t);break;case"export":await dv(t);break;case"import":await mv(t);break;case"init":await gv(t);break;case"stats":await bv(t);break;case"link":await Iv(t);break;case"index":await Rv(t);break;case"bundle":await Tv(t);break;case"publish":await Mv(t);break;case"outdated":await Dv(t);break;case"update":await _v(t);break;case"doctor":await vv(t);break;case"eval":await xv(t);break;case"eval-providers":await Av(t);break;default:$(`Unknown command: "${t.command}"`),console.error('Run "asm --help" for usage.'),process.exit(2)}}function wf(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"],i=t[0];return!!(s.includes(i)||i==="--help"||i==="-h"||i==="--version"||i==="-v"||i.startsWith("-")||i.length>0)}if(wf(process.argv))await bf(process.argv);else{let{main:e}=await import("./src-WHMVOOPJ.js");await e().catch(t=>{console.error("Fatal error:",t),process.exit(1)})}
|