agent-skill-manager 2.7.0 → 2.8.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 +34 -0
- package/data/skill-index/Affitor_affiliate-skills.json +1764 -160
- package/data/skill-index/Eronred_aso-skills.json +1365 -121
- package/data/skill-index/GPTomics_bioSkills.json +22236 -10797
- package/data/skill-index/Galaxy-Dawn_claude-scholar.json +2346 -232
- package/data/skill-index/Imbad0202_academic-research-skills.json +314 -42
- package/data/skill-index/K-Dense-AI_claude-scientific-skills.json +3634 -447
- package/data/skill-index/Leonxlnx_taste-skill.json +429 -37
- package/data/skill-index/Master-cai_Research-Paper-Writing-Skills.json +6 -5
- package/data/skill-index/MiniMax-AI_skills.json +804 -70
- package/data/skill-index/Paramchoudhary_ResumeSkills.json +465 -61
- package/data/skill-index/affaan-m_everything-claude-code.json +13583 -3818
- package/data/skill-index/alirezarezvani_claude-skills.json +22302 -6760
- package/data/skill-index/anthropics_skills.json +531 -55
- package/data/skill-index/antonbabenko_terraform-skill.json +12 -11
- package/data/skill-index/bytedance_deer-flow.json +676 -68
- package/data/skill-index/coreyhaines31_marketingskills.json +2005 -760
- package/data/skill-index/entireio_skills.json +151 -23
- package/data/skill-index/github_awesome-copilot.json +7409 -3541
- package/data/skill-index/google_skills.json +1000 -149
- package/data/skill-index/heygen-com_hyperframes.json +743 -41
- package/data/skill-index/himself65_finance-skills.json +1169 -94
- package/data/skill-index/kemiljk_fluid-design.json +6 -5
- package/data/skill-index/kepano_obsidian-skills.json +126 -16
- package/data/skill-index/luongnv89_skills.json +1210 -94
- package/data/skill-index/mattpocock_skills.json +838 -105
- package/data/skill-index/nextlevelbuilder_ui-ux-pro-max-skill.json +414 -22
- package/data/skill-index/obra_superpowers.json +375 -43
- package/data/skill-index/romainsimon_paperasse.json +377 -21
- package/data/skill-index/sickn33_antigravity-awesome-skills.json +11342 -5578
- package/data/skill-index/slavingia_skills.json +387 -31
- package/data/skill-index/warpdotdev_oz-skills.json +474 -46
- package/dist/agent-skill-manager.js +213 -211
- package/dist/chunk-54DE5T53.js +19 -0
- package/dist/chunk-6PA2GSCN.js +3 -0
- package/dist/chunk-NGQYBLQE.js +3 -0
- package/dist/{config-55HAAFSH.js → config-7PXPKO4K.js} +1 -1
- package/dist/lock-MDX7A2DF.js +2 -0
- package/dist/{src-VA7JX53D.js → src-S3FQI2MC.js} +1 -1
- package/package.json +4 -2
- package/dist/chunk-GOI5LV72.js +0 -3
- package/dist/chunk-HG3RG5GM.js +0 -19
- package/dist/chunk-PVEAYTE2.js +0 -3
- package/dist/lock-SOHBB4N3.js +0 -2
|
@@ -1,165 +1,165 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __asmCreateRequire } from 'node:module'; const require = __asmCreateRequire(import.meta.url);
|
|
3
|
-
import{a as
|
|
4
|
-
`)}};
|
|
5
|
-
`)?
|
|
3
|
+
import{a as Le,b as bt,c as Ao,d as Co,e as Po}from"./chunk-NGQYBLQE.js";import{A as $o,D as xo,E as Eo,F as G,G as Di,H as No,J as Io,K as Ro,L as Lo,M as _i,N as Oo,a as re,b as ue,c as co,d as os,g as ee,h as uo,i as Ri,j as fo,k as po,l as mo,m as Li,n as ho,o as u,p as go,q as yo,r as bo,s as Oi,t as Ti,u as Mi,v as wo,w as vo,x as as,y as ko,z as So}from"./chunk-54DE5T53.js";import{a as no,b as I,c as ro,d as gt,e as oo,f as yt,g as ao,j as ce,k as B,l as lo}from"./chunk-6PA2GSCN.js";import{a as rs,b as P,d as io}from"./chunk-7BMOBFGJ.js";var q=P(Y=>{"use strict";var Hi=Symbol.for("yaml.alias"),Wo=Symbol.for("yaml.document"),ms=Symbol.for("yaml.map"),Go=Symbol.for("yaml.pair"),Wi=Symbol.for("yaml.scalar"),hs=Symbol.for("yaml.seq"),ye=Symbol.for("yaml.node.type"),cf=e=>!!e&&typeof e=="object"&&e[ye]===Hi,uf=e=>!!e&&typeof e=="object"&&e[ye]===Wo,df=e=>!!e&&typeof e=="object"&&e[ye]===ms,ff=e=>!!e&&typeof e=="object"&&e[ye]===Go,Yo=e=>!!e&&typeof e=="object"&&e[ye]===Wi,pf=e=>!!e&&typeof e=="object"&&e[ye]===hs;function zo(e){if(e&&typeof e=="object")switch(e[ye]){case ms:case hs:return!0}return!1}function mf(e){if(e&&typeof e=="object")switch(e[ye]){case Hi:case ms:case Wi:case hs:return!0}return!1}var hf=e=>(Yo(e)||zo(e))&&!!e.anchor;Y.ALIAS=Hi;Y.DOC=Wo;Y.MAP=ms;Y.NODE_TYPE=ye;Y.PAIR=Go;Y.SCALAR=Wi;Y.SEQ=hs;Y.hasAnchor=hf;Y.isAlias=cf;Y.isCollection=zo;Y.isDocument=uf;Y.isMap=df;Y.isNode=mf;Y.isPair=ff;Y.isScalar=Yo;Y.isSeq=pf});var wt=P(Gi=>{"use strict";var J=q(),te=Symbol("break visit"),Qo=Symbol("skip children"),pe=Symbol("remove node");function gs(e,t){let s=Xo(t);J.isDocument(e)?Ze(null,e.contents,s,Object.freeze([e]))===pe&&(e.contents=null):Ze(null,e,s,Object.freeze([]))}gs.BREAK=te;gs.SKIP=Qo;gs.REMOVE=pe;function Ze(e,t,s,i){let n=Zo(e,t,s,i);if(J.isNode(n)||J.isPair(n))return ea(e,i,n),Ze(e,n,s,i);if(typeof n!="symbol"){if(J.isCollection(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){let o=Ze(r,t.items[r],s,i);if(typeof o=="number")r=o-1;else{if(o===te)return te;o===pe&&(t.items.splice(r,1),r-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let r=Ze("key",t.key,s,i);if(r===te)return te;r===pe&&(t.key=null);let o=Ze("value",t.value,s,i);if(o===te)return te;o===pe&&(t.value=null)}}return n}async function ys(e,t){let s=Xo(t);J.isDocument(e)?await et(null,e.contents,s,Object.freeze([e]))===pe&&(e.contents=null):await et(null,e,s,Object.freeze([]))}ys.BREAK=te;ys.SKIP=Qo;ys.REMOVE=pe;async function et(e,t,s,i){let n=await Zo(e,t,s,i);if(J.isNode(n)||J.isPair(n))return ea(e,i,n),et(e,n,s,i);if(typeof n!="symbol"){if(J.isCollection(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){let o=await et(r,t.items[r],s,i);if(typeof o=="number")r=o-1;else{if(o===te)return te;o===pe&&(t.items.splice(r,1),r-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let r=await et("key",t.key,s,i);if(r===te)return te;r===pe&&(t.key=null);let o=await et("value",t.value,s,i);if(o===te)return te;o===pe&&(t.value=null)}}return n}function Xo(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 Zo(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 ea(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`)}}Gi.visit=gs;Gi.visitAsync=ys});var Yi=P(sa=>{"use strict";var ta=q(),gf=wt(),yf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},bf=e=>e.replace(/[!,[\]{}]/g,t=>yf[t]),vt=class e{constructor(t,s){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,s)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,s){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(s(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return s(0,"%YAML directive should contain exactly one part"),!1;let[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return s(6,`Unsupported YAML version ${r}`,o),!1}}default:return s(0,`Unknown directive ${n}`,!0),!1}}tagName(t,s){if(t==="!")return"!";if(t[0]!=="!")return s(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(s(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&s("Verbatim tags must end with a >"),o)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||s(`The ${t} tag has no suffix`);let r=this.tags[i];if(r)try{return r+decodeURIComponent(n)}catch(o){return s(String(o)),null}return i==="!"?t:(s(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[s,i]of Object.entries(this.tags))if(t.startsWith(i))return s+bf(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&&ta.isNode(t.contents)){let r={};gf.visit(t.contents,(o,a)=>{ta.isNode(a)&&a.tag&&(r[a.tag]=!0)}),n=Object.keys(r)}else n=[];for(let[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!t||n.some(a=>a.startsWith(o)))&&s.push(`%TAG ${r} ${o}`);return s.join(`
|
|
4
|
+
`)}};vt.defaultYaml={explicit:!1,version:"1.2"};vt.defaultTags={"!!":"tag:yaml.org,2002:"};sa.Directives=vt});var bs=P(kt=>{"use strict";var ia=q(),wf=wt();function vf(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 na(e){let t=new Set;return wf.visit(e,{Value(s,i){i.anchor&&t.add(i.anchor)}}),t}function ra(e,t){for(let s=1;;++s){let i=`${e}${s}`;if(!t.has(i))return i}}function kf(e,t){let s=[],i=new Map,n=null;return{onAnchor:r=>{s.push(r),n??(n=na(e));let o=ra(t,n);return n.add(o),o},setAnchors:()=>{for(let r of s){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(ia.isScalar(o.node)||ia.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:i}}kt.anchorIsValid=vf;kt.anchorNames=na;kt.createNodeAnchors=kf;kt.findNewAnchor=ra});var zi=P(oa=>{"use strict";function St(e,t,s,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let o=i[n],a=St(e,i,String(n),o);a===void 0?delete i[n]:a!==o&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),o=St(e,i,n,r);o===void 0?i.delete(n):o!==r&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let r=St(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let o=St(e,i,n,r);o===void 0?delete i[n]:o!==r&&(i[n]=o)}return e.call(t,s,i)}oa.applyReviver=St});var ke=P(la=>{"use strict";var Sf=q();function aa(e,t,s){if(Array.isArray(e))return e.map((i,n)=>aa(i,String(n),s));if(e&&typeof e.toJSON=="function"){if(!s||!Sf.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}la.toJS=aa});var ws=P(ua=>{"use strict";var $f=zi(),ca=q(),xf=ke(),Qi=class{constructor(t){Object.defineProperty(this,ca.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(!ca.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=xf.toJS(this,"",o);if(typeof n=="function")for(let{count:l,res:c}of o.anchors.values())n(c,l);return typeof r=="function"?$f.applyReviver(r,{"":a},"",a):a}};ua.NodeBase=Qi});var $t=P(da=>{"use strict";var Ef=bs(),Af=wt(),tt=q(),Cf=ws(),Pf=ke(),Xi=class extends Cf.NodeBase{constructor(t){super(tt.ALIAS),this.source=t,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(t,s){let i;s?.aliasResolveCache?i=s.aliasResolveCache:(i=[],Af.visit(t,{Node:(r,o)=>{(tt.isAlias(o)||tt.hasAnchor(o))&&i.push(o)}}),s&&(s.aliasResolveCache=i));let n;for(let r of i){if(r===this)break;r.anchor===this.source&&(n=r)}return n}toJSON(t,s){if(!s)return{source:this.source};let{anchors:i,doc:n,maxAliasCount:r}=s,o=this.resolve(n,s);if(!o){let l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=i.get(o);if(a||(Pf.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=vs(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(Ef.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 vs(e,t,s){if(tt.isAlias(t)){let i=t.resolve(e),n=s&&i&&s.get(i);return n?n.count*n.aliasCount:0}else if(tt.isCollection(t)){let i=0;for(let n of t.items){let r=vs(e,n,s);r>i&&(i=r)}return i}else if(tt.isPair(t)){let i=vs(e,t.key,s),n=vs(e,t.value,s);return Math.max(i,n)}return 1}da.Alias=Xi});var V=P(Zi=>{"use strict";var Nf=q(),If=ws(),Rf=ke(),Lf=e=>!e||typeof e!="function"&&typeof e!="object",Se=class extends If.NodeBase{constructor(t){super(Nf.SCALAR),this.value=t}toJSON(t,s){return s?.keep?this.value:Rf.toJS(this.value,t,s)}toString(){return String(this.value)}};Se.BLOCK_FOLDED="BLOCK_FOLDED";Se.BLOCK_LITERAL="BLOCK_LITERAL";Se.PLAIN="PLAIN";Se.QUOTE_DOUBLE="QUOTE_DOUBLE";Se.QUOTE_SINGLE="QUOTE_SINGLE";Zi.Scalar=Se;Zi.isScalarValue=Lf});var xt=P(pa=>{"use strict";var Of=$t(),qe=q(),fa=V(),Tf="tag:yaml.org,2002:";function Mf(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 Df(e,t,s){if(qe.isDocument(e)&&(e=e.contents),qe.isNode(e))return e;if(qe.isPair(e)){let d=s.schema[qe.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 Of.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=Tf+t.slice(2));let c=Mf(e,t,o.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new fa.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?o[qe.MAP]:Symbol.iterator in Object(e)?o[qe.SEQ]:o[qe.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 fa.Scalar(e);return t?f.tag=t:c.default||(f.tag=c.tag),l&&(l.node=f),f}pa.createNode=Df});var Ss=P(ks=>{"use strict";var _f=xt(),me=q(),Ff=ws();function en(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 _f.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 ma=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,tn=class extends Ff.NodeBase{constructor(t,s){super(t),Object.defineProperty(this,"schema",{value:s,configurable:!0,enumerable:!1,writable:!0})}clone(t){let s=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return t&&(s.schema=t),s.items=s.items.map(i=>me.isNode(i)||me.isPair(i)?i.clone(t):i),this.range&&(s.range=this.range.slice()),s}addIn(t,s){if(ma(t))this.add(s);else{let[i,...n]=t,r=this.get(i,!0);if(me.isCollection(r))r.addIn(n,s);else if(r===void 0&&this.schema)this.set(i,en(this.schema,n,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}deleteIn(t){let[s,...i]=t;if(i.length===0)return this.delete(s);let n=this.get(s,!0);if(me.isCollection(n))return n.deleteIn(i);throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}getIn(t,s){let[i,...n]=t,r=this.get(i,!0);return n.length===0?!s&&me.isScalar(r)?r.value:r:me.isCollection(r)?r.getIn(n,s):void 0}hasAllNullValues(t){return this.items.every(s=>{if(!me.isPair(s))return!1;let i=s.value;return i==null||t&&me.isScalar(i)&&i.value==null&&!i.commentBefore&&!i.comment&&!i.tag})}hasIn(t){let[s,...i]=t;if(i.length===0)return this.has(s);let n=this.get(s,!0);return me.isCollection(n)?n.hasIn(i):!1}setIn(t,s){let[i,...n]=t;if(n.length===0)this.set(i,s);else{let r=this.get(i,!0);if(me.isCollection(r))r.setIn(n,s);else if(r===void 0&&this.schema)this.set(i,en(this.schema,n,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};ks.Collection=tn;ks.collectionFromPath=en;ks.isEmptyPath=ma});var Et=P($s=>{"use strict";var qf=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function sn(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var jf=(e,t,s)=>e.endsWith(`
|
|
5
|
+
`)?sn(s,t):s.includes(`
|
|
6
6
|
`)?`
|
|
7
|
-
`+
|
|
8
|
-
`)s===
|
|
9
|
-
`&&
|
|
10
|
-
`&&S!==" "&&(p=
|
|
11
|
-
${t}${e.slice(0,v)}`:(s===
|
|
12
|
-
${t}${e.slice(S+1,v)}`)}return w}function
|
|
13
|
-
`);i=t,n=t+1,r=e[n]}return i}
|
|
14
|
-
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function Ct(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(
|
|
7
|
+
`+sn(s,t):(e.endsWith(" ")?"":" ")+s;$s.indentComment=sn;$s.lineComment=jf;$s.stringifyComment=qf});var ga=P(At=>{"use strict";var Bf="flow",nn="block",xs="quoted";function Uf(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===nn&&(h=ha(e,h,t.length),h!==-1&&(d=h+l));for(let k;k=e[h+=1];){if(s===xs&&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===nn&&(h=ha(e,h,t.length)),d=h+t.length+l,p=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
|
|
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===xs){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===xs&&f[S]&&(w+=`${e[S]}\\`),w+=`
|
|
12
|
+
${t}${e.slice(S+1,v)}`)}return w}function ha(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=nn;At.FOLD_FLOW=Bf;At.FOLD_QUOTED=xs;At.foldFlowLines=Uf});var Pt=P(ya=>{"use strict";var de=V(),$e=ga(),As=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Cs=e=>/^(%|---|\.\.\.)/m.test(e);function Vf(e,t,s){if(!t||t<0)return!1;let i=t-s,n=e.length;if(n<=i)return!1;for(let r=0,o=0;r<n;++r)if(e[r]===`
|
|
14
|
+
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function Ct(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(Cs(e)?" ":""),o="",a=0;for(let l=0,c=s[l];c;c=s[++l])if(c===" "&&s[l+1]==="\\"&&s[l+2]==="n"&&(o+=s.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(s[l+1]){case"u":{o+=s.slice(a,l);let f=s.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=s.substr(l,6)}l+=5,a=l+1}break;case"n":if(i||s[l+2]==='"'||s.length<n)l+=1;else{for(o+=s.slice(a,l)+`
|
|
15
15
|
|
|
16
16
|
`;s[l+2]==="\\"&&s[l+3]==="n"&&s[l+4]!=='"';)o+=`
|
|
17
|
-
`,l+=2;o+=r,s[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+s.slice(a):s,i?o:$e.foldFlowLines(o,r,$e.FOLD_QUOTED
|
|
18
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return Ct(e,t);let s=t.indent||(
|
|
19
|
-
${s}`)+"'";return t.implicitKey?i:$e.foldFlowLines(i,s,$e.FOLD_FLOW
|
|
17
|
+
`,l+=2;o+=r,s[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+s.slice(a):s,i?o:$e.foldFlowLines(o,r,$e.FOLD_QUOTED,As(t,!1))}function rn(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
18
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return Ct(e,t);let s=t.indent||(Cs(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
19
|
+
${s}`)+"'";return t.implicitKey?i:$e.foldFlowLines(i,s,$e.FOLD_FLOW,As(t,!1))}function st(e,t){let{singleQuote:s}=t.options,i;if(s===!1)i=Ct;else{let n=e.includes('"'),r=e.includes("'");n&&!r?i=rn:r&&!n?i=Ct:i=s?rn:Ct}return i(e,t)}var on;try{on=new RegExp(`(^|(?<!
|
|
20
20
|
))
|
|
21
21
|
+(?!
|
|
22
|
-
|$)`,"g")}catch{
|
|
22
|
+
|$)`,"g")}catch{on=/\n+(?!\n|$)/g}function Es({comment:e,type:t,value:s},i,n,r){let{blockQuote:o,commentString:a,lineWidth:l}=i.options;if(!o||/\n[\t ]+$/.test(s))return st(s,i);let c=i.indent||(i.forceBlockIndent||Cs(s)?" ":""),f=o==="literal"?!0:o==="folded"||t===de.Scalar.BLOCK_FOLDED?!1:t===de.Scalar.BLOCK_LITERAL?!0:!Vf(s,l,c.length);if(!s)return f?`|
|
|
23
23
|
`:`>
|
|
24
|
-
`;let
|
|
25
|
-
`&&v!==" "&&v!==" ")break}let
|
|
26
|
-
`);y===-1?
|
|
27
|
-
`&&(
|
|
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=(
|
|
29
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),
|
|
24
|
+
`;let d,p;for(p=s.length;p>0;--p){let v=s[p-1];if(v!==`
|
|
25
|
+
`&&v!==" "&&v!==" ")break}let m=s.substring(p),y=m.indexOf(`
|
|
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(on,`$&${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
|
+
`)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}`),A=!1,E=As(i,!0);o!=="folded"&&t!==de.Scalar.BLOCK_FOLDED&&(E.onOverflow=()=>{A=!0});let x=$e.foldFlowLines(`${w}${v}${m}`,c,$e.FOLD_BLOCK,E);if(!A)return`>${S}
|
|
30
30
|
${c}${x}`}return s=s.replace(/\n+/g,`$&${c}`),`|${S}
|
|
31
|
-
${c}${w}${s}${
|
|
32
|
-
`)||
|
|
33
|
-
`)?st(r,t):
|
|
34
|
-
`))return
|
|
35
|
-
${l}`);if(o){let p=
|
|
36
|
-
${t.indent}${a}`:a}
|
|
37
|
-
${a}:`):(g=`${g}:`,p&&(g+=
|
|
38
|
-
`:"",w){let E=c(w);
|
|
39
|
-
${
|
|
40
|
-
`&&k&&(
|
|
41
|
-
|
|
42
|
-
`):
|
|
43
|
-
${s.indent}`}else if(!
|
|
44
|
-
`),M=x!==-1,O=s.inFlow??t.flow??t.items.length===0;if(M||!O){let D=!1;if(M&&(E==="&"||E==="!")){let T=v.indexOf(" ");E==="&"&&T!==-1&&T<x&&v[T+1]==="!"&&(T=v.indexOf(" ",T+1)),(T===-1||x<T)&&(D=!0)}D||(
|
|
31
|
+
${c}${w}${s}${m}`}function Kf(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 st(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||f||!r.includes(`
|
|
33
|
+
`)?st(r,t):Es(e,t,s,i);if(!a&&!f&&n!==de.Scalar.PLAIN&&r.includes(`
|
|
34
|
+
`))return Es(e,t,s,i);if(Cs(r)){if(l==="")return t.forceBlockIndent=!0,Es(e,t,s,i);if(a&&l===c)return st(r,t)}let d=r.replace(/\n+/g,`$&
|
|
35
|
+
${l}`);if(o){let p=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:m,tags:y}=t.doc.schema;if(y.some(p)||m?.some(p))return st(r,t)}return a?d:$e.foldFlowLines(d,l,$e.FOLD_FLOW,As(t,!1))}function Jf(e,t,s,i){let{implicitKey:n,inFlow:r}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;a!==de.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=de.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case de.Scalar.BLOCK_FOLDED:case de.Scalar.BLOCK_LITERAL:return n||r?st(o.value,t):Es(o,t,s,i);case de.Scalar.QUOTE_DOUBLE:return Ct(o.value,t);case de.Scalar.QUOTE_SINGLE:return rn(o.value,t);case de.Scalar.PLAIN:return Kf(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}ya.stringifyString=Jf});var Nt=P(an=>{"use strict";var Hf=bs(),xe=q(),Wf=Et(),Gf=Pt();function Yf(e,t){let s=Object.assign({blockQuote:!0,commentString:Wf.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 zf(e,t){if(t.tag){let n=e.filter(r=>r.tag===t.tag);if(n.length>0)return n.find(r=>r.format===t.format)??n[0]}let s,i;if(xe.isScalar(t)){i=t.value;let n=e.filter(r=>r.identify?.(i));if(n.length>1){let r=n.filter(o=>o.test);r.length>0&&(n=r)}s=n.find(r=>r.format===t.format)??n.find(r=>!r.format)}else i=t,s=e.find(n=>n.nodeClass&&i instanceof n.nodeClass);if(!s){let n=i?.constructor?.name??(i===null?"null":typeof i);throw new Error(`Tag not resolved for ${n} value`)}return s}function Qf(e,t,{anchors:s,doc:i}){if(!i.directives)return"";let n=[],r=(xe.isScalar(e)||xe.isCollection(e))&&e.anchor;r&&Hf.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 Xf(e,t,s,i){if(xe.isPair(e))return e.toString(t,s,i);if(xe.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw new TypeError("Cannot stringify circular structure without alias nodes");t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=new Set([e]),e=e.resolve(t.doc)}let n,r=xe.isNode(e)?e:t.doc.createNode(e,{onTagObj:l=>n=l});n??(n=zf(t.doc.schema.tags,r));let o=Qf(r,n,t);o.length>0&&(t.indentAtStart=(t.indentAtStart??0)+o.length+1);let a=typeof n.stringify=="function"?n.stringify(r,t,s,i):xe.isScalar(r)?Gf.stringifyString(r,t,s,i):r.toString(t,s,i);return o?xe.isScalar(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
36
|
+
${t.indent}${a}`:a}an.createStringifyContext=Yf;an.stringify=Xf});var ka=P(va=>{"use strict";var be=q(),ba=V(),wa=Nt(),It=Et();function Zf({key:e,value:t},s,i,n){let{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:d}}=s,p=be.isNode(e)&&e.comment||null;if(d){if(p)throw new Error("With simple keys, key nodes cannot have comments");if(be.isCollection(e)||!be.isNode(e)&&typeof e=="object"){let E="With simple keys, collection cannot be used as a key value";throw new Error(E)}}let m=!d&&(!e||p&&t==null&&!s.inFlow||be.isCollection(e)||(be.isScalar(e)?e.type===ba.Scalar.BLOCK_FOLDED||e.type===ba.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=wa.stringify(e,s,()=>y=!0,()=>h=!0);if(!m&&!s.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(s.inFlow){if(r||t==null)return y&&i&&i(),g===""?"?":m?`? ${g}`:g}else if(r&&!d||t==null&&m)return g=`? ${g}`,p&&!y?g+=It.lineComment(g,s.indent,c(p)):h&&n&&n(),g;y&&(p=null),m?(p&&(g+=It.lineComment(g,s.indent,c(p))),g=`? ${g}
|
|
37
|
+
${a}:`):(g=`${g}:`,p&&(g+=It.lineComment(g,s.indent,c(p))));let b,w,k;be.isNode(t)?(b=!!t.spaceBefore,w=t.commentBefore,k=t.comment):(b=!1,w=null,k=null,t&&typeof t=="object"&&(t=o.createNode(t))),s.implicitKey=!1,!m&&!p&&be.isScalar(t)&&(s.indentAtStart=g.length+1),h=!1,!f&&l.length>=2&&!s.inFlow&&!m&&be.isSeq(t)&&!t.flow&&!t.tag&&!t.anchor&&(s.indent=s.indent.substring(2));let S=!1,v=wa.stringify(t,s,()=>S=!0,()=>h=!0),A=" ";if(p||b||w){if(A=b?`
|
|
38
|
+
`:"",w){let E=c(w);A+=`
|
|
39
|
+
${It.indentComment(E,s.indent)}`}v===""&&!s.inFlow?A===`
|
|
40
|
+
`&&k&&(A=`
|
|
41
|
+
|
|
42
|
+
`):A+=`
|
|
43
|
+
${s.indent}`}else if(!m&&be.isCollection(t)){let E=v[0],x=v.indexOf(`
|
|
44
|
+
`),M=x!==-1,O=s.inFlow??t.flow??t.items.length===0;if(M||!O){let D=!1;if(M&&(E==="&"||E==="!")){let T=v.indexOf(" ");E==="&"&&T!==-1&&T<x&&v[T+1]==="!"&&(T=v.indexOf(" ",T+1)),(T===-1||x<T)&&(D=!0)}D||(A=`
|
|
45
45
|
${s.indent}`)}}else(v===""||v[0]===`
|
|
46
|
-
`)&&(
|
|
47
|
-
${l}${
|
|
48
|
-
`}}return e?(
|
|
49
|
-
`+
|
|
50
|
-
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=
|
|
51
|
-
${r}${n}${
|
|
46
|
+
`)&&(A="");return g+=A+v,s.inFlow?S&&i&&i():k&&!S?g+=It.lineComment(g,s.indent,c(k)):h&&n&&n(),g}va.stringifyPair=Zf});var cn=P(ln=>{"use strict";var Sa=rs("process");function ep(e,...t){e==="debug"&&console.log(...t)}function tp(e,t){(e==="debug"||e==="warn")&&(typeof Sa.emitWarning=="function"?Sa.emitWarning(t):console.warn(t))}ln.debug=ep;ln.warn=tp});var Rs=P(Is=>{"use strict";var Rt=q(),$a=V(),Ps="<<",Ns={identify:e=>e===Ps||typeof e=="symbol"&&e.description===Ps,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new $a.Scalar(Symbol(Ps)),{addToJSMap:xa}),stringify:()=>Ps},sp=(e,t)=>(Ns.identify(t)||Rt.isScalar(t)&&(!t.type||t.type===$a.Scalar.PLAIN)&&Ns.identify(t.value))&&e?.doc.schema.tags.some(s=>s.tag===Ns.tag&&s.default);function xa(e,t,s){if(s=e&&Rt.isAlias(s)?s.resolve(e.doc):s,Rt.isSeq(s))for(let i of s.items)un(e,t,i);else if(Array.isArray(s))for(let i of s)un(e,t,i);else un(e,t,s)}function un(e,t,s){let i=e&&Rt.isAlias(s)?s.resolve(e.doc):s;if(!Rt.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[r,o]of n)t instanceof Map?t.has(r)||t.set(r,o):t instanceof Set?t.add(r):Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}Is.addMergeToJSMap=xa;Is.isMergeKey=sp;Is.merge=Ns});var fn=P(Ca=>{"use strict";var ip=cn(),Ea=Rs(),np=Nt(),Aa=q(),dn=ke();function rp(e,t,{key:s,value:i}){if(Aa.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,i);else if(Ea.isMergeKey(e,s))Ea.addMergeToJSMap(e,t,i);else{let n=dn.toJS(s,"",e);if(t instanceof Map)t.set(n,dn.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let r=op(s,n,e),o=dn.toJS(i,r,e);r in t?Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):t[r]=o}}return t}function op(e,t,s){if(t===null)return"";if(typeof t!="object")return String(t);if(Aa.isNode(e)&&s?.doc){let i=np.createStringifyContext(s.doc,{});i.anchors=new Set;for(let r of s.anchors.keys())i.anchors.add(r.anchor);i.inFlow=!0,i.inStringifyKey=!0;let n=e.toString(i);if(!s.mapKeyWarned){let r=JSON.stringify(n);r.length>40&&(r=r.substring(0,36)+'..."'),ip.warn(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return n}return JSON.stringify(t)}Ca.addPairToJSMap=rp});var Ee=P(pn=>{"use strict";var Pa=xt(),ap=ka(),lp=fn(),Ls=q();function cp(e,t,s){let i=Pa.createNode(e,void 0,s),n=Pa.createNode(t,void 0,s);return new Os(i,n)}var Os=class e{constructor(t,s=null){Object.defineProperty(this,Ls.NODE_TYPE,{value:Ls.PAIR}),this.key=t,this.value=s}clone(t){let{key:s,value:i}=this;return Ls.isNode(s)&&(s=s.clone(t)),Ls.isNode(i)&&(i=i.clone(t)),new e(s,i)}toJSON(t,s){let i=s?.mapAsMap?new Map:{};return lp.addPairToJSMap(s,i,this)}toString(t,s,i){return t?.doc?ap.stringifyPair(this,t,s,i):JSON.stringify(this)}};pn.Pair=Os;pn.createPair=cp});var mn=P(Ia=>{"use strict";var je=q(),Na=Nt(),Ts=Et();function up(e,t,s){return(t.inFlow??e.flow?fp:dp)(e,t,s)}function dp({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(je.isNode(h))!d&&h.spaceBefore&&p.push(""),Ms(s,p,h.commentBefore,d),h.comment&&(g=h.comment);else if(je.isPair(h)){let w=je.isNode(h.key)?h.key:null;w&&(!d&&w.spaceBefore&&p.push(""),Ms(s,p,w.commentBefore,d))}d=!1;let b=Na.stringify(h,f,()=>g=null,()=>d=!0);g&&(b+=Ts.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
|
+
${l}${h}`:`
|
|
48
|
+
`}}return e?(m+=`
|
|
49
|
+
`+Ts.indentComment(c(e),l),a&&a()):d&&o&&o(),m}function fp({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(je.isNode(h))h.spaceBefore&&d.push(""),Ms(t,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(je.isPair(h)){let w=je.isNode(h.key)?h.key:null;w&&(w.spaceBefore&&d.push(""),Ms(t,d,w.commentBefore,!1),w.comment&&(c=!0));let k=je.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=Na.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+=Ts.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
|
+
${r}${n}${h}`:`
|
|
52
52
|
`;return`${y}
|
|
53
|
-
${n}${
|
|
54
|
-
`:" ")}return
|
|
53
|
+
${n}${m}`}else return`${p}${o}${d.join(" ")}${o}${m}`}function Ms({indent:e,options:{commentString:t}},s,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let r=Ts.indentComment(t(i),e);s.push(r.trimStart())}}Ia.stringifyCollection=up});var Ce=P(gn=>{"use strict";var pp=mn(),mp=fn(),hp=Ss(),Ae=q(),Ds=Ee(),gp=V();function Lt(e,t){let s=Ae.isScalar(t)?t.value:t;for(let i of e)if(Ae.isPair(i)&&(i.key===t||i.key===s||Ae.isScalar(i.key)&&i.key.value===s))return i}var hn=class extends hp.Collection{static get tagName(){return"tag:yaml.org,2002:map"}constructor(t){super(Ae.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(Ds.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;Ae.isPair(t)?i=t:!t||typeof t!="object"||!("key"in t)?i=new Ds.Pair(t,t?.value):i=new Ds.Pair(t.key,t.value);let n=Lt(this.items,i.key),r=this.schema?.sortMapEntries;if(n){if(!s)throw new Error(`Key ${i.key} already set`);Ae.isScalar(n.value)&&gp.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(r){let o=this.items.findIndex(a=>r(i,a)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){let s=Lt(this.items,t);return s?this.items.splice(this.items.indexOf(s),1).length>0:!1}get(t,s){let n=Lt(this.items,t)?.value;return(!s&&Ae.isScalar(n)?n.value:n)??void 0}has(t){return!!Lt(this.items,t)}set(t,s){this.add(new Ds.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)mp.addPairToJSMap(s,n,r);return n}toString(t,s,i){if(!t)return JSON.stringify(this);for(let n of this.items)if(!Ae.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})),pp.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:s})}};gn.YAMLMap=hn;gn.findPair=Lt});var it=P(La=>{"use strict";var yp=q(),Ra=Ce(),bp={collection:"map",default:!0,nodeClass:Ra.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return yp.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,s)=>Ra.YAMLMap.from(e,t,s)};La.map=bp});var Pe=P(Oa=>{"use strict";var wp=xt(),vp=mn(),kp=Ss(),Fs=q(),Sp=V(),$p=ke(),yn=class extends kp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Fs.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let s=_s(t);return typeof s!="number"?!1:this.items.splice(s,1).length>0}get(t,s){let i=_s(t);if(typeof i!="number")return;let n=this.items[i];return!s&&Fs.isScalar(n)?n.value:n}has(t){let s=_s(t);return typeof s=="number"&&s<this.items.length}set(t,s){let i=_s(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];Fs.isScalar(n)&&Sp.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($p.toJS(r,String(n++),s));return i}toString(t,s,i){return t?vp.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(wp.createNode(a,void 0,i))}}return r}};function _s(e){let t=Fs.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}Oa.YAMLSeq=yn});var nt=P(Ma=>{"use strict";var xp=q(),Ta=Pe(),Ep={collection:"seq",default:!0,nodeClass:Ta.YAMLSeq,tag:"tag:yaml.org,2002:seq",resolve(e,t){return xp.isSeq(e)||t("Expected a sequence for this tag"),e},createNode:(e,t,s)=>Ta.YAMLSeq.from(e,t,s)};Ma.seq=Ep});var Ot=P(Da=>{"use strict";var Ap=Pt(),Cp={identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify(e,t,s,i){return t=Object.assign({actualString:!0},t),Ap.stringifyString(e,t,s,i)}};Da.string=Cp});var qs=P(qa=>{"use strict";var _a=V(),Fa={identify:e=>e==null,createNode:()=>new _a.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new _a.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&Fa.test.test(e)?e:t.options.nullStr};qa.nullTag=Fa});var bn=P(Ba=>{"use strict";var Pp=V(),ja={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new Pp.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&ja.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?s.options.trueStr:s.options.falseStr}};Ba.boolTag=ja});var rt=P(Ua=>{"use strict";function Np({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}Ua.stringifyNumber=Np});var vn=P(js=>{"use strict";var Ip=V(),wn=rt(),Rp={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:wn.stringifyNumber},Lp={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():wn.stringifyNumber(e)}},Op={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 Ip.Scalar(parseFloat(e)),s=e.indexOf(".");return s!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-s-1),t},stringify:wn.stringifyNumber};js.float=Op;js.floatExp=Lp;js.floatNaN=Rp});var Sn=P(Us=>{"use strict";var Va=rt(),Bs=e=>typeof e=="bigint"||Number.isInteger(e),kn=(e,t,s,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),s);function Ka(e,t,s){let{value:i}=e;return Bs(i)&&i>=0?s+i.toString(t):Va.stringifyNumber(e)}var Tp={identify:e=>Bs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>kn(e,2,8,s),stringify:e=>Ka(e,8,"0o")},Mp={identify:Bs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>kn(e,0,10,s),stringify:Va.stringifyNumber},Dp={identify:e=>Bs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>kn(e,2,16,s),stringify:e=>Ka(e,16,"0x")};Us.int=Mp;Us.intHex=Dp;Us.intOct=Tp});var Ha=P(Ja=>{"use strict";var _p=it(),Fp=qs(),qp=nt(),jp=Ot(),Bp=bn(),$n=vn(),xn=Sn(),Up=[_p.map,qp.seq,jp.string,Fp.nullTag,Bp.boolTag,xn.intOct,xn.int,xn.intHex,$n.floatNaN,$n.floatExp,$n.float];Ja.schema=Up});var Ya=P(Ga=>{"use strict";var Vp=V(),Kp=it(),Jp=nt();function Wa(e){return typeof e=="bigint"||Number.isInteger(e)}var Vs=({value:e})=>JSON.stringify(e),Hp=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Vs},{identify:e=>e==null,createNode:()=>new Vp.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Vs},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Vs},{identify:Wa,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})=>Wa(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:Vs}],Wp={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Gp=[Kp.map,Jp.seq].concat(Hp,Wp);Ga.schema=Gp});var An=P(za=>{"use strict";var Tt=rs("buffer"),En=V(),Yp=Pt(),zp={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Tt.Buffer=="function")return Tt.Buffer.from(e,"base64");if(typeof atob=="function"){let s=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(s.length);for(let n=0;n<s.length;++n)i[n]=s.charCodeAt(n);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:s},i,n,r){if(!s)return"";let o=s,a;if(typeof Tt.Buffer=="function")a=o instanceof Tt.Buffer?o.toString("base64"):Tt.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=En.Scalar.BLOCK_LITERAL),t!==En.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===En.Scalar.BLOCK_LITERAL?`
|
|
54
|
+
`:" ")}return Yp.stringifyString({comment:e,type:t,value:a},i,n,r)}};za.binary=zp});var Hs=P(Js=>{"use strict";var Ks=q(),Cn=Ee(),Qp=V(),Xp=Pe();function Qa(e,t){if(Ks.isSeq(e))for(let s=0;s<e.items.length;++s){let i=e.items[s];if(!Ks.isPair(i)){if(Ks.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new Cn.Pair(new Qp.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]=Bs.isPair(i)?i:new xn.Pair(i)}}else t("Expected a sequence for this tag");return e}function Ha(e,t,s){let{replacer:i}=s,n=new Dp.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;n.items.push(xn.createPair(a,l,s))}return n}var _p={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ja,createNode:Ha};Us.createPairs=Ha;Us.pairs=_p;Us.resolvePairs=Ja});var An=P(Cn=>{"use strict";var Wa=F(),En=ke(),Tt=Ae(),qp=Pe(),Ga=Vs(),Be=class e extends qp.YAMLSeq{constructor(){super(),this.add=Tt.YAMLMap.prototype.add.bind(this),this.delete=Tt.YAMLMap.prototype.delete.bind(this),this.get=Tt.YAMLMap.prototype.get.bind(this),this.has=Tt.YAMLMap.prototype.has.bind(this),this.set=Tt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,s){if(!s)return super.toJSON(t);let i=new Map;s?.onCreate&&s.onCreate(i);for(let n of this.items){let r,o;if(Wa.isPair(n)?(r=En.toJS(n.key,"",s),o=En.toJS(n.value,r,s)):r=En.toJS(n,"",s),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}static from(t,s,i){let n=Ga.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var Fp={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=Ga.resolvePairs(e,t),i=[];for(let{key:n}of s.items)Wa.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Be,s)},createNode:(e,t,s)=>Be.from(e,t,s)};Cn.YAMLOMap=Be;Cn.omap=Fp});var Za=P(Pn=>{"use strict";var Ya=V();function za({value:e,source:t},s){return t&&(e?Qa:Xa).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var Qa={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new Ya.Scalar(!0),stringify:za},Xa={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new Ya.Scalar(!1),stringify:za};Pn.falseTag=Xa;Pn.trueTag=Qa});var el=P(Ks=>{"use strict";var jp=V(),Nn=rt(),Bp={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Nn.stringifyNumber},Up={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Nn.stringifyNumber(e)}},Vp={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 jp.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let i=e.substring(s+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Nn.stringifyNumber};Ks.float=Vp;Ks.floatExp=Up;Ks.floatNaN=Bp});var sl=P(Dt=>{"use strict";var tl=rt(),Mt=e=>typeof e=="bigint"||Number.isInteger(e);function Js(e,t,s,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let r=parseInt(e,s);return n==="-"?-1*r:r}function In(e,t,s){let{value:i}=e;if(Mt(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return tl.stringifyNumber(e)}var Kp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Js(e,2,2,s),stringify:e=>In(e,2,"0b")},Jp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Js(e,1,8,s),stringify:e=>In(e,8,"0")},Hp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Js(e,0,10,s),stringify:tl.stringifyNumber},Wp={identify:Mt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Js(e,2,16,s),stringify:e=>In(e,16,"0x")};Dt.int=Hp;Dt.intBin=Kp;Dt.intHex=Wp;Dt.intOct=Jp});var Rn=P(Ln=>{"use strict";var Gs=F(),Hs=Ee(),Ws=Ae(),Ue=class e extends Ws.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;Gs.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Hs.Pair(t.key,null):s=new Hs.Pair(t,null),Ws.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=Ws.findPair(this.items,t);return!s&&Gs.isPair(i)?Gs.isScalar(i.key)?i.key.value:i.key:i}set(t,s){if(typeof s!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof s}`);let i=Ws.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Hs.Pair(t))}toJSON(t,s){return super.toJSON(t,s,Set)}toString(t,s,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),s,i);throw new Error("Set items must all have null values")}static from(t,s,i){let{replacer:n}=i,r=new this(t);if(s&&Symbol.iterator in Object(s))for(let o of s)typeof n=="function"&&(o=n.call(s,o,o)),r.items.push(Hs.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var Gp={collection:"map",identify:e=>e instanceof Set,nodeClass:Ue,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>Ue.from(e,t,s),resolve(e,t){if(Gs.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ue,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Ln.YAMLSet=Ue;Ln.set=Gp});var Tn=P(Ys=>{"use strict";var Yp=rt();function On(e,t){let s=e[0],i=s==="-"||s==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return s==="-"?n(-1)*r:r}function il(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return Yp.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 zp={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>On(e,s),stringify:il},Qp={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>On(e,!1),stringify:il},nl={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(nl.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,n,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,i-1,n,r||0,o||0,a||0,l),d=t[8];if(d&&d!=="Z"){let f=On(d,!1);Math.abs(f)<30&&(f*=60),c-=6e4*f}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Ys.floatTime=Qp;Ys.intTime=zp;Ys.timestamp=nl});var al=P(ol=>{"use strict";var Xp=it(),Zp=Ds(),em=nt(),tm=Rt(),sm=$n(),rl=Za(),Mn=el(),zs=sl(),im=Ps(),nm=An(),rm=Vs(),om=Rn(),Dn=Tn(),am=[Xp.map,em.seq,tm.string,Zp.nullTag,rl.trueTag,rl.falseTag,zs.intBin,zs.intOct,zs.int,zs.intHex,Mn.floatNaN,Mn.floatExp,Mn.float,sm.binary,im.merge,nm.omap,rm.pairs,om.set,Dn.intTime,Dn.floatTime,Dn.timestamp];ol.schema=am});var yl=P(Fn=>{"use strict";var fl=it(),lm=Ds(),dl=nt(),cm=Rt(),um=hn(),_n=yn(),qn=wn(),fm=ja(),dm=Va(),pl=$n(),_t=Ps(),ml=An(),hl=Vs(),ll=al(),gl=Rn(),Qs=Tn(),cl=new Map([["core",fm.schema],["failsafe",[fl.map,dl.seq,cm.string]],["json",dm.schema],["yaml11",ll.schema],["yaml-1.1",ll.schema]]),ul={binary:pl.binary,bool:um.boolTag,float:_n.float,floatExp:_n.floatExp,floatNaN:_n.floatNaN,floatTime:Qs.floatTime,int:qn.int,intHex:qn.intHex,intOct:qn.intOct,intTime:Qs.intTime,map:fl.map,merge:_t.merge,null:lm.nullTag,omap:ml.omap,pairs:hl.pairs,seq:dl.seq,set:gl.set,timestamp:Qs.timestamp},pm={"tag:yaml.org,2002:binary":pl.binary,"tag:yaml.org,2002:merge":_t.merge,"tag:yaml.org,2002:omap":ml.omap,"tag:yaml.org,2002:pairs":hl.pairs,"tag:yaml.org,2002:set":gl.set,"tag:yaml.org,2002:timestamp":Qs.timestamp};function mm(e,t,s){let i=cl.get(t);if(i&&!e)return s&&!i.includes(_t.merge)?i.concat(_t.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(cl.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${r} or define customTags array`)}if(Array.isArray(e))for(let r of e)n=n.concat(r);else typeof e=="function"&&(n=e(n.slice()));return s&&(n=n.concat(_t.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?ul[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(ul).map(d=>JSON.stringify(d)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Fn.coreKnownTags=pm;Fn.getTags=mm});var Un=P(bl=>{"use strict";var jn=F(),hm=it(),gm=nt(),ym=Rt(),Xs=yl(),bm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Bn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?Xs.getTags(t,"compat"):t?Xs.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?Xs.coreKnownTags:{},this.tags=Xs.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,jn.MAP,{value:hm.map}),Object.defineProperty(this,jn.SCALAR,{value:ym.string}),Object.defineProperty(this,jn.SEQ,{value:gm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?bm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};bl.Schema=Bn});var vl=P(wl=>{"use strict";var wm=F(),Vn=Pt(),qt=xt();function vm(e,t){let s=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(s.push(l),i=!0):e.directives.docStart&&(i=!0)}i&&s.push("---");let n=Vn.createStringifyContext(e,t),{commentString:r}=n.options;if(e.commentBefore){s.length!==1&&s.unshift("");let l=r(e.commentBefore);s.unshift(qt.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(wm.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let d=r(e.contents.commentBefore);s.push(qt.indentComment(d,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Vn.stringify(e.contents,n,()=>a=null,l);a&&(c+=qt.lineComment(c,"",r(a))),(c[0]==="|"||c[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${c}`:s.push(c)}else s.push(Vn.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
56
|
+
${r.comment}`:i.comment}i=n}e.items[s]=Ks.isPair(i)?i:new Cn.Pair(i)}}else t("Expected a sequence for this tag");return e}function Xa(e,t,s){let{replacer:i}=s,n=new Xp.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;n.items.push(Cn.createPair(a,l,s))}return n}var Zp={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Qa,createNode:Xa};Js.createPairs=Xa;Js.pairs=Zp;Js.resolvePairs=Qa});var In=P(Nn=>{"use strict";var Za=q(),Pn=ke(),Mt=Ce(),em=Pe(),el=Hs(),Be=class e extends em.YAMLSeq{constructor(){super(),this.add=Mt.YAMLMap.prototype.add.bind(this),this.delete=Mt.YAMLMap.prototype.delete.bind(this),this.get=Mt.YAMLMap.prototype.get.bind(this),this.has=Mt.YAMLMap.prototype.has.bind(this),this.set=Mt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,s){if(!s)return super.toJSON(t);let i=new Map;s?.onCreate&&s.onCreate(i);for(let n of this.items){let r,o;if(Za.isPair(n)?(r=Pn.toJS(n.key,"",s),o=Pn.toJS(n.value,r,s)):r=Pn.toJS(n,"",s),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}static from(t,s,i){let n=el.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var tm={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=el.resolvePairs(e,t),i=[];for(let{key:n}of s.items)Za.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Be,s)},createNode:(e,t,s)=>Be.from(e,t,s)};Nn.YAMLOMap=Be;Nn.omap=tm});var rl=P(Rn=>{"use strict";var tl=V();function sl({value:e,source:t},s){return t&&(e?il:nl).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var il={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new tl.Scalar(!0),stringify:sl},nl={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new tl.Scalar(!1),stringify:sl};Rn.falseTag=nl;Rn.trueTag=il});var ol=P(Ws=>{"use strict";var sm=V(),Ln=rt(),im={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Ln.stringifyNumber},nm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Ln.stringifyNumber(e)}},rm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new sm.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let i=e.substring(s+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:Ln.stringifyNumber};Ws.float=rm;Ws.floatExp=nm;Ws.floatNaN=im});var ll=P(_t=>{"use strict";var al=rt(),Dt=e=>typeof e=="bigint"||Number.isInteger(e);function Gs(e,t,s,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let r=parseInt(e,s);return n==="-"?-1*r:r}function On(e,t,s){let{value:i}=e;if(Dt(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return al.stringifyNumber(e)}var om={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Gs(e,2,2,s),stringify:e=>On(e,2,"0b")},am={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Gs(e,1,8,s),stringify:e=>On(e,8,"0")},lm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Gs(e,0,10,s),stringify:al.stringifyNumber},cm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Gs(e,2,16,s),stringify:e=>On(e,16,"0x")};_t.int=lm;_t.intBin=om;_t.intHex=cm;_t.intOct=am});var Mn=P(Tn=>{"use strict";var Qs=q(),Ys=Ee(),zs=Ce(),Ue=class e extends zs.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;Qs.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Ys.Pair(t.key,null):s=new Ys.Pair(t,null),zs.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=zs.findPair(this.items,t);return!s&&Qs.isPair(i)?Qs.isScalar(i.key)?i.key.value:i.key:i}set(t,s){if(typeof s!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof s}`);let i=zs.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Ys.Pair(t))}toJSON(t,s){return super.toJSON(t,s,Set)}toString(t,s,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),s,i);throw new Error("Set items must all have null values")}static from(t,s,i){let{replacer:n}=i,r=new this(t);if(s&&Symbol.iterator in Object(s))for(let o of s)typeof n=="function"&&(o=n.call(s,o,o)),r.items.push(Ys.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var um={collection:"map",identify:e=>e instanceof Set,nodeClass:Ue,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>Ue.from(e,t,s),resolve(e,t){if(Qs.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ue,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Tn.YAMLSet=Ue;Tn.set=um});var _n=P(Xs=>{"use strict";var dm=rt();function Dn(e,t){let s=e[0],i=s==="-"||s==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return s==="-"?n(-1)*r:r}function cl(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return dm.stringifyNumber(e);let i="";t<0&&(i="-",t*=s(-1));let n=s(60),r=[t%n];return t<60?r.unshift(0):(t=(t-r[0])/n,r.unshift(t%n),t>=60&&(t=(t-r[0])/n,r.unshift(t))),i+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var fm={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>Dn(e,s),stringify:cl},pm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Dn(e,!1),stringify:cl},ul={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(ul.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,n,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,i-1,n,r||0,o||0,a||0,l),f=t[8];if(f&&f!=="Z"){let d=Dn(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};Xs.floatTime=pm;Xs.intTime=fm;Xs.timestamp=ul});var pl=P(fl=>{"use strict";var mm=it(),hm=qs(),gm=nt(),ym=Ot(),bm=An(),dl=rl(),Fn=ol(),Zs=ll(),wm=Rs(),vm=In(),km=Hs(),Sm=Mn(),qn=_n(),$m=[mm.map,gm.seq,ym.string,hm.nullTag,dl.trueTag,dl.falseTag,Zs.intBin,Zs.intOct,Zs.int,Zs.intHex,Fn.floatNaN,Fn.floatExp,Fn.float,bm.binary,wm.merge,vm.omap,km.pairs,Sm.set,qn.intTime,qn.floatTime,qn.timestamp];fl.schema=$m});var $l=P(Un=>{"use strict";var yl=it(),xm=qs(),bl=nt(),Em=Ot(),Am=bn(),jn=vn(),Bn=Sn(),Cm=Ha(),Pm=Ya(),wl=An(),Ft=Rs(),vl=In(),kl=Hs(),ml=pl(),Sl=Mn(),ei=_n(),hl=new Map([["core",Cm.schema],["failsafe",[yl.map,bl.seq,Em.string]],["json",Pm.schema],["yaml11",ml.schema],["yaml-1.1",ml.schema]]),gl={binary:wl.binary,bool:Am.boolTag,float:jn.float,floatExp:jn.floatExp,floatNaN:jn.floatNaN,floatTime:ei.floatTime,int:Bn.int,intHex:Bn.intHex,intOct:Bn.intOct,intTime:ei.intTime,map:yl.map,merge:Ft.merge,null:xm.nullTag,omap:vl.omap,pairs:kl.pairs,seq:bl.seq,set:Sl.set,timestamp:ei.timestamp},Nm={"tag:yaml.org,2002:binary":wl.binary,"tag:yaml.org,2002:merge":Ft.merge,"tag:yaml.org,2002:omap":vl.omap,"tag:yaml.org,2002:pairs":kl.pairs,"tag:yaml.org,2002:set":Sl.set,"tag:yaml.org,2002:timestamp":ei.timestamp};function Im(e,t,s){let i=hl.get(t);if(i&&!e)return s&&!i.includes(Ft.merge)?i.concat(Ft.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(hl.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${r} or define customTags array`)}if(Array.isArray(e))for(let r of e)n=n.concat(r);else typeof e=="function"&&(n=e(n.slice()));return s&&(n=n.concat(Ft.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?gl[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(gl).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Un.coreKnownTags=Nm;Un.getTags=Im});var Jn=P(xl=>{"use strict";var Vn=q(),Rm=it(),Lm=nt(),Om=Ot(),ti=$l(),Tm=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Kn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?ti.getTags(t,"compat"):t?ti.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?ti.coreKnownTags:{},this.tags=ti.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Vn.MAP,{value:Rm.map}),Object.defineProperty(this,Vn.SCALAR,{value:Om.string}),Object.defineProperty(this,Vn.SEQ,{value:Lm.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?Tm:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};xl.Schema=Kn});var Al=P(El=>{"use strict";var Mm=q(),Hn=Nt(),qt=Et();function Dm(e,t){let s=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(s.push(l),i=!0):e.directives.docStart&&(i=!0)}i&&s.push("---");let n=Hn.createStringifyContext(e,t),{commentString:r}=n.options;if(e.commentBefore){s.length!==1&&s.unshift("");let l=r(e.commentBefore);s.unshift(qt.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(Mm.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let f=r(e.contents.commentBefore);s.push(qt.indentComment(f,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Hn.stringify(e.contents,n,()=>a=null,l);a&&(c+=qt.lineComment(c,"",r(a))),(c[0]==="|"||c[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${c}`:s.push(c)}else s.push(Hn.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
57
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
|
+
`}El.stringifyDocument=Dm});var jt=P(Cl=>{"use strict";var _m=$t(),ot=Ss(),ae=q(),Fm=Ee(),qm=ke(),jm=Jn(),Bm=Al(),Wn=bs(),Um=zi(),Vm=xt(),Gn=Yi(),Yn=class e{constructor(t,s,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ae.NODE_TYPE,{value:ae.DOC});let n=null;typeof s=="function"||Array.isArray(s)?n=s:i===void 0&&s&&(i=s,s=void 0);let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=r;let{version:o}=r;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new Gn.Directives({version:o}),this.setSchema(o,i),this.contents=t===void 0?null:this.createNode(t,n,i)}clone(){let t=Object.create(e.prototype,{[ae.NODE_TYPE]:{value:ae.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=ae.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){at(this.contents)&&this.contents.add(t)}addIn(t,s){at(this.contents)&&this.contents.addIn(t,s)}createAlias(t,s){if(!t.anchor){let i=Wn.anchorNames(this);t.anchor=!s||i.has(s)?Wn.findNewAnchor(s||"a",i):s}return new _m.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}=Wn.createNodeAnchors(this,o||"a"),y={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:m},h=Vm.createNode(t,f,y);return a&&ae.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 Fm.Pair(n,r)}delete(t){return at(this.contents)?this.contents.delete(t):!1}deleteIn(t){return ot.isEmptyPath(t)?this.contents==null?!1:(this.contents=null,!0):at(this.contents)?this.contents.deleteIn(t):!1}get(t,s){return ae.isCollection(this.contents)?this.contents.get(t,s):void 0}getIn(t,s){return ot.isEmptyPath(t)?!s&&ae.isScalar(this.contents)?this.contents.value:this.contents:ae.isCollection(this.contents)?this.contents.getIn(t,s):void 0}has(t){return ae.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return ot.isEmptyPath(t)?this.contents!==void 0:ae.isCollection(this.contents)?this.contents.hasIn(t):!1}set(t,s){this.contents==null?this.contents=ot.collectionFromPath(this.schema,[t],s):at(this.contents)&&this.contents.set(t,s)}setIn(t,s){ot.isEmptyPath(t)?this.contents=s:this.contents==null?this.contents=ot.collectionFromPath(this.schema,Array.from(t),s):at(this.contents)&&this.contents.setIn(t,s)}setSchema(t,s={}){typeof t=="number"&&(t=String(t));let i;switch(t){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new Gn.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 Gn.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 jm.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=qm.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"?Um.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 Bm.stringifyDocument(this,t)}};function at(e){if(ae.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}Cl.Document=Yn});var Vt=P(Ut=>{"use strict";var Bt=class extends Error{constructor(t,s,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=s}},zn=class extends Bt{constructor(t,s,i){super("YAMLParseError",t,s,i)}},Qn=class extends Bt{constructor(t,s,i){super("YAMLWarning",t,s,i)}},Km=(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
|
-
`}};
|
|
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
|
-
`+
|
|
67
|
-
`+k.comment:w.comment=k.comment);let S=new
|
|
68
|
-
`+
|
|
69
|
-
`+E:x.comment=E,
|
|
70
|
-
`+M.comment:x.comment=M.comment);let D=new
|
|
71
|
-
`+g.comment:c.comment=g.comment),c.range=[i.offset,
|
|
72
|
-
`.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return t.source&&(g+=t.source.length),{value:
|
|
73
|
-
`;for(let
|
|
64
|
+
`}};Ut.YAMLError=Bt;Ut.YAMLParseError=zn;Ut.YAMLWarning=Qn;Ut.prettifyError=Km});var Kt=P(Pl=>{"use strict";function Jm(e,{flow:t,indicator:s,next:i,offset:n,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",p="",m=!1,y=!1,h=null,g=null,b=null,w=null,k=null,S=null,v=null;for(let x of e)switch(y&&(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma"&&r(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),y=!1),h&&(c&&x.type!=="comment"&&x.type!=="newline"&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),x.type){case"space":!t&&(s!=="doc-start"||i?.type!=="flow-collection")&&x.source.includes(" ")&&(h=x),f=!0;break;case"comment":{f||r(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let M=x.source.substring(1)||" ";d?d+=p+M:d=M,p="",c=!1;break}case"newline":c?d?d+=x.source:(!S||s!=="seq-item-ind")&&(l=!0):p+=x.source,c=!0,m=!0,(g||b)&&(w=x),f=!0;break;case"anchor":g&&r(x,"MULTIPLE_ANCHORS","A node can have at most one anchor"),x.source.endsWith(":")&&r(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=x,v??(v=x.offset),c=!1,f=!1,y=!0;break;case"tag":{b&&r(x,"MULTIPLE_TAGS","A node can have at most one tag"),b=x,v??(v=x.offset),c=!1,f=!1,y=!0;break}case s:(g||b)&&r(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`),S&&r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${t??"collection"}`),S=x,c=s==="seq-item-ind"||s==="explicit-key-ind",f=!1;break;case"comma":if(t){k&&r(x,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),k=x,c=!1,f=!1;break}default:r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),c=!1,f=!1}let A=e[e.length-1],E=A?A.offset+A.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}}Pl.resolveProps=Jm});var si=P(Nl=>{"use strict";function Xn(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(Xn(t.key)||Xn(t.value))return!0}return!1;default:return!0}}Nl.containsNewline=Xn});var Zn=P(Il=>{"use strict";var Hm=si();function Wm(e,t,s){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&Hm.containsNewline(t)&&s(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Il.flowIndentCheck=Wm});var er=P(Ll=>{"use strict";var Rl=q();function Gm(e,t,s){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(r,o)=>r===o||Rl.isScalar(r)&&Rl.isScalar(o)&&r.value===o.value;return t.some(r=>n(r.key,s))}Ll.mapIncludes=Gm});var Fl=P(_l=>{"use strict";var Ol=Ee(),Ym=Ce(),Tl=Kt(),zm=si(),Ml=Zn(),Qm=er(),Dl="All mapping items must start at the same column";function Xm({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??Ym.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=Tl.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",Dl)),!h.anchor&&!h.tag&&!m){c=h.end,h.comment&&(a.comment?a.comment+=`
|
|
66
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||zm.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",Dl);s.atKey=!0;let b=h.end,w=p?e(s,p,h,n):t(s,b,d,null,h,n);s.schema.compat&&Ml.flowIndentCheck(i.indent,p,n),s.atKey=!1,Qm.mapIncludes(s,a.items,w)&&n(b,"DUPLICATE_KEY","Map keys must be unique");let k=Tl.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&&Ml.flowIndentCheck(i.indent,y,n),l=S.range[2];let v=new Ol.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 Ol.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}_l.resolveBlockMap=Xm});var jl=P(ql=>{"use strict";var Zm=Pe(),eh=Kt(),th=Zn();function sh({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??Zm.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=eh.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&&th.flowIndentCheck(i.indent,d,n),l=m.range[2],a.items.push(m)}return a.range=[i.offset,l,c??l],a}ql.resolveBlockSeq=sh});var lt=P(Bl=>{"use strict";function ih(e,t,s,i){let n="";if(e){let r=!1,o="";for(let a of e){let{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{s&&!r&&i(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let f=l.substring(1)||" ";n?n+=o+f:n=f,o="";break}case"newline":n&&(o+=l),r=!0;break;default:i(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}t+=l.length}}return{comment:n,offset:t}}Bl.resolveEnd=ih});var Jl=P(Kl=>{"use strict";var nh=q(),rh=Ee(),Ul=Ce(),oh=Pe(),ah=lt(),Vl=Kt(),lh=si(),ch=er(),tr="Block collections are not allowed within flow collections",sr=e=>e&&(e.type==="block-map"||e.type==="block-seq");function uh({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=i.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?Ul.YAMLMap:oh.YAMLSeq),c=new l(s.schema);c.flow=!0;let f=s.atRoot;f&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let d=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let b=i.items[g],{start:w,key:k,sep:S,value:v}=b,A=Vl.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:k??S?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!A.found){if(!A.anchor&&!A.tag&&!S&&!v){g===0&&A.comma?n(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<i.items.length-1&&n(A.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),A.comment&&(c.comment?c.comment+=`
|
|
68
|
+
`+A.comment:c.comment=A.comment),d=A.end;continue}!o&&s.options.strict&&lh.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)A.comma&&n(A.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(A.comma||n(A.start,"MISSING_CHAR",`Missing , between ${a} items`),A.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];nh.isPair(x)&&(x=x.value??x.key),x.comment?x.comment+=`
|
|
69
|
+
`+E:x.comment=E,A.comment=A.comment.substring(E.length+1)}}if(!o&&!S&&!A.found){let E=v?e(s,v,A,n):t(s,A.end,S,null,A,n);c.items.push(E),d=E.range[2],sr(v)&&n(E.range,"BLOCK_IN_FLOW",tr)}else{s.atKey=!0;let E=A.end,x=k?e(s,k,A,n):t(s,E,w,null,A,n);sr(k)&&n(x.range,"BLOCK_IN_FLOW",tr),s.atKey=!1;let M=Vl.resolveProps(S??[],{flow:a,indicator:"map-value-ind",next:v,offset:x.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(M.found){if(!o&&!A.found&&s.options.strict){if(S)for(let T of S){if(T===M.found)break;if(T.type==="newline"){n(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}A.start<M.found.offset-1024&&n(M.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else v&&("source"in v&&v.source?.[0]===":"?n(v,"MISSING_CHAR",`Missing space after : in ${a}`):n(M.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let O=v?e(s,v,M,n):M.found?t(s,M.end,S,null,M,n):null;O?sr(v)&&n(O.range,"BLOCK_IN_FLOW",tr):M.comment&&(x.comment?x.comment+=`
|
|
70
|
+
`+M.comment:x.comment=M.comment);let D=new rh.Pair(x,O);if(s.options.keepSourceTokens&&(D.srcToken=b),o){let T=c;ch.mapIncludes(s,T.items,x)&&n(E,"DUPLICATE_KEY","Map keys must be unique"),T.items.push(D)}else{let T=new Ul.YAMLMap(s.schema);T.flow=!0,T.items.push(D);let C=(O??x).range;T.range=[x.range[0],C[1],C[2]],c.items.push(T)}d=O?O.range[2]:M.end}}let p=o?"}":"]",[m,...y]=i.end,h=d;if(m?.source===p)h=m.offset+m.source.length;else{let g=a[0].toUpperCase()+a.substring(1),b=f?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;n(d,f?"MISSING_CHAR":"BAD_INDENT",b),m&&m.source.length!==1&&y.unshift(m)}if(y.length>0){let g=ah.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}Kl.resolveFlowCollection=uh});var Wl=P(Hl=>{"use strict";var dh=q(),fh=V(),ph=Ce(),mh=Pe(),hh=Fl(),gh=jl(),yh=Jl();function ir(e,t,s,i,n,r){let o=s.type==="block-map"?hh.resolveBlockMap(e,t,s,i,r):s.type==="block-seq"?gh.resolveBlockSeq(e,t,s,i,r):yh.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 bh(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===ph.YAMLMap.tagName&&a==="map"||o===mh.YAMLSeq.tagName&&a==="seq")return ir(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),ir(e,t,s,n,o)}let c=ir(e,t,s,n,o,l),f=l.resolve?.(c,p=>n(r,"TAG_RESOLVE_FAILED",p),t.options)??c,d=dh.isNode(f)?f:new fh.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}Hl.composeCollection=bh});var rr=P(Gl=>{"use strict";var nr=V();function wh(e,t,s){let i=t.offset,n=vh(t,e.options.strict,s);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let r=n.mode===">"?nr.Scalar.BLOCK_FOLDED:nr.Scalar.BLOCK_LITERAL,o=t.source?kh(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
|
+
`.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===nr.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=`
|
|
77
77
|
|
|
78
|
-
`),
|
|
79
|
-
`,
|
|
80
|
-
`?
|
|
78
|
+
`),d+=p+g.slice(l)+b,p=`
|
|
79
|
+
`,m=!0):b===""?p===`
|
|
80
|
+
`?d+=`
|
|
81
81
|
`:p=`
|
|
82
|
-
`:(
|
|
83
|
-
`+o[
|
|
84
|
-
`&&(
|
|
85
|
-
`);break;default:
|
|
86
|
-
`}let y=i+n.length+t.source.length;return{value:
|
|
82
|
+
`:(d+=p+b,p=" ",m=!1)}switch(n.chomp){case"-":break;case"+":for(let h=a;h<o.length;++h)d+=`
|
|
83
|
+
`+o[h][0].slice(l);d[d.length-1]!==`
|
|
84
|
+
`&&(d+=`
|
|
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 vh({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 kh(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}Gl.resolveBlockScalar=wh});var ar=P(zl=>{"use strict";var or=V(),Sh=lt();function $h(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=or.Scalar.PLAIN,l=xh(r,c);break;case"single-quoted-scalar":a=or.Scalar.QUOTE_SINGLE,l=Eh(r,c);break;case"double-quoted-scalar":a=or.Scalar.QUOTE_DOUBLE,l=Ah(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=Sh.resolveEnd(o,f,t,s);return{value:l,type:a,comment:d.comment,range:[i,f,d.offset]}}function xh(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}`),Yl(e)}function Eh(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),Yl(e.slice(1,-1)).replace(/''/g,"'")}function Yl(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 Ah(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}=Ch(e,i);s+=r,i=o}else if(n==="\\"){let r=e[++i],o=Ph[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+=Nh(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 Ch(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 Ph={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 Nh(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)}zl.resolveFlowScalar=$h});var Zl=P(Xl=>{"use strict";var Ve=q(),Ql=V(),Ih=rr(),Rh=ar();function Lh(e,t,s,i){let{value:n,type:r,comment:o,range:a}=t.type==="block-scalar"?Ih.resolveBlockScalar(e,t,i):Rh.resolveFlowScalar(t,e.options.strict,i),l=s?e.directives.tagName(s.source,d=>i(s,"TAG_RESOLVE_FAILED",d)):null,c;e.options.stringKeys&&e.atKey?c=e.schema[Ve.SCALAR]:l?c=Oh(e.schema,n,l,s,i):t.type==="scalar"?c=Th(e,n,t,i):c=e.schema[Ve.SCALAR];let f;try{let d=c.resolve(n,p=>i(s??t,"TAG_RESOLVE_FAILED",p),e.options);f=Ve.isScalar(d)?d:new Ql.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(s??t,"TAG_RESOLVE_FAILED",p),f=new Ql.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 Oh(e,t,s,i,n){if(s==="!")return e[Ve.SCALAR];let r=[];for(let a of e.tags)if(!a.collection&&a.tag===s)if(a.default&&a.test)r.push(a);else return a;for(let a of r)if(a.test?.test(t))return a;let o=e.knownTags[s];return o&&!o.collection?(e.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(n(i,"TAG_RESOLVE_FAILED",`Unresolved tag: ${s}`,s!=="tag:yaml.org,2002:str"),e[Ve.SCALAR])}function Th({atKey:e,directives:t,schema:s},i,n,r){let o=s.tags.find(a=>(a.default===!0||e&&a.default==="key")&&a.test?.test(i))||s[Ve.SCALAR];if(s.compat){let a=s.compat.find(l=>l.default&&l.test?.test(i))??s[Ve.SCALAR];if(o.tag!==a.tag){let l=t.tagString(o.tag),c=t.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;r(n,"TAG_RESOLVE_FAILED",f,!0)}}return o}Xl.composeScalar=Lh});var tc=P(ec=>{"use strict";function Mh(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}ec.emptyScalarPosition=Mh});var nc=P(cr=>{"use strict";var Dh=$t(),_h=q(),Fh=Wl(),sc=Zl(),qh=lt(),jh=tc(),Bh={composeNode:ic,composeEmptyNode:lr};function ic(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=Uh(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=sc.composeScalar(e,t,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=Fh.composeCollection(Bh,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=lr(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&&(!_h.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 lr(e,t,s,i,{spaceBefore:n,comment:r,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:jh.emptyScalarPosition(t,s,i),indent:-1,source:""},d=sc.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 Uh({options:e},{offset:t,source:s,end:i},n){let r=new Dh.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=qh.resolveEnd(i,o,e.strict,n);return r.range=[t,o,a.offset],a.comment&&(r.comment=a.comment),r}cr.composeEmptyNode=lr;cr.composeNode=ic});var ac=P(oc=>{"use strict";var Vh=jt(),rc=nc(),Kh=lt(),Jh=Kt();function Hh(e,t,{offset:s,start:i,value:n,end:r},o){let a=Object.assign({_directives:t},e),l=new Vh.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=Jh.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?rc.composeNode(c,n,f,o):rc.composeEmptyNode(c,f.end,i,null,f,o);let d=l.contents.range[2],p=Kh.resolveEnd(r,d,!1,o);return p.comment&&(l.comment=p.comment),l.range=[s,d,p.offset],l}oc.composeDoc=Hh});var dr=P(uc=>{"use strict";var Wh=rs("process"),Gh=Yi(),Yh=jt(),Jt=Vt(),lc=q(),zh=ac(),Qh=lt();function Ht(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:s}=e;return[t,t+(typeof s=="string"?s.length:1)]}function cc(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 ur=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(s,i,n,r)=>{let o=Ht(s);r?this.warnings.push(new Jt.YAMLWarning(o,i,n)):this.errors.push(new Jt.YAMLParseError(o,i,n))},this.directives=new Gh.Directives({version:t.version||"1.2"}),this.options=t}decorate(t,s){let{comment:i,afterEmptyLine:n}=cc(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(lc.isCollection(r)&&!r.flow&&r.items.length>0){let o=r.items[0];lc.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
|
|
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:cc(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(Wh.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(s,i,n)=>{let r=Ht(t);r[0]+=s,this.onError(r,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let s=zh.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!s.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(s,!1),this.doc&&(yield this.doc),this.doc=s,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let s=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new Jt.YAMLParseError(Ht(t),"UNEXPECTED_TOKEN",s);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new Jt.YAMLParseError(Ht(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let s=Qh.resolveEnd(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),s.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
|
|
108
|
+
${s.comment}`:s.comment}this.doc.range[2]=s.offset;break}default:this.errors.push(new Jt.YAMLParseError(Ht(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,s=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let i=Object.assign({_directives:this.directives},this.options),n=new Yh.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}}};uc.Composer=ur});var pc=P(ii=>{"use strict";var Xh=rr(),Zh=ar(),eg=Vt(),dc=Pt();function tg(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 eg.YAMLParseError([a,a+1],r,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Zh.resolveFlowScalar(e,t,i);case"block-scalar":return Xh.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function sg(e,t){let{implicitKey:s=!1,indent:i,inFlow:n=!1,offset:r=-1,type:o="PLAIN"}=t,a=dc.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
|
-
`),
|
|
111
|
-
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:
|
|
112
|
-
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:
|
|
110
|
+
`),f=a.substring(0,c),d=a.substring(c+1)+`
|
|
111
|
+
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return fc(p,l)||p.push({type:"newline",offset:-1,indent:i,source:`
|
|
112
|
+
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:r,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:i,source:a,end:l};default:return{type:"scalar",offset:r,indent:i,source:a,end:l}}}function ig(e,t,s={}){let{afterKey:i=!1,implicitKey:n=!1,inFlow:r=!1,type:o}=s,a="indent"in e?e.indent:null;if(i&&typeof a=="number"&&(a+=2),!o)switch(e.type){case"single-quoted-scalar":o="QUOTE_SINGLE";break;case"double-quoted-scalar":o="QUOTE_DOUBLE";break;case"block-scalar":{let c=e.props[0];if(c.type!=="block-scalar-header")throw new Error("Invalid block scalar header");o=c.source[0]===">"?"BLOCK_FOLDED":"BLOCK_LITERAL";break}default:o="PLAIN"}let l=dc.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">":ng(e,l);break;case'"':fr(e,l,"double-quoted-scalar");break;case"'":fr(e,l,"single-quoted-scalar");break;default:fr(e,l,"scalar")}}function ng(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}];fc(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 fc(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 fr(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})}}}ii.createScalarToken=sg;ii.resolveAsScalar=tg;ii.setScalarValue=ig});var hc=P(mc=>{"use strict";var rg=e=>"type"in e?ri(e):ni(e);function ri(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=ri(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=ni(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=ni(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=ni(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 ni({start:e,key:t,sep:s,value:i}){let n="";for(let r of e)n+=r.source;if(t&&(n+=ri(t)),s)for(let r of s)n+=r.source;return i&&(n+=ri(i)),n}mc.stringify=rg});var wc=P(bc=>{"use strict";var pr=Symbol("break visit"),og=Symbol("skip children"),gc=Symbol("remove item");function Ke(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),yc(Object.freeze([]),e,t)}Ke.BREAK=pr;Ke.SKIP=og;Ke.REMOVE=gc;Ke.itemAtPath=(e,t)=>{let s=e;for(let[i,n]of t){let r=s?.[i];if(r&&"items"in r)s=r.items[n];else return}return s};Ke.parentCollection=(e,t)=>{let s=Ke.itemAtPath(e,t.slice(0,-1)),i=t[t.length-1][0],n=s?.[i];if(n&&"items"in n)return n;throw new Error("Parent collection not found")};function yc(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=yc(Object.freeze(e.concat([[n,o]])),r.items[o],s);if(typeof a=="number")o=a-1;else{if(a===pr)return pr;a===gc&&(r.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}bc.visit=Ke});var oi=P(se=>{"use strict";var mr=pc(),ag=hc(),lg=wc(),hr="\uFEFF",gr="",yr="",br="",cg=e=>!!e&&"items"in e,ug=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function dg(e){switch(e){case hr:return"<BOM>";case gr:return"<DOC>";case yr:return"<FLOW_END>";case br:return"<SCALAR>";default:return JSON.stringify(e)}}function fg(e){switch(e){case hr:return"byte-order-mark";case gr:return"doc-mode";case yr:return"flow-error-end";case br:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
117
117
|
`:case`\r
|
|
118
|
-
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}se.createScalarToken=
|
|
119
|
-
`:case"\r":case" ":return!0;default:return!1}}var
|
|
120
|
-
\r `),
|
|
118
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(e[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}se.createScalarToken=mr.createScalarToken;se.resolveAsScalar=mr.resolveAsScalar;se.setScalarValue=mr.setScalarValue;se.stringify=ag.stringify;se.visit=lg.visit;se.BOM=hr;se.DOCUMENT=gr;se.FLOW_END=yr;se.SCALAR=br;se.isCollection=cg;se.isScalar=ug;se.prettyToken=dg;se.tokenType=fg});var kr=P(kc=>{"use strict";var Wt=oi();function fe(e){switch(e){case void 0:case" ":case`
|
|
119
|
+
`:case"\r":case" ":return!0;default:return!1}}var vc=new Set("0123456789ABCDEFabcdef"),pg=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),ai=new Set(",[]{}"),mg=new Set(` ,[]{}
|
|
120
|
+
\r `),wr=e=>!e||mg.has(e),vr=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]===
|
|
124
|
+
`||i>=this.indentNext||!s&&!this.atEnd?t+i:-1}if(s==="-"||s==="."){let i=this.buffer.substr(t,3);if((i==="---"||i==="...")&&fe(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
|
|
125
|
+
`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===Wt.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let s=t.length,i=t.indexOf("#");for(;i!==-1;){let r=t[i-1];if(r===" "||r===" "){s=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let r=t[s-1];if(r===" "||r===" ")s-=1;else break}let n=(yield*this.pushCount(s))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let s=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-s),yield*this.pushNewline(),"stream"}return yield Wt.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let s=this.peek(3);if((s==="---"||s==="...")&&fe(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,s==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!fe(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[t,s]=this.peek(2);if(!s&&!this.atEnd)return this.setNext("block-start");if((t==="-"||t==="?"||t===":")&&fe(s)){let i=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=i,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);let t=this.getLine();if(t===null)return this.setNext("doc");let s=yield*this.pushIndicators();switch(t[s]){case"#":yield*this.pushCount(t.length-s);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(wr),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return s+=yield*this.parseBlockScalarHeader(),s+=yield*this.pushSpaces(!0),yield*this.pushCount(t.length-s),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let t,s,i=-1;do t=yield*this.pushNewline(),t>0?(s=yield*this.pushSpaces(!1),this.indentValue=i=s):s=0,s+=yield*this.pushSpaces(!0);while(t+s>0);let n=this.getLine();if(n===null)return this.setNext("flow");if((i!==-1&&i<this.indentNext&&n[0]!=="#"||i===0&&(n.startsWith("---")||n.startsWith("..."))&&fe(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Wt.FLOW_END,yield*this.parseLineStart();let r=0;for(;n[r]===",";)r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),n[r]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-r),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(wr),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||fe(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let t=this.charAt(0),s=this.buffer.indexOf(t,this.pos+1);if(t==="'")for(;s!==-1&&this.buffer[s+1]==="'";)s=this.buffer.indexOf("'",s+2);else for(;s!==-1;){let r=0;for(;this.buffer[s-1-r]==="\\";)r+=1;if(r%2===0)break;s=this.buffer.indexOf('"',s+1)}let i=this.buffer.substring(0,s),n=i.indexOf(`
|
|
126
126
|
`,this.pos);if(n!==-1){for(;n!==-1;){let r=this.continueScalar(n+1);if(r===-1)break;n=i.indexOf(`
|
|
127
|
-
`,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=>fe(s)||s==="#")}*parseBlockScalar(){let t=this.pos-1,s=0,i;e:for(let r=this.pos;i=this.buffer[r];++r)switch(i){case" ":s+=1;break;case`
|
|
128
128
|
`:t=r,s=0;break;case"\r":{let o=this.buffer[r+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
129
129
|
`)break}default:break e}if(!i&&!this.atEnd)return this.setNext("block-scalar");if(s>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=s:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let r=this.continueScalar(t+1);if(r===-1)break;t=this.buffer.indexOf(`
|
|
130
130
|
`,r)}while(t!==-1);if(t===-1){if(!this.atEnd)return this.setNext("block-scalar");t=this.buffer.length}}let n=t+1;for(i=this.buffer[n];i===" ";)i=this.buffer[++n];if(i===" "){for(;i===" "||i===" "||i==="\r"||i===`
|
|
131
131
|
`;)i=this.buffer[++n];t=n-1}else if(!this.blockScalarKeep)do{let r=t-1,o=this.buffer[r];o==="\r"&&(o=this.buffer[--r]);let a=r;for(;o===" ";)o=this.buffer[--r];if(o===`
|
|
132
|
-
`&&r>=this.pos&&r+1+s>a)t=r;else break}while(!0);return yield
|
|
132
|
+
`&&r>=this.pos&&r+1+s>a)t=r;else break}while(!0);return yield Wt.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,s=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let r=this.buffer[i+1];if(fe(r)||t&&ai.has(r))break;s=i}else if(fe(n)){let r=this.buffer[i+1];if(n==="\r"&&(r===`
|
|
133
133
|
`?(i+=1,n=`
|
|
134
|
-
`,r=this.buffer[i+1]):s=i),r==="#"||t&&
|
|
135
|
-
`){let o=this.continueScalar(i+1);if(o===-1)break;i=Math.max(i,o-2)}}else{if(t&&
|
|
134
|
+
`,r=this.buffer[i+1]):s=i),r==="#"||t&&ai.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&&ai.has(n))break;s=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Wt.SCALAR,yield*this.pushToIndex(s+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,s){let i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(s&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(wr))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(fe(s)||t&&ai.has(s))return t?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let t=this.pos+2,s=this.buffer[t];for(;!fe(s)&&s!==">";)s=this.buffer[++t];return yield*this.pushToIndex(s===">"?t+1:t,!1)}else{let t=this.pos+1,s=this.buffer[t];for(;s;)if(pg.has(s))s=this.buffer[++t];else if(s==="%"&&vc.has(this.buffer[t+1])&&vc.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)}};kc.Lexer=vr});var $r=P(Sc=>{"use strict";var Sr=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}}}};Sc.LineCounter=Sr});var Er=P(Cc=>{"use strict";var hg=rs("process"),$c=oi(),gg=kr();function Ne(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function xc(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 Ac(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 li(e){switch(e.type){case"document":return e.start;case"block-map":{let t=e.items[e.items.length-1];return t.sep??t.start}case"block-seq":return e.items[e.items.length-1].start;default:return[]}}function ct(e){if(e.length===0)return[];let t=e.length;e:for(;--t>=0;)switch(e[t].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;e[++t]?.type==="space";);return e.splice(t,e.length)}function Ec(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!Ne(t.start,"explicit-key-ind")&&!Ne(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,Ac(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 xr=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 gg.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,hg.env.LOG_TOKENS&&console.log("|",$c.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let s=$c.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"&&Ec(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&&xc(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":{xc(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=li(this.peek(2)),i=ct(s),n;t.end?(n=t.end,n.push(this.sourceToken),delete t.end):n=[this.sourceToken];let r={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:i,key:t,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(t)}*blockScalar(t){switch(this.type){case"space":case"comment":case"newline":t.props.push(this.sourceToken);return;case"scalar":if(t.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let s=this.source.indexOf(`
|
|
138
138
|
`)+1;for(;s!==0;)this.onNewLine(this.offset+s),s=this.source.indexOf(`
|
|
139
|
-
`,s)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let s=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,s.value){let i="end"in s.value?s.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)t.items.push({start:[this.sourceToken]});else if(s.sep)s.sep.push(this.sourceToken);else{if(this.atIndentedComment(s.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,s.start),n.push(this.sourceToken),t.items.pop();return}}s.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let i=!this.onKeyLine&&this.indent===t.indent,n=i&&(s.sep||s.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&s.sep&&!s.value){let o=[];for(let a=0;a<s.sep.length;++a){let l=s.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=s.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||s.value?(r.push(this.sourceToken),t.items.push({start:r}),this.onKeyLine=!0):s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"explicit-key-ind":!s.sep&&!s.explicitKey?(s.start.push(this.sourceToken),s.explicitKey=!0):n||s.value?(r.push(this.sourceToken),t.items.push({start:r,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(s.explicitKey)if(s.sep)if(s.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ne(s.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(
|
|
139
|
+
`,s)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(t){let s=t.items[t.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,s.value){let i="end"in s.value?s.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)t.items.push({start:[this.sourceToken]});else if(s.sep)s.sep.push(this.sourceToken);else{if(this.atIndentedComment(s.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,s.start),n.push(this.sourceToken),t.items.pop();return}}s.start.push(this.sourceToken)}return}if(this.indent>=t.indent){let i=!this.onKeyLine&&this.indent===t.indent,n=i&&(s.sep||s.explicitKey)&&this.type!=="seq-item-ind",r=[];if(n&&s.sep&&!s.value){let o=[];for(let a=0;a<s.sep.length;++a){let l=s.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>t.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=s.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":n||s.value?(r.push(this.sourceToken),t.items.push({start:r}),this.onKeyLine=!0):s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"explicit-key-ind":!s.sep&&!s.explicitKey?(s.start.push(this.sourceToken),s.explicitKey=!0):n||s.value?(r.push(this.sourceToken),t.items.push({start:r,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(s.explicitKey)if(s.sep)if(s.value)t.items.push({start:[],key:null,sep:[this.sourceToken]});else if(Ne(s.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Ac(s.key)&&!Ne(s.sep,"newline")){let o=ct(s.start),a=s.key,l=s.sep;l.push(this.sourceToken),delete s.key,delete s.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else r.length>0?s.sep=s.sep.concat(r,this.sourceToken):s.sep.push(this.sourceToken);else if(Ne(s.start,"newline"))Object.assign(s,{key:null,sep:[this.sourceToken]});else{let o=ct(s.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else s.sep?s.value||n?t.items.push({start:r,key:null,sep:[this.sourceToken]}):Ne(s.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):s.sep.push(this.sourceToken):Object.assign(s,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let o=this.flowScalar(this.type);n||s.value?(t.items.push({start:r,key:o,sep:[]}),this.onKeyLine=!0):s.sep?this.stack.push(o):(Object.assign(s,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{let o=this.startBlockValue(t);if(o){if(o.type==="block-seq"){if(!s.explicitKey&&s.sep&&!Ne(s.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else i&&t.items.push({start:r});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(t){let s=t.items[t.items.length-1];switch(this.type){case"newline":if(s.value){let i="end"in s.value?s.value.end:void 0;(Array.isArray(i)?i[i.length-1]:void 0)?.type==="comment"?i?.push(this.sourceToken):t.items.push({start:[this.sourceToken]})}else s.start.push(this.sourceToken);return;case"space":case"comment":if(s.value)t.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(s.start,t.indent)){let n=t.items[t.items.length-2]?.value?.end;if(Array.isArray(n)){Array.prototype.push.apply(n,s.start),n.push(this.sourceToken),t.items.pop();return}}s.start.push(this.sourceToken)}return;case"anchor":case"tag":if(s.value||this.indent<=t.indent)break;s.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==t.indent)break;s.value||Ne(s.start,"seq-item-ind")?t.items.push({start:[this.sourceToken]}):s.start.push(this.sourceToken);return}if(this.indent>t.indent){let i=this.startBlockValue(t);if(i){this.stack.push(i);return}}yield*this.pop(),yield*this.step()}*flowCollection(t){let s=t.items[t.items.length-1];if(this.type==="flow-error-end"){let i;do yield*this.pop(),i=this.peek(1);while(i?.type==="flow-collection")}else if(t.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!s||s.sep?t.items.push({start:[this.sourceToken]}):s.start.push(this.sourceToken);return;case"map-value-ind":!s||s.value?t.items.push({start:[],key:null,sep:[this.sourceToken]}):s.sep?s.sep.push(this.sourceToken):Object.assign(s,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!s||s.value?t.items.push({start:[this.sourceToken]}):s.sep?s.sep.push(this.sourceToken):s.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{let n=this.flowScalar(this.type);!s||s.value?t.items.push({start:[],key:n,sep:[]}):s.sep?this.stack.push(n):Object.assign(s,{key:n,sep:[]});return}case"flow-map-end":case"flow-seq-end":t.end.push(this.sourceToken);return}let i=this.startBlockValue(t);i?this.stack.push(i):(yield*this.pop(),yield*this.step())}else{let i=this.peek(2);if(i.type==="block-map"&&(this.type==="map-value-ind"&&i.indent===t.indent||this.type==="newline"&&!i.items[i.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&i.type!=="flow-collection"){let n=li(i),r=ct(n);Ec(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:r,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let s=this.source.indexOf(`
|
|
140
140
|
`)+1;for(;s!==0;)this.onNewLine(this.offset+s),s=this.source.indexOf(`
|
|
141
|
-
`,s)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let s=
|
|
142
|
-
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var
|
|
143
|
-
`;n.write(
|
|
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=li(t),i=ct(s);return i.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;let s=li(t),i=ct(s);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,s){return this.type!=="comment"||this.indent<=s?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Cc.Parser=xr});var Lc=P(Yt=>{"use strict";var Pc=dr(),yg=jt(),Gt=Vt(),bg=cn(),wg=q(),vg=$r(),Nc=Er();function Ic(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new vg.LineCounter||null,prettyErrors:t}}function kg(e,t={}){let{lineCounter:s,prettyErrors:i}=Ic(t),n=new Nc.Parser(s?.addNewLine),r=new Pc.Composer(t),o=Array.from(r.compose(n.parse(e)));if(i&&s)for(let a of o)a.errors.forEach(Gt.prettifyError(e,s)),a.warnings.forEach(Gt.prettifyError(e,s));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function Rc(e,t={}){let{lineCounter:s,prettyErrors:i}=Ic(t),n=new Nc.Parser(s?.addNewLine),r=new Pc.Composer(t),o=null;for(let a of r.compose(n.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Gt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&s&&(o.errors.forEach(Gt.prettifyError(e,s)),o.warnings.forEach(Gt.prettifyError(e,s))),o}function Sg(e,t,s){let i;typeof t=="function"?i=t:s===void 0&&t&&typeof t=="object"&&(s=t);let n=Rc(e,s);if(!n)return null;if(n.warnings.forEach(r=>bg.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 $g(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 wg.isDocument(e)&&!i?e.toString(s):new yg.Document(e,i,s).toString(s)}Yt.parse=Sg;Yt.parseAllDocuments=kg;Yt.parseDocument=Rc;Yt.stringify=$g});var Cr=P(j=>{"use strict";var xg=dr(),Eg=jt(),Ag=Jn(),Ar=Vt(),Cg=$t(),Ie=q(),Pg=Ee(),Ng=V(),Ig=Ce(),Rg=Pe(),Lg=oi(),Og=kr(),Tg=$r(),Mg=Er(),ci=Lc(),Oc=wt();j.Composer=xg.Composer;j.Document=Eg.Document;j.Schema=Ag.Schema;j.YAMLError=Ar.YAMLError;j.YAMLParseError=Ar.YAMLParseError;j.YAMLWarning=Ar.YAMLWarning;j.Alias=Cg.Alias;j.isAlias=Ie.isAlias;j.isCollection=Ie.isCollection;j.isDocument=Ie.isDocument;j.isMap=Ie.isMap;j.isNode=Ie.isNode;j.isPair=Ie.isPair;j.isScalar=Ie.isScalar;j.isSeq=Ie.isSeq;j.Pair=Pg.Pair;j.Scalar=Ng.Scalar;j.YAMLMap=Ig.YAMLMap;j.YAMLSeq=Rg.YAMLSeq;j.CST=Lg;j.Lexer=Og.Lexer;j.LineCounter=Tg.LineCounter;j.Parser=Mg.Parser;j.parse=ci.parse;j.parseAllDocuments=ci.parseAllDocuments;j.parseDocument=ci.parseDocument;j.stringify=ci.stringify;j.visit=Oc.visit;j.visitAsync=Oc.visitAsync});import{execFile as Jd}from"child_process";import{promisify as Hd}from"util";import{mkdtemp as To,readdir as Wd,readFile as Vi,rm as us,cp as Gd,access as Bi,stat as Fo,lstat as Yd,symlink as zd,mkdir as Qd}from"fs/promises";import{join as ge,resolve as Ui,relative as Xd,basename as Zd}from"path";import{homedir as Mo}from"os";import{tmpdir as Do}from"os";import{readdir as Fd,readFile as qd,stat as jd}from"fs/promises";import{join as Bd}from"path";var Ud=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"]),Vd=512*1024;async function ls(e){let t=[];async function s(i,n){let r;try{r=await Fd(i)}catch{return}for(let o of r){if(o===".git"||o==="node_modules")continue;let a=Bd(i,o),l=n?`${n}/${o}`:o;try{let c=await jd(a);if(c.isDirectory())await s(a,l);else if(c.isFile()){let f=o.includes(".")?`.${o.split(".").pop().toLowerCase()}`:"";if(Ud.has(f)||c.size>Vd)continue;try{let d=await qd(a,"utf-8");t.push({relPath:l,content:d,lineCount:d.split(`
|
|
142
|
+
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var qi=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 Kd(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=Fi(m.hint,S);i.push(`${g}${w} ${u.dim(v)}`)}else{let v=Fi(m.label,s-b);i.push(`${g}${u.bold(v)}`)}}else{let S=Fi(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 Fi(e,t){return t<=0?"":e.length<=t?e:t<=3?e.slice(0,t):e.slice(0,t-3)+"..."}async function Qe(e){let{items:t}=e,s=e.pageSize??Math.min(t.length+1,15),i=new qi(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=Kd(i,t,o);a>0&&n.write(`\x1B[${a}F`);let f=Math.max(c.length,a),d="";for(let p=0;p<f;p++)d+=`\x1B[2K${p<c.length?c[p]:""}
|
|
143
|
+
`;n.write(d),a=f}return l(),new Promise(c=>{let f="",d=null;function p(){r.removeListener("data",h),typeof r.setRawMode=="function"&&r.setRawMode(!1),r.pause(),n.write("\x1B[?25h"),d&&clearTimeout(d)}function m(g){p(),c(g)}function y(g){if(i.searchActive){if(g==="\x1B"){i.searchActive=!1,i.filter="",i.applyFilter(t),l();return}if(g==="\r"||g===`
|
|
144
144
|
`){i.searchActive=!1,l();return}if(g==="\x7F"||g==="\b"){i.filter.length>0?(i.filter=i.filter.slice(0,-1),i.applyFilter(t)):i.searchActive=!1,l();return}if(g===""){p(),process.kill(process.pid,"SIGINT");return}if(g==="\x1B[A"){i.moveUp(),l();return}if(g==="\x1B[B"){i.moveDown(),l();return}if(g===" "){i.toggleCurrent(),l();return}if(g.length===1&&g>=" "&&g<="~"){i.filter+=g,i.applyFilter(t),l();return}return}switch(g){case"\x1B[A":case"k":i.moveUp(),l();break;case"\x1B[B":case"j":i.moveDown(),l();break;case" ":i.toggleCurrent(),l();break;case"a":i.toggleAll(),l();break;case"/":i.searchActive=!0,l();break;case"\r":case`
|
|
145
|
-
`:
|
|
145
|
+
`:m(i.getSelectedIndices());break;case"\x1B":i.filter!==""?(i.filter="",i.applyFilter(t),l()):m([]);break;case"\x7F":case"\b":i.filter.length>0&&(i.filter=i.filter.slice(0,-1),i.applyFilter(t),l());break;case"":p(),process.kill(process.pid,"SIGINT");break}}function h(g){if(f.length>0){if(f+=g,d&&clearTimeout(d),f.length>=3&&f[1]==="["){let w=f.slice(0,3),k=f.slice(3);f="",y(w),k&&h(k);return}let b=f;f="",y("\x1B");for(let w=1;w<b.length;w++)y(b[w]);return}for(let b=0;b<g.length;b++){let w=g[b];if(w==="\x1B"){let k=g.slice(b);if(k.length>=3&&k[1]==="[")y(k.slice(0,3)),b+=2;else if(k.length>=2){f=k,d=setTimeout(()=>{let S=f;f="",y("\x1B");for(let v=1;v<S.length;v++)y(S[v])},50);return}else{f="\x1B",d=setTimeout(()=>{f="",y("\x1B")},50);return}}else y(w)}}r.on("data",h)})}var Oe=Hd(Jd),ef=/^[a-zA-Z0-9_-]+$/,tf=/^[a-zA-Z0-9._-]+$/,sf=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,_o=128,nf=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function Ki(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 qo(e){if(!e.includes("/")&&!e.includes("\\"))return!1;try{return(await Fo(Ui(e))).isDirectory()}catch{return!1}}function rf(e){let t;e==="~"?t=Mo():e.startsWith("~/")||e.startsWith("~\\")?t=Ui(Mo(),e.slice(2)):t=Ui(e);let s=Zd(t);return I(`install: parsed local source -> path=${t}`),{owner:"local",repo:s,ref:null,subpath:null,cloneUrl:"",sshCloneUrl:"",isLocal:!0,localPath:t}}function Te(e){if(Ki(e))return rf(e);let t=nf.exec(e);if(t){let[,d,p,m]=t,y=p.endsWith(".git")?p.slice(0,-4):p;e=`github:${d}/${y}${m?`#${m}`:""}`}if(!e.startsWith("github:"))throw new Error(`Invalid source format. Got: "${e}"
|
|
146
146
|
Supported formats:
|
|
147
147
|
github:owner/repo[#ref]
|
|
148
148
|
github:owner/repo#ref:path
|
|
149
149
|
https://github.com/owner/repo
|
|
150
150
|
https://github.com/owner/repo/tree/branch/path/to/skill
|
|
151
151
|
/path/to/local/skill
|
|
152
|
-
./relative/path/to/skill`);let s=e.slice(7),i=s.indexOf("#"),n,r=null,o=null;if(i!==-1){n=s.slice(0,i);let
|
|
153
|
-
`)){let r=n.match(/\trefs\/(?:heads|tags)\/(.+)$/);r&&s.add(r[1])}let i=e.ref.split("/");for(let n=1;n<i.length;n++){let r=i.slice(0,n).join("/");if(s.has(r)){let o=i.slice(n).join("/");return I(`install: resolved ref="${r}" subpath="${o}"`),{...e,ref:r,subpath:o||null}}}}catch(t){I(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function Me(e){if(!e)throw new Error("Invalid skill name: name cannot be empty");if(e.includes("\0"))throw new Error("Invalid skill name: contains unsafe characters (null byte)");if(e.includes(".."))throw new Error("Invalid skill name: contains unsafe characters (..)");if(e.includes("/")||e.includes("\\"))throw new Error("Invalid skill name: contains unsafe characters (path separator)");if(e.startsWith("."))throw new Error("Invalid skill name: must not start with a dot");if(e.length>
|
|
154
|
-
HTTPS: ${
|
|
155
|
-
SSH: ${
|
|
156
|
-
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of
|
|
157
|
-
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;I(`install: target ${e} \u2014 no conflict`)}}var
|
|
158
|
-
`),s=!1,i=!1;for(let n of t){if(n.trim()==="---")if(s){i=!0;continue}else{s=!0;continue}if(i&&n.trim().length>0)return!0}return!1}function
|
|
152
|
+
./relative/path/to/skill`);let s=e.slice(7),i=s.indexOf("#"),n,r=null,o=null;if(i!==-1){n=s.slice(0,i);let d=s.slice(i+1);if(!d)throw new Error("Invalid source: ref cannot be empty after #");let p=d.indexOf(":");if(p!==-1){if(r=d.slice(0,p),!r)throw new Error("Invalid source: ref cannot be empty before :");o=d.slice(p+1)||null}else r=d}else{let d=s.indexOf(":");d!==-1?(n=s.slice(0,d),o=s.slice(d+1)||null):n=s}let a=n.indexOf("/");if(a===-1)throw new Error(`Invalid source: format must be github:owner/repo. Got: "${e}"`);let l=n.slice(0,a),c=n.slice(a+1);if(!l)throw new Error("Invalid source: owner cannot be empty");if(!c)throw new Error("Invalid source: repo cannot be empty");if(!ef.test(l))throw new Error(`Invalid source: owner contains invalid characters: "${l}". Allowed: [a-zA-Z0-9_-]`);if(!tf.test(c))throw new Error(`Invalid source: repo contains invalid characters: "${c}". Allowed: [a-zA-Z0-9._-]`);let f={owner:l,repo:c,ref:r,subpath:o,cloneUrl:`https://github.com/${l}/${c}.git`,sshCloneUrl:`git@github.com:${l}/${c}.git`};return I(`install: parsed source -> owner=${l} repo=${c} ref=${r} subpath=${o}`),f}async function ds(e){if(e.subpath!==null||!e.ref||!e.ref.includes("/"))return e;try{let{stdout:t}=await Oe("git",["ls-remote","--heads","--tags",e.cloneUrl],{timeout:15e3}),s=new Set;for(let n of t.split(`
|
|
153
|
+
`)){let r=n.match(/\trefs\/(?:heads|tags)\/(.+)$/);r&&s.add(r[1])}let i=e.ref.split("/");for(let n=1;n<i.length;n++){let r=i.slice(0,n).join("/");if(s.has(r)){let o=i.slice(n).join("/");return I(`install: resolved ref="${r}" subpath="${o}"`),{...e,ref:r,subpath:o||null}}}}catch(t){I(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function Me(e){if(!e)throw new Error("Invalid skill name: name cannot be empty");if(e.includes("\0"))throw new Error("Invalid skill name: contains unsafe characters (null byte)");if(e.includes(".."))throw new Error("Invalid skill name: contains unsafe characters (..)");if(e.includes("/")||e.includes("\\"))throw new Error("Invalid skill name: contains unsafe characters (path separator)");if(e.startsWith("."))throw new Error("Invalid skill name: must not start with a dot");if(e.length>_o)throw new Error(`Invalid skill name: exceeds maximum length of ${_o} characters`);if(!sf.test(e))throw new Error(`Invalid skill name: "${e}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return e}function of(e){let t=e.split(/[/\\]/).filter(Boolean),s=t.length>0?t[t.length-1]:e;return Me(s)}function jo(e){let t=new Map;for(let s of e){let i=of(s),n=t.get(i);n?n.push(s):t.set(i,[s])}return[...t.entries()].filter(([,s])=>s.length>1).map(([s,i])=>({name:s,paths:i}))}async function De(){try{await Oe("git",["--version"]),I("install: git available")}catch{throw new Error("git is required for installing skills. Install git from https://git-scm.com")}}function af(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 cs(e){return e.killed?"Clone timed out after 60 seconds":`Clone failed: ${e.stderr||e.message}`}async function ji(e,t,s){if(t!==null&&/^[0-9a-f]{40}$/i.test(t))return await Oe("git",["clone","--no-checkout",e,s],{timeout:6e4}),await Oe("git",["checkout",t],{cwd:s,timeout:3e4}),s;let n=["clone","--depth","1"];return t&&n.push("--branch",t),n.push(e,s),await Oe("git",n,{timeout:6e4}),s}async function _e(e,t="auto"){I(`install: cloning ${e.owner}/${e.repo}${e.ref?` (ref: ${e.ref})`:""} (transport: ${t})`);let s=await To(ge(Do(),"asm-install-"));if(t==="ssh"||t==="https"){let i=t==="ssh"?e.sshCloneUrl:e.cloneUrl;try{return await ji(i,e.ref,s)}catch(n){throw await oe(s),new Error(cs(n))}}try{return await ji(e.cloneUrl,e.ref,s)}catch(i){if(!af(i))throw await oe(s),new Error(cs(i));I("install: HTTPS clone failed with auth error, retrying with SSH..."),await oe(s);let n=await To(ge(Do(),"asm-install-"));try{return await ji(e.sshCloneUrl,e.ref,n)}catch(r){throw await oe(n),new Error(`Clone failed with both transports:
|
|
154
|
+
HTTPS: ${cs(i)}
|
|
155
|
+
SSH: ${cs(r)}`)}}}async function Fe(e){let t=ge(e,"SKILL.md"),s;try{s=await Vi(t,"utf-8")}catch{throw new Error("Not a valid skill: SKILL.md not found in repository root")}let i=re(s),n=e.split(/[/\\]/).pop()||"unknown",r=i.name||n,o=ue(i);return I(`install: validated skill "${r}" v${o}`),{name:r,version:o,description:(i.description||"").replace(/\s*\n\s*/g," ").trim(),effort:i.effort||i["metadata.effort"]||void 0}}async function fs(e,t=5){let s=[];async function i(n,r,o){let a;try{a=await Wd(n)}catch{return}for(let l of a){if(l===".git"||l==="node_modules")continue;let c=ge(n,l);try{if(!(await Fo(c)).isDirectory())continue}catch{continue}let f=r?`${r}/${l}`:l,d=o+1,p=ge(c,"SKILL.md");try{let m=await Vi(p,"utf-8"),y=re(m);s.push({relPath:f,name:y.name||l,version:ue(y),description:(y.description||"").replace(/\s*\n\s*/g," ").trim(),effort:y.effort||y["metadata.effort"]||void 0,license:(y.license||"").trim(),creator:(y["metadata.creator"]||"").trim(),compatibility:(y.compatibility||"").trim(),allowedTools:co(y),tokenCount:os(m)})}catch{d<t&&await i(c,f,d)}}}return await i(e,"",0),s.sort((n,r)=>n.name.localeCompare(r.name)),s}var lf=[{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 Bo(e){let t=[],s=await ls(e);for(let{relPath:i,content:n}of s){let r=n.split(`
|
|
156
|
+
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of lf)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 ps(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 Bi(e.targetDir),await us(e.targetDir,{recursive:!0,force:!0})}catch{}let s=e.sourceDir;try{await Gd(s,e.targetDir,{recursive:!0})}catch(a){throw new Error(`Failed to install: ${a.message}`)}let i=ge(e.targetDir,".git");try{await us(i,{recursive:!0,force:!0})}catch{}I(`install: copied files to ${e.targetDir}`);let n=ge(e.targetDir,"SKILL.md");try{await Bi(n)}catch{throw new Error("Installation verification failed: SKILL.md not found at target")}let r=await Vi(n,"utf-8"),o=re(r);return{success:!0,path:e.targetDir,name:o.name||e.skillName,version:ue(o),provider:e.providerLabel,source:t}}async function Uo(e,t){let s=await ps(e);for(let i of t){if(i.name===e.providerName)continue;let n=e.scope==="project"?i.project:i.global,r=ce(n),o=ge(r,e.skillName);await Qd(r,{recursive:!0});try{if((await Yd(o)).isSymbolicLink())await us(o);else{I(`install: skipping ${o} \u2014 existing non-symlink directory`);continue}}catch{}let a=Xd(r,e.targetDir);await zd(a,o,"dir"),I(`install: symlinked ${o} -> ${a}`)}return s.provider=`All (${t.map(i=>i.label).join(", ")})`,s}async function oe(e){try{await us(e,{recursive:!0,force:!0})}catch{}}async function Vo(){try{await Oe("npx",["--version"]),I("install: npx available")}catch{throw new Error("npx is required for Vercel method installation. Install Node.js from https://nodejs.org")}}async function Ko(e,t){let s=["--yes","skills","add",e];t&&s.push("--skill",t),I(`install: running npx ${s.join(" ")}`);try{let i=await Oe("npx",s,{timeout:12e4});return{stdout:i.stdout,stderr:i.stderr}}catch(i){let n=i.stderr||i.message||"";throw new Error(`npx skills add failed: ${n}`)}}function Jo(e){if(e.isLocal)return e.localPath;let t=`https://github.com/${e.owner}/${e.repo}`;return e.ref?`${t}/tree/${e.ref}${e.subpath?`/${e.subpath}`:""}`:t}async function Xe(e,t,s){let i=e.providers.filter(m=>m.enabled);if(t==="all"){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");return{provider:i.find(y=>y.name==="agents")||i[0],allProviders:i}}if(t){let m=e.providers.find(y=>y.name===t);if(!m){let y=e.providers.map(h=>h.name).join(", ");throw new Error(`Unknown provider: "${t}". Valid providers: ${y}, all`)}if(!m.enabled)throw new Error(`Provider "${t}" is disabled. Enable it in your config or choose another provider.`);return{provider:m,allProviders:null}}if(i.length===1)return{provider:i[0],allProviders:null};if(!s){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");let m=i.map(y=>y.name).join(", ");throw new Error(`--tool (or --provider) is required in non-interactive mode. Available: ${m}, all`)}let n=e.preferences.selectedTools,o=n&&n.length>0?new Set(n):null,a=e.providers.map(m=>({label:`${m.label} (${m.name})`,hint:m.global,checked:o?o.has(m.name):m.name==="agents"})),l=await Qe({items:a});if(l.length===0)throw new Error("No tools selected. Aborting.");let c=l.map(m=>e.providers[m]),f=c.map(m=>m.name),{saveSelectedTools:d}=await import("./config-7PXPKO4K.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 Ji(e,t,s,i,n,r,o="global"){let a=o==="project"?n.project:n.global,l=ce(a),c=ge(l,i);return{source:e,tempDir:t,sourceDir:s,targetDir:c,skillName:i,force:r,providerName:n.name,providerLabel:n.label,scope:o}}async function Ho(e,t){try{if(await Bi(e),I(`install: target ${e} \u2014 conflict (exists)${t?", force overwrite":""}`),!t)throw new Error(`Skill already exists at: ${e}
|
|
157
|
+
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;I(`install: target ${e} \u2014 no conflict`)}}var Mc=io(Cr(),1);import{readFile as Dg}from"fs/promises";import{join as _g}from"path";var Tc=500;function Fg(e){let t=e.split(`
|
|
158
|
+
`),s=!1,i=!1;for(let n of t){if(n.trim()==="---")if(s){i=!0;continue}else{s=!0;continue}if(i&&n.trim().length>0)return!0}return!1}function qg(e){let t=e.split(`
|
|
159
159
|
`),s=-1;for(let i=0;i<t.length;i++)if(t[i].trim()==="---")if(s===-1)s=i+1;else return t.slice(s,i).join(`
|
|
160
|
-
`);return null}function
|
|
160
|
+
`);return null}function jg(e){let t=qg(e);if(t===null)return null;try{return(0,Mc.parse)(t),null}catch(s){return s.message||"invalid YAML"}}async function Dc(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=_g(e.path,"SKILL.md"),n=await Dg(i,"utf-8");Fg(n)||t.push({category:"empty-body",message:"SKILL.md contains only frontmatter with no body content"});let r=jg(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>Tc&&t.push({category:"high-file-count",message:`Skill has ${s} files (threshold: ${Tc})`}),t}import{join as Gg}from"path";import{homedir as Yg}from"os";import{readFile as Bg,writeFile as Ug,mkdir as Vg}from"fs/promises";import{dirname as Kg}from"path";async function Jg(e){try{let t=await Bg(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 Hg(e,t,s){let i={fetched_at:new Date().toISOString(),ttl_seconds:s,data:t};try{await Vg(Kg(e),{recursive:!0}),await Ug(e,JSON.stringify(i,null,2),"utf-8"),I(`http: wrote cache -> ${e}`)}catch(n){I(`http: failed to write cache: ${n}`)}}function Wg(e){let t=new Date(e.fetched_at).getTime();return(Date.now()-t)/1e3<e.ttl_seconds}async function _c(e,t,s={}){let i=s.ttl??3600,n=s.noCache??!1,r=await Jg(t);if(r&&!n&&Wg(r))return I(`http: cache hit (fresh) -> ${t}`),r.data;try{I(`http: fetching -> ${e}`);let o=await fetch(e);if(!o.ok)throw new Error(`HTTP ${o.status}: ${o.statusText}`);let a=await o.json();return await Hg(t,a,i),a}catch(o){return I(`http: fetch failed: ${o}`),r?(I(`http: using stale cache as fallback -> ${t}`),r.data):null}}var zg=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,Qg=/^[a-zA-Z0-9_-]+$/,jc=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9._-]+$/,Xg=/^[0-9a-f]{40}$/,Zg=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/,ey=/^[a-z0-9-]+$/,ty=/^sha256:[0-9a-f]{64}$/,Fc=["pass","warning","dangerous"];function ui(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:zg,maxLength:128},{field:"author",pattern:Qg,maxLength:39},{field:"description",maxLength:256},{field:"repository",pattern:jc},{field:"commit",pattern:Xg},{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"||!Fc.includes(r))&&t.push({field:"security_verdict",message:`"security_verdict" must be one of: ${Fc.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"||!Zg.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`}),ey.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"||!ty.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 sy(e,t){let s=e.length,i=t.length;if(s===0)return i;if(i===0)return s;let n=new Array(i+1),r=new Array(i+1);for(let o=0;o<=i;o++)n[o]=o;for(let o=1;o<=s;o++){r[0]=o;for(let a=1;a<=i;a++){let l=e[o-1]===t[a-1]?0:1;r[a]=Math.min(n[a]+1,r[a-1]+1,n[a-1]+l)}[n,r]=[r,n]}return n[i]}function iy(e,t,s=2){let i=[];for(let n of t){if(e===n)continue;let r=sy(e,n);r<=s&&i.push({existingName:n,distance:r})}return i.sort((n,r)=>n.distance-r.distance)}var Pr=process.env.ASM_REGISTRY_URL??"https://raw.githubusercontent.com/luongnv89/asm-registry/main/index.json",ny=process.env.ASM_REGISTRY_CACHE??Gg(Yg(),".config","agent-skill-manager","registry-cache.json"),ry=3600;function zt(e){if(e.startsWith("github:")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("~/")||e==="~"||e==="."||e==="..")return!1;let t=(e.match(/\//g)||[]).length;if(t>1)return!1;if(t===1){let[s,i]=e.split("/");return/^[a-zA-Z0-9_-]+$/.test(s)&&/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(i)}return/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(e)}function Nr(e){return zt(e)?e.includes("/"):!1}async function Ir(e){let t=await _c(Pr,ny,{ttl:ry,noCache:e?.noCache});if(!t)return null;if(typeof t!="object"||!Array.isArray(t.manifests)||typeof t.generated_at!="string")return I("registry: fetched index has invalid structure \u2014 discarding"),null;let s=[];for(let i of t.manifests){let n=ui(i);if(n.length>0){I(`registry: dropping invalid manifest entry (${i?.name??"unknown"}): ${n.map(r=>r.message).join(", ")}`);continue}if(!jc.test(i.repository)){I(`registry: dropping manifest with unexpected repository URL: ${i.repository}`);continue}s.push(i)}return{generated_at:t.generated_at,manifests:s}}function oy(e,t){return t.manifests.filter(s=>s.name.toLowerCase()===e.toLowerCase())}function ay(e,t,s){return s.manifests.find(i=>i.author.toLowerCase()===e.toLowerCase()&&i.name.toLowerCase()===t.toLowerCase())??null}function qc(e,t,s=5){return iy(e,t.manifests.map(n=>n.name),3).slice(0,s).map(n=>n.existingName)}async function Bc(e,t){let s=await Ir(t);if(!s)return I("registry: failed to fetch index \u2014 skipping registry resolution"),{resolved:null,multipleMatches:[],suggestions:[]};if(Nr(e)){let[r,o]=e.split("/"),a=ay(r,o,s);if(a)return{resolved:{manifest:a,source:"registry"},multipleMatches:[],suggestions:[]};let l=qc(o,s);return{resolved:null,multipleMatches:[],suggestions:l}}let i=oy(e,s);if(i.length===1)return{resolved:{manifest:i[0],source:"registry"},multipleMatches:[],suggestions:[]};if(i.length>1)return{resolved:null,multipleMatches:i,suggestions:[]};let n=qc(e,s);return{resolved:null,multipleMatches:[],suggestions:n}}function Uc(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 ly,access as Kc,mkdir as cy,cp as Vc,rm as uy,symlink as dy}from"fs/promises";import{join as Jc,basename as fy}from"path";function py(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 Hc(e){let t;try{t=await ly(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=py(s);if(!i.valid)throw new Error(`Invalid manifest:
|
|
161
161
|
${i.errors.join(`
|
|
162
|
-
`)}`);return s}async function
|
|
162
|
+
`)}`);return s}async function my(e){try{return await Kc(e),!0}catch{return!1}}function hy(e,t){return e.providers.find(s=>s.name===t&&s.enabled)}function gy(e,t,s,i){let n=hy(e,t);if(!n)return null;let r=s==="global"?n.global:n.project,o=ce(r),a=fy(i);return!a||a==="."||a===".."?null:Jc(o,a)}function yy(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 Wc(e,t,s){let i=s?.config??await B(),n=s?.installedSkills??await ee(i,"both"),r=[];for(let c of e.skills){if(t.scopeFilter!=="both"&&c.scope!==t.scopeFilter){I(`import: skipping "${c.name}" \u2014 scope "${c.scope}" filtered out`);continue}let f=gy(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 my(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=yy(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 cy(Jc(f,".."),{recursive:!0}),d&&await uy(f,{recursive:!0,force:!0}),c.isSymlink&&c.symlinkTarget)try{await Kc(c.symlinkTarget),await dy(c.symlinkTarget,f),I(`import: symlinked "${c.name}" -> ${c.symlinkTarget} at ${f}`)}catch{await Vc(p.realPath,f,{recursive:!0}),I(`import: symlink target unreachable, copied "${c.name}" from ${p.realPath} to ${f}`)}else await Vc(p.realPath,f,{recursive:!0}),I(`import: copied "${c.name}" from ${p.realPath} to ${f}`);r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"installed",path:f})}catch(m){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:`Copy failed: ${m.message}`})}}let o=r.filter(c=>c.status==="installed").length,a=r.filter(c=>c.status==="skipped").length,l=r.filter(c=>c.status==="failed").length;return{total:r.length,installed:o,skipped:a,failed:l,results:r}}import{mkdir as by,writeFile as wy,access as vy}from"fs/promises";import{join as ky}from"path";function Sy(e){return`---
|
|
163
163
|
name: ${e}
|
|
164
164
|
description: ""
|
|
165
165
|
license: ""
|
|
@@ -180,62 +180,62 @@ as instructions for when and how to use this skill.
|
|
|
180
180
|
## Instructions
|
|
181
181
|
|
|
182
182
|
- Step-by-step instructions for the agent
|
|
183
|
-
`}async function
|
|
184
|
-
`)}import{access as dy,lstat as py,mkdir as my,readdir as hy,readFile as Wc,rm as gy,stat as Gc,symlink as yy}from"fs/promises";import{join as li}from"path";async function Nr(e){let t;try{t=await Gc(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=li(e,"SKILL.md"),i;try{i=await Wc(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=re(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ue(n)}}async function Yc(e,t,s,i){let n=li(t,s),r=!1;try{await dy(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await gy(n,{recursive:!0,force:!0})}await my(t,{recursive:!0}),await yy(e,n,"dir")}async function Ir(e){let t;try{t=await Gc(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=await hy(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=li(e,n);try{if(!(await py(r)).isDirectory())continue}catch{continue}let o=li(r,"SKILL.md");try{let a=await Wc(o,"utf-8"),l=re(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ue(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as by,writeFile as wy,readdir as zc,access as Qc,mkdir as vy,rm as ky}from"fs/promises";import{join as He,resolve as Xc,dirname as Sy}from"path";import{homedir as $y}from"os";import{fileURLToPath as xy}from"url";var Ey=xy(import.meta.url),Cy=Sy(Ey),Je=He($y(),".config","agent-skill-manager","bundles"),ci=Xc(Cy,"..","data","bundles");function Ay(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 Zc(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function eu(e,t){let s=t??await Re(),i=s.skills[e.name]||s.skills[e.dirName],n;return e.isSymlink&&e.symlinkTarget?n=e.symlinkTarget:i?.source?n=i.source:n=e.path,{name:e.name,installUrl:n,description:e.description||void 0,version:e.version||void 0}}async function Py(){await vy(Je,{recursive:!0})}function Lr(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(t=t.replace(/^\.+|\.+$/g,""),!t||t==="."||t==="..")throw new Error("Invalid bundle name: results in an empty filename after sanitization.");return t}async function Rr(e){await Py();let t=`${Lr(e.name)}.json`,s=He(Je,t);return await wy(s,JSON.stringify(e,null,2)+`
|
|
185
|
-
`,"utf-8"),I(`bundle: saved to ${s}`),s}async function
|
|
183
|
+
`}async function Gc(e,t){await by(t,{recursive:!0});let s=ky(t,"SKILL.md"),i=Sy(e);await wy(s,i,"utf-8")}async function Yc(e){try{return await vy(e),!0}catch{return!1}}import{readdir as $y,stat as xy}from"fs/promises";import{join as Ey}from"path";async function Ay(e){let t=0;try{let i=(await $y(e,{recursive:!0})).map(async r=>{try{let o=await xy(Ey(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 Qc(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 Ay(l.path);return n[l.path]=c,c}),a=(await Promise.all(r)).reduce((l,c)=>l+c,0);return{totalSkills:e.length,byProvider:s,byScope:i,totalDiskBytes:a,perSkillDiskBytes:n,duplicateGroups:t.duplicateGroups.length,duplicateInstances:t.totalDuplicateInstances}}function Cy(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:e<1024*1024*1024?`${(e/(1024*1024)).toFixed(1)} MB`:`${(e/(1024*1024*1024)).toFixed(1)} GB`}function Rr(e,t,s=20){let i=Math.round(e/t*s),n=s-i;return u.green("#".repeat(i))+u.dim("-".repeat(n))}var zc={claude:"Claude Code",codex:"Codex",openclaw:"OpenClaw",agents:"Agents"};function Xc(e){let t=[];t.push(""),t.push(u.blueBold(" Skill Statistics")),t.push(u.dim(" "+"-".repeat(20))),t.push(""),t.push(` ${u.bold("Total:")} ${u.cyan(String(e.totalSkills))} skills`),t.push(` ${u.bold("Disk:")} ${u.cyan(Cy(e.totalDiskBytes))}`),t.push(""),t.push(u.bold(" By Tool"));let s=Object.entries(e.byProvider).sort((l,c)=>c[1]-l[1]),i=Math.max(...s.map(([,l])=>l)),n=Math.max(...s.map(([l])=>(zc[l]||l).length));for(let[l,c]of s){let f=zc[l]||l,d=yo(l,f.padEnd(n)),p=String(c).padStart(4);t.push(` ${d} ${p} ${Rr(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} ${Rr(e.byScope.global,r)}`),t.push(` ${"project".padEnd(n)} ${a} ${Rr(e.byScope.project,r)}`),t.push(""),t.push(u.bold(" Duplicates")),e.duplicateGroups>0?(t.push(` ${u.yellow(`${e.duplicateGroups} group(s), ${e.duplicateInstances} total instance(s)`)}`),t.push(u.dim(` Run ${u.bold("asm audit")} to review`))):t.push(` ${u.green("None")}`),t.push(""),t.join(`
|
|
184
|
+
`)}import{access as Py,lstat as Ny,mkdir as Iy,readdir as Ry,readFile as Zc,rm as Ly,stat as eu,symlink as Oy}from"fs/promises";import{join as di}from"path";async function Lr(e){let t;try{t=await eu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=di(e,"SKILL.md"),i;try{i=await Zc(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=re(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ue(n)}}async function tu(e,t,s,i){let n=di(t,s),r=!1;try{await Py(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await Ly(n,{recursive:!0,force:!0})}await Iy(t,{recursive:!0}),await Oy(e,n,"dir")}async function Or(e){let t;try{t=await eu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=await Ry(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=di(e,n);try{if(!(await Ny(r)).isDirectory())continue}catch{continue}let o=di(r,"SKILL.md");try{let a=await Zc(o,"utf-8"),l=re(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ue(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as sb,writeFile as ib,readdir as hu,access as gu,mkdir as nb,rm as rb}from"fs/promises";import{join as He,resolve as yu,dirname as ob}from"path";import{homedir as ab}from"os";import{fileURLToPath as lb}from"url";import{readdir as Ty,readFile as My}from"fs/promises";import{join as Dy}from"path";function Tr(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var _y=10,Fy=5,qy=3,jy=1;function By(e,t){let s=Tr(e),i=Tr(t.name),n=Tr(t.description),r=0;for(let o of s)i.has(o)&&(r+=_y),n.has(o)&&(r+=qy),t.name.toLowerCase().includes(o)&&(r+=Fy),t.description.toLowerCase().includes(o)&&(r+=jy);return r}async function su(e){let t=new Map,s;try{s=await Ty(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=Dy(e,i);try{let r=await My(n,"utf-8"),o=JSON.parse(r);for(let a of o.skills)"license"in a||(a.license=""),"creator"in a||(a.creator=""),"compatibility"in a||(a.compatibility=""),"allowedTools"in a||(a.allowedTools=[]),"verified"in a||(a.verified=!1);t.set(`${o.owner}/${o.repo}`,o)}catch{}}return t}async function ut(){let e=await su(ao()),t=await su(yt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var Uy=["license","creator","version"];function iu(e){return Uy.includes(e)}function nu(e,t){return e[t]||""}function Vy(e,t){if(t.has){for(let s of t.has)if(iu(s)&&!nu(e,s))return!1}if(t.missing){for(let s of t.missing)if(iu(s)&&nu(e,s))return!1}return!0}function ru(e){let t=[];return e.license||t.push("license"),e.creator||t.push("creator"),(!e.version||e.version==="0.0.0")&&t.push("version"),t}async function fi(e,t=20,s){let i=await ut(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!Vy(a,s))continue;let l=r?1:By(e,a);l>0&&n.push({skill:a,repo:{owner:o.owner,repo:o.repo},score:l})}return n.sort((o,a)=>a.score-o.score),n.slice(0,t)}async function ou(){return(await ut()).reduce((t,s)=>t+s.skillCount,0)}import{readdir as Ky,readFile as au,stat as cu}from"fs/promises";import{join as Mr}from"path";var Jy=[{id:"marketing",title:"Marketing Skills",description:"Marketing, growth, SEO, ASO, affiliate, sales, and conversion skills.",tags:["marketing","growth","seo"],keywords:["marketing","growth","seo","aso","affiliate","sales","copy","copywriting","conversion","cro","brand","social","campaign"]},{id:"writing",title:"Writing Skills",description:"Writing, editing, documentation, publishing, and content-production skills.",tags:["writing","content","docs"],keywords:["write","writing","writer","blog","article","content","docs","documentation","draft","copy","readme","paper","thesis","proposal"]},{id:"research",title:"Research Skills",description:"Research, academic, literature-review, citation, paper, and analysis skills.",tags:["research","academic","analysis"],keywords:["research","academic","scholar","paper","literature","citation","review","analysis","summar","evaluate","verify"]},{id:"engineering",title:"Engineering Skills",description:"Coding, debugging, testing, architecture, review, and software engineering skills.",tags:["engineering","coding","testing"],keywords:["code","coding","debug","test","testing","coverage","review","refactor","architecture","typescript","python","javascript","build","cli","api"]},{id:"frontend-design",title:"Frontend & Design Skills",description:"Frontend, UI, UX, visual design, component, theme, and landing-page skills.",tags:["frontend","design","ui"],keywords:["frontend","ui","ux","design","component","react","css","html","figma","theme","landing","layout","visual","brand","logo"]},{id:"devops",title:"DevOps Skills",description:"Deployment, CI/CD, infrastructure, cloud, Docker, Kubernetes, and automation skills.",tags:["devops","infra","automation"],keywords:["devops","deploy","deployment","ci","cd","pipeline","docker","kubernetes","terraform","ansible","cloud","infra","infrastructure","workflow","release"]},{id:"data-ai",title:"Data & AI Skills",description:"Data, analytics, AI, model, prompt, agent, and automation skills.",tags:["data","ai","agents"],keywords:["data","analytics","analysis","ai","agent","llm","model","prompt","openai","claude","gemini","automation","dataset","sql"]},{id:"product-business",title:"Product & Business Skills",description:"Product, strategy, PRD, planning, finance, resume, and business workflow skills.",tags:["product","business","planning"],keywords:["product","prd","strategy","planning","business","finance","resume","career","startup","market","competitor","customer","sales"]}],lu=2,Hy=80,Wy=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],Gy=["bundles","data/bundles",".asm/bundles"];function Qt(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function uu(e,t,s){let i=Qt(e),n=Qt(t),r=Qt(s),o=`${i}-${n}`;return r.startsWith(o)?r:`${o}-${r}`}function Yy(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function zy(e,t){let s=Yy(e);return t.keywords.some(i=>s.includes(i))}function du(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function Qy(e){let t=new Set,s=[];for(let i of e){let n=`${i.installUrl||""}\0${i.name}`;t.has(n)||(t.add(n),s.push(i))}return s}function fu(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function Dr(e){let t=[];if(!e.skills||e.skills.length<lu)return t;for(let s of Jy){let i=e.skills.filter(r=>zy(r,s)).slice(0,Hy);if(i.length<lu)continue;let n=uu(e.owner,e.repo,s.id);t.push({version:1,name:n,description:`${s.description} Derived from ${e.owner}/${e.repo}.`,author:`ASM (${e.owner}/${e.repo})`,createdAt:e.updatedAt,tags:["repo-derived","inferred",...s.tags,Qt(e.owner),Qt(e.repo)],skills:fu(i.map(du)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function Xy(e,t,s){if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e,n=Array.isArray(i.skills)?i.skills:[];if(n.length===0)return null;let r=new Map(t.skills.map(l=>[l.name,l])),o=Qy(n.map(l=>{if(typeof l=="string"){let p=r.get(l);return p?du(p):null}if(!l||typeof l!="object"||Array.isArray(l))return null;let c=l,f=typeof c.name=="string"?c.name:"";if(!f)return null;let d=r.get(f);return d?{name:d.name,installUrl:d.installUrl,description:typeof c.description=="string"&&c.description?c.description:d.description||void 0,version:typeof c.version=="string"&&c.version?c.version:d.version||void 0}:null}).filter(l=>l!==null));if(o.length===0)return null;let a=typeof i.name=="string"&&i.name?i.name:s.replace(/\.json$/,"");return{version:1,name:uu(t.owner,t.repo,a),description:typeof i.description=="string"&&i.description?i.description:`Bundle from ${t.owner}/${t.repo}.`,author:typeof i.author=="string"&&i.author?i.author:`ASM (${t.owner}/${t.repo})`,createdAt:typeof i.createdAt=="string"&&i.createdAt?i.createdAt:t.updatedAt,tags:Array.isArray(i.tags)?["repo-derived","explicit",...i.tags.filter(l=>typeof l=="string")]:["repo-derived","explicit"],skills:fu(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function Zy(e){try{return(await cu(e)).isFile()}catch{return!1}}async function eb(e){try{return(await cu(e)).isDirectory()}catch{return!1}}async function tb(e){let t=[];for(let s of Wy){let i=Mr(e,s);if(await Zy(i))try{t.push({relPath:s,data:JSON.parse(await au(i,"utf-8"))})}catch{}}for(let s of Gy){let i=Mr(e,s);if(!await eb(i))continue;let n=[];try{n=await Ky(i)}catch{continue}for(let r of n.filter(o=>o.endsWith(".json")).sort()){let o=`${s}/${r}`;try{t.push({relPath:o,data:JSON.parse(await au(Mr(i,r),"utf-8"))})}catch{}}}return t}async function pu(e,t){let s=[],i=await tb(e);for(let n of i){let r=n.data,o=Array.isArray(r?.bundles)?r.bundles:[r];for(let a of o){let l=Xy(a,t,n.relPath);l&&s.push(l)}}return pi(s)}function pi(e){let t=new Map;for(let s of e){let i=t.get(s.name);(!i||s.explicit&&!i.explicit)&&t.set(s.name,s)}return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}function mu(e){let t=e.bundles||[],s=Dr(e);return pi([...t,...s])}var cb=lb(import.meta.url),ub=ob(cb),Je=He(ab(),".config","agent-skill-manager","bundles"),mi=yu(ub,"..","data","bundles");function db(e){let t=[];if(typeof e!="object"||e===null||Array.isArray(e))return{valid:!1,errors:["Bundle must be a JSON object."]};let s=e;if(s.version!==1&&t.push(`Unsupported bundle version: ${JSON.stringify(s.version)}. Expected 1.`),(typeof s.name!="string"||!s.name)&&t.push("Missing or empty 'name' field."),(typeof s.description!="string"||!s.description)&&t.push("Missing or empty 'description' field."),(typeof s.author!="string"||!s.author)&&t.push("Missing or empty 'author' field."),typeof s.createdAt!="string"&&t.push("Missing or invalid 'createdAt' field."),!Array.isArray(s.skills))return t.push("Missing or invalid 'skills' array."),{valid:!1,errors:t};s.skills.length===0&&t.push("Bundle must contain at least one skill.");for(let i=0;i<s.skills.length;i++){let n=s.skills[i];if(typeof n!="object"||n===null){t.push(`skills[${i}]: must be an object.`);continue}let r=n;(typeof r.name!="string"||!r.name)&&t.push(`skills[${i}]: missing or empty 'name'.`),(typeof r.installUrl!="string"||!r.installUrl)&&t.push(`skills[${i}]: missing or empty 'installUrl'.`)}return s.tags!==void 0&&(Array.isArray(s.tags)?s.tags.some(i=>typeof i!="string")&&t.push("'tags' must contain only strings."):t.push("'tags' must be an array of strings if provided.")),{valid:t.length===0,errors:t}}function bu(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function wu(e,t){let s=t??await Le(),i=s.skills[e.name]||s.skills[e.dirName],n;return e.isSymlink&&e.symlinkTarget?n=e.symlinkTarget:i?.source?n=i.source:n=e.path,{name:e.name,installUrl:n,description:e.description||void 0,version:e.version||void 0}}async function fb(){await nb(Je,{recursive:!0})}function Zt(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(t=t.replace(/^\.+|\.+$/g,""),!t||t==="."||t==="..")throw new Error("Invalid bundle name: results in an empty filename after sanitization.");return t}async function _r(e){await fb();let t=`${Zt(e.name)}.json`,s=He(Je,t);return await ib(s,JSON.stringify(e,null,2)+`
|
|
185
|
+
`,"utf-8"),I(`bundle: saved to ${s}`),s}async function Xt(e){let t;try{t=await sb(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=db(s);if(!i.valid)throw new Error(`Invalid bundle:
|
|
186
186
|
${i.errors.join(`
|
|
187
|
-
`)}`);return s}async function
|
|
188
|
-
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let
|
|
189
|
-
`)}function
|
|
187
|
+
`)}`);return s}async function es(e){if(e.includes("/")||e.includes("\\")||e.endsWith(".json")){let i=yu(e);return Xt(i)}let t=`${Zt(e)}.json`,s=He(Je,t);try{return await Xt(s)}catch(i){if(i?.message?.includes("Bundle file not found")){let n=He(mi,t);try{return await Xt(n)}catch(r){if(r?.message?.includes("Bundle file not found")){let o=await pb(e);if(o)return o;throw new Error(`Bundle file not found: ${s}`)}throw r}}throw i}}async function vu(){let e=[];try{await gu(mi);let s;try{s=await hu(mi)}catch{s=[]}for(let i of s){if(!i.endsWith(".json"))continue;let n=He(mi,i);try{let r=await Xt(n);e.push(r)}catch{I(`bundle: skipping invalid predefined file ${n}`)}}}catch{}e.push(...await ku());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 ku(){try{return(await ut()).flatMap(t=>mu(t))}catch(e){return I(`bundle: failed to load repo-derived bundles: ${e}`),[]}}async function pb(e){let t=Zt(e),s=await ku();return s.find(i=>i.name===e)||s.find(i=>Zt(i.name)===t)||null}async function Su(){let e=[];try{await gu(Je)}catch{return e}let t;try{t=await hu(Je)}catch{return e}for(let s of t){if(!s.endsWith(".json"))continue;let i=He(Je,s);try{let n=await Xt(i);e.push(n)}catch{I(`bundle: skipping invalid file ${i}`)}}return e.sort((s,i)=>s.name.localeCompare(i.name)),e}async function $u(e){let t=`${Zt(e)}.json`,s=He(Je,t);try{return await rb(s),I(`bundle: removed ${s}`),!0}catch(i){if(i?.code==="ENOENT")return!1;throw i}}import{readFile as $b,realpath as xb}from"fs/promises";import{join as Eb,resolve as Ab,relative as Cb}from"path";var Au=[{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 mb(e,t){let s={owner:e,repo:t,profileUrl:`https://github.com/${e}`,reposUrl:`https://github.com/${e}?tab=repositories`,isOrganization:null,publicRepos:null,accountAge:null,fetchError:null};try{let i=await fetch(`https://api.github.com/users/${e}`,{headers:{Accept:"application/vnd.github.v3+json","User-Agent":"agent-skill-manager"},signal:AbortSignal.timeout(1e4)});if(!i.ok)return s.fetchError=`GitHub API returned ${i.status}`,s;let n=await i.json();if(s.isOrganization=n.type==="Organization",s.publicRepos=typeof n.public_repos=="number"?n.public_repos:null,typeof n.created_at=="string"){let r=new Date(n.created_at),o=new Date,a=Math.floor((o.getTime()-r.getTime())/(365.25*24*60*60*1e3)),l=Math.floor((o.getTime()-r.getTime())%(365.25*24*60*60*1e3)/(30.44*24*60*60*1e3));s.accountAge=a>0?`${a}y ${l}m`:`${l}m`}I(`security-audit: source analysis for ${e} -> repos=${s.publicRepos}, org=${s.isOrganization}, age=${s.accountAge}`)}catch(i){s.fetchError=i.message||"Failed to fetch GitHub profile",I(`security-audit: source analysis failed -> ${s.fetchError}`)}return s}function hb(e){let t=new Map;for(let{relPath:n,content:r}of e){let o=r.split(`
|
|
188
|
+
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let f of Au)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 gb(e){let t=new Map;for(let r of e)for(let o of r.matches)for(let a of Au)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 yb(e,t,s){let i=0,n=0;for(let l of e)for(let c of l.matches)c.severity==="critical"&&i++,c.severity==="warning"&&n++;let r=t.some(l=>l.type==="shell"),o=t.some(l=>l.type==="code-execution"),a=t.some(l=>l.type==="network");return r&&a?{verdict:"dangerous",reason:"Skill has both shell execution and network access -- potential data exfiltration risk."}:o&&a?{verdict:"dangerous",reason:"Skill has dynamic code execution and network access -- potential remote code execution risk."}:i>=10?{verdict:"dangerous",reason:`${i} critical findings detected. High concentration of risky patterns.`}:r||o?{verdict:"warning",reason:r?"Skill executes shell commands. Review commands carefully before installing.":"Skill uses dynamic code execution. Review usage carefully."}:i>0?{verdict:"warning",reason:`${i} critical finding${i>1?"s":""} detected. Manual review recommended.`}:n>0?{verdict:"caution",reason:`${n} warning${n>1?"s":""} found. Generally acceptable but worth reviewing.`}:s&&s.publicRepos!==null&&s.publicRepos<3?{verdict:"caution",reason:"No code issues found, but the author has very few public repositories."}:{verdict:"safe",reason:"No suspicious patterns detected."}}async function Re(e,t,s,i){I(`security-audit: scanning ${e}`);let n=await ls(e),r=n.reduce((d,p)=>d+p.lineCount,0),o=null;s&&i&&(o=await mb(s,i));let a=hb(n),l=gb(a),{verdict:c,reason:f}=yb(a,l,o);return{scannedAt:new Date().toISOString(),skillName:t,skillPath:e,source:o,codeScans:a,permissions:l,totalFiles:n.length,totalLines:r,verdict:c,verdictReason:f}}var R=u,We=56,bb={"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"},xu={critical:0,warning:1,info:2};function wb(e){switch(e){case"safe":return R.bgGreen(" SAFE ");case"caution":return R.bgCyan(" CAUTION ");case"warning":return R.bgYellow(" WARNING ");case"dangerous":return R.bgRed(" DANGEROUS ")}}function vb(e){switch(e){case"safe":return R.green;case"caution":return R.cyan;case"warning":return R.yellow;case"dangerous":return R.red}}function dt(e){switch(e){case"critical":return R.red("!!");case"warning":return R.yellow(" !");case"info":return R.dim(" i")}}function Fr(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function hi(e){return e.toLocaleString("en-US")}function Cu(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Eu(e){return Cu(e).length}function kb(e){let t=new Map;for(let s of e){let i=`${s.file}:${s.line}`,n=t.get(i);(!n||xu[s.severity]<xu[n.severity])&&t.set(i,s)}return Array.from(t.values())}function Sb(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 gi(e){let t=[],s=wb(e.verdict),i=Cu(s),n=` ${R.bold(e.skillName)}`,r=` ${e.skillName}`,o=We-4,a=Math.max(1,o-r.length-i.length);if(t.push(""),t.push(R.dim(" +-- ")+R.bold("Security Audit")+R.dim(" "+"-".repeat(We-19)+"+")),t.push(R.dim(" |")+n+" ".repeat(a)+s+R.dim("|")),t.push(R.dim(" |")+R.dim(` ${hi(e.totalFiles)} files | ${hi(e.totalLines)} lines`)+" ".repeat(Math.max(1,o-` ${hi(e.totalFiles)} files | ${hi(e.totalLines)} lines`.length))+R.dim("|")),t.push(R.dim(" +"+"-".repeat(We-2)+"+")),e.source){let d=e.source;if(d.fetchError)t.push(` ${R.yellow("!")} Could not fetch profile: ${d.fetchError}`);else{let p=[];if(p.push(`${d.owner} ${d.isOrganization?R.cyan("(org)"):R.dim("(user)")}`),d.publicRepos!==null){let m=d.publicRepos,y=m<3?R.yellow(`${m} repos`):m<10?R.cyan(`${m} repos`):R.green(`${m} repos`);p.push(y)}d.accountAge&&p.push(d.accountAge),t.push(` ${R.dim("Author:")} ${p.join(R.dim(" | "))}`)}}if(t.push(""),e.codeScans.length===0)t.push(` ${R.green("*")} ${R.green("No suspicious patterns detected.")}`);else{let d=vb(e.verdict),p=e.verdict==="dangerous"||e.verdict==="warning"?dt("critical"):e.verdict==="caution"?dt("warning"):dt("info");t.push(` ${p} ${d(e.verdictReason)}`);let m=0,y=0,h=0;for(let k of e.codeScans)for(let S of k.matches)S.severity==="critical"?m++:S.severity==="warning"?y++:h++;let g=[];m>0&&g.push(R.red(`${m} critical`)),y>0&&g.push(R.yellow(`${y} warning`)),h>0&&g.push(R.dim(`${h} info`));let b=e.permissions.map(k=>k.type),w=b.length>0?R.dim(`Perms: ${b.join(", ")}`):"";t.push(` ${g.join(R.dim(" | "))} ${w}`)}if(t.push(""),e.codeScans.length>0){t.push(` ${R.bold("Findings")}`),t.push(R.dim(" "+"=".repeat(We-2)));for(let d of e.codeScans){let p=kb(d.matches),m=p.filter(O=>O.severity==="critical").length,y=p.filter(O=>O.severity==="warning").length,h=p.filter(O=>O.severity==="info").length,g=m>0?dt("critical"):y>0?dt("warning"):dt("info"),b=[];m>0&&b.push(R.red(`${m} critical`)),y>0&&b.push(R.yellow(`${y} warning`)),h>0&&b.push(R.dim(`${h} info`));let w=bb[d.category],k=w?R.dim(`PERM: ${w}`):"",S=` ${g} ${R.bold(d.category)} (${b.join(", ")})`;if(k){let O=Eu(S),D=Eu(k),T=Math.max(2,We-O-D);t.push(S+" ".repeat(T)+k)}else t.push(S);let v=Sb(p),A=Math.min(24,Math.max(...v.map(O=>O.file.length))),E=0,x=3;for(let O of v){if(E>=x)break;let D=Fr(O.file,24),T=R.dim(D.padEnd(A));if(O.entries.length===1){let C=O.entries[0],N=Fr(C.match,50);t.push(` ${T} :${C.line} ${R.dim("--")} ${C.severity==="critical"?N:R.dim(N)}`),E++}else if(O.entries.length<=3){let C=O.entries.map(F=>`:${F.line}`).join(", "),N=Fr(O.entries[0].match,40);t.push(` ${T} ${C} ${R.dim("--")} ${R.dim(N)}`),E++}else{let N=O.entries.slice(0,3).map(L=>`:${L.line}`).join(", "),F=O.entries.length-3;t.push(` ${T} ${N} ${R.dim(`(+${F} more)`)}`),E++}}let M=v.length-Math.min(v.length,x);if(M>0){let O=p.length-v.slice(0,x).reduce((D,T)=>D+T.entries.length,0);O>0&&t.push(` ${R.dim(`... ${O} more in ${M} file${M>1?"s":""}`)}`)}t.push("")}}t.push(R.dim(" "+"=".repeat(We-2)));let l=new Date(e.scannedAt),c=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")} ${String(l.getHours()).padStart(2,"0")}:${String(l.getMinutes()).padStart(2,"0")}`,f=e.source&&!e.source.fetchError?`github.com/${e.source.owner}`:"";if(f){let d=Math.max(2,We-2-c.length-f.length);t.push(R.dim(` ${c}${" ".repeat(d)}${f}`))}else t.push(R.dim(` ${c}`));return t.push(""),t.join(`
|
|
189
|
+
`)}function qr(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 yi(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 Pb(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/</g,"<").replace(/>/g,">").replace(/\|/g,"\\|")}function jr(e){return Pb(yi(e))}var Ge="luongnv89/asm-registry";async function Nb(e){let t=Eb(e,"SKILL.md"),s;try{s=await $b(t,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}. Run "asm init" to create one.`)}let i=re(s);if(!i.name)throw new Error("SKILL.md is missing required field: name");if(!i.description)throw new Error("SKILL.md is missing required field: description");let n=ue(i),r=i.tags?i.tags.split(/[\s,]+/).map(o=>o.trim().toLowerCase()).filter(Boolean):[];return{name:i.name,description:i.description.replace(/\s*\n\s*/g," ").trim(),version:n,license:i.license||"MIT",creator:i.creator||"",tags:r}}async function Ib(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 Rb(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 Lb(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 Ob(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 Tb(){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 Mb(e){switch(e){case"safe":case"caution":return"pass";case"warning":return"warning";case"dangerous":return"dangerous"}}function Pu(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 Db(e){let t=Pu({metadata:e.metadata,author:e.metadata.creator||"unknown",commit:e.commit,repository:e.repository,securityVerdict:e.registryVerdict}),s=ui(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 Nu(e){let t=Ab(e.path);I(`publish: starting for ${t}`),await Ib(t);let s=await Nb(t);I(`publish: parsed metadata for "${s.name}"`);let n=await(e._auditFn??Re)(t,s.name),r=Mb(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 Rb(t),a=await Ob(t),l=await Lb(t),c=await xb(t),f=Cb(l,c),d=f&&f!=="."?f:void 0,m=await(e._checkGhCliFn??Tb)();if(!m.available||!m.authenticated){let U=m.available?"gh CLI not authenticated":"gh CLI not found";return Db({metadata:s,commit:o,repository:a,registryVerdict:r,securityReport:n,fallbackReason:U})}if(!m.login)throw new Error("Could not determine GitHub username. The gh CLI is authenticated but the API call failed. Check your network connection and try again.");let y=m.login,h=Pu({metadata:s,author:y,commit:o,repository:a,skillPath:d,securityVerdict:r}),g=ui(h);if(g.length>0)return{success:!1,manifest:h,prUrl:null,error:`Manifest validation failed: ${g.map(U=>`${U.field}: ${U.message}`).join("; ")}`,securityVerdict:r,securityReport:n};if(e.dryRun)return{success:!0,manifest:h,prUrl:null,error:null,securityVerdict:r,securityReport:n};if(!e.yes){if(!process.stdin.isTTY)return{success:!1,manifest:h,prUrl:null,error:"Cannot prompt for confirmation in non-interactive mode. Use --yes to skip.",securityVerdict:r,securityReport:n};let U=yi(s.name),ze=yi(y);process.stderr.write(`
|
|
190
190
|
About to publish "${U}" by ${ze} to ${Ge}.
|
|
191
191
|
Security verdict: ${r}
|
|
192
192
|
|
|
193
|
-
Proceed? [y/N] `);let ne=await new Promise(le=>{let ve="",
|
|
194
|
-
`)&&(process.stdin.removeListener("data",
|
|
195
|
-
`,S=Buffer.from(k,"utf-8").toString("base64"),{stdout:v,exitCode:
|
|
196
|
-
`),{stdout:
|
|
193
|
+
Proceed? [y/N] `);let ne=await new Promise(le=>{let ve="",ns=ht=>{ve+=ht.toString(),ve.includes(`
|
|
194
|
+
`)&&(process.stdin.removeListener("data",ns),process.stdin.pause(),le(ve.trim()))};process.stdin.resume(),process.stdin.on("data",ns)});if(ne.toLowerCase()!=="y"&&ne.toLowerCase()!=="yes")return{success:!1,manifest:h,prUrl:null,error:"Publish aborted by user.",securityVerdict:r,securityReport:n}}I(`publish: forking ${Ge}`),await H(["gh","repo","fork",Ge,"--clone=false"]);let b=`publish/${y}/${s.name}`,w=`manifests/${y}/${s.name}.json`,k=JSON.stringify(h,null,2)+`
|
|
195
|
+
`,S=Buffer.from(k,"utf-8").toString("base64"),{stdout:v,exitCode:A}=await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/main`,"--jq",".object.sha"]);if(A!==0)return{success:!1,manifest:h,prUrl:null,error:`Failed to read fork's main branch. Ensure the fork exists at ${y}/asm-registry.`,securityVerdict:r,securityReport:n};let E=v.trim(),{exitCode:x}=await H(["gh","api",`repos/${y}/asm-registry/git/refs`,"-X","POST","-f",`ref=refs/heads/${b}`,"-f",`sha=${E}`]);x!==0&&await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/${b}`,"-X","PATCH","-f",`sha=${E}`,"-f","force=true"]);let{stderr:M,exitCode:O}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}`,"-X","PUT","-f",`message=Publish ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`]);if(O!==0){let{stdout:U,exitCode:ze}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}?ref=${b}`,"-q",".sha"]),ne=U.trim();if(ze===0&&ne){let{exitCode:le}=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=${ne}`]);if(le!==0)return{success:!1,manifest:h,prUrl:null,error:"Failed to write manifest to registry fork.",securityVerdict:r,securityReport:n}}else return{success:!1,manifest:h,prUrl:null,error:`Failed to write manifest to registry fork. ${M}`,securityVerdict:r,securityReport:n}}let D=jr(s.name),T=jr(s.description),C=jr(s.license),N=`Publish ${y}/${yi(s.name)}`,F=[`## Skill: ${D}`,"",`**Author:** ${y}`,`**Version:** ${s.version}`,`**Description:** ${T}`,`**License:** ${C}`,`**Repository:** ${a}`,`**Commit:** \`${o}\``,`**Security verdict:** ${r}`,"","---","","*This PR was generated by `asm publish`.*"].join(`
|
|
196
|
+
`),{stdout:L,stderr:_,exitCode:ie}=await H(["gh","pr","create","--repo",Ge,"--head",`${y}:${b}`,"--title",N,"--body",F]),K=null;if(ie===0)K=L.trim();else{let U=_.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/);U&&(K=U[0])}return K?{success:!0,manifest:h,prUrl:K,error:null,securityVerdict:r,securityReport:n}:{success:!1,manifest:h,prUrl:null,error:`Failed to create PR against ${Ge}. ${_}`,securityVerdict:r,securityReport:n}}function Iu(e){let t=e.manifest;return t?["",` gh CLI is unavailable (${e.fallbackReason}).`," To publish manually:","",` 1. Fork ${Ge} on GitHub`,` 2. Create branch: publish/${t.author}/${t.name}`,` 3. Add file: manifests/${t.author}/${t.name}.json`," 4. Paste the manifest below into that file",` 5. Open a PR against ${Ge}`,"",' Run "asm doctor" to fix your environment.',""," Generated manifest:",JSON.stringify(t,null,2).split(`
|
|
197
197
|
`).map(i=>` ${i}`).join(`
|
|
198
198
|
`)].join(`
|
|
199
|
-
`):""}import{execFile as
|
|
200
|
-
`)[0];if(!n)return null;let r=n.split(/\s+/)[0];return r&&/^[0-9a-f]{40}$/.test(r)?r:null}catch(s){return I(`updater: git ls-remote failed for ${e}: ${s}`),null}}function
|
|
201
|
-
`)}function
|
|
202
|
-
`)[0],n=i.match(/(\d+\.\d+\.\d+)/);return{name:"GitHub CLI available",status:"pass",message:n?n[1]:i}}catch{return{name:"GitHub CLI available",status:"fail",message:"gh not found",fix:"Install GitHub CLI: https://cli.github.com"}}}async function
|
|
203
|
-
`);if(i.length<2)return{name:"Disk space",status:"warn",message:"Could not parse df output"};let n=i[1].split(/\s+/),r=parseInt(n[3],10);if(isNaN(r))return{name:"Disk space",status:"warn",message:"Could not parse available space"};let o=r/1024,a=o/1024;return o>100?{name:"Disk space",status:"pass",message:`OK (${a>=1?`${a.toFixed(1)} GB free`:`${Math.round(o)} MB free`})`}:{name:"Disk space",status:"fail",message:`${Math.round(o)} MB free (requires > 100 MB)`,fix:"Free disk space in home directory"}}catch{return{name:"Disk space",status:"warn",message:"Could not check disk space"}}}async function
|
|
204
|
-
`)}function
|
|
199
|
+
`):""}import{execFile as _b}from"child_process";import{promisify as Fb}from"util";import{rm as bi,rename as Ru,cp as Lu,access as qb,mkdir as jb}from"fs/promises";import{join as wi}from"path";import{homedir as Ou}from"os";var Br=Fb(_b);async function Bb(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 Ub(e,t){try{let s=["ls-remote",e];t?s.push(t):s.push("HEAD");let{stdout:i}=await Br("git",s,{timeout:1e4}),n=i.split(`
|
|
200
|
+
`)[0];if(!n)return null;let r=n.split(/\s+/)[0];return r&&/^[0-9a-f]{40}$/.test(r)?r:null}catch(s){return I(`updater: git ls-remote failed for ${e}: ${s}`),null}}function Ur(e){return e.sourceType?e.sourceType:e.source.startsWith("local:")?"local":"github"}function Tu(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 Vb(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 Vr(e){let t=e?.readLockFn??Le,s=e?.fetchRegistryIndexFn??Ir,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])=>Ur(l)==="registry"||l.registryName)&&(r=await s());let a=await Bb(n,5,async([l,c])=>{let f=Ur(c);if(!c.commitHash||c.commitHash==="unknown")return{name:l,installedCommit:c.commitHash||"unknown",latestCommit:"unknown",source:c.source,sourceType:f,status:"untracked"};if(f==="local")return{name:l,installedCommit:c.commitHash,latestCommit:c.commitHash,source:c.source,sourceType:f,status:"up-to-date"};if(f==="registry"&&r){let y=c.registryName||l,h=r.manifests.find(g=>g.name.toLowerCase()===y.toLowerCase());if(h){let g=h.commit!==c.commitHash;return{name:l,installedCommit:he(c.commitHash),latestCommit:he(h.commit),source:c.source,sourceType:f,status:g?"outdated":"up-to-date"}}}let d=Tu(c.source);if(!d)return{name:l,installedCommit:he(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:f,status:"error",error:"Cannot determine remote URL"};let p=await Ub(d,c.ref);if(!p)return{name:l,installedCommit:he(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:f,status:"error",error:"Failed to fetch remote commit"};let m=p!==c.commitHash;return{name:l,installedCommit:he(c.commitHash),latestCommit:he(p),source:c.source,sourceType:f,status:m?"outdated":"up-to-date"}});return{entries:a,outdatedCount:a.filter(l=>l.status==="outdated").length,upToDateCount:a.filter(l=>l.status==="up-to-date").length,untrackedCount:a.filter(l=>l.status==="untracked").length,errorCount:a.filter(l=>l.status==="error").length}}async function Kb(e,t,s,i){if(Ur(t)==="local")return{name:e,status:"skipped",reason:"Local skill (not updatable)"};let r=Tu(t.source);if(!r)return{name:e,status:"failed",reason:"Cannot determine remote URL"};let o=wi(Ou(),".config","agent-skill-manager",".tmp",`${e}-${Date.now()}`);try{let a=wi(Ou(),".config","agent-skill-manager",".tmp");await jb(a,{recursive:!0}),I(`updater: cloning latest ${e} to ${o}`);let l=["clone","--depth","1"];t.ref&&t.ref!=="HEAD"&&l.push("--branch",t.ref),l.push(r,o);try{await Br("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 Br("git",["rev-parse","HEAD"],{cwd:o,timeout:5e3});c=v.trim()}catch{return{name:e,status:"failed",reason:"Could not read new commit"}}if(c===t.commitHash)return{name:e,status:"skipped",reason:"Already up to date"};I(`updater: running security audit on ${e}`);let f="safe";try{let v=i?.auditFn??Re,A=Vb(t.source);if(f=(await v(o,e,A?.owner,A?.repo)).verdict,f==="dangerous")return{name:e,status:"skipped",reason:"Security audit: dangerous \u2014 update blocked",securityVerdict:f};if(f==="warning"||f==="caution"){if(!s)return{name:e,status:"skipped",reason:`Security audit: ${f} \u2014 use --yes to override`,securityVerdict:f};I(`updater: security audit ${f} for ${e} \u2014 proceeding (--yes)`)}}catch(v){return I(`updater: security audit failed for ${e}: ${v.message}`),{name:e,status:"failed",reason:`Security audit failed \u2014 skipping update: ${v.message}`}}let d=i?.loadConfigFn??B,p=i?.resolveProviderPathFn??ce,y=(await d()).providers.find(v=>v.name===t.provider),h=y?y.global:`~/.${t.provider}/skills`,g=p(h),b=wi(g,e),w=wi(o,".git");try{await bi(w,{recursive:!0,force:!0})}catch{}try{await qb(b)}catch{let v=i?.writeLockEntryFn??bt;return await Lu(o,b,{recursive:!0}),await v(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:he(t.commitHash),newCommit:he(c),securityVerdict:f}}let k=`${b}.bak-${Date.now()}`;try{await Ru(b,k),await Lu(o,b,{recursive:!0}),await bi(k,{recursive:!0,force:!0})}catch(v){try{await bi(b,{recursive:!0,force:!0}),await Ru(k,b)}catch{}return{name:e,status:"failed",reason:`Atomic swap failed: ${v.message}`}}return await(i?.writeLockEntryFn??bt)(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:he(t.commitHash),newCommit:he(c),securityVerdict:f}}finally{try{await bi(o,{recursive:!0,force:!0})}catch{}}}async function Mu(e,t,s){let i=s?.readLockFn??Le,n=s?.checkOutdatedFn??Vr,r=s?.updateSkillFn??Kb,o=await i(),a=await n({lock:o}),l=a.entries.filter(d=>d.status==="outdated"),c=[];if(e&&e.length>0){let d=new Set(e.map(p=>p.toLowerCase()));l=l.filter(p=>d.has(p.name.toLowerCase()));for(let p of e)l.find(m=>m.name.toLowerCase()===p.toLowerCase())||(a.entries.find(y=>y.name.toLowerCase()===p.toLowerCase())?I(`updater: skill "${p}" is already up to date`):(I(`updater: skill "${p}" not found in lock file`),c.push(p)))}if(l.length===0)return{results:[],updatedCount:0,skippedCount:0,failedCount:0,...c.length>0?{warnings:c}:{}};let f=[];for(let d of l){let p=o.skills[d.name];if(!p)continue;let m=await r(d.name,p,t);f.push(m)}return{results:f,updatedCount:f.filter(d=>d.status==="updated").length,skippedCount:f.filter(d=>d.status==="skipped").length,failedCount:f.filter(d=>d.status==="failed").length,...c.length>0?{warnings:c}:{}}}function he(e){return!e||e==="unknown"?"unknown":e.slice(0,7)}function Du(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(`
|
|
201
|
+
`)}function _u(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 Fu(e){return JSON.stringify({results:e.results.map(t=>({name:t.name,status:t.status,...t.reason?{reason:t.reason}:{},...t.oldCommit?{oldCommit:t.oldCommit}:{},...t.newCommit?{newCommit:t.newCommit}:{},...t.securityVerdict?{securityVerdict:t.securityVerdict}:{}})),summary:{updated:e.updatedCount,skipped:e.skippedCount,failed:e.failedCount}},null,2)}import{execFile as iw}from"child_process";import{promisify as nw}from"util";import{access as qu,readFile as Bu,readdir as rw,writeFile as ow,rm as aw,stat as Uu}from"fs/promises";import{join as Kr}from"path";import{homedir as lw}from"os";import{constants as ju}from"fs";import{access as Jb,realpath as Hb,stat as Wb}from"fs/promises";import{constants as Gb}from"fs";import{delimiter as Yb,resolve as zb,sep as Qb}from"path";var Xb="asm";function Zb(e){if(!e)return[];let t=new Set,s=[];for(let i of e.split(Yb)){let n=i.trim();if(!n)continue;let r=n.endsWith(Qb)?n.slice(0,-1):n;t.has(r)||(t.add(r),s.push(r))}return s}async function ew(e){try{if(!(await Wb(e)).isFile())return!1}catch{return!1}try{return await Jb(e,Gb.X_OK),!0}catch{return!1}}async function tw(e){try{return await Hb(e)}catch{return e}}async function sw(e=process.env.PATH){let t=new Set,s=[];for(let i of Zb(e)){let n=zb(i,Xb);if(!await ew(n))continue;let r=await tw(n);t.has(r)||(t.add(r),s.push({path:n,realPath:r}))}return s}async function vi(e=process.env.PATH){let t=await sw(e);if(t.length===0)return{resolved:null,shadowed:[]};let[s,...i]=t;return{resolved:s,shadowed:i}}var ft=nw(iw);async function cw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("git",["--version"],{timeout:5e3});return{name:"Git available",status:"pass",message:s.trim().replace("git version ","")}}catch{return{name:"Git available",status:"fail",message:"git not found",fix:"Install git: https://git-scm.com/downloads"}}}async function uw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("git",["--version"],{timeout:5e3}),i=s.match(/(\d+)\.(\d+)/);if(!i)return{name:"Git version",status:"warn",message:"Could not parse git version",fix:"Upgrade git: https://git-scm.com/downloads"};let n=parseInt(i[1],10),r=parseInt(i[2],10);return n>2||n===2&&r>=20?{name:"Git version",status:"pass",message:`${n}.${r} (>= 2.20)`}:{name:"Git version",status:"fail",message:`${n}.${r} (requires >= 2.20)`,fix:"Upgrade git: https://git-scm.com/downloads"}}catch{return{name:"Git version",status:"pass",message:"Skipped \u2014 git not available"}}}async function dw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("gh",["--version"],{timeout:5e3}),i=s.trim().split(`
|
|
202
|
+
`)[0],n=i.match(/(\d+\.\d+\.\d+)/);return{name:"GitHub CLI available",status:"pass",message:n?n[1]:i}}catch{return{name:"GitHub CLI available",status:"fail",message:"gh not found",fix:"Install GitHub CLI: https://cli.github.com"}}}async function fw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("gh",["auth","status"],{timeout:1e4}),i=s.match(/Logged in to .+ account (\S+)/);return{name:"GitHub CLI authenticated",status:"pass",message:i?i[1]:"authenticated"}}catch(s){let n=(s?.stderr??"").match(/Logged in to .+ account (\S+)/);return n?{name:"GitHub CLI authenticated",status:"pass",message:n[1]}:{name:"GitHub CLI authenticated",status:"fail",message:"Not authenticated",fix:"Run: gh auth login"}}}async function pw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("node",["--version"],{timeout:5e3}),i=s.trim().replace(/^v/,"");return parseInt(i.split(".")[0],10)>=18?{name:"Node.js version",status:"pass",message:i}:{name:"Node.js version",status:"fail",message:`${i} (requires >= 18.0)`,fix:"Upgrade Node.js: https://nodejs.org"}}catch{return{name:"Node.js version",status:"fail",message:"node not found",fix:"Install Node.js >= 18: https://nodejs.org"}}}async function mw(e){try{let t=Kr(e,".asm-doctor-write-test");return await ow(t,"test","utf-8"),await aw(t),{writable:!0,exists:!0}}catch{}try{return await qu(e,ju.W_OK),{writable:!0,exists:!0}}catch{}try{return await qu(e,ju.F_OK),{writable:!1,exists:!0}}catch{return{writable:!0,exists:!1}}}async function hw(e){let t=e.providers.filter(r=>r.enabled),s=0,i=0;for(let r of t){let o=ce(r.global);i++,(await mw(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 gw(){let e=gt();try{let t=await Bu(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 yw(){let e=oo();try{let t=await Bu(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 bw(){try{let e=await fetch(Pr,{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 ww(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=ce(l.global),f=Kr(c,o);try{(await Uu(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 vw(e,t){let s=new Set(Object.keys(t.skills)),i=[];for(let n of e.providers.filter(r=>r.enabled)){let r=ce(n.global);try{let o=await rw(r);for(let a of o)try{(await Uu(Kr(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 kw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("df",["-Pk",lw()],{timeout:5e3}),i=s.trim().split(`
|
|
203
|
+
`);if(i.length<2)return{name:"Disk space",status:"warn",message:"Could not parse df output"};let n=i[1].split(/\s+/),r=parseInt(n[3],10);if(isNaN(r))return{name:"Disk space",status:"warn",message:"Could not parse available space"};let o=r/1024,a=o/1024;return o>100?{name:"Disk space",status:"pass",message:`OK (${a>=1?`${a.toFixed(1)} GB free`:`${Math.round(o)} MB free`})`}:{name:"Disk space",status:"fail",message:`${Math.round(o)} MB free (requires > 100 MB)`,fix:"Free disk space in home directory"}}catch{return{name:"Disk space",status:"warn",message:"Could not check disk space"}}}async function Sw(){try{let e=await vi();if(e.shadowed.length===0)return e.resolved?{name:"No PATH shadowing",status:"pass",message:`single install at ${e.resolved.path}`}:{name:"No PATH shadowing",status:"pass",message:"asm not yet on PATH"};let t=e.resolved,s=e.shadowed[0].path,i=e.shadowed.length>1?` (+${e.shadowed.length-1} more)`:"";return{name:"No PATH shadowing",status:"warn",message:`resolved ${t.path}, shadowed ${s}${i}`,fix:"Remove the duplicate install (e.g. `bun remove -g agent-skill-manager` or `npm uninstall -g agent-skill-manager`) and keep only one."}}catch(e){return{name:"No PATH shadowing",status:"warn",message:`Could not scan PATH: ${e?.message??e}`}}}async function Vu(){let e=await B(),t=await Le(),i=(await Promise.allSettled([cw(),uw(),dw(),fw(),pw(),hw(e),gw(),yw(),bw(),ww(e,t),vw(e,t),kw(),Sw()])).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 $w={pass:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function Ku(e){let t=["Checking your environment...",""];for(let s of e.checks){let n=` ${$w[s.status]} ${s.name}${s.message?` (${s.message})`:""}`;if(t.push(n),s.fix&&s.status!=="pass"){let r;s.fix.startsWith("Run: ")?r=s.fix:/^[a-z/~]/.test(s.fix)?r=`Run: ${s.fix}`:r=`Fix: ${s.fix}`,t.push(` \u2192 ${r}`)}}return t.push(""),t.push(`${e.passed} passed, ${e.warnings} warning${e.warnings!==1?"s":""}, ${e.failures} error${e.failures!==1?"s":""}`),t.join(`
|
|
204
|
+
`)}function Ju(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 Hr,writeFile as xw,stat as pt,copyFile as Ew,readdir as zu}from"fs/promises";import{join as mt,resolve as Gr,basename as we,isAbsolute as Yr}from"path";var Wr="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`).",Hu=["name","description","version","license","author","creator","compatibility","allowed-tools","effort","tags","metadata"],Wu=["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"],Aw=["confirm","confirmation","error","errors","fail","failure","caution","warning","prerequisite","prerequisites","requires","requirements","rollback","dry-run","dry run","safety","validate","validation","check","backup"],Cw=["acceptance criteria","expected output","expected result","edge case","edge cases","test","tests","testing","verify","verification","assert","example input","example output","given","then"],Pw=["reference","references","see","template","templates","script","scripts","helper","helpers","link"],Nw=["when to use","quick start","overview","instructions","steps","workflow","phases","progressive"];function Qu(e){let t=e.split(`
|
|
205
205
|
`);if(t.length===0||t[0].trim()!=="---")return{rawFrontmatter:null,body:e};for(let s=1;s<t.length;s++)if(t[s].trim()==="---"){let i=t.slice(1,s).join(`
|
|
206
206
|
`),n=t.slice(s+1).join(`
|
|
207
207
|
`);return{rawFrontmatter:i,body:n}}return{rawFrontmatter:t.slice(1).join(`
|
|
208
|
-
`),body:""}}function
|
|
209
|
-
`).length:0}function Jr(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function Jb(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function gi(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function Hb(e){return/```[\s\S]+?```/m.test(e)}function Wb(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function Gb(e,t,s,i){let n=[],r=[],o=0;s!==null?(o+=2,n.push("Has YAML frontmatter block.")):(n.push("SKILL.md has no YAML frontmatter."),r.push("Add a YAML frontmatter block delimited by `---` with at least `name` and `description` fields."));let a=!!(e.name&&e.name.trim()),l=!!(e.description&&e.description.trim());a?o+=1.5:(n.push("Missing required field: name."),r.push("Add `name:` to frontmatter (use the skill directory name).")),l?o+=1.5:(n.push("Missing required field: description."),r.push("Add a one-line `description:` to frontmatter."));let c=ue(e);c&&c!=="0.0.0"?o+=1:(n.push("Missing or default version."),r.push("Set `metadata.version` (or top-level `version`) using semver (e.g. 0.1.0).")),!!(e.author||e["metadata.author"]||e.creator||e["metadata.creator"])?o+=1:(n.push("Missing `author`."),r.push("Add an `author` field so users know who authored and maintains the skill.")),!!e.license?o+=1:(n.push("Missing `license`."),r.push("Add a `license` field (e.g. `license: MIT`)."));let h=t.trim().length>=20,y=Jb(t,1);if(h?(o+=1,n.push("Body has meaningful content.")):(n.push("Body content is too short (<20 chars of instructions)."),r.push("Flesh out the markdown body with at least one paragraph of instructions for the agent.")),y?(o+=1,n.push("Body uses markdown headings.")):(n.push("Body has no markdown headings."),r.push("Add section headings (e.g. `## When to Use`, `## Instructions`) so the agent can navigate the skill quickly.")),i){let m=i.find(g=>g.toLowerCase()==="readme.md");m&&(n.push(`\`${m}\` found at skill root; move it to a subdirectory (e.g., \`docs/README.md\`).`),r.push(Ur))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function Yb(e,t){let s=[],i=[],n=0,r=(e.description||"").trim();if(!r)return s.push("No description."),i.push("Write a one-sentence description that says specifically what the skill does and when to use it."),{id:"description",name:"Description quality",score:0,max:10,findings:s,suggestions:i};let o=Jr(r);s.push(`Description is ${o} words.`),o>=8&&o<=40?n+=4:o>=5&&o<8?(n+=2,i.push("Lengthen the description slightly so it names both the action and the trigger (aim for 8\u201320 words).")):o>=41&&o<=60?(n+=2,i.push("Trim the description \u2014 aim for under 40 words. Move the long version to the markdown body.")):o>60?(n+=0,i.push("Description is too long. Keep it under 40 words; put detail in the body.")):(n+=0,i.push("Description is too short. Aim for 8\u201320 words."));let a=r.split(/\s+/)[0]?.toLowerCase().replace(/[^\w-]/g,"");return!!(a&&(Au.includes(a)||Au.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 zb(e,t){let s=[],i=[],n=0,r=gi(t,Kb);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.'),Wb(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=Hb(t),a=/\bexample\b/i.test(t);o&&a?(n+=2,s.push("Includes example code block.")):o||a?(n+=1,i.push('Back up examples with fenced code blocks labelled under "## Example" so the agent sees concrete input/output.')):i.push('Add an "## Example" section with a fenced code block showing the desired output.');let l=(t.match(/^\s*[-*0-9.]*\s*(Do|Use|Run|Call|Check|Validate|Return|Emit|Write|Read|Ask|Confirm|Avoid|Never|Always)\b/gim)||[]).length;l>=3?(n+=2,s.push(`Uses imperative voice (${l} cues).`)):l>=1?(n+=1,i.push("Favor imperative voice (Do / Use / Avoid / Never) to narrow the agent's choices.")):i.push('Rewrite instructions in the imperative mood \u2014 e.g. "Run `git status` first" instead of "you might want to run".');let c=Jr(t);return c>=80&&c<=3e3?(n+=1,s.push(`Body length within healthy range (${c} words).`)):c<80?(s.push(`Body is very short (${c} words).`),i.push("Expand the instructions; an underspecified skill gives the agent too much freedom.")):(s.push(`Body is very long (${c} words).`),i.push("Split large content into referenced files; keep SKILL.md focused under ~3000 words.")),{id:"prompt-engineering",name:"Prompt engineering",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function Qb(e,t){let s=[],i=[],n=0,r=Jr(t);s.push(`Body is ${r} words.`),r>=120&&r<=1500?n+=4:r>=60&&r<120?(n+=2,i.push("Expand instructions slightly \u2014 too little context can push the agent to improvise.")):r>1500&&r<=3e3?(n+=2,i.push("Consider moving large sections into referenced files (e.g. `references/*.md`) and linking them instead of inlining.")):r>3e3&&(n+=0,i.push("Body is over 3000 words \u2014 split long content into referenced files or templates."));let o=gi(t,Vb);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=>Ru(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 Xb(e,t){let s=[],i=[],n=0,r=gi(t,Bb);r.length>=4?(n+=4,s.push(`Covers multiple safety cues (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=2,s.push(`Mentions a few safety cues: ${r.join(", ")}.`),i.push("Add explicit error-handling and confirmation steps so the agent knows how to recover from failures.")):r.length===1?(n+=1,i.push('Expand the safety section \u2014 include prerequisites, validation steps, and what to do "on error".')):i.push("Describe prerequisites, confirmation prompts, and error-handling steps to reduce blast radius.");let o=/\b(rm\s|delete|remove|drop|force|overwrite|destructive)\b/i.test(t),a=/\bconfirm\b|\bdry-?run\b|\bare you sure\b|\bbackup\b/i.test(t);return o&&a?(n+=3,s.push("Destructive actions paired with confirmation/dry-run.")):o?(s.push("References destructive actions without explicit confirmation/dry-run."),i.push("Pair any destructive command with an explicit confirmation prompt, dry-run flag, or backup step.")):n+=1.5,/\bprerequisit/i.test(t)||/\brequire/i.test(t)||/\bdepend/i.test(t)?(n+=3,s.push("Declares prerequisites or requirements.")):(s.push("No prerequisites / requirements section."),i.push('Add a "## Prerequisites" block listing required tools, credentials, and environment state.')),{id:"safety",name:"Safety & guardrails",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function Zb(e,t){let s=[],i=[],n=0,r=gi(t,Ub);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 ew(e,t){let s=[],i=[],n=0,r=(e.name||"").trim();if(r){let l=/^[a-z][a-z0-9-]*$/.test(r),c=r.length<=40;l&&c?(n+=4,s.push(`name "${r}" follows kebab-case convention.`)):(l||(s.push(`name "${r}" is not lowercase kebab-case.`),i.push(`Rename to lowercase kebab-case (e.g. "${r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}").`)),c||s.push(`name is ${r.length} chars; keep it <= 40.`))}else i.push("Add a kebab-case `name` (e.g. `my-skill`).");let o=t.match(/^#{1,6}\s+(.+)$/gm)||[];return o.length>0&&(o.filter(d=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(d)).length/o.length>=.5?(n+=3,s.push("Most headings use action/imperative labels.")):(n+=1,i.push("Rename body headings to action-oriented labels (e.g. `## Instructions`, `## When to Use`)."))),/(?:\s\s|\bTODO\b|\bFIXME\b|\?{2,})/.test(e.description||"")?i.push("Clean up description \u2014 remove TODOs, FIXMEs, double spaces, or trailing punctuation."):(n+=2,s.push("Description looks clean (no TODO/FIXME/stray noise).")),{id:"naming",name:"Naming & conventions",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function Xt(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=re(t),{rawFrontmatter:o,body:a}=Lu(t),l=[Gb(r,a,o,n),Yb(r,a),zb(r,a),Qb(r,a),Xb(r,a),Zb(r,a),ew(r,a)];if(r.name&&we(s)===r.name){let g=l.find(b=>b.id==="naming");g.score<g.max&&(g.score=Math.min(g.max,g.score+1),g.findings.push("Directory name matches frontmatter `name`."))}let c=l.reduce((g,b)=>g+b.score,0),d=l.reduce((g,b)=>g+b.max,0),f=Math.round(c/d*100),p="F";f>=90?p="A":f>=80?p="B":f>=65?p="C":f>=50&&(p="D");let h=[];l.find(g=>g.id==="structure")?.suggestions.includes(Ur)&&h.push(Ur);let m=[...l].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of m){for(let b of g.suggestions){if(h.length>=3)break;h.includes(b)||h.push(b)}if(h.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:l,overallScore:f,grade:p,topSuggestions:h,frontmatter:r}}async function Ou(e){let t=Kr(e)?e:Vr(e),s;try{s=await dt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Br(i,"utf-8"),Xt({content:n,skillPath:we(t)==="SKILL.md"?we(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=pt(t,"SKILL.md");try{n=await Br(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await Iu(t)}catch{r=void 0}return Xt({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function tw(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function sw(e){let t=e.split(`
|
|
210
|
-
`),s=[],i=[],n=0;for(;n<t.length;){let c=t[n];if(!c.trim()){n++;continue}let
|
|
211
|
-
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let
|
|
212
|
-
`),changed:a}}function
|
|
208
|
+
`),body:""}}function Xu(e){return e?e.split(`
|
|
209
|
+
`).length:0}function zr(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function Iw(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function ki(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function Rw(e){return/```[\s\S]+?```/m.test(e)}function Lw(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function Ow(e,t,s,i){let n=[],r=[],o=0;s!==null?(o+=2,n.push("Has YAML frontmatter block.")):(n.push("SKILL.md has no YAML frontmatter."),r.push("Add a YAML frontmatter block delimited by `---` with at least `name` and `description` fields."));let a=!!(e.name&&e.name.trim()),l=!!(e.description&&e.description.trim());a?o+=1.5:(n.push("Missing required field: name."),r.push("Add `name:` to frontmatter (use the skill directory name).")),l?o+=1.5:(n.push("Missing required field: description."),r.push("Add a one-line `description:` to frontmatter."));let c=ue(e);c&&c!=="0.0.0"?o+=1:(n.push("Missing or default version."),r.push("Set `metadata.version` (or top-level `version`) using semver (e.g. 0.1.0).")),!!(e.author||e["metadata.author"]||e.creator||e["metadata.creator"])?o+=1:(n.push("Missing `author`."),r.push("Add an `author` field so users know who authored and maintains the skill.")),!!e.license?o+=1:(n.push("Missing `license`."),r.push("Add a `license` field (e.g. `license: MIT`)."));let m=t.trim().length>=20,y=Iw(t,1);if(m?(o+=1,n.push("Body has meaningful content.")):(n.push("Body content is too short (<20 chars of instructions)."),r.push("Flesh out the markdown body with at least one paragraph of instructions for the agent.")),y?(o+=1,n.push("Body uses markdown headings.")):(n.push("Body has no markdown headings."),r.push("Add section headings (e.g. `## When to Use`, `## Instructions`) so the agent can navigate the skill quickly.")),i){let h=i.find(g=>g.toLowerCase()==="readme.md");h&&(n.push(`\`${h}\` found at skill root; move it to a subdirectory (e.g., \`docs/README.md\`).`),r.push(Wr))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function Tw(e,t){let s=[],i=[],n=0,r=(e.description||"").trim();if(!r)return s.push("No description."),i.push("Write a one-sentence description that says specifically what the skill does and when to use it."),{id:"description",name:"Description quality",score:0,max:10,findings:s,suggestions:i};let o=zr(r);s.push(`Description is ${o} words.`),o>=8&&o<=40?n+=4:o>=5&&o<8?(n+=2,i.push("Lengthen the description slightly so it names both the action and the trigger (aim for 8\u201320 words).")):o>=41&&o<=60?(n+=2,i.push("Trim the description \u2014 aim for under 40 words. Move the long version to the markdown body.")):o>60?(n+=0,i.push("Description is too long. Keep it under 40 words; put detail in the body.")):(n+=0,i.push("Description is too short. Aim for 8\u201320 words."));let a=r.split(/\s+/)[0]?.toLowerCase().replace(/[^\w-]/g,"");return!!(a&&(Wu.includes(a)||Wu.includes(a.replace(/s$/,""))))?(n+=3,s.push("Starts with an action verb.")):(s.push(`Does not start with a recognized action verb (got "${a??""}").`),i.push('Start the description with an imperative action verb (e.g. "Generate...", "Analyze...", "Review...").')),/\buse when\b|\btrigger\b|\bwhen\b|\bfor\b/i.test(r)||/\b(before|after|during)\b/i.test(r)?(n+=3,s.push("Mentions a trigger or use-case signal.")):(s.push("No explicit trigger / use-case phrase."),i.push('Name the trigger in the description \u2014 e.g. "Use when...", "for reviewing...", "before publishing...".')),{id:"description",name:"Description quality",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function Mw(e,t){let s=[],i=[],n=0,r=ki(t,Nw);r.length>=2?(n+=3,s.push(`Progressive disclosure cues present: ${r.slice(0,3).join(", ")}.`)):r.length===1?(n+=1,i.push('Add clearer section labels \u2014 e.g. "## When to Use" and "## Instructions" \u2014 to support progressive disclosure.')):i.push('Structure the body with "## When to Use" and "## Instructions" sections so the agent reads only what it needs.'),Lw(t)?(n+=2,s.push("Uses lists or numbered steps.")):(s.push("No lists or steps detected."),i.push("Use bulleted or numbered steps to narrow the agent's degrees of freedom."));let o=Rw(t),a=/\bexample\b/i.test(t);o&&a?(n+=2,s.push("Includes example code block.")):o||a?(n+=1,i.push('Back up examples with fenced code blocks labelled under "## Example" so the agent sees concrete input/output.')):i.push('Add an "## Example" section with a fenced code block showing the desired output.');let l=(t.match(/^\s*[-*0-9.]*\s*(Do|Use|Run|Call|Check|Validate|Return|Emit|Write|Read|Ask|Confirm|Avoid|Never|Always)\b/gim)||[]).length;l>=3?(n+=2,s.push(`Uses imperative voice (${l} cues).`)):l>=1?(n+=1,i.push("Favor imperative voice (Do / Use / Avoid / Never) to narrow the agent's choices.")):i.push('Rewrite instructions in the imperative mood \u2014 e.g. "Run `git status` first" instead of "you might want to run".');let c=zr(t);return c>=80&&c<=3e3?(n+=1,s.push(`Body length within healthy range (${c} words).`)):c<80?(s.push(`Body is very short (${c} words).`),i.push("Expand the instructions; an underspecified skill gives the agent too much freedom.")):(s.push(`Body is very long (${c} words).`),i.push("Split large content into referenced files; keep SKILL.md focused under ~3000 words.")),{id:"prompt-engineering",name:"Prompt engineering",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function Dw(e,t){let s=[],i=[],n=0,r=zr(t);s.push(`Body is ${r} words.`),r>=120&&r<=1500?n+=4:r>=60&&r<120?(n+=2,i.push("Expand instructions slightly \u2014 too little context can push the agent to improvise.")):r>1500&&r<=3e3?(n+=2,i.push("Consider moving large sections into referenced files (e.g. `references/*.md`) and linking them instead of inlining.")):r>3e3&&(n+=0,i.push("Body is over 3000 words \u2014 split long content into referenced files or templates."));let o=ki(t,Pw);o.length>=2?(n+=3,s.push(`References external files or links (${o.slice(0,3).join(", ")}).`)):o.length===1?(n+=1,i.push('Link out to supporting files (e.g. "see `references/examples.md`") instead of inlining them.')):i.push('Offload verbose content to referenced files and link to them ("see `./templates/x.md`").');let l=(t.match(/```[\s\S]+?```/g)||[]).filter(c=>Xu(c)>60);return l.length===0?(n+=2,s.push("No oversized code blocks.")):(s.push(`${l.length} code block(s) longer than 60 lines.`),i.push("Move large code blocks into referenced template files; link to them from SKILL.md.")),/\btoken\b|\bbudget\b|\bcontext window\b/i.test(t)&&(n+=1,s.push("Mentions tokens/budget/context window.")),{id:"context-efficiency",name:"Context efficiency",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function _w(e,t){let s=[],i=[],n=0,r=ki(t,Aw);r.length>=4?(n+=4,s.push(`Covers multiple safety cues (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=2,s.push(`Mentions a few safety cues: ${r.join(", ")}.`),i.push("Add explicit error-handling and confirmation steps so the agent knows how to recover from failures.")):r.length===1?(n+=1,i.push('Expand the safety section \u2014 include prerequisites, validation steps, and what to do "on error".')):i.push("Describe prerequisites, confirmation prompts, and error-handling steps to reduce blast radius.");let o=/\b(rm\s|delete|remove|drop|force|overwrite|destructive)\b/i.test(t),a=/\bconfirm\b|\bdry-?run\b|\bare you sure\b|\bbackup\b/i.test(t);return o&&a?(n+=3,s.push("Destructive actions paired with confirmation/dry-run.")):o?(s.push("References destructive actions without explicit confirmation/dry-run."),i.push("Pair any destructive command with an explicit confirmation prompt, dry-run flag, or backup step.")):n+=1.5,/\bprerequisit/i.test(t)||/\brequire/i.test(t)||/\bdepend/i.test(t)?(n+=3,s.push("Declares prerequisites or requirements.")):(s.push("No prerequisites / requirements section."),i.push('Add a "## Prerequisites" block listing required tools, credentials, and environment state.')),{id:"safety",name:"Safety & guardrails",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function Fw(e,t){let s=[],i=[],n=0,r=ki(t,Cw);return r.length>=4?(n+=5,s.push(`Many testability cues present (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=3,s.push(`Some testability cues: ${r.join(", ")}.`),i.push('Add an "## Acceptance Criteria" block listing verifiable outputs or checklist items.')):r.length===1?(n+=1,i.push('Add concrete "expected output" examples so the agent can self-check.')):i.push('Add a "## Acceptance Criteria" section with testable statements (e.g. "produces a JSON report with overall_score").'),/expected\s+(output|result|response)/i.test(t)?(n+=3,s.push("Describes expected output/result.")):i.push('Include an "Expected output" example so reviewers and the agent can verify correctness.'),/\bedge case|gotcha|pitfall|limitation/i.test(t)?(n+=2,s.push("Mentions edge cases or limitations.")):i.push('Add a short "Edge cases" list to describe inputs the skill should reject or handle carefully.'),{id:"testability",name:"Testability",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function qw(e,t){let s=[],i=[],n=0,r=(e.name||"").trim();if(r){let l=/^[a-z][a-z0-9-]*$/.test(r),c=r.length<=40;l&&c?(n+=4,s.push(`name "${r}" follows kebab-case convention.`)):(l||(s.push(`name "${r}" is not lowercase kebab-case.`),i.push(`Rename to lowercase kebab-case (e.g. "${r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}").`)),c||s.push(`name is ${r.length} chars; keep it <= 40.`))}else i.push("Add a kebab-case `name` (e.g. `my-skill`).");let o=t.match(/^#{1,6}\s+(.+)$/gm)||[];return o.length>0&&(o.filter(f=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(f)).length/o.length>=.5?(n+=3,s.push("Most headings use action/imperative labels.")):(n+=1,i.push("Rename body headings to action-oriented labels (e.g. `## Instructions`, `## When to Use`)."))),/(?:\s\s|\bTODO\b|\bFIXME\b|\?{2,})/.test(e.description||"")?i.push("Clean up description \u2014 remove TODOs, FIXMEs, double spaces, or trailing punctuation."):(n+=2,s.push("Description looks clean (no TODO/FIXME/stray noise).")),{id:"naming",name:"Naming & conventions",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function ts(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=re(t),{rawFrontmatter:o,body:a}=Qu(t),l=[Ow(r,a,o,n),Tw(r,a),Mw(r,a),Dw(r,a),_w(r,a),Fw(r,a),qw(r,a)];if(r.name&&we(s)===r.name){let g=l.find(b=>b.id==="naming");g.score<g.max&&(g.score=Math.min(g.max,g.score+1),g.findings.push("Directory name matches frontmatter `name`."))}let c=l.reduce((g,b)=>g+b.score,0),f=l.reduce((g,b)=>g+b.max,0),d=Math.round(c/f*100),p="F";d>=90?p="A":d>=80?p="B":d>=65?p="C":d>=50&&(p="D");let m=[];l.find(g=>g.id==="structure")?.suggestions.includes(Wr)&&m.push(Wr);let h=[...l].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of h){for(let b of g.suggestions){if(m.length>=3)break;m.includes(b)||m.push(b)}if(m.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:l,overallScore:d,grade:p,topSuggestions:m,frontmatter:r}}async function Zu(e){let t=Yr(e)?e:Gr(e),s;try{s=await pt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Hr(i,"utf-8"),ts({content:n,skillPath:we(t)==="SKILL.md"?we(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=mt(t,"SKILL.md");try{n=await Hr(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await zu(t)}catch{r=void 0}return ts({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function jw(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function Bw(e){let t=e.split(`
|
|
210
|
+
`),s=[],i=[],n=0;for(;n<t.length;){let c=t[n];if(!c.trim()){n++;continue}let d=c.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!d)return{newFrontmatter:e,changed:!1};let p=d[1],m=d[2];if(m===""||m===">"||m==="|"){let y=[c];for(n++;n<t.length;){let h=t[n];if(h.trim()===""){y.push(h),n++;continue}if(/^\s+/.test(h))y.push(h),n++;else break}i.push({key:p,text:y.join(`
|
|
211
|
+
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let f=Hu.indexOf(c);return f===-1?Hu.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(`
|
|
212
|
+
`),changed:a}}function Uw(e,t={}){let s=[],i=[],n=e.replace(/\r\n/g,`
|
|
213
213
|
`);n!==e&&s.push({id:"normalise-line-endings",description:"Convert CRLF line endings to LF."});let r=n.split(`
|
|
214
214
|
`),o=r.map(g=>g.replace(/[ \t]+$/g,""));o.some((g,b)=>g!==r[b])&&s.push({id:"strip-trailing-whitespace",description:"Strip trailing whitespace from lines."}),n=o.join(`
|
|
215
|
-
`);let{rawFrontmatter:a,body:l}=
|
|
216
|
-
${
|
|
215
|
+
`);let{rawFrontmatter:a,body:l}=Qu(n),c=re(n);if(a===null)return i.push({id:"missing-frontmatter",description:"SKILL.md has no frontmatter \u2014 not auto-fixable (requires author decisions)."}),{newContent:n,applied:s,skipped:i};let f=a;if(!!(c.version||c["metadata.version"])||(f=Jr(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=Jr(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=jw(Xu(l));f=Jr(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=Bw(f);m.changed&&(s.push({id:"reorder-frontmatter",description:"Reorder frontmatter fields to canonical order."}),f=m.newFrontmatter);let y=l.replace(/^\n+/,""),h=`---
|
|
216
|
+
${f.replace(/^\n+|\n+$/g,"")}
|
|
217
217
|
---
|
|
218
218
|
|
|
219
|
-
${y}`;return
|
|
220
|
-
`)||(
|
|
219
|
+
${y}`;return h.endsWith(`
|
|
220
|
+
`)||(h+=`
|
|
221
221
|
`),e.replace(/\r\n/g,`
|
|
222
|
-
`),{newContent:
|
|
222
|
+
`),{newContent:h,applied:s,skipped:i}}function Jr(e,t,s){if(new RegExp(`^${t}:\\s*`,"m").test(e))return e;let n=/[:#{}\[\],&*?|<>=!%@`"']/.test(s)?JSON.stringify(s):s,r=e.length===0||e.endsWith(`
|
|
223
223
|
`)?"":`
|
|
224
224
|
`;return`${e}${r}${t}: ${n}
|
|
225
|
-
`}function
|
|
225
|
+
`}function Vw(e,t,s="SKILL.md"){if(e===t)return"";let i=e.split(`
|
|
226
226
|
`),n=t.split(`
|
|
227
|
-
`),r=[`--- a/${s}`,`+++ b/${s}`],o=0;for(;o<i.length&&o<n.length&&i[o]===n[o];)o++;let a=0;for(;a<i.length-o&&a<n.length-o&&i[i.length-1-a]===n[n.length-1-a];)a++;let l=i.slice(o,i.length-a),c=n.slice(o,n.length-a),
|
|
228
|
-
`)}async function
|
|
229
|
-
`)}function
|
|
227
|
+
`),r=[`--- a/${s}`,`+++ b/${s}`],o=0;for(;o<i.length&&o<n.length&&i[o]===n[o];)o++;let a=0;for(;a<i.length-o&&a<n.length-o&&i[i.length-1-a]===n[n.length-1-a];)a++;let l=i.slice(o,i.length-a),c=n.slice(o,n.length-a),f=o+1,d=o+1;r.push(`@@ -${f},${l.length} +${d},${c.length} @@`);let p=i.slice(Math.max(0,o-3),o).map(y=>` ${y}`),m=i.slice(i.length-a,Math.min(i.length,i.length-a+3)).map(y=>` ${y}`);r.push(...p);for(let y of l)r.push(`-${y}`);for(let y of c)r.push(`+${y}`);return r.push(...m),r.join(`
|
|
228
|
+
`)}async function ed(e,t){let s=Yr(e)?e:Gr(e),i,n=await pt(s).catch(()=>null);if(!n)throw new Error(`Skill path does not exist: ${s}`);if(n.isFile())i=s;else if(n.isDirectory())i=mt(s,"SKILL.md");else throw new Error(`Skill path is not a directory or file: ${s}`);let r;try{r=await Hr(i,"utf-8")}catch{throw new Error(`SKILL.md not found at ${i}.`)}let o=Uw(r,{gitAuthor:t.gitAuthor}),a=Vw(r,o.newContent),l=null;return!t.dryRun&&o.newContent!==r&&(l=`${i}.bak`,await Ew(i,l),await xw(i,o.newContent,"utf-8")),{report:ts({content:t.dryRun?r:o.newContent,skillPath:s,skillMdPath:i}),applied:o.applied,skipped:o.skipped,diff:a,dryRun:t.dryRun,backupPath:l,skillMdPath:i}}async function td(){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 Kw(e,t,s=20){let i=Math.round(e/t*s);return"\u2588".repeat(i)+"\u2591".repeat(Math.max(0,s-i))}function Si(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} ${Kw(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=Jw(i.raw);if(n&&n.length>0){t.push(""),t.push(`${i.id}@${i.version} breakdown:`);for(let r of n){let o=r.passed?"\u221A":r.severity==="warning"?"\u26A0":"\xD7";t.push(` ${o} ${r.label}`),r.passed||t.push(` [${r.severity}] ${r.message}`)}continue}if(i.findings.length!==0){t.push(""),t.push(`${i.id}@${i.version} findings:`);for(let r of i.findings)t.push(` [${r.severity}] ${r.message}`)}}return t.join(`
|
|
229
|
+
`)}function Jw(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 sd(e){return JSON.stringify(e,null,2)}function id(e){let t=[];if(e.applied.length===0&&e.skipped.length===0)return t.push("No fixes needed \u2014 SKILL.md is already clean."),t.join(`
|
|
230
230
|
`);if(e.applied.length>0){t.push(`${e.dryRun?"Would apply":"Applied"} ${e.applied.length} fix(es):`);for(let s of e.applied)t.push(` \u2022 ${s.description}`)}if(e.skipped.length>0){t.push(""),t.push(`Skipped ${e.skipped.length} issue(s) (not auto-fixable):`);for(let s of e.skipped)t.push(` \u2022 ${s.description}`)}return e.diff&&(t.push(""),t.push("Diff:"),t.push(e.diff)),!e.dryRun&&e.backupPath&&(t.push(""),t.push(`Backup: ${e.backupPath}`)),t.join(`
|
|
231
|
-
`)}async function
|
|
232
|
-
`)}function
|
|
231
|
+
`)}async function Hw(e){let t;try{t=await zu(e)}catch{return[]}let s=[];for(let i of t){if(i.startsWith(".")||i==="node_modules"||i==="dist"||i==="build")continue;let n=mt(e,i),r;try{r=await pt(n)}catch{continue}if(!r.isDirectory())continue;let o=mt(n,"SKILL.md");try{(await pt(o)).isFile()&&s.push(n)}catch{}}return s.sort((i,n)=>we(i).localeCompare(we(n))),s}async function Gu(e){let t=mt(e,"SKILL.md");try{if((await pt(t)).isFile())return{kind:"single",skillDirs:[e]}}catch{}let s=await Hw(e);return s.length>0?{kind:"collection",skillDirs:s}:{kind:"none",skillDirs:[]}}function Qr(e){return e?!!(e.startsWith("github:")||/^https?:\/\/github\.com\//i.test(e)):!1}function Yu(e){return{skillPath:e,skillMdPath:mt(e,"SKILL.md"),label:we(e)}}async function nd(e,t={}){if(!e)throw new Error("resolveEvalInput: input must be a non-empty string");if(Qr(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 Gu(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(Yu),isCollection:o.kind==="collection",cleanup:r.cleanup,provenance:{input:e,remote:!0,sourceRef:r.sourceRef,commitSha:r.commitSha,tempPath:r.rootDir}}}let s=Yr(e)?e:Gr(e),i;try{i=await pt(s)}catch{throw new Error(`Skill path does not exist: ${s}`)}if(i.isFile())return{targets:[{skillPath:we(s)==="SKILL.md"?we(s):s,skillMdPath:s,label:we(s)}],isCollection:!1,cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}};if(!i.isDirectory())throw new Error(`Skill path is not a directory or file: ${s}`);let n=await Gu(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(Yu),isCollection:n.kind==="collection",cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}}}function rd(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 od(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 ad(e,t=28){let s=[];return s.push(""),s.push("Batch summary:"),s.push(` Skills evaluated: ${e.aggregate.succeeded}/${e.aggregate.total}`+(e.aggregate.failed>0?` (${e.aggregate.failed} failed)`:"")),e.aggregate.meanScore!==null&&s.push(` Mean score: ${e.aggregate.meanScore}/100`),e.aggregate.top&&s.push(` Top: ${e.aggregate.top.label} (${e.aggregate.top.score}/100)`),e.aggregate.bottom&&e.aggregate.bottom.label!==e.aggregate.top?.label&&s.push(` Bottom: ${e.aggregate.bottom.label} (${e.aggregate.bottom.score}/100)`),e.provenance.remote&&(e.provenance.sourceRef&&s.push(` Source: ${e.provenance.sourceRef}`),e.provenance.commitSha&&s.push(` Commit: ${e.provenance.commitSha}`),e.provenance.tempPath&&s.push(` Fetched to: ${e.provenance.tempPath}`)),s.join(`
|
|
232
|
+
`)}function ld(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?$i(t.report,null):null}))}}function $i(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 Ww=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function Gw(e){if(typeof e!="string")return null;let t=Ww.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 Yw(e,t){let s=Gw(e);if(!s)throw new Error(`invalid semver: ${t} "${e}"`);return s}var Xr=new Map;function Zr(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("register: provider.id is required");if(Yw(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=Xr.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),Xr.set(e.id,t)}function xi(){let e=[];for(let t of Xr.values())for(let s of t)e.push(s);return e}import{stat as zw}from"fs/promises";var cd="quality",ud="1.0.0",dd=1;function Qw(e){return e.topSuggestions.map(t=>({severity:"info",message:t}))}function Xw(e){return e.categories.map(t=>({id:t.id,name:t.name,score:t.score,max:t.max}))}var fd={id:cd,version:ud,schemaVersion:dd,description:"Static linter for SKILL.md structure, description, and safety.",async applicable(e){try{return(await zw(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 Zu(e.skillPath);return{providerId:cd,providerVersion:ud,schemaVersion:dd,score:s.overallScore,passed:s.grade!=="F",categories:Xw(s),findings:Qw(s),raw:s,startedAt:"",durationMs:0}}};var yd=io(Cr(),1);import{readFile as Zw,stat as ev}from"fs/promises";import{basename as tv}from"path";var pd="skill-best-practice",md="1.1.0",hd=1,sv=new Set(["name","description","license","allowed-tools","metadata","compatibility","effort"]),gd=new Set(["low","medium","high","xhigh","max"]),eo=250,iv=/^\d+\.\d+\.\d+$/;function nv(e){if(!e.startsWith("---"))return null;let t=e.split(`
|
|
233
233
|
`);if(t.length<3||t[0]?.trim()!=="---")return null;let s=t.findIndex((i,n)=>n>0&&i.trim()==="---");return s===-1?null:t.slice(1,s).join(`
|
|
234
|
-
`)}function
|
|
235
|
-
`)&&!
|
|
236
|
-
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function
|
|
237
|
-
---`,3);return s===-1?"":t.slice(s+4)}async function
|
|
238
|
-
`,"utf-8"),I(`ingester: wrote index to ${c}`),{success:!0,repoIndex:a}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await oe(s)}}async function
|
|
234
|
+
`)}function Ei(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 Ai(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 rv(e){let t=await Zw(e.skillMdPath,"utf-8"),s=[],i=nv(t);if(i===null){W(s,"missing-frontmatter","Frontmatter exists",!1,"error","SKILL.md must start with a YAML frontmatter block.");let E=Ai(e,s,null);return{score:0,passed:!1,findings:s.map(Ei),raw:E}}W(s,"frontmatter-present","Frontmatter exists",!0,"error","SKILL.md contains a YAML frontmatter block.");let n;try{n=(0,yd.parse)(i)}catch(E){W(s,"invalid-yaml","Frontmatter parses as YAML",!1,"error",`Invalid YAML in frontmatter: ${E?.message??String(E)}`);let x=Ai(e,s,null);return{score:0,passed:!1,findings:s.map(Ei),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=Ai(e,s,null);return{score:0,passed:!1,findings:s.map(Ei),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=>!sv.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(`
|
|
235
|
+
`)&&!f.includes("\r")&&!f.includes("<")&&!f.includes(">")&&f.length<=1024;W(s,"description-shape","Description follows skill-best-practice formatting rules",E,"error",E?"Description is single-line, angle-bracket free, and within 1024 characters.":"Description must be a single line, avoid angle brackets, and stay within 1024 characters.");let x=f.length<=eo;W(s,"description-runtime-budget","Description fits the runtime context budget",x,"warning",x?`Description is ${f.length} chars (target \u2264 ${eo}).`:`Description is ${f.length} chars; target \u2264 ${eo}. 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"&&gd.has(d.trim()),"error",d===void 0||typeof d=="string"&&gd.has(d.trim())?"Effort is omitted or uses a supported value.":"Effort must be one of: low, medium, high, xhigh, max.");let p=r.compatibility;if(p!==void 0){let E=typeof p=="string"&&p.length<=500;W(s,"compatibility-shape","Compatibility is a short string",E,"error",E?"Compatibility is a valid short string.":"Compatibility must be a string no longer than 500 characters.")}let m=r.metadata&&typeof r.metadata=="object"&&!Array.isArray(r.metadata)?r.metadata:null,y=m?.version,h=typeof y=="string"||typeof y=="number"?String(y).trim():"",g=h.length>0;if(W(s,"metadata-version-present","metadata.version is present",g,"error",g?"Frontmatter declares `metadata.version`.":"Frontmatter must declare `metadata.version` (start new skills at 1.0.0)."),g){let E=iv.test(h);W(s,"metadata-version-semver","metadata.version follows MAJOR.MINOR.PATCH",E,"error",E?"`metadata.version` follows semantic versioning.":`\`metadata.version\` must follow semantic versioning (e.g. 1.0.0); got "${h}".`)}let b=m?.author,w=typeof b=="string"&&b.trim().length>0;if(W(s,"metadata-author-present","metadata.author is present",w,"warning",w?"Frontmatter declares `metadata.author`.":"Add `metadata.author` (recommended for published skills) so users know who maintains the skill."),l.length>0){let E=tv(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=Ai(e,s,r),v=S.checkCount===0?100:Math.round(S.passedChecks/S.checkCount*100),A=s.filter(E=>!E.passed).map(Ei);return{score:v,passed:A.every(E=>E.severity!=="error"),findings:A,raw:S}}var bd={id:pd,version:md,schemaVersion:hd,description:"Deterministic SKILL.md best-practice validation (rules aligned with the skill-creator standard, v1.7.1).",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 rv(e);return{providerId:pd,providerVersion:md,schemaVersion:hd,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 wd(){Zr(fd),Zr(bd)}var vd=!1;function Ci(){vd||(wd(),vd=!0)}function Pi(){return Ci(),xi()}function kd(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function Sd(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 Ni(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: ${kd(p)}`;return Sd(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 Sd(r,i,f,kd(c),"provider-threw")}finally{a&&clearTimeout(a)}}function ov(e){return e>=90?"A":e>=80?"B":e>=65?"C":e>=50?"D":"F"}function $d(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 xd(e,t){return{providerId:e.providerId,providerVersion:e.providerVersion,schemaVersion:e.schemaVersion,passed:e.passed,overallScore:e.score,grade:ov(e.score),categories:e.categories.map(s=>({id:s.id,name:s.name,score:s.score,max:s.max})),evaluatedAt:e.startedAt,evaluatedVersion:t}}function ss(e){return[...e].sort((t,s)=>t.id==="quality"&&s.id!=="quality"?-1:s.id==="quality"&&t.id!=="quality"?1:t.id.localeCompare(s.id))}var X={SKILL_NOT_FOUND:"SKILL_NOT_FOUND",AUDIT_FAILED:"AUDIT_FAILED",INSTALL_FAILED:"INSTALL_FAILED",PUBLISH_FAILED:"PUBLISH_FAILED",NETWORK_ERROR:"NETWORK_ERROR",INVALID_ARGUMENT:"INVALID_ARGUMENT",UNKNOWN_ERROR:"UNKNOWN_ERROR"};function Ye(){let e=console.log,t=console.info,s=(...i)=>process.stderr.write(i.map(String).join(" ")+`
|
|
236
|
+
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function Ed(e){return{timestamp:new Date().toISOString(),asm_version:Lo,duration_ms:Math.round(performance.now()-e)}}function z(e,t,s){let i={version:1,command:e,status:"ok",data:t,meta:Ed(s)},n=process.stdout.isTTY?2:0;return JSON.stringify(i,null,n)}function Z(e,t,s,i,n){let r={version:1,command:e,status:"error",error:{code:t,message:s,...n!==void 0?{details:n}:{}},meta:Ed(i)},o=process.stdout.isTTY?2:0;return JSON.stringify(r,null,o)}import{writeFile as cv,mkdir as uv,unlink as dv,readFile as fv,readdir as pv}from"fs/promises";import{join as is}from"path";function to(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 Ad(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=to(o[0].relPath);for(let f=1;f<o.length;f++){let d=to(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:to(f.relPath).root})),reason:l.priority===4?"first occurrence (no priority match)":`${l.root} priority`})}return{kept:s,decisions:i}}var av=[{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 Cd(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"),lv(t).trim().length<20&&s.push("SKILL.md body too short (less than 20 chars of instructions)");for(let{label:n,pattern:r}of av)r.test(t)&&s.push(`malicious pattern detected: ${n}`);return{verified:s.length===0,reasons:s}}function lv(e){let t=e.trimStart();if(!t.startsWith("---"))return t;let s=t.indexOf(`
|
|
237
|
+
---`,3);return s===-1?"":t.slice(s+4)}async function mv(){let e=yt();return await uv(e,{recursive:!0}),e}async function Pd(e){await De();let t;try{t=Te(e)}catch(i){return{success:!1,repoIndex:null,error:i.message}}if(t.isLocal)return{success:!1,repoIndex:null,error:"Local paths are not supported for indexing. Use a GitHub source instead."};I(`ingester: cloning ${t.owner}/${t.repo}`);let s=null;try{s=await _e(t),I(`ingester: discovering skills in ${s}`);let i=await fs(s);I(`ingester: found ${i.length} skills`);let{kept:n,decisions:r}=Ad(i);for(let f of r){let d=f.dropped.map(p=>p.relPath).join(", ");I(`ingester: dedupe "${f.name}": kept ${f.kept.relPath} (${f.reason}); dropped ${d}`)}r.length>0&&I(`ingester: deduped ${i.length} -> ${n.length} skills (${r.length} name collision${r.length===1?"":"s"})`);let o=[];for(let f of n){let d=is(s,f.relPath,"SKILL.md"),p="";try{p=await fv(d,"utf-8")}catch{I(`ingester: could not read SKILL.md at ${d}`)}let m=Cd(f,p);m.verified||I(`ingester: ${f.name} not verified: ${m.reasons.join(", ")}`);let y=typeof f.tokenCount=="number"?f.tokenCount:p?os(p):void 0,h,g;if(p){let b;try{b=await pv(is(s,f.relPath))}catch{b=void 0}try{let w=ts({content:p,skillPath:f.relPath||f.name,skillMdPath:d,rootEntries:b});h={overallScore:w.overallScore,grade:w.grade,categories:w.categories.map(k=>({id:k.id,name:k.name,score:k.score,max:k.max})),evaluatedAt:w.evaluatedAt,evaluatedVersion:f.version||void 0}}catch(w){I(`ingester: eval failed for ${f.name}: ${w}`)}try{let w={skillPath:is(s,f.relPath),skillMdPath:d},S=(await Promise.all(ss(Pi()).map(async v=>(await v.applicable(w,{})).ok?Ni(v,w):null))).filter(v=>v!==null).map(v=>xd(v,f.version||void 0));S.length>0&&(g=Object.fromEntries(S.filter(v=>v.providerId).map(v=>[v.providerId,v])))}catch(w){I(`ingester: provider eval failed for ${f.name}: ${w}`)}}o.push({name:f.name,description:f.description,version:f.version,license:f.license,creator:f.creator,compatibility:f.compatibility,allowedTools:f.allowedTools,installUrl:`github:${t.owner}/${t.repo}${t.ref?`#${t.ref}`:""}${f.relPath?`:${f.relPath}`:""}`,relPath:f.relPath,verified:m.verified,tokenCount:y,evalSummary:h,evalSummaries:g})}let a={repoUrl:t.cloneUrl,owner:t.owner,repo:t.repo,updatedAt:new Date().toISOString(),skillCount:o.length,skills:o};a.bundles=pi([...await pu(s,a),...Dr(a)]);let l=await mv(),c=is(l,`${t.owner}_${t.repo}.json`);return await cv(c,JSON.stringify(a,null,2)+`
|
|
238
|
+
`,"utf-8"),I(`ingester: wrote index to ${c}`),{success:!0,repoIndex:a}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await oe(s)}}async function Nd(){return(await ut()).map(t=>({owner:t.owner,repo:t.repo,skillCount:t.skillCount,updatedAt:t.updatedAt})).sort((t,s)=>s.skillCount-t.skillCount)}async function Id(e,t){let s=yt(),i=is(s,`${e}_${t}.json`);try{return await dv(i),!0}catch{return!1}}import{join as Od,resolve as Rd}from"path";function hv(e){switch(e){case"dangerous":return 3;case"warning":return 2;case"caution":return 1;default:return 0}}function so(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+hv(s.verdict),0)}}function gv(e){let t=e.slice(2),s={command:null,subcommand:null,positional:[],flags:{help:!1,version:!1,json:!1,yes:!1,noColor:!1,scope:"both",sort:"name",provider:null,name:null,force:!1,path:null,all:!1,verbose:!1,flat:!1,transport:"auto",method:"default",installed:!1,available:!1,has:[],missing:[],dryRun:!1,machine:!1,noCache:!1,fix:!1,compact:!1,summary:!1,groupBy:null,limit:0,concurrency:0,keep:!1,add:null,remove:null,description:null,author:null,tags:null,predefined:!1}},i=0;for(;i<t.length;){let n=t[i];if(n==="--help"||n==="-h")s.flags.help=!0;else if(n==="--version"||n==="-v")s.flags.version=!0;else if(n==="--json")s.flags.json=!0;else if(n==="--yes"||n==="-y")s.flags.yes=!0;else if(n==="--no-color")s.flags.noColor=!0;else if(n==="--scope"||n==="-s"){i++;let r=t[i];r==="global"||r==="project"||r==="both"?s.flags.scope=r:($(`Invalid scope: "${r}". Must be global, project, or both.`),process.exit(2))}else if(n==="--sort"){i++;let r=t[i];r==="name"||r==="version"||r==="location"?s.flags.sort=r:($(`Invalid sort: "${r}". Must be name, version, or location.`),process.exit(2))}else if(n==="--provider"||n==="-p"||n==="--tool")i++,s.flags.provider=t[i]||null;else if(n==="--name")i++,s.flags.name=t[i]||null;else if(n==="--force"||n==="-f")s.flags.force=!0;else if(n==="--path")i++,s.flags.path=t[i]||null;else if(n==="--all")s.flags.all=!0;else if(n==="--verbose"||n==="-V")s.flags.verbose=!0;else if(n==="--flat")s.flags.flat=!0;else if(n==="--compact")s.flags.compact=!0;else if(n==="--summary")s.flags.summary=!0;else if(n==="--group-by"){i++;let r=t[i];r==="tool"||r==="scope"||r==="effort"?s.flags.groupBy=r:($(`Invalid --group-by: "${r}". Must be tool, scope, or effort.`),process.exit(2))}else if(n==="--limit"){i++;let r=t[i],o=Number(r);(!Number.isFinite(o)||o<0||!Number.isInteger(o))&&($(`Invalid --limit: "${r}". Must be a non-negative integer (0 means no limit).`),process.exit(2)),s.flags.limit=o}else if(n==="--installed")s.flags.installed=!0;else if(n==="--available")s.flags.available=!0;else if(n==="--concurrency"){i++;let r=t[i],o=Number(r);(!Number.isFinite(o)||o<1||!Number.isInteger(o))&&($(`Invalid --concurrency: "${r}". Must be a positive integer.`),process.exit(2)),s.flags.concurrency=o}else if(n==="--keep")s.flags.keep=!0;else if(n==="--transport"||n==="-t"){i++;let r=t[i];r==="https"||r==="ssh"||r==="auto"?s.flags.transport=r:($(`Invalid transport: "${r}". Must be https, ssh, or auto.`),process.exit(2))}else if(n==="--method"||n==="-m"){i++;let r=t[i];r==="default"||r==="vercel"?s.flags.method=r:($(`Invalid method: "${r}". Must be default or vercel.`),process.exit(2))}else n==="--skill"?(i++,s.flags.path=t[i]||null):n==="--dry-run"?s.flags.dryRun=!0:n==="--fix"?s.flags.fix=!0:n==="--machine"?s.flags.machine=!0:n==="--no-cache"?s.flags.noCache=!0:n==="--has"?(i++,t[i]&&s.flags.has.push(t[i])):n==="--missing"?(i++,t[i]&&s.flags.missing.push(t[i])):n==="--add"?(i++,s.flags.add=t[i]||null):n==="--remove"?(i++,s.flags.remove=t[i]||null):n==="--description"?(i++,s.flags.description=t[i]||null):n==="--author"?(i++,s.flags.author=t[i]||null):n==="--tags"?(i++,s.flags.tags=t[i]||null):n==="--predefined"?s.flags.predefined=!0:n.startsWith("-")?($(`Unknown option: ${n}`),console.error('Run "asm --help" for usage.'),process.exit(2)):s.command?s.subcommand?s.positional.push(n):s.subcommand=n:s.command=n;i++}return s}function $(e){console.error(u.red(`Error: ${e}`))}function yv(){console.log(`${u.blueBold("agent-skill-manager")} (${u.bold("asm")}) ${_i}
|
|
239
239
|
|
|
240
240
|
Interactive TUI and CLI for managing installed skills for AI coding agents.
|
|
241
241
|
|
|
@@ -280,11 +280,11 @@ ${u.bold("Global Options:")}
|
|
|
280
280
|
--sort <field> Sort by: name, version, or location (default: name)
|
|
281
281
|
--flat Show one row per tool instance (list, search)
|
|
282
282
|
-y, --yes Skip confirmation prompts
|
|
283
|
-
-V, --verbose Show debug output`)}function
|
|
283
|
+
-V, --verbose Show debug output`)}function bv(){console.log(`${u.bold("Usage:")} asm list [options]
|
|
284
284
|
|
|
285
285
|
List all discovered skills. By default, skills installed across multiple
|
|
286
286
|
tools are grouped into a single row with tool badges. When more than
|
|
287
|
-
${
|
|
287
|
+
${Ti} skills are present, a compact summary is
|
|
288
288
|
automatically prepended above the table.
|
|
289
289
|
|
|
290
290
|
${u.bold("Options:")}
|
|
@@ -314,7 +314,7 @@ ${u.bold("Examples:")}
|
|
|
314
314
|
asm list -s project ${u.dim("Only project-scoped skills")}
|
|
315
315
|
asm list --sort version ${u.dim("Sort by version")}
|
|
316
316
|
asm list --json ${u.dim("Output as JSON")}
|
|
317
|
-
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
317
|
+
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function wv(){console.log(`${u.bold("Usage:")} asm search <query> [options]
|
|
318
318
|
|
|
319
319
|
Search both installed skills and the skill index. Results show installation
|
|
320
320
|
status and include copy-paste install commands for available skills.
|
|
@@ -337,7 +337,7 @@ ${u.bold("Examples:")}
|
|
|
337
337
|
asm search "test" --installed ${u.dim("Search installed skills only")}
|
|
338
338
|
asm search "test" --available ${u.dim("Search available skills only")}
|
|
339
339
|
asm search openspec --json ${u.dim("Output matches as JSON")}
|
|
340
|
-
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
340
|
+
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function vv(){console.log(`${u.bold("Usage:")} asm inspect <skill-name> [options]
|
|
341
341
|
|
|
342
342
|
Show detailed information for a skill. The <skill-name> is the directory name.
|
|
343
343
|
Shows version, description, file count, and all provider installations.
|
|
@@ -351,7 +351,7 @@ ${u.bold("Options:")}
|
|
|
351
351
|
${u.bold("Examples:")}
|
|
352
352
|
asm inspect code-review ${u.dim("Show details for code-review")}
|
|
353
353
|
asm inspect code-review --json ${u.dim("Output as JSON")}
|
|
354
|
-
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function
|
|
354
|
+
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function kv(){console.log(`${u.bold("Usage:")} asm uninstall <skill-name> [options]
|
|
355
355
|
|
|
356
356
|
Remove a skill and its associated rule files. Shows a removal plan
|
|
357
357
|
before proceeding and asks for confirmation.
|
|
@@ -359,13 +359,15 @@ before proceeding and asks for confirmation.
|
|
|
359
359
|
${u.bold("Options:")}
|
|
360
360
|
-y, --yes Skip confirmation prompt
|
|
361
361
|
-s, --scope <s> Filter: global, project, or both (default: both)
|
|
362
|
+
-p, --tool <name> Filter by tool/provider (e.g., claude, codex)
|
|
362
363
|
--no-color Disable ANSI colors
|
|
363
364
|
-V, --verbose Show debug output
|
|
364
365
|
|
|
365
366
|
${u.bold("Examples:")}
|
|
366
|
-
asm uninstall code-review
|
|
367
|
-
asm uninstall code-review -y
|
|
368
|
-
asm uninstall code-review -s project
|
|
367
|
+
asm uninstall code-review ${u.dim("Remove with confirmation")}
|
|
368
|
+
asm uninstall code-review -y ${u.dim("Remove without confirmation")}
|
|
369
|
+
asm uninstall code-review -s project ${u.dim("Remove project copy only")}
|
|
370
|
+
asm uninstall code-review -p claude ${u.dim("Remove from Claude only")}`)}function Sv(){console.log(`${u.bold("Usage:")} asm audit [subcommand] [options]
|
|
369
371
|
|
|
370
372
|
Detect duplicate skills or run security audits on installed/remote skills.
|
|
371
373
|
|
|
@@ -391,7 +393,7 @@ ${u.bold("Examples:")}
|
|
|
391
393
|
asm audit security code-review --json ${u.dim("Output audit as JSON")}
|
|
392
394
|
asm audit security code-review --machine ${u.dim("Machine-readable v1 envelope output")}
|
|
393
395
|
asm audit security https://github.com/user/skills/tree/main/skills/agent-config
|
|
394
|
-
${u.dim("Audit a skill from a subfolder URL")}`)}function
|
|
396
|
+
${u.dim("Audit a skill from a subfolder URL")}`)}function $v(){console.log(`${u.bold("Usage:")} asm publish [path] [options]
|
|
395
397
|
|
|
396
398
|
Validate a skill, run a security audit, generate a registry manifest,
|
|
397
399
|
and open a PR against the asm-registry.
|
|
@@ -414,7 +416,7 @@ ${u.bold("Examples:")}
|
|
|
414
416
|
asm publish --dry-run ${u.dim("Preview manifest without side effects")}
|
|
415
417
|
asm publish --force ${u.dim("Override warning-level security findings")}
|
|
416
418
|
asm publish --json ${u.dim("Output as JSON")}
|
|
417
|
-
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
419
|
+
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function xv(){console.log(`${u.bold("Usage:")} asm outdated [options]
|
|
418
420
|
|
|
419
421
|
Show which installed skills have newer versions available.
|
|
420
422
|
|
|
@@ -427,7 +429,7 @@ ${u.bold("Options:")}
|
|
|
427
429
|
${u.bold("Examples:")}
|
|
428
430
|
asm outdated ${u.dim("Show outdated skills")}
|
|
429
431
|
asm outdated --json ${u.dim("Output as JSON")}
|
|
430
|
-
asm outdated --machine ${u.dim("Machine-readable output")}`)}function
|
|
432
|
+
asm outdated --machine ${u.dim("Machine-readable output")}`)}function Ev(){console.log(`${u.bold("Usage:")} asm update [name...] [options]
|
|
431
433
|
|
|
432
434
|
Update outdated skills to their latest version with security re-audit.
|
|
433
435
|
|
|
@@ -445,7 +447,7 @@ ${u.bold("Examples:")}
|
|
|
445
447
|
asm update ${u.dim("Update all outdated skills")}
|
|
446
448
|
asm update code-review ${u.dim("Update a specific skill")}
|
|
447
449
|
asm update --yes ${u.dim("Skip confirmation prompts")}
|
|
448
|
-
asm update --json ${u.dim("Output as JSON")}`)}function
|
|
450
|
+
asm update --json ${u.dim("Output as JSON")}`)}function Av(){console.log(`${u.bold("Usage:")} asm config <subcommand>
|
|
449
451
|
|
|
450
452
|
Manage configuration. Config is stored at ~/.config/agent-skill-manager/.
|
|
451
453
|
|
|
@@ -461,19 +463,19 @@ ${u.bold("Options:")}
|
|
|
461
463
|
${u.bold("Examples:")}
|
|
462
464
|
asm config show ${u.dim("View current config")}
|
|
463
465
|
asm config edit ${u.dim("Edit in $EDITOR")}
|
|
464
|
-
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function
|
|
465
|
-
${u.yellow(`${o.length} skill${o.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(r)}else if(e.flags.summary)console.log(
|
|
466
|
-
`))}}async function
|
|
467
|
-
`)),e.flags.flat?console.log(
|
|
468
|
-
${u.bold("Proceed with removal?")} [y/N] `);let
|
|
466
|
+
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function Td(e){for(let t of e)t.warnings=await Dc(t)}async function Cv(e){if(e.flags.help){bv();return}let t=performance.now(),s=await B(),i=await ee(s,e.flags.scope);e.flags.provider&&e.command==="list"&&(i=i.filter(r=>r.provider===e.flags.provider)),await Td(i);let n=Ri(i,e.flags.sort);if(e.flags.machine){let r=n.map(o=>({name:o.name,version:o.version,description:o.description,scope:o.scope,provider:o.provider,path:o.path}));console.log(z("list",r,t));return}if(e.flags.json)console.log(G(n));else if(e.flags.flat){let r=Oi(n),o=n.filter(a=>a.warnings&&a.warnings.length>0);o.length>0&&(r+=`
|
|
467
|
+
${u.yellow(`${o.length} skill${o.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(r)}else if(e.flags.summary)console.log(Mi(n));else if(e.flags.groupBy){let{skills:r,hint:o}=as(n,e.flags.limit);console.log(vo(r,e.flags.groupBy)),o&&console.log(o)}else if(e.flags.compact){let{skills:r,hint:o}=as(n,e.flags.limit);console.log(wo(r)),o&&console.log(o)}else{let r=[];n.length>Ti&&(r.push(Mi(n,{showHint:!1})),r.push(""));let{skills:o,hint:a}=as(n,e.flags.limit);r.push(ko(o)),a&&r.push(a),console.log(r.join(`
|
|
468
|
+
`))}}async function Pv(e){if(e.flags.help){wv();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;i||(e.flags.machine&&(t?.(),console.log(Z("search",X.INVALID_ARGUMENT,"Missing required argument: <query>",s)),process.exit(2)),$("Missing required argument: <query>"),console.error('Run "asm search --help" for usage.'),process.exit(2));let n=!e.flags.available,r=!e.flags.installed,o=[];if(n){let f=await B(),d=await ee(f,e.flags.scope);e.flags.provider&&(d=d.filter(m=>m.provider===e.flags.provider));let p=uo(d,i);o=Ri(p,e.flags.sort)}let a=[];if(r&&(a=await fi(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(z("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(G([...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}":
|
|
469
|
+
`)),e.flags.flat?console.log(Oi(o)):console.log(So(o,i))),c){l&&console.error("");let f=$o(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 Nv(e){if(e.flags.help){vv();return}let t=e.subcommand;t||($("Missing required argument: <skill-name>"),console.error('Run "asm inspect --help" for usage.'),process.exit(2));let s=await B(),n=(await ee(s,e.flags.scope)).filter(r=>r.dirName===t);n.length===0&&($(`Skill "${t}" not found.`),console.error(u.dim(`Try ${u.bold("asm list")} to see all skills or ${u.bold(`asm search "${t}"`)} to search.`)),process.exit(1)),await Td(n),e.flags.json?console.log(G(n.length===1?n[0]:n)):console.log(await xo(n))}async function Iv(e){if(e.flags.help){kv();return}let t=e.subcommand;t||($("Missing required argument: <skill-name>"),console.error('Run "asm uninstall --help" for usage.'),process.exit(2));let s=await B(),i=await ee(s,e.flags.scope),n={};e.flags.provider&&(n.providerFilter=e.flags.provider),e.flags.scope&&e.flags.scope!=="both"&&(n.scopeFilter=e.flags.scope);let r=po(t,i,s,n),o=await ho(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=mo(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")} ${bo(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(`
|
|
470
|
+
${u.bold("Proceed with removal?")} [y/N] `);let m=await Q();m.toLowerCase()!=="y"&&m.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let f;try{f=await Li(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=>Rd(m.path))),p=a.filter(m=>!d.has(Rd(m.originalPath)));try{l&&p.length>0?c?.needed&&!c.repointOnly&&await Co(t,c.toProvider):await Ao(t)}catch{}console.error(u.green(`
|
|
469
471
|
Done.`))}function Q(){return new Promise(e=>{let t="",s=!1;function i(){process.stdin.removeListener("data",r),process.stdin.removeListener("end",o),process.stdin.pause(),clearTimeout(a)}function n(l){s||(s=!0,i(),e(l))}function r(l){t+=l,t.includes(`
|
|
470
|
-
`)&&n(t.trim())}function o(){n(t.trim())}let a=setTimeout(()=>{n(t.trim())},3e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",r),process.stdin.on("end",o),process.stdin.resume()})}async function
|
|
471
|
-
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a
|
|
472
|
-
Done.`))}}async function
|
|
473
|
-
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function
|
|
474
|
-
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await
|
|
475
|
-
Summary:`)),a.dangerous>0&&console.log(` ${u.red(`${a.dangerous} dangerous`)}`),a.warning>0&&console.log(` ${u.yellow(`${a.warning} warning`)}`),a.caution>0&&console.log(` ${a.caution} caution`),a.safe>0&&console.log(` ${u.green(`${a.safe} safe`)}`),console.log("")}}async function
|
|
476
|
-
`);let a=await
|
|
472
|
+
`)&&n(t.trim())}function o(){n(t.trim())}let a=setTimeout(()=>{n(t.trim())},3e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",r),process.stdin.on("end",o),process.stdin.resume()})}async function Rv(e){if(e.flags.help){Sv();return}let t=performance.now(),s=e.subcommand??"duplicates";if(s==="security"){await Lv(e,t);return}s!=="duplicates"&&($(`Unknown audit subcommand: "${s}". Use: duplicates, security`),process.exit(2));let i=await B(),n=await ee(i,"both"),r=Di(n);if(e.flags.machine){let o={duplicate_groups:r.duplicateGroups.map(a=>({name:a.key,count:a.instances.length,instances:a.instances.map(l=>({path:l.path,scope:l.scope,provider:l.provider}))})),total_duplicates:r.duplicateGroups.length};console.log(z("audit duplicates",o,t));return}if(e.flags.json){console.log(Ro(r));return}if(console.log(Io(r)),e.flags.yes&&r.duplicateGroups.length>0){console.error(u.bold(`
|
|
473
|
+
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a=No(o.instances),l=a[0].path;for(let c=1;c<a.length;c++){let f=a[c],d=fo(f,i),p=await Li(d,l);for(let m of p)console.error(m)}}console.error(u.green(`
|
|
474
|
+
Done.`))}}async function Lv(e,t){let s=e.positional[0];e.flags.all?await Ov(e,t):s?s.startsWith("github:")||s.startsWith("https://github.com/")?await Tv(e,s,t):await Mv(e,s,t):(e.flags.machine&&(console.log(Z("audit security",X.INVALID_ARGUMENT,"Missing target. Provide a skill name, GitHub source, or use --all.",t)),process.exit(2)),$(`Missing target. Provide a skill name, GitHub source, or use --all.
|
|
475
|
+
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function Ov(e,t){let s=await B(),i=await ee(s,e.flags.scope);if(i.length===0){e.flags.machine?console.log(z("audit security",[],t)):e.flags.json?console.log("[]"):console.log("No skills found to audit.");return}let n=new Set,r=i.filter(a=>n.has(a.realPath)?!1:(n.add(a.realPath),!0));console.error(`Auditing ${r.length} skill${r.length>1?"s":""}...
|
|
476
|
+
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await Re(a.realPath,a.name);o.push(l)}if(e.flags.machine)console.log(z("audit security",so(o),t));else if(e.flags.json)console.log(JSON.stringify(o,null,2));else{for(let l of o)console.log(gi(l));let a={safe:0,caution:0,warning:0,dangerous:0};for(let l of o)a[l.verdict]++;console.log(u.bold(`
|
|
477
|
+
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 Tv(e,t,s){let i=null;try{let n=Te(t);if(n.isLocal)throw new Error("Local paths are not supported for remote security audits. Use: asm audit security <installed-skill-name>");await De(),n=await ds(n),console.error(`Cloning ${t} for audit...`),i=await _e(n,e.flags.transport);let{join:r}=await import("path"),o=n.subpath?r(i,n.subpath):i,{name:a}=await Fe(o),l=await Re(o,a,n.owner,n.repo);e.flags.machine?console.log(z("audit security",so([l]),s)):e.flags.json?console.log(qr(l)):console.log(gi(l))}catch(n){e.flags.machine&&(console.log(Z("audit security",X.AUDIT_FAILED,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}finally{i&&await oe(i)}}async function Mv(e,t,s){let i=await B(),r=(await ee(i,e.flags.scope)).filter(l=>l.dirName===t);r.length===0&&(e.flags.machine&&(console.log(Z("audit security",X.SKILL_NOT_FOUND,`Skill "${t}" not found.`,s)),process.exit(1)),$(`Skill "${t}" not found. Use "asm list" to see installed skills.`),process.exit(1));let o=r[0];console.error(`Auditing installed skill: ${u.bold(o.name)}...
|
|
478
|
+
`);let a=await Re(o.realPath,o.name);e.flags.machine?console.log(z("audit security",so([a]),s)):e.flags.json?console.log(qr(a)):console.log(gi(a))}async function Dv(e){if(e.flags.help){Av();return}let t=e.subcommand;switch(t||($("Missing subcommand. Use: show, path, reset, or edit."),console.error('Run "asm config --help" for usage.'),process.exit(2)),t){case"show":{let s=await B();console.log(G(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 Q();i.toLowerCase()!=="y"&&i.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let s=ro();await lo(s),console.error(u.green("Config reset to defaults."));break}case"edit":{let s=process.env.VISUAL||process.env.EDITOR||"vi",[i,n]=Oo(s),r=gt();await B();let{spawn:o}=await import("child_process");await new Promise((a,l)=>{let c=o(i,[...n,r],{stdio:"inherit"});c.on("close",()=>a()),c.on("error",l)});break}default:$(`Unknown config subcommand: "${t}". Use: show, path, reset, or edit.`),process.exit(2)}}function _v(){console.log(`${u.bold("Usage:")} asm install <source> [options]
|
|
477
479
|
|
|
478
480
|
Install a skill from a GitHub repository, the curated registry, or a local path.
|
|
479
481
|
|
|
@@ -545,27 +547,27 @@ ${u.bold("Subfolder URL:")}
|
|
|
545
547
|
${u.bold("Vercel skills CLI:")}
|
|
546
548
|
asm install github:user/skills --method vercel --skill my-skill
|
|
547
549
|
asm install https://github.com/user/skills -m vercel --skill my-skill -y
|
|
548
|
-
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function
|
|
549
|
-
${u.bold("Install preview:")}`),console.info(` ${u.bold("Name:")} ${o.name}`),console.info(` ${u.bold("Version:")} ${o.version}`),o.description&&console.info(` ${u.bold("Description:")} ${u.dim(o.description)}`),o.effort&&console.info(` ${u.bold("Effort:")} ${
|
|
550
|
-
${u.bold("Security warnings:")}`);let p=new Map;for(let
|
|
551
|
-
${g} ${u.dim(`(${y.length} match${y.length>1?"es":""})`)}`);for(let b of y.slice(0,5))console.info(` ${u.dim(`${b.file}:${b.line}`)} -- ${b.match}`);y.length>5&&console.info(u.dim(` ... and ${y.length-5} more`))}}}}async function
|
|
552
|
-
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(
|
|
553
|
-
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:
|
|
554
|
-
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let
|
|
555
|
-
Select a skill [1-${
|
|
556
|
-
Did you mean: ${
|
|
557
|
-
`);for(let _=0;_<N.length;_++){let ie=u.cyan(` ${String(_+1).padStart(String(N.length).length)})`);console.info(`${ie} ${u.bold(N[_].name)} ${u.dim(`v${N[_].version}`)} ${u.dim(`(${N[_].relPath})`)}`),N[_].description&&console.info(` ${u.dim(N[_].description)}`)}console.info(l("Selecting skills")),a--;let
|
|
550
|
+
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function Fv(e,t,s,i,n,r,o,a,l="global"){let c=await Fe(i),f=await Bo(i),d=i===s?null:i.split(/[/\\]/).pop(),p=n||d||t.repo,m=Me(p),y=a.find(A=>A.name.toLowerCase()===c.name.toLowerCase()&&A.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=Ji(t,s,i,m,o,e.flags.force||g,l),w=f.some(A=>["Shell commands","Code execution","Credentials"].includes(A.category)),k=f.some(A=>["External URLs"].includes(A.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 qv(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(`
|
|
551
|
+
${u.bold("Install preview:")}`),console.info(` ${u.bold("Name:")} ${o.name}`),console.info(` ${u.bold("Version:")} ${o.version}`),o.description&&console.info(` ${u.bold("Description:")} ${u.dim(o.description)}`),o.effort&&console.info(` ${u.bold("Effort:")} ${go(o.effort)}`),console.info(` ${u.bold("Source:")} ${t}`),i?(console.info(` ${u.bold("Tool:")} All (${i.map(p=>p.label).join(", ")})`),console.info(` ${u.bold("Primary:")} ${s.label} (${s.name})`),console.info(` ${u.bold("Symlinks:")} ${i.filter(p=>p.name!==s.name).map(p=>p.label).join(", ")}`)):console.info(` ${u.bold("Tool:")} ${s.label} (${s.name})`),console.info(` ${u.bold("Scope:")} ${f.scope==="project"?"Project":"Global"}`),console.info(` ${u.bold("Target:")} ${f.targetDir}`),console.info(` ${u.bold("Status:")} ${d}`),console.info(` ${u.bold("Risk:")} ${c}`),a.length>0){console.info(`
|
|
552
|
+
${u.bold("Security warnings:")}`);let p=new Map;for(let m of a){let y=p.get(m.category)||[];y.push(m),p.set(m.category,y)}for(let[m,y]of p){let g=["Shell commands","Code execution","Credentials"].includes(m)?u.red(`[${m}]`):u.yellow(`[${m}]`);console.info(`
|
|
553
|
+
${g} ${u.dim(`(${y.length} match${y.length>1?"es":""})`)}`);for(let b of y.slice(0,5))console.info(` ${u.dim(`${b.file}:${b.line}`)} -- ${b.match}`);y.length>5&&console.info(u.dim(` ... and ${y.length-5} more`))}}}}async function jv(e,t){return t?await Uo(e,t):await ps(e)}async function Bv(e){if(e.flags.help){_v();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;i||($("Missing required argument: <source>"),console.error('Run "asm install --help" for usage.'),process.exit(2));let n=null,r="github",o=8,a=0,l=f=>(a++,`
|
|
554
|
+
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(f)}`),c=()=>{n?oe(n).finally(()=>process.exit(1)):process.exit(1)};process.on("SIGINT",c),process.on("SIGTERM",c);try{if(!Ki(i)&&await qo(i)&&(i=`./${i}`),zt(i)){console.info(`
|
|
555
|
+
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:C,multipleMatches:N,suggestions:F}=await Bc(i,{noCache:e.flags.noCache});if(C){r="registry";let L=C.manifest,_=L.repository.replace("https://github.com/","");i=L.skill_path?`github:${_}#${L.commit}:${L.skill_path}`:`github:${_}#${L.commit}`,console.info(` ${u.green("\u2713")} Resolved: ${u.bold(`${L.author}/${L.name}`)} @ ${L.commit.slice(0,7)}`)}else if(N.length>0){console.info(`
|
|
556
|
+
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let L=N.slice(0,5);for(let ne=0;ne<L.length;ne++){let le=L[ne];console.info(` ${u.cyan(`${ne+1}.`)} ${u.bold(`${le.author}/${le.name}`)} \u2014 ${le.description}`)}process.stdin.isTTY||($(`Ambiguous skill name "${i}". Use a scoped name: asm install author/name`),process.exit(2));let _=`
|
|
557
|
+
Select a skill [1-${L.length}]: `;process.stderr.write(_);let ie=await new Promise(ne=>{let le="",ve=!1,ns=setTimeout(()=>{ve||(ve=!0,process.stdin.removeListener("data",ht),ne(le.trim()))},3e4);function ht(_d){le=_d.toString().trim(),ve||(ve=!0,clearTimeout(ns),process.stdin.removeListener("data",ht),ne(le))}process.stdin.setEncoding("utf-8"),process.stdin.on("data",ht)}),K=parseInt(ie,10);(isNaN(K)||K<1||K>L.length)&&($("Invalid selection. Aborting."),process.exit(2));let U=L[K-1];r="registry";let ze=U.repository.replace("https://github.com/","");i=U.skill_path?`github:${ze}#${U.commit}:${U.skill_path}`:`github:${ze}#${U.commit}`,console.info(` ${u.green("\u2713")} Selected: ${u.bold(`${U.author}/${U.name}`)} @ ${U.commit.slice(0,7)}`)}else Nr(i)?($(`Skill "${i}" not found in the registry.`),F.length>0&&console.error(`
|
|
558
|
+
Did you mean: ${F.map(L=>u.cyan(L)).join(", ")}?`),process.exit(1)):(console.info(` ${u.dim("Not found in registry \u2014 trying existing sources...")}`),r="pre-indexed")}console.info(l("Parsing source"));let f=Te(i),d=!!f.isLocal;if(d){let C=f.localPath;console.info(` ${u.dim(`local: ${C}`)}`);let{stat:N}=await import("fs/promises");try{if(!(await N(C)).isDirectory())throw new Error(`Path is not a directory: ${C}`)}catch(F){throw F.code==="ENOENT"?new Error(`Path does not exist: ${C}`):F}}else await De(),f=await ds(f),console.info(` ${u.dim(i)}`);if(e.flags.method==="vercel"){console.info(l("Installing via Vercel skills CLI")),await Vo();let C=Jo(f),N=e.flags.path||null;console.info(` ${u.dim(`npx skills add ${C}${N?` --skill ${N}`:""}`)}`);let{stdout:F,stderr:L}=await Ko(C,N);F.trim()&&console.info(` ${u.dim(F.trim())}`),L.trim()&&console.error(` ${u.dim(L.trim())}`),console.info(` ${u.green("\u2713")} Vercel skills CLI install completed`),e.flags.force=!0,console.info(` ${u.dim("Continuing with asm install to register in local inventory...")}`)}console.info(l("Selecting provider"));let p=await B(),{provider:m,allProviders:y}=await Xe(p,e.flags.provider,!!process.stdin.isTTY);console.info(l("Selecting scope"));let h;if(e.flags.scope==="global"||e.flags.scope==="project")h=e.flags.scope,console.info(` ${u.dim(`scope: ${h}`)}${h==="global"?` (${m.global})`:` (${m.project})`}`);else if(!process.stdin.isTTY||e.flags.yes)h="global",console.info(` ${u.dim("scope: global (default)")} (${m.global})`);else{let C=[{label:`Global (${m.global})`,hint:"Available in all projects",checked:!0},{label:`Project (${m.project})`,hint:"Available only in this project",checked:!1}];console.info("");let N=await Qe({items:C});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 C=e.flags.transport,N=C==="ssh"?f.sshCloneUrl:C==="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 _e(f,C)}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,A=g,E="";if(k){let C=b(g,k),N=!1;try{await Fe(C),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(C)).isDirectory())throw new Error(`No SKILL.md found at path "${k}" in the repository.`)}catch(L){throw L&&L.code==="ENOENT"?new Error(`No SKILL.md found at path "${k}" in the repository.`):L}v=!0,A=C,E=k}N&&(console.info(` Found skill at ${u.bold(k)}`),S=[{skillDir:C,nameOverride:e.flags.name}])}else{let C=!1;try{await Fe(g),C=!0}catch{}if(C){let N=await Fe(g);console.info(` Found: ${u.bold(N.name)} v${N.version}`),S=[{skillDir:g,nameOverride:e.flags.name}]}else v=!0}if(v){console.info(E?` No SKILL.md at ${u.bold(E)}. Scanning subdirectories...`:" No SKILL.md at root. Scanning subdirectories...");let C=await fs(A),N=E?C.map(_=>({..._,relPath:`${E}/${_.relPath}`})):C;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):
|
|
559
|
+
`);for(let _=0;_<N.length;_++){let ie=u.cyan(` ${String(_+1).padStart(String(N.length).length)})`);console.info(`${ie} ${u.bold(N[_].name)} ${u.dim(`v${N[_].version}`)} ${u.dim(`(${N[_].relPath})`)}`),N[_].description&&console.info(` ${u.dim(N[_].description)}`)}console.info(l("Selecting skills")),a--;let F;if(e.flags.all&&(e.flags.yes||!process.stdin.isTTY))F=N.map(_=>_.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 _=N.map(K=>({label:K.name,hint:`v${K.version}${K.description?" "+K.description:""}`,checked:!!e.flags.all}));console.info("");let ie=await Qe({items:_});if(ie.length===0)throw new Error("No skills selected. Aborting.");F=ie.map(K=>N[K].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.
|
|
558
560
|
Available skills:
|
|
559
561
|
${N.map(_=>` --path ${_.relPath}`).join(`
|
|
560
|
-
`)}`),process.exit(2);return}let
|
|
562
|
+
`)}`),process.exit(2);return}let L=jo(F);if(L.length>0){let _=L.map(K=>` - ${K.name}: ${K.paths.map(U=>`"${U}"`).join(", ")}`).join(`
|
|
561
563
|
`),ie=new Error(`Duplicate skill names detected in selection:
|
|
562
564
|
${_}
|
|
563
|
-
Choose one path per skill name or install with --path.`);throw ie.duplicates=
|
|
565
|
+
Choose one path per skill name or install with --path.`);throw ie.duplicates=L,ie}S=F.map(_=>({skillDir:b(g,_),nameOverride:F.length===1?e.flags.name:null})),a++}console.info(l("Inspecting skills"));let x=await ee(p,"both"),M=[],O=S.length>1;for(let C=0;C<S.length;C++){let{skillDir:N,nameOverride:F}=S[C],L=await Fv(e,f,g,N,F,p,m,x,h);M.push(L),qv(L,i,m,y,O,O?{index:C+1,total:S.length}:void 0)}if(O){console.info(""),console.info(` ${u.bold("Install settings:")}`),console.info(` ${u.bold("Source:")} ${i}`),console.info(y?` ${u.bold("Tool:")} All (${y.map(_=>_.label).join(", ")})`:` ${u.bold("Tool:")} ${m.label} (${m.name})`),console.info(` ${u.bold("Scope:")} ${h==="project"?"Project":"Global"}`);let C=M.filter(_=>_.riskLevel==="high").length,N=M.filter(_=>_.riskLevel==="medium").length,F=M.filter(_=>_.riskLevel==="safe").length,L=[];F>0&&L.push(u.green(`${F} Safe`)),N>0&&L.push(u.yellow(`${N} Medium Risk`)),C>0&&L.push(u.red(`${C} High Risk`)),console.info(` ${u.bold("Risk:")} ${L.join(", ")}`)}if(console.info(l("Installing")),!e.flags.yes){let C=M.some(_=>_.riskLevel==="high");process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2));let N=O?`${M.length} skills`:`"${M[0].metadata.name}"`,F=C?`
|
|
564
566
|
${u.red("[!]")} ${u.bold(`Install ${N}? Some have high-risk patterns.`)} [y/N] `:`
|
|
565
|
-
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(
|
|
566
|
-
${u.yellow(`${T.length} skill(s) failed to install:`)}`);for(let
|
|
567
|
+
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(F);let L=await Q();C?L.toLowerCase()!=="y"&&L.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)):(L.toLowerCase()==="n"||L.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let D=n?await Po(n):null,T=[];for(let C=0;C<M.length;C++){let N=M[C],F=O?u.dim(`[${C+1}/${M.length}]`)+" ":" ";try{console.info(`${F}Installing ${u.bold(N.metadata.name)}...`);let L=await jv(N.plan,y);w.push(L),console.info(`${F}${u.green("\u2713")} ${N.metadata.name} installed to ${u.dim(N.plan.targetDir)}`);try{let _=d?`local:${f.localPath}`:`github:${f.owner}/${f.repo}`,ie=d?"local":r==="registry"?"registry":"github";await bt(L.name,{source:_,commitHash:D||"unknown",ref:f.ref||"main",installedAt:new Date().toISOString(),provider:N.plan.providerName,sourceType:ie,...r==="registry"?{registryName:L.name}:{}})}catch{}}catch(L){T.push({name:N.metadata.name,error:L.message}),console.error(`${F}${u.red("\u2717")} ${u.bold(N.metadata.name)} \u2014 ${u.red(L.message)}`)}}if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),T.length>0){console.error(`
|
|
568
|
+
${u.yellow(`${T.length} skill(s) failed to install:`)}`);for(let C of T)console.error(` ${u.red("\u2717")} ${C.name}: ${C.error}`)}if(e.flags.machine){t?.();let C=w.map(N=>({name:N.name,path:N.path,version:N.version,provider:N.provider,source:N.source,resolution_source:r}));console.log(z("install",C.length===1?C[0]:C,s))}else if(e.flags.json){let C=w.map(N=>({...N,resolutionSource:r}));console.log(JSON.stringify(C.length===1?C[0]:C,null,2))}else w.length===1?console.error(u.green(`
|
|
567
569
|
Done! Installed "${w[0].name}" to ${w[0].path}`)):w.length>0&&console.error(`
|
|
568
|
-
${u.green(`Done! Installed ${w.length} skill(s) successfully.`)}`)}catch(
|
|
570
|
+
${u.green(`Done! Installed ${w.length} skill(s) successfully.`)}`)}catch(f){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(Z("install",X.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 oe(n),t?.()}}function Uv(){console.log(`${u.bold("Usage:")} asm export [options]
|
|
569
571
|
|
|
570
572
|
Export skill inventory as a portable JSON manifest. Useful for backup,
|
|
571
573
|
sharing, or scripting.
|
|
@@ -578,7 +580,7 @@ ${u.bold("Options:")}
|
|
|
578
580
|
${u.bold("Examples:")}
|
|
579
581
|
asm export ${u.dim("Export all skills")}
|
|
580
582
|
asm export -s global ${u.dim("Export global skills only")}
|
|
581
|
-
asm export > skills.json ${u.dim("Save to file")}`)}async function
|
|
583
|
+
asm export > skills.json ${u.dim("Save to file")}`)}async function Vv(e){if(e.flags.help){Uv();return}let t=await B(),s=await ee(t,e.flags.scope),i=Uc(s);console.log(JSON.stringify(i,null,2))}function Kv(){console.log(`${u.bold("Usage:")} asm import <file> [options]
|
|
582
584
|
|
|
583
585
|
Import skills from a previously exported JSON manifest. Recreates skill
|
|
584
586
|
installations based on the manifest metadata.
|
|
@@ -600,9 +602,9 @@ ${u.bold("Examples:")}
|
|
|
600
602
|
asm import skills.json --force ${u.dim("Overwrite existing skills")}
|
|
601
603
|
asm import skills.json -s global ${u.dim("Import only global skills")}
|
|
602
604
|
asm export > backup.json ${u.dim("Export first, then import later")}
|
|
603
|
-
asm import backup.json ${u.dim("Restore from backup")}`)}async function
|
|
604
|
-
${u.bold("Proceed?")} [y/N] `);let l=await Q();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await
|
|
605
|
-
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let l of a.results){let c=l.status==="installed"?u.green("+++"):l.status==="skipped"?u.yellow("---"):l.status==="dry-run"?u.cyan("~~~"):u.red("!!!"),
|
|
605
|
+
asm import backup.json ${u.dim("Restore from backup")}`)}async function Jv(e){if(e.flags.help){Kv();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 Hc(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(`
|
|
606
|
+
${u.bold("Proceed?")} [y/N] `);let l=await Q();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await Wc(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(`
|
|
607
|
+
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let l of a.results){let c=l.status==="installed"?u.green("+++"):l.status==="skipped"?u.yellow("---"):l.status==="dry-run"?u.cyan("~~~"):u.red("!!!"),f=l.reason?` ${u.dim(l.reason)}`:"",d=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${f}${d}`)}console.error(""),console.error(`${u.bold("Summary:")} ${a.total} total, ${u.green(String(a.installed))} installed, ${u.yellow(String(a.skipped))} skipped, ${u.red(String(a.failed))} failed`),a.failed>0&&(process.exitCode=1)}function Hv(){console.log(`${u.bold("Usage:")} asm init <name> [options]
|
|
606
608
|
|
|
607
609
|
Scaffold a new skill directory with a SKILL.md template. Creates a
|
|
608
610
|
ready-to-edit skill in the target tool's skill folder.
|
|
@@ -617,8 +619,8 @@ ${u.bold("Options:")}
|
|
|
617
619
|
${u.bold("Examples:")}
|
|
618
620
|
asm init my-skill ${u.dim("Scaffold (interactive tool)")}
|
|
619
621
|
asm init my-skill -p claude ${u.dim("Scaffold in Claude Code")}
|
|
620
|
-
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function
|
|
621
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await Q();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await
|
|
622
|
+
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function Wv(e){if(e.flags.help){Hv();return}let t=e.subcommand;t||($("Missing required argument: <name>"),console.error('Run "asm init --help" for usage.'),process.exit(2));let s=Me(t),i;if(e.flags.path){let{resolve:n}=await import("path");i=n(e.flags.path)}else{let n=await B(),{provider:r}=await Xe(n,e.flags.provider,!!process.stdin.isTTY),{join:o}=await import("path"),{resolveProviderPath:a}=await import("./config-7PXPKO4K.js"),l=a(n.providers.find(c=>c.name===r.name).global);i=o(l,s)}if(await Yc(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}`)}
|
|
623
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await Q();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await Gc(s,i),console.error(u.green(`Done! Created skill "${s}" at ${i}`))}function Gv(){console.log(`${u.bold("Usage:")} asm stats [options]
|
|
622
624
|
|
|
623
625
|
Show aggregate skill metrics with provider distribution charts,
|
|
624
626
|
scope breakdown, disk usage, and duplicate summary.
|
|
@@ -632,7 +634,7 @@ ${u.bold("Options:")}
|
|
|
632
634
|
${u.bold("Examples:")}
|
|
633
635
|
asm stats ${u.dim("Show full dashboard")}
|
|
634
636
|
asm stats -s global ${u.dim("Global skills only")}
|
|
635
|
-
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function
|
|
637
|
+
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function Yv(e){if(e.flags.help){Gv();return}let t=await B(),s=await ee(t,e.flags.scope);if(s.length===0){console.log("No skills found.");return}let i=Di(s),n=await Qc(s,i);if(e.flags.json)if(e.flags.verbose)console.log(G(n));else{let{perSkillDiskBytes:r,...o}=n;console.log(G(o))}else console.log(Xc(n))}function zv(){console.log(`${u.bold("Usage:")} asm doctor [options]
|
|
636
638
|
|
|
637
639
|
Run environment health checks and diagnostics. Validates all
|
|
638
640
|
prerequisites for using asm \u2014 git, GitHub CLI, Node.js, config,
|
|
@@ -647,7 +649,7 @@ ${u.bold("Options:")}
|
|
|
647
649
|
${u.bold("Examples:")}
|
|
648
650
|
asm doctor ${u.dim("Run all health checks")}
|
|
649
651
|
asm doctor --json ${u.dim("Output as JSON")}
|
|
650
|
-
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function
|
|
652
|
+
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function Qv(e){if(e.flags.help){zv();return}let t=performance.now(),s=await Vu();if(e.flags.machine){let i={checks:s.checks.map(n=>({name:n.name,status:n.status,message:n.message,...n.fix?{fix:n.fix}:{}})),passed:s.passed,warnings:s.warnings,failures:s.failures};console.log(z("doctor",i,t))}else e.flags.json?console.log(Ju(s)):console.log(Ku(s));s.failures>0&&process.exit(1)}function Xv(){console.log(`${u.bold("Usage:")} asm eval <target> [options]
|
|
651
653
|
|
|
652
654
|
Evaluate a skill's SKILL.md against best practices and produce a scored quality
|
|
653
655
|
report with recommendations. Zero configuration \u2014 just point it at a skill
|
|
@@ -683,8 +685,8 @@ ${u.bold("Examples:")}
|
|
|
683
685
|
asm eval ./my-skill --fix ${u.dim("Auto-fix deterministic issues")}
|
|
684
686
|
asm eval ./my-skill --fix --dry-run ${u.dim("Preview fixes as diff")}
|
|
685
687
|
asm eval ./my-skill --machine ${u.dim("Machine-readable v1 envelope")}
|
|
686
|
-
asm eval-providers list ${u.dim("List registered eval providers")}`)}function
|
|
687
|
-
`))}function
|
|
688
|
+
asm eval-providers list ${u.dim("List registered eval providers")}`)}function Zv(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 ek(e,t,s){await De();let i=Te(e);if(i.isLocal)throw new Error(`fetchRemoteForEval received a local path: "${e}". This is a bug \u2014 local paths should use the non-remote branch.`);i=await ds(i);let n=await _e(i,t),r=i.subpath?Od(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 oe(n)},sourceRef:a,commitSha:o}}async function Ld(e){Ci();try{let t={skillPath:e.skillPath,skillMdPath:e.skillMdPath},s=(await Promise.all(ss(Pi()).map(async r=>(await r.applicable(t,{})).ok?Ni(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 Zv(i),{report:{...i.raw,providers:ss(s.map($d))},error:null}}catch(t){return{report:null,error:t?.message??String(t)}}}async function tk(e){if(e.flags.help){Xv();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;if(i||(e.flags.machine&&(t?.(),console.log(Z("eval",X.INVALID_ARGUMENT,"Missing required argument: <skill-path>",s)),process.exit(2)),$("Missing required argument: <skill-path>"),console.error('Run "asm eval --help" for usage.'),process.exit(2)),e.flags.fix){if(Qr(i)){let r="--fix is only supported for local skill paths. Clone the repo first or run `asm install` to materialise it locally.";e.flags.machine&&(t?.(),console.log(Z("eval",X.INVALID_ARGUMENT,r,s)),process.exit(2)),$(r),process.exit(2)}try{let r=await td(),o=await ed(i,{dryRun:e.flags.dryRun,gitAuthor:r});if(e.flags.machine){t?.(),console.log(z("eval",$i(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(Si(o.report)),console.log(""),console.log(id(o));return}catch(r){e.flags.machine&&(t?.(),console.log(Z("eval",X.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}return}let n=null;try{n=await nd(i,{fetchRemote:r=>ek(r,e.flags.transport,e.flags.keep)})}catch(r){e.flags.machine&&(t?.(),console.log(Z("eval",X.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}try{if(!n.isCollection&&n.targets.length===1){let c=n.targets[0],{report:f,error:d}=await Ld(c);if(!f)throw new Error(d??"eval failed");if(e.flags.machine){t?.();let p=$i(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(z("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(sd(f));return}console.log(Si(f)),n.provenance.remote&&sk(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 od(n.targets,r,async c=>{let{report:f,error:d}=await Ld(c);return{label:c.label,skillPath:c.skillPath,report:f,error:d}}),a=rd(o),l={provenance:n.provenance,aggregate:a,results:o};if(e.flags.machine){t?.(),console.log(z("eval",ld(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(Si(c.report)):(console.log(`Skill evaluation: ${c.skillPath}`),console.log(` ${u.red("error:")} ${c.error??"unknown failure"}`)),console.log("");console.log(ad(l)),n.provenance.remote&&e.flags.verbose}catch(r){e.flags.machine&&(t?.(),console.log(Z("eval",X.SKILL_NOT_FOUND,r?.message??String(r),s)),process.exit(1)),$(r?.message??String(r)),process.exit(1)}finally{if(n)try{await n.cleanup()}catch{}}}function sk(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(`
|
|
689
|
+
`))}function ik(){console.log(`${u.bold("Usage:")} asm eval-providers <subcommand> [options]
|
|
688
690
|
|
|
689
691
|
Manage evaluation providers registered with the ${u.bold("asm eval")} framework.
|
|
690
692
|
Providers implement the ${u.bold("EvalProvider")} contract (see src/eval/types.ts) and
|
|
@@ -700,7 +702,7 @@ ${u.bold("Options:")}
|
|
|
700
702
|
|
|
701
703
|
${u.bold("Examples:")}
|
|
702
704
|
asm eval-providers list ${u.dim("Show registered providers")}
|
|
703
|
-
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function
|
|
705
|
+
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function nk(e){if(e.flags.help){ik();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":{Ci();let s=xi();if(e.flags.json){console.log(G(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 rk(){console.log(`${u.bold("Usage:")} asm link <path> [<path2> ...] [options]
|
|
704
706
|
|
|
705
707
|
Symlink a local skill directory into an agent's skill folder. Useful
|
|
706
708
|
for local development \u2014 changes to the source are reflected immediately.
|
|
@@ -724,13 +726,13 @@ ${u.bold("Examples:")}
|
|
|
724
726
|
asm link ./my-skill -p claude ${u.dim("Link to Claude Code")}
|
|
725
727
|
asm link ./my-skill --name alias ${u.dim("Link with custom name")}
|
|
726
728
|
asm link ./my-skills-folder ${u.dim("Link all skills in folder")}
|
|
727
|
-
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function
|
|
728
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await Q();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function
|
|
729
|
+
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function ok(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}`)}
|
|
730
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await Q();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function Ii(e,t,s,i){let{join:n}=await import("path"),r=n(t,s),o=await ok(r,i);return await tu(e,t,s,o),{name:s,symlinkPath:r,targetPath:e}}async function ak(e){if(e.flags.help){rk();return}let t=[];if(e.subcommand&&t.push(e.subcommand),t.push(...e.positional),t.length===0&&($("Missing required argument: <path>"),console.error('Run "asm link --help" for usage.'),process.exit(2)),t.length>1){e.flags.name&&($("--name cannot be used when linking multiple paths. Link each skill individually to use --name."),process.exit(2));let y=await B(),{provider:h}=await Xe(y,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:g}=await import("./config-7PXPKO4K.js"),b=g(y.providers.find(A=>A.name===h.name).global),{resolve:w,basename:k}=await import("path"),S=[],v=[];for(let A of t){let E=w(A),x=!1,M=null;try{await Lr(E),x=!0}catch(O){let D=O instanceof Error?O.message:String(O);D.startsWith("Path does not exist")||D.startsWith("Path is not a directory")||D.startsWith("No SKILL.md found")||(M=D)}if(M){v.push({name:A,error:M}),e.flags.json||console.error(u.red(` Failed to process "${A}": ${M}`));continue}if(x){let O=k(E);try{let D=await Ii(E,b,O,!!e.flags.force);S.push(D),e.flags.json||console.error(u.green(` Linked "${D.name}" -> ${D.targetPath}`))}catch(D){let T=D instanceof Error?D.message:String(D);v.push({name:O,error:T}),e.flags.json||console.error(u.red(` Failed to link "${O}": ${T}`))}}else{let O=[];try{O=await Or(E)}catch(D){let T=D instanceof Error?D.message:String(D),C=T;T.startsWith("Path does not exist")&&zt(A)&&(C=`${T} \u2014 "${A}" looks like a registry name; try "asm install ${A}" first.`),v.push({name:A,error:C}),e.flags.json||console.error(u.red(` Failed to process "${A}": ${C}`));continue}if(O.length===0){let D=`No SKILL.md found in ${E} or its immediate subdirectories.`;v.push({name:A,error:D}),e.flags.json||console.error(u.red(` ${D}`));continue}for(let D of O)try{let T=await Ii(D.absPath,b,D.dirName,!!e.flags.force);S.push(T),e.flags.json||console.error(u.green(` Linked "${T.name}" -> ${T.targetPath}`))}catch(T){let C=T instanceof Error?T.message:String(T);v.push({name:D.name,error:C}),e.flags.json||console.error(u.red(` Failed to link "${D.name}": ${C}`))}}}e.flags.json?console.log(G({success:v.length===0,linked:S,failures:v})):v.length>0?console.error(u.yellow(`
|
|
729
731
|
${S.length} linked, ${v.length} failed.`)):console.error(u.green(`
|
|
730
|
-
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
|
|
731
|
-
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await Q();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],
|
|
732
|
-
${p.length} linked, ${
|
|
733
|
-
Done! Linked ${p.length} skill(s) successfully.`)),
|
|
732
|
+
Done! Linked ${S.length} skill(s) successfully.`)),v.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await Lr(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 Or(r)}catch(y){let h=y instanceof Error?y.message:String(y);h.startsWith("Path does not exist")?($(`No such skill or path: ${s}`),zt(s)?(console.error(` "${s}" looks like a registry name, not a local path.`),console.error(` Install it first: ${u.bold(`asm install ${s}`)}`),console.error(` Or pass a local path: ${u.bold(`asm link ./path/to/${s}`)}`)):console.error(' Pass a local directory containing SKILL.md, or run "asm install <name>" first.')):$(h),process.exit(1)}a.length===0&&($(`No SKILL.md found in ${r} or its immediate subdirectories.`),process.exit(1)),e.flags.name&&a.length>1&&($(`--name cannot be used when linking multiple skills (found ${a.length} skills). Link each skill individually to use --name.`),process.exit(2))}let l=await B(),{provider:c}=await Xe(l,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:f}=await import("./config-7PXPKO4K.js"),d=f(l.providers.find(y=>y.name===c.name).global);if(o){let y=e.flags.name?Me(e.flags.name):n(r),h;try{h=await Ii(r,d,y,!!e.flags.force)}catch(g){let b=g instanceof Error?g.message:String(g);e.flags.json?console.log(G({success:!1,error:b})):$(b),process.exit(2)}e.flags.json?console.log(G({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(`
|
|
733
|
+
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await Q();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],m=[];for(let y of a){let h=e.flags.name&&a.length===1?Me(e.flags.name):y.dirName;try{let g=await Ii(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(G({success:m.length===0,linked:p,failures:m})):m.length>0?console.error(u.yellow(`
|
|
734
|
+
${p.length} linked, ${m.length} failed.`)):console.error(u.green(`
|
|
735
|
+
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}function lk(){console.log(`${u.bold("Usage:")} asm index <subcommand> [options]
|
|
734
736
|
|
|
735
737
|
Manage the skill index for searching available skills from indexed repos.
|
|
736
738
|
|
|
@@ -754,10 +756,10 @@ ${u.bold("Examples:")}
|
|
|
754
756
|
asm index search marketing --has license ${u.dim("Only with license")}
|
|
755
757
|
asm index search "" --missing creator ${u.dim("Skills missing creator")}
|
|
756
758
|
asm index list ${u.dim("List indexed repos")}
|
|
757
|
-
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function
|
|
758
|
-
`));for(let o of r){let a=o.skill.verified?u.blue(" [verified]"):"";console.error(`${u.cyan(o.skill.name)} ${u.dim(`v${o.skill.version}`)}${a} ${u.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let c of
|
|
759
|
-
`)}}break}case"list":{let s=await
|
|
760
|
-
`));for(let n of s)console.error(`${u.cyan(`${n.owner}/${n.repo}`)} - ${n.skillCount} skills ${u.dim(`(${new Date(n.updatedAt).toLocaleDateString()})`)}`)}break}case"remove":{let s=e.positional[0];s||($("Missing required argument: <owner/repo>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let[i,n]=s.split("/");if((!i||!n)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove")} ${u.cyan(`${i}/${n}`)} ${u.bold("from index?")} [y/N] `);let o=await Q();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await
|
|
759
|
+
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function ck(e){if(e.flags.help){lk();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 Pd(s);i.success||($(`Failed to ingest: ${i.error}`),process.exit(1)),i.repoIndex&&(e.flags.json?console.log(G({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 fi(s||"",20,i):await fi(s);if(r.length===0){e.flags.json?console.log(G([])):(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(G(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:
|
|
760
|
+
`));for(let o of r){let a=o.skill.verified?u.blue(" [verified]"):"";console.error(`${u.cyan(o.skill.name)} ${u.dim(`v${o.skill.version}`)}${a} ${u.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let c of Eo(o.skill.description,80))console.error(` ${c}`);let l=ru(o.skill);l.length>0&&console.error(` ${u.yellow(`\u26A0 Missing: ${l.join(", ")}`)}`),console.error(` ${u.green(`asm install ${o.skill.installUrl}`)}
|
|
761
|
+
`)}}break}case"list":{let s=await Nd();if(s.length===0){e.flags.json?console.log(G([])):(console.info("No repositories indexed."),console.error(u.dim("Add repos with: asm index ingest <repo>")));return}let i=await ou();if(e.flags.json)console.log(G(s));else{console.error(u.bold(`Indexed Repositories (${i} total skills):
|
|
762
|
+
`));for(let n of s)console.error(`${u.cyan(`${n.owner}/${n.repo}`)} - ${n.skillCount} skills ${u.dim(`(${new Date(n.updatedAt).toLocaleDateString()})`)}`)}break}case"remove":{let s=e.positional[0];s||($("Missing required argument: <owner/repo>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let[i,n]=s.split("/");if((!i||!n)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove")} ${u.cyan(`${i}/${n}`)} ${u.bold("from index?")} [y/N] `);let o=await Q();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await Id(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 uk(){console.log(`${u.bold("Usage:")} asm bundle <subcommand> [options]
|
|
761
763
|
|
|
762
764
|
Create, install, and manage curated skill bundles. A bundle is a reusable
|
|
763
765
|
recipe of skills for a particular workflow, domain, or project setup.
|
|
@@ -793,14 +795,14 @@ ${u.bold("Examples:")}
|
|
|
793
795
|
asm bundle modify my-workflow --add github:u/r ${u.dim("Add a skill to bundle")}
|
|
794
796
|
asm bundle modify my-workflow --remove skill ${u.dim("Remove a skill from bundle")}
|
|
795
797
|
asm bundle export my-workflow ${u.dim("Export to ./my-workflow.json")}
|
|
796
|
-
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function
|
|
797
|
-
`));let g=await Qe({items:
|
|
798
|
-
${u.bold("Description")} (optional, press Enter to skip): `);let
|
|
799
|
-
${u.bold("Install all skills from this bundle?")} [y/N] `);let
|
|
800
|
-
Installing ${u.bold(
|
|
798
|
+
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function dk(e){if(e.flags.help){uk();return}let t=e.subcommand;switch(t||($("Missing subcommand. Use: create, install, list, show, remove, modify, or export"),console.error('Run "asm bundle --help" for usage.'),process.exit(2)),t){case"create":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle create <name>"),process.exit(2));let i=await B(),n=await ee(i,e.flags.scope);n.length===0&&($("No skills found to include in the bundle."),process.exit(1));let r=new Set,o=n.filter(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}":
|
|
799
|
+
`));let g=await Qe({items:h});g.length===0&&($("No skills selected. Bundle not created."),process.exit(1)),a=g.map(b=>o[b])}let{readLock:l}=await import("./lock-MDX7A2DF.js"),c=await l(),f=await Promise.all(a.map(h=>wu(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(`
|
|
800
|
+
${u.bold("Description")} (optional, press Enter to skip): `);let h=await Q();h.trim()&&(d=h.trim()),process.stderr.write(`${u.bold("Author")} (optional, press Enter to skip): `);let g=await Q();g.trim()&&(p=g.trim())}let m=bu(s,d,p,f),y=await _r(m);e.flags.json?console.log(JSON.stringify(m,null,2)):(console.error(u.green(`Bundle "${s}" created with ${f.length} skill(s).`)),console.error(` Saved to: ${u.dim(y)}`));break}case"install":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle install <name|file>"),process.exit(2));let i;try{i=await es(s)}catch(d){$(d.message),process.exit(1)}console.error(`${u.bold("Bundle:")} ${i.name} (${i.skills.length} skills)`),i.description&&console.error(` ${u.dim(i.description)}`),console.error("");for(let d of i.skills){let p=d.version?` v${d.version}`:"";console.error(` ${u.cyan(d.name)}${u.dim(p)} ${u.dim(`-> ${d.installUrl}`)}`)}if(!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
801
|
+
${u.bold("Install all skills from this bundle?")} [y/N] `);let d=await Q();d.toLowerCase()!=="y"&&d.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let n=[],r=await B(),{provider:o}=await Xe(r,e.flags.provider,!1),a=e.flags.scope==="global"||e.flags.scope==="project"?e.flags.scope:"global";for(let d of i.skills){console.error(`
|
|
802
|
+
Installing ${u.bold(d.name)}...`);try{(d.installUrl.startsWith("github:")||d.installUrl.startsWith("https://github.com/"))&&await De();let m=Te(d.installUrl),y=!!m.isLocal,h=null;try{let g,b;y?(g=m.localPath,b=m.localPath):(h=await _e(m,e.flags.transport),g=h,b=m.subpath?Od(h,m.subpath):h);let w=await Fe(b),k=Me(d.name||w.name||m.repo),S=Ji(m,g,b,k,o,e.flags.force,a);try{await Ho(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 ps(S),n.push({name:d.name,status:"installed"}),console.error(` ${u.green("+++")} ${d.name} installed`)}finally{h&&await oe(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 vu();if(n.length===0){e.flags.json?console.log("[]"):console.log("No predefined bundles found.");return}if(e.flags.json)console.log(JSON.stringify(n,null,2));else{console.error(u.bold(`Pre-defined Bundles (${n.length}):
|
|
801
803
|
`));for(let r of n){let o=r.tags&&r.tags.length>0?` ${u.dim(`[${r.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(r.name)} ${u.dim(`(${r.skills.length} skills)`)}${o}`),r.description&&console.error(` ${u.dim(r.description)}`)}console.error(`
|
|
802
|
-
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await
|
|
803
|
-
`));for(let n of i){let r=n.tags&&n.tags.length>0?` ${u.dim(`[${n.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(n.name)} ${u.dim(`(${n.skills.length} skills)`)}${r}`),n.description&&console.error(` ${u.dim(n.description)}`),n.author&&console.error(` ${u.dim(`by ${n.author}`)}`)}}break}case"show":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle show <name|file>"),process.exit(2));let i;try{i=await
|
|
804
|
-
${u.bold(`Skills (${i.skills.length})`)}:`);for(let n of i.skills){let r=n.version?` v${n.version}`:"";console.error(` ${u.cyan(n.name)}${u.dim(r)}`),n.description&&console.error(` ${u.dim(n.description)}`),console.error(` ${u.dim(`install: ${n.installUrl}`)}`)}}break}case"remove":{let s=e.positional[0];if(s||($("Missing required argument: <name>"),console.error("Usage: asm bundle remove <name>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove bundle")} ${u.cyan(s)}${u.bold("?")} [y/N] `);let n=await Q();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await
|
|
805
|
-
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(u.green(`Exported to ${o}`));break}default:$(`Unknown subcommand: "${t}". Use: create, install, list, show, remove, modify, or export`),console.error('Run "asm bundle --help" for usage.'),process.exit(2)}}async function
|
|
806
|
-
`)),console.log(JSON.stringify(n.manifest,null,2));return}n.prUrl&&(console.error(u.green("Published successfully!")),console.error(""),console.error(` PR: ${n.prUrl}`),console.error(` Manifest: manifests/${n.manifest?.author}/${n.manifest?.name}.json`),console.error(` Security: ${n.securityVerdict}`),console.error(""),console.error(u.dim("The registry maintainers will review your submission.")))}catch(n){let r={success:!1,manifest:null,prUrl:null,error:n.message,securityVerdict:"pass",securityReport:{scannedAt:new Date().toISOString(),skillName:"",skillPath:"",source:null,codeScans:[],permissions:[],totalFiles:0,totalLines:0,verdict:"safe",verdictReason:""}};e.flags.machine&&(t?.(),console.log(Z("publish",X.PUBLISH_FAILED,n.message,s)),process.exit(1)),e.flags.json&&(console.log(JSON.stringify({success:!1,manifest:null,pr_url:null,error:n.message,security_verdict:null},null,2)),process.exit(1)),$(n.message),process.exit(1)}}async function
|
|
804
|
+
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await Su();if(i.length===0){e.flags.json?console.log("[]"):(console.log("No bundles found."),console.error(u.dim("Create one with: asm bundle create <name>")),console.error(u.dim("List pre-defined bundles with: asm bundle list --predefined")));return}if(e.flags.json)console.log(JSON.stringify(i,null,2));else{console.error(u.bold(`Saved Bundles (${i.length}):
|
|
805
|
+
`));for(let n of i){let r=n.tags&&n.tags.length>0?` ${u.dim(`[${n.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(n.name)} ${u.dim(`(${n.skills.length} skills)`)}${r}`),n.description&&console.error(` ${u.dim(n.description)}`),n.author&&console.error(` ${u.dim(`by ${n.author}`)}`)}}break}case"show":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle show <name|file>"),process.exit(2));let i;try{i=await es(s)}catch(n){$(n.message),process.exit(1)}if(e.flags.json)console.log(JSON.stringify(i,null,2));else{console.error(u.bold(`Bundle: ${i.name}`)),i.description&&console.error(` ${i.description}`),i.author&&console.error(` ${u.dim(`Author: ${i.author}`)}`),console.error(` ${u.dim(`Created: ${new Date(i.createdAt).toLocaleString()}`)}`),i.tags&&i.tags.length>0&&console.error(` ${u.dim(`Tags: ${i.tags.join(", ")}`)}`),console.error(`
|
|
806
|
+
${u.bold(`Skills (${i.skills.length})`)}:`);for(let n of i.skills){let r=n.version?` v${n.version}`:"";console.error(` ${u.cyan(n.name)}${u.dim(r)}`),n.description&&console.error(` ${u.dim(n.description)}`),console.error(` ${u.dim(`install: ${n.installUrl}`)}`)}}break}case"remove":{let s=e.positional[0];if(s||($("Missing required argument: <name>"),console.error("Usage: asm bundle remove <name>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove bundle")} ${u.cyan(s)}${u.bold("?")} [y/N] `);let n=await Q();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await $u(s)}catch(n){$(n.message),process.exit(1)}i?console.error(u.green(`Bundle "${s}" removed.`)):($(`Bundle "${s}" not found.`),process.exit(1));break}case"modify":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle modify <name> [--add <installUrl>] [--remove <skillName>] [--description <desc>] [--author <author>] [--tags <tag,...>]"),process.exit(2));let i;try{i=await es(s)}catch(d){$(d.message),process.exit(1)}let n=!1,r=e.flags.add;if(r){let d={name:r.split("/").pop()?.replace(/\.json$/,"")??r,installUrl:r};i.skills.push(d),n=!0,console.error(u.green(`Added skill from ${r}`))}let o=e.flags.remove;if(o){let d=i.skills.length;i.skills=i.skills.filter(p=>p.name.toLowerCase()!==o.toLowerCase()),i.skills.length<d?(n=!0,console.error(u.green(`Removed skill "${o}"`))):console.error(u.dim(`Skill "${o}" not found in bundle (no change)`))}let a=e.flags.description;a!==null&&(i.description=a,n=!0);let l=e.flags.author;l!==null&&(i.author=l,n=!0);let c=e.flags.tags;if(c!==null&&(i.tags=c.split(",").map(d=>d.trim()).filter(d=>d.length>0),n=!0),!n&&process.stdin.isTTY&&!e.flags.yes&&!r&&!o&&a===null&&l===null&&c===null){console.error(u.bold(`Modifying bundle "${i.name}"`)),console.error(` Current skills: ${i.skills.map(y=>y.name).join(", ")}`),console.error(` Description: ${i.description}`),console.error(` Author: ${i.author}`),console.error(` Tags: ${i.tags?.join(", ")??"(none)"}`),console.error(""),process.stderr.write(`${u.bold("New description")} (Enter to keep current): `);let d=await Q();d.trim()&&(i.description=d.trim(),n=!0),process.stderr.write(`${u.bold("New author")} (Enter to keep current): `);let p=await Q();p.trim()&&(i.author=p.trim(),n=!0),process.stderr.write(`${u.bold("New tags (comma-separated)")} (Enter to keep current): `);let m=await Q();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 _r(i);e.flags.json?console.log(JSON.stringify(i,null,2)):(console.error(u.green(`Bundle "${i.name}" updated (${i.skills.length} skill(s)).`)),console.error(` Saved to: ${u.dim(f)}`));break}case"export":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle export <name> [output-file]"),process.exit(2));let i;try{i=await es(s)}catch(l){$(l.message),process.exit(1)}let n=e.positional[1]??`./${s}.json`,{resolve:r}=await import("path"),o=r(n);if(!e.flags.force){let{access:l}=await import("fs/promises");try{if(await l(o),process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`File ${u.bold(o)} already exists. Overwrite? [y/N] `);let c=await Q();c.toLowerCase()!=="y"&&c.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}else e.flags.yes||($(`File "${o}" already exists. Use --force to overwrite.`),process.exit(1))}catch{}}let{writeFile:a}=await import("fs/promises");await a(o,JSON.stringify(i,null,2)+`
|
|
807
|
+
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(u.green(`Exported to ${o}`));break}default:$(`Unknown subcommand: "${t}". Use: create, install, list, show, remove, modify, or export`),console.error('Run "asm bundle --help" for usage.'),process.exit(2)}}async function fk(e){if(e.flags.help){$v();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand||".";try{let n=await Nu({path:i,dryRun:e.flags.dryRun,force:e.flags.force,yes:e.flags.yes});if(e.flags.machine){t?.(),n.success||(console.log(Z("publish",X.PUBLISH_FAILED,n.error||"Publish failed",s,{manifest:n.manifest,security_verdict:n.securityVerdict,fallback:n.fallback??!1})),process.exit(1)),console.log(z("publish",{manifest:n.manifest,pr_url:n.prUrl,status:n.securityVerdict},s));return}if(e.flags.json){console.log(JSON.stringify({success:n.success,manifest:n.manifest,pr_url:n.prUrl,error:n.error,security_verdict:n.securityVerdict},null,2)),n.success||process.exit(1);return}if(n.success||($(n.error||"Publish failed."),process.exit(1)),n.fallback){console.log(u.yellow("Manifest generated (gh CLI unavailable):")),console.log(Iu(n));return}if(e.flags.dryRun){console.error(u.dim(`Dry run \u2014 no PR created.
|
|
808
|
+
`)),console.log(JSON.stringify(n.manifest,null,2));return}n.prUrl&&(console.error(u.green("Published successfully!")),console.error(""),console.error(` PR: ${n.prUrl}`),console.error(` Manifest: manifests/${n.manifest?.author}/${n.manifest?.name}.json`),console.error(` Security: ${n.securityVerdict}`),console.error(""),console.error(u.dim("The registry maintainers will review your submission.")))}catch(n){let r={success:!1,manifest:null,prUrl:null,error:n.message,securityVerdict:"pass",securityReport:{scannedAt:new Date().toISOString(),skillName:"",skillPath:"",source:null,codeScans:[],permissions:[],totalFiles:0,totalLines:0,verdict:"safe",verdictReason:""}};e.flags.machine&&(t?.(),console.log(Z("publish",X.PUBLISH_FAILED,n.message,s)),process.exit(1)),e.flags.json&&(console.log(JSON.stringify({success:!1,manifest:null,pr_url:null,error:n.message,security_verdict:null},null,2)),process.exit(1)),$(n.message),process.exit(1)}}async function pk(e){if(e.flags.help){xv();return}let t=e.flags.machine?Ye():void 0,s=performance.now();try{let i=await Vr();if(e.flags.machine){t?.();let r=i.entries.map(o=>({name:o.name,installed_commit:o.installedCommit,latest_commit:o.latestCommit,source:o.sourceType,status:o.status}));console.log(z("outdated",r,s));return}if(e.flags.json){console.log(_u(i));return}let n=!e.flags.noColor&&process.stdout.isTTY!==!1;console.log(Du(i,n)),i.outdatedCount>0&&(process.exitCode=1)}catch(i){e.flags.machine&&(t?.(),console.log(Z("outdated",X.UNKNOWN_ERROR,i.message,s)),process.exit(1)),$(i.message),process.exit(1)}}async function mk(e){if(e.flags.help){Ev();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=[];e.subcommand&&i.push(e.subcommand),i.push(...e.positional);try{let n=await Mu(i.length>0?i:null,e.flags.yes);if(e.flags.machine){t?.();let o=n.results.map(a=>({name:a.name,status:a.status,reason:a.reason||null,old_commit:a.oldCommit||null,new_commit:a.newCommit||null,security_verdict:a.securityVerdict||null}));console.log(z("update",o,s));return}if(e.flags.json){console.log(Fu(n));return}if(n.results.length>0&&console.error(u.yellow("Note: project-scoped skill detection is not yet supported. All updates target the global skill path.")),n.warnings&&n.warnings.length>0)for(let o of n.warnings)console.error(u.yellow(`Warning: skill "${o}" not found in lock file \u2014 skipped`));if(n.results.length===0){console.log("All skills are up to date.");return}for(let o of n.results)switch(o.status){case"updated":console.log(`${u.green("\u2713")} ${o.name} ${u.dim(o.oldCommit||"")} \u2192 ${o.newCommit||""}`),o.securityVerdict==="warning"&&console.error(u.yellow(` \u26A0 Security audit returned warning for ${o.name} \u2014 updated because --yes was supplied`));break;case"skipped":console.log(`${u.yellow("\u25CB")} ${o.name} ${u.dim(o.reason||"skipped")}`);break;case"failed":console.log(`${u.red("\u2717")} ${o.name} ${u.dim(o.reason||"failed")}`);break}console.log("");let r=[];n.updatedCount>0&&r.push(u.green(`${n.updatedCount} updated`)),n.skippedCount>0&&r.push(u.yellow(`${n.skippedCount} skipped`)),n.failedCount>0&&r.push(u.red(`${n.failedCount} failed`)),console.log(r.join(", ")),n.failedCount>0&&(process.exitCode=1)}catch(n){e.flags.machine&&(t?.(),console.log(Z("update",X.UNKNOWN_ERROR,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}}async function Md(e){let t=gv(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&&no(!0),t.flags.version){console.log(`asm ${_i}`);let s=await vi();if(t.flags.verbose&&s.resolved&&(console.log(` path: ${s.resolved.path}`),s.resolved.realPath!==s.resolved.path&&console.log(` real: ${s.resolved.realPath}`)),s.shadowed.length>0&&s.resolved){console.error(""),console.error(u.yellow(`Warning: ${s.shadowed.length+1} \`asm\` binaries on PATH \u2014 you may be running a shadowed install.`)),console.error(` resolved: ${s.resolved.path}`);for(let i of s.shadowed)console.error(` shadowed: ${i.path}`);console.error(u.dim(" Pick one package manager (npm OR bun) and remove the other install.")),console.error(u.dim(" See: https://github.com/luongnv89/asm#troubleshooting"))}return}if(!t.command&&t.flags.help){yv();return}if(t.command)switch(t.command){case"list":await Cv(t);break;case"search":await Pv(t);break;case"inspect":await Nv(t);break;case"uninstall":await Iv(t);break;case"audit":await Rv(t);break;case"install":await Bv(t);break;case"config":await Dv(t);break;case"export":await Vv(t);break;case"import":await Jv(t);break;case"init":await Wv(t);break;case"stats":await Yv(t);break;case"link":await ak(t);break;case"index":await ck(t);break;case"bundle":await dk(t);break;case"publish":await fk(t);break;case"outdated":await pk(t);break;case"update":await mk(t);break;case"doctor":await Qv(t);break;case"eval":await tk(t);break;case"eval-providers":await nk(t);break;default:$(`Unknown command: "${t.command}"`),console.error('Run "asm --help" for usage.'),process.exit(2)}}function Dd(e){let t=e.slice(2);if(t.length===0)return!1;let s=["list","search","inspect","uninstall","audit","config","install","export","import","init","stats","link","index","bundle","publish","outdated","update","doctor","eval","eval-providers"],i=t[0];return!!(s.includes(i)||i==="--help"||i==="-h"||i==="--version"||i==="-v"||i.startsWith("-")||i.length>0)}if(Dd(process.argv))await Md(process.argv);else{let{main:e}=await import("./src-S3FQI2MC.js");await e().catch(t=>{console.error("Fatal error:",t),process.exit(1)})}
|