agent-skill-manager 2.11.0 → 2.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -1
- package/data/skill-index/Affitor_affiliate-skills.json +8896 -14
- package/data/skill-index/Eronred_aso-skills.json +129 -129
- package/data/skill-index/GPTomics_bioSkills.json +4381 -3088
- package/data/skill-index/Galaxy-Dawn_claude-scholar.json +144 -144
- package/data/skill-index/Imbad0202_academic-research-skills.json +59 -59
- package/data/skill-index/K-Dense-AI_claude-scientific-skills.json +3061 -2429
- package/data/skill-index/Leonxlnx_taste-skill.json +47 -47
- package/data/skill-index/Master-cai_Research-Paper-Writing-Skills.json +4 -4
- package/data/skill-index/MiniMax-AI_skills.json +78 -78
- package/data/skill-index/Paramchoudhary_ResumeSkills.json +67 -67
- package/data/skill-index/affaan-m_everything-claude-code.json +5481 -4020
- package/data/skill-index/alirezarezvani_claude-skills.json +3293 -3293
- package/data/skill-index/anthropics_skills.json +85 -91
- package/data/skill-index/antonbabenko_terraform-skill.json +4 -4
- package/data/skill-index/badlogic_pi-skills.json +29 -29
- package/data/skill-index/briiirussell_cybersecurity-skills.json +96 -96
- package/data/skill-index/bytedance_deer-flow.json +419 -79
- package/data/skill-index/coreyhaines31_marketingskills.json +597 -239
- package/data/skill-index/entireio_skills.json +39 -39
- package/data/skill-index/github_awesome-copilot.json +3638 -2208
- package/data/skill-index/google_skills.json +279 -118
- package/data/skill-index/heygen-com_hyperframes.json +718 -407
- package/data/skill-index/himself65_finance-skills.json +84 -84
- package/data/skill-index/kemiljk_fluid-design.json +4 -4
- package/data/skill-index/kepano_obsidian-skills.json +19 -19
- package/data/skill-index/luongnv89_skills.json +102 -102
- package/data/skill-index/mattpocock_skills.json +100 -100
- package/data/skill-index/nextlevelbuilder_ui-ux-pro-max-skill.json +29 -29
- package/data/skill-index/obra_superpowers.json +82 -82
- package/data/skill-index/romainsimon_paperasse.json +26 -26
- package/data/skill-index/sickn33_antigravity-awesome-skills.json +14474 -8720
- package/data/skill-index/slavingia_skills.json +38 -38
- package/data/skill-index/warpdotdev_oz-skills.json +52 -52
- package/data/skill-index/zarazhangrui_follow-builders.json +4 -4
- package/dist/agent-skill-manager.js +186 -186
- package/dist/{chunk-E2P2XYIZ.js → chunk-5MMJGI6J.js} +1 -1
- package/dist/devtools-6JCLZ364.js +8 -0
- package/dist/{src-TIH4UJL5.js → src-NB45CVD2.js} +2 -2
- package/package.json +1 -1
- package/dist/devtools-W557IAG7.js +0 -8
|
@@ -1,76 +1,76 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __asmCreateRequire } from 'node:module'; const require = __asmCreateRequire(import.meta.url);
|
|
3
|
-
import{a as
|
|
4
|
-
`)}};kt.defaultYaml={explicit:!1,version:"1.2"};kt.defaultTags={"!!":"tag:yaml.org,2002:"};
|
|
5
|
-
`)?
|
|
3
|
+
import{a as De,b as wt,c as Mo,d as Do,e as Fo}from"./chunk-APSM2WG3.js";import{A as Lo,D as Oo,E as To,F as Y,G as Vi,H as _o,J as jo,K as qo,L as Bo,M as Ji,N as Uo,a as Z,b as ae,c as _i,d as bt,g as ee,h as vo,i as ji,j as ko,k as So,l as $o,m as qi,n as xo,o as u,p as Eo,q as Co,r as Ao,s as Bi,t as Ui,u as Ki,v as Po,w as No,x as os,y as Io,z as Ro}from"./chunk-5MMJGI6J.js";import{a as ho,b as P,c as go,d as gt,e as yo,f as Fi,g as yt,h as bo,k as oe,l as U,m as wo}from"./chunk-GHPE6SB3.js";import{a as rs,b as A,d as mo}from"./chunk-7BMOBFGJ.js";var _=A(z=>{"use strict";var tn=Symbol.for("yaml.alias"),fa=Symbol.for("yaml.document"),bs=Symbol.for("yaml.map"),pa=Symbol.for("yaml.pair"),sn=Symbol.for("yaml.scalar"),ws=Symbol.for("yaml.seq"),be=Symbol.for("yaml.node.type"),_f=e=>!!e&&typeof e=="object"&&e[be]===tn,jf=e=>!!e&&typeof e=="object"&&e[be]===fa,qf=e=>!!e&&typeof e=="object"&&e[be]===bs,Bf=e=>!!e&&typeof e=="object"&&e[be]===pa,ma=e=>!!e&&typeof e=="object"&&e[be]===sn,Uf=e=>!!e&&typeof e=="object"&&e[be]===ws;function ha(e){if(e&&typeof e=="object")switch(e[be]){case bs:case ws:return!0}return!1}function Kf(e){if(e&&typeof e=="object")switch(e[be]){case tn:case bs:case sn:case ws:return!0}return!1}var Vf=e=>(ma(e)||ha(e))&&!!e.anchor;z.ALIAS=tn;z.DOC=fa;z.MAP=bs;z.NODE_TYPE=be;z.PAIR=pa;z.SCALAR=sn;z.SEQ=ws;z.hasAnchor=Vf;z.isAlias=_f;z.isCollection=ha;z.isDocument=jf;z.isMap=qf;z.isNode=Kf;z.isPair=Bf;z.isScalar=ma;z.isSeq=Uf});var vt=A(nn=>{"use strict";var J=_(),ne=Symbol("break visit"),ga=Symbol("skip children"),he=Symbol("remove node");function vs(e,t){let s=ya(t);J.isDocument(e)?et(null,e.contents,s,Object.freeze([e]))===he&&(e.contents=null):et(null,e,s,Object.freeze([]))}vs.BREAK=ne;vs.SKIP=ga;vs.REMOVE=he;function et(e,t,s,i){let n=ba(e,t,s,i);if(J.isNode(n)||J.isPair(n))return wa(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=et(r,t.items[r],s,i);if(typeof o=="number")r=o-1;else{if(o===ne)return ne;o===he&&(t.items.splice(r,1),r-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let r=et("key",t.key,s,i);if(r===ne)return ne;r===he&&(t.key=null);let o=et("value",t.value,s,i);if(o===ne)return ne;o===he&&(t.value=null)}}return n}async function ks(e,t){let s=ya(t);J.isDocument(e)?await tt(null,e.contents,s,Object.freeze([e]))===he&&(e.contents=null):await tt(null,e,s,Object.freeze([]))}ks.BREAK=ne;ks.SKIP=ga;ks.REMOVE=he;async function tt(e,t,s,i){let n=await ba(e,t,s,i);if(J.isNode(n)||J.isPair(n))return wa(e,i,n),tt(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 tt(r,t.items[r],s,i);if(typeof o=="number")r=o-1;else{if(o===ne)return ne;o===he&&(t.items.splice(r,1),r-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let r=await tt("key",t.key,s,i);if(r===ne)return ne;r===he&&(t.key=null);let o=await tt("value",t.value,s,i);if(o===ne)return ne;o===he&&(t.value=null)}}return n}function ya(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 ba(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 wa(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`)}}nn.visit=vs;nn.visitAsync=ks});var rn=A(ka=>{"use strict";var va=_(),Jf=vt(),Hf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Wf=e=>e.replace(/[!,[\]{}]/g,t=>Hf[t]),kt=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+Wf(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&&va.isNode(t.contents)){let r={};Jf.visit(t.contents,(o,a)=>{va.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
|
+
`)}};kt.defaultYaml={explicit:!1,version:"1.2"};kt.defaultTags={"!!":"tag:yaml.org,2002:"};ka.Directives=kt});var Ss=A(St=>{"use strict";var Sa=_(),Gf=vt();function Yf(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 $a(e){let t=new Set;return Gf.visit(e,{Value(s,i){i.anchor&&t.add(i.anchor)}}),t}function xa(e,t){for(let s=1;;++s){let i=`${e}${s}`;if(!t.has(i))return i}}function zf(e,t){let s=[],i=new Map,n=null;return{onAnchor:r=>{s.push(r),n??(n=$a(e));let o=xa(t,n);return n.add(o),o},setAnchors:()=>{for(let r of s){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(Sa.isScalar(o.node)||Sa.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}}St.anchorIsValid=Yf;St.anchorNames=$a;St.createNodeAnchors=zf;St.findNewAnchor=xa});var on=A(Ea=>{"use strict";function $t(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=$t(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=$t(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=$t(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=$t(e,i,n,r);o===void 0?delete i[n]:o!==r&&(i[n]=o)}return e.call(t,s,i)}Ea.applyReviver=$t});var xe=A(Aa=>{"use strict";var Qf=_();function Ca(e,t,s){if(Array.isArray(e))return e.map((i,n)=>Ca(i,String(n),s));if(e&&typeof e.toJSON=="function"){if(!s||!Qf.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}Aa.toJS=Ca});var $s=A(Na=>{"use strict";var Xf=on(),Pa=_(),Zf=xe(),an=class{constructor(t){Object.defineProperty(this,Pa.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(!Pa.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=Zf.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof r=="function"?Xf.applyReviver(r,{"":a},"",a):a}};Na.NodeBase=an});var xt=A(Ia=>{"use strict";var ep=Ss(),tp=vt(),st=_(),sp=$s(),ip=xe(),ln=class extends sp.NodeBase{constructor(t){super(st.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=[],tp.visit(t,{Node:(r,o)=>{(st.isAlias(o)||st.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||(ip.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=xs(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(ep.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 xs(e,t,s){if(st.isAlias(t)){let i=t.resolve(e),n=s&&i&&s.get(i);return n?n.count*n.aliasCount:0}else if(st.isCollection(t)){let i=0;for(let n of t.items){let r=xs(e,n,s);r>i&&(i=r)}return i}else if(st.isPair(t)){let i=xs(e,t.key,s),n=xs(e,t.value,s);return Math.max(i,n)}return 1}Ia.Alias=ln});var V=A(cn=>{"use strict";var np=_(),rp=$s(),op=xe(),ap=e=>!e||typeof e!="function"&&typeof e!="object",Ee=class extends rp.NodeBase{constructor(t){super(np.SCALAR),this.value=t}toJSON(t,s){return s?.keep?this.value:op.toJS(this.value,t,s)}toString(){return String(this.value)}};Ee.BLOCK_FOLDED="BLOCK_FOLDED";Ee.BLOCK_LITERAL="BLOCK_LITERAL";Ee.PLAIN="PLAIN";Ee.QUOTE_DOUBLE="QUOTE_DOUBLE";Ee.QUOTE_SINGLE="QUOTE_SINGLE";cn.Scalar=Ee;cn.isScalarValue=ap});var Et=A(La=>{"use strict";var lp=xt(),Be=_(),Ra=V(),cp="tag:yaml.org,2002:";function up(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 dp(e,t,s){if(Be.isDocument(e)&&(e=e.contents),Be.isNode(e))return e;if(Be.isPair(e)){let d=s.schema[Be.MAP].createNode?.(s.schema,null,s);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:r,schema:o,sourceObjects:a}=s,l;if(i&&e&&typeof e=="object"){if(l=a.get(e),l)return l.anchor??(l.anchor=n(e)),new lp.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=cp+t.slice(2));let c=up(e,t,o.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new Ra.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?o[Be.MAP]:Symbol.iterator in Object(e)?o[Be.SEQ]:o[Be.MAP]}r&&(r(c),delete s.onTagObj);let f=c?.createNode?c.createNode(s.schema,e,s):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(s.schema,e,s):new Ra.Scalar(e);return t?f.tag=t:c.default||(f.tag=c.tag),l&&(l.node=f),f}La.createNode=dp});var Cs=A(Es=>{"use strict";var fp=Et(),ge=_(),pp=$s();function un(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 fp.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 Oa=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,dn=class extends pp.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=>ge.isNode(i)||ge.isPair(i)?i.clone(t):i),this.range&&(s.range=this.range.slice()),s}addIn(t,s){if(Oa(t))this.add(s);else{let[i,...n]=t,r=this.get(i,!0);if(ge.isCollection(r))r.addIn(n,s);else if(r===void 0&&this.schema)this.set(i,un(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(ge.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&&ge.isScalar(r)?r.value:r:ge.isCollection(r)?r.getIn(n,s):void 0}hasAllNullValues(t){return this.items.every(s=>{if(!ge.isPair(s))return!1;let i=s.value;return i==null||t&&ge.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 ge.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(ge.isCollection(r))r.setIn(n,s);else if(r===void 0&&this.schema)this.set(i,un(this.schema,n,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Es.Collection=dn;Es.collectionFromPath=un;Es.isEmptyPath=Oa});var Ct=A(As=>{"use strict";var mp=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function fn(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var hp=(e,t,s)=>e.endsWith(`
|
|
5
|
+
`)?fn(s,t):s.includes(`
|
|
6
6
|
`)?`
|
|
7
|
-
`+
|
|
8
|
-
`)s===
|
|
7
|
+
`+fn(s,t):(e.endsWith(" ")?"":" ")+s;As.indentComment=fn;As.lineComment=hp;As.stringifyComment=mp});var Ma=A(At=>{"use strict";var gp="flow",pn="block",Ps="quoted";function yp(e,t,s="flow",{indentAtStart:i,lineWidth:n=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!n||n<0)return e;n<r&&(r=0);let l=Math.max(1+r,1+n-t.length);if(e.length<=l)return e;let c=[],f={},d=n-t.length;typeof i=="number"&&(i>n-Math.max(2,r)?c.push(0):d=n-i);let p,m,y=!1,h=-1,g=-1,b=-1;s===pn&&(h=Ta(e,h,t.length),h!==-1&&(d=h+l));for(let k;k=e[h+=1];){if(s===Ps&&k==="\\"){switch(g=h,e[h+1]){case"x":h+=3;break;case"u":h+=5;break;case"U":h+=9;break;default:h+=1}b=h}if(k===`
|
|
8
|
+
`)s===pn&&(h=Ta(e,h,t.length)),d=h+t.length+l,p=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
|
|
9
9
|
`&&m!==" "){let S=e[h+1];S&&S!==" "&&S!==`
|
|
10
|
-
`&&S!==" "&&(p=h)}if(h>=d)if(p)c.push(p),d=p+l,p=void 0;else if(s===
|
|
11
|
-
${t}${e.slice(0,v)}`:(s===
|
|
12
|
-
${t}${e.slice(S+1,v)}`)}return w}function
|
|
13
|
-
`);i=t,n=t+1,r=e[n]}return i}At.FOLD_BLOCK=
|
|
14
|
-
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function Pt(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(
|
|
10
|
+
`&&S!==" "&&(p=h)}if(h>=d)if(p)c.push(p),d=p+l,p=void 0;else if(s===Ps){for(;m===" "||m===" ";)m=k,k=e[h+=1],y=!0;let S=h>b+1?h-2:g-1;if(f[S])return e;c.push(S),f[S]=!0,d=S+l,p=void 0}else y=!0}m=k}if(y&&a&&a(),c.length===0)return e;o&&o();let w=e.slice(0,c[0]);for(let k=0;k<c.length;++k){let S=c[k],v=c[k+1]||e.length;S===0?w=`
|
|
11
|
+
${t}${e.slice(0,v)}`:(s===Ps&&f[S]&&(w+=`${e[S]}\\`),w+=`
|
|
12
|
+
${t}${e.slice(S+1,v)}`)}return w}function Ta(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}At.FOLD_BLOCK=pn;At.FOLD_FLOW=gp;At.FOLD_QUOTED=Ps;At.foldFlowLines=yp});var Nt=A(Da=>{"use strict";var pe=V(),Ce=Ma(),Is=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Rs=e=>/^(%|---|\.\.\.)/m.test(e);function bp(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 Pt(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(Rs(e)?" ":""),o="",a=0;for(let l=0,c=s[l];c;c=s[++l])if(c===" "&&s[l+1]==="\\"&&s[l+2]==="n"&&(o+=s.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(s[l+1]){case"u":{o+=s.slice(a,l);let f=s.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=s.substr(l,6)}l+=5,a=l+1}break;case"n":if(i||s[l+2]==='"'||s.length<n)l+=1;else{for(o+=s.slice(a,l)+`
|
|
15
15
|
|
|
16
16
|
`;s[l+2]==="\\"&&s[l+3]==="n"&&s[l+4]!=='"';)o+=`
|
|
17
|
-
`,l+=2;o+=r,s[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+s.slice(a):s,i?o:
|
|
18
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return Pt(e,t);let s=t.indent||(
|
|
19
|
-
${s}`)+"'";return t.implicitKey?i:
|
|
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:Ce.foldFlowLines(o,r,Ce.FOLD_QUOTED,Is(t,!1))}function mn(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
18
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return Pt(e,t);let s=t.indent||(Rs(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
19
|
+
${s}`)+"'";return t.implicitKey?i:Ce.foldFlowLines(i,s,Ce.FOLD_FLOW,Is(t,!1))}function it(e,t){let{singleQuote:s}=t.options,i;if(s===!1)i=Pt;else{let n=e.includes('"'),r=e.includes("'");n&&!r?i=mn:r&&!n?i=Pt:i=s?mn:Pt}return i(e,t)}var hn;try{hn=new RegExp(`(^|(?<!
|
|
20
20
|
))
|
|
21
21
|
+(?!
|
|
22
|
-
|$)`,"g")}catch{
|
|
22
|
+
|$)`,"g")}catch{hn=/\n+(?!\n|$)/g}function Ns({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 it(s,i);let c=i.indent||(i.forceBlockIndent||Rs(s)?" ":""),f=o==="literal"?!0:o==="folded"||t===pe.Scalar.BLOCK_FOLDED?!1:t===pe.Scalar.BLOCK_LITERAL?!0:!bp(s,l,c.length);if(!s)return f?`|
|
|
23
23
|
`:`>
|
|
24
24
|
`;let d,p;for(p=s.length;p>0;--p){let v=s[p-1];if(v!==`
|
|
25
25
|
`&&v!==" "&&v!==" ")break}let m=s.substring(p),y=m.indexOf(`
|
|
26
26
|
`);y===-1?d="-":s===m||y!==m.length-1?(d="+",r&&r()):d="",m&&(s=s.slice(0,-m.length),m[m.length-1]===`
|
|
27
|
-
`&&(m=m.slice(0,-1)),m=m.replace(
|
|
27
|
+
`&&(m=m.slice(0,-1)),m=m.replace(hn,`$&${c}`));let h=!1,g,b=-1;for(g=0;g<s.length;++g){let v=s[g];if(v===" ")h=!0;else if(v===`
|
|
28
28
|
`)b=g;else break}let w=s.substring(0,b<g?b+1:g);w&&(s=s.substring(w.length),w=w.replace(/\n+/g,`$&${c}`));let S=(h?c?"2":"1":"")+d;if(e&&(S+=" "+a(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let v=s.replace(/\n+/g,`
|
|
29
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),C=!1,E=
|
|
29
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),C=!1,E=Is(i,!0);o!=="folded"&&t!==pe.Scalar.BLOCK_FOLDED&&(E.onOverflow=()=>{C=!0});let x=Ce.foldFlowLines(`${w}${v}${m}`,c,Ce.FOLD_BLOCK,E);if(!C)return`>${S}
|
|
30
30
|
${c}${x}`}return s=s.replace(/\n+/g,`$&${c}`),`|${S}
|
|
31
|
-
${c}${w}${s}${m}`}function
|
|
32
|
-
`)||f&&/[[\]{},]/.test(r))return
|
|
33
|
-
`)?
|
|
34
|
-
`))return
|
|
35
|
-
${l}`);if(o){let p=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:m,tags:y}=t.doc.schema;if(y.some(p)||m?.some(p))return
|
|
36
|
-
${t.indent}${a}`:a}
|
|
37
|
-
${a}:`):(g=`${g}:`,p&&(g+=Rt.lineComment(g,s.indent,c(p))));let b,w,k;
|
|
31
|
+
${c}${w}${s}${m}`}function wp(e,t,s,i){let{type:n,value:r}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=t;if(a&&r.includes(`
|
|
32
|
+
`)||f&&/[[\]{},]/.test(r))return it(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||f||!r.includes(`
|
|
33
|
+
`)?it(r,t):Ns(e,t,s,i);if(!a&&!f&&n!==pe.Scalar.PLAIN&&r.includes(`
|
|
34
|
+
`))return Ns(e,t,s,i);if(Rs(r)){if(l==="")return t.forceBlockIndent=!0,Ns(e,t,s,i);if(a&&l===c)return it(r,t)}let d=r.replace(/\n+/g,`$&
|
|
35
|
+
${l}`);if(o){let p=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:m,tags:y}=t.doc.schema;if(y.some(p)||m?.some(p))return it(r,t)}return a?d:Ce.foldFlowLines(d,l,Ce.FOLD_FLOW,Is(t,!1))}function vp(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!==pe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=pe.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case pe.Scalar.BLOCK_FOLDED:case pe.Scalar.BLOCK_LITERAL:return n||r?it(o.value,t):Ns(o,t,s,i);case pe.Scalar.QUOTE_DOUBLE:return Pt(o.value,t);case pe.Scalar.QUOTE_SINGLE:return mn(o.value,t);case pe.Scalar.PLAIN:return wp(o,t,s,i);default:return null}},c=l(a);if(c===null){let{defaultKeyType:f,defaultStringType:d}=t.options,p=n&&f||d;if(c=l(p),c===null)throw new Error(`Unsupported default string type ${p}`)}return c}Da.stringifyString=vp});var It=A(gn=>{"use strict";var kp=Ss(),Ae=_(),Sp=Ct(),$p=Nt();function xp(e,t){let s=Object.assign({blockQuote:!0,commentString:Sp.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 Ep(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(Ae.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 Cp(e,t,{anchors:s,doc:i}){if(!i.directives)return"";let n=[],r=(Ae.isScalar(e)||Ae.isCollection(e))&&e.anchor;r&&kp.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 Ap(e,t,s,i){if(Ae.isPair(e))return e.toString(t,s,i);if(Ae.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=Ae.isNode(e)?e:t.doc.createNode(e,{onTagObj:l=>n=l});n??(n=Ep(t.doc.schema.tags,r));let o=Cp(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):Ae.isScalar(r)?$p.stringifyString(r,t,s,i):r.toString(t,s,i);return o?Ae.isScalar(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
36
|
+
${t.indent}${a}`:a}gn.createStringifyContext=xp;gn.stringify=Ap});var qa=A(ja=>{"use strict";var we=_(),Fa=V(),_a=It(),Rt=Ct();function Pp({key:e,value:t},s,i,n){let{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:d}}=s,p=we.isNode(e)&&e.comment||null;if(d){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(we.isCollection(e)||!we.isNode(e)&&typeof e=="object"){let E="With simple keys, collection cannot be used as a key value";throw new Error(E)}}let m=!d&&(!e||p&&t==null&&!s.inFlow||we.isCollection(e)||(we.isScalar(e)?e.type===Fa.Scalar.BLOCK_FOLDED||e.type===Fa.Scalar.BLOCK_LITERAL:typeof e=="object"));s=Object.assign({},s,{allNullValues:!1,implicitKey:!m&&(d||!r),indent:a+l});let y=!1,h=!1,g=_a.stringify(e,s,()=>y=!0,()=>h=!0);if(!m&&!s.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(s.inFlow){if(r||t==null)return y&&i&&i(),g===""?"?":m?`? ${g}`:g}else if(r&&!d||t==null&&m)return g=`? ${g}`,p&&!y?g+=Rt.lineComment(g,s.indent,c(p)):h&&n&&n(),g;y&&(p=null),m?(p&&(g+=Rt.lineComment(g,s.indent,c(p))),g=`? ${g}
|
|
37
|
+
${a}:`):(g=`${g}:`,p&&(g+=Rt.lineComment(g,s.indent,c(p))));let b,w,k;we.isNode(t)?(b=!!t.spaceBefore,w=t.commentBefore,k=t.comment):(b=!1,w=null,k=null,t&&typeof t=="object"&&(t=o.createNode(t))),s.implicitKey=!1,!m&&!p&&we.isScalar(t)&&(s.indentAtStart=g.length+1),h=!1,!f&&l.length>=2&&!s.inFlow&&!m&&we.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(s.indent=s.indent.substring(2));let S=!1,v=_a.stringify(t,s,()=>S=!0,()=>h=!0),C=" ";if(p||b||w){if(C=b?`
|
|
38
38
|
`:"",w){let E=c(w);C+=`
|
|
39
39
|
${Rt.indentComment(E,s.indent)}`}v===""&&!s.inFlow?C===`
|
|
40
40
|
`&&k&&(C=`
|
|
41
41
|
|
|
42
42
|
`):C+=`
|
|
43
|
-
${s.indent}`}else if(!m&&
|
|
44
|
-
`),
|
|
43
|
+
${s.indent}`}else if(!m&&we.isCollection(t)){let E=v[0],x=v.indexOf(`
|
|
44
|
+
`),j=x!==-1,R=s.inFlow??t.flow??t.items.length===0;if(j||!R){let M=!1;if(j&&(E==="&"||E==="!")){let T=v.indexOf(" ");E==="&"&&T!==-1&&T<x&&v[T+1]==="!"&&(T=v.indexOf(" ",T+1)),(T===-1||x<T)&&(M=!0)}M||(C=`
|
|
45
45
|
${s.indent}`)}}else(v===""||v[0]===`
|
|
46
|
-
`)&&(C="");return g+=C+v,s.inFlow?S&&i&&i():k&&!S?g+=Rt.lineComment(g,s.indent,c(k)):h&&n&&n(),g}
|
|
46
|
+
`)&&(C="");return g+=C+v,s.inFlow?S&&i&&i():k&&!S?g+=Rt.lineComment(g,s.indent,c(k)):h&&n&&n(),g}ja.stringifyPair=Pp});var bn=A(yn=>{"use strict";var Ba=rs("process");function Np(e,...t){e==="debug"&&console.log(...t)}function Ip(e,t){(e==="debug"||e==="warn")&&(typeof Ba.emitWarning=="function"?Ba.emitWarning(t):console.warn(t))}yn.debug=Np;yn.warn=Ip});var Ms=A(Ts=>{"use strict";var Lt=_(),Ua=V(),Ls="<<",Os={identify:e=>e===Ls||typeof e=="symbol"&&e.description===Ls,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new Ua.Scalar(Symbol(Ls)),{addToJSMap:Ka}),stringify:()=>Ls},Rp=(e,t)=>(Os.identify(t)||Lt.isScalar(t)&&(!t.type||t.type===Ua.Scalar.PLAIN)&&Os.identify(t.value))&&e?.doc.schema.tags.some(s=>s.tag===Os.tag&&s.default);function Ka(e,t,s){if(s=e&&Lt.isAlias(s)?s.resolve(e.doc):s,Lt.isSeq(s))for(let i of s.items)wn(e,t,i);else if(Array.isArray(s))for(let i of s)wn(e,t,i);else wn(e,t,s)}function wn(e,t,s){let i=e&&Lt.isAlias(s)?s.resolve(e.doc):s;if(!Lt.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}Ts.addMergeToJSMap=Ka;Ts.isMergeKey=Rp;Ts.merge=Os});var kn=A(Ha=>{"use strict";var Lp=bn(),Va=Ms(),Op=It(),Ja=_(),vn=xe();function Tp(e,t,{key:s,value:i}){if(Ja.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,i);else if(Va.isMergeKey(e,s))Va.addMergeToJSMap(e,t,i);else{let n=vn.toJS(s,"",e);if(t instanceof Map)t.set(n,vn.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let r=Mp(s,n,e),o=vn.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 Mp(e,t,s){if(t===null)return"";if(typeof t!="object")return String(t);if(Ja.isNode(e)&&s?.doc){let i=Op.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)+'..."'),Lp.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)}Ha.addPairToJSMap=Tp});var Pe=A(Sn=>{"use strict";var Wa=Et(),Dp=qa(),Fp=kn(),Ds=_();function _p(e,t,s){let i=Wa.createNode(e,void 0,s),n=Wa.createNode(t,void 0,s);return new Fs(i,n)}var Fs=class e{constructor(t,s=null){Object.defineProperty(this,Ds.NODE_TYPE,{value:Ds.PAIR}),this.key=t,this.value=s}clone(t){let{key:s,value:i}=this;return Ds.isNode(s)&&(s=s.clone(t)),Ds.isNode(i)&&(i=i.clone(t)),new e(s,i)}toJSON(t,s){let i=s?.mapAsMap?new Map:{};return Fp.addPairToJSMap(s,i,this)}toString(t,s,i){return t?.doc?Dp.stringifyPair(this,t,s,i):JSON.stringify(this)}};Sn.Pair=Fs;Sn.createPair=_p});var $n=A(Ya=>{"use strict";var Ue=_(),Ga=It(),_s=Ct();function jp(e,t,s){return(t.inFlow??e.flow?Bp:qp)(e,t,s)}function qp({comment:e,items:t},s,{blockItemPrefix:i,flowChars:n,itemIndent:r,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=s,f=Object.assign({},s,{indent:r,type:null}),d=!1,p=[];for(let y=0;y<t.length;++y){let h=t[y],g=null;if(Ue.isNode(h))!d&&h.spaceBefore&&p.push(""),js(s,p,h.commentBefore,d),h.comment&&(g=h.comment);else if(Ue.isPair(h)){let w=Ue.isNode(h.key)?h.key:null;w&&(!d&&w.spaceBefore&&p.push(""),js(s,p,w.commentBefore,d))}d=!1;let b=Ga.stringify(h,f,()=>g=null,()=>d=!0);g&&(b+=_s.lineComment(b,r,c(g))),d&&g&&(d=!1),p.push(i+b)}let m;if(p.length===0)m=n.start+n.end;else{m=p[0];for(let y=1;y<p.length;++y){let h=p[y];m+=h?`
|
|
47
47
|
${l}${h}`:`
|
|
48
48
|
`}}return e?(m+=`
|
|
49
|
-
`+
|
|
50
|
-
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=d.reduce((w,k)=>w+k.length+2,2)+(b.length+2)>t.options.lineWidth)),c&&(b+=",")),g&&(b+=
|
|
49
|
+
`+_s.indentComment(c(e),l),a&&a()):d&&o&&o(),m}function Bp({items:e},t,{flowChars:s,itemIndent:i}){let{indent:n,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=t;i+=r;let l=Object.assign({},t,{indent:i,inFlow:!0,type:null}),c=!1,f=0,d=[];for(let y=0;y<e.length;++y){let h=e[y],g=null;if(Ue.isNode(h))h.spaceBefore&&d.push(""),js(t,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(Ue.isPair(h)){let w=Ue.isNode(h.key)?h.key:null;w&&(w.spaceBefore&&d.push(""),js(t,d,w.commentBefore,!1),w.comment&&(c=!0));let k=Ue.isNode(h.value)?h.value:null;k?(k.comment&&(g=k.comment),k.commentBefore&&(c=!0)):h.value==null&&w?.comment&&(g=w.comment)}g&&(c=!0);let b=Ga.stringify(h,l,()=>g=null);c||(c=d.length>f||b.includes(`
|
|
50
|
+
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=d.reduce((w,k)=>w+k.length+2,2)+(b.length+2)>t.options.lineWidth)),c&&(b+=",")),g&&(b+=_s.lineComment(b,i,a(g))),d.push(b),f=d.length}let{start:p,end:m}=s;if(d.length===0)return p+m;if(!c){let y=d.reduce((h,g)=>h+g.length+2,2);c=t.options.lineWidth>0&&y>t.options.lineWidth}if(c){let y=p;for(let h of d)y+=h?`
|
|
51
51
|
${r}${n}${h}`:`
|
|
52
52
|
`;return`${y}
|
|
53
|
-
${n}${m}`}else return`${p}${o}${d.join(" ")}${o}${m}`}function
|
|
54
|
-
`:" ")}return
|
|
53
|
+
${n}${m}`}else return`${p}${o}${d.join(" ")}${o}${m}`}function js({indent:e,options:{commentString:t}},s,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let r=_s.indentComment(t(i),e);s.push(r.trimStart())}}Ya.stringifyCollection=jp});var Ie=A(En=>{"use strict";var Up=$n(),Kp=kn(),Vp=Cs(),Ne=_(),qs=Pe(),Jp=V();function Ot(e,t){let s=Ne.isScalar(t)?t.value:t;for(let i of e)if(Ne.isPair(i)&&(i.key===t||i.key===s||Ne.isScalar(i.key)&&i.key.value===s))return i}var xn=class extends Vp.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Ne.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(qs.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;Ne.isPair(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new qs.Pair(t,t?.value):i=new qs.Pair(t.key,t.value);let n=Ot(this.items,i.key),r=this.schema?.sortMapEntries;if(n){if(!s)throw new Error(`Key ${i.key} already set`);Ne.isScalar(n.value)&&Jp.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=Ot(this.items,t);return s?this.items.splice(this.items.indexOf(s),1).length>0:!1}get(t,s){let n=Ot(this.items,t)?.value;return(!s&&Ne.isScalar(n)?n.value:n)??void 0}has(t){return!!Ot(this.items,t)}set(t,s){this.add(new qs.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)Kp.addPairToJSMap(s,n,r);return n}toString(t,s,i){if(!t)return JSON.stringify(this);for(let n of this.items)if(!Ne.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})),Up.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:s})}};En.YAMLMap=xn;En.findPair=Ot});var nt=A(Qa=>{"use strict";var Hp=_(),za=Ie(),Wp={collection:"map",default:!0,nodeClass:za.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return Hp.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,s)=>za.YAMLMap.from(e,t,s)};Qa.map=Wp});var Re=A(Xa=>{"use strict";var Gp=Et(),Yp=$n(),zp=Cs(),Us=_(),Qp=V(),Xp=xe(),Cn=class extends zp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Us.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let s=Bs(t);return typeof s!="number"?!1:this.items.splice(s,1).length>0}get(t,s){let i=Bs(t);if(typeof i!="number")return;let n=this.items[i];return!s&&Us.isScalar(n)?n.value:n}has(t){let s=Bs(t);return typeof s=="number"&&s<this.items.length}set(t,s){let i=Bs(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];Us.isScalar(n)&&Qp.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(Xp.toJS(r,String(n++),s));return i}toString(t,s,i){return t?Yp.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(Gp.createNode(a,void 0,i))}}return r}};function Bs(e){let t=Us.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}Xa.YAMLSeq=Cn});var rt=A(el=>{"use strict";var Zp=_(),Za=Re(),em={collection:"seq",default:!0,nodeClass:Za.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return Zp.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,s)=>Za.YAMLSeq.from(e,t,s)};el.seq=em});var Tt=A(tl=>{"use strict";var tm=Nt(),sm={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),tm.stringifyString(e,t,s,i)}};tl.string=sm});var Ks=A(nl=>{"use strict";var sl=V(),il={identify:e=>e==null,createNode:()=>new sl.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new sl.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&il.test.test(e)?e:t.options.nullStr};nl.nullTag=il});var An=A(ol=>{"use strict";var im=V(),rl={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new im.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&rl.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?s.options.trueStr:s.options.falseStr}};ol.boolTag=rl});var ot=A(al=>{"use strict";function nm({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}al.stringifyNumber=nm});var Nn=A(Vs=>{"use strict";var rm=V(),Pn=ot(),om={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},am={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():Pn.stringifyNumber(e)}},lm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new rm.Scalar(parseFloat(e)),s=e.indexOf(".");return s!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-s-1),t},stringify:Pn.stringifyNumber};Vs.float=lm;Vs.floatExp=am;Vs.floatNaN=om});var Rn=A(Hs=>{"use strict";var ll=ot(),Js=e=>typeof e=="bigint"||Number.isInteger(e),In=(e,t,s,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),s);function cl(e,t,s){let{value:i}=e;return Js(i)&&i>=0?s+i.toString(t):ll.stringifyNumber(e)}var cm={identify:e=>Js(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>In(e,2,8,s),stringify:e=>cl(e,8,"0o")},um={identify:Js,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>In(e,0,10,s),stringify:ll.stringifyNumber},dm={identify:e=>Js(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>In(e,2,16,s),stringify:e=>cl(e,16,"0x")};Hs.int=um;Hs.intHex=dm;Hs.intOct=cm});var dl=A(ul=>{"use strict";var fm=nt(),pm=Ks(),mm=rt(),hm=Tt(),gm=An(),Ln=Nn(),On=Rn(),ym=[fm.map,mm.seq,hm.string,pm.nullTag,gm.boolTag,On.intOct,On.int,On.intHex,Ln.floatNaN,Ln.floatExp,Ln.float];ul.schema=ym});var ml=A(pl=>{"use strict";var bm=V(),wm=nt(),vm=rt();function fl(e){return typeof e=="bigint"||Number.isInteger(e)}var Ws=({value:e})=>JSON.stringify(e),km=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Ws},{identify:e=>e==null,createNode:()=>new bm.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Ws},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Ws},{identify:fl,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})=>fl(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:Ws}],Sm={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},$m=[wm.map,vm.seq].concat(km,Sm);pl.schema=$m});var Mn=A(hl=>{"use strict";var Mt=rs("buffer"),Tn=V(),xm=Nt(),Em={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Mt.Buffer=="function")return Mt.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 Mt.Buffer=="function")a=o instanceof Mt.Buffer?o.toString("base64"):Mt.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=Tn.Scalar.BLOCK_LITERAL),t!==Tn.Scalar.QUOTE_DOUBLE){let l=Math.max(i.options.lineWidth-i.indent.length,i.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let d=0,p=0;d<c;++d,p+=l)f[d]=a.substr(p,l);a=f.join(t===Tn.Scalar.BLOCK_LITERAL?`
|
|
54
|
+
`:" ")}return xm.stringifyString({comment:e,type:t,value:a},i,n,r)}};hl.binary=Em});var zs=A(Ys=>{"use strict";var Gs=_(),Dn=Pe(),Cm=V(),Am=Re();function gl(e,t){if(Gs.isSeq(e))for(let s=0;s<e.items.length;++s){let i=e.items[s];if(!Gs.isPair(i)){if(Gs.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new Dn.Pair(new Cm.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]=Ys.isPair(i)?i:new Tn.Pair(i)}}else t("Expected a sequence for this tag");return e}function hl(e,t,s){let{replacer:i}=s,n=new Cm.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(Tn.createPair(a,l,s))}return n}var Am={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ml,createNode:hl};zs.createPairs=hl;zs.pairs=Am;zs.resolvePairs=ml});var Fn=P(Dn=>{"use strict";var gl=j(),Mn=Se(),Dt=Pe(),Pm=Ne(),yl=Qs(),Be=class e extends Pm.YAMLSeq{constructor(){super(),this.add=Dt.YAMLMap.prototype.add.bind(this),this.delete=Dt.YAMLMap.prototype.delete.bind(this),this.get=Dt.YAMLMap.prototype.get.bind(this),this.has=Dt.YAMLMap.prototype.has.bind(this),this.set=Dt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,s){if(!s)return super.toJSON(t);let i=new Map;s?.onCreate&&s.onCreate(i);for(let n of this.items){let r,o;if(gl.isPair(n)?(r=Mn.toJS(n.key,"",s),o=Mn.toJS(n.value,r,s)):r=Mn.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=yl.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var Nm={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=yl.resolvePairs(e,t),i=[];for(let{key:n}of s.items)gl.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)};Dn.YAMLOMap=Be;Dn.omap=Nm});var Sl=P(_n=>{"use strict";var bl=K();function wl({value:e,source:t},s){return t&&(e?vl:kl).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var vl={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 bl.Scalar(!0),stringify:wl},kl={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 bl.Scalar(!1),stringify:wl};_n.falseTag=kl;_n.trueTag=vl});var $l=P(Xs=>{"use strict";var Im=K(),jn=rt(),Rm={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:jn.stringifyNumber},Lm={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():jn.stringifyNumber(e)}},Om={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Im.Scalar(parseFloat(e.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:jn.stringifyNumber};Xs.float=Om;Xs.floatExp=Lm;Xs.floatNaN=Rm});var El=P(_t=>{"use strict";var xl=rt(),Ft=e=>typeof e=="bigint"||Number.isInteger(e);function Zs(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 qn(e,t,s){let{value:i}=e;if(Ft(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return xl.stringifyNumber(e)}var Tm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Zs(e,2,2,s),stringify:e=>qn(e,2,"0b")},Mm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Zs(e,1,8,s),stringify:e=>qn(e,8,"0")},Dm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Zs(e,0,10,s),stringify:xl.stringifyNumber},Fm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Zs(e,2,16,s),stringify:e=>qn(e,16,"0x")};_t.int=Dm;_t.intBin=Tm;_t.intHex=Fm;_t.intOct=Mm});var Un=P(Bn=>{"use strict";var si=j(),ei=Ce(),ti=Pe(),Ue=class e extends ti.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;si.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new ei.Pair(t.key,null):s=new ei.Pair(t,null),ti.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=ti.findPair(this.items,t);return!s&&si.isPair(i)?si.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=ti.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new ei.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(ei.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var _m={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(si.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}};Bn.YAMLSet=Ue;Bn.set=_m});var Vn=P(ii=>{"use strict";var jm=rt();function Kn(e,t){let s=e[0],i=s==="-"||s==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return s==="-"?n(-1)*r:r}function Cl(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return jm.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 qm={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})=>Kn(e,s),stringify:Cl},Bm={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=>Kn(e,!1),stringify:Cl},Al={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(Al.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,n,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,i-1,n,r||0,o||0,a||0,l),f=t[8];if(f&&f!=="Z"){let d=Kn(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ii.floatTime=Bm;ii.intTime=qm;ii.timestamp=Al});var Il=P(Nl=>{"use strict";var Um=it(),Km=Vs(),Vm=nt(),Jm=Tt(),Hm=On(),Pl=Sl(),Jn=$l(),ni=El(),Wm=Ds(),Gm=Fn(),Ym=Qs(),zm=Un(),Hn=Vn(),Qm=[Um.map,Vm.seq,Jm.string,Km.nullTag,Pl.trueTag,Pl.falseTag,ni.intBin,ni.intOct,ni.int,ni.intHex,Jn.floatNaN,Jn.floatExp,Jn.float,Hm.binary,Wm.merge,Gm.omap,Ym.pairs,zm.set,Hn.intTime,Hn.floatTime,Hn.timestamp];Nl.schema=Qm});var ql=P(Yn=>{"use strict";var Tl=it(),Xm=Vs(),Ml=nt(),Zm=Tt(),eh=En(),Wn=An(),Gn=Nn(),th=cl(),sh=fl(),Dl=On(),jt=Ds(),Fl=Fn(),_l=Qs(),Rl=Il(),jl=Un(),ri=Vn(),Ll=new Map([["core",th.schema],["failsafe",[Tl.map,Ml.seq,Zm.string]],["json",sh.schema],["yaml11",Rl.schema],["yaml-1.1",Rl.schema]]),Ol={binary:Dl.binary,bool:eh.boolTag,float:Wn.float,floatExp:Wn.floatExp,floatNaN:Wn.floatNaN,floatTime:ri.floatTime,int:Gn.int,intHex:Gn.intHex,intOct:Gn.intOct,intTime:ri.intTime,map:Tl.map,merge:jt.merge,null:Xm.nullTag,omap:Fl.omap,pairs:_l.pairs,seq:Ml.seq,set:jl.set,timestamp:ri.timestamp},ih={"tag:yaml.org,2002:binary":Dl.binary,"tag:yaml.org,2002:merge":jt.merge,"tag:yaml.org,2002:omap":Fl.omap,"tag:yaml.org,2002:pairs":_l.pairs,"tag:yaml.org,2002:set":jl.set,"tag:yaml.org,2002:timestamp":ri.timestamp};function nh(e,t,s){let i=Ll.get(t);if(i&&!e)return s&&!i.includes(jt.merge)?i.concat(jt.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(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(jt.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?Ol[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Ol).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Yn.coreKnownTags=ih;Yn.getTags=nh});var Xn=P(Bl=>{"use strict";var zn=j(),rh=it(),oh=nt(),ah=Tt(),oi=ql(),lh=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Qn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?oi.getTags(t,"compat"):t?oi.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?oi.coreKnownTags:{},this.tags=oi.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,zn.MAP,{value:rh.map}),Object.defineProperty(this,zn.SCALAR,{value:ah.string}),Object.defineProperty(this,zn.SEQ,{value:oh.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?lh:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};Bl.Schema=Qn});var Kl=P(Ul=>{"use strict";var ch=j(),Zn=It(),qt=Ct();function uh(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=Zn.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(ch.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let f=r(e.contents.commentBefore);s.push(qt.indentComment(f,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Zn.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(Zn.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]=Gs.isPair(i)?i:new Dn.Pair(i)}}else t("Expected a sequence for this tag");return e}function yl(e,t,s){let{replacer:i}=s,n=new Am.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;n.items.push(Dn.createPair(a,l,s))}return n}var Pm={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:gl,createNode:yl};Ys.createPairs=yl;Ys.pairs=Pm;Ys.resolvePairs=gl});var jn=A(_n=>{"use strict";var bl=_(),Fn=xe(),Dt=Ie(),Nm=Re(),wl=zs(),Ke=class e extends Nm.YAMLSeq{constructor(){super(),this.add=Dt.YAMLMap.prototype.add.bind(this),this.delete=Dt.YAMLMap.prototype.delete.bind(this),this.get=Dt.YAMLMap.prototype.get.bind(this),this.has=Dt.YAMLMap.prototype.has.bind(this),this.set=Dt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,s){if(!s)return super.toJSON(t);let i=new Map;s?.onCreate&&s.onCreate(i);for(let n of this.items){let r,o;if(bl.isPair(n)?(r=Fn.toJS(n.key,"",s),o=Fn.toJS(n.value,r,s)):r=Fn.toJS(n,"",s),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}static from(t,s,i){let n=wl.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Ke.tag="tag:yaml.org,2002:omap";var Im={collection:"seq",identify:e=>e instanceof Map,nodeClass:Ke,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=wl.resolvePairs(e,t),i=[];for(let{key:n}of s.items)bl.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Ke,s)},createNode:(e,t,s)=>Ke.from(e,t,s)};_n.YAMLOMap=Ke;_n.omap=Im});var xl=A(qn=>{"use strict";var vl=V();function kl({value:e,source:t},s){return t&&(e?Sl:$l).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var Sl={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new vl.Scalar(!0),stringify:kl},$l={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new vl.Scalar(!1),stringify:kl};qn.falseTag=$l;qn.trueTag=Sl});var El=A(Qs=>{"use strict";var Rm=V(),Bn=ot(),Lm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Bn.stringifyNumber},Om={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Bn.stringifyNumber(e)}},Tm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Rm.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let i=e.substring(s+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Bn.stringifyNumber};Qs.float=Tm;Qs.floatExp=Om;Qs.floatNaN=Lm});var Al=A(_t=>{"use strict";var Cl=ot(),Ft=e=>typeof e=="bigint"||Number.isInteger(e);function Xs(e,t,s,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let r=parseInt(e,s);return n==="-"?-1*r:r}function Un(e,t,s){let{value:i}=e;if(Ft(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return Cl.stringifyNumber(e)}var Mm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Xs(e,2,2,s),stringify:e=>Un(e,2,"0b")},Dm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Xs(e,1,8,s),stringify:e=>Un(e,8,"0")},Fm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Xs(e,0,10,s),stringify:Cl.stringifyNumber},_m={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Xs(e,2,16,s),stringify:e=>Un(e,16,"0x")};_t.int=Fm;_t.intBin=Mm;_t.intHex=_m;_t.intOct=Dm});var Vn=A(Kn=>{"use strict";var ti=_(),Zs=Pe(),ei=Ie(),Ve=class e extends ei.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;ti.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Zs.Pair(t.key,null):s=new Zs.Pair(t,null),ei.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=ei.findPair(this.items,t);return!s&&ti.isPair(i)?ti.isScalar(i.key)?i.key.value:i.key:i}set(t,s){if(typeof s!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof s}`);let i=ei.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Zs.Pair(t))}toJSON(t,s){return super.toJSON(t,s,Set)}toString(t,s,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),s,i);throw new Error("Set items must all have null values")}static from(t,s,i){let{replacer:n}=i,r=new this(t);if(s&&Symbol.iterator in Object(s))for(let o of s)typeof n=="function"&&(o=n.call(s,o,o)),r.items.push(Zs.createPair(o,null,i));return r}};Ve.tag="tag:yaml.org,2002:set";var jm={collection:"map",identify:e=>e instanceof Set,nodeClass:Ve,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>Ve.from(e,t,s),resolve(e,t){if(ti.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ve,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Kn.YAMLSet=Ve;Kn.set=jm});var Hn=A(si=>{"use strict";var qm=ot();function Jn(e,t){let s=e[0],i=s==="-"||s==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return s==="-"?n(-1)*r:r}function Pl(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return qm.stringifyNumber(e);let i="";t<0&&(i="-",t*=s(-1));let n=s(60),r=[t%n];return t<60?r.unshift(0):(t=(t-r[0])/n,r.unshift(t%n),t>=60&&(t=(t-r[0])/n,r.unshift(t))),i+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var Bm={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>Jn(e,s),stringify:Pl},Um={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Jn(e,!1),stringify:Pl},Nl={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Nl.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,n,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,i-1,n,r||0,o||0,a||0,l),f=t[8];if(f&&f!=="Z"){let d=Jn(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};si.floatTime=Um;si.intTime=Bm;si.timestamp=Nl});var Ll=A(Rl=>{"use strict";var Km=nt(),Vm=Ks(),Jm=rt(),Hm=Tt(),Wm=Mn(),Il=xl(),Wn=El(),ii=Al(),Gm=Ms(),Ym=jn(),zm=zs(),Qm=Vn(),Gn=Hn(),Xm=[Km.map,Jm.seq,Hm.string,Vm.nullTag,Il.trueTag,Il.falseTag,ii.intBin,ii.intOct,ii.int,ii.intHex,Wn.floatNaN,Wn.floatExp,Wn.float,Wm.binary,Gm.merge,Ym.omap,zm.pairs,Qm.set,Gn.intTime,Gn.floatTime,Gn.timestamp];Rl.schema=Xm});var Ul=A(Qn=>{"use strict";var Dl=nt(),Zm=Ks(),Fl=rt(),eh=Tt(),th=An(),Yn=Nn(),zn=Rn(),sh=dl(),ih=ml(),_l=Mn(),jt=Ms(),jl=jn(),ql=zs(),Ol=Ll(),Bl=Vn(),ni=Hn(),Tl=new Map([["core",sh.schema],["failsafe",[Dl.map,Fl.seq,eh.string]],["json",ih.schema],["yaml11",Ol.schema],["yaml-1.1",Ol.schema]]),Ml={binary:_l.binary,bool:th.boolTag,float:Yn.float,floatExp:Yn.floatExp,floatNaN:Yn.floatNaN,floatTime:ni.floatTime,int:zn.int,intHex:zn.intHex,intOct:zn.intOct,intTime:ni.intTime,map:Dl.map,merge:jt.merge,null:Zm.nullTag,omap:jl.omap,pairs:ql.pairs,seq:Fl.seq,set:Bl.set,timestamp:ni.timestamp},nh={"tag:yaml.org,2002:binary":_l.binary,"tag:yaml.org,2002:merge":jt.merge,"tag:yaml.org,2002:omap":jl.omap,"tag:yaml.org,2002:pairs":ql.pairs,"tag:yaml.org,2002:set":Bl.set,"tag:yaml.org,2002:timestamp":ni.timestamp};function rh(e,t,s){let i=Tl.get(t);if(i&&!e)return s&&!i.includes(jt.merge)?i.concat(jt.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(Tl.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${r} or define customTags array`)}if(Array.isArray(e))for(let r of e)n=n.concat(r);else typeof e=="function"&&(n=e(n.slice()));return s&&(n=n.concat(jt.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?Ml[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Ml).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Qn.coreKnownTags=nh;Qn.getTags=rh});var er=A(Kl=>{"use strict";var Xn=_(),oh=nt(),ah=rt(),lh=Tt(),ri=Ul(),ch=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Zn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?ri.getTags(t,"compat"):t?ri.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?ri.coreKnownTags:{},this.tags=ri.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Xn.MAP,{value:oh.map}),Object.defineProperty(this,Xn.SCALAR,{value:lh.string}),Object.defineProperty(this,Xn.SEQ,{value:ah.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?ch:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};Kl.Schema=Zn});var Jl=A(Vl=>{"use strict";var uh=_(),tr=It(),qt=Ct();function dh(e,t){let s=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(s.push(l),i=!0):e.directives.docStart&&(i=!0)}i&&s.push("---");let n=tr.createStringifyContext(e,t),{commentString:r}=n.options;if(e.commentBefore){s.length!==1&&s.unshift("");let l=r(e.commentBefore);s.unshift(qt.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(uh.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let f=r(e.contents.commentBefore);s.push(qt.indentComment(f,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=tr.stringify(e.contents,n,()=>a=null,l);a&&(c+=qt.lineComment(c,"",r(a))),(c[0]==="|"||c[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${c}`:s.push(c)}else s.push(tr.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
57
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
|
+
`}Vl.stringifyDocument=dh});var Bt=A(Hl=>{"use strict";var fh=xt(),at=Cs(),ue=_(),ph=Pe(),mh=xe(),hh=er(),gh=Jl(),sr=Ss(),yh=on(),bh=Et(),ir=rn(),nr=class e{constructor(t,s,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ue.NODE_TYPE,{value:ue.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 ir.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,{[ue.NODE_TYPE]:{value:ue.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=ue.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){lt(this.contents)&&this.contents.add(t)}addIn(t,s){lt(this.contents)&&this.contents.addIn(t,s)}createAlias(t,s){if(!t.anchor){let i=sr.anchorNames(this);t.anchor=!s||i.has(s)?sr.findNewAnchor(s||"a",i):s}return new fh.Alias(t.anchor)}createNode(t,s,i){let n;if(typeof s=="function")t=s.call({"":t},"",t),n=s;else if(Array.isArray(s)){let g=w=>typeof w=="number"||w instanceof String||w instanceof Number,b=s.filter(g).map(String);b.length>0&&(s=s.concat(b)),n=s}else i===void 0&&s&&(i=s,s=void 0);let{aliasDuplicateObjects:r,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=i??{},{onAnchor:d,setAnchors:p,sourceObjects:m}=sr.createNodeAnchors(this,o||"a"),y={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:m},h=bh.createNode(t,f,y);return a&&ue.isCollection(h)&&(h.flow=!0),p(),h}createPair(t,s,i={}){let n=this.createNode(t,null,i),r=this.createNode(s,null,i);return new ph.Pair(n,r)}delete(t){return lt(this.contents)?this.contents.delete(t):!1}deleteIn(t){return at.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):lt(this.contents)?this.contents.deleteIn(t):!1}get(t,s){return ue.isCollection(this.contents)?this.contents.get(t,s):void 0}getIn(t,s){return at.isEmptyPath(t)?!s&&ue.isScalar(this.contents)?this.contents.value:this.contents:ue.isCollection(this.contents)?this.contents.getIn(t,s):void 0}has(t){return ue.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return at.isEmptyPath(t)?this.contents!==void 0:ue.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,s){this.contents==null?this.contents=at.collectionFromPath(this.schema,[t],s):lt(this.contents)&&this.contents.set(t,s)}setIn(t,s){at.isEmptyPath(t)?this.contents=s:this.contents==null?this.contents=at.collectionFromPath(this.schema,Array.from(t),s):lt(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 ir.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 ir.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 hh.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=mh.toJS(this.contents,s??"",a);if(typeof r=="function")for(let{count:c,res:f}of a.anchors.values())r(f,c);return typeof o=="function"?yh.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 gh.stringifyDocument(this,t)}};function lt(e){if(ue.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}Hl.Document=nr});var Vt=A(Kt=>{"use strict";var Ut=class extends Error{constructor(t,s,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=s}},rr=class extends Ut{constructor(t,s,i){super("YAMLParseError",t,s,i)}},or=class extends Ut{constructor(t,s,i){super("YAMLWarning",t,s,i)}},wh=(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
|
-
`}};Kt.YAMLError=Ut;Kt.YAMLParseError=
|
|
65
|
-
`))return!0;if(e.end){for(let t of e.end)if(t.type==="newline")return!0}return!1;case"flow-collection":for(let t of e.items){for(let s of t.start)if(s.type==="newline")return!0;if(t.sep){for(let s of t.sep)if(s.type==="newline")return!0}if(
|
|
66
|
-
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||
|
|
67
|
-
`+k.comment:w.comment=k.comment);let S=new
|
|
68
|
-
`+C.comment:c.comment=C.comment),d=C.end;continue}!o&&s.options.strict&&
|
|
69
|
-
`+E:x.comment=E,C.comment=C.comment.substring(E.length+1)}}if(!o&&!S&&!C.found){let E=v?e(s,v,C,n):t(s,C.end,S,null,C,n);c.items.push(E),d=E.range[2],
|
|
70
|
-
`+
|
|
71
|
-
`+g.comment:c.comment=g.comment),c.range=[i.offset,h,g.offset]}else c.range=[i.offset,h,h];return c}
|
|
64
|
+
`}};Kt.YAMLError=Ut;Kt.YAMLParseError=rr;Kt.YAMLWarning=or;Kt.prettifyError=wh});var Jt=A(Wl=>{"use strict";function vh(e,{flow:t,indicator:s,next:i,offset:n,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",p="",m=!1,y=!1,h=null,g=null,b=null,w=null,k=null,S=null,v=null;for(let x of e)switch(y&&(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma"&&r(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),y=!1),h&&(c&&x.type!=="comment"&&x.type!=="newline"&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),x.type){case"space":!t&&(s!=="doc-start"||i?.type!=="flow-collection")&&x.source.includes(" ")&&(h=x),f=!0;break;case"comment":{f||r(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let j=x.source.substring(1)||" ";d?d+=p+j:d=j,p="",c=!1;break}case"newline":c?d?d+=x.source:(!S||s!=="seq-item-ind")&&(l=!0):p+=x.source,c=!0,m=!0,(g||b)&&(w=x),f=!0;break;case"anchor":g&&r(x,"MULTIPLE_ANCHORS","A node can have at most one anchor"),x.source.endsWith(":")&&r(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=x,v??(v=x.offset),c=!1,f=!1,y=!0;break;case"tag":{b&&r(x,"MULTIPLE_TAGS","A node can have at most one tag"),b=x,v??(v=x.offset),c=!1,f=!1,y=!0;break}case s:(g||b)&&r(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`),S&&r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${t??"collection"}`),S=x,c=s==="seq-item-ind"||s==="explicit-key-ind",f=!1;break;case"comma":if(t){k&&r(x,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),k=x,c=!1,f=!1;break}default:r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),c=!1,f=!1}let C=e[e.length-1],E=C?C.offset+C.source.length:n;return y&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&r(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(c&&h.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:l,comment:d,hasNewline:m,anchor:g,tag:b,newlineAfterProp:w,end:E,start:v??E}}Wl.resolveProps=vh});var oi=A(Gl=>{"use strict";function ar(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(ar(t.key)||ar(t.value))return!0}return!1;default:return!0}}Gl.containsNewline=ar});var lr=A(Yl=>{"use strict";var kh=oi();function Sh(e,t,s){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&kh.containsNewline(t)&&s(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Yl.flowIndentCheck=Sh});var cr=A(Ql=>{"use strict";var zl=_();function $h(e,t,s){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(r,o)=>r===o||zl.isScalar(r)&&zl.isScalar(o)&&r.value===o.value;return t.some(r=>n(r.key,s))}Ql.mapIncludes=$h});var ic=A(sc=>{"use strict";var Xl=Pe(),xh=Ie(),Zl=Jt(),Eh=oi(),ec=lr(),Ch=cr(),tc="All mapping items must start at the same column";function Ah({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??xh.YAMLMap,a=new o(s.schema);s.atRoot&&(s.atRoot=!1);let l=i.offset,c=null;for(let f of i.items){let{start:d,key:p,sep:m,value:y}=f,h=Zl.resolveProps(d,{indicator:"explicit-key-ind",next:p??m?.[0],offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0}),g=!h.found;if(g){if(p&&(p.type==="block-seq"?n(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in p&&p.indent!==i.indent&&n(l,"BAD_INDENT",tc)),!h.anchor&&!h.tag&&!m){c=h.end,h.comment&&(a.comment?a.comment+=`
|
|
66
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||Eh.containsNewline(p))&&n(p??d[d.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else h.found?.indent!==i.indent&&n(l,"BAD_INDENT",tc);s.atKey=!0;let b=h.end,w=p?e(s,p,h,n):t(s,b,d,null,h,n);s.schema.compat&&ec.flowIndentCheck(i.indent,p,n),s.atKey=!1,Ch.mapIncludes(s,a.items,w)&&n(b,"DUPLICATE_KEY","Map keys must be unique");let k=Zl.resolveProps(m??[],{indicator:"map-value-ind",next:y,offset:w.range[2],onError:n,parentIndent:i.indent,startOnNewline:!p||p.type==="block-scalar"});if(l=k.end,k.found){g&&(y?.type==="block-map"&&!k.hasNewline&&n(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),s.options.strict&&h.start<k.found.offset-1024&&n(w.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));let S=y?e(s,y,k,n):t(s,l,m,null,k,n);s.schema.compat&&ec.flowIndentCheck(i.indent,y,n),l=S.range[2];let v=new Xl.Pair(w,S);s.options.keepSourceTokens&&(v.srcToken=f),a.items.push(v)}else{g&&n(w.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(w.comment?w.comment+=`
|
|
67
|
+
`+k.comment:w.comment=k.comment);let S=new Xl.Pair(w);s.options.keepSourceTokens&&(S.srcToken=f),a.items.push(S)}}return c&&c<l&&n(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[i.offset,l,c??l],a}sc.resolveBlockMap=Ah});var rc=A(nc=>{"use strict";var Ph=Re(),Nh=Jt(),Ih=lr();function Rh({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??Ph.YAMLSeq,a=new o(s.schema);s.atRoot&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let l=i.offset,c=null;for(let{start:f,value:d}of i.items){let p=Nh.resolveProps(f,{indicator:"seq-item-ind",next:d,offset:l,onError:n,parentIndent:i.indent,startOnNewline:!0});if(!p.found)if(p.anchor||p.tag||d)d?.type==="block-seq"?n(p.end,"BAD_INDENT","All sequence items must start at the same column"):n(l,"MISSING_CHAR","Sequence item without - indicator");else{c=p.end,p.comment&&(a.comment=p.comment);continue}let m=d?e(s,d,p,n):t(s,p.end,f,null,p,n);s.schema.compat&&Ih.flowIndentCheck(i.indent,d,n),l=m.range[2],a.items.push(m)}return a.range=[i.offset,l,c??l],a}nc.resolveBlockSeq=Rh});var ct=A(oc=>{"use strict";function Lh(e,t,s,i){let n="";if(e){let r=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{s&&!r&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=l),r=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:n,offset:t}}oc.resolveEnd=Lh});var uc=A(cc=>{"use strict";var Oh=_(),Th=Pe(),ac=Ie(),Mh=Re(),Dh=ct(),lc=Jt(),Fh=oi(),_h=cr(),ur="Block collections are not allowed within flow collections",dr=e=>e&&(e.type==="block-map"||e.type==="block-seq");function jh({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=i.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?ac.YAMLMap:Mh.YAMLSeq),c=new l(s.schema);c.flow=!0;let f=s.atRoot;f&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let d=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let b=i.items[g],{start:w,key:k,sep:S,value:v}=b,C=lc.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:k??S?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!S&&!v){g===0&&C.comma?n(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<i.items.length-1&&n(C.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),C.comment&&(c.comment?c.comment+=`
|
|
68
|
+
`+C.comment:c.comment=C.comment),d=C.end;continue}!o&&s.options.strict&&Fh.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)C.comma&&n(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(C.comma||n(C.start,"MISSING_CHAR",`Missing , between ${a} items`),C.comment){let E="";e:for(let x of w)switch(x.type){case"comma":case"space":break;case"comment":E=x.source.substring(1);break e;default:break e}if(E){let x=c.items[c.items.length-1];Oh.isPair(x)&&(x=x.value??x.key),x.comment?x.comment+=`
|
|
69
|
+
`+E:x.comment=E,C.comment=C.comment.substring(E.length+1)}}if(!o&&!S&&!C.found){let E=v?e(s,v,C,n):t(s,C.end,S,null,C,n);c.items.push(E),d=E.range[2],dr(v)&&n(E.range,"BLOCK_IN_FLOW",ur)}else{s.atKey=!0;let E=C.end,x=k?e(s,k,C,n):t(s,E,w,null,C,n);dr(k)&&n(x.range,"BLOCK_IN_FLOW",ur),s.atKey=!1;let j=lc.resolveProps(S??[],{flow:a,indicator:"map-value-ind",next:v,offset:x.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(j.found){if(!o&&!C.found&&s.options.strict){if(S)for(let T of S){if(T===j.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<j.found.offset-1024&&n(j.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else v&&("source"in v&&v.source?.[0]===":"?n(v,"MISSING_CHAR",`Missing space after : in ${a}`):n(j.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let R=v?e(s,v,j,n):j.found?t(s,j.end,S,null,j,n):null;R?dr(v)&&n(R.range,"BLOCK_IN_FLOW",ur):j.comment&&(x.comment?x.comment+=`
|
|
70
|
+
`+j.comment:x.comment=j.comment);let M=new Th.Pair(x,R);if(s.options.keepSourceTokens&&(M.srcToken=b),o){let T=c;_h.mapIncludes(s,T.items,x)&&n(E,"DUPLICATE_KEY","Map keys must be unique"),T.items.push(M)}else{let T=new ac.YAMLMap(s.schema);T.flow=!0,T.items.push(M);let K=(R??x).range;T.range=[x.range[0],K[1],K[2]],c.items.push(T)}d=R?R.range[2]:j.end}}let p=o?"}":"]",[m,...y]=i.end,h=d;if(m?.source===p)h=m.offset+m.source.length;else{let g=a[0].toUpperCase()+a.substring(1),b=f?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;n(d,f?"MISSING_CHAR":"BAD_INDENT",b),m&&m.source.length!==1&&y.unshift(m)}if(y.length>0){let g=Dh.resolveEnd(y,h,s.options.strict,n);g.comment&&(c.comment?c.comment+=`
|
|
71
|
+
`+g.comment:c.comment=g.comment),c.range=[i.offset,h,g.offset]}else c.range=[i.offset,h,h];return c}cc.resolveFlowCollection=jh});var fc=A(dc=>{"use strict";var qh=_(),Bh=V(),Uh=Ie(),Kh=Re(),Vh=ic(),Jh=rc(),Hh=uc();function fr(e,t,s,i,n,r){let o=s.type==="block-map"?Vh.resolveBlockMap(e,t,s,i,r):s.type==="block-seq"?Jh.resolveBlockSeq(e,t,s,i,r):Hh.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 Wh(e,t,s,i,n){let r=i.tag,o=r?t.directives.tagName(r.source,p=>n(r,"TAG_RESOLVE_FAILED",p)):null;if(s.type==="block-seq"){let{anchor:p,newlineAfterProp:m}=i,y=p&&r?p.offset>r.offset?p:r:p??r;y&&(!m||m.offset<y.offset)&&n(y,"MISSING_CHAR","Missing newline after block sequence props")}let a=s.type==="block-map"?"map":s.type==="block-seq"?"seq":s.start.source==="{"?"map":"seq";if(!r||!o||o==="!"||o===Uh.YAMLMap.tagName&&a==="map"||o===Kh.YAMLSeq.tagName&&a==="seq")return fr(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),fr(e,t,s,n,o)}let c=fr(e,t,s,n,o,l),f=l.resolve?.(c,p=>n(r,"TAG_RESOLVE_FAILED",p),t.options)??c,d=qh.isNode(f)?f:new Bh.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}dc.composeCollection=Wh});var mr=A(pc=>{"use strict";var pr=V();function Gh(e,t,s){let i=t.offset,n=Yh(t,e.options.strict,s);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let r=n.mode===">"?pr.Scalar.BLOCK_FOLDED:pr.Scalar.BLOCK_LITERAL,o=t.source?zh(t.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")a=h;else break}if(a===0){let h=n.chomp==="+"&&o.length>0?`
|
|
72
72
|
`.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return t.source&&(g+=t.source.length),{value:h,type:r,comment:n.comment,range:[i,g,g]}}let l=t.indent+n.indent,c=t.offset+n.length,f=0;for(let h=0;h<a;++h){let[g,b]=o[h];if(b===""||b==="\r")n.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&s(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(l=g.length),f=h,l===0&&!e.atRoot&&s(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+b.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let d="",p="",m=!1;for(let h=0;h<f;++h)d+=o[h][0].slice(l)+`
|
|
73
|
-
`;for(let h=f;h<a;++h){let[g,b]=o[h];c+=g.length+b.length+1;let w=b[b.length-1]==="\r";if(w&&(b=b.slice(0,-1)),b&&g.length<l){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;s(c-b.length-(w?2:1),"BAD_INDENT",S),g=""}r===
|
|
73
|
+
`;for(let h=f;h<a;++h){let[g,b]=o[h];c+=g.length+b.length+1;let w=b[b.length-1]==="\r";if(w&&(b=b.slice(0,-1)),b&&g.length<l){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;s(c-b.length-(w?2:1),"BAD_INDENT",S),g=""}r===pr.Scalar.BLOCK_LITERAL?(d+=p+g.slice(l)+b,p=`
|
|
74
74
|
`):g.length>l||b[0]===" "?(p===" "?p=`
|
|
75
75
|
`:!m&&p===`
|
|
76
76
|
`&&(p=`
|
|
@@ -83,84 +83,84 @@ ${c}
|
|
|
83
83
|
`+o[h][0].slice(l);d[d.length-1]!==`
|
|
84
84
|
`&&(d+=`
|
|
85
85
|
`);break;default:d+=`
|
|
86
|
-
`}let y=i+n.length+t.source.length;return{value:d,type:r,comment:n.comment,range:[i,y,y]}}function
|
|
86
|
+
`}let y=i+n.length+t.source.length;return{value:d,type:r,comment:n.comment,range:[i,y,y]}}function Yh({offset:e,props:t},s,i){if(t[0].type!=="block-scalar-header")return i(t[0],"IMPOSSIBLE","Block scalar header not found"),null;let{source:n}=t[0],r=n[0],o=0,a="",l=-1;for(let p=1;p<n.length;++p){let m=n[p];if(!a&&(m==="-"||m==="+"))a=m;else{let y=Number(m);!o&&y?o=y:l===-1&&(l=e+p)}}l!==-1&&i(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${n}`);let c=!1,f="",d=n.length;for(let p=1;p<t.length;++p){let m=t[p];switch(m.type){case"space":c=!0;case"newline":d+=m.source.length;break;case"comment":s&&!c&&i(m,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),d+=m.source.length,f=m.source.substring(1);break;case"error":i(m,"UNEXPECTED_TOKEN",m.message),d+=m.source.length;break;default:{let y=`Unexpected token in block scalar header: ${m.type}`;i(m,"UNEXPECTED_TOKEN",y);let h=m.source;h&&typeof h=="string"&&(d+=h.length)}}}return{mode:r,indent:o,chomp:a,comment:f,length:d}}function zh(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}pc.resolveBlockScalar=Gh});var gr=A(hc=>{"use strict";var hr=V(),Qh=ct();function Xh(e,t,s){let{offset:i,type:n,source:r,end:o}=e,a,l,c=(p,m,y)=>s(i+p,m,y);switch(n){case"scalar":a=hr.Scalar.PLAIN,l=Zh(r,c);break;case"single-quoted-scalar":a=hr.Scalar.QUOTE_SINGLE,l=eg(r,c);break;case"double-quoted-scalar":a=hr.Scalar.QUOTE_DOUBLE,l=tg(r,c);break;default:return s(e,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${n}`),{value:"",type:null,comment:"",range:[i,i+r.length,i+r.length]}}let f=i+r.length,d=Qh.resolveEnd(o,f,t,s);return{value:l,type:a,comment:d.comment,range:[i,f,d.offset]}}function Zh(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}`),mc(e)}function eg(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),mc(e.slice(1,-1)).replace(/''/g,"'")}function mc(e){let t,s;try{t=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
87
87
|
`,"sy"),s=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
88
88
|
`,"sy")}catch{t=/(.*?)[ \t]*\r?\n/sy,s=/[ \t]*(.*?)[ \t]*\r?\n/sy}let i=t.exec(e);if(!i)return e;let n=i[1],r=" ",o=t.lastIndex;for(s.lastIndex=o;i=s.exec(e);)i[1]===""?r===`
|
|
89
89
|
`?n+=r:r=`
|
|
90
|
-
`:(n+=r+i[1],r=" "),o=s.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),n+r+(i?.[1]??"")}function
|
|
90
|
+
`:(n+=r+i[1],r=" "),o=s.lastIndex;let a=/[ \t]*(.*)/sy;return a.lastIndex=o,i=a.exec(e),n+r+(i?.[1]??"")}function tg(e,t){let s="";for(let i=1;i<e.length-1;++i){let n=e[i];if(!(n==="\r"&&e[i+1]===`
|
|
91
91
|
`))if(n===`
|
|
92
|
-
`){let{fold:r,offset:o}=
|
|
92
|
+
`){let{fold:r,offset:o}=sg(e,i);s+=r,i=o}else if(n==="\\"){let r=e[++i],o=ig[r];if(o)s+=o;else if(r===`
|
|
93
93
|
`)for(r=e[i+1];r===" "||r===" ";)r=e[++i+1];else if(r==="\r"&&e[i+1]===`
|
|
94
|
-
`)for(r=e[++i+1];r===" "||r===" ";)r=e[++i+1];else if(r==="x"||r==="u"||r==="U"){let a={x:2,u:4,U:8}[r];s+=
|
|
94
|
+
`)for(r=e[++i+1];r===" "||r===" ";)r=e[++i+1];else if(r==="x"||r==="u"||r==="U"){let a={x:2,u:4,U:8}[r];s+=ng(e,i+1,a,t),i+=a}else{let a=e.substr(i-1,2);t(i-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),s+=a}}else if(n===" "||n===" "){let r=i,o=e[i+1];for(;o===" "||o===" ";)o=e[++i+1];o!==`
|
|
95
95
|
`&&!(o==="\r"&&e[i+2]===`
|
|
96
|
-
`)&&(s+=i>r?e.slice(r,i+1):n)}else s+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),s}function
|
|
96
|
+
`)&&(s+=i>r?e.slice(r,i+1):n)}else s+=n}return(e[e.length-1]!=='"'||e.length===1)&&t(e.length,"MISSING_CHAR",'Missing closing "quote'),s}function sg(e,t){let s="",i=e[t+1];for(;(i===" "||i===" "||i===`
|
|
97
97
|
`||i==="\r")&&!(i==="\r"&&e[t+2]!==`
|
|
98
98
|
`);)i===`
|
|
99
99
|
`&&(s+=`
|
|
100
|
-
`),t+=1,i=e[t+1];return s||(s=" "),{fold:s,offset:t}}var
|
|
101
|
-
`,r:"\r",t:" ",v:"\v",N:"\x85",_:"\xA0",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function
|
|
100
|
+
`),t+=1,i=e[t+1];return s||(s=" "),{fold:s,offset:t}}var ig={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 ng(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)}hc.resolveFlowScalar=Xh});var bc=A(yc=>{"use strict";var Je=_(),gc=V(),rg=mr(),og=gr();function ag(e,t,s,i){let{value:n,type:r,comment:o,range:a}=t.type==="block-scalar"?rg.resolveBlockScalar(e,t,i):og.resolveFlowScalar(t,e.options.strict,i),l=s?e.directives.tagName(s.source,d=>i(s,"TAG_RESOLVE_FAILED",d)):null,c;e.options.stringKeys&&e.atKey?c=e.schema[Je.SCALAR]:l?c=lg(e.schema,n,l,s,i):t.type==="scalar"?c=cg(e,n,t,i):c=e.schema[Je.SCALAR];let f;try{let d=c.resolve(n,p=>i(s??t,"TAG_RESOLVE_FAILED",p),e.options);f=Je.isScalar(d)?d:new gc.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(s??t,"TAG_RESOLVE_FAILED",p),f=new gc.Scalar(n)}return f.range=a,f.source=n,r&&(f.type=r),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function lg(e,t,s,i,n){if(s==="!")return e[Je.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[Je.SCALAR])}function cg({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[Je.SCALAR];if(s.compat){let a=s.compat.find(l=>l.default&&l.test?.test(i))??s[Je.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;r(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}yc.composeScalar=ag});var vc=A(wc=>{"use strict";function ug(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}wc.emptyScalarPosition=ug});var $c=A(br=>{"use strict";var dg=xt(),fg=_(),pg=fc(),kc=bc(),mg=ct(),hg=vc(),gg={composeNode:Sc,composeEmptyNode:yr};function Sc(e,t,s,i){let n=e.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=s,c,f=!0;switch(t.type){case"alias":c=yg(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=kc.composeScalar(e,t,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=pg.composeCollection(gg,e,t,s,i),a&&(c.anchor=a.source.substring(1))}catch(d){let p=d instanceof Error?d.message:String(d);i(t,"RESOURCE_EXHAUSTION",p)}break;default:{let d=t.type==="error"?t.message:`Unsupported token (type: ${t.type})`;i(t,"UNEXPECTED_TOKEN",d),f=!1}}return c??(c=yr(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&&(!fg.isScalar(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&i(l??t,"NON_STRING_KEY","With stringKeys, all keys must be strings"),r&&(c.spaceBefore=!0),o&&(t.type==="scalar"&&t.source===""?c.comment=o:c.commentBefore=o),e.options.keepSourceTokens&&f&&(c.srcToken=t),c}function yr(e,t,s,i,{spaceBefore:n,comment:r,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:hg.emptyScalarPosition(t,s,i),indent:-1,source:""},d=kc.composeScalar(e,f,a,c);return o&&(d.anchor=o.source.substring(1),d.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),n&&(d.spaceBefore=!0),r&&(d.comment=r,d.range[2]=l),d}function yg({options:e},{offset:t,source:s,end:i},n){let r=new dg.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=mg.resolveEnd(i,o,e.strict,n);return r.range=[t,o,a.offset],a.comment&&(r.comment=a.comment),r}br.composeEmptyNode=yr;br.composeNode=Sc});var Cc=A(Ec=>{"use strict";var bg=Bt(),xc=$c(),wg=ct(),vg=Jt();function kg(e,t,{offset:s,start:i,value:n,end:r},o){let a=Object.assign({_directives:t},e),l=new bg.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=vg.resolveProps(i,{indicator:"doc-start",next:n??r?.[0],offset:s,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,n&&(n.type==="block-map"||n.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=n?xc.composeNode(c,n,f,o):xc.composeEmptyNode(c,f.end,i,null,f,o);let d=l.contents.range[2],p=wg.resolveEnd(r,d,!1,o);return p.comment&&(l.comment=p.comment),l.range=[s,d,p.offset],l}Ec.composeDoc=kg});var vr=A(Nc=>{"use strict";var Sg=rs("process"),$g=rn(),xg=Bt(),Ht=Vt(),Ac=_(),Eg=Cc(),Cg=ct();function Wt(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 Pc(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 wr=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(s,i,n,r)=>{let o=Wt(s);r?this.warnings.push(new Ht.YAMLWarning(o,i,n)):this.errors.push(new Ht.YAMLParseError(o,i,n))},this.directives=new $g.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,s){let{comment:i,afterEmptyLine:n}=Pc(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(Ac.isCollection(r)&&!r.flow&&r.items.length>0){let o=r.items[0];Ac.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 Ht.YAMLParseError(Wt(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,s=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let i=Object.assign({_directives:this.directives},this.options),n=new
|
|
107
|
+
${o}`:i}}s?(Array.prototype.push.apply(t.errors,this.errors),Array.prototype.push.apply(t.warnings,this.warnings)):(t.errors=this.errors,t.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Pc(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(Sg.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(s,i,n)=>{let r=Wt(t);r[0]+=s,this.onError(r,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let s=Eg.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 Ht.YAMLParseError(Wt(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 Ht.YAMLParseError(Wt(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let s=Cg.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 Ht.YAMLParseError(Wt(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 xg.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}}};Nc.Composer=wr});var Lc=A(ai=>{"use strict";var Ag=mr(),Pg=gr(),Ng=Vt(),Ic=Nt();function Ig(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 Ng.YAMLParseError([a,a+1],r,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Pg.resolveFlowScalar(e,t,i);case"block-scalar":return Ag.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function Rg(e,t){let{implicitKey:s=!1,indent:i,inFlow:n=!1,offset:r=-1,type:o="PLAIN"}=t,a=Ic.stringifyString({type:o,value:e},{implicitKey:s,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:i,source:`
|
|
109
109
|
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
|
|
110
110
|
`),f=a.substring(0,c),d=a.substring(c+1)+`
|
|
111
|
-
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return
|
|
112
|
-
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:r,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:i,source:a,end:l};default:return{type:"scalar",offset:r,indent:i,source:a,end:l}}}function
|
|
111
|
+
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return Rc(p,l)||p.push({type:"newline",offset:-1,indent:i,source:`
|
|
112
|
+
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:r,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:i,source:a,end:l};default:return{type:"scalar",offset:r,indent:i,source:a,end:l}}}function Lg(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=Ic.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">":Og(e,l);break;case'"':kr(e,l,"double-quoted-scalar");break;case"'":kr(e,l,"single-quoted-scalar");break;default:kr(e,l,"scalar")}}function Og(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 kr(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})}}}ai.createScalarToken=Rg;ai.resolveAsScalar=Ig;ai.setScalarValue=Lg});var Tc=A(Oc=>{"use strict";var Tg=e=>"type"in e?ci(e):li(e);function ci(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=ci(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=li(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=li(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=li(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 li({start:e,key:t,sep:s,value:i}){let n="";for(let r of e)n+=r.source;if(t&&(n+=ci(t)),s)for(let r of s)n+=r.source;return i&&(n+=ci(i)),n}Oc.stringify=Tg});var _c=A(Fc=>{"use strict";var Sr=Symbol("break visit"),Mg=Symbol("skip children"),Mc=Symbol("remove item");function He(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),Dc(Object.freeze([]),e,t)}He.BREAK=Sr;He.SKIP=Mg;He.REMOVE=Mc;He.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};He.parentCollection=(e,t)=>{let s=He.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 Dc(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=Dc(Object.freeze(e.concat([[n,o]])),r.items[o],s);if(typeof a=="number")o=a-1;else{if(a===Sr)return Sr;a===Mc&&(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=He});var ui=A(re=>{"use strict";var $r=Lc(),Dg=Tc(),Fg=_c(),xr="\uFEFF",Er="",Cr="",Ar="",_g=e=>!!e&&"items"in e,jg=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function qg(e){switch(e){case xr:return"<BOM>";case Er:return"<DOC>";case Cr:return"<FLOW_END>";case Ar:return"<SCALAR>";default:return JSON.stringify(e)}}function Bg(e){switch(e){case xr:return"byte-order-mark";case Er:return"doc-mode";case Cr:return"flow-error-end";case Ar:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
117
117
|
`:case`\r
|
|
118
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}
|
|
119
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
120
|
-
\r `),
|
|
118
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}re.createScalarToken=$r.createScalarToken;re.resolveAsScalar=$r.resolveAsScalar;re.setScalarValue=$r.setScalarValue;re.stringify=Dg.stringify;re.visit=Fg.visit;re.BOM=xr;re.DOCUMENT=Er;re.FLOW_END=Cr;re.SCALAR=Ar;re.isCollection=_g;re.isScalar=jg;re.prettyToken=qg;re.tokenType=Bg});var Ir=A(qc=>{"use strict";var Gt=ui();function me(e){switch(e){case void 0:case" ":case`
|
|
119
|
+
`:case"\r":case" ":return!0;default:return!1}}var jc=new Set("0123456789ABCDEFabcdef"),Ug=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),di=new Set(",[]{}"),Kg=new Set(` ,[]{}
|
|
120
|
+
\r `),Pr=e=>!e||Kg.has(e),Nr=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
|
-
`||i>=this.indentNext||!s&&!this.atEnd?t+i:-1}if(s==="-"||s==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&
|
|
125
|
-
`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===Gt.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 Gt.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==="...")&&
|
|
124
|
+
`||i>=this.indentNext||!s&&!this.atEnd?t+i:-1}if(s==="-"||s==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&me(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]===Gt.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 Gt.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==="...")&&me(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&&!me(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===":")&&me(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(Pr),"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("..."))&&me(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Gt.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(Pr),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||me(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
|
-
`,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=>
|
|
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=>me(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 Gt.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(
|
|
132
|
+
`&&r>=this.pos&&r+1+s>a)t=r;else break}while(!0);return yield Gt.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(me(r)||t&&di.has(r))break;s=i}else if(me(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&&di.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&&di.has(n))break;s=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Gt.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(Pr))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(me(s)||t&&di.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(;!me(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(Ug.has(s))s=this.buffer[++t];else if(s==="%"&&jc.has(this.buffer[t+1])&&jc.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)}};qc.Lexer=Nr});var Lr=A(Bc=>{"use strict";var Rr=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}}}};Bc.LineCounter=Rr});var Tr=A(Hc=>{"use strict";var Vg=rs("process"),Uc=ui(),Jg=Ir();function Le(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function Kc(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 Jc(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 fi(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 ut(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 Vc(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!Le(t.start,"explicit-key-ind")&&!Le(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,Jc(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 Or=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 Jg.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,Vg.env.LOG_TOKENS&&console.log("|",Uc.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let s=Uc.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"&&Vc(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&&Kc(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":{Kc(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=fi(this.peek(2)),i=ut(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(
|
|
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(Le(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(Jc(s.key)&&!Le(s.sep,"newline")){let o=ut(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(Le(s.start,"newline"))Object.assign(s,{key:null,sep:[this.sourceToken]});else{let o=ut(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]}):Le(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&&!Le(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||Le(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=fi(i),r=ut(n);Vc(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
|
-
`,"utf-8")}function
|
|
143
|
-
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var
|
|
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=fi(t),i=ut(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=fi(t),i=ut(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())}}};Hc.Parser=Or});var Qc=A(zt=>{"use strict";var Wc=vr(),Hg=Bt(),Yt=Vt(),Wg=bn(),Gg=_(),Yg=Lr(),Gc=Tr();function Yc(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Yg.LineCounter||null,prettyErrors:t}}function zg(e,t={}){let{lineCounter:s,prettyErrors:i}=Yc(t),n=new Gc.Parser(s?.addNewLine),r=new Wc.Composer(t),o=Array.from(r.compose(n.parse(e)));if(i&&s)for(let a of o)a.errors.forEach(Yt.prettifyError(e,s)),a.warnings.forEach(Yt.prettifyError(e,s));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function zc(e,t={}){let{lineCounter:s,prettyErrors:i}=Yc(t),n=new Gc.Parser(s?.addNewLine),r=new Wc.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 Yt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&s&&(o.errors.forEach(Yt.prettifyError(e,s)),o.warnings.forEach(Yt.prettifyError(e,s))),o}function Qg(e,t,s){let i;typeof t=="function"?i=t:s===void 0&&t&&typeof t=="object"&&(s=t);let n=zc(e,s);if(!n)return null;if(n.warnings.forEach(r=>Wg.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 Xg(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 Gg.isDocument(e)&&!i?e.toString(s):new Hg.Document(e,i,s).toString(s)}zt.parse=Qg;zt.parseAllDocuments=zg;zt.parseDocument=zc;zt.stringify=Xg});var Dr=A(q=>{"use strict";var Zg=vr(),ey=Bt(),ty=er(),Mr=Vt(),sy=xt(),Oe=_(),iy=Pe(),ny=V(),ry=Ie(),oy=Re(),ay=ui(),ly=Ir(),cy=Lr(),uy=Tr(),pi=Qc(),Xc=vt();q.Composer=Zg.Composer;q.Document=ey.Document;q.Schema=ty.Schema;q.YAMLError=Mr.YAMLError;q.YAMLParseError=Mr.YAMLParseError;q.YAMLWarning=Mr.YAMLWarning;q.Alias=sy.Alias;q.isAlias=Oe.isAlias;q.isCollection=Oe.isCollection;q.isDocument=Oe.isDocument;q.isMap=Oe.isMap;q.isNode=Oe.isNode;q.isPair=Oe.isPair;q.isScalar=Oe.isScalar;q.isSeq=Oe.isSeq;q.Pair=iy.Pair;q.Scalar=ny.Scalar;q.YAMLMap=ry.YAMLMap;q.YAMLSeq=oy.YAMLSeq;q.CST=ay;q.Lexer=ly.Lexer;q.LineCounter=cy.LineCounter;q.Parser=uy.Parser;q.parse=pi.parse;q.parseAllDocuments=pi.parseAllDocuments;q.parseDocument=pi.parseDocument;q.stringify=pi.stringify;q.visit=Xc.visit;q.visitAsync=Xc.visitAsync});import{readFile as of,writeFile as af,mkdir as lf,rename as Vo,copyFile as cf,access as uf,realpath as df}from"node:fs/promises";import{join as Jo,dirname as ff}from"node:path";function Ko(){return{version:1,disabled:{}}}async function ls(e){let t=e??Fi(),s;try{s=await of(t,"utf-8")}catch(i){if(i?.code==="ENOENT")return P("skill-state: file not found, returning empty state"),Ko();throw i}try{let i=JSON.parse(s);if(!i||typeof i!="object"||i.version!==1||typeof i.disabled!="object"||i.disabled===null)throw new Error("invalid schema");return i}catch{let i=t+".bak";P(`skill-state: parse error, backing up to ${i}`);try{await cf(t,i)}catch{}return console.error(`Warning: skill-state.json was corrupted. Backup saved to ${i}. Starting fresh.`),Ko()}}async function Hi(e,t){let s=t??Fi();await lf(ff(s),{recursive:!0}),await af(s,JSON.stringify(e,null,2)+`
|
|
142
|
+
`,"utf-8")}function Ho(e,t,s,i){let n=e.disabled[t]??={},r=n[s]??={};r[i]=!0}function Wo(e,t,s,i){let n=e.disabled[t];if(!n)return;let r=n[s];r&&(delete r[i],Object.keys(r).length===0&&delete n[s],Object.keys(n).length===0&&delete e.disabled[t])}function pf(e){return e.replace(/[.+?^${}()|[\]\\]/g,"\\$&")}function mf(e){if(e==="*"||e==="all")return{kind:"all",test:()=>!0};if(e.includes("*")){let t=new RegExp("^"+pf(e).replace(/\*/g,".*")+"$");return{kind:"wildcard",test:s=>t.test(s)}}return e.endsWith(":")||e.endsWith("-")?{kind:"prefix",test:t=>t.startsWith(e)}:{kind:"exact",test:t=>t===e}}function Wi(e,t){let s=mf(t);return e.filter(i=>s.test(i.name)||s.test(i.dirName))}function Go(e){return Jo(e,"SKILL.md")}function cs(e){return Jo(e,"SKILL.md.disabled")}async function as(e){try{return await uf(e),!0}catch{return!1}}async function Yo(e){try{return await df(e)}catch{return e}}async function zo(e){let t=await Yo(e),s=Go(t),i=cs(t);return!await as(s)&&await as(i)?!1:(await Vo(s,i),!0)}async function Qo(e){let t=await Yo(e),s=Go(t),i=cs(t);return!await as(i)&&await as(s)?!1:(await Vo(i,s),!0)}import{readFile as Jv,realpath as Hv}from"fs/promises";import{existsSync as Wv}from"fs";import{execFile as Sf}from"child_process";import{promisify as $f}from"util";import{mkdtemp as Xo,readdir as xf,readFile as fs,rm as ps,cp as Ef,access as ms,stat as sa,lstat as Cf,symlink as Af,mkdir as Pf}from"fs/promises";import{join as ce,resolve as Qi,relative as Nf,basename as ia}from"path";import{homedir as Zo}from"os";import{tmpdir as ea}from"os";import{readdir as hf,readFile as gf,stat as yf}from"fs/promises";import{join as bf}from"path";var wf=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"]),vf=512*1024;async function us(e){let t=[];async function s(i,n){let r;try{r=await hf(i)}catch{return}for(let o of r){if(o===".git"||o==="node_modules")continue;let a=bf(i,o),l=n?`${n}/${o}`:o;try{let c=await yf(a);if(c.isDirectory())await s(a,l);else if(c.isFile()){let f=o.includes(".")?`.${o.split(".").pop().toLowerCase()}`:"";if(wf.has(f)||c.size>vf)continue;try{let d=await gf(a,"utf-8");t.push({relPath:l,content:d,lineCount:d.split(`
|
|
143
|
+
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var Yi=class{selected;cursor;scrollOffset;pageSize;itemCount;filter;searchActive;filteredMap;constructor(t,s){this.selected=t.map(i=>i.checked),this.cursor=1,this.scrollOffset=0,this.pageSize=s,this.itemCount=t.length,this.filter="",this.searchActive=!1,this.filteredMap=t.map((i,n)=>n)}get totalRows(){return this.filteredMap.length+1}applyFilter(t){if(this.filter==="")this.filteredMap=t.map((s,i)=>i);else{let s=this.filter.toLowerCase();this.filteredMap=[];for(let i=0;i<t.length;i++)(t[i].label.toLowerCase()+" "+(t[i].hint?.toLowerCase()??"")).includes(s)&&this.filteredMap.push(i)}this.cursor>=this.totalRows&&(this.cursor=Math.max(0,this.totalRows-1)),this.scrollOffset>0&&this.scrollOffset>=this.totalRows&&(this.scrollOffset=Math.max(0,this.totalRows-this.pageSize))}cursorToOriginalIndex(){return this.cursor===0?-1:this.filteredMap[this.cursor-1]??-1}toggleCurrent(){if(this.cursor===0)this.toggleAll();else{let t=this.cursorToOriginalIndex();t>=0&&(this.selected[t]=!this.selected[t])}}toggleAll(){let t=this.filteredMap,i=!t.every(n=>this.selected[n]);for(let n of t)this.selected[n]=i}moveUp(){this.cursor>0?this.cursor--:this.cursor=this.totalRows-1,this.adjustScroll()}moveDown(){this.cursor<this.totalRows-1?this.cursor++:this.cursor=0,this.adjustScroll()}getSelectedIndices(){let t=[];for(let s=0;s<this.selected.length;s++)this.selected[s]&&t.push(s);return t}getVisibleRange(){let t=this.scrollOffset,s=Math.min(this.scrollOffset+this.pageSize,this.totalRows);return{start:t,end:s}}adjustScroll(){this.cursor<this.scrollOffset?this.scrollOffset=this.cursor:this.cursor>=this.scrollOffset+this.pageSize&&(this.scrollOffset=this.cursor-this.pageSize+1)}};function kf(e,t,s){let i=[];if(e.searchActive||e.filter!==""){let c=u.cyan("/"),f=e.filter,d=e.searchActive?u.cyan("\u2588"):"";i.push(` ${c}${f}${d}`),e.filteredMap.length===0&&i.push(u.dim(" No matches found")),i.push("")}let{start:n,end:r}=e.getVisibleRange();n>0&&i.push(u.dim(` ... ${n} more above`));for(let c=n;c<r;c++){let d=c===e.cursor?u.cyan(">"):" ";if(c===0){let p=e.filteredMap,y=p.length>0&&p.every(g=>e.selected[g])?u.green("[*]"):"[ ]",h=e.filter!==""?`Select All Matching (${e.filteredMap.length})`:"Select All / Deselect All";i.push(`${d} ${y} ${u.bold(h)}`)}else{let p=e.filteredMap[c-1],m=t[p],h=e.selected[p]?u.green("[*]"):"[ ]",g=`${d} ${h} `,b=7,w=u.bold(m.label),k=m.label.length;if(m.hint){let S=s-b-k-2;if(S>10){let v=Gi(m.hint,S);i.push(`${g}${w} ${u.dim(v)}`)}else{let v=Gi(m.label,s-b);i.push(`${g}${u.bold(v)}`)}}else{let S=Gi(m.label,s-b);i.push(`${g}${u.bold(S)}`)}}}let o=e.totalRows-r;o>0&&i.push(u.dim(` ... ${o} more below`));let a=e.getSelectedIndices().length,l=e.filter!==""?` matching: ${e.filteredMap.length}/${e.itemCount}`:"";return i.push(""),e.searchActive?i.push(u.dim(` ${a} of ${e.itemCount} selected${l} | Type to filter Esc Clear Enter Done searching`)):i.push(u.dim(` ${a} of ${e.itemCount} selected${l} | \u2191/\u2193 Navigate Space Toggle a All / Search Enter Confirm Esc Cancel`)),i}function Gi(e,t){return t<=0?"":e.length<=t?e:t<=3?e.slice(0,t):e.slice(0,t-3)+"..."}async function Xe(e){let{items:t}=e,s=e.pageSize??Math.min(t.length+1,15),i=new Yi(t,s),n=process.stderr,r=process.stdin,o=n.columns||80;typeof r.setRawMode=="function"&&r.setRawMode(!0),r.resume(),r.setEncoding("utf-8"),n.write("\x1B[?25l");let a=0;function l(){let c=kf(i,t,o);a>0&&n.write(`\x1B[${a}F`);let f=Math.max(c.length,a),d="";for(let p=0;p<f;p++)d+=`\x1B[2K${p<c.length?c[p]:""}
|
|
144
144
|
`;n.write(d),a=f}return l(),new Promise(c=>{let f="",d=null;function p(){r.removeListener("data",h),typeof r.setRawMode=="function"&&r.setRawMode(!1),r.pause(),n.write("\x1B[?25h"),d&&clearTimeout(d)}function m(g){p(),c(g)}function y(g){if(i.searchActive){if(g==="\x1B"){i.searchActive=!1,i.filter="",i.applyFilter(t),l();return}if(g==="\r"||g===`
|
|
145
145
|
`){i.searchActive=!1,l();return}if(g==="\x7F"||g==="\b"){i.filter.length>0?(i.filter=i.filter.slice(0,-1),i.applyFilter(t)):i.searchActive=!1,l();return}if(g===""){p(),process.kill(process.pid,"SIGINT");return}if(g==="\x1B[A"){i.moveUp(),l();return}if(g==="\x1B[B"){i.moveDown(),l();return}if(g===" "){i.toggleCurrent(),l();return}if(g.length===1&&g>=" "&&g<="~"){i.filter+=g,i.applyFilter(t),l();return}return}switch(g){case"\x1B[A":case"k":i.moveUp(),l();break;case"\x1B[B":case"j":i.moveDown(),l();break;case" ":i.toggleCurrent(),l();break;case"a":i.toggleAll(),l();break;case"/":i.searchActive=!0,l();break;case"\r":case`
|
|
146
|
-
`:m(i.getSelectedIndices());break;case"\x1B":i.filter!==""?(i.filter="",i.applyFilter(t),l()):m([]);break;case"\x7F":case"\b":i.filter.length>0&&(i.filter=i.filter.slice(0,-1),i.applyFilter(t),l());break;case"":p(),process.kill(process.pid,"SIGINT");break}}function h(g){if(f.length>0){if(f+=g,d&&clearTimeout(d),f.length>=3&&f[1]==="["){let w=f.slice(0,3),k=f.slice(3);f="",y(w),k&&h(k);return}let b=f;f="",y("\x1B");for(let w=1;w<b.length;w++)y(b[w]);return}for(let b=0;b<g.length;b++){let w=g[b];if(w==="\x1B"){let k=g.slice(b);if(k.length>=3&&k[1]==="[")y(k.slice(0,3)),b+=2;else if(k.length>=2){f=k,d=setTimeout(()=>{let S=f;f="",y("\x1B");for(let v=1;v<S.length;v++)y(S[v])},50);return}else{f="\x1B",d=setTimeout(()=>{f="",y("\x1B")},50);return}}else y(w)}}r.on("data",h)})}var
|
|
146
|
+
`:m(i.getSelectedIndices());break;case"\x1B":i.filter!==""?(i.filter="",i.applyFilter(t),l()):m([]);break;case"\x7F":case"\b":i.filter.length>0&&(i.filter=i.filter.slice(0,-1),i.applyFilter(t),l());break;case"":p(),process.kill(process.pid,"SIGINT");break}}function h(g){if(f.length>0){if(f+=g,d&&clearTimeout(d),f.length>=3&&f[1]==="["){let w=f.slice(0,3),k=f.slice(3);f="",y(w),k&&h(k);return}let b=f;f="",y("\x1B");for(let w=1;w<b.length;w++)y(b[w]);return}for(let b=0;b<g.length;b++){let w=g[b];if(w==="\x1B"){let k=g.slice(b);if(k.length>=3&&k[1]==="[")y(k.slice(0,3)),b+=2;else if(k.length>=2){f=k,d=setTimeout(()=>{let S=f;f="",y("\x1B");for(let v=1;v<S.length;v++)y(S[v])},50);return}else{f="\x1B",d=setTimeout(()=>{f="",y("\x1B")},50);return}}else y(w)}}r.on("data",h)})}var Se=$f(Sf),If=/^[a-zA-Z0-9_-]+$/,Rf=/^[a-zA-Z0-9._-]+$/,Lf=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,ta=128,Of=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function Xi(e){return e.startsWith("/")||e.startsWith("./")||e.startsWith(".\\")||e.startsWith("../")||e.startsWith("..\\")||e.startsWith("~/")||e.startsWith("~\\")||e==="~"||e==="."||e===".."||/^[a-zA-Z]:[/\\]/.test(e)}async function na(e){if(!e.includes("/")&&!e.includes("\\"))return!1;try{return(await sa(Qi(e))).isDirectory()}catch{return!1}}function Tf(e){let t;e==="~"?t=Zo():e.startsWith("~/")||e.startsWith("~\\")?t=Qi(Zo(),e.slice(2)):t=Qi(e);let s=ia(t);return P(`install: parsed local source -> path=${t}`),{owner:"local",repo:s,ref:null,subpath:null,cloneUrl:"",sshCloneUrl:"",isLocal:!0,localPath:t}}function Fe(e){if(Xi(e))return Tf(e);let t=Of.exec(e);if(t){let[,d,p,m]=t,y=p.endsWith(".git")?p.slice(0,-4):p;e=`github:${d}/${y}${m?`#${m}`:""}`}if(!e.startsWith("github:"))throw new Error(`Invalid source format. Got: "${e}"
|
|
147
147
|
Supported formats:
|
|
148
148
|
github:owner/repo[#ref]
|
|
149
149
|
github:owner/repo#ref:path
|
|
150
150
|
https://github.com/owner/repo
|
|
151
151
|
https://github.com/owner/repo/tree/branch/path/to/skill
|
|
152
152
|
/path/to/local/skill
|
|
153
|
-
./relative/path/to/skill`);let s=e.slice(7),i=s.indexOf("#"),n,r=null,o=null;if(i!==-1){n=s.slice(0,i);let d=s.slice(i+1);if(!d)throw new Error("Invalid source: ref cannot be empty after #");let p=d.indexOf(":");if(p!==-1){if(r=d.slice(0,p),!r)throw new Error("Invalid source: ref cannot be empty before :");o=d.slice(p+1)||null}else r=d}else{let d=s.indexOf(":");d!==-1?(n=s.slice(0,d),o=s.slice(d+1)||null):n=s}let a=n.indexOf("/");if(a===-1)throw new Error(`Invalid source: format must be github:owner/repo. Got: "${e}"`);let l=n.slice(0,a),c=n.slice(a+1);if(!l)throw new Error("Invalid source: owner cannot be empty");if(!c)throw new Error("Invalid source: repo cannot be empty");if(!
|
|
154
|
-
`)){let r=n.match(/\trefs\/(?:heads|tags)\/(.+)$/);r&&s.add(r[1])}let i=e.ref.split("/");for(let n=1;n<i.length;n++){let r=i.slice(0,n).join("/");if(s.has(r)){let o=i.slice(n).join("/");return
|
|
155
|
-
HTTPS: ${
|
|
156
|
-
SSH: ${
|
|
157
|
-
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of
|
|
158
|
-
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;
|
|
159
|
-
`),s=!1,i=!1;for(let n of t){if(n.trim()==="---")if(s){i=!0;continue}else{s=!0;continue}if(i&&n.trim().length>0)return!0}return!1}function
|
|
153
|
+
./relative/path/to/skill`);let s=e.slice(7),i=s.indexOf("#"),n,r=null,o=null;if(i!==-1){n=s.slice(0,i);let d=s.slice(i+1);if(!d)throw new Error("Invalid source: ref cannot be empty after #");let p=d.indexOf(":");if(p!==-1){if(r=d.slice(0,p),!r)throw new Error("Invalid source: ref cannot be empty before :");o=d.slice(p+1)||null}else r=d}else{let d=s.indexOf(":");d!==-1?(n=s.slice(0,d),o=s.slice(d+1)||null):n=s}let a=n.indexOf("/");if(a===-1)throw new Error(`Invalid source: format must be github:owner/repo. Got: "${e}"`);let l=n.slice(0,a),c=n.slice(a+1);if(!l)throw new Error("Invalid source: owner cannot be empty");if(!c)throw new Error("Invalid source: repo cannot be empty");if(!If.test(l))throw new Error(`Invalid source: owner contains invalid characters: "${l}". Allowed: [a-zA-Z0-9_-]`);if(!Rf.test(c))throw new Error(`Invalid source: repo contains invalid characters: "${c}". Allowed: [a-zA-Z0-9._-]`);let f={owner:l,repo:c,ref:r,subpath:o,cloneUrl:`https://github.com/${l}/${c}.git`,sshCloneUrl:`git@github.com:${l}/${c}.git`};return P(`install: parsed source -> owner=${l} repo=${c} ref=${r} subpath=${o}`),f}async function hs(e){if(e.subpath!==null||!e.ref||!e.ref.includes("/"))return e;try{let{stdout:t}=await Se("git",["ls-remote","--heads","--tags",e.cloneUrl],{timeout:15e3}),s=new Set;for(let n of t.split(`
|
|
154
|
+
`)){let r=n.match(/\trefs\/(?:heads|tags)\/(.+)$/);r&&s.add(r[1])}let i=e.ref.split("/");for(let n=1;n<i.length;n++){let r=i.slice(0,n).join("/");if(s.has(r)){let o=i.slice(n).join("/");return P(`install: resolved ref="${r}" subpath="${o}"`),{...e,ref:r,subpath:o||null}}}}catch(t){P(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function $e(e){if(!e)throw new Error("Invalid skill name: name cannot be empty");if(e.includes("\0"))throw new Error("Invalid skill name: contains unsafe characters (null byte)");if(e.includes(".."))throw new Error("Invalid skill name: contains unsafe characters (..)");if(e.includes("/")||e.includes("\\"))throw new Error("Invalid skill name: contains unsafe characters (path separator)");if(e.startsWith("."))throw new Error("Invalid skill name: must not start with a dot");if(e.length>ta)throw new Error(`Invalid skill name: exceeds maximum length of ${ta} characters`);if(!Lf.test(e))throw new Error(`Invalid skill name: "${e}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return e}function Zi(e){let t=e.split(/[/\\]/).filter(Boolean),s=t.length>0?t[t.length-1]:e;return $e(s)}function ra(e,t=Zi){let s=new Map;for(let i of e){let n=t(i),r=s.get(n);r?r.push(i):s.set(n,[i])}return[...s.entries()].filter(([,i])=>i.length>1).map(([i,n])=>({name:i,paths:n}))}async function _e(){try{await Se("git",["--version"]),P("install: git available")}catch{throw new Error("git is required for installing skills. Install git from https://git-scm.com")}}function Mf(e){if(e.killed)return!1;let t=(e.stderr||e.message||"").toLowerCase();return t.includes("authentication failed")||t.includes("could not read username")||t.includes("repository not found")||t.includes("returned error: 403")||t.includes("returned error: 401")||t.includes("terminal prompts disabled")||t.includes("permission denied")}function ds(e){return e.killed?"Clone timed out after 60 seconds":`Clone failed: ${e.stderr||e.message}`}async function zi(e,t,s){if(t!==null&&/^[0-9a-f]{40}$/i.test(t))return await Se("git",["clone","--no-checkout",e,s],{timeout:6e4}),await Se("git",["checkout",t],{cwd:s,timeout:3e4}),s;let n=["clone","--depth","1"];return t&&n.push("--branch",t),n.push(e,s),await Se("git",n,{timeout:6e4}),s}async function je(e,t="auto"){P(`install: cloning ${e.owner}/${e.repo}${e.ref?` (ref: ${e.ref})`:""} (transport: ${t})`);let s=await Xo(ce(ea(),"asm-install-"));if(t==="ssh"||t==="https"){let i=t==="ssh"?e.sshCloneUrl:e.cloneUrl;try{return await zi(i,e.ref,s)}catch(n){throw await le(s),new Error(ds(n))}}try{return await zi(e.cloneUrl,e.ref,s)}catch(i){if(!Mf(i))throw await le(s),new Error(ds(i));P("install: HTTPS clone failed with auth error, retrying with SSH..."),await le(s);let n=await Xo(ce(ea(),"asm-install-"));try{return await zi(e.sshCloneUrl,e.ref,n)}catch(r){throw await le(n),new Error(`Clone failed with both transports:
|
|
155
|
+
HTTPS: ${ds(i)}
|
|
156
|
+
SSH: ${ds(r)}`)}}}async function qe(e){let t=ce(e,"SKILL.md"),s;try{s=await fs(t,"utf-8")}catch{throw new Error("Not a valid skill: SKILL.md not found in repository root")}let i=Z(s),n=e.split(/[/\\]/).pop()||"unknown",r=i.name||n,o=ae(i);return P(`install: validated skill "${r}" v${o}`),{name:r,version:o,description:(i.description||"").replace(/\s*\n\s*/g," ").trim(),effort:i.effort||i["metadata.effort"]||void 0}}async function gs(e,t=5){let s=[];try{let n=await fs(ce(e,"SKILL.md"),"utf-8"),r=Z(n);s.push({relPath:"",name:r.name||ia(e),version:ae(r),description:(r.description||"").replace(/\s*\n\s*/g," ").trim(),effort:r.effort||r["metadata.effort"]||void 0,license:(r.license||"").trim(),creator:(r["metadata.creator"]||"").trim(),compatibility:(r.compatibility||"").trim(),allowedTools:_i(r),tokenCount:bt(n)})}catch{}async function i(n,r,o){let a;try{a=await xf(n)}catch{return}for(let l of a){if(l===".git"||l==="node_modules")continue;let c=ce(n,l);try{if(!(await sa(c)).isDirectory())continue}catch{continue}let f=r?`${r}/${l}`:l,d=o+1,p=ce(c,"SKILL.md");try{let m=await fs(p,"utf-8"),y=Z(m);s.push({relPath:f,name:y.name||l,version:ae(y),description:(y.description||"").replace(/\s*\n\s*/g," ").trim(),effort:y.effort||y["metadata.effort"]||void 0,license:(y.license||"").trim(),creator:(y["metadata.creator"]||"").trim(),compatibility:(y.compatibility||"").trim(),allowedTools:_i(y),tokenCount:bt(m)})}catch{d<t&&await i(c,f,d)}}}return await i(e,"",0),s.sort((n,r)=>n.name.localeCompare(r.name)),s}async function Df(e,t=Se){let s=ce(e,"scripts"),i=ce(s,"package.json");try{await ms(i)}catch{P(`install: no scripts/package.json in ${e}; skipping npm install`);return}P(`install: installing script dependencies in ${s}`);try{await t("npm",["install"],{cwd:s,timeout:12e4})}catch(n){throw new Error(`Installed skill, but failed to install dependencies in scripts/: ${n.stderr||n.message}`)}}var Ff=[{category:"Shell commands",pattern:/\b(bash|sh\s+-c)\b/},{category:"Shell commands",pattern:/\bexec\(/},{category:"Shell commands",pattern:/\bchild_process\b/},{category:"Shell commands",pattern:/\bBun\.spawn\b/},{category:"Code execution",pattern:/\beval\(/},{category:"Code execution",pattern:/\bFunction\(/},{category:"Code execution",pattern:/\bnew\s+Function\b/},{category:"Credentials",pattern:/\b(API_KEY|SECRET|TOKEN|PASSWORD)\s*[=:]/},{category:"External URLs",pattern:/https?:\/\//}];async function oa(e){let t=[],s=await us(e);for(let{relPath:i,content:n}of s){let r=n.split(`
|
|
157
|
+
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of Ff)if(l.test(r[o])){let c=r[o].trim();t.push({category:a,file:i,line:o+1,match:c.length>100?c.slice(0,100)+"\u2026":c})}}return t}async function ys(e){let t=e.source.isLocal?`local:${e.source.localPath}`:`github:${e.source.owner}/${e.source.repo}${e.source.ref?`#${e.source.ref}`:""}${e.source.subpath?`:${e.source.subpath}`:""}`;if(e.force)try{await ms(e.targetDir),await ps(e.targetDir,{recursive:!0,force:!0})}catch{}let s=e.sourceDir;try{await Ef(s,e.targetDir,{recursive:!0})}catch(a){throw new Error(`Failed to install: ${a.message}`)}let i=ce(e.targetDir,".git");try{await ps(i,{recursive:!0,force:!0})}catch{}P(`install: copied files to ${e.targetDir}`);let n=ce(e.targetDir,"SKILL.md");try{await ms(n)}catch{throw new Error("Installation verification failed: SKILL.md not found at target")}await Df(e.targetDir);let r=await fs(n,"utf-8"),o=Z(r);return{success:!0,path:e.targetDir,name:o.name||e.skillName,version:ae(o),provider:e.providerLabel,source:t}}async function aa(e,t){let s=await ys(e);for(let i of t){if(i.name===e.providerName)continue;let n=e.scope==="project"?i.project:i.global,r=oe(n),o=ce(r,e.skillName);await Pf(r,{recursive:!0});try{if((await Cf(o)).isSymbolicLink())await ps(o);else{P(`install: skipping ${o} \u2014 existing non-symlink directory`);continue}}catch{}let a=Nf(r,e.targetDir);await Af(a,o,"dir"),P(`install: symlinked ${o} -> ${a}`)}return s.provider=`All (${t.map(i=>i.label).join(", ")})`,s}async function le(e){try{await ps(e,{recursive:!0,force:!0})}catch{}}async function la(){try{await Se("npx",["--version"]),P("install: npx available")}catch{throw new Error("npx is required for Vercel method installation. Install Node.js from https://nodejs.org")}}async function ca(e,t){let s=["--yes","skills","add",e];t&&s.push("--skill",t),P(`install: running npx ${s.join(" ")}`);try{let i=await Se("npx",s,{timeout:12e4});return{stdout:i.stdout,stderr:i.stderr}}catch(i){let n=i.stderr||i.message||"";throw new Error(`npx skills add failed: ${n}`)}}function ua(e){if(e.isLocal)return e.localPath;let t=`https://github.com/${e.owner}/${e.repo}`;return e.ref?`${t}/tree/${e.ref}${e.subpath?`/${e.subpath}`:""}`:t}async function Ze(e,t,s){let i=e.providers.filter(m=>m.enabled);if(t==="all"){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");return{provider:i.find(y=>y.name==="agents")||i[0],allProviders:i}}if(t){let m=e.providers.find(y=>y.name===t);if(!m){let y=e.providers.map(h=>h.name).join(", ");throw new Error(`Unknown provider: "${t}". Valid providers: ${y}, all`)}if(!m.enabled)throw new Error(`Provider "${t}" is disabled. Enable it in your config or choose another provider.`);return{provider:m,allProviders:null}}if(i.length===1)return{provider:i[0],allProviders:null};if(!s){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");let m=i.map(y=>y.name).join(", ");throw new Error(`--tool (or --provider) is required in non-interactive mode. Available: ${m}, all`)}let n=e.preferences.selectedTools,o=n&&n.length>0?new Set(n):null,a=e.providers.map(m=>({label:`${m.label} (${m.name})`,hint:m.global,checked:o?o.has(m.name):m.name==="agents"})),l=await Xe({items:a});if(l.length===0)throw new Error("No tools selected. Aborting.");let c=l.map(m=>e.providers[m]),f=c.map(m=>m.name),{saveSelectedTools:d}=await import("./config-FRM3YOMA.js");return await d(f),c.length===1?{provider:c[0],allProviders:null}:{provider:c.find(m=>m.name==="agents")||c[0],allProviders:c}}function en(e,t,s,i,n,r,o="global"){let a=o==="project"?n.project:n.global,l=oe(a),c=ce(l,i);return{source:e,tempDir:t,sourceDir:s,targetDir:c,skillName:i,force:r,providerName:n.name,providerLabel:n.label,scope:o}}async function da(e,t){try{if(await ms(e),P(`install: target ${e} \u2014 conflict (exists)${t?", force overwrite":""}`),!t)throw new Error(`Skill already exists at: ${e}
|
|
158
|
+
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;P(`install: target ${e} \u2014 no conflict`)}}var eu=mo(Dr(),1);import{readFile as dy}from"fs/promises";import{join as fy}from"path";var Zc=500;function py(e){let t=e.split(`
|
|
159
|
+
`),s=!1,i=!1;for(let n of t){if(n.trim()==="---")if(s){i=!0;continue}else{s=!0;continue}if(i&&n.trim().length>0)return!0}return!1}function my(e){let t=e.split(`
|
|
160
160
|
`),s=-1;for(let i=0;i<t.length;i++)if(t[i].trim()==="---")if(s===-1)s=i+1;else return t.slice(s,i).join(`
|
|
161
|
-
`);return null}function
|
|
161
|
+
`);return null}function hy(e){let t=my(e);if(t===null)return null;try{return(0,eu.parse)(t),null}catch(s){return s.message||"invalid YAML"}}async function tu(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=fy(e.path,"SKILL.md"),n=await dy(i,"utf-8");py(n)||t.push({category:"empty-body",message:"SKILL.md contains only frontmatter with no body content"});let r=hy(n);r&&t.push({category:"invalid-yaml",message:`SKILL.md has invalid YAML frontmatter: ${r}`})}catch{}let s=e.fileCount;return s!==void 0&&s>Zc&&t.push({category:"high-file-count",message:`Skill has ${s} files (threshold: ${Zc})`}),t}import{join as $y}from"path";import{homedir as xy}from"os";import{readFile as gy,writeFile as yy,mkdir as by}from"fs/promises";import{dirname as wy}from"path";async function vy(e){try{let t=await gy(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 ky(e,t,s){let i={fetched_at:new Date().toISOString(),ttl_seconds:s,data:t};try{await by(wy(e),{recursive:!0}),await yy(e,JSON.stringify(i,null,2),"utf-8"),P(`http: wrote cache -> ${e}`)}catch(n){P(`http: failed to write cache: ${n}`)}}function Sy(e){let t=new Date(e.fetched_at).getTime();return(Date.now()-t)/1e3<e.ttl_seconds}async function su(e,t,s={}){let i=s.ttl??3600,n=s.noCache??!1,r=await vy(t);if(r&&!n&&Sy(r))return P(`http: cache hit (fresh) -> ${t}`),r.data;try{P(`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 ky(t,a,i),a}catch(o){return P(`http: fetch failed: ${o}`),r?(P(`http: using stale cache as fallback -> ${t}`),r.data):null}}var Ey=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,Cy=/^[a-zA-Z0-9_-]+$/,ru=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9._-]+$/,Ay=/^[0-9a-f]{40}$/,Py=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/,Ny=/^[a-z0-9-]+$/,Iy=/^sha256:[0-9a-f]{64}$/,iu=["pass","warning","dangerous"];function mi(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:Ey,maxLength:128},{field:"author",pattern:Cy,maxLength:39},{field:"description",maxLength:256},{field:"repository",pattern:ru},{field:"commit",pattern:Ay},{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"||!iu.includes(r))&&t.push({field:"security_verdict",message:`"security_verdict" must be one of: ${iu.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"||!Py.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`}),Ny.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"||!Iy.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 Ry(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 Ly(e,t,s=2){let i=[];for(let n of t){if(e===n)continue;let r=Ry(e,n);r<=s&&i.push({existingName:n,distance:r})}return i.sort((n,r)=>n.distance-r.distance)}var Fr=process.env.ASM_REGISTRY_URL??"https://raw.githubusercontent.com/luongnv89/asm-registry/main/index.json",Oy=process.env.ASM_REGISTRY_CACHE??$y(xy(),".config","agent-skill-manager","registry-cache.json"),Ty=3600;function Qt(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 _r(e){return Qt(e)?e.includes("/"):!1}async function jr(e){let t=await su(Fr,Oy,{ttl:Ty,noCache:e?.noCache});if(!t)return null;if(typeof t!="object"||!Array.isArray(t.manifests)||typeof t.generated_at!="string")return P("registry: fetched index has invalid structure \u2014 discarding"),null;let s=[];for(let i of t.manifests){let n=mi(i);if(n.length>0){P(`registry: dropping invalid manifest entry (${i?.name??"unknown"}): ${n.map(r=>r.message).join(", ")}`);continue}if(!ru.test(i.repository)){P(`registry: dropping manifest with unexpected repository URL: ${i.repository}`);continue}s.push(i)}return{generated_at:t.generated_at,manifests:s}}function My(e,t){return t.manifests.filter(s=>s.name.toLowerCase()===e.toLowerCase())}function Dy(e,t,s){return s.manifests.find(i=>i.author.toLowerCase()===e.toLowerCase()&&i.name.toLowerCase()===t.toLowerCase())??null}function nu(e,t,s=5){return Ly(e,t.manifests.map(n=>n.name),3).slice(0,s).map(n=>n.existingName)}async function ou(e,t){let s=await jr(t);if(!s)return P("registry: failed to fetch index \u2014 skipping registry resolution"),{resolved:null,multipleMatches:[],suggestions:[]};if(_r(e)){let[r,o]=e.split("/"),a=Dy(r,o,s);if(a)return{resolved:{manifest:a,source:"registry"},multipleMatches:[],suggestions:[]};let l=nu(o,s);return{resolved:null,multipleMatches:[],suggestions:l}}let i=My(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=nu(e,s);return{resolved:null,multipleMatches:[],suggestions:n}}function au(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 Fy,access as cu,mkdir as _y,cp as lu,rm as jy,symlink as qy}from"fs/promises";import{join as uu,basename as By}from"path";function Uy(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 du(e){let t;try{t=await Fy(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=Uy(s);if(!i.valid)throw new Error(`Invalid manifest:
|
|
162
162
|
${i.errors.join(`
|
|
163
|
-
`)}`);return s}async function
|
|
163
|
+
`)}`);return s}async function Ky(e){try{return await cu(e),!0}catch{return!1}}function Vy(e,t){return e.providers.find(s=>s.name===t&&s.enabled)}function Jy(e,t,s,i){let n=Vy(e,t);if(!n)return null;let r=s==="global"?n.global:n.project,o=oe(r),a=By(i);return!a||a==="."||a===".."?null:uu(o,a)}function Hy(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 fu(e,t,s){let i=s?.config??await U(),n=s?.installedSkills??await ee(i,"both"),r=[];for(let c of e.skills){if(t.scopeFilter!=="both"&&c.scope!==t.scopeFilter){P(`import: skipping "${c.name}" \u2014 scope "${c.scope}" filtered out`);continue}let f=Jy(i,c.provider,c.scope,c.dirName);if(!f){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:`Provider "${c.provider}" not found or not enabled.`});continue}let d=await Ky(f);if(d&&!t.force){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"skipped",reason:"Already installed.",path:f});continue}if(t.dryRun){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"dry-run",reason:d?"Would overwrite (--force).":"Would install.",path:f});continue}let p=Hy(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 _y(uu(f,".."),{recursive:!0}),d&&await jy(f,{recursive:!0,force:!0}),c.isSymlink&&c.symlinkTarget)try{await cu(c.symlinkTarget),await qy(c.symlinkTarget,f),P(`import: symlinked "${c.name}" -> ${c.symlinkTarget} at ${f}`)}catch{await lu(p.realPath,f,{recursive:!0}),P(`import: symlink target unreachable, copied "${c.name}" from ${p.realPath} to ${f}`)}else await lu(p.realPath,f,{recursive:!0}),P(`import: copied "${c.name}" from ${p.realPath} to ${f}`);r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"installed",path:f})}catch(m){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:`Copy failed: ${m.message}`})}}let o=r.filter(c=>c.status==="installed").length,a=r.filter(c=>c.status==="skipped").length,l=r.filter(c=>c.status==="failed").length;return{total:r.length,installed:o,skipped:a,failed:l,results:r}}import{mkdir as Wy,writeFile as Gy,access as Yy}from"fs/promises";import{join as zy}from"path";function Qy(e){return`---
|
|
164
164
|
name: ${e}
|
|
165
165
|
description: ""
|
|
166
166
|
license: ""
|
|
@@ -181,62 +181,62 @@ as instructions for when and how to use this skill.
|
|
|
181
181
|
## Instructions
|
|
182
182
|
|
|
183
183
|
- Step-by-step instructions for the agent
|
|
184
|
-
`}async function
|
|
185
|
-
`)}import{access as sb,lstat as ib,mkdir as nb,readdir as rb,readFile as gu,rm as ob,stat as yu,symlink as ab}from"fs/promises";import{join as gi}from"path";async function jr(e){let t;try{t=await yu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=gi(e,"SKILL.md"),i;try{i=await gu(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=X(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ae(n)}}async function bu(e,t,s,i){let n=gi(t,s),r=!1;try{await sb(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await ob(n,{recursive:!0,force:!0})}await nb(t,{recursive:!0}),await ab(e,n,"dir")}async function qr(e){let t;try{t=await yu(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 rb(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=gi(e,n);try{if(!(await ib(r)).isDirectory())continue}catch{continue}let o=gi(r,"SKILL.md");try{let a=await gu(o,"utf-8"),l=X(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ae(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as Ib,writeFile as Rb,readdir as Lu,access as Ou,mkdir as Lb,rm as Ob}from"fs/promises";import{join as He,resolve as Tu,dirname as Tb}from"path";import{homedir as Mb}from"os";import{fileURLToPath as Db}from"url";import{readdir as lb,readFile as cb}from"fs/promises";import{join as ub}from"path";function Br(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var db=10,fb=5,pb=3,mb=1;function hb(e,t){let s=Br(e),i=Br(t.name),n=Br(t.description),r=0;for(let o of s)i.has(o)&&(r+=db),n.has(o)&&(r+=pb),t.name.toLowerCase().includes(o)&&(r+=fb),t.description.toLowerCase().includes(o)&&(r+=mb);return r}async function wu(e){let t=new Map,s;try{s=await lb(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=ub(e,i);try{let r=await cb(n,"utf-8"),o=JSON.parse(r);for(let a of o.skills)"license"in a||(a.license=""),"creator"in a||(a.creator=""),"compatibility"in a||(a.compatibility=""),"allowedTools"in a||(a.allowedTools=[]),"verified"in a||(a.verified=!1);t.set(`${o.owner}/${o.repo}`,o)}catch{}}return t}async function ut(){let e=await wu(go()),t=await wu(yt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var gb=["license","creator","version"];function vu(e){return gb.includes(e)}function ku(e,t){return e[t]||""}function yb(e,t){if(t.has){for(let s of t.has)if(vu(s)&&!ku(e,s))return!1}if(t.missing){for(let s of t.missing)if(vu(s)&&ku(e,s))return!1}return!0}function Su(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 yi(e,t=20,s){let i=await ut(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!yb(a,s))continue;let l=r?1:hb(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 $u(){return(await ut()).reduce((t,s)=>t+s.skillCount,0)}import{readdir as bb,readFile as xu,stat as Cu}from"fs/promises";import{join as Ur}from"path";var wb=[{id:"marketing",title:"Marketing Skills",description:"Marketing, growth, SEO, ASO, affiliate, sales, and conversion skills.",tags:["marketing","growth","seo"],keywords:["marketing","growth","seo","aso","affiliate","sales","copy","copywriting","conversion","cro","brand","social","campaign"]},{id:"writing",title:"Writing Skills",description:"Writing, editing, documentation, publishing, and content-production skills.",tags:["writing","content","docs"],keywords:["write","writing","writer","blog","article","content","docs","documentation","draft","copy","readme","paper","thesis","proposal"]},{id:"research",title:"Research Skills",description:"Research, academic, literature-review, citation, paper, and analysis skills.",tags:["research","academic","analysis"],keywords:["research","academic","scholar","paper","literature","citation","review","analysis","summar","evaluate","verify"]},{id:"engineering",title:"Engineering Skills",description:"Coding, debugging, testing, architecture, review, and software engineering skills.",tags:["engineering","coding","testing"],keywords:["code","coding","debug","test","testing","coverage","review","refactor","architecture","typescript","python","javascript","build","cli","api"]},{id:"frontend-design",title:"Frontend & Design Skills",description:"Frontend, UI, UX, visual design, component, theme, and landing-page skills.",tags:["frontend","design","ui"],keywords:["frontend","ui","ux","design","component","react","css","html","figma","theme","landing","layout","visual","brand","logo"]},{id:"devops",title:"DevOps Skills",description:"Deployment, CI/CD, infrastructure, cloud, Docker, Kubernetes, and automation skills.",tags:["devops","infra","automation"],keywords:["devops","deploy","deployment","ci","cd","pipeline","docker","kubernetes","terraform","ansible","cloud","infra","infrastructure","workflow","release"]},{id:"data-ai",title:"Data & AI Skills",description:"Data, analytics, AI, model, prompt, agent, and automation skills.",tags:["data","ai","agents"],keywords:["data","analytics","analysis","ai","agent","llm","model","prompt","openai","claude","gemini","automation","dataset","sql"]},{id:"product-business",title:"Product & Business Skills",description:"Product, strategy, PRD, planning, finance, resume, and business workflow skills.",tags:["product","business","planning"],keywords:["product","prd","strategy","planning","business","finance","resume","career","startup","market","competitor","customer","sales"]}],Eu=2,vb=80,kb=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],Sb=["bundles","data/bundles",".asm/bundles"];function Xt(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Au(e,t,s){let i=Xt(e),n=Xt(t),r=Xt(s),o=`${i}-${n}`;return r.startsWith(o)?r:`${o}-${r}`}function $b(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function xb(e,t){let s=$b(e);return t.keywords.some(i=>s.includes(i))}function Pu(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function Eb(e){let t=new Set,s=[];for(let i of e){let n=`${i.installUrl||""}\0${i.name}`;t.has(n)||(t.add(n),s.push(i))}return s}function Nu(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function Kr(e){let t=[];if(!e.skills||e.skills.length<Eu)return t;for(let s of wb){let i=e.skills.filter(r=>xb(r,s)).slice(0,vb);if(i.length<Eu)continue;let n=Au(e.owner,e.repo,s.id);t.push({version:1,name:n,description:`${s.description} Derived from ${e.owner}/${e.repo}.`,author:`ASM (${e.owner}/${e.repo})`,createdAt:e.updatedAt,tags:["repo-derived","inferred",...s.tags,Xt(e.owner),Xt(e.repo)],skills:Nu(i.map(Pu)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function Cb(e,t,s){if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e,n=Array.isArray(i.skills)?i.skills:[];if(n.length===0)return null;let r=new Map(t.skills.map(l=>[l.name,l])),o=Eb(n.map(l=>{if(typeof l=="string"){let p=r.get(l);return p?Pu(p):null}if(!l||typeof l!="object"||Array.isArray(l))return null;let c=l,f=typeof c.name=="string"?c.name:"";if(!f)return null;let d=r.get(f);return d?{name:d.name,installUrl:d.installUrl,description:typeof c.description=="string"&&c.description?c.description:d.description||void 0,version:typeof c.version=="string"&&c.version?c.version:d.version||void 0}:null}).filter(l=>l!==null));if(o.length===0)return null;let a=typeof i.name=="string"&&i.name?i.name:s.replace(/\.json$/,"");return{version:1,name:Au(t.owner,t.repo,a),description:typeof i.description=="string"&&i.description?i.description:`Bundle from ${t.owner}/${t.repo}.`,author:typeof i.author=="string"&&i.author?i.author:`ASM (${t.owner}/${t.repo})`,createdAt:typeof i.createdAt=="string"&&i.createdAt?i.createdAt:t.updatedAt,tags:Array.isArray(i.tags)?["repo-derived","explicit",...i.tags.filter(l=>typeof l=="string")]:["repo-derived","explicit"],skills:Nu(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function Ab(e){try{return(await Cu(e)).isFile()}catch{return!1}}async function Pb(e){try{return(await Cu(e)).isDirectory()}catch{return!1}}async function Nb(e){let t=[];for(let s of kb){let i=Ur(e,s);if(await Ab(i))try{t.push({relPath:s,data:JSON.parse(await xu(i,"utf-8"))})}catch{}}for(let s of Sb){let i=Ur(e,s);if(!await Pb(i))continue;let n=[];try{n=await bb(i)}catch{continue}for(let r of n.filter(o=>o.endsWith(".json")).sort()){let o=`${s}/${r}`;try{t.push({relPath:o,data:JSON.parse(await xu(Ur(i,r),"utf-8"))})}catch{}}}return t}async function Iu(e,t){let s=[],i=await Nb(e);for(let n of i){let r=n.data,o=Array.isArray(r?.bundles)?r.bundles:[r];for(let a of o){let l=Cb(a,t,n.relPath);l&&s.push(l)}}return bi(s)}function bi(e){let t=new Map;for(let s of e){let i=t.get(s.name);(!i||s.explicit&&!i.explicit)&&t.set(s.name,s)}return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}function Ru(e){let t=e.bundles||[],s=Kr(e);return bi([...t,...s])}var Fb=Db(import.meta.url),_b=Tb(Fb),Je=He(Mb(),".config","agent-skill-manager","bundles"),wi=Tu(_b,"..","data","bundles");function jb(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 Mu(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function Du(e,t){let s=t??await Oe(),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 qb(){await Lb(Je,{recursive:!0})}function es(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(t=t.replace(/^\.+|\.+$/g,""),!t||t==="."||t==="..")throw new Error("Invalid bundle name: results in an empty filename after sanitization.");return t}async function Vr(e){await qb();let t=`${es(e.name)}.json`,s=He(Je,t);return await Rb(s,JSON.stringify(e,null,2)+`
|
|
186
|
-
`,"utf-8"),
|
|
184
|
+
`}async function pu(e,t){await Wy(t,{recursive:!0});let s=zy(t,"SKILL.md"),i=Qy(e);await Gy(s,i,"utf-8")}async function mu(e){try{return await Yy(e),!0}catch{return!1}}import{readdir as Xy,stat as Zy}from"fs/promises";import{join as eb}from"path";async function tb(e){let t=0;try{let i=(await Xy(e,{recursive:!0})).map(async r=>{try{let o=await Zy(eb(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 gu(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 tb(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 sb(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 qr(e,t,s=20){let i=Math.round(e/t*s),n=s-i;return u.green("#".repeat(i))+u.dim("-".repeat(n))}var hu={claude:"Claude Code",codex:"Codex",openclaw:"OpenClaw",agents:"Agents"};function yu(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(sb(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])=>(hu[l]||l).length));for(let[l,c]of s){let f=hu[l]||l,d=Co(l,f.padEnd(n)),p=String(c).padStart(4);t.push(` ${d} ${p} ${qr(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} ${qr(e.byScope.global,r)}`),t.push(` ${"project".padEnd(n)} ${a} ${qr(e.byScope.project,r)}`),t.push(""),t.push(u.bold(" Duplicates")),e.duplicateGroups>0?(t.push(` ${u.yellow(`${e.duplicateGroups} group(s), ${e.duplicateInstances} total instance(s)`)}`),t.push(u.dim(` Run ${u.bold("asm audit")} to review`))):t.push(` ${u.green("None")}`),t.push(""),t.join(`
|
|
185
|
+
`)}import{access as ib,lstat as nb,mkdir as rb,readdir as ob,readFile as bu,rm as ab,stat as wu,symlink as lb}from"fs/promises";import{join as hi}from"path";async function Br(e){let t;try{t=await wu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=hi(e,"SKILL.md"),i;try{i=await bu(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=Z(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ae(n)}}async function vu(e,t,s,i){let n=hi(t,s),r=!1;try{await ib(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await ab(n,{recursive:!0,force:!0})}await rb(t,{recursive:!0}),await lb(e,n,"dir")}async function Ur(e){let t;try{t=await wu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=await ob(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=hi(e,n);try{if(!(await nb(r)).isDirectory())continue}catch{continue}let o=hi(r,"SKILL.md");try{let a=await bu(o,"utf-8"),l=Z(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ae(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as Rb,writeFile as Lb,readdir as Tu,access as Mu,mkdir as Ob,rm as Tb}from"fs/promises";import{join as Ge,resolve as Du,dirname as Mb}from"path";import{homedir as Db}from"os";import{fileURLToPath as Fb}from"url";import{readdir as cb,readFile as ub}from"fs/promises";import{join as db}from"path";function Kr(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var fb=10,pb=5,mb=3,hb=1;function gb(e,t){let s=Kr(e),i=Kr(t.name),n=Kr(t.description),r=0;for(let o of s)i.has(o)&&(r+=fb),n.has(o)&&(r+=mb),t.name.toLowerCase().includes(o)&&(r+=pb),t.description.toLowerCase().includes(o)&&(r+=hb);return r}async function ku(e){let t=new Map,s;try{s=await cb(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=db(e,i);try{let r=await ub(n,"utf-8"),o=JSON.parse(r);for(let a of o.skills)"license"in a||(a.license=""),"creator"in a||(a.creator=""),"compatibility"in a||(a.compatibility=""),"allowedTools"in a||(a.allowedTools=[]),"verified"in a||(a.verified=!1);t.set(`${o.owner}/${o.repo}`,o)}catch{}}return t}async function dt(){let e=await ku(bo()),t=await ku(yt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var yb=["license","creator","version"];function Su(e){return yb.includes(e)}function $u(e,t){return e[t]||""}function bb(e,t){if(t.has){for(let s of t.has)if(Su(s)&&!$u(e,s))return!1}if(t.missing){for(let s of t.missing)if(Su(s)&&$u(e,s))return!1}return!0}function xu(e){let t=[];return e.license||t.push("license"),e.creator||t.push("creator"),(!e.version||e.version==="0.0.0")&&t.push("version"),t}async function gi(e,t=20,s){let i=await dt(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!bb(a,s))continue;let l=r?1:gb(e,a);l>0&&n.push({skill:a,repo:{owner:o.owner,repo:o.repo},score:l})}return n.sort((o,a)=>a.score-o.score),n.slice(0,t)}async function Eu(){return(await dt()).reduce((t,s)=>t+s.skillCount,0)}import{readdir as wb,readFile as Cu,stat as Pu}from"fs/promises";import{join as Vr}from"path";var vb=[{id:"marketing",title:"Marketing Skills",description:"Marketing, growth, SEO, ASO, affiliate, sales, and conversion skills.",tags:["marketing","growth","seo"],keywords:["marketing","growth","seo","aso","affiliate","sales","copy","copywriting","conversion","cro","brand","social","campaign"]},{id:"writing",title:"Writing Skills",description:"Writing, editing, documentation, publishing, and content-production skills.",tags:["writing","content","docs"],keywords:["write","writing","writer","blog","article","content","docs","documentation","draft","copy","readme","paper","thesis","proposal"]},{id:"research",title:"Research Skills",description:"Research, academic, literature-review, citation, paper, and analysis skills.",tags:["research","academic","analysis"],keywords:["research","academic","scholar","paper","literature","citation","review","analysis","summar","evaluate","verify"]},{id:"engineering",title:"Engineering Skills",description:"Coding, debugging, testing, architecture, review, and software engineering skills.",tags:["engineering","coding","testing"],keywords:["code","coding","debug","test","testing","coverage","review","refactor","architecture","typescript","python","javascript","build","cli","api"]},{id:"frontend-design",title:"Frontend & Design Skills",description:"Frontend, UI, UX, visual design, component, theme, and landing-page skills.",tags:["frontend","design","ui"],keywords:["frontend","ui","ux","design","component","react","css","html","figma","theme","landing","layout","visual","brand","logo"]},{id:"devops",title:"DevOps Skills",description:"Deployment, CI/CD, infrastructure, cloud, Docker, Kubernetes, and automation skills.",tags:["devops","infra","automation"],keywords:["devops","deploy","deployment","ci","cd","pipeline","docker","kubernetes","terraform","ansible","cloud","infra","infrastructure","workflow","release"]},{id:"data-ai",title:"Data & AI Skills",description:"Data, analytics, AI, model, prompt, agent, and automation skills.",tags:["data","ai","agents"],keywords:["data","analytics","analysis","ai","agent","llm","model","prompt","openai","claude","gemini","automation","dataset","sql"]},{id:"product-business",title:"Product & Business Skills",description:"Product, strategy, PRD, planning, finance, resume, and business workflow skills.",tags:["product","business","planning"],keywords:["product","prd","strategy","planning","business","finance","resume","career","startup","market","competitor","customer","sales"]}],Au=2,kb=80,Sb=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],$b=["bundles","data/bundles",".asm/bundles"];function Xt(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Nu(e,t,s){let i=Xt(e),n=Xt(t),r=Xt(s),o=`${i}-${n}`;return r.startsWith(o)?r:`${o}-${r}`}function xb(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function Eb(e,t){let s=xb(e);return t.keywords.some(i=>s.includes(i))}function Iu(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function Cb(e){let t=new Set,s=[];for(let i of e){let n=`${i.installUrl||""}\0${i.name}`;t.has(n)||(t.add(n),s.push(i))}return s}function Ru(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function Jr(e){let t=[];if(!e.skills||e.skills.length<Au)return t;for(let s of vb){let i=e.skills.filter(r=>Eb(r,s)).slice(0,kb);if(i.length<Au)continue;let n=Nu(e.owner,e.repo,s.id);t.push({version:1,name:n,description:`${s.description} Derived from ${e.owner}/${e.repo}.`,author:`ASM (${e.owner}/${e.repo})`,createdAt:e.updatedAt,tags:["repo-derived","inferred",...s.tags,Xt(e.owner),Xt(e.repo)],skills:Ru(i.map(Iu)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function Ab(e,t,s){if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e,n=Array.isArray(i.skills)?i.skills:[];if(n.length===0)return null;let r=new Map(t.skills.map(l=>[l.name,l])),o=Cb(n.map(l=>{if(typeof l=="string"){let p=r.get(l);return p?Iu(p):null}if(!l||typeof l!="object"||Array.isArray(l))return null;let c=l,f=typeof c.name=="string"?c.name:"";if(!f)return null;let d=r.get(f);return d?{name:d.name,installUrl:d.installUrl,description:typeof c.description=="string"&&c.description?c.description:d.description||void 0,version:typeof c.version=="string"&&c.version?c.version:d.version||void 0}:null}).filter(l=>l!==null));if(o.length===0)return null;let a=typeof i.name=="string"&&i.name?i.name:s.replace(/\.json$/,"");return{version:1,name:Nu(t.owner,t.repo,a),description:typeof i.description=="string"&&i.description?i.description:`Bundle from ${t.owner}/${t.repo}.`,author:typeof i.author=="string"&&i.author?i.author:`ASM (${t.owner}/${t.repo})`,createdAt:typeof i.createdAt=="string"&&i.createdAt?i.createdAt:t.updatedAt,tags:Array.isArray(i.tags)?["repo-derived","explicit",...i.tags.filter(l=>typeof l=="string")]:["repo-derived","explicit"],skills:Ru(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function Pb(e){try{return(await Pu(e)).isFile()}catch{return!1}}async function Nb(e){try{return(await Pu(e)).isDirectory()}catch{return!1}}async function Ib(e){let t=[];for(let s of Sb){let i=Vr(e,s);if(await Pb(i))try{t.push({relPath:s,data:JSON.parse(await Cu(i,"utf-8"))})}catch{}}for(let s of $b){let i=Vr(e,s);if(!await Nb(i))continue;let n=[];try{n=await wb(i)}catch{continue}for(let r of n.filter(o=>o.endsWith(".json")).sort()){let o=`${s}/${r}`;try{t.push({relPath:o,data:JSON.parse(await Cu(Vr(i,r),"utf-8"))})}catch{}}}return t}async function Lu(e,t){let s=[],i=await Ib(e);for(let n of i){let r=n.data,o=Array.isArray(r?.bundles)?r.bundles:[r];for(let a of o){let l=Ab(a,t,n.relPath);l&&s.push(l)}}return yi(s)}function yi(e){let t=new Map;for(let s of e){let i=t.get(s.name);(!i||s.explicit&&!i.explicit)&&t.set(s.name,s)}return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}function Ou(e){let t=e.bundles||[],s=Jr(e);return yi([...t,...s])}var _b=Fb(import.meta.url),jb=Mb(_b),We=Ge(Db(),".config","agent-skill-manager","bundles"),bi=Du(jb,"..","data","bundles");function qb(e){let t=[];if(typeof e!="object"||e===null||Array.isArray(e))return{valid:!1,errors:["Bundle must be a JSON object."]};let s=e;if(s.version!==1&&t.push(`Unsupported bundle version: ${JSON.stringify(s.version)}. Expected 1.`),(typeof s.name!="string"||!s.name)&&t.push("Missing or empty 'name' field."),(typeof s.description!="string"||!s.description)&&t.push("Missing or empty 'description' field."),(typeof s.author!="string"||!s.author)&&t.push("Missing or empty 'author' field."),typeof s.createdAt!="string"&&t.push("Missing or invalid 'createdAt' field."),!Array.isArray(s.skills))return t.push("Missing or invalid 'skills' array."),{valid:!1,errors:t};s.skills.length===0&&t.push("Bundle must contain at least one skill.");for(let i=0;i<s.skills.length;i++){let n=s.skills[i];if(typeof n!="object"||n===null){t.push(`skills[${i}]: must be an object.`);continue}let r=n;(typeof r.name!="string"||!r.name)&&t.push(`skills[${i}]: missing or empty 'name'.`),(typeof r.installUrl!="string"||!r.installUrl)&&t.push(`skills[${i}]: missing or empty 'installUrl'.`)}return s.tags!==void 0&&(Array.isArray(s.tags)?s.tags.some(i=>typeof i!="string")&&t.push("'tags' must contain only strings."):t.push("'tags' must be an array of strings if provided.")),{valid:t.length===0,errors:t}}function Fu(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function _u(e,t){let s=t??await De(),i=s.skills[e.name]||s.skills[e.dirName],n;return e.isSymlink&&e.symlinkTarget?n=e.symlinkTarget:i?.source?n=i.source:n=e.path,{name:e.name,installUrl:n,description:e.description||void 0,version:e.version||void 0}}async function Bb(){await Ob(We,{recursive:!0})}function es(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(t=t.replace(/^\.+|\.+$/g,""),!t||t==="."||t==="..")throw new Error("Invalid bundle name: results in an empty filename after sanitization.");return t}async function Hr(e){await Bb();let t=`${es(e.name)}.json`,s=Ge(We,t);return await Lb(s,JSON.stringify(e,null,2)+`
|
|
186
|
+
`,"utf-8"),P(`bundle: saved to ${s}`),s}async function Zt(e){let t;try{t=await Rb(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=qb(s);if(!i.valid)throw new Error(`Invalid bundle:
|
|
187
187
|
${i.errors.join(`
|
|
188
|
-
`)}`);return s}async function ts(e){if(e.includes("/")||e.includes("\\")||e.endsWith(".json")){let i=
|
|
189
|
-
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let f of
|
|
190
|
-
`)}function
|
|
191
|
-
About to publish "${
|
|
188
|
+
`)}`);return s}async function ts(e){if(e.includes("/")||e.includes("\\")||e.endsWith(".json")){let i=Du(e);return Zt(i)}let t=`${es(e)}.json`,s=Ge(We,t);try{return await Zt(s)}catch(i){if(i?.message?.includes("Bundle file not found")){let n=Ge(bi,t);try{return await Zt(n)}catch(r){if(r?.message?.includes("Bundle file not found")){let o=await Ub(e);if(o)return o;throw new Error(`Bundle file not found: ${s}`)}throw r}}throw i}}async function ju(){let e=[];try{await Mu(bi);let s;try{s=await Tu(bi)}catch{s=[]}for(let i of s){if(!i.endsWith(".json"))continue;let n=Ge(bi,i);try{let r=await Zt(n);e.push(r)}catch{P(`bundle: skipping invalid predefined file ${n}`)}}}catch{}e.push(...await qu());let t=new Map;for(let s of e)t.has(s.name)||t.set(s.name,s);return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}async function qu(){try{return(await dt()).flatMap(t=>Ou(t))}catch(e){return P(`bundle: failed to load repo-derived bundles: ${e}`),[]}}async function Ub(e){let t=es(e),s=await qu();return s.find(i=>i.name===e)||s.find(i=>es(i.name)===t)||null}async function Bu(){let e=[];try{await Mu(We)}catch{return e}let t;try{t=await Tu(We)}catch{return e}for(let s of t){if(!s.endsWith(".json"))continue;let i=Ge(We,s);try{let n=await Zt(i);e.push(n)}catch{P(`bundle: skipping invalid file ${i}`)}}return e.sort((s,i)=>s.name.localeCompare(i.name)),e}async function Uu(e){let t=`${es(e)}.json`,s=Ge(We,t);try{return await Tb(s),P(`bundle: removed ${s}`),!0}catch(i){if(i?.code==="ENOENT")return!1;throw i}}import{readFile as Xb,realpath as Zb}from"fs/promises";import{join as ew,resolve as tw,relative as sw}from"path";var Ju=[{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 Kb(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`}P(`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",P(`security-audit: source analysis failed -> ${s.fetchError}`)}return s}function Vb(e){let t=new Map;for(let{relPath:n,content:r}of e){let o=r.split(`
|
|
189
|
+
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let f of Ju)if(f.pattern.test(l)){let d=f.category;t.has(d)||t.set(d,{description:f.description,matches:[]});let p=c.length>120?c.slice(0,120)+"...":c;t.get(d).matches.push({file:n,line:a+1,match:p,severity:f.severity})}}}let s=[];for(let[n,r]of t)s.push({category:n,description:r.description,matches:r.matches});let i={critical:0,warning:1,info:2};return s.sort((n,r)=>{let o=Math.min(...n.matches.map(l=>i[l.severity])),a=Math.min(...r.matches.map(l=>i[l.severity]));return o-a}),s}function Jb(e){let t=new Map;for(let r of e)for(let o of r.matches)for(let a of Ju)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 Hb(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 Te(e,t,s,i){P(`security-audit: scanning ${e}`);let n=await us(e),r=n.reduce((d,p)=>d+p.lineCount,0),o=null;s&&i&&(o=await Kb(s,i));let a=Vb(n),l=Jb(a),{verdict:c,reason:f}=Hb(a,l,o);return{scannedAt:new Date().toISOString(),skillName:t,skillPath:e,source:o,codeScans:a,permissions:l,totalFiles:n.length,totalLines:r,verdict:c,verdictReason:f}}var L=u,Ye=56,Wb={"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"},Ku={critical:0,warning:1,info:2};function Gb(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 Yb(e){switch(e){case"safe":return L.green;case"caution":return L.cyan;case"warning":return L.yellow;case"dangerous":return L.red}}function ft(e){switch(e){case"critical":return L.red("!!");case"warning":return L.yellow(" !");case"info":return L.dim(" i")}}function Wr(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function wi(e){return e.toLocaleString("en-US")}function Hu(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Vu(e){return Hu(e).length}function zb(e){let t=new Map;for(let s of e){let i=`${s.file}:${s.line}`,n=t.get(i);(!n||Ku[s.severity]<Ku[n.severity])&&t.set(i,s)}return Array.from(t.values())}function Qb(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 vi(e){let t=[],s=Gb(e.verdict),i=Hu(s),n=` ${L.bold(e.skillName)}`,r=` ${e.skillName}`,o=Ye-4,a=Math.max(1,o-r.length-i.length);if(t.push(""),t.push(L.dim(" +-- ")+L.bold("Security Audit")+L.dim(" "+"-".repeat(Ye-19)+"+")),t.push(L.dim(" |")+n+" ".repeat(a)+s+L.dim("|")),t.push(L.dim(" |")+L.dim(` ${wi(e.totalFiles)} files | ${wi(e.totalLines)} lines`)+" ".repeat(Math.max(1,o-` ${wi(e.totalFiles)} files | ${wi(e.totalLines)} lines`.length))+L.dim("|")),t.push(L.dim(" +"+"-".repeat(Ye-2)+"+")),e.source){let d=e.source;if(d.fetchError)t.push(` ${L.yellow("!")} Could not fetch profile: ${d.fetchError}`);else{let p=[];if(p.push(`${d.owner} ${d.isOrganization?L.cyan("(org)"):L.dim("(user)")}`),d.publicRepos!==null){let m=d.publicRepos,y=m<3?L.yellow(`${m} repos`):m<10?L.cyan(`${m} repos`):L.green(`${m} repos`);p.push(y)}d.accountAge&&p.push(d.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 d=Yb(e.verdict),p=e.verdict==="dangerous"||e.verdict==="warning"?ft("critical"):e.verdict==="caution"?ft("warning"):ft("info");t.push(` ${p} ${d(e.verdictReason)}`);let m=0,y=0,h=0;for(let k of e.codeScans)for(let S of k.matches)S.severity==="critical"?m++:S.severity==="warning"?y++:h++;let g=[];m>0&&g.push(L.red(`${m} critical`)),y>0&&g.push(L.yellow(`${y} warning`)),h>0&&g.push(L.dim(`${h} info`));let b=e.permissions.map(k=>k.type),w=b.length>0?L.dim(`Perms: ${b.join(", ")}`):"";t.push(` ${g.join(L.dim(" | "))} ${w}`)}if(t.push(""),e.codeScans.length>0){t.push(` ${L.bold("Findings")}`),t.push(L.dim(" "+"=".repeat(Ye-2)));for(let d of e.codeScans){let p=zb(d.matches),m=p.filter(R=>R.severity==="critical").length,y=p.filter(R=>R.severity==="warning").length,h=p.filter(R=>R.severity==="info").length,g=m>0?ft("critical"):y>0?ft("warning"):ft("info"),b=[];m>0&&b.push(L.red(`${m} critical`)),y>0&&b.push(L.yellow(`${y} warning`)),h>0&&b.push(L.dim(`${h} info`));let w=Wb[d.category],k=w?L.dim(`PERM: ${w}`):"",S=` ${g} ${L.bold(d.category)} (${b.join(", ")})`;if(k){let R=Vu(S),M=Vu(k),T=Math.max(2,Ye-R-M);t.push(S+" ".repeat(T)+k)}else t.push(S);let v=Qb(p),C=Math.min(24,Math.max(...v.map(R=>R.file.length))),E=0,x=3;for(let R of v){if(E>=x)break;let M=Wr(R.file,24),T=L.dim(M.padEnd(C));if(R.entries.length===1){let K=R.entries[0],I=Wr(K.match,50);t.push(` ${T} :${K.line} ${L.dim("--")} ${K.severity==="critical"?I:L.dim(I)}`),E++}else if(R.entries.length<=3){let K=R.entries.map(N=>`:${N.line}`).join(", "),I=Wr(R.entries[0].match,40);t.push(` ${T} ${K} ${L.dim("--")} ${L.dim(I)}`),E++}else{let I=R.entries.slice(0,3).map(F=>`:${F.line}`).join(", "),N=R.entries.length-3;t.push(` ${T} ${I} ${L.dim(`(+${N} more)`)}`),E++}}let j=v.length-Math.min(v.length,x);if(j>0){let R=p.length-v.slice(0,x).reduce((M,T)=>M+T.entries.length,0);R>0&&t.push(` ${L.dim(`... ${R} more in ${j} file${j>1?"s":""}`)}`)}t.push("")}}t.push(L.dim(" "+"=".repeat(Ye-2)));let l=new Date(e.scannedAt),c=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")} ${String(l.getHours()).padStart(2,"0")}:${String(l.getMinutes()).padStart(2,"0")}`,f=e.source&&!e.source.fetchError?`github.com/${e.source.owner}`:"";if(f){let d=Math.max(2,Ye-2-c.length-f.length);t.push(L.dim(` ${c}${" ".repeat(d)}${f}`))}else t.push(L.dim(` ${c}`));return t.push(""),t.join(`
|
|
190
|
+
`)}function Gr(e){return JSON.stringify(e,null,2)}async function H(e,t={}){if(e.length===0)throw new Error("runCommand requires a non-empty argv");let{spawn:s}=await import("child_process"),[i,...n]=e;return new Promise((r,o)=>{let a=s(i,n,{cwd:t.cwd,stdio:["ignore","pipe","pipe"]}),l="",c="",f=!1;a.stdout?.on("data",d=>{l+=d.toString()}),a.stderr?.on("data",d=>{c+=d.toString()}),a.on("error",d=>{if(f)return;if(f=!0,d.code==="ENOENT"){r({exitCode:127,stdout:l,stderr:d.message});return}o(d)}),a.on("close",d=>{f||(f=!0,r({exitCode:d??-1,stdout:l,stderr:c}))})})}function ki(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 iw(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/</g,"<").replace(/>/g,">").replace(/\|/g,"\\|")}function Yr(e){return iw(ki(e))}var ze="luongnv89/asm-registry";async function nw(e){let t=ew(e,"SKILL.md"),s;try{s=await Xb(t,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}. Run "asm init" to create one.`)}let i=Z(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=ae(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 rw(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 ow(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 aw(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 lw(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 cw(){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 uw(e){switch(e){case"safe":case"caution":return"pass";case"warning":return"warning";case"dangerous":return"dangerous"}}function Wu(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 dw(e){let t=Wu({metadata:e.metadata,author:e.metadata.creator||"unknown",commit:e.commit,repository:e.repository,securityVerdict:e.registryVerdict}),s=mi(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 Gu(e){let t=tw(e.path);P(`publish: starting for ${t}`),await rw(t);let s=await nw(t);P(`publish: parsed metadata for "${s.name}"`);let n=await(e._auditFn??Te)(t,s.name),r=uw(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 ow(t),a=await lw(t),l=await aw(t),c=await Zb(t),f=sw(l,c),d=f&&f!=="."?f:void 0,m=await(e._checkGhCliFn??cw)();if(!m.available||!m.authenticated){let B=m.available?"gh CLI not authenticated":"gh CLI not found";return dw({metadata:s,commit:o,repository:a,registryVerdict:r,securityReport:n,fallbackReason:B})}if(!m.login)throw new Error("Could not determine GitHub username. The gh CLI is authenticated but the API call failed. Check your network connection and try again.");let y=m.login,h=Wu({metadata:s,author:y,commit:o,repository:a,skillPath:d,securityVerdict:r}),g=mi(h);if(g.length>0)return{success:!1,manifest:h,prUrl:null,error:`Manifest validation failed: ${g.map(B=>`${B.field}: ${B.message}`).join("; ")}`,securityVerdict:r,securityReport:n};if(e.dryRun)return{success:!0,manifest:h,prUrl:null,error:null,securityVerdict:r,securityReport:n};if(!e.yes){if(!process.stdin.isTTY)return{success:!1,manifest:h,prUrl:null,error:"Cannot prompt for confirmation in non-interactive mode. Use --yes to skip.",securityVerdict:r,securityReport:n};let B=ki(s.name),ie=ki(y);process.stderr.write(`
|
|
191
|
+
About to publish "${B}" by ${ie} to ${ze}.
|
|
192
192
|
Security verdict: ${r}
|
|
193
193
|
|
|
194
|
-
Proceed? [y/N] `);let
|
|
195
|
-
`)&&(process.stdin.removeListener("data",
|
|
196
|
-
`,S=Buffer.from(k,"utf-8").toString("base64"),{stdout:v,exitCode:C}=await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/main`,"--jq",".object.sha"]);if(C!==0)return{success:!1,manifest:h,prUrl:null,error:`Failed to read fork's main branch. Ensure the fork exists at ${y}/asm-registry.`,securityVerdict:r,securityReport:n};let E=v.trim(),{exitCode:x}=await H(["gh","api",`repos/${y}/asm-registry/git/refs`,"-X","POST","-f",`ref=refs/heads/${b}`,"-f",`sha=${E}`]);x!==0&&await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/${b}`,"-X","PATCH","-f",`sha=${E}`,"-f","force=true"]);let{stderr:
|
|
197
|
-
`),{stdout:
|
|
194
|
+
Proceed? [y/N] `);let ke=await new Promise(de=>{let fe="",Me=Mi=>{fe+=Mi.toString(),fe.includes(`
|
|
195
|
+
`)&&(process.stdin.removeListener("data",Me),process.stdin.pause(),de(fe.trim()))};process.stdin.resume(),process.stdin.on("data",Me)});if(ke.toLowerCase()!=="y"&&ke.toLowerCase()!=="yes")return{success:!1,manifest:h,prUrl:null,error:"Publish aborted by user.",securityVerdict:r,securityReport:n}}P(`publish: forking ${ze}`),await H(["gh","repo","fork",ze,"--clone=false"]);let b=`publish/${y}/${s.name}`,w=`manifests/${y}/${s.name}.json`,k=JSON.stringify(h,null,2)+`
|
|
196
|
+
`,S=Buffer.from(k,"utf-8").toString("base64"),{stdout:v,exitCode:C}=await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/main`,"--jq",".object.sha"]);if(C!==0)return{success:!1,manifest:h,prUrl:null,error:`Failed to read fork's main branch. Ensure the fork exists at ${y}/asm-registry.`,securityVerdict:r,securityReport:n};let E=v.trim(),{exitCode:x}=await H(["gh","api",`repos/${y}/asm-registry/git/refs`,"-X","POST","-f",`ref=refs/heads/${b}`,"-f",`sha=${E}`]);x!==0&&await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/${b}`,"-X","PATCH","-f",`sha=${E}`,"-f","force=true"]);let{stderr:j,exitCode:R}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}`,"-X","PUT","-f",`message=Publish ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`]);if(R!==0){let{stdout:B,exitCode:ie}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}?ref=${b}`,"-q",".sha"]),ke=B.trim();if(ie===0&&ke){let{exitCode:de}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}`,"-X","PUT","-f",`message=Update ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`,"-f",`sha=${ke}`]);if(de!==0)return{success:!1,manifest:h,prUrl:null,error:"Failed to write manifest to registry fork.",securityVerdict:r,securityReport:n}}else return{success:!1,manifest:h,prUrl:null,error:`Failed to write manifest to registry fork. ${j}`,securityVerdict:r,securityReport:n}}let M=Yr(s.name),T=Yr(s.description),K=Yr(s.license),I=`Publish ${y}/${ki(s.name)}`,N=[`## Skill: ${M}`,"",`**Author:** ${y}`,`**Version:** ${s.version}`,`**Description:** ${T}`,`**License:** ${K}`,`**Repository:** ${a}`,`**Commit:** \`${o}\``,`**Security verdict:** ${r}`,"","---","","*This PR was generated by `asm publish`.*"].join(`
|
|
197
|
+
`),{stdout:F,stderr:O,exitCode:D}=await H(["gh","pr","create","--repo",ze,"--head",`${y}:${b}`,"--title",I,"--body",N]),Q=null;if(D===0)Q=F.trim();else{let B=O.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/);B&&(Q=B[0])}return Q?{success:!0,manifest:h,prUrl:Q,error:null,securityVerdict:r,securityReport:n}:{success:!1,manifest:h,prUrl:null,error:`Failed to create PR against ${ze}. ${O}`,securityVerdict:r,securityReport:n}}function Yu(e){let t=e.manifest;return t?["",` gh CLI is unavailable (${e.fallbackReason}).`," To publish manually:","",` 1. Fork ${ze} on GitHub`,` 2. Create branch: publish/${t.author}/${t.name}`,` 3. Add file: manifests/${t.author}/${t.name}.json`," 4. Paste the manifest below into that file",` 5. Open a PR against ${ze}`,"",' Run "asm doctor" to fix your environment.',""," Generated manifest:",JSON.stringify(t,null,2).split(`
|
|
198
198
|
`).map(i=>` ${i}`).join(`
|
|
199
199
|
`)].join(`
|
|
200
|
-
`):""}import{execFile as
|
|
201
|
-
`)[0];if(!n)return null;let r=n.split(/\s+/)[0];return r&&/^[0-9a-f]{40}$/.test(r)?r:null}catch(s){return
|
|
202
|
-
`)}function
|
|
203
|
-
`)[0],n=i.match(/(\d+\.\d+\.\d+)/);return{name:"GitHub CLI available",status:"pass",message:n?n[1]:i}}catch{return{name:"GitHub CLI available",status:"fail",message:"gh not found",fix:"Install GitHub CLI: https://cli.github.com"}}}async function
|
|
204
|
-
`);if(i.length<2)return{name:"Disk space",status:"warn",message:"Could not parse df output"};let n=i[1].split(/\s+/),r=parseInt(n[3],10);if(isNaN(r))return{name:"Disk space",status:"warn",message:"Could not parse available space"};let o=r/1024,a=o/1024;return o>100?{name:"Disk space",status:"pass",message:`OK (${a>=1?`${a.toFixed(1)} GB free`:`${Math.round(o)} MB free`})`}:{name:"Disk space",status:"fail",message:`${Math.round(o)} MB free (requires > 100 MB)`,fix:"Free disk space in home directory"}}catch{return{name:"Disk space",status:"warn",message:"Could not check disk space"}}}async function
|
|
205
|
-
`)}function
|
|
200
|
+
`):""}import{execFile as fw}from"child_process";import{promisify as pw}from"util";import{rm as Si,rename as zu,cp as Qu,access as mw,mkdir as hw}from"fs/promises";import{join as $i}from"path";import{homedir as Xu}from"os";var zr=pw(fw);async function gw(e,t,s){let i=new Array(e.length),n=0;async function r(){for(;n<e.length;){let a=n++;i[a]=await s(e[a])}}let o=[];for(let a=0;a<Math.min(t,e.length);a++)o.push(r());return await Promise.all(o),i}async function yw(e,t){try{let s=["ls-remote",e];t?s.push(t):s.push("HEAD");let{stdout:i}=await zr("git",s,{timeout:1e4}),n=i.split(`
|
|
201
|
+
`)[0];if(!n)return null;let r=n.split(/\s+/)[0];return r&&/^[0-9a-f]{40}$/.test(r)?r:null}catch(s){return P(`updater: git ls-remote failed for ${e}: ${s}`),null}}function Qr(e){return e.sourceType?e.sourceType:e.source.startsWith("local:")?"local":"github"}function Zu(e){if(e.startsWith("github:")){let t=e.slice(7),s=t.indexOf("#");return s!==-1&&(t=t.slice(0,s)),`https://github.com/${t}.git`}return e.startsWith("file://")?e:null}function bw(e){if(!e.startsWith("github:"))return null;let t=e.slice(7),s=t.indexOf("#");s!==-1&&(t=t.slice(0,s));let i=t.split("/");return i.length<2||!i[0]||!i[1]?null:{owner:i[0],repo:i[1]}}async function Xr(e){let t=e?.readLockFn??De,s=e?.fetchRegistryIndexFn??jr,i=e?.lock??await t(),n=Object.entries(i.skills);if(n.length===0)return{entries:[],outdatedCount:0,upToDateCount:0,untrackedCount:0,errorCount:0};let r=null;n.some(([,l])=>Qr(l)==="registry"||l.registryName)&&(r=await s());let a=await gw(n,5,async([l,c])=>{let f=Qr(c);if(!c.commitHash||c.commitHash==="unknown")return{name:l,installedCommit:c.commitHash||"unknown",latestCommit:"unknown",source:c.source,sourceType:f,status:"untracked"};if(f==="local")return{name:l,installedCommit:c.commitHash,latestCommit:c.commitHash,source:c.source,sourceType:f,status:"up-to-date"};if(f==="registry"&&r){let y=c.registryName||l,h=r.manifests.find(g=>g.name.toLowerCase()===y.toLowerCase());if(h){let g=h.commit!==c.commitHash;return{name:l,installedCommit:ye(c.commitHash),latestCommit:ye(h.commit),source:c.source,sourceType:f,status:g?"outdated":"up-to-date"}}}let d=Zu(c.source);if(!d)return{name:l,installedCommit:ye(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:f,status:"error",error:"Cannot determine remote URL"};let p=await yw(d,c.ref);if(!p)return{name:l,installedCommit:ye(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:f,status:"error",error:"Failed to fetch remote commit"};let m=p!==c.commitHash;return{name:l,installedCommit:ye(c.commitHash),latestCommit:ye(p),source:c.source,sourceType:f,status:m?"outdated":"up-to-date"}});return{entries:a,outdatedCount:a.filter(l=>l.status==="outdated").length,upToDateCount:a.filter(l=>l.status==="up-to-date").length,untrackedCount:a.filter(l=>l.status==="untracked").length,errorCount:a.filter(l=>l.status==="error").length}}async function ww(e,t,s,i){if(Qr(t)==="local")return{name:e,status:"skipped",reason:"Local skill (not updatable)"};let r=Zu(t.source);if(!r)return{name:e,status:"failed",reason:"Cannot determine remote URL"};let o=$i(Xu(),".config","agent-skill-manager",".tmp",`${e}-${Date.now()}`);try{let a=$i(Xu(),".config","agent-skill-manager",".tmp");await hw(a,{recursive:!0}),P(`updater: cloning latest ${e} to ${o}`);let l=["clone","--depth","1"];t.ref&&t.ref!=="HEAD"&&l.push("--branch",t.ref),l.push(r,o);try{await zr("git",l,{timeout:6e4})}catch(v){return{name:e,status:"failed",reason:`Clone failed: ${v.stderr||v.message}`}}let c=null;try{let{stdout:v}=await zr("git",["rev-parse","HEAD"],{cwd:o,timeout:5e3});c=v.trim()}catch{return{name:e,status:"failed",reason:"Could not read new commit"}}if(c===t.commitHash)return{name:e,status:"skipped",reason:"Already up to date"};P(`updater: running security audit on ${e}`);let f="safe";try{let v=i?.auditFn??Te,C=bw(t.source);if(f=(await v(o,e,C?.owner,C?.repo)).verdict,f==="dangerous")return{name:e,status:"skipped",reason:"Security audit: dangerous \u2014 update blocked",securityVerdict:f};if(f==="warning"||f==="caution"){if(!s)return{name:e,status:"skipped",reason:`Security audit: ${f} \u2014 use --yes to override`,securityVerdict:f};P(`updater: security audit ${f} for ${e} \u2014 proceeding (--yes)`)}}catch(v){return P(`updater: security audit failed for ${e}: ${v.message}`),{name:e,status:"failed",reason:`Security audit failed \u2014 skipping update: ${v.message}`}}let d=i?.loadConfigFn??U,p=i?.resolveProviderPathFn??oe,y=(await d()).providers.find(v=>v.name===t.provider),h=y?y.global:`~/.${t.provider}/skills`,g=p(h),b=$i(g,e),w=$i(o,".git");try{await Si(w,{recursive:!0,force:!0})}catch{}try{await mw(b)}catch{let v=i?.writeLockEntryFn??wt;return await Qu(o,b,{recursive:!0}),await v(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:ye(t.commitHash),newCommit:ye(c),securityVerdict:f}}let k=`${b}.bak-${Date.now()}`;try{await zu(b,k),await Qu(o,b,{recursive:!0}),await Si(k,{recursive:!0,force:!0})}catch(v){try{await Si(b,{recursive:!0,force:!0}),await zu(k,b)}catch{}return{name:e,status:"failed",reason:`Atomic swap failed: ${v.message}`}}return await(i?.writeLockEntryFn??wt)(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:ye(t.commitHash),newCommit:ye(c),securityVerdict:f}}finally{try{await Si(o,{recursive:!0,force:!0})}catch{}}}async function ed(e,t,s){let i=s?.readLockFn??De,n=s?.checkOutdatedFn??Xr,r=s?.updateSkillFn??ww,o=await i(),a=await n({lock:o}),l=a.entries.filter(d=>d.status==="outdated"),c=[];if(e&&e.length>0){let d=new Set(e.map(p=>p.toLowerCase()));l=l.filter(p=>d.has(p.name.toLowerCase()));for(let p of e)l.find(m=>m.name.toLowerCase()===p.toLowerCase())||(a.entries.find(y=>y.name.toLowerCase()===p.toLowerCase())?P(`updater: skill "${p}" is already up to date`):(P(`updater: skill "${p}" not found in lock file`),c.push(p)))}if(l.length===0)return{results:[],updatedCount:0,skippedCount:0,failedCount:0,...c.length>0?{warnings:c}:{}};let f=[];for(let d of l){let p=o.skills[d.name];if(!p)continue;let m=await r(d.name,p,t);f.push(m)}return{results:f,updatedCount:f.filter(d=>d.status==="updated").length,skippedCount:f.filter(d=>d.status==="skipped").length,failedCount:f.filter(d=>d.status==="failed").length,...c.length>0?{warnings:c}:{}}}function ye(e){return!e||e==="unknown"?"unknown":e.slice(0,7)}function td(e,t){if(e.entries.length===0)return"No skills installed.";let s=d=>d,i=t?u.red:s,n=t?u.green:s,r=t?u.yellow:s,o=t?u.dim:s,a=`${"Skill".padEnd(22)}${"Installed".padEnd(14)}${"Latest".padEnd(14)}Source`,l="\u2500".repeat(60),c=[a,l];for(let d of e.entries){let p=d.name.padEnd(22),m=d.installedCommit.padEnd(14),y,h;switch(d.status){case"outdated":y=i(d.latestCommit.padEnd(14)),h=d.sourceType;break;case"up-to-date":y=n(d.latestCommit.padEnd(14)),h=o("(up to date)");break;case"untracked":y=r("untracked".padEnd(14)),h=r("untracked");break;case"error":y=o("error".padEnd(14)),h=o(d.error||"error");break}c.push(`${p}${m}${y}${h}`)}c.push("");let f=[];return e.outdatedCount>0&&f.push(i(`${e.outdatedCount} outdated`)),e.upToDateCount>0&&f.push(n(`${e.upToDateCount} up to date`)),e.untrackedCount>0&&f.push(r(`${e.untrackedCount} untracked`)),e.errorCount>0&&f.push(o(`${e.errorCount} error`)),c.push(f.join(", ")),c.join(`
|
|
202
|
+
`)}function sd(e){return JSON.stringify({skills:e.entries.map(t=>({name:t.name,installed:t.installedCommit,latest:t.latestCommit,source:t.sourceType,status:t.status,...t.error?{error:t.error}:{}})),summary:{outdated:e.outdatedCount,upToDate:e.upToDateCount,untracked:e.untrackedCount,errors:e.errorCount}},null,2)}function id(e){return JSON.stringify({results:e.results.map(t=>({name:t.name,status:t.status,...t.reason?{reason:t.reason}:{},...t.oldCommit?{oldCommit:t.oldCommit}:{},...t.newCommit?{newCommit:t.newCommit}:{},...t.securityVerdict?{securityVerdict:t.securityVerdict}:{}})),summary:{updated:e.updatedCount,skipped:e.skippedCount,failed:e.failedCount}},null,2)}import{execFile as Lw}from"child_process";import{promisify as Ow}from"util";import{access as nd,readFile as od,readdir as Tw,writeFile as Mw,rm as Dw,stat as ad}from"fs/promises";import{join as Zr}from"path";import{homedir as Fw}from"os";import{constants as rd}from"fs";import{access as vw,realpath as kw,stat as Sw}from"fs/promises";import{constants as $w}from"fs";import{delimiter as xw,resolve as Ew,sep as Cw}from"path";var Aw="asm";function Pw(e){if(!e)return[];let t=new Set,s=[];for(let i of e.split(xw)){let n=i.trim();if(!n)continue;let r=n.endsWith(Cw)?n.slice(0,-1):n;t.has(r)||(t.add(r),s.push(r))}return s}async function Nw(e){try{if(!(await Sw(e)).isFile())return!1}catch{return!1}try{return await vw(e,$w.X_OK),!0}catch{return!1}}async function Iw(e){try{return await kw(e)}catch{return e}}async function Rw(e=process.env.PATH){let t=new Set,s=[];for(let i of Pw(e)){let n=Ew(i,Aw);if(!await Nw(n))continue;let r=await Iw(n);t.has(r)||(t.add(r),s.push({path:n,realPath:r}))}return s}async function xi(e=process.env.PATH){let t=await Rw(e);if(t.length===0)return{resolved:null,shadowed:[]};let[s,...i]=t;return{resolved:s,shadowed:i}}var pt=Ow(Lw);async function _w(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("git",["--version"],{timeout:5e3});return{name:"Git available",status:"pass",message:s.trim().replace("git version ","")}}catch{return{name:"Git available",status:"fail",message:"git not found",fix:"Install git: https://git-scm.com/downloads"}}}async function jw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("git",["--version"],{timeout:5e3}),i=s.match(/(\d+)\.(\d+)/);if(!i)return{name:"Git version",status:"warn",message:"Could not parse git version",fix:"Upgrade git: https://git-scm.com/downloads"};let n=parseInt(i[1],10),r=parseInt(i[2],10);return n>2||n===2&&r>=20?{name:"Git version",status:"pass",message:`${n}.${r} (>= 2.20)`}:{name:"Git version",status:"fail",message:`${n}.${r} (requires >= 2.20)`,fix:"Upgrade git: https://git-scm.com/downloads"}}catch{return{name:"Git version",status:"pass",message:"Skipped \u2014 git not available"}}}async function qw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("gh",["--version"],{timeout:5e3}),i=s.trim().split(`
|
|
203
|
+
`)[0],n=i.match(/(\d+\.\d+\.\d+)/);return{name:"GitHub CLI available",status:"pass",message:n?n[1]:i}}catch{return{name:"GitHub CLI available",status:"fail",message:"gh not found",fix:"Install GitHub CLI: https://cli.github.com"}}}async function Bw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("gh",["auth","status"],{timeout:1e4}),i=s.match(/Logged in to .+ account (\S+)/);return{name:"GitHub CLI authenticated",status:"pass",message:i?i[1]:"authenticated"}}catch(s){let n=(s?.stderr??"").match(/Logged in to .+ account (\S+)/);return n?{name:"GitHub CLI authenticated",status:"pass",message:n[1]}:{name:"GitHub CLI authenticated",status:"fail",message:"Not authenticated",fix:"Run: gh auth login"}}}async function Uw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("node",["--version"],{timeout:5e3}),i=s.trim().replace(/^v/,"");return parseInt(i.split(".")[0],10)>=18?{name:"Node.js version",status:"pass",message:i}:{name:"Node.js version",status:"fail",message:`${i} (requires >= 18.0)`,fix:"Upgrade Node.js: https://nodejs.org"}}catch{return{name:"Node.js version",status:"fail",message:"node not found",fix:"Install Node.js >= 18: https://nodejs.org"}}}async function Kw(e){try{let t=Zr(e,".asm-doctor-write-test");return await Mw(t,"test","utf-8"),await Dw(t),{writable:!0,exists:!0}}catch{}try{return await nd(e,rd.W_OK),{writable:!0,exists:!0}}catch{}try{return await nd(e,rd.F_OK),{writable:!1,exists:!0}}catch{return{writable:!0,exists:!1}}}async function Vw(e){let t=e.providers.filter(r=>r.enabled),s=0,i=0;for(let r of t){let o=oe(r.global);i++,(await Kw(o)).writable&&s++}if(s===i)return{name:"Agent directories writable",status:"pass",message:`${s}/${i} providers`};let n=i-s;return{name:"Agent directories writable",status:"warn",message:`${s}/${i} providers (${n} not writable)`,fix:"Fix permissions on agent skill directories"}}async function Jw(){let e=gt();try{let t=await od(e,"utf-8"),s=JSON.parse(t),i=[];return s.version===void 0&&i.push("version"),Array.isArray(s.providers)||i.push("providers"),i.length>0?{name:"Config file valid",status:"fail",message:`Missing required fields: ${i.join(", ")}`,fix:"Run: asm init"}:{name:"Config file valid",status:"pass",message:"OK"}}catch(t){return t?.code==="ENOENT"?{name:"Config file valid",status:"pass",message:"No config file (using defaults)"}:{name:"Config file valid",status:"fail",message:"Corrupted or unreadable config",fix:"Run: asm init, or delete corrupted config"}}}async function Hw(){let e=yo();try{let t=await od(e,"utf-8"),s=JSON.parse(t);if(s.version!==1||typeof s.skills!="object")return{name:"Lock file integrity",status:"fail",message:"Invalid lock file schema",fix:"Run: asm install to regenerate"};let i=s.skills,n=Object.entries(i),r=["source","installedAt","provider"],o=[];for(let[a,l]of n){if(typeof l!="object"||l===null){o.push(a);continue}let c=l;for(let f of r)if(!c[f]){o.push(a);break}}return o.length>0?{name:"Lock file integrity",status:"warn",message:`${n.length} skills tracked, ${o.length} with missing fields`,fix:"Run: asm install to regenerate"}:{name:"Lock file integrity",status:"pass",message:`${n.length} skills tracked`}}catch(t){return t?.code==="ENOENT"?{name:"Lock file integrity",status:"pass",message:"No lock file (first-time user)"}:{name:"Lock file integrity",status:"fail",message:"Corrupted lock file",fix:"Run: asm install to regenerate"}}}async function Ww(){try{let e=await fetch(Fr,{method:"HEAD",signal:AbortSignal.timeout(5e3)});return e.ok?{name:"Registry reachable",status:"pass",message:"OK"}:{name:"Registry reachable",status:"fail",message:`HTTP ${e.status}`,fix:"Check network connection or proxy settings"}}catch{return{name:"Registry reachable",status:"fail",message:"Network error",fix:"Check network connection or proxy settings"}}}async function Gw(e,t){let s=Object.entries(t.skills);if(s.length===0)return{name:"Installed skills intact",status:"pass",message:"No skills in lock file"};let i=[];for(let[o,a]of s){let l=e.providers.find(d=>d.name===a.provider);if(!l){i.push(o);continue}let c=oe(l.global),f=Zr(c,o);try{(await ad(f)).isDirectory()||i.push(o)}catch{i.push(o)}}if(i.length===0)return{name:"Installed skills intact",status:"pass",message:`${s.length} skills verified`};let n=i[0],r=i.length>1?` (+${i.length-1} more)`:"";return{name:"Installed skills intact",status:"fail",message:`Missing: ${n}${r}`,fix:`Run: asm update ${n}`}}async function Yw(e,t){let s=new Set(Object.keys(t.skills)),i=[];for(let n of e.providers.filter(r=>r.enabled)){let r=oe(n.global);try{let o=await Tw(r);for(let a of o)try{(await ad(Zr(r,a))).isDirectory()&&!s.has(a)&&i.push(a)}catch{}}catch{}}return i.length===0?{name:"No orphaned skills",status:"pass",message:"OK"}:{name:"No orphaned skills",status:"warn",message:`${i.length} skill(s) without lock entries`,fix:"Run: asm list to review"}}async function zw(e){let t=e?.execFn??pt;try{let{stdout:s}=await t("df",["-Pk",Fw()],{timeout:5e3}),i=s.trim().split(`
|
|
204
|
+
`);if(i.length<2)return{name:"Disk space",status:"warn",message:"Could not parse df output"};let n=i[1].split(/\s+/),r=parseInt(n[3],10);if(isNaN(r))return{name:"Disk space",status:"warn",message:"Could not parse available space"};let o=r/1024,a=o/1024;return o>100?{name:"Disk space",status:"pass",message:`OK (${a>=1?`${a.toFixed(1)} GB free`:`${Math.round(o)} MB free`})`}:{name:"Disk space",status:"fail",message:`${Math.round(o)} MB free (requires > 100 MB)`,fix:"Free disk space in home directory"}}catch{return{name:"Disk space",status:"warn",message:"Could not check disk space"}}}async function Qw(){try{let e=await xi();if(e.shadowed.length===0)return e.resolved?{name:"No PATH shadowing",status:"pass",message:`single install at ${e.resolved.path}`}:{name:"No PATH shadowing",status:"pass",message:"asm not yet on PATH"};let t=e.resolved,s=e.shadowed[0].path,i=e.shadowed.length>1?` (+${e.shadowed.length-1} more)`:"";return{name:"No PATH shadowing",status:"warn",message:`resolved ${t.path}, shadowed ${s}${i}`,fix:"Remove the duplicate install (`npm uninstall -g agent-skill-manager`) and keep only one."}}catch(e){return{name:"No PATH shadowing",status:"warn",message:`Could not scan PATH: ${e?.message??e}`}}}async function ld(){let e=await U(),t=await De(),i=(await Promise.allSettled([_w(),jw(),qw(),Bw(),Uw(),Vw(e),Jw(),Hw(),Ww(),Gw(e,t),Yw(e,t),zw(),Qw()])).map((a,l)=>a.status==="fulfilled"?a.value:{name:["Git available","Git version","GitHub CLI available","GitHub CLI authenticated","Node.js version","Agent directories writable","Config file valid","Lock file integrity","Registry reachable","Installed skills intact","No orphaned skills","Disk space","No PATH shadowing"][l],status:"fail",message:`Check threw: ${a.reason}`}),n=i.filter(a=>a.status==="pass").length,r=i.filter(a=>a.status==="warn").length,o=i.filter(a=>a.status==="fail").length;return{checks:i,passed:n,warnings:r,failures:o}}var Xw={pass:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function cd(e){let t=["Checking your environment...",""];for(let s of e.checks){let n=` ${Xw[s.status]} ${s.name}${s.message?` (${s.message})`:""}`;if(t.push(n),s.fix&&s.status!=="pass"){let r;s.fix.startsWith("Run: ")?r=s.fix:/^[a-z/~]/.test(s.fix)?r=`Run: ${s.fix}`:r=`Fix: ${s.fix}`,t.push(` \u2192 ${r}`)}}return t.push(""),t.push(`${e.passed} passed, ${e.warnings} warning${e.warnings!==1?"s":""}, ${e.failures} error${e.failures!==1?"s":""}`),t.join(`
|
|
205
|
+
`)}function ud(e){return JSON.stringify({checks:e.checks.map(t=>({name:t.name,status:t.status,message:t.message,...t.fix?{fix:t.fix}:{}})),summary:{passed:e.passed,warnings:e.warnings,failures:e.failures}},null,2)}import{readFile as to,writeFile as Zw,stat as mt,copyFile as ev,readdir as hd}from"fs/promises";import{join as ht,resolve as io,basename as ve,isAbsolute as no}from"path";var so="Relocate `README.md` out of the skill root so SKILL.md remains the sole top-level document (e.g., move it to `docs/README.md`).",dd=["name","description","version","license","author","creator","compatibility","allowed-tools","effort","tags","metadata"],fd=["add","analyze","audit","build","check","configure","convert","create","debug","deploy","detect","edit","evaluate","explain","export","extract","fetch","find","fix","format","generate","identify","improve","index","inspect","install","list","manage","migrate","optimize","parse","plan","prepare","publish","refactor","remove","rename","report","research","review","run","scaffold","scan","score","search","set","setup","show","summarize","sync","test","transform","translate","update","validate","verify","write"],tv=["confirm","confirmation","error","errors","fail","failure","caution","warning","prerequisite","prerequisites","requires","requirements","rollback","dry-run","dry run","safety","validate","validation","check","backup"],sv=["acceptance criteria","expected output","expected result","edge case","edge cases","test","tests","testing","verify","verification","assert","example input","example output","given","then"],iv=["reference","references","see","template","templates","script","scripts","helper","helpers","link"],nv=["when to use","quick start","overview","instructions","steps","workflow","phases","progressive"];function gd(e){let t=e.split(`
|
|
206
206
|
`);if(t.length===0||t[0].trim()!=="---")return{rawFrontmatter:null,body:e};for(let s=1;s<t.length;s++)if(t[s].trim()==="---"){let i=t.slice(1,s).join(`
|
|
207
207
|
`),n=t.slice(s+1).join(`
|
|
208
208
|
`);return{rawFrontmatter:i,body:n}}return{rawFrontmatter:t.slice(1).join(`
|
|
209
|
-
`),body:""}}function
|
|
210
|
-
`).length:0}function io(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function nv(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function Ci(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function rv(e){return/```[\s\S]+?```/m.test(e)}function ov(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function av(e,t,s,i){let n=[],r=[],o=0;s!==null?(o+=2,n.push("Has YAML frontmatter block.")):(n.push("SKILL.md has no YAML frontmatter."),r.push("Add a YAML frontmatter block delimited by `---` with at least `name` and `description` fields."));let a=!!(e.name&&e.name.trim()),l=!!(e.description&&e.description.trim());a?o+=1.5:(n.push("Missing required field: name."),r.push("Add `name:` to frontmatter (use the skill directory name).")),l?o+=1.5:(n.push("Missing required field: description."),r.push("Add a one-line `description:` to frontmatter."));let c=ae(e);c&&c!=="0.0.0"?o+=1:(n.push("Missing or default version."),r.push("Set `metadata.version` (or top-level `version`) using semver (e.g. 0.1.0).")),!!(e.author||e["metadata.author"]||e.creator||e["metadata.creator"])?o+=1:(n.push("Missing `author`."),r.push("Add an `author` field so users know who authored and maintains the skill.")),!!e.license?o+=1:(n.push("Missing `license`."),r.push("Add a `license` field (e.g. `license: MIT`)."));let m=t.trim().length>=20,y=nv(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(eo))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function lv(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=io(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&&(ud.includes(a)||ud.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 cv(e,t){let s=[],i=[],n=0,r=Ci(t,iv);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.'),ov(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=rv(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=io(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 uv(e,t){let s=[],i=[],n=0,r=io(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=Ci(t,sv);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=>hd(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 dv(e,t){let s=[],i=[],n=0,r=Ci(t,ev);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 fv(e,t){let s=[],i=[],n=0,r=Ci(t,tv);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 pv(e,t){let s=[],i=[],n=0,r=(e.name||"").trim();if(r){let l=/^[a-z][a-z0-9-]*$/.test(r),c=r.length<=40;l&&c?(n+=4,s.push(`name "${r}" follows kebab-case convention.`)):(l||(s.push(`name "${r}" is not lowercase kebab-case.`),i.push(`Rename to lowercase kebab-case (e.g. "${r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}").`)),c||s.push(`name is ${r.length} chars; keep it <= 40.`))}else i.push("Add a kebab-case `name` (e.g. `my-skill`).");let o=t.match(/^#{1,6}\s+(.+)$/gm)||[];return o.length>0&&(o.filter(f=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(f)).length/o.length>=.5?(n+=3,s.push("Most headings use action/imperative labels.")):(n+=1,i.push("Rename body headings to action-oriented labels (e.g. `## Instructions`, `## When to Use`)."))),/(?:\s\s|\bTODO\b|\bFIXME\b|\?{2,})/.test(e.description||"")?i.push("Clean up description \u2014 remove TODOs, FIXMEs, double spaces, or trailing punctuation."):(n+=2,s.push("Description looks clean (no TODO/FIXME/stray noise).")),{id:"naming",name:"Naming & conventions",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function ss(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=X(t),{rawFrontmatter:o,body:a}=md(t),l=[av(r,a,o,n),lv(r,a),cv(r,a),uv(r,a),dv(r,a),fv(r,a),pv(r,a)];if(r.name&&we(s)===r.name){let g=l.find(b=>b.id==="naming");g.score<g.max&&(g.score=Math.min(g.max,g.score+1),g.findings.push("Directory name matches frontmatter `name`."))}let c=l.reduce((g,b)=>g+b.score,0),f=l.reduce((g,b)=>g+b.max,0),d=Math.round(c/f*100),p="F";d>=90?p="A":d>=80?p="B":d>=65?p="C":d>=50&&(p="D");let m=[];l.find(g=>g.id==="structure")?.suggestions.includes(eo)&&m.push(eo);let h=[...l].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of h){for(let b of g.suggestions){if(m.length>=3)break;m.includes(b)||m.push(b)}if(m.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:l,overallScore:d,grade:p,topSuggestions:m,frontmatter:r}}async function gd(e){let t=so(e)?e:to(e),s;try{s=await pt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Zr(i,"utf-8"),ss({content:n,skillPath:we(t)==="SKILL.md"?we(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=mt(t,"SKILL.md");try{n=await Zr(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await pd(t)}catch{r=void 0}return ss({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function mv(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function hv(e){let t=e.split(`
|
|
209
|
+
`),body:""}}function yd(e){return e?e.split(`
|
|
210
|
+
`).length:0}function ro(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function rv(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function Ei(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function ov(e){return/```[\s\S]+?```/m.test(e)}function av(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function lv(e,t,s,i){let n=[],r=[],o=0;s!==null?(o+=2,n.push("Has YAML frontmatter block.")):(n.push("SKILL.md has no YAML frontmatter."),r.push("Add a YAML frontmatter block delimited by `---` with at least `name` and `description` fields."));let a=!!(e.name&&e.name.trim()),l=!!(e.description&&e.description.trim());a?o+=1.5:(n.push("Missing required field: name."),r.push("Add `name:` to frontmatter (use the skill directory name).")),l?o+=1.5:(n.push("Missing required field: description."),r.push("Add a one-line `description:` to frontmatter."));let c=ae(e);c&&c!=="0.0.0"?o+=1:(n.push("Missing or default version."),r.push("Set `metadata.version` (or top-level `version`) using semver (e.g. 0.1.0).")),!!(e.author||e["metadata.author"]||e.creator||e["metadata.creator"])?o+=1:(n.push("Missing `author`."),r.push("Add an `author` field so users know who authored and maintains the skill.")),!!e.license?o+=1:(n.push("Missing `license`."),r.push("Add a `license` field (e.g. `license: MIT`)."));let m=t.trim().length>=20,y=rv(t,1);if(m?(o+=1,n.push("Body has meaningful content.")):(n.push("Body content is too short (<20 chars of instructions)."),r.push("Flesh out the markdown body with at least one paragraph of instructions for the agent.")),y?(o+=1,n.push("Body uses markdown headings.")):(n.push("Body has no markdown headings."),r.push("Add section headings (e.g. `## When to Use`, `## Instructions`) so the agent can navigate the skill quickly.")),i){let h=i.find(g=>g.toLowerCase()==="readme.md");h&&(n.push(`\`${h}\` found at skill root; move it to a subdirectory (e.g., \`docs/README.md\`).`),r.push(so))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function cv(e,t){let s=[],i=[],n=0,r=(e.description||"").trim();if(!r)return s.push("No description."),i.push("Write a one-sentence description that says specifically what the skill does and when to use it."),{id:"description",name:"Description quality",score:0,max:10,findings:s,suggestions:i};let o=ro(r);s.push(`Description is ${o} words.`),o>=8&&o<=40?n+=4:o>=5&&o<8?(n+=2,i.push("Lengthen the description slightly so it names both the action and the trigger (aim for 8\u201320 words).")):o>=41&&o<=60?(n+=2,i.push("Trim the description \u2014 aim for under 40 words. Move the long version to the markdown body.")):o>60?(n+=0,i.push("Description is too long. Keep it under 40 words; put detail in the body.")):(n+=0,i.push("Description is too short. Aim for 8\u201320 words."));let a=r.split(/\s+/)[0]?.toLowerCase().replace(/[^\w-]/g,"");return!!(a&&(fd.includes(a)||fd.includes(a.replace(/s$/,""))))?(n+=3,s.push("Starts with an action verb.")):(s.push(`Does not start with a recognized action verb (got "${a??""}").`),i.push('Start the description with an imperative action verb (e.g. "Generate...", "Analyze...", "Review...").')),/\buse when\b|\btrigger\b|\bwhen\b|\bfor\b/i.test(r)||/\b(before|after|during)\b/i.test(r)?(n+=3,s.push("Mentions a trigger or use-case signal.")):(s.push("No explicit trigger / use-case phrase."),i.push('Name the trigger in the description \u2014 e.g. "Use when...", "for reviewing...", "before publishing...".')),{id:"description",name:"Description quality",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function uv(e,t){let s=[],i=[],n=0,r=Ei(t,nv);r.length>=2?(n+=3,s.push(`Progressive disclosure cues present: ${r.slice(0,3).join(", ")}.`)):r.length===1?(n+=1,i.push('Add clearer section labels \u2014 e.g. "## When to Use" and "## Instructions" \u2014 to support progressive disclosure.')):i.push('Structure the body with "## When to Use" and "## Instructions" sections so the agent reads only what it needs.'),av(t)?(n+=2,s.push("Uses lists or numbered steps.")):(s.push("No lists or steps detected."),i.push("Use bulleted or numbered steps to narrow the agent's degrees of freedom."));let o=ov(t),a=/\bexample\b/i.test(t);o&&a?(n+=2,s.push("Includes example code block.")):o||a?(n+=1,i.push('Back up examples with fenced code blocks labelled under "## Example" so the agent sees concrete input/output.')):i.push('Add an "## Example" section with a fenced code block showing the desired output.');let l=(t.match(/^\s*[-*0-9.]*\s*(Do|Use|Run|Call|Check|Validate|Return|Emit|Write|Read|Ask|Confirm|Avoid|Never|Always)\b/gim)||[]).length;l>=3?(n+=2,s.push(`Uses imperative voice (${l} cues).`)):l>=1?(n+=1,i.push("Favor imperative voice (Do / Use / Avoid / Never) to narrow the agent's choices.")):i.push('Rewrite instructions in the imperative mood \u2014 e.g. "Run `git status` first" instead of "you might want to run".');let c=ro(t);return c>=80&&c<=3e3?(n+=1,s.push(`Body length within healthy range (${c} words).`)):c<80?(s.push(`Body is very short (${c} words).`),i.push("Expand the instructions; an underspecified skill gives the agent too much freedom.")):(s.push(`Body is very long (${c} words).`),i.push("Split large content into referenced files; keep SKILL.md focused under ~3000 words.")),{id:"prompt-engineering",name:"Prompt engineering",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function dv(e,t){let s=[],i=[],n=0,r=ro(t);s.push(`Body is ${r} words.`),r>=120&&r<=1500?n+=4:r>=60&&r<120?(n+=2,i.push("Expand instructions slightly \u2014 too little context can push the agent to improvise.")):r>1500&&r<=3e3?(n+=2,i.push("Consider moving large sections into referenced files (e.g. `references/*.md`) and linking them instead of inlining.")):r>3e3&&(n+=0,i.push("Body is over 3000 words \u2014 split long content into referenced files or templates."));let o=Ei(t,iv);o.length>=2?(n+=3,s.push(`References external files or links (${o.slice(0,3).join(", ")}).`)):o.length===1?(n+=1,i.push('Link out to supporting files (e.g. "see `references/examples.md`") instead of inlining them.')):i.push('Offload verbose content to referenced files and link to them ("see `./templates/x.md`").');let l=(t.match(/```[\s\S]+?```/g)||[]).filter(c=>yd(c)>60);return l.length===0?(n+=2,s.push("No oversized code blocks.")):(s.push(`${l.length} code block(s) longer than 60 lines.`),i.push("Move large code blocks into referenced template files; link to them from SKILL.md.")),/\btoken\b|\bbudget\b|\bcontext window\b/i.test(t)&&(n+=1,s.push("Mentions tokens/budget/context window.")),{id:"context-efficiency",name:"Context efficiency",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function fv(e,t){let s=[],i=[],n=0,r=Ei(t,tv);r.length>=4?(n+=4,s.push(`Covers multiple safety cues (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=2,s.push(`Mentions a few safety cues: ${r.join(", ")}.`),i.push("Add explicit error-handling and confirmation steps so the agent knows how to recover from failures.")):r.length===1?(n+=1,i.push('Expand the safety section \u2014 include prerequisites, validation steps, and what to do "on error".')):i.push("Describe prerequisites, confirmation prompts, and error-handling steps to reduce blast radius.");let o=/\b(rm\s|delete|remove|drop|force|overwrite|destructive)\b/i.test(t),a=/\bconfirm\b|\bdry-?run\b|\bare you sure\b|\bbackup\b/i.test(t);return o&&a?(n+=3,s.push("Destructive actions paired with confirmation/dry-run.")):o?(s.push("References destructive actions without explicit confirmation/dry-run."),i.push("Pair any destructive command with an explicit confirmation prompt, dry-run flag, or backup step.")):n+=1.5,/\bprerequisit/i.test(t)||/\brequire/i.test(t)||/\bdepend/i.test(t)?(n+=3,s.push("Declares prerequisites or requirements.")):(s.push("No prerequisites / requirements section."),i.push('Add a "## Prerequisites" block listing required tools, credentials, and environment state.')),{id:"safety",name:"Safety & guardrails",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function pv(e,t){let s=[],i=[],n=0,r=Ei(t,sv);return r.length>=4?(n+=5,s.push(`Many testability cues present (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=3,s.push(`Some testability cues: ${r.join(", ")}.`),i.push('Add an "## Acceptance Criteria" block listing verifiable outputs or checklist items.')):r.length===1?(n+=1,i.push('Add concrete "expected output" examples so the agent can self-check.')):i.push('Add a "## Acceptance Criteria" section with testable statements (e.g. "produces a JSON report with overall_score").'),/expected\s+(output|result|response)/i.test(t)?(n+=3,s.push("Describes expected output/result.")):i.push('Include an "Expected output" example so reviewers and the agent can verify correctness.'),/\bedge case|gotcha|pitfall|limitation/i.test(t)?(n+=2,s.push("Mentions edge cases or limitations.")):i.push('Add a short "Edge cases" list to describe inputs the skill should reject or handle carefully.'),{id:"testability",name:"Testability",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function mv(e,t){let s=[],i=[],n=0,r=(e.name||"").trim();if(r){let l=/^[a-z][a-z0-9-]*$/.test(r),c=r.length<=40;l&&c?(n+=4,s.push(`name "${r}" follows kebab-case convention.`)):(l||(s.push(`name "${r}" is not lowercase kebab-case.`),i.push(`Rename to lowercase kebab-case (e.g. "${r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}").`)),c||s.push(`name is ${r.length} chars; keep it <= 40.`))}else i.push("Add a kebab-case `name` (e.g. `my-skill`).");let o=t.match(/^#{1,6}\s+(.+)$/gm)||[];return o.length>0&&(o.filter(f=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(f)).length/o.length>=.5?(n+=3,s.push("Most headings use action/imperative labels.")):(n+=1,i.push("Rename body headings to action-oriented labels (e.g. `## Instructions`, `## When to Use`)."))),/(?:\s\s|\bTODO\b|\bFIXME\b|\?{2,})/.test(e.description||"")?i.push("Clean up description \u2014 remove TODOs, FIXMEs, double spaces, or trailing punctuation."):(n+=2,s.push("Description looks clean (no TODO/FIXME/stray noise).")),{id:"naming",name:"Naming & conventions",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function ss(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=Z(t),{rawFrontmatter:o,body:a}=gd(t),l=[lv(r,a,o,n),cv(r,a),uv(r,a),dv(r,a),fv(r,a),pv(r,a),mv(r,a)];if(r.name&&ve(s)===r.name){let g=l.find(b=>b.id==="naming");g.score<g.max&&(g.score=Math.min(g.max,g.score+1),g.findings.push("Directory name matches frontmatter `name`."))}let c=l.reduce((g,b)=>g+b.score,0),f=l.reduce((g,b)=>g+b.max,0),d=Math.round(c/f*100),p="F";d>=90?p="A":d>=80?p="B":d>=65?p="C":d>=50&&(p="D");let m=[];l.find(g=>g.id==="structure")?.suggestions.includes(so)&&m.push(so);let h=[...l].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of h){for(let b of g.suggestions){if(m.length>=3)break;m.includes(b)||m.push(b)}if(m.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:l,overallScore:d,grade:p,topSuggestions:m,frontmatter:r}}async function bd(e){let t=no(e)?e:io(e),s;try{s=await mt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await to(i,"utf-8"),ss({content:n,skillPath:ve(t)==="SKILL.md"?ve(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=ht(t,"SKILL.md");try{n=await to(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await hd(t)}catch{r=void 0}return ss({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function hv(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function gv(e){let t=e.split(`
|
|
211
211
|
`),s=[],i=[],n=0;for(;n<t.length;){let c=t[n];if(!c.trim()){n++;continue}let d=c.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!d)return{newFrontmatter:e,changed:!1};let p=d[1],m=d[2];if(m===""||m===">"||m==="|"){let y=[c];for(n++;n<t.length;){let h=t[n];if(h.trim()===""){y.push(h),n++;continue}if(/^\s+/.test(h))y.push(h),n++;else break}i.push({key:p,text:y.join(`
|
|
212
|
-
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let f=
|
|
213
|
-
`),changed:a}}function
|
|
212
|
+
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let f=dd.indexOf(c);return f===-1?dd.length+1:f},o=[...s].sort((c,f)=>{let d=r(c.key),p=r(f.key);return d!==p?d-p:s.indexOf(c)-s.indexOf(f)}),a=o.some((c,f)=>c!==s[f]);return{newFrontmatter:[...o.map(c=>c.text),...i.map(c=>c.text)].join(`
|
|
213
|
+
`),changed:a}}function yv(e,t={}){let s=[],i=[],n=e.replace(/\r\n/g,`
|
|
214
214
|
`);n!==e&&s.push({id:"normalise-line-endings",description:"Convert CRLF line endings to LF."});let r=n.split(`
|
|
215
215
|
`),o=r.map(g=>g.replace(/[ \t]+$/g,""));o.some((g,b)=>g!==r[b])&&s.push({id:"strip-trailing-whitespace",description:"Strip trailing whitespace from lines."}),n=o.join(`
|
|
216
|
-
`);let{rawFrontmatter:a,body:l}=
|
|
216
|
+
`);let{rawFrontmatter:a,body:l}=gd(n),c=Z(n);if(a===null)return i.push({id:"missing-frontmatter",description:"SKILL.md has no frontmatter \u2014 not auto-fixable (requires author decisions)."}),{newContent:n,applied:s,skipped:i};let f=a;if(!!(c.version||c["metadata.version"])||(f=eo(f,"version","0.1.0"),s.push({id:"add-missing-version",description:"Add `version: 0.1.0`."})),!!!(c.author||c["metadata.author"]||c.creator||c["metadata.creator"])){let g=t.gitAuthor?.trim();g?(f=eo(f,"author",g),s.push({id:"add-missing-author",description:`Add \`author: ${g}\` from git config.`})):i.push({id:"add-missing-author",description:"Missing `author` \u2014 no git user.name found to fill in safely."})}if(!c.effort){let g=hv(yd(l));f=eo(f,"effort",g),s.push({id:"infer-missing-effort",description:`Infer \`effort: ${g}\` from body size.`})}c.description||i.push({id:"missing-description",description:"Missing `description` \u2014 content-level fix, left to the author."});let m=gv(f);m.changed&&(s.push({id:"reorder-frontmatter",description:"Reorder frontmatter fields to canonical order."}),f=m.newFrontmatter);let y=l.replace(/^\n+/,""),h=`---
|
|
217
217
|
${f.replace(/^\n+|\n+$/g,"")}
|
|
218
218
|
---
|
|
219
219
|
|
|
220
220
|
${y}`;return h.endsWith(`
|
|
221
221
|
`)||(h+=`
|
|
222
222
|
`),e.replace(/\r\n/g,`
|
|
223
|
-
`),{newContent:h,applied:s,skipped:i}}function
|
|
223
|
+
`),{newContent:h,applied:s,skipped:i}}function eo(e,t,s){if(new RegExp(`^${t}:\\s*`,"m").test(e))return e;let n=/[:#{}\[\],&*?|<>=!%@`"']/.test(s)?JSON.stringify(s):s,r=e.length===0||e.endsWith(`
|
|
224
224
|
`)?"":`
|
|
225
225
|
`;return`${e}${r}${t}: ${n}
|
|
226
|
-
`}function
|
|
226
|
+
`}function bv(e,t,s="SKILL.md"){if(e===t)return"";let i=e.split(`
|
|
227
227
|
`),n=t.split(`
|
|
228
228
|
`),r=[`--- a/${s}`,`+++ b/${s}`],o=0;for(;o<i.length&&o<n.length&&i[o]===n[o];)o++;let a=0;for(;a<i.length-o&&a<n.length-o&&i[i.length-1-a]===n[n.length-1-a];)a++;let l=i.slice(o,i.length-a),c=n.slice(o,n.length-a),f=o+1,d=o+1;r.push(`@@ -${f},${l.length} +${d},${c.length} @@`);let p=i.slice(Math.max(0,o-3),o).map(y=>` ${y}`),m=i.slice(i.length-a,Math.min(i.length,i.length-a+3)).map(y=>` ${y}`);r.push(...p);for(let y of l)r.push(`-${y}`);for(let y of c)r.push(`+${y}`);return r.push(...m),r.join(`
|
|
229
|
-
`)}async function
|
|
230
|
-
`)}function
|
|
229
|
+
`)}async function wd(e,t){let s=no(e)?e:io(e),i,n=await mt(s).catch(()=>null);if(!n)throw new Error(`Skill path does not exist: ${s}`);if(n.isFile())i=s;else if(n.isDirectory())i=ht(s,"SKILL.md");else throw new Error(`Skill path is not a directory or file: ${s}`);let r;try{r=await to(i,"utf-8")}catch{throw new Error(`SKILL.md not found at ${i}.`)}let o=yv(r,{gitAuthor:t.gitAuthor}),a=bv(r,o.newContent),l=null;return!t.dryRun&&o.newContent!==r&&(l=`${i}.bak`,await ev(i,l),await Zw(i,o.newContent,"utf-8")),{report:ss({content:t.dryRun?r:o.newContent,skillPath:s,skillMdPath:i}),applied:o.applied,skipped:o.skipped,diff:a,dryRun:t.dryRun,backupPath:l,skillMdPath:i}}async function vd(){try{let{stdout:e,exitCode:t}=await H(["git","config","--global","--get","user.name"]);if(t!==0)return null;let s=e.trim();return s||null}catch{return null}}function wv(e,t,s=20){let i=Math.round(e/t*s);return"\u2588".repeat(i)+"\u2591".repeat(Math.max(0,s-i))}function Ci(e){let t=[];t.push(`Skill evaluation: ${e.skillPath}`),t.push(`SKILL.md: ${e.skillMdPath}`),t.push(""),t.push(`Overall score: ${e.overallScore}/100 (${e.grade})`);let s=(e.providers??[]).filter(i=>i.id!=="quality");for(let i of s){let n=i.passed?"pass":"fail",r=`${i.id}@${i.version}`;t.push(` ${r}: ${i.score}/100 ${n}`)}t.push(""),t.push("Categories:");for(let i of e.categories)t.push(` ${i.name.padEnd(28)} ${String(i.score).padStart(2)}/${i.max} ${wv(i.score,i.max)}`);if(t.push(""),e.topSuggestions.length>0){t.push("Top suggestions:");for(let i of e.topSuggestions)t.push(` \u2022 ${i}`)}else t.push("No suggestions \u2014 skill looks great.");for(let i of s){let n=vv(i.raw);if(n&&n.length>0){t.push(""),t.push(`${i.id}@${i.version} breakdown:`);for(let r of n){let o=r.passed?"\u221A":r.severity==="warning"?"\u26A0":"\xD7";t.push(` ${o} ${r.label}`),r.passed||t.push(` [${r.severity}] ${r.message}`)}continue}if(i.findings.length!==0){t.push(""),t.push(`${i.id}@${i.version} findings:`);for(let r of i.findings)t.push(` [${r.severity}] ${r.message}`)}}return t.join(`
|
|
230
|
+
`)}function vv(e){if(!e||typeof e!="object")return null;let t=e.checks;if(!Array.isArray(t))return null;let s=[];for(let i of t){if(!i||typeof i!="object")return null;let n=i;if(typeof n.id!="string"||typeof n.label!="string"||typeof n.passed!="boolean"||typeof n.message!="string"||n.severity!=="error"&&n.severity!=="warning")return null;s.push({id:n.id,label:n.label,passed:n.passed,severity:n.severity,message:n.message})}return s}function kd(e){return JSON.stringify(e,null,2)}function Sd(e){let t=[];if(e.applied.length===0&&e.skipped.length===0)return t.push("No fixes needed \u2014 SKILL.md is already clean."),t.join(`
|
|
231
231
|
`);if(e.applied.length>0){t.push(`${e.dryRun?"Would apply":"Applied"} ${e.applied.length} fix(es):`);for(let s of e.applied)t.push(` \u2022 ${s.description}`)}if(e.skipped.length>0){t.push(""),t.push(`Skipped ${e.skipped.length} issue(s) (not auto-fixable):`);for(let s of e.skipped)t.push(` \u2022 ${s.description}`)}return e.diff&&(t.push(""),t.push("Diff:"),t.push(e.diff)),!e.dryRun&&e.backupPath&&(t.push(""),t.push(`Backup: ${e.backupPath}`)),t.join(`
|
|
232
|
-
`)}async function
|
|
233
|
-
`)}function
|
|
232
|
+
`)}async function kv(e){let t;try{t=await hd(e)}catch{return[]}let s=[];for(let i of t){if(i.startsWith(".")||i==="node_modules"||i==="dist"||i==="build")continue;let n=ht(e,i),r;try{r=await mt(n)}catch{continue}if(!r.isDirectory())continue;let o=ht(n,"SKILL.md");try{(await mt(o)).isFile()&&s.push(n)}catch{}}return s.sort((i,n)=>ve(i).localeCompare(ve(n))),s}async function pd(e){let t=ht(e,"SKILL.md");try{if((await mt(t)).isFile())return{kind:"single",skillDirs:[e]}}catch{}let s=await kv(e);return s.length>0?{kind:"collection",skillDirs:s}:{kind:"none",skillDirs:[]}}function oo(e){return e?!!(e.startsWith("github:")||/^https?:\/\/github\.com\//i.test(e)):!1}function md(e){return{skillPath:e,skillMdPath:ht(e,"SKILL.md"),label:ve(e)}}async function $d(e,t={}){if(!e)throw new Error("resolveEvalInput: input must be a non-empty string");if(oo(e)){if(!t.fetchRemote)throw new Error(`Remote evaluation is not available in this context: "${e}"`);let r=await t.fetchRemote(e),o;try{o=await pd(r.rootDir)}catch(a){throw await r.cleanup().catch(()=>{}),a}if(o.kind==="none")throw await r.cleanup().catch(()=>{}),new Error(`No SKILL.md found at ${r.rootDir} (source: ${e}). The location is neither a single skill nor a skill collection.`);return{targets:o.skillDirs.map(md),isCollection:o.kind==="collection",cleanup:r.cleanup,provenance:{input:e,remote:!0,sourceRef:r.sourceRef,commitSha:r.commitSha,tempPath:r.rootDir}}}let s=no(e)?e:io(e),i;try{i=await mt(s)}catch{throw new Error(`Skill path does not exist: ${s}`)}if(i.isFile())return{targets:[{skillPath:ve(s)==="SKILL.md"?ve(s):s,skillMdPath:s,label:ve(s)}],isCollection:!1,cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}};if(!i.isDirectory())throw new Error(`Skill path is not a directory or file: ${s}`);let n=await pd(s);if(n.kind==="none")throw new Error(`No SKILL.md found in ${s}. Pass a skill directory, a SKILL.md file, or a collection root with SKILL.md in its children.`);return{targets:n.skillDirs.map(md),isCollection:n.kind==="collection",cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}}}function xd(e){let t=e.filter(f=>f.report!==null),s=e.length,i=s-t.length;if(t.length===0)return{total:s,succeeded:0,failed:i,meanScore:null,top:null,bottom:null};let n=t.map(f=>f.report.overallScore),r=n.reduce((f,d)=>f+d,0)/n.length,o=Math.round(r),a=[...t].sort((f,d)=>d.report.overallScore-f.report.overallScore),l=a[0],c=a[a.length-1];return{total:s,succeeded:t.length,failed:i,meanScore:o,top:{label:l.label,score:l.report.overallScore},bottom:{label:c.label,score:c.report.overallScore}}}async function Ed(e,t,s){let i=new Array(e.length),n=0,r=Math.max(1,Math.floor(t)),o=[],a=Math.min(r,e.length);for(let l=0;l<a;l++)o.push((async()=>{for(;;){let c=n++;if(c>=e.length)break;i[c]=await s(e[c],c)}})());return await Promise.all(o),i}function Cd(e,t=28){let s=[];return s.push(""),s.push("Batch summary:"),s.push(` Skills evaluated: ${e.aggregate.succeeded}/${e.aggregate.total}`+(e.aggregate.failed>0?` (${e.aggregate.failed} failed)`:"")),e.aggregate.meanScore!==null&&s.push(` Mean score: ${e.aggregate.meanScore}/100`),e.aggregate.top&&s.push(` Top: ${e.aggregate.top.label} (${e.aggregate.top.score}/100)`),e.aggregate.bottom&&e.aggregate.bottom.label!==e.aggregate.top?.label&&s.push(` Bottom: ${e.aggregate.bottom.label} (${e.aggregate.bottom.score}/100)`),e.provenance.remote&&(e.provenance.sourceRef&&s.push(` Source: ${e.provenance.sourceRef}`),e.provenance.commitSha&&s.push(` Commit: ${e.provenance.commitSha}`),e.provenance.tempPath&&s.push(` Fetched to: ${e.provenance.tempPath}`)),s.join(`
|
|
233
|
+
`)}function Ad(e){return{provenance:{input:e.provenance.input,remote:e.provenance.remote,source_ref:e.provenance.sourceRef??null,commit_sha:e.provenance.commitSha??null,temp_path:e.provenance.tempPath??null},aggregate:{total:e.aggregate.total,succeeded:e.aggregate.succeeded,failed:e.aggregate.failed,mean_score:e.aggregate.meanScore,top:e.aggregate.top,bottom:e.aggregate.bottom},results:e.results.map(t=>({label:t.label,skill_path:t.skillPath,error:t.error,report:t.report?Ai(t.report,null):null}))}}function Ai(e,t=null){return{skill_path:e.skillPath,skill_md_path:e.skillMdPath,overall_score:e.overallScore,grade:e.grade,categories:e.categories.map(s=>({id:s.id,name:s.name,score:s.score,max:s.max,findings:s.findings,suggestions:s.suggestions})),top_suggestions:e.topSuggestions,providers:e.providers?.map(s=>({id:s.id,version:s.version,schemaVersion:s.schemaVersion,score:s.score,passed:s.passed,categories:s.categories.map(i=>({id:i.id,name:i.name,score:i.score,max:i.max,findings:i.findings??[]})),findings:s.findings}))??[],fix:t?{dry_run:t.dryRun,applied:t.applied,skipped:t.skipped,backup_path:t.backupPath,diff:t.diff}:null}}var Sv=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function $v(e){if(typeof e!="string")return null;let t=Sv.exec(e.trim());if(!t)return null;let[,s,i,n,r]=t;return{major:Number(s),minor:Number(i),patch:Number(n),prerelease:r?r.split("."):[]}}function xv(e,t){let s=$v(e);if(!s)throw new Error(`invalid semver: ${t} "${e}"`);return s}var ao=new Map;function lo(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("register: provider.id is required");if(xv(e.version,`provider ${e.id} version`),typeof e.schemaVersion!="number"||!Number.isInteger(e.schemaVersion))throw new Error(`register: provider ${e.id} schemaVersion must be an integer`);let t=ao.get(e.id)??[];if(t.some(s=>s.version===e.version))throw new Error(`register: provider ${e.id}@${e.version} already registered`);t.push(e),ao.set(e.id,t)}function Pi(){let e=[];for(let t of ao.values())for(let s of t)e.push(s);return e}import{stat as Ev}from"fs/promises";var Pd="quality",Nd="1.0.0",Id=1;function Cv(e){return e.topSuggestions.map(t=>({severity:"info",message:t}))}function Av(e){return e.categories.map(t=>({id:t.id,name:t.name,score:t.score,max:t.max}))}var Rd={id:Pd,version:Nd,schemaVersion:Id,description:"Static linter for SKILL.md structure, description, and safety.",async applicable(e){try{return(await Ev(e.skillMdPath)).isFile()?{ok:!0}:{ok:!1,reason:`${e.skillMdPath} is not a file`}}catch{return{ok:!1,reason:`SKILL.md not found at ${e.skillMdPath}`}}},async run(e,t){let s=await bd(e.skillPath);return{providerId:Pd,providerVersion:Nd,schemaVersion:Id,score:s.overallScore,passed:s.grade!=="F",categories:Av(s),findings:Cv(s),raw:s,startedAt:"",durationMs:0}}};var Dd=mo(Dr(),1);import{readFile as Pv,stat as Nv}from"fs/promises";import{basename as Iv}from"path";var Ld="skill-best-practice",Od="1.1.0",Td=1,Rv=new Set(["name","description","license","allowed-tools","metadata","compatibility","effort"]),Md=new Set(["low","medium","high","xhigh","max"]),co=250,Lv=/^\d+\.\d+\.\d+$/;function Ov(e){if(!e.startsWith("---"))return null;let t=e.split(`
|
|
234
234
|
`);if(t.length<3||t[0]?.trim()!=="---")return null;let s=t.findIndex((i,n)=>n>0&&i.trim()==="---");return s===-1?null:t.slice(1,s).join(`
|
|
235
|
-
`)}function
|
|
236
|
-
`)&&!f.includes("\r")&&!f.includes("<")&&!f.includes(">")&&f.length<=1024;W(s,"description-shape","Description follows skill-best-practice formatting rules",E,"error",E?"Description is single-line, angle-bracket free, and within 1024 characters.":"Description must be a single line, avoid angle brackets, and stay within 1024 characters.");let x=f.length<=
|
|
237
|
-
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function
|
|
238
|
-
---`,3);return s===-1?"":t.slice(s+4)}async function
|
|
239
|
-
`,"utf-8"),
|
|
235
|
+
`)}function Ni(e){return{severity:e.severity,message:e.message,code:e.id,categoryId:"validation"}}function W(e,t,s,i,n,r){e.push({id:t,label:s,passed:i,severity:n,message:r})}function Ii(e,t,s){return{skillPath:e.skillPath,skillMdPath:e.skillMdPath,validatedAt:new Date().toISOString(),checkCount:t.length,passedChecks:t.filter(i=>i.passed).length,checks:t,frontmatter:s}}async function Tv(e){let t=await Pv(e.skillMdPath,"utf-8"),s=[],i=Ov(t);if(i===null){W(s,"missing-frontmatter","Frontmatter exists",!1,"error","SKILL.md must start with a YAML frontmatter block.");let E=Ii(e,s,null);return{score:0,passed:!1,findings:s.map(Ni),raw:E}}W(s,"frontmatter-present","Frontmatter exists",!0,"error","SKILL.md contains a YAML frontmatter block.");let n;try{n=(0,Dd.parse)(i)}catch(E){W(s,"invalid-yaml","Frontmatter parses as YAML",!1,"error",`Invalid YAML in frontmatter: ${E?.message??String(E)}`);let x=Ii(e,s,null);return{score:0,passed:!1,findings:s.map(Ni),raw:x}}if(!n||typeof n!="object"||Array.isArray(n)){W(s,"frontmatter-not-object","Frontmatter is a mapping",!1,"error","Frontmatter must parse to a YAML object.");let E=Ii(e,s,null);return{score:0,passed:!1,findings:s.map(Ni),raw:E}}let r=n;W(s,"frontmatter-object","Frontmatter is a mapping",!0,"error","Frontmatter parses to a YAML object.");let o=Object.keys(r).filter(E=>!Rv.has(E));W(s,"allowed-keys","Allowed top-level keys only",o.length===0,"error",o.length===0?"Frontmatter uses only the allowed top-level keys.":`Unexpected frontmatter key(s): ${o.sort().join(", ")}.`);let a=r.name,l=typeof a=="string"?a.trim():"";if(W(s,"name-present","Name is present and non-empty",l.length>0,"error",l.length>0?"Frontmatter includes a non-empty `name`.":"Frontmatter must include a non-empty string `name`."),l.length>0){let E=/^[a-z0-9-]+$/.test(l)&&!l.startsWith("-")&&!l.endsWith("-")&&!l.includes("--")&&l.length<=64;W(s,"name-kebab-case","Name follows skill-best-practice naming rules",E,"error",E?"Name follows the skill-best-practice kebab-case naming rules.":"Name must be kebab-case, avoid consecutive/edge hyphens, and stay within 64 characters.")}let c=r.description,f=typeof c=="string"?c.trim():"";if(W(s,"description-present","Description is present and non-empty",f.length>0,"error",f.length>0?"Frontmatter includes a non-empty `description`.":"Frontmatter must include a non-empty string `description`."),f.length>0){let E=!f.includes(`
|
|
236
|
+
`)&&!f.includes("\r")&&!f.includes("<")&&!f.includes(">")&&f.length<=1024;W(s,"description-shape","Description follows skill-best-practice formatting rules",E,"error",E?"Description is single-line, angle-bracket free, and within 1024 characters.":"Description must be a single line, avoid angle brackets, and stay within 1024 characters.");let x=f.length<=co;W(s,"description-runtime-budget","Description fits the runtime context budget",x,"warning",x?`Description is ${f.length} chars (target \u2264 ${co}).`:`Description is ${f.length} chars; target \u2264 ${co}. The /skills listing truncates tail-first, often chopping the negative-trigger clause.`)}let d=r.effort;W(s,"effort-enum","Effort uses the supported enum",d===void 0||typeof d=="string"&&Md.has(d.trim()),"error",d===void 0||typeof d=="string"&&Md.has(d.trim())?"Effort is omitted or uses a supported value.":"Effort must be one of: low, medium, high, xhigh, max.");let p=r.compatibility;if(p!==void 0){let E=typeof p=="string"&&p.length<=500;W(s,"compatibility-shape","Compatibility is a short string",E,"error",E?"Compatibility is a valid short string.":"Compatibility must be a string no longer than 500 characters.")}let m=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:null,y=m?.version,h=typeof y=="string"||typeof y=="number"?String(y).trim():"",g=h.length>0;if(W(s,"metadata-version-present","metadata.version is present",g,"error",g?"Frontmatter declares `metadata.version`.":"Frontmatter must declare `metadata.version` (start new skills at 1.0.0)."),g){let E=Lv.test(h);W(s,"metadata-version-semver","metadata.version follows MAJOR.MINOR.PATCH",E,"error",E?"`metadata.version` follows semantic versioning.":`\`metadata.version\` must follow semantic versioning (e.g. 1.0.0); got "${h}".`)}let b=m?.author,w=typeof b=="string"&&b.trim().length>0;if(W(s,"metadata-author-present","metadata.author is present",w,"warning",w?"Frontmatter declares `metadata.author`.":"Add `metadata.author` (recommended for published skills) so users know who maintains the skill."),l.length>0){let E=Iv(e.skillPath),x=E===l;W(s,"name-matches-directory","Name matches the parent directory",x,"error",x?"Frontmatter `name` matches the skill directory.":`Frontmatter \`name\` ("${l}") must match the parent directory ("${E}").`)}let k=/don'?t use (?:for|when|if|on)|not (?:for|intended for|suitable for|meant for)\b|skip (?:for|when|if)|avoid (?:using )?(?:for|when|on)|never (?:use )?for\b|only (?:use )?for\b/i.test(f);W(s,"negative-trigger-clause","Description includes a negative-trigger clause",k,"warning",k?"Description names adjacent cases that should not trigger the skill.":"Description appears to lack a negative-trigger clause; consider naming adjacent cases that should not trigger the skill.");let S=Ii(e,s,r),v=S.checkCount===0?100:Math.round(S.passedChecks/S.checkCount*100),C=s.filter(E=>!E.passed).map(Ni);return{score:v,passed:C.every(E=>E.severity!=="error"),findings:C,raw:S}}var Fd={id:Ld,version:Od,schemaVersion:Td,description:"Deterministic SKILL.md best-practice validation (rules aligned with the skill-creator standard, v1.7.1).",async applicable(e){try{return(await Nv(e.skillMdPath)).isFile()?{ok:!0}:{ok:!1,reason:`${e.skillMdPath} is not a file`}}catch{return{ok:!1,reason:`SKILL.md not found at ${e.skillMdPath}`}}},async run(e,t){let s=await Tv(e);return{providerId:Ld,providerVersion:Od,schemaVersion:Td,score:s.score,passed:s.passed,categories:[{id:"validation",name:"Deterministic validation",score:s.raw.passedChecks,max:s.raw.checkCount,findings:s.findings.length>0?s.findings:void 0}],findings:s.findings,raw:s.raw,startedAt:"",durationMs:0}}};function _d(){lo(Rd),lo(Fd)}var jd=!1;function Ri(){jd||(_d(),jd=!0)}function Li(){return Ri(),Pi()}function qd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Bd(e,t,s,i,n){let r={severity:"error",message:i,code:n};return{providerId:e.id,providerVersion:e.version,schemaVersion:e.schemaVersion,score:0,passed:!1,categories:[],findings:[r],raw:void 0,startedAt:t,durationMs:s}}async function Oi(e,t,s={}){let i=new Date().toISOString(),n=performance.now(),r={id:e.id,version:e.version,schemaVersion:e.schemaVersion},o=new AbortController;s.signal&&(s.signal.aborted?o.abort(s.signal.reason):s.signal.addEventListener("abort",()=>o.abort(s.signal?.reason)));let a=null;typeof s.timeoutMs=="number"&&s.timeoutMs>0&&(a=setTimeout(()=>o.abort(new Error("timeout")),s.timeoutMs));let l={...s,signal:o.signal};try{let c=await Promise.race([e.run(t,l).then(p=>({kind:"ok",value:p})),new Promise(p=>{if(o.signal.aborted){p({kind:"timeout"});return}o.signal.addEventListener("abort",()=>p({kind:"timeout"}))})]),f=Math.max(0,Math.round(performance.now()-n));if(c.kind==="timeout"){let p=o.signal.reason,m=p instanceof Error&&p.message==="timeout"?`provider timed out after ${s.timeoutMs}ms`:`provider aborted: ${qd(p)}`;return Bd(r,i,f,m,p instanceof Error&&p.message==="timeout"?"timeout":"aborted")}let d=c.value;return{...d,providerId:r.id,providerVersion:r.version,schemaVersion:d.schemaVersion??r.schemaVersion,startedAt:i,durationMs:f}}catch(c){let f=Math.max(0,Math.round(performance.now()-n));return Bd(r,i,f,qd(c),"provider-threw")}finally{a&&clearTimeout(a)}}function Mv(e){return e>=90?"A":e>=80?"B":e>=65?"C":e>=50?"D":"F"}function Ud(e){return{id:e.providerId,version:e.providerVersion,schemaVersion:e.schemaVersion,score:e.score,passed:e.passed,categories:e.categories,findings:e.findings,raw:e.raw}}function Kd(e,t){return{providerId:e.providerId,providerVersion:e.providerVersion,schemaVersion:e.schemaVersion,passed:e.passed,overallScore:e.score,grade:Mv(e.score),categories:e.categories.map(s=>({id:s.id,name:s.name,score:s.score,max:s.max})),evaluatedAt:e.startedAt,evaluatedVersion:t}}function is(e){return[...e].sort((t,s)=>t.id==="quality"&&s.id!=="quality"?-1:s.id==="quality"&&t.id!=="quality"?1:t.id.localeCompare(s.id))}var te={SKILL_NOT_FOUND:"SKILL_NOT_FOUND",AUDIT_FAILED:"AUDIT_FAILED",INSTALL_FAILED:"INSTALL_FAILED",PUBLISH_FAILED:"PUBLISH_FAILED",NETWORK_ERROR:"NETWORK_ERROR",INVALID_ARGUMENT:"INVALID_ARGUMENT",UNKNOWN_ERROR:"UNKNOWN_ERROR"};function Qe(){let e=console.log,t=console.info,s=(...i)=>process.stderr.write(i.map(String).join(" ")+`
|
|
237
|
+
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function Vd(e){return{timestamp:new Date().toISOString(),asm_version:Bo,duration_ms:Math.round(performance.now()-e)}}function X(e,t,s){let i={version:1,command:e,status:"ok",data:t,meta:Vd(s)},n=process.stdout.isTTY?2:0;return JSON.stringify(i,null,n)}function se(e,t,s,i,n){let r={version:1,command:e,status:"error",error:{code:t,message:s,...n!==void 0?{details:n}:{}},meta:Vd(i)},o=process.stdout.isTTY?2:0;return JSON.stringify(r,null,o)}import{writeFile as _v,mkdir as jv,unlink as qv,readFile as Bv,readdir as Uv}from"fs/promises";import{join as ns}from"path";function uo(e){return e==="skills"||e.startsWith("skills/")?{priority:1,root:"skills/"}:e===".claude/skills"||e.startsWith(".claude/skills/")?{priority:2,root:".claude/skills/"}:e===".agent/skills"||e.startsWith(".agent/skills/")?{priority:3,root:".agent/skills/"}:e===".agents/skills"||e.startsWith(".agents/skills/")?{priority:3,root:".agents/skills/"}:{priority:4,root:"(other)"}}function Jd(e){let t=new Map;for(let r of e){let o=t.get(r.name);o?o.push(r):t.set(r.name,[r])}let s=[],i=[],n=new Set;for(let r of e){if(n.has(r.name))continue;n.add(r.name);let o=t.get(r.name);if(o.length===1){s.push(o[0]);continue}let a=0,l=uo(o[0].relPath);for(let f=1;f<o.length;f++){let d=uo(o[f].relPath);d.priority<l.priority&&(a=f,l=d)}let c=o[a];s.push(c),i.push({name:r.name,kept:{relPath:c.relPath,root:l.root},dropped:o.filter((f,d)=>d!==a).map(f=>({relPath:f.relPath,root:uo(f.relPath).root})),reason:l.priority===4?"first occurrence (no priority match)":`${l.root} priority`})}return{kept:s,decisions:i}}var Dv=[{label:"obfuscation:atob",pattern:/\batob\s*\(/},{label:"obfuscation:base64",pattern:/(?:^|[=:\s])[A-Za-z0-9+/]{40,}={1,2}(?:\s|$)/m},{label:"obfuscation:hex-escape",pattern:/\\x[0-9a-fA-F]{2}(?:\\x[0-9a-fA-F]{2}){3,}/},{label:"credential-leak:api-key",pattern:/\bAPI_KEY\s*=\s*['"][^'"]+['"]/},{label:"credential-leak:secret",pattern:/\bSECRET_KEY\s*=\s*['"][^'"]+['"]/},{label:"credential-leak:password",pattern:/\bPASSWORD\s*=\s*['"][^'"]+['"]/}];function Hd(e,t){let s=[];(!e.name||!e.name.trim())&&s.push("missing frontmatter field: name"),(!e.description||!e.description.trim())&&s.push("missing frontmatter field: description"),Fv(t).trim().length<20&&s.push("SKILL.md body too short (less than 20 chars of instructions)");for(let{label:n,pattern:r}of Dv)r.test(t)&&s.push(`malicious pattern detected: ${n}`);return{verified:s.length===0,reasons:s}}function Fv(e){let t=e.trimStart();if(!t.startsWith("---"))return t;let s=t.indexOf(`
|
|
238
|
+
---`,3);return s===-1?"":t.slice(s+4)}async function Kv(){let e=yt();return await jv(e,{recursive:!0}),e}function Vv(e,t){return`github:${e.owner}/${e.repo}${e.ref?`#${e.ref}`:""}${t?`:${t}`:""}`}async function Wd(e){await _e();let t;try{t=Fe(e)}catch(i){return{success:!1,repoIndex:null,error:i.message}}if(t.isLocal)return{success:!1,repoIndex:null,error:"Local paths are not supported for indexing. Use a GitHub source instead."};P(`ingester: cloning ${t.owner}/${t.repo}`);let s=null;try{s=await je(t),P(`ingester: discovering skills in ${s}`);let i=await gs(s);P(`ingester: found ${i.length} skills`);let{kept:n,decisions:r}=Jd(i);for(let f of r){let d=f.dropped.map(p=>p.relPath).join(", ");P(`ingester: dedupe "${f.name}": kept ${f.kept.relPath} (${f.reason}); dropped ${d}`)}r.length>0&&P(`ingester: deduped ${i.length} -> ${n.length} skills (${r.length} name collision${r.length===1?"":"s"})`);let o=[];for(let f of n){let d=ns(s,f.relPath,"SKILL.md"),p="";try{p=await Bv(d,"utf-8")}catch{P(`ingester: could not read SKILL.md at ${d}`)}let m=Hd(f,p);m.verified||P(`ingester: ${f.name} not verified: ${m.reasons.join(", ")}`);let y=typeof f.tokenCount=="number"?f.tokenCount:p?bt(p):void 0,h,g;if(p){let b;try{b=await Uv(ns(s,f.relPath))}catch{b=void 0}try{let w=ss({content:p,skillPath:f.relPath||f.name,skillMdPath:d,rootEntries:b});h={overallScore:w.overallScore,grade:w.grade,categories:w.categories.map(k=>({id:k.id,name:k.name,score:k.score,max:k.max})),evaluatedAt:w.evaluatedAt,evaluatedVersion:f.version||void 0}}catch(w){P(`ingester: eval failed for ${f.name}: ${w}`)}try{let w={skillPath:ns(s,f.relPath),skillMdPath:d},S=(await Promise.all(is(Li()).map(async v=>(await v.applicable(w,{})).ok?Oi(v,w):null))).filter(v=>v!==null).map(v=>Kd(v,f.version||void 0));S.length>0&&(g=Object.fromEntries(S.filter(v=>v.providerId).map(v=>[v.providerId,v])))}catch(w){P(`ingester: provider eval failed for ${f.name}: ${w}`)}}o.push({name:f.name,description:f.description,version:f.version,license:f.license,creator:f.creator,compatibility:f.compatibility,allowedTools:f.allowedTools,installUrl:Vv(t,f.relPath),relPath:f.relPath,verified:m.verified,tokenCount:y,evalSummary:h,evalSummaries:g})}let a={repoUrl:t.cloneUrl,owner:t.owner,repo:t.repo,updatedAt:new Date().toISOString(),skillCount:o.length,skills:o};a.bundles=yi([...await Lu(s,a),...Jr(a)]);let l=await Kv(),c=ns(l,`${t.owner}_${t.repo}.json`);return await _v(c,JSON.stringify(a,null,2)+`
|
|
239
|
+
`,"utf-8"),P(`ingester: wrote index to ${c}`),{success:!0,repoIndex:a}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await le(s)}}async function Gd(){return(await dt()).map(t=>({owner:t.owner,repo:t.repo,skillCount:t.skillCount,updatedAt:t.updatedAt})).sort((t,s)=>s.skillCount-t.skillCount)}async function Yd(e,t){let s=yt(),i=ns(s,`${e}_${t}.json`);try{return await qv(i),!0}catch{return!1}}import{join as fo,resolve as zd}from"path";function Gv(e){switch(e){case"dangerous":return 3;case"warning":return 2;case"caution":return 1;default:return 0}}function po(e){return{verdict:e.every(t=>t.verdict==="safe")?"safe":e.some(t=>t.verdict==="dangerous")?"dangerous":"warning",findings:e.map(t=>({skill:t.skillName,verdict:t.verdict,verdict_reason:t.verdictReason,total_files:t.totalFiles,total_lines:t.totalLines})),risk_score:e.reduce((t,s)=>t+Gv(s.verdict),0)}}function Yv(e){let t=e.slice(2),s={command:null,subcommand:null,positional:[],flags:{help:!1,version:!1,json:!1,yes:!1,noColor:!1,scope:"both",sort:"name",provider:null,name:null,force:!1,path:null,all:!1,verbose:!1,flat:!1,transport:"auto",method:"default",installed:!1,available:!1,has:[],missing:[],dryRun:!1,machine:!1,noCache:!1,fix:!1,compact:!1,summary:!1,groupBy:null,limit:0,concurrency:0,keep:!1,add:null,remove:null,description:null,author:null,tags:null,predefined:!1}},i=0;for(;i<t.length;){let n=t[i];if(n==="--help"||n==="-h")s.flags.help=!0;else if(n==="--version"||n==="-v")s.flags.version=!0;else if(n==="--json")s.flags.json=!0;else if(n==="--yes"||n==="-y")s.flags.yes=!0;else if(n==="--no-color")s.flags.noColor=!0;else if(n==="--scope"||n==="-s"){i++;let r=t[i],o=r==="local"?"project":r;o==="global"||o==="project"||o==="both"?s.flags.scope=o:($(`Invalid scope: "${r}". Must be global, local, project, or both.`),process.exit(2))}else if(n==="--sort"){i++;let r=t[i];r==="name"||r==="version"||r==="location"?s.flags.sort=r:($(`Invalid sort: "${r}". Must be name, version, or location.`),process.exit(2))}else if(n==="--provider"||n==="-p"||n==="--tool")i++,s.flags.provider=t[i]||null;else if(n==="--name")i++,s.flags.name=t[i]||null;else if(n==="--force"||n==="-f")s.flags.force=!0;else if(n==="--path")i++,s.flags.path=t[i]||null;else if(n==="--all")s.flags.all=!0;else if(n==="--verbose"||n==="-V")s.flags.verbose=!0;else if(n==="--flat")s.flags.flat=!0;else if(n==="--compact")s.flags.compact=!0;else if(n==="--summary")s.flags.summary=!0;else if(n==="--group-by"){i++;let r=t[i];r==="tool"||r==="scope"||r==="effort"?s.flags.groupBy=r:($(`Invalid --group-by: "${r}". Must be tool, scope, or effort.`),process.exit(2))}else if(n==="--limit"){i++;let r=t[i],o=Number(r);(!Number.isFinite(o)||o<0||!Number.isInteger(o))&&($(`Invalid --limit: "${r}". Must be a non-negative integer (0 means no limit).`),process.exit(2)),s.flags.limit=o}else if(n==="--installed")s.flags.installed=!0;else if(n==="--available")s.flags.available=!0;else if(n==="--concurrency"){i++;let r=t[i],o=Number(r);(!Number.isFinite(o)||o<1||!Number.isInteger(o))&&($(`Invalid --concurrency: "${r}". Must be a positive integer.`),process.exit(2)),s.flags.concurrency=o}else if(n==="--keep")s.flags.keep=!0;else if(n==="--transport"||n==="-t"){i++;let r=t[i];r==="https"||r==="ssh"||r==="auto"?s.flags.transport=r:($(`Invalid transport: "${r}". Must be https, ssh, or auto.`),process.exit(2))}else if(n==="--method"||n==="-m"){i++;let r=t[i];r==="default"||r==="vercel"?s.flags.method=r:($(`Invalid method: "${r}". Must be default or vercel.`),process.exit(2))}else n==="--skill"?(i++,s.flags.path=t[i]||null):n==="--dry-run"?s.flags.dryRun=!0:n==="--fix"?s.flags.fix=!0:n==="--machine"?s.flags.machine=!0:n==="--no-cache"?s.flags.noCache=!0:n==="--has"?(i++,t[i]&&s.flags.has.push(t[i])):n==="--missing"?(i++,t[i]&&s.flags.missing.push(t[i])):n==="--add"?(i++,s.flags.add=t[i]||null):n==="--remove"?(i++,s.flags.remove=t[i]||null):n==="--description"?(i++,s.flags.description=t[i]||null):n==="--author"?(i++,s.flags.author=t[i]||null):n==="--tags"?(i++,s.flags.tags=t[i]||null):n==="--predefined"?s.flags.predefined=!0:n.startsWith("-")?($(`Unknown option: ${n}`),console.error('Run "asm --help" for usage.'),process.exit(2)):s.command?s.subcommand?s.positional.push(n):s.subcommand=n:s.command=n;i++}return s}function $(e){console.error(u.red(`Error: ${e}`))}function zv(){console.log(`${u.blueBold("agent-skill-manager")} (${u.bold("asm")}) ${Ji}
|
|
240
240
|
|
|
241
241
|
Interactive TUI and CLI for managing installed skills for AI coding agents.
|
|
242
242
|
|
|
@@ -283,11 +283,11 @@ ${u.bold("Global Options:")}
|
|
|
283
283
|
--sort <field> Sort by: name, version, or location (default: name)
|
|
284
284
|
--flat Show one row per tool instance (list, search)
|
|
285
285
|
-y, --yes Skip confirmation prompts
|
|
286
|
-
-V, --verbose Show debug output`)}function
|
|
286
|
+
-V, --verbose Show debug output`)}function Qv(){console.log(`${u.bold("Usage:")} asm list [options]
|
|
287
287
|
|
|
288
288
|
List all discovered skills. By default, skills installed across multiple
|
|
289
289
|
tools are grouped into a single row with tool badges. When more than
|
|
290
|
-
${
|
|
290
|
+
${Ui} skills are present, a compact summary is
|
|
291
291
|
automatically prepended above the table.
|
|
292
292
|
|
|
293
293
|
${u.bold("Options:")}
|
|
@@ -317,7 +317,7 @@ ${u.bold("Examples:")}
|
|
|
317
317
|
asm list -s project ${u.dim("Only project-scoped skills")}
|
|
318
318
|
asm list --sort version ${u.dim("Sort by version")}
|
|
319
319
|
asm list --json ${u.dim("Output as JSON")}
|
|
320
|
-
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
320
|
+
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function Xv(){console.log(`${u.bold("Usage:")} asm search <query> [options]
|
|
321
321
|
|
|
322
322
|
Search both installed skills and the skill index. Results show installation
|
|
323
323
|
status and include copy-paste install commands for available skills.
|
|
@@ -340,7 +340,7 @@ ${u.bold("Examples:")}
|
|
|
340
340
|
asm search "test" --installed ${u.dim("Search installed skills only")}
|
|
341
341
|
asm search "test" --available ${u.dim("Search available skills only")}
|
|
342
342
|
asm search openspec --json ${u.dim("Output matches as JSON")}
|
|
343
|
-
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
343
|
+
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function Zv(){console.log(`${u.bold("Usage:")} asm inspect <skill-name> [options]
|
|
344
344
|
|
|
345
345
|
Show detailed information for a skill. The <skill-name> is the directory name.
|
|
346
346
|
Shows version, description, file count, and all provider installations.
|
|
@@ -354,7 +354,7 @@ ${u.bold("Options:")}
|
|
|
354
354
|
${u.bold("Examples:")}
|
|
355
355
|
asm inspect code-review ${u.dim("Show details for code-review")}
|
|
356
356
|
asm inspect code-review --json ${u.dim("Output as JSON")}
|
|
357
|
-
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function
|
|
357
|
+
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function ek(){console.log(`${u.bold("Usage:")} asm uninstall <skill-name> [options]
|
|
358
358
|
|
|
359
359
|
Remove a skill and its associated rule files. Shows a removal plan
|
|
360
360
|
before proceeding and asks for confirmation.
|
|
@@ -370,7 +370,7 @@ ${u.bold("Examples:")}
|
|
|
370
370
|
asm uninstall code-review ${u.dim("Remove with confirmation")}
|
|
371
371
|
asm uninstall code-review -y ${u.dim("Remove without confirmation")}
|
|
372
372
|
asm uninstall code-review -s project ${u.dim("Remove project copy only")}
|
|
373
|
-
asm uninstall code-review -p claude ${u.dim("Remove from Claude only")}`)}function
|
|
373
|
+
asm uninstall code-review -p claude ${u.dim("Remove from Claude only")}`)}function tk(){console.log(`${u.bold("Usage:")} asm audit [subcommand] [options]
|
|
374
374
|
|
|
375
375
|
Detect duplicate skills or run security audits on installed/remote skills.
|
|
376
376
|
|
|
@@ -396,7 +396,7 @@ ${u.bold("Examples:")}
|
|
|
396
396
|
asm audit security code-review --json ${u.dim("Output audit as JSON")}
|
|
397
397
|
asm audit security code-review --machine ${u.dim("Machine-readable v1 envelope output")}
|
|
398
398
|
asm audit security https://github.com/user/skills/tree/main/skills/agent-config
|
|
399
|
-
${u.dim("Audit a skill from a subfolder URL")}`)}function
|
|
399
|
+
${u.dim("Audit a skill from a subfolder URL")}`)}function sk(){console.log(`${u.bold("Usage:")} asm publish [path] [options]
|
|
400
400
|
|
|
401
401
|
Validate a skill, run a security audit, generate a registry manifest,
|
|
402
402
|
and open a PR against the asm-registry.
|
|
@@ -419,7 +419,7 @@ ${u.bold("Examples:")}
|
|
|
419
419
|
asm publish --dry-run ${u.dim("Preview manifest without side effects")}
|
|
420
420
|
asm publish --force ${u.dim("Override warning-level security findings")}
|
|
421
421
|
asm publish --json ${u.dim("Output as JSON")}
|
|
422
|
-
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
422
|
+
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function ik(){console.log(`${u.bold("Usage:")} asm outdated [options]
|
|
423
423
|
|
|
424
424
|
Show which installed skills have newer versions available.
|
|
425
425
|
|
|
@@ -432,7 +432,7 @@ ${u.bold("Options:")}
|
|
|
432
432
|
${u.bold("Examples:")}
|
|
433
433
|
asm outdated ${u.dim("Show outdated skills")}
|
|
434
434
|
asm outdated --json ${u.dim("Output as JSON")}
|
|
435
|
-
asm outdated --machine ${u.dim("Machine-readable output")}`)}function
|
|
435
|
+
asm outdated --machine ${u.dim("Machine-readable output")}`)}function nk(){console.log(`${u.bold("Usage:")} asm update [name...] [options]
|
|
436
436
|
|
|
437
437
|
Update outdated skills to their latest version with security re-audit.
|
|
438
438
|
|
|
@@ -450,7 +450,7 @@ ${u.bold("Examples:")}
|
|
|
450
450
|
asm update ${u.dim("Update all outdated skills")}
|
|
451
451
|
asm update code-review ${u.dim("Update a specific skill")}
|
|
452
452
|
asm update --yes ${u.dim("Skip confirmation prompts")}
|
|
453
|
-
asm update --json ${u.dim("Output as JSON")}`)}function
|
|
453
|
+
asm update --json ${u.dim("Output as JSON")}`)}function rk(){console.log(`${u.bold("Usage:")} asm config <subcommand>
|
|
454
454
|
|
|
455
455
|
Manage configuration. Config is stored at ~/.config/agent-skill-manager/.
|
|
456
456
|
|
|
@@ -466,13 +466,13 @@ ${u.bold("Options:")}
|
|
|
466
466
|
${u.bold("Examples:")}
|
|
467
467
|
asm config show ${u.dim("View current config")}
|
|
468
468
|
asm config edit ${u.dim("Edit in $EDITOR")}
|
|
469
|
-
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function
|
|
470
|
-
${u.yellow(`${c.length} skill${c.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(l)}else if(e.flags.summary)console.log(
|
|
471
|
-
`))}}async function
|
|
472
|
-
`)),e.flags.flat?console.log(
|
|
473
|
-
${u.bold("Proceed with removal?")} [y/N] `);let m=await G();m.toLowerCase()!=="y"&&m.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let f;try{f=await
|
|
469
|
+
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function Xd(e){for(let t of e)t.warnings=await tu(t)}async function ok(e){if(e.flags.help){Qv();return}let t=performance.now(),s=await U(),i=await ee(s,e.flags.scope),n=await ls(),r=new Set(i.map(l=>`${l.dirName}||${l.provider}||${l.scope}`)),o=await Zd(s,n,e.flags.scope,e.flags.provider,r);i=[...i,...o],e.flags.provider&&e.command==="list"&&(i=i.filter(l=>l.provider===e.flags.provider)),await Xd(i);let a=ji(i,e.flags.sort);if(e.flags.machine){let l=a.map(c=>({name:c.name,version:c.version,description:c.description,scope:c.scope,provider:c.provider,path:c.path}));console.log(X("list",l,t));return}if(e.flags.json)console.log(Y(a));else if(e.flags.flat){let l=Bi(a),c=a.filter(f=>f.warnings&&f.warnings.length>0);c.length>0&&(l+=`
|
|
470
|
+
${u.yellow(`${c.length} skill${c.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(l)}else if(e.flags.summary)console.log(Ki(a));else if(e.flags.groupBy){let{skills:l,hint:c}=os(a,e.flags.limit);console.log(No(l,e.flags.groupBy)),c&&console.log(c)}else if(e.flags.compact){let{skills:l,hint:c}=os(a,e.flags.limit);console.log(Po(l)),c&&console.log(c)}else{let l=[];a.length>Ui&&(l.push(Ki(a,{showHint:!1})),l.push(""));let{skills:c,hint:f}=os(a,e.flags.limit);l.push(Io(c)),f&&l.push(f),console.log(l.join(`
|
|
471
|
+
`))}}async function ak(e){if(e.flags.help){Xv();return}let t=e.flags.machine?Qe():void 0,s=performance.now(),i=e.subcommand;i||(e.flags.machine&&(t?.(),console.log(se("search",te.INVALID_ARGUMENT,"Missing required argument: <query>",s)),process.exit(2)),$("Missing required argument: <query>"),console.error('Run "asm search --help" for usage.'),process.exit(2));let n=!e.flags.available,r=!e.flags.installed,o=[];if(n){let f=await U(),d=await ee(f,e.flags.scope);e.flags.provider&&(d=d.filter(m=>m.provider===e.flags.provider));let p=vo(d,i);o=ji(p,e.flags.sort)}let a=[];if(r&&(a=await gi(i),o.length>0)){let f=new Set(o.map(d=>d.name.toLowerCase()));a=a.filter(d=>!f.has(d.skill.name.toLowerCase()))}if(e.flags.machine){t?.();let f=o.map(p=>({name:p.name,description:p.description,source:"installed",url:null,match_count:1})),d=a.map(p=>({name:p.skill.name,description:p.skill.description,source:"index",url:p.skill.installUrl,match_count:1}));console.log(X("search",[...f,...d],s));return}if(e.flags.json){let f=o.map(p=>({name:p.name,description:p.description,version:p.version,scope:p.scope,provider:p.provider,status:"installed"})),d=a.map(p=>({name:p.skill.name,description:p.skill.description,version:p.skill.version,repo:`${p.repo.owner}/${p.repo.repo}`,installCommand:`asm install ${p.skill.installUrl}`,status:"available"}));console.log(Y([...f,...d]));return}let l=o.length>0,c=a.length>0;if(!l&&!c){console.error(`No skills matching "${i}".`),console.error(u.dim("Try ingesting more repos with: asm index ingest <repo>"));return}if(l&&(console.error(u.bold(`Installed skills matching "${i}":
|
|
472
|
+
`)),e.flags.flat?console.log(Bi(o)):console.log(Ro(o,i))),c){l&&console.error("");let f=Lo(a.map(d=>({name:d.skill.name,version:d.skill.version,description:d.skill.description,verified:d.skill.verified,repoLabel:`${d.repo.owner}/${d.repo.repo}`,installUrl:d.skill.installUrl})),i);console.error(f)}}async function lk(e){if(e.flags.help){Zv();return}let t=e.subcommand;t||($("Missing required argument: <skill-name>"),console.error('Run "asm inspect --help" for usage.'),process.exit(2));let s=await U(),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 Xd(n),e.flags.json?console.log(Y(n.length===1?n[0]:n)):console.log(await Oo(n))}async function ck(e){if(e.flags.help){ek();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 U(),i=await ee(s,e.flags.scope),n={};e.flags.provider&&(n.providerFilter=e.flags.provider),e.flags.scope&&e.flags.scope!=="both"&&(n.scopeFilter=e.flags.scope);let r=So(t,i,s,n),o=await xo(r);o.length===0&&($(`Skill "${t}" not found or nothing to remove.`),process.exit(1));let a=i.filter(m=>m.dirName===t),l=n.providerFilter,c=null;l&&(c=$o(r,a,l)),console.error(u.bold("Removal plan:")),console.error(` ${u.dim("Scope:")} ${n.scopeFilter||"both"}`),l&&(console.error(` ${u.dim("Tool:")} ${l}`),c?.needed&&console.error(` ${u.yellow("\u26A0 Real folder relocation:")} ${c.fromPath} \u2192 ${c.toPath} (${c.toProvider})`)),console.error("");for(let m of o)console.error(` ${u.red("\u2022")} ${Ao(m)}`);if(!e.flags.yes){process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2)),process.stderr.write(`
|
|
473
|
+
${u.bold("Proceed with removal?")} [y/N] `);let m=await G();m.toLowerCase()!=="y"&&m.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let f;try{f=await qi(r,void 0,c?.needed?c:void 0)}catch(m){let y=Array.isArray(m?.log)?m.log:[];for(let h of y)console.error(h);$(m?.message||"Uninstall failed."),process.exit(1)}for(let m of f)console.error(m);let d=new Set(r.directories.map(m=>zd(m.path))),p=a.filter(m=>!d.has(zd(m.originalPath)));try{l&&p.length>0?c?.needed&&!c.repointOnly&&await Do(t,c.toProvider):await Mo(t)}catch{}console.error(u.green(`
|
|
474
474
|
Done.`))}function G(){return new Promise(e=>{let t="",s=!1;function i(){process.stdin.removeListener("data",r),process.stdin.removeListener("end",o),process.stdin.pause(),clearTimeout(a)}function n(l){s||(s=!0,i(),e(l))}function r(l){t+=l,t.includes(`
|
|
475
|
-
`)&&n(t.trim())}function o(){n(t.trim())}let a=setTimeout(()=>{n(t.trim())},3e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",r),process.stdin.on("end",o),process.stdin.resume()})}function
|
|
475
|
+
`)&&n(t.trim())}function o(){n(t.trim())}let a=setTimeout(()=>{n(t.trim())},3e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",r),process.stdin.on("end",o),process.stdin.resume()})}function uk(){console.log(`${u.bold("Usage:")} asm disable <target> [options]
|
|
476
476
|
asm disable --all [options]
|
|
477
477
|
|
|
478
478
|
Disable skills without uninstalling them. Disabling renames a skill's
|
|
@@ -505,7 +505,7 @@ ${u.bold("Examples:")}
|
|
|
505
505
|
asm disable openspec: ${u.dim("# prefix (colon)")}
|
|
506
506
|
asm disable asc- ${u.dim("# prefix (hyphen)")}
|
|
507
507
|
asm disable --all ${u.dim("# everything")}
|
|
508
|
-
asm disable code-review --tool claude --scope local`)}function
|
|
508
|
+
asm disable code-review --tool claude --scope local`)}function dk(){console.log(`${u.bold("Usage:")} asm enable <target> [options]
|
|
509
509
|
asm enable --all [options]
|
|
510
510
|
|
|
511
511
|
Re-enable skills previously disabled with ${u.bold("asm disable")}. Enabling renames
|
|
@@ -533,15 +533,15 @@ ${u.bold("Examples:")}
|
|
|
533
533
|
asm enable code-review
|
|
534
534
|
asm enable '*-review'
|
|
535
535
|
asm enable openspec:
|
|
536
|
-
asm enable --all`)}async function
|
|
537
|
-
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let c=await
|
|
538
|
-
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let f=[];try{for(let d of l){await
|
|
539
|
-
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a=
|
|
540
|
-
Done.`))}}async function
|
|
541
|
-
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function
|
|
542
|
-
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await
|
|
543
|
-
Summary:`)),a.dangerous>0&&console.log(` ${u.red(`${a.dangerous} dangerous`)}`),a.warning>0&&console.log(` ${u.yellow(`${a.warning} warning`)}`),a.caution>0&&console.log(` ${a.caution} caution`),a.safe>0&&console.log(` ${u.green(`${a.safe} safe`)}`),console.log("")}}async function
|
|
544
|
-
`);let a=await
|
|
536
|
+
asm enable --all`)}async function Zd(e,t,s,i,n){let r=new Map(e.providers.map(a=>[a.name,a])),o=[];for(let[a,l]of Object.entries(t.disabled))for(let[c,f]of Object.entries(l)){if(i&&c!==i)continue;let d=r.get(c);if(d)for(let p of["global","project"]){if(!f[p]||s==="global"&&p!=="global"||s==="project"&&p!=="project"||n?.has(`${a}||${c}||${p}`))continue;let m=p==="global"?d.global:d.project;if(!m)continue;let y=oe(m),h=fo(y,a),g=cs(h);if(!Wv(g))continue;let b={};try{b=Z(await Jv(g,"utf-8"))}catch{}let w=h;try{w=await Hv(h)}catch{}o.push({name:b.name||a,version:b["metadata.version"]||b.version||"0.0.0",description:(b.description||"").replace(/\s*\n\s*/g," ").trim(),creator:b["metadata.creator"]||"",license:(b.license||"").trim(),compatibility:(b.compatibility||"").trim(),allowedTools:[],dirName:a,path:h,originalPath:h,location:`${p}-${c}`,scope:p,provider:c,providerLabel:d.label,isSymlink:!1,symlinkTarget:null,realPath:w,disabled:!0})}}return o}function ef(e,t){if(e.flags.json)console.log(JSON.stringify(t,null,2));else if(e.flags.machine)for(let s of t)console.log([s.name,s.provider,s.scope,s.action].join(" "))}function tf(e,t){let s=new Map;for(let n of t){let r=s.get(n.realPath)??[];r.push(n),s.set(n.realPath,r)}let i=new Map;for(let n of e)i.has(n.realPath)||i.set(n.realPath,{realPath:n.realPath,representative:n,siblings:s.get(n.realPath)??[n]});return[...i.values()]}async function fk(e){if(e.flags.help){uk();return}let t=e.subcommand;if(!t&&!e.flags.all){$("Missing target. Provide a skill name/pattern or use --all."),process.exitCode=2;return}if(t&&e.flags.all){$("Provide either a target or --all, not both."),process.exitCode=2;return}let s=await U(),i=e.flags.provider,n=(await ee(s,e.flags.scope)).filter(d=>d.provider!=="plugin"&&d.provider!=="codex-plugin"),r=i?n.filter(d=>d.provider===i):n,o=e.flags.all?r:Wi(r,t);if(o.length===0){let d=t?` for '${t}'`:"";console.log(u.dim(`No matching active skills${d}.`));return}let a=tf(o,n),l=new Set(o.map(d=>`${d.realPath}||${d.provider}||${d.scope}`));if(!e.flags.json&&!e.flags.machine){let d=a.reduce((p,m)=>p+m.siblings.length,0);console.log(u.bold(`Will disable ${d} skill instance(s):`));for(let p of a){for(let m of p.siblings){let y=l.has(`${m.realPath}||${m.provider}||${m.scope}`)?"":u.yellow(" (shared via symlink)");console.log(` ${u.dim("\u2022")} ${m.name} (${m.provider}, ${m.scope})${y}`)}p.siblings.length>1&&console.log(u.yellow(` \u26A0 ${p.representative.name} shares one SKILL.md across ${p.siblings.length} tools \u2014 disabling affects all of them.`))}if(!e.flags.yes&&process.stdin.isTTY){process.stdout.write(`
|
|
537
|
+
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let c=await ls(),f=[];try{for(let d of a){await zo(d.representative.path);for(let p of d.siblings)Ho(c,p.dirName,p.provider,p.scope),f.push({name:p.name,provider:p.provider,scope:p.scope,action:"disabled"}),!e.flags.json&&!e.flags.machine&&console.log(`${u.green("\u2713")} disabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await Hi(c)}ef(e,f)}async function pk(e){if(e.flags.help){dk();return}let t=e.subcommand;if(!t&&!e.flags.all){$("Missing target. Provide a skill name/pattern or use --all."),process.exitCode=2;return}if(t&&e.flags.all){$("Provide either a target or --all, not both."),process.exitCode=2;return}let s=await U(),i=e.flags.provider,n=await ls(),r=await Zd(s,n,e.flags.scope),o=i?r.filter(d=>d.provider===i):r,a=e.flags.all?o:Wi(o,t);if(a.length===0){let d=t?` for '${t}'`:"";console.log(u.dim(`No matching disabled skills${d}.`));return}let l=tf(a,r),c=new Set(a.map(d=>`${d.realPath}||${d.provider}||${d.scope}`));if(!e.flags.json&&!e.flags.machine){let d=l.reduce((p,m)=>p+m.siblings.length,0);console.log(u.bold(`Will enable ${d} skill instance(s):`));for(let p of l){for(let m of p.siblings){let y=c.has(`${m.realPath}||${m.provider}||${m.scope}`)?"":u.yellow(" (shared via symlink)");console.log(` ${u.dim("\u2022")} ${m.name} (${m.provider}, ${m.scope})${y}`)}p.siblings.length>1&&console.log(u.yellow(` \u26A0 ${p.representative.name} shares one SKILL.md across ${p.siblings.length} tools \u2014 enabling affects all of them.`))}if(!e.flags.yes&&process.stdin.isTTY){process.stdout.write(`
|
|
538
|
+
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let f=[];try{for(let d of l){await Qo(d.representative.path);for(let p of d.siblings)Wo(n,p.dirName,p.provider,p.scope),f.push({name:p.name,provider:p.provider,scope:p.scope,action:"enabled"}),!e.flags.json&&!e.flags.machine&&console.log(`${u.green("\u2713")} enabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await Hi(n)}ef(e,f)}async function mk(e){if(e.flags.help){tk();return}let t=performance.now(),s=e.subcommand??"duplicates";if(s==="security"){await hk(e,t);return}s!=="duplicates"&&($(`Unknown audit subcommand: "${s}". Use: duplicates, security`),process.exit(2));let i=await U(),n=await ee(i,"both"),r=Vi(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(X("audit duplicates",o,t));return}if(e.flags.json){console.log(qo(r));return}if(console.log(jo(r)),e.flags.yes&&r.duplicateGroups.length>0){console.error(u.bold(`
|
|
539
|
+
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a=_o(o.instances),l=a[0].path;for(let c=1;c<a.length;c++){let f=a[c],d=ko(f,i),p=await qi(d,l);for(let m of p)console.error(m)}}console.error(u.green(`
|
|
540
|
+
Done.`))}}async function hk(e,t){let s=e.positional[0];e.flags.all?await gk(e,t):s?s.startsWith("github:")||s.startsWith("https://github.com/")?await yk(e,s,t):await bk(e,s,t):(e.flags.machine&&(console.log(se("audit security",te.INVALID_ARGUMENT,"Missing target. Provide a skill name, GitHub source, or use --all.",t)),process.exit(2)),$(`Missing target. Provide a skill name, GitHub source, or use --all.
|
|
541
|
+
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function gk(e,t){let s=await U(),i=await ee(s,e.flags.scope);if(i.length===0){e.flags.machine?console.log(X("audit security",[],t)):e.flags.json?console.log("[]"):console.log("No skills found to audit.");return}let n=new Set,r=i.filter(a=>n.has(a.realPath)?!1:(n.add(a.realPath),!0));console.error(`Auditing ${r.length} skill${r.length>1?"s":""}...
|
|
542
|
+
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await Te(a.realPath,a.name);o.push(l)}if(e.flags.machine)console.log(X("audit security",po(o),t));else if(e.flags.json)console.log(JSON.stringify(o,null,2));else{for(let l of o)console.log(vi(l));let a={safe:0,caution:0,warning:0,dangerous:0};for(let l of o)a[l.verdict]++;console.log(u.bold(`
|
|
543
|
+
Summary:`)),a.dangerous>0&&console.log(` ${u.red(`${a.dangerous} dangerous`)}`),a.warning>0&&console.log(` ${u.yellow(`${a.warning} warning`)}`),a.caution>0&&console.log(` ${a.caution} caution`),a.safe>0&&console.log(` ${u.green(`${a.safe} safe`)}`),console.log("")}}async function yk(e,t,s){let i=null;try{let n=Fe(t);if(n.isLocal)throw new Error("Local paths are not supported for remote security audits. Use: asm audit security <installed-skill-name>");await _e(),n=await hs(n),console.error(`Cloning ${t} for audit...`),i=await je(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 Te(o,a,n.owner,n.repo);e.flags.machine?console.log(X("audit security",po([l]),s)):e.flags.json?console.log(Gr(l)):console.log(vi(l))}catch(n){e.flags.machine&&(console.log(se("audit security",te.AUDIT_FAILED,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}finally{i&&await le(i)}}async function bk(e,t,s){let i=await U(),r=(await ee(i,e.flags.scope)).filter(l=>l.dirName===t);r.length===0&&(e.flags.machine&&(console.log(se("audit security",te.SKILL_NOT_FOUND,`Skill "${t}" not found.`,s)),process.exit(1)),$(`Skill "${t}" not found. Use "asm list" to see installed skills.`),process.exit(1));let o=r[0];console.error(`Auditing installed skill: ${u.bold(o.name)}...
|
|
544
|
+
`);let a=await Te(o.realPath,o.name);e.flags.machine?console.log(X("audit security",po([a]),s)):e.flags.json?console.log(Gr(a)):console.log(vi(a))}async function wk(e){if(e.flags.help){rk();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 U();console.log(Y(s));break}case"path":{console.log(gt());break}case"reset":{if(!e.flags.yes){process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2)),process.stderr.write(`${u.bold("Reset config to defaults?")} [y/N] `);let i=await G();i.toLowerCase()!=="y"&&i.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let s=go();await wo(s),console.error(u.green("Config reset to defaults."));break}case"edit":{let s=process.env.VISUAL||process.env.EDITOR||"vi",[i,n]=Uo(s),r=gt();await U();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 vk(){console.log(`${u.bold("Usage:")} asm install <source> [options]
|
|
545
545
|
|
|
546
546
|
Install a skill from a GitHub repository, the curated registry, or a local path.
|
|
547
547
|
|
|
@@ -613,27 +613,27 @@ ${u.bold("Subfolder URL:")}
|
|
|
613
613
|
${u.bold("Vercel skills CLI:")}
|
|
614
614
|
asm install github:user/skills --method vercel --skill my-skill
|
|
615
615
|
asm install https://github.com/user/skills -m vercel --skill my-skill -y
|
|
616
|
-
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function
|
|
617
|
-
${u.bold("Install preview:")}`),console.info(` ${u.bold("Name:")} ${o.name}`),console.info(` ${u.bold("Version:")} ${o.version}`),o.description&&console.info(` ${u.bold("Description:")} ${u.dim(o.description)}`),o.effort&&console.info(` ${u.bold("Effort:")} ${
|
|
616
|
+
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function kk(e,t,s,i,n,r,o,a,l="global"){let c=await qe(i),f=await oa(i),d=i===s?null:i.split(/[/\\]/).pop(),p=n||d||t.repo,m=$e(p),y=a.find(C=>C.name.toLowerCase()===c.name.toLowerCase()&&C.provider===o.name),h,g=!!y;y?y.version===c.version?h=e.flags.force?"REINSTALL":`UPDATE: ${y.version} (same version)`:h=`UPDATE: ${y.version} \u2192 ${c.version}`:h="NEW";let b=en(t,s,i,m,o,e.flags.force||g,l),w=f.some(C=>["Shell commands","Code execution","Credentials"].includes(C.category)),k=f.some(C=>["External URLs"].includes(C.category)),S=w?"high":k?"medium":"safe",v=w?u.red("[!] High Risk"):k?u.yellow("[~] Medium Risk"):u.green("[ok] Safe");return{metadata:c,skillName:m,warnings:f,installStatus:h,riskLevel:S,riskLabel:v,plan:b}}function Sk(e,t,s,i,n,r){let{metadata:o,warnings:a,installStatus:l,riskLabel:c,plan:f}=e;if(n&&r){let d=u.dim(`[${r.index}/${r.total}]`),p=l==="NEW"?u.green(`[${l}]`):u.yellow(`[${l}]`);console.info(`${d} ${u.bold(o.name)} v${o.version} ${p} ${c}`)}else{let d=l==="NEW"?u.green(`[${l}]`):u.yellow(`[${l}]`);if(console.info(` ${u.bold(o.name)} v${o.version} ${d}`),console.info(`
|
|
617
|
+
${u.bold("Install preview:")}`),console.info(` ${u.bold("Name:")} ${o.name}`),console.info(` ${u.bold("Version:")} ${o.version}`),o.description&&console.info(` ${u.bold("Description:")} ${u.dim(o.description)}`),o.effort&&console.info(` ${u.bold("Effort:")} ${Eo(o.effort)}`),console.info(` ${u.bold("Source:")} ${t}`),i?(console.info(` ${u.bold("Tool:")} All (${i.map(p=>p.label).join(", ")})`),console.info(` ${u.bold("Primary:")} ${s.label} (${s.name})`),console.info(` ${u.bold("Symlinks:")} ${i.filter(p=>p.name!==s.name).map(p=>p.label).join(", ")}`)):console.info(` ${u.bold("Tool:")} ${s.label} (${s.name})`),console.info(` ${u.bold("Scope:")} ${f.scope==="project"?"Project":"Global"}`),console.info(` ${u.bold("Target:")} ${f.targetDir}`),console.info(` ${u.bold("Status:")} ${d}`),console.info(` ${u.bold("Risk:")} ${c}`),a.length>0){console.info(`
|
|
618
618
|
${u.bold("Security warnings:")}`);let p=new Map;for(let m of a){let y=p.get(m.category)||[];y.push(m),p.set(m.category,y)}for(let[m,y]of p){let g=["Shell commands","Code execution","Credentials"].includes(m)?u.red(`[${m}]`):u.yellow(`[${m}]`);console.info(`
|
|
619
|
-
${g} ${u.dim(`(${y.length} match${y.length>1?"es":""})`)}`);for(let b of y.slice(0,5))console.info(` ${u.dim(`${b.file}:${b.line}`)} -- ${b.match}`);y.length>5&&console.info(u.dim(` ... and ${y.length-5} more`))}}}}async function
|
|
620
|
-
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(f)}`),c=()=>{n?le(n).finally(()=>process.exit(1)):process.exit(1)};process.on("SIGINT",c),process.on("SIGTERM",c);try{if(!
|
|
621
|
-
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:
|
|
622
|
-
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let
|
|
623
|
-
Select a skill [1-${
|
|
624
|
-
Did you mean: ${
|
|
625
|
-
`);for(let
|
|
619
|
+
${g} ${u.dim(`(${y.length} match${y.length>1?"es":""})`)}`);for(let b of y.slice(0,5))console.info(` ${u.dim(`${b.file}:${b.line}`)} -- ${b.match}`);y.length>5&&console.info(u.dim(` ... and ${y.length-5} more`))}}}}async function $k(e,t){return t?await aa(e,t):await ys(e)}async function xk(e){if(e.flags.help){vk();return}let t=e.flags.machine?Qe():void 0,s=performance.now(),i=e.subcommand;i||($("Missing required argument: <source>"),console.error('Run "asm install --help" for usage.'),process.exit(2));let n=null,r="github",o=8,a=0,l=f=>(a++,`
|
|
620
|
+
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(f)}`),c=()=>{n?le(n).finally(()=>process.exit(1)):process.exit(1)};process.on("SIGINT",c),process.on("SIGTERM",c);try{if(!Xi(i)&&await na(i)&&(i=`./${i}`),Qt(i)){console.info(`
|
|
621
|
+
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:I,multipleMatches:N,suggestions:F}=await ou(i,{noCache:e.flags.noCache});if(I){r="registry";let O=I.manifest,D=O.repository.replace("https://github.com/","");i=O.skill_path?`github:${D}#${O.commit}:${O.skill_path}`:`github:${D}#${O.commit}`,console.info(` ${u.green("\u2713")} Resolved: ${u.bold(`${O.author}/${O.name}`)} @ ${O.commit.slice(0,7)}`)}else if(N.length>0){console.info(`
|
|
622
|
+
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let O=N.slice(0,5);for(let de=0;de<O.length;de++){let fe=O[de];console.info(` ${u.cyan(`${de+1}.`)} ${u.bold(`${fe.author}/${fe.name}`)} \u2014 ${fe.description}`)}process.stdin.isTTY||($(`Ambiguous skill name "${i}". Use a scoped name: asm install author/name`),process.exit(2));let D=`
|
|
623
|
+
Select a skill [1-${O.length}]: `;process.stderr.write(D);let Q=await new Promise(de=>{let fe="",Me=!1,Mi=setTimeout(()=>{Me||(Me=!0,process.stdin.removeListener("data",Di),de(fe.trim()))},3e4);function Di(rf){fe=rf.toString().trim(),Me||(Me=!0,clearTimeout(Mi),process.stdin.removeListener("data",Di),de(fe))}process.stdin.setEncoding("utf-8"),process.stdin.on("data",Di)}),B=parseInt(Q,10);(isNaN(B)||B<1||B>O.length)&&($("Invalid selection. Aborting."),process.exit(2));let ie=O[B-1];r="registry";let ke=ie.repository.replace("https://github.com/","");i=ie.skill_path?`github:${ke}#${ie.commit}:${ie.skill_path}`:`github:${ke}#${ie.commit}`,console.info(` ${u.green("\u2713")} Selected: ${u.bold(`${ie.author}/${ie.name}`)} @ ${ie.commit.slice(0,7)}`)}else _r(i)?($(`Skill "${i}" not found in the registry.`),F.length>0&&console.error(`
|
|
624
|
+
Did you mean: ${F.map(O=>u.cyan(O)).join(", ")}?`),process.exit(1)):(console.info(` ${u.dim("Not found in registry \u2014 trying existing sources...")}`),r="pre-indexed")}console.info(l("Parsing source"));let f=Fe(i),d=!!f.isLocal;if(d){let I=f.localPath;console.info(` ${u.dim(`local: ${I}`)}`);let{stat:N}=await import("fs/promises");try{if(!(await N(I)).isDirectory())throw new Error(`Path is not a directory: ${I}`)}catch(F){throw F.code==="ENOENT"?new Error(`Path does not exist: ${I}`):F}}else await _e(),f=await hs(f),console.info(` ${u.dim(i)}`);if(e.flags.method==="vercel"){console.info(l("Installing via Vercel skills CLI")),await la();let I=ua(f),N=e.flags.path||null;console.info(` ${u.dim(`npx skills add ${I}${N?` --skill ${N}`:""}`)}`);let{stdout:F,stderr:O}=await ca(I,N);F.trim()&&console.info(` ${u.dim(F.trim())}`),O.trim()&&console.error(` ${u.dim(O.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 U(),{provider:m,allProviders:y}=await Ze(p,e.flags.provider,!!process.stdin.isTTY);console.info(l("Selecting scope"));let h;if(e.flags.scope==="global"||e.flags.scope==="project")h=e.flags.scope,console.info(` ${u.dim(`scope: ${h}`)}${h==="global"?` (${m.global})`:` (${m.project})`}`);else if(!process.stdin.isTTY||e.flags.yes)h="global",console.info(` ${u.dim("scope: global (default)")} (${m.global})`);else{let I=[{label:`Global (${m.global})`,hint:"Available in all projects",checked:!0},{label:`Project (${m.project})`,hint:"Available only in this project",checked:!1}];console.info("");let N=await Xe({items:I});if(N.length===0)throw new Error("No scope selected. Aborting.");h=N[0]===0?"global":"project",console.info(` Selected: ${u.bold(h)} ${u.dim(`(${h==="global"?m.global:m.project})`)}`)}if(d)console.info(l("Reading local source")),console.info(` ${u.dim(f.localPath)}`),n=null;else{console.info(l("Cloning repository"));let I=e.flags.transport,N=I==="ssh"?f.sshCloneUrl:I==="https"?f.cloneUrl:`${f.cloneUrl} ${u.dim("(auto)")}`;console.info(` ${N}${f.ref?` ${u.dim(`(ref: ${f.ref})`)}`:""}${f.subpath?` ${u.dim(`(path: ${f.subpath})`)}`:""}`),n=await je(f,I)}let g=d?f.localPath:n;console.info(l("Scanning for skills"));let{join:b}=await import("path"),w=[],k=e.flags.path||f.subpath,S=[],v=!1,C=g,E="",x=!1;if(k){let I=b(g,k),N=!1;try{await qe(I),N=!0}catch{if(!e.flags.all)throw new Error(`No SKILL.md found at path "${k}" in the repository.`);let{stat:F}=await import("fs/promises");try{if(!(await F(I)).isDirectory())throw new Error(`No SKILL.md found at path "${k}" in the repository.`)}catch(O){throw O&&O.code==="ENOENT"?new Error(`No SKILL.md found at path "${k}" in the repository.`):O}v=!0,C=I,E=k}N&&(console.info(` Found skill at ${u.bold(k)}`),S=[{skillDir:I,nameOverride:e.flags.name}])}else{try{await qe(g),x=!0}catch{}if(x&&!e.flags.all){let I=await qe(g);console.info(` Found: ${u.bold(I.name)} v${I.version}`),S=[{skillDir:g,nameOverride:e.flags.name}]}else x&&e.flags.all,v=!0}if(v){console.info(E?` No SKILL.md at ${u.bold(E)}. Scanning subdirectories...`:x?" Root SKILL.md found. Scanning for additional skills in subdirectories...":" No SKILL.md at root. Scanning subdirectories...");let I=await gs(C),N=E?I.map(D=>({...D,relPath:`${E}/${D.relPath}`})):I;if(N.length===0)throw new Error(E?`No skills found under path "${E}". Skills must have a SKILL.md file.`:"No skills found in this repository. Skills must have a SKILL.md file.");console.info(` Found ${u.bold(String(N.length))} skill(s):
|
|
625
|
+
`);for(let D=0;D<N.length;D++){let Q=u.cyan(` ${String(D+1).padStart(String(N.length).length)})`);console.info(`${Q} ${u.bold(N[D].name)} ${u.dim(`v${N[D].version}`)} ${u.dim(`(${N[D].relPath})`)}`),N[D].description&&console.info(` ${u.dim(N[D].description)}`)}console.info(l("Selecting skills")),a--;let F;if(e.flags.all&&(e.flags.yes||!process.stdin.isTTY))F=N.map(D=>D.relPath),console.info(` Selected all ${u.bold(String(F.length))} skills`);else if(process.stdin.isTTY)if(N.length===1)F=[N[0].relPath],console.info(` Auto-selected: ${u.bold(N[0].name)} ${u.dim(`v${N[0].version}`)}`);else{let D=N.map(B=>({label:B.name,hint:`v${B.version}${B.description?" "+B.description:""}`,checked:!!e.flags.all}));console.info("");let Q=await Xe({items:D});if(Q.length===0)throw new Error("No skills selected. Aborting.");F=Q.map(B=>N[B].relPath),console.info(` Selected ${u.bold(String(F.length))} skill(s)`)}else{$(`Repository contains ${N.length} skills. Use --path <subdir> to pick one or --all to install all.
|
|
626
626
|
Available skills:
|
|
627
|
-
${N.map(
|
|
628
|
-
`)}`),process.exit(2);return}let
|
|
629
|
-
`),
|
|
630
|
-
${
|
|
631
|
-
Choose one path per skill name or install with --path.`);throw
|
|
627
|
+
${N.map(D=>` --path ${D.relPath}`).join(`
|
|
628
|
+
`)}`),process.exit(2);return}let O=ra(F,D=>D===""?$e(f.repo):Zi(D));if(O.length>0){let D=O.map(B=>` - ${B.name}: ${B.paths.map(ie=>`"${ie}"`).join(", ")}`).join(`
|
|
629
|
+
`),Q=new Error(`Duplicate skill names detected in selection:
|
|
630
|
+
${D}
|
|
631
|
+
Choose one path per skill name or install with --path.`);throw Q.duplicates=O,Q}S=F.map(D=>({skillDir:b(g,D),nameOverride:F.length===1?e.flags.name:null})),a++}console.info(l("Inspecting skills"));let j=await ee(p,"both"),R=[],M=S.length>1;for(let I=0;I<S.length;I++){let{skillDir:N,nameOverride:F}=S[I],O=await kk(e,f,g,N,F,p,m,j,h);R.push(O),Sk(O,i,m,y,M,M?{index:I+1,total:S.length}:void 0)}if(M){console.info(""),console.info(` ${u.bold("Install settings:")}`),console.info(` ${u.bold("Source:")} ${i}`),console.info(y?` ${u.bold("Tool:")} All (${y.map(D=>D.label).join(", ")})`:` ${u.bold("Tool:")} ${m.label} (${m.name})`),console.info(` ${u.bold("Scope:")} ${h==="project"?"Project":"Global"}`);let I=R.filter(D=>D.riskLevel==="high").length,N=R.filter(D=>D.riskLevel==="medium").length,F=R.filter(D=>D.riskLevel==="safe").length,O=[];F>0&&O.push(u.green(`${F} Safe`)),N>0&&O.push(u.yellow(`${N} Medium Risk`)),I>0&&O.push(u.red(`${I} High Risk`)),console.info(` ${u.bold("Risk:")} ${O.join(", ")}`)}if(console.info(l("Installing")),!e.flags.yes){let I=R.some(D=>D.riskLevel==="high");process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2));let N=M?`${R.length} skills`:`"${R[0].metadata.name}"`,F=I?`
|
|
632
632
|
${u.red("[!]")} ${u.bold(`Install ${N}? Some have high-risk patterns.`)} [y/N] `:`
|
|
633
|
-
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(
|
|
634
|
-
${u.yellow(`${
|
|
633
|
+
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(F);let O=await G();I?O.toLowerCase()!=="y"&&O.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)):(O.toLowerCase()==="n"||O.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let T=n?await Fo(n):null,K=[];for(let I=0;I<R.length;I++){let N=R[I],F=M?u.dim(`[${I+1}/${R.length}]`)+" ":" ";try{console.info(`${F}Installing ${u.bold(N.metadata.name)}...`);let O=await $k(N.plan,y);w.push(O),console.info(`${F}${u.green("\u2713")} ${N.metadata.name} installed to ${u.dim(N.plan.targetDir)}`);try{let D=d?`local:${f.localPath}`:`github:${f.owner}/${f.repo}`,Q=d?"local":r==="registry"?"registry":"github";await wt(O.name,{source:D,commitHash:T||"unknown",ref:f.ref||"main",installedAt:new Date().toISOString(),provider:N.plan.providerName,sourceType:Q,...r==="registry"?{registryName:O.name}:{}})}catch{}}catch(O){K.push({name:N.metadata.name,error:O.message}),console.error(`${F}${u.red("\u2717")} ${u.bold(N.metadata.name)} \u2014 ${u.red(O.message)}`)}}if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),K.length>0){console.error(`
|
|
634
|
+
${u.yellow(`${K.length} skill(s) failed to install:`)}`);for(let I of K)console.error(` ${u.red("\u2717")} ${I.name}: ${I.error}`)}if(e.flags.machine){t?.();let I=w.map(N=>({name:N.name,path:N.path,version:N.version,provider:N.provider,source:N.source,resolution_source:r}));console.log(X("install",I.length===1?I[0]:I,s))}else if(e.flags.json){let I=w.map(N=>({...N,resolutionSource:r}));console.log(JSON.stringify(I.length===1?I[0]:I,null,2))}else w.length===1?console.error(u.green(`
|
|
635
635
|
Done! Installed "${w[0].name}" to ${w[0].path}`)):w.length>0&&console.error(`
|
|
636
|
-
${u.green(`Done! Installed ${w.length} skill(s) successfully.`)}`)}catch(f){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(
|
|
636
|
+
${u.green(`Done! Installed ${w.length} skill(s) successfully.`)}`)}catch(f){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(se("install",te.INSTALL_FAILED,f.message,s,f?.duplicates?{duplicates:f.duplicates}:void 0));else if(e.flags.json){let d={success:!1,error:f.message};f?.duplicates&&(d.duplicates=f.duplicates),console.log(JSON.stringify(d,null,2))}else $(f.message);process.exit(1)}finally{n&&await le(n),t?.()}}function Ek(){console.log(`${u.bold("Usage:")} asm export [options]
|
|
637
637
|
|
|
638
638
|
Export skill inventory as a portable JSON manifest. Useful for backup,
|
|
639
639
|
sharing, or scripting.
|
|
@@ -646,7 +646,7 @@ ${u.bold("Options:")}
|
|
|
646
646
|
${u.bold("Examples:")}
|
|
647
647
|
asm export ${u.dim("Export all skills")}
|
|
648
648
|
asm export -s global ${u.dim("Export global skills only")}
|
|
649
|
-
asm export > skills.json ${u.dim("Save to file")}`)}async function
|
|
649
|
+
asm export > skills.json ${u.dim("Save to file")}`)}async function Ck(e){if(e.flags.help){Ek();return}let t=await U(),s=await ee(t,e.flags.scope),i=au(s);console.log(JSON.stringify(i,null,2))}function Ak(){console.log(`${u.bold("Usage:")} asm import <file> [options]
|
|
650
650
|
|
|
651
651
|
Import skills from a previously exported JSON manifest. Recreates skill
|
|
652
652
|
installations based on the manifest metadata.
|
|
@@ -668,9 +668,9 @@ ${u.bold("Examples:")}
|
|
|
668
668
|
asm import skills.json --force ${u.dim("Overwrite existing skills")}
|
|
669
669
|
asm import skills.json -s global ${u.dim("Import only global skills")}
|
|
670
670
|
asm export > backup.json ${u.dim("Export first, then import later")}
|
|
671
|
-
asm import backup.json ${u.dim("Restore from backup")}`)}async function
|
|
672
|
-
${u.bold("Proceed?")} [y/N] `);let l=await G();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await
|
|
673
|
-
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let l of a.results){let c=l.status==="installed"?u.green("+++"):l.status==="skipped"?u.yellow("---"):l.status==="dry-run"?u.cyan("~~~"):u.red("!!!"),f=l.reason?` ${u.dim(l.reason)}`:"",d=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${f}${d}`)}console.error(""),console.error(`${u.bold("Summary:")} ${a.total} total, ${u.green(String(a.installed))} installed, ${u.yellow(String(a.skipped))} skipped, ${u.red(String(a.failed))} failed`),a.failed>0&&(process.exitCode=1)}function
|
|
671
|
+
asm import backup.json ${u.dim("Restore from backup")}`)}async function Pk(e){if(e.flags.help){Ak();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 du(i)}catch(l){$(l.message),process.exit(1)}let r=n.skills.length;if(r===0){e.flags.json?console.log(JSON.stringify({total:0,installed:0,skipped:0,failed:0,results:[]},null,2)):console.log("Manifest contains no skills. Nothing to import.");return}let o=e.flags.scope==="both"?"all scopes":e.flags.scope;if(console.error(`${u.bold("Importing")} ${r} skill${r>1?"s":""} from ${u.dim(i)}`),console.error(` Scope filter: ${o}`),e.flags.force&&console.error(` ${u.yellow("Force mode: existing skills will be overwritten")}`),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
672
|
+
${u.bold("Proceed?")} [y/N] `);let l=await G();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await fu(n,{force:e.flags.force,dryRun:!1,scopeFilter:e.flags.scope});if(e.flags.json){console.log(JSON.stringify(a,null,2));return}if(a.total===0){console.error(`
|
|
673
|
+
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let l of a.results){let c=l.status==="installed"?u.green("+++"):l.status==="skipped"?u.yellow("---"):l.status==="dry-run"?u.cyan("~~~"):u.red("!!!"),f=l.reason?` ${u.dim(l.reason)}`:"",d=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${f}${d}`)}console.error(""),console.error(`${u.bold("Summary:")} ${a.total} total, ${u.green(String(a.installed))} installed, ${u.yellow(String(a.skipped))} skipped, ${u.red(String(a.failed))} failed`),a.failed>0&&(process.exitCode=1)}function Nk(){console.log(`${u.bold("Usage:")} asm init <name> [options]
|
|
674
674
|
|
|
675
675
|
Scaffold a new skill directory with a SKILL.md template. Creates a
|
|
676
676
|
ready-to-edit skill in the target tool's skill folder.
|
|
@@ -685,8 +685,8 @@ ${u.bold("Options:")}
|
|
|
685
685
|
${u.bold("Examples:")}
|
|
686
686
|
asm init my-skill ${u.dim("Scaffold (interactive tool)")}
|
|
687
687
|
asm init my-skill -p claude ${u.dim("Scaffold in Claude Code")}
|
|
688
|
-
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function
|
|
689
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await
|
|
688
|
+
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function Ik(e){if(e.flags.help){Nk();return}let t=e.subcommand;t||($("Missing required argument: <name>"),console.error('Run "asm init --help" for usage.'),process.exit(2));let s=$e(t),i;if(e.flags.path){let{resolve:n}=await import("path");i=n(e.flags.path)}else{let n=await U(),{provider:r}=await Ze(n,e.flags.provider,!!process.stdin.isTTY),{join:o}=await import("path"),{resolveProviderPath:a}=await import("./config-FRM3YOMA.js"),l=a(n.providers.find(c=>c.name===r.name).global);i=o(l,s)}if(await mu(i)&&!e.flags.force){process.stdin.isTTY||($(`Directory already exists: ${i}. Use --force to overwrite.`),process.exit(2)),process.stderr.write(`${u.yellow(`Directory already exists: ${i}`)}
|
|
689
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await pu(s,i),console.error(u.green(`Done! Created skill "${s}" at ${i}`))}function Rk(){console.log(`${u.bold("Usage:")} asm stats [options]
|
|
690
690
|
|
|
691
691
|
Show aggregate skill metrics with provider distribution charts,
|
|
692
692
|
scope breakdown, disk usage, and duplicate summary.
|
|
@@ -700,7 +700,7 @@ ${u.bold("Options:")}
|
|
|
700
700
|
${u.bold("Examples:")}
|
|
701
701
|
asm stats ${u.dim("Show full dashboard")}
|
|
702
702
|
asm stats -s global ${u.dim("Global skills only")}
|
|
703
|
-
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function
|
|
703
|
+
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function Lk(e){if(e.flags.help){Rk();return}let t=await U(),s=await ee(t,e.flags.scope);if(s.length===0){console.log("No skills found.");return}let i=Vi(s),n=await gu(s,i);if(e.flags.json)if(e.flags.verbose)console.log(Y(n));else{let{perSkillDiskBytes:r,...o}=n;console.log(Y(o))}else console.log(yu(n))}function Ok(){console.log(`${u.bold("Usage:")} asm doctor [options]
|
|
704
704
|
|
|
705
705
|
Run environment health checks and diagnostics. Validates all
|
|
706
706
|
prerequisites for using asm \u2014 git, GitHub CLI, Node.js, config,
|
|
@@ -715,7 +715,7 @@ ${u.bold("Options:")}
|
|
|
715
715
|
${u.bold("Examples:")}
|
|
716
716
|
asm doctor ${u.dim("Run all health checks")}
|
|
717
717
|
asm doctor --json ${u.dim("Output as JSON")}
|
|
718
|
-
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function
|
|
718
|
+
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function Tk(e){if(e.flags.help){Ok();return}let t=performance.now(),s=await ld();if(e.flags.machine){let i={checks:s.checks.map(n=>({name:n.name,status:n.status,message:n.message,...n.fix?{fix:n.fix}:{}})),passed:s.passed,warnings:s.warnings,failures:s.failures};console.log(X("doctor",i,t))}else e.flags.json?console.log(ud(s)):console.log(cd(s));s.failures>0&&process.exit(1)}function Mk(){console.log(`${u.bold("Usage:")} asm eval <target> [options]
|
|
719
719
|
|
|
720
720
|
Evaluate a skill's SKILL.md against best practices and produce a scored quality
|
|
721
721
|
report with recommendations. Zero configuration \u2014 just point it at a skill
|
|
@@ -751,8 +751,8 @@ ${u.bold("Examples:")}
|
|
|
751
751
|
asm eval ./my-skill --fix ${u.dim("Auto-fix deterministic issues")}
|
|
752
752
|
asm eval ./my-skill --fix --dry-run ${u.dim("Preview fixes as diff")}
|
|
753
753
|
asm eval ./my-skill --machine ${u.dim("Machine-readable v1 envelope")}
|
|
754
|
-
asm eval-providers list ${u.dim("List registered eval providers")}`)}function
|
|
755
|
-
`))}function
|
|
754
|
+
asm eval-providers list ${u.dim("List registered eval providers")}`)}function Dk(e){let t=e.findings.find(s=>s.severity==="error"&&(s.code==="provider-threw"||s.code==="timeout"||s.code==="aborted"));if(t)throw new Error(t.message)}async function Fk(e,t,s){await _e();let i=Fe(e);if(i.isLocal)throw new Error(`fetchRemoteForEval received a local path: "${e}". This is a bug \u2014 local paths should use the non-remote branch.`);i=await hs(i);let n=await je(i,t),r=i.subpath?fo(n,i.subpath):n,o=null;try{let{execFile:c}=await import("child_process"),{promisify:f}=await import("util"),d=f(c),{stdout:p}=await d("git",["-C",n,"rev-parse","HEAD"],{timeout:5e3}),m=p.trim();/^[0-9a-f]{40}$/i.test(m)&&(o=m)}catch{}let a=`github:${i.owner}/${i.repo}${i.ref?`#${i.ref}`:""}${i.subpath?`:${i.subpath}`:""}`;return{rootDir:r,cleanup:async()=>{s||await le(n)},sourceRef:a,commitSha:o}}async function Qd(e){Ri();try{let t={skillPath:e.skillPath,skillMdPath:e.skillMdPath},s=(await Promise.all(is(Li()).map(async r=>(await r.applicable(t,{})).ok?Oi(r,t):null))).filter(r=>r!==null),i=s.find(r=>r.providerId==="quality");if(!i)throw new Error("quality provider did not produce a result");return Dk(i),{report:{...i.raw,providers:is(s.map(Ud))},error:null}}catch(t){return{report:null,error:t?.message??String(t)}}}async function _k(e){if(e.flags.help){Mk();return}let t=e.flags.machine?Qe():void 0,s=performance.now(),i=e.subcommand;if(i||(e.flags.machine&&(t?.(),console.log(se("eval",te.INVALID_ARGUMENT,"Missing required argument: <skill-path>",s)),process.exit(2)),$("Missing required argument: <skill-path>"),console.error('Run "asm eval --help" for usage.'),process.exit(2)),e.flags.fix){if(oo(i)){let r="--fix is only supported for local skill paths. Clone the repo first or run `asm install` to materialise it locally.";e.flags.machine&&(t?.(),console.log(se("eval",te.INVALID_ARGUMENT,r,s)),process.exit(2)),$(r),process.exit(2)}try{let r=await vd(),o=await wd(i,{dryRun:e.flags.dryRun,gitAuthor:r});if(e.flags.machine){t?.(),console.log(X("eval",Ai(o.report,o),s));return}if(e.flags.json){console.log(JSON.stringify({report:o.report,fix:{dryRun:o.dryRun,applied:o.applied,skipped:o.skipped,backupPath:o.backupPath,diff:o.diff}},null,2));return}console.log(Ci(o.report)),console.log(""),console.log(Sd(o));return}catch(r){e.flags.machine&&(t?.(),console.log(se("eval",te.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}return}let n=null;try{n=await $d(i,{fetchRemote:r=>Fk(r,e.flags.transport,e.flags.keep)})}catch(r){e.flags.machine&&(t?.(),console.log(se("eval",te.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}try{if(!n.isCollection&&n.targets.length===1){let c=n.targets[0],{report:f,error:d}=await Qd(c);if(!f)throw new Error(d??"eval failed");if(e.flags.machine){t?.();let p=Ai(f,null),m=n.provenance.remote?{...p,provenance:{input:n.provenance.input,remote:!0,source_ref:n.provenance.sourceRef??null,commit_sha:n.provenance.commitSha??null,temp_path:n.provenance.tempPath??null}}:p;console.log(X("eval",m,s));return}if(e.flags.json){n.provenance.remote?console.log(JSON.stringify({...f,provenance:{input:n.provenance.input,remote:!0,sourceRef:n.provenance.sourceRef??null,commitSha:n.provenance.commitSha??null,tempPath:n.provenance.tempPath??null}},null,2)):console.log(kd(f));return}console.log(Ci(f)),n.provenance.remote&&jk(n.provenance);return}let r=e.flags.concurrency||4;if(n.targets.length===0)throw new Error(`No skills to evaluate at "${i}" \u2014 the resolved location has no SKILL.md in itself or its immediate children.`);let o=await Ed(n.targets,r,async c=>{let{report:f,error:d}=await Qd(c);return{label:c.label,skillPath:c.skillPath,report:f,error:d}}),a=xd(o),l={provenance:n.provenance,aggregate:a,results:o};if(e.flags.machine){t?.(),console.log(X("eval",Ad(l),s));return}if(e.flags.json){console.log(JSON.stringify({provenance:l.provenance,aggregate:l.aggregate,results:l.results.map(c=>({label:c.label,skillPath:c.skillPath,error:c.error,report:c.report}))},null,2));return}for(let c of l.results)c.report?console.log(Ci(c.report)):(console.log(`Skill evaluation: ${c.skillPath}`),console.log(` ${u.red("error:")} ${c.error??"unknown failure"}`)),console.log("");console.log(Cd(l)),n.provenance.remote&&e.flags.verbose}catch(r){e.flags.machine&&(t?.(),console.log(se("eval",te.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}finally{if(n)try{await n.cleanup()}catch{}}}function jk(e){let t=[];t.push(""),t.push(u.dim("Fetched remote skill:")),e.sourceRef&&t.push(u.dim(` Source: ${e.sourceRef}`)),e.commitSha&&t.push(u.dim(` Commit: ${e.commitSha}`)),e.tempPath&&t.push(u.dim(` Temp: ${e.tempPath}`)),console.log(t.join(`
|
|
755
|
+
`))}function qk(){console.log(`${u.bold("Usage:")} asm eval-providers <subcommand> [options]
|
|
756
756
|
|
|
757
757
|
Manage evaluation providers registered with the ${u.bold("asm eval")} framework.
|
|
758
758
|
Providers implement the ${u.bold("EvalProvider")} contract (see src/eval/types.ts) and
|
|
@@ -768,7 +768,7 @@ ${u.bold("Options:")}
|
|
|
768
768
|
|
|
769
769
|
${u.bold("Examples:")}
|
|
770
770
|
asm eval-providers list ${u.dim("Show registered providers")}
|
|
771
|
-
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function
|
|
771
|
+
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function Bk(e){if(e.flags.help){qk();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":{Ri();let s=Pi();if(e.flags.json){console.log(Y(s.map(a=>({id:a.id,version:a.version,schemaVersion:a.schemaVersion,description:a.description,requires:a.requires??[]}))));return}if(s.length===0){console.log("No eval providers registered.");return}let i=["id","version","schemaVersion","description","requires"],n=s.map(a=>[a.id,a.version,String(a.schemaVersion),a.description,a.requires&&a.requires.length>0?a.requires.join(","):"-"]),r=i.map((a,l)=>Math.max(a.length,...n.map(c=>c[l].length))),o=a=>a.map((l,c)=>l.padEnd(r[c])).join(" ");console.log(u.bold(o(i))),console.log(r.map(a=>"-".repeat(a)).join(" "));for(let a of n)console.log(o(a));return}default:$(`Unknown eval-providers subcommand: "${t}". Use: list`),console.error('Run "asm eval-providers --help" for usage.'),process.exit(2)}}function Uk(){console.log(`${u.bold("Usage:")} asm link <path> [<path2> ...] [options]
|
|
772
772
|
|
|
773
773
|
Symlink a local skill directory into an agent's skill folder. Useful
|
|
774
774
|
for local development \u2014 changes to the source are reflected immediately.
|
|
@@ -792,13 +792,13 @@ ${u.bold("Examples:")}
|
|
|
792
792
|
asm link ./my-skill -p claude ${u.dim("Link to Claude Code")}
|
|
793
793
|
asm link ./my-skill --name alias ${u.dim("Link with custom name")}
|
|
794
794
|
asm link ./my-skills-folder ${u.dim("Link all skills in folder")}
|
|
795
|
-
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function
|
|
796
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await G();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function
|
|
795
|
+
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function Kk(e,t){if(t)return!0;let{access:s}=await import("fs/promises"),i=!1;try{await s(e),i=!0}catch{}if(!i)return!1;if(!process.stdin.isTTY)throw new Error(`Target already exists: ${e}. Use --force to overwrite.`);process.stderr.write(`${u.yellow(`Target already exists: ${e}`)}
|
|
796
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await G();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function Ti(e,t,s,i){let{join:n}=await import("path"),r=n(t,s),o=await Kk(r,i);return await vu(e,t,s,o),{name:s,symlinkPath:r,targetPath:e}}async function Vk(e){if(e.flags.help){Uk();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 U(),{provider:h}=await Ze(y,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:g}=await import("./config-FRM3YOMA.js"),b=g(y.providers.find(C=>C.name===h.name).global),{resolve:w,basename:k}=await import("path"),S=[],v=[];for(let C of t){let E=w(C),x=!1,j=null;try{await Br(E),x=!0}catch(R){let M=R instanceof Error?R.message:String(R);M.startsWith("Path does not exist")||M.startsWith("Path is not a directory")||M.startsWith("No SKILL.md found")||(j=M)}if(j){v.push({name:C,error:j}),e.flags.json||console.error(u.red(` Failed to process "${C}": ${j}`));continue}if(x){let R=k(E);try{let M=await Ti(E,b,R,!!e.flags.force);S.push(M),e.flags.json||console.error(u.green(` Linked "${M.name}" -> ${M.targetPath}`))}catch(M){let T=M instanceof Error?M.message:String(M);v.push({name:R,error:T}),e.flags.json||console.error(u.red(` Failed to link "${R}": ${T}`))}}else{let R=[];try{R=await Ur(E)}catch(M){let T=M instanceof Error?M.message:String(M),K=T;T.startsWith("Path does not exist")&&Qt(C)&&(K=`${T} \u2014 "${C}" looks like a registry name; try "asm install ${C}" first.`),v.push({name:C,error:K}),e.flags.json||console.error(u.red(` Failed to process "${C}": ${K}`));continue}if(R.length===0){let M=`No SKILL.md found in ${E} or its immediate subdirectories.`;v.push({name:C,error:M}),e.flags.json||console.error(u.red(` ${M}`));continue}for(let M of R)try{let T=await Ti(M.absPath,b,M.dirName,!!e.flags.force);S.push(T),e.flags.json||console.error(u.green(` Linked "${T.name}" -> ${T.targetPath}`))}catch(T){let K=T instanceof Error?T.message:String(T);v.push({name:M.name,error:K}),e.flags.json||console.error(u.red(` Failed to link "${M.name}": ${K}`))}}}e.flags.json?console.log(Y({success:v.length===0,linked:S,failures:v})):v.length>0?console.error(u.yellow(`
|
|
797
797
|
${S.length} linked, ${v.length} failed.`)):console.error(u.green(`
|
|
798
|
-
Done! Linked ${S.length} skill(s) successfully.`)),v.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await
|
|
799
|
-
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await G();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],m=[];for(let y of a){let h=e.flags.name&&a.length===1
|
|
798
|
+
Done! Linked ${S.length} skill(s) successfully.`)),v.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await Br(r),o=!0}catch(y){let h=y instanceof Error?y.message:String(y);h.startsWith("Path does not exist")||h.startsWith("Path is not a directory")||h.startsWith("No SKILL.md found")||($(h),process.exit(1))}let a=[];if(!o){try{a=await Ur(r)}catch(y){let h=y instanceof Error?y.message:String(y);h.startsWith("Path does not exist")?($(`No such skill or path: ${s}`),Qt(s)?(console.error(` "${s}" looks like a registry name, not a local path.`),console.error(` Install it first: ${u.bold(`asm install ${s}`)}`),console.error(` Or pass a local path: ${u.bold(`asm link ./path/to/${s}`)}`)):console.error(' Pass a local directory containing SKILL.md, or run "asm install <name>" first.')):$(h),process.exit(1)}a.length===0&&($(`No SKILL.md found in ${r} or its immediate subdirectories.`),process.exit(1)),e.flags.name&&a.length>1&&($(`--name cannot be used when linking multiple skills (found ${a.length} skills). Link each skill individually to use --name.`),process.exit(2))}let l=await U(),{provider:c}=await Ze(l,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:f}=await import("./config-FRM3YOMA.js"),d=f(l.providers.find(y=>y.name===c.name).global);if(o){let y=e.flags.name?$e(e.flags.name):n(r),h;try{h=await Ti(r,d,y,!!e.flags.force)}catch(g){let b=g instanceof Error?g.message:String(g);e.flags.json?console.log(Y({success:!1,error:b})):$(b),process.exit(2)}e.flags.json?console.log(Y({success:!0,...h})):(console.error(u.green(`Done! Linked "${h.name}" -> ${h.targetPath}`)),console.error(` Symlink: ${h.symlinkPath}`),console.error(u.dim(` If you move or delete the source, run "asm uninstall ${h.name}" to clean up.`)));return}console.error(`Found ${u.bold(String(a.length))} skill(s) in ${r}:`);for(let y of a)console.error(` ${u.bold(y.name)} ${u.dim(`v${y.version}`)} ${u.dim(`(${y.dirName}/)`)}`);if(process.stdin.isTTY&&!e.flags.force){process.stderr.write(`
|
|
799
|
+
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await G();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],m=[];for(let y of a){let h=e.flags.name&&a.length===1?$e(e.flags.name):y.dirName;try{let g=await Ti(y.absPath,d,h,!!e.flags.force);p.push(g),e.flags.json||console.error(u.green(` Linked "${g.name}" -> ${g.targetPath}`))}catch(g){let b=g instanceof Error?g.message:String(g);m.push({name:y.name,error:b}),e.flags.json||console.error(u.red(` Failed to link "${y.name}": ${b}`))}}e.flags.json?console.log(Y({success:m.length===0,linked:p,failures:m})):m.length>0?console.error(u.yellow(`
|
|
800
800
|
${p.length} linked, ${m.length} failed.`)):console.error(u.green(`
|
|
801
|
-
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}function
|
|
801
|
+
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}function Jk(){console.log(`${u.bold("Usage:")} asm index <subcommand> [options]
|
|
802
802
|
|
|
803
803
|
Manage the skill index for searching available skills from indexed repos.
|
|
804
804
|
|
|
@@ -822,10 +822,10 @@ ${u.bold("Examples:")}
|
|
|
822
822
|
asm index search marketing --has license ${u.dim("Only with license")}
|
|
823
823
|
asm index search "" --missing creator ${u.dim("Skills missing creator")}
|
|
824
824
|
asm index list ${u.dim("List indexed repos")}
|
|
825
|
-
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function
|
|
826
|
-
`));for(let o of r){let a=o.skill.verified?u.blue(" [verified]"):"";console.error(`${u.cyan(o.skill.name)} ${u.dim(`v${o.skill.version}`)}${a} ${u.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let c of
|
|
827
|
-
`)}}break}case"list":{let s=await
|
|
828
|
-
`));for(let n of s)console.error(`${u.cyan(`${n.owner}/${n.repo}`)} - ${n.skillCount} skills ${u.dim(`(${new Date(n.updatedAt).toLocaleDateString()})`)}`)}break}case"remove":{let s=e.positional[0];s||($("Missing required argument: <owner/repo>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let[i,n]=s.split("/");if((!i||!n)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove")} ${u.cyan(`${i}/${n}`)} ${u.bold("from index?")} [y/N] `);let o=await G();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await
|
|
825
|
+
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function Hk(e){if(e.flags.help){Jk();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 Wd(s);i.success||($(`Failed to ingest: ${i.error}`),process.exit(1)),i.repoIndex&&(e.flags.json?console.log(Y({success:!0,owner:i.repoIndex.owner,repo:i.repoIndex.repo,skillCount:i.repoIndex.skillCount,updatedAt:i.repoIndex.updatedAt})):(console.error(u.green(`Successfully indexed ${i.repoIndex.owner}/${i.repoIndex.repo}`)),console.error(` Skills found: ${i.repoIndex.skillCount}`)));break}case"search":{let s=e.positional.join(" ");!s&&e.flags.has.length===0&&e.flags.missing.length===0&&($("Missing required argument: <query>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let i={};e.flags.has.length>0&&(i.has=e.flags.has),e.flags.missing.length>0&&(i.missing=e.flags.missing);let r=i.has||i.missing?await gi(s||"",20,i):await gi(s);if(r.length===0){e.flags.json?console.log(Y([])):(console.info("No skills found matching your query."),console.error(u.dim("Try ingesting more repos with: asm index ingest <repo>")));return}if(e.flags.json)console.log(Y(r.map(o=>({name:o.skill.name,description:o.skill.description,version:o.skill.version,license:o.skill.license||"",creator:o.skill.creator||"",compatibility:o.skill.compatibility||"",allowedTools:o.skill.allowedTools||[],verified:o.skill.verified===!0,installUrl:o.skill.installUrl,installCommand:`asm install ${o.skill.installUrl}`,repo:`${o.repo.owner}/${o.repo.repo}`}))));else{console.error(u.bold(`Found ${r.length} skills:
|
|
826
|
+
`));for(let o of r){let a=o.skill.verified?u.blue(" [verified]"):"";console.error(`${u.cyan(o.skill.name)} ${u.dim(`v${o.skill.version}`)}${a} ${u.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let c of To(o.skill.description,80))console.error(` ${c}`);let l=xu(o.skill);l.length>0&&console.error(` ${u.yellow(`\u26A0 Missing: ${l.join(", ")}`)}`),console.error(` ${u.green(`asm install ${o.skill.installUrl}`)}
|
|
827
|
+
`)}}break}case"list":{let s=await Gd();if(s.length===0){e.flags.json?console.log(Y([])):(console.info("No repositories indexed."),console.error(u.dim("Add repos with: asm index ingest <repo>")));return}let i=await Eu();if(e.flags.json)console.log(Y(s));else{console.error(u.bold(`Indexed Repositories (${i} total skills):
|
|
828
|
+
`));for(let n of s)console.error(`${u.cyan(`${n.owner}/${n.repo}`)} - ${n.skillCount} skills ${u.dim(`(${new Date(n.updatedAt).toLocaleDateString()})`)}`)}break}case"remove":{let s=e.positional[0];s||($("Missing required argument: <owner/repo>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let[i,n]=s.split("/");if((!i||!n)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove")} ${u.cyan(`${i}/${n}`)} ${u.bold("from index?")} [y/N] `);let o=await G();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await Yd(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 Wk(){console.log(`${u.bold("Usage:")} asm bundle <subcommand> [options]
|
|
829
829
|
|
|
830
830
|
Create, install, and manage curated skill bundles. A bundle is a reusable
|
|
831
831
|
recipe of skills for a particular workflow, domain, or project setup.
|
|
@@ -861,14 +861,14 @@ ${u.bold("Examples:")}
|
|
|
861
861
|
asm bundle modify my-workflow --add github:u/r ${u.dim("Add a skill to bundle")}
|
|
862
862
|
asm bundle modify my-workflow --remove skill ${u.dim("Remove a skill from bundle")}
|
|
863
863
|
asm bundle export my-workflow ${u.dim("Export to ./my-workflow.json")}
|
|
864
|
-
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function
|
|
865
|
-
`));let g=await
|
|
866
|
-
${u.bold("Description")} (optional, press Enter to skip): `);let h=await G();h.trim()&&(d=h.trim()),process.stderr.write(`${u.bold("Author")} (optional, press Enter to skip): `);let g=await G();g.trim()&&(p=g.trim())}let m=
|
|
867
|
-
${u.bold("Install all skills from this bundle?")} [y/N] `);let d=await G();d.toLowerCase()!=="y"&&d.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let n=[],r=await
|
|
868
|
-
Installing ${u.bold(d.name)}...`);try{(d.installUrl.startsWith("github:")||d.installUrl.startsWith("https://github.com/"))&&await
|
|
864
|
+
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function Gk(e){if(e.flags.help){Wk();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 U(),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(h=>{let g=h.name.toLowerCase();return r.has(g)?!1:(r.add(g),!0)}),a=o;if(process.stdin.isTTY&&!e.flags.yes){let h=o.map(b=>({label:`${b.name} v${b.version}`,hint:b.description?b.description.slice(0,60)+(b.description.length>60?"...":""):`(${b.provider}/${b.scope})`,checked:!0}));console.error(u.bold(`Select skills for bundle "${s}":
|
|
865
|
+
`));let g=await Xe({items:h});g.length===0&&($("No skills selected. Bundle not created."),process.exit(1)),a=g.map(b=>o[b])}let{readLock:l}=await import("./lock-6S53S4SC.js"),c=await l(),f=await Promise.all(a.map(h=>_u(h,c))),d=`Bundle of ${f.length} skills`,p="unknown";try{let{execSync:h}=await import("child_process"),g=h("git config user.name",{encoding:"utf-8"}).trim();g&&(p=g)}catch{}if(process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`
|
|
866
|
+
${u.bold("Description")} (optional, press Enter to skip): `);let h=await G();h.trim()&&(d=h.trim()),process.stderr.write(`${u.bold("Author")} (optional, press Enter to skip): `);let g=await G();g.trim()&&(p=g.trim())}let m=Fu(s,d,p,f),y=await Hr(m);e.flags.json?console.log(JSON.stringify(m,null,2)):(console.error(u.green(`Bundle "${s}" created with ${f.length} skill(s).`)),console.error(` Saved to: ${u.dim(y)}`));break}case"install":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle install <name|file>"),process.exit(2));let i;try{i=await ts(s)}catch(d){$(d.message),process.exit(1)}console.error(`${u.bold("Bundle:")} ${i.name} (${i.skills.length} skills)`),i.description&&console.error(` ${u.dim(i.description)}`),console.error("");for(let d of i.skills){let p=d.version?` v${d.version}`:"";console.error(` ${u.cyan(d.name)}${u.dim(p)} ${u.dim(`-> ${d.installUrl}`)}`)}if(!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
867
|
+
${u.bold("Install all skills from this bundle?")} [y/N] `);let d=await G();d.toLowerCase()!=="y"&&d.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let n=[],r=await U(),{provider:o}=await Ze(r,e.flags.provider,!1),a=e.flags.scope==="global"||e.flags.scope==="project"?e.flags.scope:"global";for(let d of i.skills){console.error(`
|
|
868
|
+
Installing ${u.bold(d.name)}...`);try{(d.installUrl.startsWith("github:")||d.installUrl.startsWith("https://github.com/"))&&await _e();let m=Fe(d.installUrl),y=!!m.isLocal,h=null;try{let g,b;y?(g=m.localPath,b=m.localPath):(h=await je(m,e.flags.transport),g=h,b=m.subpath?fo(h,m.subpath):h);let w=await qe(b),k=$e(d.name||w.name||m.repo),S=en(m,g,b,k,o,e.flags.force,a);try{await da(S.targetDir,S.force)}catch(v){if(v.message?.includes("--force")){n.push({name:d.name,status:"skipped",reason:"Already installed. Use --force to overwrite."}),console.error(` ${u.dim("---")} ${d.name} skipped (already installed)`);continue}throw v}await ys(S),n.push({name:d.name,status:"installed"}),console.error(` ${u.green("+++")} ${d.name} installed`)}finally{h&&await le(h)}}catch(p){n.push({name:d.name,status:"failed",reason:p.message}),console.error(` ${u.red("!!!")} ${d.name}: ${p.message}`)}}let l=n.filter(d=>d.status==="installed").length,c=n.filter(d=>d.status==="skipped").length,f=n.filter(d=>d.status==="failed").length;e.flags.json?console.log(JSON.stringify({bundleName:i.name,total:n.length,installed:l,skipped:c,failed:f,results:n},null,2)):(console.error(""),console.error(`${u.bold("Summary:")} ${n.length} total, ${u.green(String(l))} installed, `+(c>0?`${u.dim(String(c))} skipped, `:"")+`${u.red(String(f))} failed`)),f>0&&(process.exitCode=1);break}case"list":{if(!!e.flags.predefined){let n=await ju();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}):
|
|
869
869
|
`));for(let r of n){let o=r.tags&&r.tags.length>0?` ${u.dim(`[${r.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(r.name)} ${u.dim(`(${r.skills.length} skills)`)}${o}`),r.description&&console.error(` ${u.dim(r.description)}`)}console.error(`
|
|
870
|
-
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await
|
|
870
|
+
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await Bu();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}):
|
|
871
871
|
`));for(let n of i){let r=n.tags&&n.tags.length>0?` ${u.dim(`[${n.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(n.name)} ${u.dim(`(${n.skills.length} skills)`)}${r}`),n.description&&console.error(` ${u.dim(n.description)}`),n.author&&console.error(` ${u.dim(`by ${n.author}`)}`)}}break}case"show":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle show <name|file>"),process.exit(2));let i;try{i=await ts(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(`
|
|
872
|
-
${u.bold(`Skills (${i.skills.length})`)}:`);for(let n of i.skills){let r=n.version?` v${n.version}`:"";console.error(` ${u.cyan(n.name)}${u.dim(r)}`),n.description&&console.error(` ${u.dim(n.description)}`),console.error(` ${u.dim(`install: ${n.installUrl}`)}`)}}break}case"remove":{let s=e.positional[0];if(s||($("Missing required argument: <name>"),console.error("Usage: asm bundle remove <name>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove bundle")} ${u.cyan(s)}${u.bold("?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await
|
|
873
|
-
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(u.green(`Exported to ${o}`));break}default:$(`Unknown subcommand: "${t}". Use: create, install, list, show, remove, modify, or export`),console.error('Run "asm bundle --help" for usage.'),process.exit(2)}}async function
|
|
874
|
-
`)),console.log(JSON.stringify(n.manifest,null,2));return}n.prUrl&&(console.error(u.green("Published successfully!")),console.error(""),console.error(` PR: ${n.prUrl}`),console.error(` Manifest: manifests/${n.manifest?.author}/${n.manifest?.name}.json`),console.error(` Security: ${n.securityVerdict}`),console.error(""),console.error(u.dim("The registry maintainers will review your submission.")))}catch(n){let r={success:!1,manifest:null,prUrl:null,error:n.message,securityVerdict:"pass",securityReport:{scannedAt:new Date().toISOString(),skillName:"",skillPath:"",source:null,codeScans:[],permissions:[],totalFiles:0,totalLines:0,verdict:"safe",verdictReason:""}};e.flags.machine&&(t?.(),console.log(
|
|
872
|
+
${u.bold(`Skills (${i.skills.length})`)}:`);for(let n of i.skills){let r=n.version?` v${n.version}`:"";console.error(` ${u.cyan(n.name)}${u.dim(r)}`),n.description&&console.error(` ${u.dim(n.description)}`),console.error(` ${u.dim(`install: ${n.installUrl}`)}`)}}break}case"remove":{let s=e.positional[0];if(s||($("Missing required argument: <name>"),console.error("Usage: asm bundle remove <name>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove bundle")} ${u.cyan(s)}${u.bold("?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await Uu(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 ts(s)}catch(d){$(d.message),process.exit(1)}let n=!1,r=e.flags.add;if(r){let d={name:r.split("/").pop()?.replace(/\.json$/,"")??r,installUrl:r};i.skills.push(d),n=!0,console.error(u.green(`Added skill from ${r}`))}let o=e.flags.remove;if(o){let d=i.skills.length;i.skills=i.skills.filter(p=>p.name.toLowerCase()!==o.toLowerCase()),i.skills.length<d?(n=!0,console.error(u.green(`Removed skill "${o}"`))):console.error(u.dim(`Skill "${o}" not found in bundle (no change)`))}let a=e.flags.description;a!==null&&(i.description=a,n=!0);let l=e.flags.author;l!==null&&(i.author=l,n=!0);let c=e.flags.tags;if(c!==null&&(i.tags=c.split(",").map(d=>d.trim()).filter(d=>d.length>0),n=!0),!n&&process.stdin.isTTY&&!e.flags.yes&&!r&&!o&&a===null&&l===null&&c===null){console.error(u.bold(`Modifying bundle "${i.name}"`)),console.error(` Current skills: ${i.skills.map(y=>y.name).join(", ")}`),console.error(` Description: ${i.description}`),console.error(` Author: ${i.author}`),console.error(` Tags: ${i.tags?.join(", ")??"(none)"}`),console.error(""),process.stderr.write(`${u.bold("New description")} (Enter to keep current): `);let d=await G();d.trim()&&(i.description=d.trim(),n=!0),process.stderr.write(`${u.bold("New author")} (Enter to keep current): `);let p=await G();p.trim()&&(i.author=p.trim(),n=!0),process.stderr.write(`${u.bold("New tags (comma-separated)")} (Enter to keep current): `);let m=await G();m.trim()&&(i.tags=m.split(",").map(y=>y.trim()).filter(y=>y.length>0),n=!0)}if(!n){console.error(u.dim("No changes made to bundle."));break}i.skills.length===0&&($("Bundle must contain at least one skill after modification."),process.exit(1));let f=await Hr(i);e.flags.json?console.log(JSON.stringify(i,null,2)):(console.error(u.green(`Bundle "${i.name}" updated (${i.skills.length} skill(s)).`)),console.error(` Saved to: ${u.dim(f)}`));break}case"export":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle export <name> [output-file]"),process.exit(2));let i;try{i=await ts(s)}catch(l){$(l.message),process.exit(1)}let n=e.positional[1]??`./${s}.json`,{resolve:r}=await import("path"),o=r(n);if(!e.flags.force){let{access:l}=await import("fs/promises");try{if(await l(o),process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`File ${u.bold(o)} already exists. Overwrite? [y/N] `);let c=await G();c.toLowerCase()!=="y"&&c.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}else e.flags.yes||($(`File "${o}" already exists. Use --force to overwrite.`),process.exit(1))}catch{}}let{writeFile:a}=await import("fs/promises");await a(o,JSON.stringify(i,null,2)+`
|
|
873
|
+
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(u.green(`Exported to ${o}`));break}default:$(`Unknown subcommand: "${t}". Use: create, install, list, show, remove, modify, or export`),console.error('Run "asm bundle --help" for usage.'),process.exit(2)}}async function Yk(e){if(e.flags.help){sk();return}let t=e.flags.machine?Qe():void 0,s=performance.now(),i=e.subcommand||".";try{let n=await Gu({path:i,dryRun:e.flags.dryRun,force:e.flags.force,yes:e.flags.yes});if(e.flags.machine){t?.(),n.success||(console.log(se("publish",te.PUBLISH_FAILED,n.error||"Publish failed",s,{manifest:n.manifest,security_verdict:n.securityVerdict,fallback:n.fallback??!1})),process.exit(1)),console.log(X("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(Yu(n));return}if(e.flags.dryRun){console.error(u.dim(`Dry run \u2014 no PR created.
|
|
874
|
+
`)),console.log(JSON.stringify(n.manifest,null,2));return}n.prUrl&&(console.error(u.green("Published successfully!")),console.error(""),console.error(` PR: ${n.prUrl}`),console.error(` Manifest: manifests/${n.manifest?.author}/${n.manifest?.name}.json`),console.error(` Security: ${n.securityVerdict}`),console.error(""),console.error(u.dim("The registry maintainers will review your submission.")))}catch(n){let r={success:!1,manifest:null,prUrl:null,error:n.message,securityVerdict:"pass",securityReport:{scannedAt:new Date().toISOString(),skillName:"",skillPath:"",source:null,codeScans:[],permissions:[],totalFiles:0,totalLines:0,verdict:"safe",verdictReason:""}};e.flags.machine&&(t?.(),console.log(se("publish",te.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 zk(e){if(e.flags.help){ik();return}let t=e.flags.machine?Qe():void 0,s=performance.now();try{let i=await Xr();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(X("outdated",r,s));return}if(e.flags.json){console.log(sd(i));return}let n=!e.flags.noColor&&process.stdout.isTTY!==!1;console.log(td(i,n)),i.outdatedCount>0&&(process.exitCode=1)}catch(i){e.flags.machine&&(t?.(),console.log(se("outdated",te.UNKNOWN_ERROR,i.message,s)),process.exit(1)),$(i.message),process.exit(1)}}async function Qk(e){if(e.flags.help){nk();return}let t=e.flags.machine?Qe():void 0,s=performance.now(),i=[];e.subcommand&&i.push(e.subcommand),i.push(...e.positional);try{let n=await ed(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(X("update",o,s));return}if(e.flags.json){console.log(id(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(se("update",te.UNKNOWN_ERROR,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}}async function sf(e){let t=Yv(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&&ho(!0),t.flags.version){console.log(`asm ${Ji}`);let s=await xi();if(t.flags.verbose&&s.resolved&&(console.log(` path: ${s.resolved.path}`),s.resolved.realPath!==s.resolved.path&&console.log(` real: ${s.resolved.realPath}`)),s.shadowed.length>0&&s.resolved){console.error(""),console.error(u.yellow(`Warning: ${s.shadowed.length+1} \`asm\` binaries on PATH \u2014 you may be running a shadowed install.`)),console.error(` resolved: ${s.resolved.path}`);for(let i of s.shadowed)console.error(` shadowed: ${i.path}`);console.error(u.dim(" Remove the stale global install (npm uninstall -g agent-skill-manager) and keep only one.")),console.error(u.dim(" See: https://github.com/luongnv89/asm#troubleshooting"))}return}if(!t.command&&t.flags.help){zv();return}if(t.command)switch(t.command){case"list":await ok(t);break;case"search":await ak(t);break;case"inspect":await lk(t);break;case"uninstall":await ck(t);break;case"disable":await fk(t);break;case"enable":await pk(t);break;case"audit":await mk(t);break;case"install":await xk(t);break;case"config":await wk(t);break;case"export":await Ck(t);break;case"import":await Pk(t);break;case"init":await Ik(t);break;case"stats":await Lk(t);break;case"link":await Vk(t);break;case"index":await Hk(t);break;case"bundle":await Gk(t);break;case"publish":await Yk(t);break;case"outdated":await zk(t);break;case"update":await Qk(t);break;case"doctor":await Tk(t);break;case"eval":await _k(t);break;case"eval-providers":await Bk(t);break;default:$(`Unknown command: "${t.command}"`),console.error('Run "asm --help" for usage.'),process.exit(2)}}function nf(e){let t=e.slice(2);if(t.length===0)return!1;let s=["list","search","inspect","uninstall","audit","config","install","export","import","init","stats","link","index","bundle","publish","outdated","update","doctor","eval","eval-providers","disable","enable"],i=t[0];return!!(s.includes(i)||i==="--help"||i==="-h"||i==="--version"||i==="-v"||i.startsWith("-")||i.length>0)}if(nf(process.argv))await sf(process.argv);else{let{main:e}=await import("./src-NB45CVD2.js");await e().catch(t=>{console.error("Fatal error:",t),process.exit(1)})}
|