agent-skill-manager 2.9.0 → 2.11.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 +6 -5
- package/data/skill-index/Affitor_affiliate-skills.json +32 -8759
- package/data/skill-index/Eronred_aso-skills.json +129 -129
- package/data/skill-index/GPTomics_bioSkills.json +15445 -10094
- package/data/skill-index/Galaxy-Dawn_claude-scholar.json +144 -144
- package/data/skill-index/Imbad0202_academic-research-skills.json +52 -52
- package/data/skill-index/K-Dense-AI_claude-scientific-skills.json +4568 -3985
- package/data/skill-index/Leonxlnx_taste-skill.json +234 -61
- package/data/skill-index/Master-cai_Research-Paper-Writing-Skills.json +4 -4
- package/data/skill-index/MiniMax-AI_skills.json +78 -78
- package/data/skill-index/Paramchoudhary_ResumeSkills.json +306 -306
- package/data/skill-index/affaan-m_everything-claude-code.json +7535 -3337
- package/data/skill-index/alirezarezvani_claude-skills.json +6010 -2859
- package/data/skill-index/anthropics_skills.json +81 -81
- package/data/skill-index/antonbabenko_terraform-skill.json +9 -9
- package/data/skill-index/badlogic_pi-skills.json +1287 -0
- package/data/skill-index/briiirussell_cybersecurity-skills.json +4752 -0
- package/data/skill-index/bytedance_deer-flow.json +246 -91
- package/data/skill-index/coreyhaines31_marketingskills.json +683 -152
- package/data/skill-index/entireio_skills.json +986 -68
- package/data/skill-index/github_awesome-copilot.json +4130 -2466
- package/data/skill-index/google_skills.json +2608 -384
- package/data/skill-index/heygen-com_hyperframes.json +64 -64
- package/data/skill-index/himself65_finance-skills.json +249 -82
- package/data/skill-index/kemiljk_fluid-design.json +4 -4
- package/data/skill-index/kepano_obsidian-skills.json +20 -20
- package/data/skill-index/luongnv89_skills.json +289 -307
- package/data/skill-index/mattpocock_skills.json +237 -94
- package/data/skill-index/nextlevelbuilder_ui-ux-pro-max-skill.json +29 -29
- package/data/skill-index/obra_superpowers.json +49 -49
- package/data/skill-index/romainsimon_paperasse.json +26 -26
- package/data/skill-index/sickn33_antigravity-awesome-skills.json +40353 -31808
- package/data/skill-index/slavingia_skills.json +38 -38
- package/data/skill-index/warpdotdev_oz-skills.json +52 -52
- package/data/skill-index/zarazhangrui_follow-builders.json +147 -0
- package/data/skill-index-resources.json +28 -1
- package/dist/agent-skill-manager.js +178 -178
- package/dist/{chunk-7DMA7RUC.js → chunk-E2P2XYIZ.js} +1 -1
- package/dist/{src-H2QOCGTV.js → src-TIH4UJL5.js} +1 -1
- package/package.json +1 -1
|
@@ -1,76 +1,76 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { createRequire as __asmCreateRequire } from 'node:module'; const require = __asmCreateRequire(import.meta.url);
|
|
3
|
-
import{a as
|
|
4
|
-
`)}};
|
|
5
|
-
`)?
|
|
3
|
+
import{a as Oe,b as wt,c as Oo,d as To,e as Mo}from"./chunk-APSM2WG3.js";import{A as Io,D as Ro,E as Lo,F as Y,G as Ki,H as Do,J as Fo,K as _o,L as jo,M as Vi,N as qo,a as X,b as ae,c as Fi,d as bt,g as Z,h as bo,i as _i,j as wo,k as vo,l as ko,m as ji,n as So,o as u,p as $o,q as xo,r as Eo,s as qi,t as Bi,u as Ui,v as Co,w as Ao,x as as,y as Po,z as No}from"./chunk-E2P2XYIZ.js";import{a as po,b as I,c as mo,d as gt,e as ho,f as Di,g as yt,h as go,k as oe,l as B,m as yo}from"./chunk-GHPE6SB3.js";import{a as os,b as P,d as fo}from"./chunk-7BMOBFGJ.js";var j=P(z=>{"use strict";var Zi=Symbol.for("yaml.alias"),ua=Symbol.for("yaml.document"),ws=Symbol.for("yaml.map"),da=Symbol.for("yaml.pair"),en=Symbol.for("yaml.scalar"),vs=Symbol.for("yaml.seq"),ye=Symbol.for("yaml.node.type"),Ff=e=>!!e&&typeof e=="object"&&e[ye]===Zi,_f=e=>!!e&&typeof e=="object"&&e[ye]===ua,jf=e=>!!e&&typeof e=="object"&&e[ye]===ws,qf=e=>!!e&&typeof e=="object"&&e[ye]===da,fa=e=>!!e&&typeof e=="object"&&e[ye]===en,Bf=e=>!!e&&typeof e=="object"&&e[ye]===vs;function pa(e){if(e&&typeof e=="object")switch(e[ye]){case ws:case vs:return!0}return!1}function Uf(e){if(e&&typeof e=="object")switch(e[ye]){case Zi:case ws:case en:case vs:return!0}return!1}var Kf=e=>(fa(e)||pa(e))&&!!e.anchor;z.ALIAS=Zi;z.DOC=ua;z.MAP=ws;z.NODE_TYPE=ye;z.PAIR=da;z.SCALAR=en;z.SEQ=vs;z.hasAnchor=Kf;z.isAlias=Ff;z.isCollection=pa;z.isDocument=_f;z.isMap=jf;z.isNode=Uf;z.isPair=qf;z.isScalar=fa;z.isSeq=Bf});var vt=P(tn=>{"use strict";var J=j(),se=Symbol("break visit"),ma=Symbol("skip children"),me=Symbol("remove node");function ks(e,t){let s=ha(t);J.isDocument(e)?Ze(null,e.contents,s,Object.freeze([e]))===me&&(e.contents=null):Ze(null,e,s,Object.freeze([]))}ks.BREAK=se;ks.SKIP=ma;ks.REMOVE=me;function Ze(e,t,s,i){let n=ga(e,t,s,i);if(J.isNode(n)||J.isPair(n))return ya(e,i,n),Ze(e,n,s,i);if(typeof n!="symbol"){if(J.isCollection(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){let o=Ze(r,t.items[r],s,i);if(typeof o=="number")r=o-1;else{if(o===se)return se;o===me&&(t.items.splice(r,1),r-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let r=Ze("key",t.key,s,i);if(r===se)return se;r===me&&(t.key=null);let o=Ze("value",t.value,s,i);if(o===se)return se;o===me&&(t.value=null)}}return n}async function Ss(e,t){let s=ha(t);J.isDocument(e)?await et(null,e.contents,s,Object.freeze([e]))===me&&(e.contents=null):await et(null,e,s,Object.freeze([]))}Ss.BREAK=se;Ss.SKIP=ma;Ss.REMOVE=me;async function et(e,t,s,i){let n=await ga(e,t,s,i);if(J.isNode(n)||J.isPair(n))return ya(e,i,n),et(e,n,s,i);if(typeof n!="symbol"){if(J.isCollection(t)){i=Object.freeze(i.concat(t));for(let r=0;r<t.items.length;++r){let o=await et(r,t.items[r],s,i);if(typeof o=="number")r=o-1;else{if(o===se)return se;o===me&&(t.items.splice(r,1),r-=1)}}}else if(J.isPair(t)){i=Object.freeze(i.concat(t));let r=await et("key",t.key,s,i);if(r===se)return se;r===me&&(t.key=null);let o=await et("value",t.value,s,i);if(o===se)return se;o===me&&(t.value=null)}}return n}function ha(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 ga(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 ya(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`)}}tn.visit=ks;tn.visitAsync=Ss});var sn=P(wa=>{"use strict";var ba=j(),Vf=vt(),Jf={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Hf=e=>e.replace(/[!,[\]{}]/g,t=>Jf[t]),kt=class e{constructor(t,s){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,s)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},e.defaultTags);break}return t}add(t,s){this.atNextDocument&&(this.yaml={explicit:e.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},e.defaultTags),this.atNextDocument=!1);let i=t.trim().split(/[ \t]+/),n=i.shift();switch(n){case"%TAG":{if(i.length!==2&&(s(0,"%TAG directive should contain exactly two parts"),i.length<2))return!1;let[r,o]=i;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,i.length!==1)return s(0,"%YAML directive should contain exactly one part"),!1;let[r]=i;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{let o=/^\d+\.\d+$/.test(r);return s(6,`Unsupported YAML version ${r}`,o),!1}}default:return s(0,`Unknown directive ${n}`,!0),!1}}tagName(t,s){if(t==="!")return"!";if(t[0]!=="!")return s(`Not a valid tag: ${t}`),null;if(t[1]==="<"){let o=t.slice(2,-1);return o==="!"||o==="!!"?(s(`Verbatim tags aren't resolved, so ${t} is invalid.`),null):(t[t.length-1]!==">"&&s("Verbatim tags must end with a >"),o)}let[,i,n]=t.match(/^(.*!)([^!]*)$/s);n||s(`The ${t} tag has no suffix`);let r=this.tags[i];if(r)try{return r+decodeURIComponent(n)}catch(o){return s(String(o)),null}return i==="!"?t:(s(`Could not resolve tag: ${t}`),null)}tagString(t){for(let[s,i]of Object.entries(this.tags))if(t.startsWith(i))return s+Hf(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&&ba.isNode(t.contents)){let r={};Vf.visit(t.contents,(o,a)=>{ba.isNode(a)&&a.tag&&(r[a.tag]=!0)}),n=Object.keys(r)}else n=[];for(let[r,o]of i)r==="!!"&&o==="tag:yaml.org,2002:"||(!t||n.some(a=>a.startsWith(o)))&&s.push(`%TAG ${r} ${o}`);return s.join(`
|
|
4
|
+
`)}};kt.defaultYaml={explicit:!1,version:"1.2"};kt.defaultTags={"!!":"tag:yaml.org,2002:"};wa.Directives=kt});var $s=P(St=>{"use strict";var va=j(),Wf=vt();function Gf(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 ka(e){let t=new Set;return Wf.visit(e,{Value(s,i){i.anchor&&t.add(i.anchor)}}),t}function Sa(e,t){for(let s=1;;++s){let i=`${e}${s}`;if(!t.has(i))return i}}function Yf(e,t){let s=[],i=new Map,n=null;return{onAnchor:r=>{s.push(r),n??(n=ka(e));let o=Sa(t,n);return n.add(o),o},setAnchors:()=>{for(let r of s){let o=i.get(r);if(typeof o=="object"&&o.anchor&&(va.isScalar(o.node)||va.isCollection(o.node)))o.node.anchor=o.anchor;else{let a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:i}}St.anchorIsValid=Gf;St.anchorNames=ka;St.createNodeAnchors=Yf;St.findNewAnchor=Sa});var nn=P($a=>{"use strict";function $t(e,t,s,i){if(i&&typeof i=="object")if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let o=i[n],a=$t(e,i,String(n),o);a===void 0?delete i[n]:a!==o&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),o=$t(e,i,n,r);o===void 0?i.delete(n):o!==r&&i.set(n,o)}else if(i instanceof Set)for(let n of Array.from(i)){let r=$t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let o=$t(e,i,n,r);o===void 0?delete i[n]:o!==r&&(i[n]=o)}return e.call(t,s,i)}$a.applyReviver=$t});var Se=P(Ea=>{"use strict";var zf=j();function xa(e,t,s){if(Array.isArray(e))return e.map((i,n)=>xa(i,String(n),s));if(e&&typeof e.toJSON=="function"){if(!s||!zf.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}Ea.toJS=xa});var xs=P(Aa=>{"use strict";var Qf=nn(),Ca=j(),Xf=Se(),rn=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"?Qf.applyReviver(r,{"":a},"",a):a}};Aa.NodeBase=rn});var xt=P(Pa=>{"use strict";var Zf=$s(),ep=vt(),tt=j(),tp=xs(),sp=Se(),on=class extends tp.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=[],ep.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||(sp.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=Es(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(Zf.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 Es(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=Es(e,n,s);r>i&&(i=r)}return i}else if(tt.isPair(t)){let i=Es(e,t.key,s),n=Es(e,t.value,s);return Math.max(i,n)}return 1}Pa.Alias=on});var K=P(an=>{"use strict";var ip=j(),np=xs(),rp=Se(),op=e=>!e||typeof e!="function"&&typeof e!="object",$e=class extends np.NodeBase{constructor(t){super(ip.SCALAR),this.value=t}toJSON(t,s){return s?.keep?this.value:rp.toJS(this.value,t,s)}toString(){return String(this.value)}};$e.BLOCK_FOLDED="BLOCK_FOLDED";$e.BLOCK_LITERAL="BLOCK_LITERAL";$e.PLAIN="PLAIN";$e.QUOTE_DOUBLE="QUOTE_DOUBLE";$e.QUOTE_SINGLE="QUOTE_SINGLE";an.Scalar=$e;an.isScalarValue=op});var Et=P(Ia=>{"use strict";var ap=xt(),je=j(),Na=K(),lp="tag:yaml.org,2002:";function cp(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 up(e,t,s){if(je.isDocument(e)&&(e=e.contents),je.isNode(e))return e;if(je.isPair(e)){let d=s.schema[je.MAP].createNode?.(s.schema,null,s);return d.items.push(e),d}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<"u"&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:i,onAnchor:n,onTagObj:r,schema:o,sourceObjects:a}=s,l;if(i&&e&&typeof e=="object"){if(l=a.get(e),l)return l.anchor??(l.anchor=n(e)),new ap.Alias(l.anchor);l={anchor:null,node:null},a.set(e,l)}t?.startsWith("!!")&&(t=lp+t.slice(2));let c=cp(e,t,o.tags);if(!c){if(e&&typeof e.toJSON=="function"&&(e=e.toJSON()),!e||typeof e!="object"){let d=new Na.Scalar(e);return l&&(l.node=d),d}c=e instanceof Map?o[je.MAP]:Symbol.iterator in Object(e)?o[je.SEQ]:o[je.MAP]}r&&(r(c),delete s.onTagObj);let f=c?.createNode?c.createNode(s.schema,e,s):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(s.schema,e,s):new Na.Scalar(e);return t?f.tag=t:c.default||(f.tag=c.tag),l&&(l.node=f),f}Ia.createNode=up});var As=P(Cs=>{"use strict";var dp=Et(),he=j(),fp=xs();function ln(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 dp.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 Ra=e=>e==null||typeof e=="object"&&!!e[Symbol.iterator]().next().done,cn=class extends fp.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=>he.isNode(i)||he.isPair(i)?i.clone(t):i),this.range&&(s.range=this.range.slice()),s}addIn(t,s){if(Ra(t))this.add(s);else{let[i,...n]=t,r=this.get(i,!0);if(he.isCollection(r))r.addIn(n,s);else if(r===void 0&&this.schema)this.set(i,ln(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(he.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&&he.isScalar(r)?r.value:r:he.isCollection(r)?r.getIn(n,s):void 0}hasAllNullValues(t){return this.items.every(s=>{if(!he.isPair(s))return!1;let i=s.value;return i==null||t&&he.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 he.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(he.isCollection(r))r.setIn(n,s);else if(r===void 0&&this.schema)this.set(i,ln(this.schema,n,s));else throw new Error(`Expected YAML collection at ${i}. Remaining path: ${n}`)}}};Cs.Collection=cn;Cs.collectionFromPath=ln;Cs.isEmptyPath=Ra});var Ct=P(Ps=>{"use strict";var pp=e=>e.replace(/^(?!$)(?: $)?/gm,"#");function un(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}var mp=(e,t,s)=>e.endsWith(`
|
|
5
|
+
`)?un(s,t):s.includes(`
|
|
6
6
|
`)?`
|
|
7
|
-
`+
|
|
8
|
-
`)s===
|
|
7
|
+
`+un(s,t):(e.endsWith(" ")?"":" ")+s;Ps.indentComment=un;Ps.lineComment=mp;Ps.stringifyComment=pp});var Oa=P(At=>{"use strict";var hp="flow",dn="block",Ns="quoted";function gp(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===dn&&(h=La(e,h,t.length),h!==-1&&(d=h+l));for(let k;k=e[h+=1];){if(s===Ns&&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===dn&&(h=La(e,h,t.length)),d=h+t.length+l,p=void 0;else{if(k===" "&&m&&m!==" "&&m!==`
|
|
9
9
|
`&&m!==" "){let S=e[h+1];S&&S!==" "&&S!==`
|
|
10
|
-
`&&S!==" "&&(p=h)}if(h>=d)if(p)c.push(p),d=p+l,p=void 0;else if(s===
|
|
11
|
-
${t}${e.slice(0,v)}`:(s===
|
|
12
|
-
${t}${e.slice(S+1,v)}`)}return w}function
|
|
13
|
-
`);i=t,n=t+1,r=e[n]}return i}
|
|
14
|
-
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function
|
|
10
|
+
`&&S!==" "&&(p=h)}if(h>=d)if(p)c.push(p),d=p+l,p=void 0;else if(s===Ns){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===Ns&&f[S]&&(w+=`${e[S]}\\`),w+=`
|
|
12
|
+
${t}${e.slice(S+1,v)}`)}return w}function La(e,t,s){let i=t,n=t+1,r=e[n];for(;r===" "||r===" ";)if(t<n+s)r=e[++t];else{do r=e[++t];while(r&&r!==`
|
|
13
|
+
`);i=t,n=t+1,r=e[n]}return i}At.FOLD_BLOCK=dn;At.FOLD_FLOW=hp;At.FOLD_QUOTED=Ns;At.foldFlowLines=gp});var Nt=P(Ta=>{"use strict";var fe=K(),xe=Oa(),Rs=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),Ls=e=>/^(%|---|\.\.\.)/m.test(e);function yp(e,t,s){if(!t||t<0)return!1;let i=t-s,n=e.length;if(n<=i)return!1;for(let r=0,o=0;r<n;++r)if(e[r]===`
|
|
14
|
+
`){if(r-o>i)return!0;if(o=r+1,n-o<=i)return!1}return!0}function Pt(e,t){let s=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return s;let{implicitKey:i}=t,n=t.options.doubleQuotedMinMultiLineLength,r=t.indent||(Ls(e)?" ":""),o="",a=0;for(let l=0,c=s[l];c;c=s[++l])if(c===" "&&s[l+1]==="\\"&&s[l+2]==="n"&&(o+=s.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(s[l+1]){case"u":{o+=s.slice(a,l);let f=s.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=s.substr(l,6)}l+=5,a=l+1}break;case"n":if(i||s[l+2]==='"'||s.length<n)l+=1;else{for(o+=s.slice(a,l)+`
|
|
15
15
|
|
|
16
16
|
`;s[l+2]==="\\"&&s[l+3]==="n"&&s[l+4]!=='"';)o+=`
|
|
17
|
-
`,l+=2;o+=r,s[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+s.slice(a):s,i?o
|
|
18
|
-
`)||/[ \t]\n|\n[ \t]/.test(e))return
|
|
19
|
-
${s}`)+"'";return t.implicitKey?i
|
|
17
|
+
`,l+=2;o+=r,s[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+s.slice(a):s,i?o:xe.foldFlowLines(o,r,xe.FOLD_QUOTED,Rs(t,!1))}function fn(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
18
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return Pt(e,t);let s=t.indent||(Ls(e)?" ":""),i="'"+e.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
19
|
+
${s}`)+"'";return t.implicitKey?i:xe.foldFlowLines(i,s,xe.FOLD_FLOW,Rs(t,!1))}function st(e,t){let{singleQuote:s}=t.options,i;if(s===!1)i=Pt;else{let n=e.includes('"'),r=e.includes("'");n&&!r?i=fn:r&&!n?i=Pt:i=s?fn:Pt}return i(e,t)}var pn;try{pn=new RegExp(`(^|(?<!
|
|
20
20
|
))
|
|
21
21
|
+(?!
|
|
22
|
-
|$)`,"g")}catch{
|
|
22
|
+
|$)`,"g")}catch{pn=/\n+(?!\n|$)/g}function Is({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||Ls(s)?" ":""),f=o==="literal"?!0:o==="folded"||t===fe.Scalar.BLOCK_FOLDED?!1:t===fe.Scalar.BLOCK_LITERAL?!0:!yp(s,l,c.length);if(!s)return f?`|
|
|
23
23
|
`:`>
|
|
24
24
|
`;let d,p;for(p=s.length;p>0;--p){let v=s[p-1];if(v!==`
|
|
25
25
|
`&&v!==" "&&v!==" ")break}let m=s.substring(p),y=m.indexOf(`
|
|
26
26
|
`);y===-1?d="-":s===m||y!==m.length-1?(d="+",r&&r()):d="",m&&(s=s.slice(0,-m.length),m[m.length-1]===`
|
|
27
|
-
`&&(m=m.slice(0,-1)),m=m.replace(
|
|
27
|
+
`&&(m=m.slice(0,-1)),m=m.replace(pn,`$&${c}`));let h=!1,g,b=-1;for(g=0;g<s.length;++g){let v=s[g];if(v===" ")h=!0;else if(v===`
|
|
28
28
|
`)b=g;else break}let w=s.substring(0,b<g?b+1:g);w&&(s=s.substring(w.length),w=w.replace(/\n+/g,`$&${c}`));let S=(h?c?"2":"1":"")+d;if(e&&(S+=" "+a(e.replace(/ ?[\r\n]+/g," ")),n&&n()),!f){let v=s.replace(/\n+/g,`
|
|
29
|
-
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),C=!1,E=
|
|
29
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`),C=!1,E=Rs(i,!0);o!=="folded"&&t!==fe.Scalar.BLOCK_FOLDED&&(E.onOverflow=()=>{C=!0});let x=xe.foldFlowLines(`${w}${v}${m}`,c,xe.FOLD_BLOCK,E);if(!C)return`>${S}
|
|
30
30
|
${c}${x}`}return s=s.replace(/\n+/g,`$&${c}`),`|${S}
|
|
31
|
-
${c}${w}${s}${m}`}function
|
|
31
|
+
${c}${w}${s}${m}`}function bp(e,t,s,i){let{type:n,value:r}=e,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=t;if(a&&r.includes(`
|
|
32
32
|
`)||f&&/[[\]{},]/.test(r))return st(r,t);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||f||!r.includes(`
|
|
33
|
-
`)?st(r,t):
|
|
34
|
-
`))return
|
|
35
|
-
${l}`);if(o){let p=h=>h.default&&h.tag!=="tag:yaml.org,2002:str"&&h.test?.test(d),{compat:m,tags:y}=t.doc.schema;if(y.some(p)||m?.some(p))return st(r,t)}return a?d
|
|
36
|
-
${t.indent}${a}`:a}
|
|
37
|
-
${a}:`):(g=`${g}:`,p&&(g+=
|
|
33
|
+
`)?st(r,t):Is(e,t,s,i);if(!a&&!f&&n!==fe.Scalar.PLAIN&&r.includes(`
|
|
34
|
+
`))return Is(e,t,s,i);if(Ls(r)){if(l==="")return t.forceBlockIndent=!0,Is(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:xe.foldFlowLines(d,l,xe.FOLD_FLOW,Rs(t,!1))}function wp(e,t,s,i){let{implicitKey:n,inFlow:r}=t,o=typeof e.value=="string"?e:Object.assign({},e,{value:String(e.value)}),{type:a}=e;a!==fe.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=fe.Scalar.QUOTE_DOUBLE);let l=f=>{switch(f){case fe.Scalar.BLOCK_FOLDED:case fe.Scalar.BLOCK_LITERAL:return n||r?st(o.value,t):Is(o,t,s,i);case fe.Scalar.QUOTE_DOUBLE:return Pt(o.value,t);case fe.Scalar.QUOTE_SINGLE:return fn(o.value,t);case fe.Scalar.PLAIN:return bp(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}Ta.stringifyString=wp});var It=P(mn=>{"use strict";var vp=$s(),Ee=j(),kp=Ct(),Sp=Nt();function $p(e,t){let s=Object.assign({blockQuote:!0,commentString:kp.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 xp(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(Ee.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 Ep(e,t,{anchors:s,doc:i}){if(!i.directives)return"";let n=[],r=(Ee.isScalar(e)||Ee.isCollection(e))&&e.anchor;r&&vp.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 Cp(e,t,s,i){if(Ee.isPair(e))return e.toString(t,s,i);if(Ee.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=Ee.isNode(e)?e:t.doc.createNode(e,{onTagObj:l=>n=l});n??(n=xp(t.doc.schema.tags,r));let o=Ep(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):Ee.isScalar(r)?Sp.stringifyString(r,t,s,i):r.toString(t,s,i);return o?Ee.isScalar(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
36
|
+
${t.indent}${a}`:a}mn.createStringifyContext=$p;mn.stringify=Cp});var _a=P(Fa=>{"use strict";var be=j(),Ma=K(),Da=It(),Rt=Ct();function Ap({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===Ma.Scalar.BLOCK_FOLDED||e.type===Ma.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=Da.stringify(e,s,()=>y=!0,()=>h=!0);if(!m&&!s.inFlow&&g.length>1024){if(d)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");m=!0}if(s.inFlow){if(r||t==null)return y&&i&&i(),g===""?"?":m?`? ${g}`:g}else if(r&&!d||t==null&&m)return g=`? ${g}`,p&&!y?g+=Rt.lineComment(g,s.indent,c(p)):h&&n&&n(),g;y&&(p=null),m?(p&&(g+=Rt.lineComment(g,s.indent,c(p))),g=`? ${g}
|
|
37
|
+
${a}:`):(g=`${g}:`,p&&(g+=Rt.lineComment(g,s.indent,c(p))));let b,w,k;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=Da.stringify(t,s,()=>S=!0,()=>h=!0),C=" ";if(p||b||w){if(C=b?`
|
|
38
38
|
`:"",w){let E=c(w);C+=`
|
|
39
|
-
${
|
|
39
|
+
${Rt.indentComment(E,s.indent)}`}v===""&&!s.inFlow?C===`
|
|
40
40
|
`&&k&&(C=`
|
|
41
41
|
|
|
42
42
|
`):C+=`
|
|
43
43
|
${s.indent}`}else if(!m&&be.isCollection(t)){let E=v[0],x=v.indexOf(`
|
|
44
44
|
`),M=x!==-1,O=s.inFlow??t.flow??t.items.length===0;if(M||!O){let D=!1;if(M&&(E==="&"||E==="!")){let T=v.indexOf(" ");E==="&"&&T!==-1&&T<x&&v[T+1]==="!"&&(T=v.indexOf(" ",T+1)),(T===-1||x<T)&&(D=!0)}D||(C=`
|
|
45
45
|
${s.indent}`)}}else(v===""||v[0]===`
|
|
46
|
-
`)&&(C="");return g+=C+v,s.inFlow?S&&i&&i():k&&!S?g+=
|
|
46
|
+
`)&&(C="");return g+=C+v,s.inFlow?S&&i&&i():k&&!S?g+=Rt.lineComment(g,s.indent,c(k)):h&&n&&n(),g}Fa.stringifyPair=Ap});var gn=P(hn=>{"use strict";var ja=os("process");function Pp(e,...t){e==="debug"&&console.log(...t)}function Np(e,t){(e==="debug"||e==="warn")&&(typeof ja.emitWarning=="function"?ja.emitWarning(t):console.warn(t))}hn.debug=Pp;hn.warn=Np});var Ds=P(Ms=>{"use strict";var Lt=j(),qa=K(),Os="<<",Ts={identify:e=>e===Os||typeof e=="symbol"&&e.description===Os,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new qa.Scalar(Symbol(Os)),{addToJSMap:Ba}),stringify:()=>Os},Ip=(e,t)=>(Ts.identify(t)||Lt.isScalar(t)&&(!t.type||t.type===qa.Scalar.PLAIN)&&Ts.identify(t.value))&&e?.doc.schema.tags.some(s=>s.tag===Ts.tag&&s.default);function Ba(e,t,s){if(s=e&&Lt.isAlias(s)?s.resolve(e.doc):s,Lt.isSeq(s))for(let i of s.items)yn(e,t,i);else if(Array.isArray(s))for(let i of s)yn(e,t,i);else yn(e,t,s)}function yn(e,t,s){let i=e&&Lt.isAlias(s)?s.resolve(e.doc):s;if(!Lt.isMap(i))throw new Error("Merge sources must be maps or map aliases");let n=i.toJSON(null,e,Map);for(let[r,o]of n)t instanceof Map?t.has(r)||t.set(r,o):t instanceof Set?t.add(r):Object.prototype.hasOwnProperty.call(t,r)||Object.defineProperty(t,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return t}Ms.addMergeToJSMap=Ba;Ms.isMergeKey=Ip;Ms.merge=Ts});var wn=P(Va=>{"use strict";var Rp=gn(),Ua=Ds(),Lp=It(),Ka=j(),bn=Se();function Op(e,t,{key:s,value:i}){if(Ka.isNode(s)&&s.addToJSMap)s.addToJSMap(e,t,i);else if(Ua.isMergeKey(e,s))Ua.addMergeToJSMap(e,t,i);else{let n=bn.toJS(s,"",e);if(t instanceof Map)t.set(n,bn.toJS(i,n,e));else if(t instanceof Set)t.add(n);else{let r=Tp(s,n,e),o=bn.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 Tp(e,t,s){if(t===null)return"";if(typeof t!="object")return String(t);if(Ka.isNode(e)&&s?.doc){let i=Lp.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)+'..."'),Rp.warn(s.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),s.mapKeyWarned=!0}return n}return JSON.stringify(t)}Va.addPairToJSMap=Op});var Ce=P(vn=>{"use strict";var Ja=Et(),Mp=_a(),Dp=wn(),Fs=j();function Fp(e,t,s){let i=Ja.createNode(e,void 0,s),n=Ja.createNode(t,void 0,s);return new _s(i,n)}var _s=class e{constructor(t,s=null){Object.defineProperty(this,Fs.NODE_TYPE,{value:Fs.PAIR}),this.key=t,this.value=s}clone(t){let{key:s,value:i}=this;return Fs.isNode(s)&&(s=s.clone(t)),Fs.isNode(i)&&(i=i.clone(t)),new e(s,i)}toJSON(t,s){let i=s?.mapAsMap?new Map:{};return Dp.addPairToJSMap(s,i,this)}toString(t,s,i){return t?.doc?Mp.stringifyPair(this,t,s,i):JSON.stringify(this)}};vn.Pair=_s;vn.createPair=Fp});var kn=P(Wa=>{"use strict";var qe=j(),Ha=It(),js=Ct();function _p(e,t,s){return(t.inFlow??e.flow?qp:jp)(e,t,s)}function jp({comment:e,items:t},s,{blockItemPrefix:i,flowChars:n,itemIndent:r,onChompKeep:o,onComment:a}){let{indent:l,options:{commentString:c}}=s,f=Object.assign({},s,{indent:r,type:null}),d=!1,p=[];for(let y=0;y<t.length;++y){let h=t[y],g=null;if(qe.isNode(h))!d&&h.spaceBefore&&p.push(""),qs(s,p,h.commentBefore,d),h.comment&&(g=h.comment);else if(qe.isPair(h)){let w=qe.isNode(h.key)?h.key:null;w&&(!d&&w.spaceBefore&&p.push(""),qs(s,p,w.commentBefore,d))}d=!1;let b=Ha.stringify(h,f,()=>g=null,()=>d=!0);g&&(b+=js.lineComment(b,r,c(g))),d&&g&&(d=!1),p.push(i+b)}let m;if(p.length===0)m=n.start+n.end;else{m=p[0];for(let y=1;y<p.length;++y){let h=p[y];m+=h?`
|
|
47
47
|
${l}${h}`:`
|
|
48
48
|
`}}return e?(m+=`
|
|
49
|
-
`+
|
|
50
|
-
`)),y<e.length-1?b+=",":t.options.trailingComma&&(t.options.lineWidth>0&&(c||(c=d.reduce((w,k)=>w+k.length+2,2)+(b.length+2)>t.options.lineWidth)),c&&(b+=",")),g&&(b+=
|
|
49
|
+
`+js.indentComment(c(e),l),a&&a()):d&&o&&o(),m}function qp({items:e},t,{flowChars:s,itemIndent:i}){let{indent:n,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=t;i+=r;let l=Object.assign({},t,{indent:i,inFlow:!0,type:null}),c=!1,f=0,d=[];for(let y=0;y<e.length;++y){let h=e[y],g=null;if(qe.isNode(h))h.spaceBefore&&d.push(""),qs(t,d,h.commentBefore,!1),h.comment&&(g=h.comment);else if(qe.isPair(h)){let w=qe.isNode(h.key)?h.key:null;w&&(w.spaceBefore&&d.push(""),qs(t,d,w.commentBefore,!1),w.comment&&(c=!0));let k=qe.isNode(h.value)?h.value:null;k?(k.comment&&(g=k.comment),k.commentBefore&&(c=!0)):h.value==null&&w?.comment&&(g=w.comment)}g&&(c=!0);let b=Ha.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+=js.lineComment(b,i,a(g))),d.push(b),f=d.length}let{start:p,end:m}=s;if(d.length===0)return p+m;if(!c){let y=d.reduce((h,g)=>h+g.length+2,2);c=t.options.lineWidth>0&&y>t.options.lineWidth}if(c){let y=p;for(let h of d)y+=h?`
|
|
51
51
|
${r}${n}${h}`:`
|
|
52
52
|
`;return`${y}
|
|
53
|
-
${n}${m}`}else return`${p}${o}${d.join(" ")}${o}${m}`}function
|
|
54
|
-
`:" ")}return
|
|
53
|
+
${n}${m}`}else return`${p}${o}${d.join(" ")}${o}${m}`}function qs({indent:e,options:{commentString:t}},s,i,n){if(i&&n&&(i=i.replace(/^\n+/,"")),i){let r=js.indentComment(t(i),e);s.push(r.trimStart())}}Wa.stringifyCollection=_p});var Pe=P($n=>{"use strict";var Bp=kn(),Up=wn(),Kp=As(),Ae=j(),Bs=Ce(),Vp=K();function Ot(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 Sn=class extends Kp.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(Bs.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 Bs.Pair(t,t?.value):i=new Bs.Pair(t.key,t.value);let n=Ot(this.items,i.key),r=this.schema?.sortMapEntries;if(n){if(!s)throw new Error(`Key ${i.key} already set`);Ae.isScalar(n.value)&&Vp.isScalarValue(i.value)?n.value.value=i.value:n.value=i.value}else if(r){let o=this.items.findIndex(a=>r(i,a)<0);o===-1?this.items.push(i):this.items.splice(o,0,i)}else this.items.push(i)}delete(t){let s=Ot(this.items,t);return s?this.items.splice(this.items.indexOf(s),1).length>0:!1}get(t,s){let n=Ot(this.items,t)?.value;return(!s&&Ae.isScalar(n)?n.value:n)??void 0}has(t){return!!Ot(this.items,t)}set(t,s){this.add(new Bs.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)Up.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})),Bp.stringifyCollection(this,t,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:t.indent||"",onChompKeep:i,onComment:s})}};$n.YAMLMap=Sn;$n.findPair=Ot});var it=P(Ya=>{"use strict";var Jp=j(),Ga=Pe(),Hp={collection:"map",default:!0,nodeClass:Ga.YAMLMap,tag:"tag:yaml.org,2002:map",resolve(e,t){return Jp.isMap(e)||t("Expected a mapping for this tag"),e},createNode:(e,t,s)=>Ga.YAMLMap.from(e,t,s)};Ya.map=Hp});var Ne=P(za=>{"use strict";var Wp=Et(),Gp=kn(),Yp=As(),Ks=j(),zp=K(),Qp=Se(),xn=class extends Yp.Collection{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(t){super(Ks.SEQ,t),this.items=[]}add(t){this.items.push(t)}delete(t){let s=Us(t);return typeof s!="number"?!1:this.items.splice(s,1).length>0}get(t,s){let i=Us(t);if(typeof i!="number")return;let n=this.items[i];return!s&&Ks.isScalar(n)?n.value:n}has(t){let s=Us(t);return typeof s=="number"&&s<this.items.length}set(t,s){let i=Us(t);if(typeof i!="number")throw new Error(`Expected a valid index, not ${t}.`);let n=this.items[i];Ks.isScalar(n)&&zp.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(Qp.toJS(r,String(n++),s));return i}toString(t,s,i){return t?Gp.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 Us(e){let t=Ks.isScalar(e)?e.value:e;return t&&typeof t=="string"&&(t=Number(t)),typeof t=="number"&&Number.isInteger(t)&&t>=0?t:null}za.YAMLSeq=xn});var nt=P(Xa=>{"use strict";var Xp=j(),Qa=Ne(),Zp={collection:"seq",default:!0,nodeClass:Qa.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)=>Qa.YAMLSeq.from(e,t,s)};Xa.seq=Zp});var Tt=P(Za=>{"use strict";var em=Nt(),tm={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),em.stringifyString(e,t,s,i)}};Za.string=tm});var Vs=P(sl=>{"use strict";var el=K(),tl={identify:e=>e==null,createNode:()=>new el.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new el.Scalar(null),stringify:({source:e},t)=>typeof e=="string"&&tl.test.test(e)?e:t.options.nullStr};sl.nullTag=tl});var En=P(nl=>{"use strict";var sm=K(),il={identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new sm.Scalar(e[0]==="t"||e[0]==="T"),stringify({source:e,value:t},s){if(e&&il.test.test(e)){let i=e[0]==="t"||e[0]==="T";if(t===i)return e}return t?s.options.trueStr:s.options.falseStr}};nl.boolTag=il});var rt=P(rl=>{"use strict";function im({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}rl.stringifyNumber=im});var An=P(Js=>{"use strict";var nm=K(),Cn=rt(),rm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:Cn.stringifyNumber},om={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():Cn.stringifyNumber(e)}},am={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let t=new nm.Scalar(parseFloat(e)),s=e.indexOf(".");return s!==-1&&e[e.length-1]==="0"&&(t.minFractionDigits=e.length-s-1),t},stringify:Cn.stringifyNumber};Js.float=am;Js.floatExp=om;Js.floatNaN=rm});var Nn=P(Ws=>{"use strict";var ol=rt(),Hs=e=>typeof e=="bigint"||Number.isInteger(e),Pn=(e,t,s,{intAsBigInt:i})=>i?BigInt(e):parseInt(e.substring(t),s);function al(e,t,s){let{value:i}=e;return Hs(i)&&i>=0?s+i.toString(t):ol.stringifyNumber(e)}var lm={identify:e=>Hs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(e,t,s)=>Pn(e,2,8,s),stringify:e=>al(e,8,"0o")},cm={identify:Hs,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(e,t,s)=>Pn(e,0,10,s),stringify:ol.stringifyNumber},um={identify:e=>Hs(e)&&e>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,s)=>Pn(e,2,16,s),stringify:e=>al(e,16,"0x")};Ws.int=cm;Ws.intHex=um;Ws.intOct=lm});var cl=P(ll=>{"use strict";var dm=it(),fm=Vs(),pm=nt(),mm=Tt(),hm=En(),In=An(),Rn=Nn(),gm=[dm.map,pm.seq,mm.string,fm.nullTag,hm.boolTag,Rn.intOct,Rn.int,Rn.intHex,In.floatNaN,In.floatExp,In.float];ll.schema=gm});var fl=P(dl=>{"use strict";var ym=K(),bm=it(),wm=nt();function ul(e){return typeof e=="bigint"||Number.isInteger(e)}var Gs=({value:e})=>JSON.stringify(e),vm=[{identify:e=>typeof e=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:e=>e,stringify:Gs},{identify:e=>e==null,createNode:()=>new ym.Scalar(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:Gs},{identify:e=>typeof e=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:e=>e==="true",stringify:Gs},{identify:ul,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})=>ul(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:Gs}],km={default:!0,tag:"",test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}},Sm=[bm.map,wm.seq].concat(vm,km);dl.schema=Sm});var On=P(pl=>{"use strict";var Mt=os("buffer"),Ln=K(),$m=Nt(),xm={identify:e=>e instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(e,t){if(typeof Mt.Buffer=="function")return Mt.Buffer.from(e,"base64");if(typeof atob=="function"){let s=atob(e.replace(/[\n\r]/g,"")),i=new Uint8Array(s.length);for(let n=0;n<s.length;++n)i[n]=s.charCodeAt(n);return i}else return t("This environment does not support reading binary tags; either Buffer or atob is required"),e},stringify({comment:e,type:t,value:s},i,n,r){if(!s)return"";let o=s,a;if(typeof Mt.Buffer=="function")a=o instanceof Mt.Buffer?o.toString("base64"):Mt.Buffer.from(o.buffer).toString("base64");else if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(t??(t=Ln.Scalar.BLOCK_LITERAL),t!==Ln.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===Ln.Scalar.BLOCK_LITERAL?`
|
|
54
|
+
`:" ")}return $m.stringifyString({comment:e,type:t,value:a},i,n,r)}};pl.binary=xm});var Qs=P(zs=>{"use strict";var Ys=j(),Tn=Ce(),Em=K(),Cm=Ne();function ml(e,t){if(Ys.isSeq(e))for(let s=0;s<e.items.length;++s){let i=e.items[s];if(!Ys.isPair(i)){if(Ys.isMap(i)){i.items.length>1&&t("Each pair must have its own sequence indicator");let n=i.items[0]||new Tn.Pair(new Em.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]=Ws.isPair(i)?i:new On.Pair(i)}}else t("Expected a sequence for this tag");return e}function ml(e,t,s){let{replacer:i}=s,n=new Em.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;n.items.push(On.createPair(a,l,s))}return n}var Cm={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:pl,createNode:ml};Gs.createPairs=ml;Gs.pairs=Cm;Gs.resolvePairs=pl});var Dn=P(Mn=>{"use strict";var hl=j(),Tn=ke(),Mt=Ae(),Am=Pe(),gl=Ys(),Be=class e extends Am.YAMLSeq{constructor(){super(),this.add=Mt.YAMLMap.prototype.add.bind(this),this.delete=Mt.YAMLMap.prototype.delete.bind(this),this.get=Mt.YAMLMap.prototype.get.bind(this),this.has=Mt.YAMLMap.prototype.has.bind(this),this.set=Mt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,s){if(!s)return super.toJSON(t);let i=new Map;s?.onCreate&&s.onCreate(i);for(let n of this.items){let r,o;if(hl.isPair(n)?(r=Tn.toJS(n.key,"",s),o=Tn.toJS(n.value,r,s)):r=Tn.toJS(n,"",s),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}static from(t,s,i){let n=gl.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var Pm={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=gl.resolvePairs(e,t),i=[];for(let{key:n}of s.items)hl.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Be,s)},createNode:(e,t,s)=>Be.from(e,t,s)};Mn.YAMLOMap=Be;Mn.omap=Pm});var kl=P(Fn=>{"use strict";var yl=V();function bl({value:e,source:t},s){return t&&(e?wl:vl).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var wl={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new yl.Scalar(!0),stringify:bl},vl={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new yl.Scalar(!1),stringify:bl};Fn.falseTag=vl;Fn.trueTag=wl});var Sl=P(zs=>{"use strict";var Nm=V(),_n=rt(),Im={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:_n.stringifyNumber},Rm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():_n.stringifyNumber(e)}},Lm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Nm.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let i=e.substring(s+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:_n.stringifyNumber};zs.float=Lm;zs.floatExp=Rm;zs.floatNaN=Im});var xl=P(Ft=>{"use strict";var $l=rt(),Dt=e=>typeof e=="bigint"||Number.isInteger(e);function Qs(e,t,s,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let r=parseInt(e,s);return n==="-"?-1*r:r}function jn(e,t,s){let{value:i}=e;if(Dt(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return $l.stringifyNumber(e)}var Om={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Qs(e,2,2,s),stringify:e=>jn(e,2,"0b")},Tm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Qs(e,1,8,s),stringify:e=>jn(e,8,"0")},Mm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Qs(e,0,10,s),stringify:$l.stringifyNumber},Dm={identify:Dt,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Qs(e,2,16,s),stringify:e=>jn(e,16,"0x")};Ft.int=Mm;Ft.intBin=Om;Ft.intHex=Dm;Ft.intOct=Tm});var Bn=P(qn=>{"use strict";var ei=j(),Xs=Ee(),Zs=Ae(),Ue=class e extends Zs.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;ei.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new Xs.Pair(t.key,null):s=new Xs.Pair(t,null),Zs.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=Zs.findPair(this.items,t);return!s&&ei.isPair(i)?ei.isScalar(i.key)?i.key.value:i.key:i}set(t,s){if(typeof s!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof s}`);let i=Zs.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new Xs.Pair(t))}toJSON(t,s){return super.toJSON(t,s,Set)}toString(t,s,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),s,i);throw new Error("Set items must all have null values")}static from(t,s,i){let{replacer:n}=i,r=new this(t);if(s&&Symbol.iterator in Object(s))for(let o of s)typeof n=="function"&&(o=n.call(s,o,o)),r.items.push(Xs.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var Fm={collection:"map",identify:e=>e instanceof Set,nodeClass:Ue,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>Ue.from(e,t,s),resolve(e,t){if(ei.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ue,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};qn.YAMLSet=Ue;qn.set=Fm});var Vn=P(ti=>{"use strict";var _m=rt();function Un(e,t){let s=e[0],i=s==="-"||s==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return s==="-"?n(-1)*r:r}function El(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return _m.stringifyNumber(e);let i="";t<0&&(i="-",t*=s(-1));let n=s(60),r=[t%n];return t<60?r.unshift(0):(t=(t-r[0])/n,r.unshift(t%n),t>=60&&(t=(t-r[0])/n,r.unshift(t))),i+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var jm={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>Un(e,s),stringify:El},qm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Un(e,!1),stringify:El},Cl={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Cl.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,n,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,i-1,n,r||0,o||0,a||0,l),f=t[8];if(f&&f!=="Z"){let d=Un(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ti.floatTime=qm;ti.intTime=jm;ti.timestamp=Cl});var Nl=P(Pl=>{"use strict";var Bm=it(),Um=Us(),Vm=nt(),Km=Ot(),Jm=Ln(),Al=kl(),Kn=Sl(),si=xl(),Hm=Ts(),Wm=Dn(),Gm=Ys(),Ym=Bn(),Jn=Vn(),zm=[Bm.map,Vm.seq,Km.string,Um.nullTag,Al.trueTag,Al.falseTag,si.intBin,si.intOct,si.int,si.intHex,Kn.floatNaN,Kn.floatExp,Kn.float,Jm.binary,Hm.merge,Wm.omap,Gm.pairs,Ym.set,Jn.intTime,Jn.floatTime,Jn.timestamp];Pl.schema=zm});var jl=P(Gn=>{"use strict";var Ol=it(),Qm=Us(),Tl=nt(),Xm=Ot(),Zm=xn(),Hn=Cn(),Wn=Pn(),eh=ll(),th=dl(),Ml=Ln(),_t=Ts(),Dl=Dn(),Fl=Ys(),Il=Nl(),_l=Bn(),ii=Vn(),Rl=new Map([["core",eh.schema],["failsafe",[Ol.map,Tl.seq,Xm.string]],["json",th.schema],["yaml11",Il.schema],["yaml-1.1",Il.schema]]),Ll={binary:Ml.binary,bool:Zm.boolTag,float:Hn.float,floatExp:Hn.floatExp,floatNaN:Hn.floatNaN,floatTime:ii.floatTime,int:Wn.int,intHex:Wn.intHex,intOct:Wn.intOct,intTime:ii.intTime,map:Ol.map,merge:_t.merge,null:Qm.nullTag,omap:Dl.omap,pairs:Fl.pairs,seq:Tl.seq,set:_l.set,timestamp:ii.timestamp},sh={"tag:yaml.org,2002:binary":Ml.binary,"tag:yaml.org,2002:merge":_t.merge,"tag:yaml.org,2002:omap":Dl.omap,"tag:yaml.org,2002:pairs":Fl.pairs,"tag:yaml.org,2002:set":_l.set,"tag:yaml.org,2002:timestamp":ii.timestamp};function ih(e,t,s){let i=Rl.get(t);if(i&&!e)return s&&!i.includes(_t.merge)?i.concat(_t.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(Rl.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${r} or define customTags array`)}if(Array.isArray(e))for(let r of e)n=n.concat(r);else typeof e=="function"&&(n=e(n.slice()));return s&&(n=n.concat(_t.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?Ll[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Ll).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Gn.coreKnownTags=sh;Gn.getTags=ih});var Qn=P(ql=>{"use strict";var Yn=j(),nh=it(),rh=nt(),oh=Ot(),ni=jl(),ah=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,zn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?ni.getTags(t,"compat"):t?ni.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?ni.coreKnownTags:{},this.tags=ni.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,Yn.MAP,{value:nh.map}),Object.defineProperty(this,Yn.SCALAR,{value:oh.string}),Object.defineProperty(this,Yn.SEQ,{value:rh.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?ah:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};ql.Schema=zn});var Ul=P(Bl=>{"use strict";var lh=j(),Xn=Nt(),jt=Et();function ch(e,t){let s=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(s.push(l),i=!0):e.directives.docStart&&(i=!0)}i&&s.push("---");let n=Xn.createStringifyContext(e,t),{commentString:r}=n.options;if(e.commentBefore){s.length!==1&&s.unshift("");let l=r(e.commentBefore);s.unshift(jt.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(lh.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let f=r(e.contents.commentBefore);s.push(jt.indentComment(f,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Xn.stringify(e.contents,n,()=>a=null,l);a&&(c+=jt.lineComment(c,"",r(a))),(c[0]==="|"||c[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${c}`:s.push(c)}else s.push(Xn.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
57
|
-
`)?(s.push("..."),s.push(
|
|
56
|
+
${r.comment}`:i.comment}i=n}e.items[s]=Ys.isPair(i)?i:new Tn.Pair(i)}}else t("Expected a sequence for this tag");return e}function hl(e,t,s){let{replacer:i}=s,n=new Cm.YAMLSeq(e);n.tag="tag:yaml.org,2002:pairs";let r=0;if(t&&Symbol.iterator in Object(t))for(let o of t){typeof i=="function"&&(o=i.call(t,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){let c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;n.items.push(Tn.createPair(a,l,s))}return n}var Am={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:ml,createNode:hl};zs.createPairs=hl;zs.pairs=Am;zs.resolvePairs=ml});var Fn=P(Dn=>{"use strict";var gl=j(),Mn=Se(),Dt=Pe(),Pm=Ne(),yl=Qs(),Be=class e extends Pm.YAMLSeq{constructor(){super(),this.add=Dt.YAMLMap.prototype.add.bind(this),this.delete=Dt.YAMLMap.prototype.delete.bind(this),this.get=Dt.YAMLMap.prototype.get.bind(this),this.has=Dt.YAMLMap.prototype.has.bind(this),this.set=Dt.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(t,s){if(!s)return super.toJSON(t);let i=new Map;s?.onCreate&&s.onCreate(i);for(let n of this.items){let r,o;if(gl.isPair(n)?(r=Mn.toJS(n.key,"",s),o=Mn.toJS(n.value,r,s)):r=Mn.toJS(n,"",s),i.has(r))throw new Error("Ordered maps must not include duplicate keys");i.set(r,o)}return i}static from(t,s,i){let n=yl.createPairs(t,s,i),r=new this;return r.items=n.items,r}};Be.tag="tag:yaml.org,2002:omap";var Nm={collection:"seq",identify:e=>e instanceof Map,nodeClass:Be,default:!1,tag:"tag:yaml.org,2002:omap",resolve(e,t){let s=yl.resolvePairs(e,t),i=[];for(let{key:n}of s.items)gl.isScalar(n)&&(i.includes(n.value)?t(`Ordered maps must not include duplicate keys: ${n.value}`):i.push(n.value));return Object.assign(new Be,s)},createNode:(e,t,s)=>Be.from(e,t,s)};Dn.YAMLOMap=Be;Dn.omap=Nm});var Sl=P(_n=>{"use strict";var bl=K();function wl({value:e,source:t},s){return t&&(e?vl:kl).test.test(t)?t:e?s.options.trueStr:s.options.falseStr}var vl={identify:e=>e===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new bl.Scalar(!0),stringify:wl},kl={identify:e=>e===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new bl.Scalar(!1),stringify:wl};_n.falseTag=kl;_n.trueTag=vl});var $l=P(Xs=>{"use strict";var Im=K(),jn=rt(),Rm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()==="nan"?NaN:e[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:jn.stringifyNumber},Lm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,"")),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():jn.stringifyNumber(e)}},Om={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let t=new Im.Scalar(parseFloat(e.replace(/_/g,""))),s=e.indexOf(".");if(s!==-1){let i=e.substring(s+1).replace(/_/g,"");i[i.length-1]==="0"&&(t.minFractionDigits=i.length)}return t},stringify:jn.stringifyNumber};Xs.float=Om;Xs.floatExp=Lm;Xs.floatNaN=Rm});var El=P(_t=>{"use strict";var xl=rt(),Ft=e=>typeof e=="bigint"||Number.isInteger(e);function Zs(e,t,s,{intAsBigInt:i}){let n=e[0];if((n==="-"||n==="+")&&(t+=1),e=e.substring(t).replace(/_/g,""),i){switch(s){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`;break}let o=BigInt(e);return n==="-"?BigInt(-1)*o:o}let r=parseInt(e,s);return n==="-"?-1*r:r}function qn(e,t,s){let{value:i}=e;if(Ft(i)){let n=i.toString(t);return i<0?"-"+s+n.substr(1):s+n}return xl.stringifyNumber(e)}var Tm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,s)=>Zs(e,2,2,s),stringify:e=>qn(e,2,"0b")},Mm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(e,t,s)=>Zs(e,1,8,s),stringify:e=>qn(e,8,"0")},Dm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,s)=>Zs(e,0,10,s),stringify:xl.stringifyNumber},Fm={identify:Ft,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,s)=>Zs(e,2,16,s),stringify:e=>qn(e,16,"0x")};_t.int=Dm;_t.intBin=Tm;_t.intHex=Fm;_t.intOct=Mm});var Un=P(Bn=>{"use strict";var si=j(),ei=Ce(),ti=Pe(),Ue=class e extends ti.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(t){let s;si.isPair(t)?s=t:t&&typeof t=="object"&&"key"in t&&"value"in t&&t.value===null?s=new ei.Pair(t.key,null):s=new ei.Pair(t,null),ti.findPair(this.items,s.key)||this.items.push(s)}get(t,s){let i=ti.findPair(this.items,t);return!s&&si.isPair(i)?si.isScalar(i.key)?i.key.value:i.key:i}set(t,s){if(typeof s!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof s}`);let i=ti.findPair(this.items,t);i&&!s?this.items.splice(this.items.indexOf(i),1):!i&&s&&this.items.push(new ei.Pair(t))}toJSON(t,s){return super.toJSON(t,s,Set)}toString(t,s,i){if(!t)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},t,{allNullValues:!0}),s,i);throw new Error("Set items must all have null values")}static from(t,s,i){let{replacer:n}=i,r=new this(t);if(s&&Symbol.iterator in Object(s))for(let o of s)typeof n=="function"&&(o=n.call(s,o,o)),r.items.push(ei.createPair(o,null,i));return r}};Ue.tag="tag:yaml.org,2002:set";var _m={collection:"map",identify:e=>e instanceof Set,nodeClass:Ue,default:!1,tag:"tag:yaml.org,2002:set",createNode:(e,t,s)=>Ue.from(e,t,s),resolve(e,t){if(si.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new Ue,e);t("Set items must all have null values")}else t("Expected a mapping for this tag");return e}};Bn.YAMLSet=Ue;Bn.set=_m});var Vn=P(ii=>{"use strict";var jm=rt();function Kn(e,t){let s=e[0],i=s==="-"||s==="+"?e.substring(1):e,n=o=>t?BigInt(o):Number(o),r=i.replace(/_/g,"").split(":").reduce((o,a)=>o*n(60)+n(a),n(0));return s==="-"?n(-1)*r:r}function Cl(e){let{value:t}=e,s=o=>o;if(typeof t=="bigint")s=o=>BigInt(o);else if(isNaN(t)||!isFinite(t))return jm.stringifyNumber(e);let i="";t<0&&(i="-",t*=s(-1));let n=s(60),r=[t%n];return t<60?r.unshift(0):(t=(t-r[0])/n,r.unshift(t%n),t>=60&&(t=(t-r[0])/n,r.unshift(t))),i+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}var qm={identify:e=>typeof e=="bigint"||Number.isInteger(e),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:s})=>Kn(e,s),stringify:Cl},Bm={identify:e=>typeof e=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>Kn(e,!1),stringify:Cl},Al={identify:e=>e instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(e){let t=e.match(Al.test);if(!t)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");let[,s,i,n,r,o,a]=t.map(Number),l=t[7]?Number((t[7]+"00").substr(1,3)):0,c=Date.UTC(s,i-1,n,r||0,o||0,a||0,l),f=t[8];if(f&&f!=="Z"){let d=Kn(f,!1);Math.abs(d)<30&&(d*=60),c-=6e4*d}return new Date(c)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""};ii.floatTime=Bm;ii.intTime=qm;ii.timestamp=Al});var Il=P(Nl=>{"use strict";var Um=it(),Km=Vs(),Vm=nt(),Jm=Tt(),Hm=On(),Pl=Sl(),Jn=$l(),ni=El(),Wm=Ds(),Gm=Fn(),Ym=Qs(),zm=Un(),Hn=Vn(),Qm=[Um.map,Vm.seq,Jm.string,Km.nullTag,Pl.trueTag,Pl.falseTag,ni.intBin,ni.intOct,ni.int,ni.intHex,Jn.floatNaN,Jn.floatExp,Jn.float,Hm.binary,Wm.merge,Gm.omap,Ym.pairs,zm.set,Hn.intTime,Hn.floatTime,Hn.timestamp];Nl.schema=Qm});var ql=P(Yn=>{"use strict";var Tl=it(),Xm=Vs(),Ml=nt(),Zm=Tt(),eh=En(),Wn=An(),Gn=Nn(),th=cl(),sh=fl(),Dl=On(),jt=Ds(),Fl=Fn(),_l=Qs(),Rl=Il(),jl=Un(),ri=Vn(),Ll=new Map([["core",th.schema],["failsafe",[Tl.map,Ml.seq,Zm.string]],["json",sh.schema],["yaml11",Rl.schema],["yaml-1.1",Rl.schema]]),Ol={binary:Dl.binary,bool:eh.boolTag,float:Wn.float,floatExp:Wn.floatExp,floatNaN:Wn.floatNaN,floatTime:ri.floatTime,int:Gn.int,intHex:Gn.intHex,intOct:Gn.intOct,intTime:ri.intTime,map:Tl.map,merge:jt.merge,null:Xm.nullTag,omap:Fl.omap,pairs:_l.pairs,seq:Ml.seq,set:jl.set,timestamp:ri.timestamp},ih={"tag:yaml.org,2002:binary":Dl.binary,"tag:yaml.org,2002:merge":jt.merge,"tag:yaml.org,2002:omap":Fl.omap,"tag:yaml.org,2002:pairs":_l.pairs,"tag:yaml.org,2002:set":jl.set,"tag:yaml.org,2002:timestamp":ri.timestamp};function nh(e,t,s){let i=Ll.get(t);if(i&&!e)return s&&!i.includes(jt.merge)?i.concat(jt.merge):i.slice();let n=i;if(!n)if(Array.isArray(e))n=[];else{let r=Array.from(Ll.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${t}"; use one of ${r} or define customTags array`)}if(Array.isArray(e))for(let r of e)n=n.concat(r);else typeof e=="function"&&(n=e(n.slice()));return s&&(n=n.concat(jt.merge)),n.reduce((r,o)=>{let a=typeof o=="string"?Ol[o]:o;if(!a){let l=JSON.stringify(o),c=Object.keys(Ol).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}Yn.coreKnownTags=ih;Yn.getTags=nh});var Xn=P(Bl=>{"use strict";var zn=j(),rh=it(),oh=nt(),ah=Tt(),oi=ql(),lh=(e,t)=>e.key<t.key?-1:e.key>t.key?1:0,Qn=class e{constructor({compat:t,customTags:s,merge:i,resolveKnownTags:n,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(t)?oi.getTags(t,"compat"):t?oi.getTags(null,t):null,this.name=typeof r=="string"&&r||"core",this.knownTags=n?oi.coreKnownTags:{},this.tags=oi.getTags(s,this.name,i),this.toStringOptions=a??null,Object.defineProperty(this,zn.MAP,{value:rh.map}),Object.defineProperty(this,zn.SCALAR,{value:ah.string}),Object.defineProperty(this,zn.SEQ,{value:oh.seq}),this.sortMapEntries=typeof o=="function"?o:o===!0?lh:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}};Bl.Schema=Qn});var Kl=P(Ul=>{"use strict";var ch=j(),Zn=It(),qt=Ct();function uh(e,t){let s=[],i=t.directives===!0;if(t.directives!==!1&&e.directives){let l=e.directives.toString(e);l?(s.push(l),i=!0):e.directives.docStart&&(i=!0)}i&&s.push("---");let n=Zn.createStringifyContext(e,t),{commentString:r}=n.options;if(e.commentBefore){s.length!==1&&s.unshift("");let l=r(e.commentBefore);s.unshift(qt.indentComment(l,""))}let o=!1,a=null;if(e.contents){if(ch.isNode(e.contents)){if(e.contents.spaceBefore&&i&&s.push(""),e.contents.commentBefore){let f=r(e.contents.commentBefore);s.push(qt.indentComment(f,""))}n.forceBlockIndent=!!e.comment,a=e.contents.comment}let l=a?void 0:()=>o=!0,c=Zn.stringify(e.contents,n,()=>a=null,l);a&&(c+=qt.lineComment(c,"",r(a))),(c[0]==="|"||c[0]===">")&&s[s.length-1]==="---"?s[s.length-1]=`--- ${c}`:s.push(c)}else s.push(Zn.stringify(e.contents,n));if(e.directives?.docEnd)if(e.comment){let l=r(e.comment);l.includes(`
|
|
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
|
+
`}Ul.stringifyDocument=uh});var Bt=P(Vl=>{"use strict";var dh=xt(),ot=As(),ue=j(),fh=Ce(),ph=Se(),mh=Xn(),hh=Kl(),er=$s(),gh=nn(),yh=Et(),tr=sn(),sr=class e{constructor(t,s,i){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,ue.NODE_TYPE,{value:ue.DOC});let n=null;typeof s=="function"||Array.isArray(s)?n=s:i===void 0&&s&&(i=s,s=void 0);let r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},i);this.options=r;let{version:o}=r;i?._directives?(this.directives=i._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new tr.Directives({version:o}),this.setSchema(o,i),this.contents=t===void 0?null:this.createNode(t,n,i)}clone(){let t=Object.create(e.prototype,{[ue.NODE_TYPE]:{value:ue.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=ue.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(t){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=er.anchorNames(this);t.anchor=!s||i.has(s)?er.findNewAnchor(s||"a",i):s}return new dh.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}=er.createNodeAnchors(this,o||"a"),y={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:d,onTagObj:c,replacer:n,schema:this.schema,sourceObjects:m},h=yh.createNode(t,f,y);return a&&ue.isCollection(h)&&(h.flow=!0),p(),h}createPair(t,s,i={}){let n=this.createNode(t,null,i),r=this.createNode(s,null,i);return new fh.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 ue.isCollection(this.contents)?this.contents.get(t,s):void 0}getIn(t,s){return ot.isEmptyPath(t)?!s&&ue.isScalar(this.contents)?this.contents.value:this.contents:ue.isCollection(this.contents)?this.contents.getIn(t,s):void 0}has(t){return ue.isCollection(this.contents)?this.contents.has(t):!1}hasIn(t){return ot.isEmptyPath(t)?this.contents!==void 0:ue.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 tr.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 tr.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 mh.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=ph.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"?gh.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 hh.stringifyDocument(this,t)}};function at(e){if(ue.isCollection(e))return!0;throw new Error("Expected a YAML collection as document contents")}Vl.Document=sr});var Vt=P(Kt=>{"use strict";var Ut=class extends Error{constructor(t,s,i,n){super(),this.name=t,this.code=i,this.message=n,this.pos=s}},ir=class extends Ut{constructor(t,s,i){super("YAMLParseError",t,s,i)}},nr=class extends Ut{constructor(t,s,i){super("YAMLWarning",t,s,i)}},bh=(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
|
-
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp
|
|
67
|
-
`+k.comment:w.comment=k.comment);let S=new
|
|
68
|
-
`+C.comment:c.comment=C.comment),d=C.end;continue}!o&&s.options.strict&&
|
|
69
|
-
`+E:x.comment=E,C.comment=C.comment.substring(E.length+1)}}if(!o&&!S&&!C.found){let E=v?e(s,v,C,n):t(s,C.end,S,null,C,n);c.items.push(E),d=E.range[2],
|
|
70
|
-
`+M.comment:x.comment=M.comment);let D=new
|
|
71
|
-
`+g.comment:c.comment=g.comment),c.range=[i.offset,h,g.offset]}else c.range=[i.offset,h,h];return c}
|
|
64
|
+
`}};Kt.YAMLError=Ut;Kt.YAMLParseError=ir;Kt.YAMLWarning=nr;Kt.prettifyError=bh});var Jt=P(Jl=>{"use strict";function wh(e,{flow:t,indicator:s,next:i,offset:n,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,d="",p="",m=!1,y=!1,h=null,g=null,b=null,w=null,k=null,S=null,v=null;for(let x of e)switch(y&&(x.type!=="space"&&x.type!=="newline"&&x.type!=="comma"&&r(x.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),y=!1),h&&(c&&x.type!=="comment"&&x.type!=="newline"&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),h=null),x.type){case"space":!t&&(s!=="doc-start"||i?.type!=="flow-collection")&&x.source.includes(" ")&&(h=x),f=!0;break;case"comment":{f||r(x,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");let M=x.source.substring(1)||" ";d?d+=p+M:d=M,p="",c=!1;break}case"newline":c?d?d+=x.source:(!S||s!=="seq-item-ind")&&(l=!0):p+=x.source,c=!0,m=!0,(g||b)&&(w=x),f=!0;break;case"anchor":g&&r(x,"MULTIPLE_ANCHORS","A node can have at most one anchor"),x.source.endsWith(":")&&r(x.offset+x.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=x,v??(v=x.offset),c=!1,f=!1,y=!0;break;case"tag":{b&&r(x,"MULTIPLE_TAGS","A node can have at most one tag"),b=x,v??(v=x.offset),c=!1,f=!1,y=!0;break}case s:(g||b)&&r(x,"BAD_PROP_ORDER",`Anchors and tags must be after the ${x.source} indicator`),S&&r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.source} in ${t??"collection"}`),S=x,c=s==="seq-item-ind"||s==="explicit-key-ind",f=!1;break;case"comma":if(t){k&&r(x,"UNEXPECTED_TOKEN",`Unexpected , in ${t}`),k=x,c=!1,f=!1;break}default:r(x,"UNEXPECTED_TOKEN",`Unexpected ${x.type} token`),c=!1,f=!1}let C=e[e.length-1],E=C?C.offset+C.source.length:n;return y&&i&&i.type!=="space"&&i.type!=="newline"&&i.type!=="comma"&&(i.type!=="scalar"||i.source!=="")&&r(i.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),h&&(c&&h.indent<=o||i?.type==="block-map"||i?.type==="block-seq")&&r(h,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:l,comment:d,hasNewline:m,anchor:g,tag:b,newlineAfterProp:w,end:E,start:v??E}}Jl.resolveProps=wh});var ai=P(Hl=>{"use strict";function rr(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(rr(t.key)||rr(t.value))return!0}return!1;default:return!0}}Hl.containsNewline=rr});var or=P(Wl=>{"use strict";var vh=ai();function kh(e,t,s){if(t?.type==="flow-collection"){let i=t.end[0];i.indent===e&&(i.source==="]"||i.source==="}")&&vh.containsNewline(t)&&s(i,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}Wl.flowIndentCheck=kh});var ar=P(Yl=>{"use strict";var Gl=j();function Sh(e,t,s){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let n=typeof i=="function"?i:(r,o)=>r===o||Gl.isScalar(r)&&Gl.isScalar(o)&&r.value===o.value;return t.some(r=>n(r.key,s))}Yl.mapIncludes=Sh});var tc=P(ec=>{"use strict";var zl=Ce(),$h=Pe(),Ql=Jt(),xh=ai(),Xl=or(),Eh=ar(),Zl="All mapping items must start at the same column";function Ch({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??$h.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=Ql.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",Zl)),!h.anchor&&!h.tag&&!m){c=h.end,h.comment&&(a.comment?a.comment+=`
|
|
66
|
+
`+h.comment:a.comment=h.comment);continue}(h.newlineAfterProp||xh.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",Zl);s.atKey=!0;let b=h.end,w=p?e(s,p,h,n):t(s,b,d,null,h,n);s.schema.compat&&Xl.flowIndentCheck(i.indent,p,n),s.atKey=!1,Eh.mapIncludes(s,a.items,w)&&n(b,"DUPLICATE_KEY","Map keys must be unique");let k=Ql.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&&Xl.flowIndentCheck(i.indent,y,n),l=S.range[2];let v=new zl.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 zl.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}ec.resolveBlockMap=Ch});var ic=P(sc=>{"use strict";var Ah=Ne(),Ph=Jt(),Nh=or();function Ih({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=r?.nodeClass??Ah.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=Ph.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&&Nh.flowIndentCheck(i.indent,d,n),l=m.range[2],a.items.push(m)}return a.range=[i.offset,l,c??l],a}sc.resolveBlockSeq=Ih});var lt=P(nc=>{"use strict";function Rh(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}}nc.resolveEnd=Rh});var lc=P(ac=>{"use strict";var Lh=j(),Oh=Ce(),rc=Pe(),Th=Ne(),Mh=lt(),oc=Jt(),Dh=ai(),Fh=ar(),lr="Block collections are not allowed within flow collections",cr=e=>e&&(e.type==="block-map"||e.type==="block-seq");function _h({composeNode:e,composeEmptyNode:t},s,i,n,r){let o=i.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?rc.YAMLMap:Th.YAMLSeq),c=new l(s.schema);c.flow=!0;let f=s.atRoot;f&&(s.atRoot=!1),s.atKey&&(s.atKey=!1);let d=i.offset+i.start.source.length;for(let g=0;g<i.items.length;++g){let b=i.items[g],{start:w,key:k,sep:S,value:v}=b,C=oc.resolveProps(w,{flow:a,indicator:"explicit-key-ind",next:k??S?.[0],offset:d,onError:n,parentIndent:i.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!S&&!v){g===0&&C.comma?n(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<i.items.length-1&&n(C.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),C.comment&&(c.comment?c.comment+=`
|
|
68
|
+
`+C.comment:c.comment=C.comment),d=C.end;continue}!o&&s.options.strict&&Dh.containsNewline(k)&&n(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)C.comma&&n(C.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(C.comma||n(C.start,"MISSING_CHAR",`Missing , between ${a} items`),C.comment){let E="";e:for(let x of w)switch(x.type){case"comma":case"space":break;case"comment":E=x.source.substring(1);break e;default:break e}if(E){let x=c.items[c.items.length-1];Lh.isPair(x)&&(x=x.value??x.key),x.comment?x.comment+=`
|
|
69
|
+
`+E:x.comment=E,C.comment=C.comment.substring(E.length+1)}}if(!o&&!S&&!C.found){let E=v?e(s,v,C,n):t(s,C.end,S,null,C,n);c.items.push(E),d=E.range[2],cr(v)&&n(E.range,"BLOCK_IN_FLOW",lr)}else{s.atKey=!0;let E=C.end,x=k?e(s,k,C,n):t(s,E,w,null,C,n);cr(k)&&n(x.range,"BLOCK_IN_FLOW",lr),s.atKey=!1;let M=oc.resolveProps(S??[],{flow:a,indicator:"map-value-ind",next:v,offset:x.range[2],onError:n,parentIndent:i.indent,startOnNewline:!1});if(M.found){if(!o&&!C.found&&s.options.strict){if(S)for(let T of S){if(T===M.found)break;if(T.type==="newline"){n(T,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}C.start<M.found.offset-1024&&n(M.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else v&&("source"in v&&v.source?.[0]===":"?n(v,"MISSING_CHAR",`Missing space after : in ${a}`):n(M.start,"MISSING_CHAR",`Missing , or : between ${a} items`));let O=v?e(s,v,M,n):M.found?t(s,M.end,S,null,M,n):null;O?cr(v)&&n(O.range,"BLOCK_IN_FLOW",lr):M.comment&&(x.comment?x.comment+=`
|
|
70
|
+
`+M.comment:x.comment=M.comment);let D=new Oh.Pair(x,O);if(s.options.keepSourceTokens&&(D.srcToken=b),o){let T=c;Fh.mapIncludes(s,T.items,x)&&n(E,"DUPLICATE_KEY","Map keys must be unique"),T.items.push(D)}else{let T=new rc.YAMLMap(s.schema);T.flow=!0,T.items.push(D);let A=(O??x).range;T.range=[x.range[0],A[1],A[2]],c.items.push(T)}d=O?O.range[2]:M.end}}let p=o?"}":"]",[m,...y]=i.end,h=d;if(m?.source===p)h=m.offset+m.source.length;else{let g=a[0].toUpperCase()+a.substring(1),b=f?`${g} must end with a ${p}`:`${g} in block collection must be sufficiently indented and end with a ${p}`;n(d,f?"MISSING_CHAR":"BAD_INDENT",b),m&&m.source.length!==1&&y.unshift(m)}if(y.length>0){let g=Mh.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}ac.resolveFlowCollection=_h});var uc=P(cc=>{"use strict";var jh=j(),qh=K(),Bh=Pe(),Uh=Ne(),Kh=tc(),Vh=ic(),Jh=lc();function ur(e,t,s,i,n,r){let o=s.type==="block-map"?Kh.resolveBlockMap(e,t,s,i,r):s.type==="block-seq"?Vh.resolveBlockSeq(e,t,s,i,r):Jh.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 Hh(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===Bh.YAMLMap.tagName&&a==="map"||o===Uh.YAMLSeq.tagName&&a==="seq")return ur(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),ur(e,t,s,n,o)}let c=ur(e,t,s,n,o,l),f=l.resolve?.(c,p=>n(r,"TAG_RESOLVE_FAILED",p),t.options)??c,d=jh.isNode(f)?f:new qh.Scalar(f);return d.range=c.range,d.tag=o,l?.format&&(d.format=l.format),d}cc.composeCollection=Hh});var fr=P(dc=>{"use strict";var dr=K();function Wh(e,t,s){let i=t.offset,n=Gh(t,e.options.strict,s);if(!n)return{value:"",type:null,comment:"",range:[i,i,i]};let r=n.mode===">"?dr.Scalar.BLOCK_FOLDED:dr.Scalar.BLOCK_LITERAL,o=t.source?Yh(t.source):[],a=o.length;for(let h=o.length-1;h>=0;--h){let g=o[h][1];if(g===""||g==="\r")a=h;else break}if(a===0){let h=n.chomp==="+"&&o.length>0?`
|
|
72
72
|
`.repeat(Math.max(1,o.length-1)):"",g=i+n.length;return t.source&&(g+=t.source.length),{value:h,type:r,comment:n.comment,range:[i,g,g]}}let l=t.indent+n.indent,c=t.offset+n.length,f=0;for(let h=0;h<a;++h){let[g,b]=o[h];if(b===""||b==="\r")n.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&s(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),n.indent===0&&(l=g.length),f=h,l===0&&!e.atRoot&&s(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+b.length+1}for(let h=o.length-1;h>=a;--h)o[h][0].length>l&&(a=h+1);let d="",p="",m=!1;for(let h=0;h<f;++h)d+=o[h][0].slice(l)+`
|
|
73
|
-
`;for(let h=f;h<a;++h){let[g,b]=o[h];c+=g.length+b.length+1;let w=b[b.length-1]==="\r";if(w&&(b=b.slice(0,-1)),b&&g.length<l){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;s(c-b.length-(w?2:1),"BAD_INDENT",S),g=""}r===
|
|
73
|
+
`;for(let h=f;h<a;++h){let[g,b]=o[h];c+=g.length+b.length+1;let w=b[b.length-1]==="\r";if(w&&(b=b.slice(0,-1)),b&&g.length<l){let S=`Block scalar lines must not be less indented than their ${n.indent?"explicit indentation indicator":"first line"}`;s(c-b.length-(w?2:1),"BAD_INDENT",S),g=""}r===dr.Scalar.BLOCK_LITERAL?(d+=p+g.slice(l)+b,p=`
|
|
74
74
|
`):g.length>l||b[0]===" "?(p===" "?p=`
|
|
75
75
|
`:!m&&p===`
|
|
76
76
|
`&&(p=`
|
|
@@ -83,84 +83,84 @@ ${c}
|
|
|
83
83
|
`+o[h][0].slice(l);d[d.length-1]!==`
|
|
84
84
|
`&&(d+=`
|
|
85
85
|
`);break;default:d+=`
|
|
86
|
-
`}let y=i+n.length+t.source.length;return{value:d,type:r,comment:n.comment,range:[i,y,y]}}function
|
|
86
|
+
`}let y=i+n.length+t.source.length;return{value:d,type:r,comment:n.comment,range:[i,y,y]}}function Gh({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 Yh(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}dc.resolveBlockScalar=Wh});var mr=P(pc=>{"use strict";var pr=K(),zh=lt();function Qh(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=pr.Scalar.PLAIN,l=Xh(r,c);break;case"single-quoted-scalar":a=pr.Scalar.QUOTE_SINGLE,l=Zh(r,c);break;case"double-quoted-scalar":a=pr.Scalar.QUOTE_DOUBLE,l=eg(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=zh.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}`),fc(e)}function Zh(e,t){return(e[e.length-1]!=="'"||e.length===1)&&t(e.length,"MISSING_CHAR","Missing closing 'quote"),fc(e.slice(1,-1)).replace(/''/g,"'")}function fc(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 eg(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}=tg(e,i);s+=r,i=o}else if(n==="\\"){let r=e[++i],o=sg[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+=ig(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 tg(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 sg={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 ig(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)}pc.resolveFlowScalar=Qh});var gc=P(hc=>{"use strict";var Ke=j(),mc=K(),ng=fr(),rg=mr();function og(e,t,s,i){let{value:n,type:r,comment:o,range:a}=t.type==="block-scalar"?ng.resolveBlockScalar(e,t,i):rg.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[Ke.SCALAR]:l?c=ag(e.schema,n,l,s,i):t.type==="scalar"?c=lg(e,n,t,i):c=e.schema[Ke.SCALAR];let f;try{let d=c.resolve(n,p=>i(s??t,"TAG_RESOLVE_FAILED",p),e.options);f=Ke.isScalar(d)?d:new mc.Scalar(d)}catch(d){let p=d instanceof Error?d.message:String(d);i(s??t,"TAG_RESOLVE_FAILED",p),f=new mc.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 ag(e,t,s,i,n){if(s==="!")return e[Ke.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[Ke.SCALAR])}function lg({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[Ke.SCALAR];if(s.compat){let a=s.compat.find(l=>l.default&&l.test?.test(i))??s[Ke.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}hc.composeScalar=og});var bc=P(yc=>{"use strict";function cg(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}yc.emptyScalarPosition=cg});var kc=P(gr=>{"use strict";var ug=xt(),dg=j(),fg=uc(),wc=gc(),pg=lt(),mg=bc(),hg={composeNode:vc,composeEmptyNode:hr};function vc(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=gg(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=wc.composeScalar(e,t,l,i),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":try{c=fg.composeCollection(hg,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=hr(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&&(!dg.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 hr(e,t,s,i,{spaceBefore:n,comment:r,anchor:o,tag:a,end:l},c){let f={type:"scalar",offset:mg.emptyScalarPosition(t,s,i),indent:-1,source:""},d=wc.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 gg({options:e},{offset:t,source:s,end:i},n){let r=new ug.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=pg.resolveEnd(i,o,e.strict,n);return r.range=[t,o,a.offset],a.comment&&(r.comment=a.comment),r}gr.composeEmptyNode=hr;gr.composeNode=vc});var xc=P($c=>{"use strict";var yg=Bt(),Sc=kc(),bg=lt(),wg=Jt();function vg(e,t,{offset:s,start:i,value:n,end:r},o){let a=Object.assign({_directives:t},e),l=new yg.Document(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=wg.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?Sc.composeNode(c,n,f,o):Sc.composeEmptyNode(c,f.end,i,null,f,o);let d=l.contents.range[2],p=bg.resolveEnd(r,d,!1,o);return p.comment&&(l.comment=p.comment),l.range=[s,d,p.offset],l}$c.composeDoc=vg});var br=P(Ac=>{"use strict";var kg=os("process"),Sg=sn(),$g=Bt(),Ht=Vt(),Ec=j(),xg=xc(),Eg=lt();function Wt(e){if(typeof e=="number")return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:s}=e;return[t,t+(typeof s=="string"?s.length:1)]}function 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 yr=class{constructor(t={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(s,i,n,r)=>{let o=Wt(s);r?this.warnings.push(new Ht.YAMLWarning(o,i,n)):this.errors.push(new Ht.YAMLParseError(o,i,n))},this.directives=new Sg.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(Ec.isCollection(r)&&!r.flow&&r.items.length>0){let o=r.items[0];Ec.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(kg.env.LOG_STREAM&&console.dir(t,{depth:null}),t.type){case"directive":this.directives.add(t.source,(s,i,n)=>{let r=Wt(t);r[0]+=s,this.onError(r,"BAD_DIRECTIVE",i,n)}),this.prelude.push(t.source),this.atDirectives=!0;break;case"document":{let s=xg.composeDoc(this.options,this.directives,t,this.onError);this.atDirectives&&!s.directives.docStart&&this.onError(t,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(s,!1),this.doc&&(yield this.doc),this.doc=s,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(t.source);break;case"error":{let s=t.source?`${t.message}: ${JSON.stringify(t.source)}`:t.message,i=new Ht.YAMLParseError(Wt(t),"UNEXPECTED_TOKEN",s);this.atDirectives||!this.doc?this.errors.push(i):this.doc.errors.push(i);break}case"doc-end":{if(!this.doc){let i="Unexpected doc-end without preceding document";this.errors.push(new Ht.YAMLParseError(Wt(t),"UNEXPECTED_TOKEN",i));break}this.doc.directives.docEnd=!0;let s=Eg.resolveEnd(t.end,t.offset+t.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),s.comment){let i=this.doc.comment;this.doc.comment=i?`${i}
|
|
108
|
+
${s.comment}`:s.comment}this.doc.range[2]=s.offset;break}default:this.errors.push(new Ht.YAMLParseError(Wt(t),"UNEXPECTED_TOKEN",`Unsupported token ${t.type}`))}}*end(t=!1,s=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(t){let i=Object.assign({_directives:this.directives},this.options),n=new $g.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}}};Ac.Composer=yr});var Ic=P(li=>{"use strict";var Cg=fr(),Ag=mr(),Pg=Vt(),Pc=Nt();function Ng(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 Pg.YAMLParseError([a,a+1],r,o)};switch(e.type){case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return Ag.resolveFlowScalar(e,t,i);case"block-scalar":return Cg.resolveBlockScalar({options:{strict:t}},e,i)}}return null}function Ig(e,t){let{implicitKey:s=!1,indent:i,inFlow:n=!1,offset:r=-1,type:o="PLAIN"}=t,a=Pc.stringifyString({type:o,value:e},{implicitKey:s,indent:i>0?" ".repeat(i):"",inFlow:n,options:{blockQuote:!0,lineWidth:-1}}),l=t.end??[{type:"newline",offset:-1,indent:i,source:`
|
|
109
109
|
`}];switch(a[0]){case"|":case">":{let c=a.indexOf(`
|
|
110
110
|
`),f=a.substring(0,c),d=a.substring(c+1)+`
|
|
111
|
-
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return
|
|
112
|
-
`}),{type:"block-scalar",offset:r,indent:i,props:p,source:d}}case'"':return{type:"double-quoted-scalar",offset:r,indent:i,source:a,end:l};case"'":return{type:"single-quoted-scalar",offset:r,indent:i,source:a,end:l};default:return{type:"scalar",offset:r,indent:i,source:a,end:l}}}function
|
|
111
|
+
`,p=[{type:"block-scalar-header",offset:r,indent:i,source:f}];return Nc(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 Rg(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=Pc.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">":Lg(e,l);break;case'"':wr(e,l,"double-quoted-scalar");break;case"'":wr(e,l,"single-quoted-scalar");break;default:wr(e,l,"scalar")}}function Lg(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}];Nc(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 Nc(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 wr(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})}}}li.createScalarToken=Ig;li.resolveAsScalar=Ng;li.setScalarValue=Rg});var Lc=P(Rc=>{"use strict";var Og=e=>"type"in e?ui(e):ci(e);function ui(e){switch(e.type){case"block-scalar":{let t="";for(let s of e.props)t+=ui(s);return t+e.source}case"block-map":case"block-seq":{let t="";for(let s of e.items)t+=ci(s);return t}case"flow-collection":{let t=e.start.source;for(let s of e.items)t+=ci(s);for(let s of e.end)t+=s.source;return t}case"document":{let t=ci(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 ci({start:e,key:t,sep:s,value:i}){let n="";for(let r of e)n+=r.source;if(t&&(n+=ui(t)),s)for(let r of s)n+=r.source;return i&&(n+=ui(i)),n}Rc.stringify=Og});var Dc=P(Mc=>{"use strict";var vr=Symbol("break visit"),Tg=Symbol("skip children"),Oc=Symbol("remove item");function Ve(e,t){"type"in e&&e.type==="document"&&(e={start:e.start,value:e.value}),Tc(Object.freeze([]),e,t)}Ve.BREAK=vr;Ve.SKIP=Tg;Ve.REMOVE=Oc;Ve.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};Ve.parentCollection=(e,t)=>{let s=Ve.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 Tc(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=Tc(Object.freeze(e.concat([[n,o]])),r.items[o],s);if(typeof a=="number")o=a-1;else{if(a===vr)return vr;a===Oc&&(r.items.splice(o,1),o-=1)}}typeof i=="function"&&n==="key"&&(i=i(t,e))}}return typeof i=="function"?i(t,e):i}Mc.visit=Ve});var di=P(ie=>{"use strict";var kr=Ic(),Mg=Lc(),Dg=Dc(),Sr="\uFEFF",$r="",xr="",Er="",Fg=e=>!!e&&"items"in e,_g=e=>!!e&&(e.type==="scalar"||e.type==="single-quoted-scalar"||e.type==="double-quoted-scalar"||e.type==="block-scalar");function jg(e){switch(e){case Sr:return"<BOM>";case $r:return"<DOC>";case xr:return"<FLOW_END>";case Er:return"<SCALAR>";default:return JSON.stringify(e)}}function qg(e){switch(e){case Sr:return"byte-order-mark";case $r:return"doc-mode";case xr:return"flow-error-end";case Er: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}ie.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}ie.createScalarToken=kr.createScalarToken;ie.resolveAsScalar=kr.resolveAsScalar;ie.setScalarValue=kr.setScalarValue;ie.stringify=Mg.stringify;ie.visit=Dg.visit;ie.BOM=Sr;ie.DOCUMENT=$r;ie.FLOW_END=xr;ie.SCALAR=Er;ie.isCollection=Fg;ie.isScalar=_g;ie.prettyToken=jg;ie.tokenType=qg});var Pr=P(_c=>{"use strict";var Gt=di();function pe(e){switch(e){case void 0:case" ":case`
|
|
119
|
+
`:case"\r":case" ":return!0;default:return!1}}var Fc=new Set("0123456789ABCDEFabcdef"),Bg=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),fi=new Set(",[]{}"),Ug=new Set(` ,[]{}
|
|
120
|
+
\r `),Cr=e=>!e||Ug.has(e),Ar=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==="...")&&pe(this.buffer[t+3]))return-1}return t}getLine(){let t=this.lineEndPos;return(typeof t!="number"||t!==-1&&t<this.pos)&&(t=this.buffer.indexOf(`
|
|
125
|
+
`,this.pos),this.lineEndPos=t),t===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[t-1]==="\r"&&(t-=1),this.buffer.substring(this.pos,t))}hasChars(t){return this.pos+t<=this.buffer.length}setNext(t){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=t,null}peek(t){return this.buffer.substr(this.pos,t)}*parseNext(t){switch(t){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let t=this.getLine();if(t===null)return this.setNext("stream");if(t[0]===Gt.BOM&&(yield*this.pushCount(1),t=t.substring(1)),t[0]==="%"){let s=t.length,i=t.indexOf("#");for(;i!==-1;){let r=t[i-1];if(r===" "||r===" "){s=i-1;break}else i=t.indexOf("#",i+1)}for(;;){let r=t[s-1];if(r===" "||r===" ")s-=1;else break}let n=(yield*this.pushCount(s))+(yield*this.pushSpaces(!0));return yield*this.pushCount(t.length-n),this.pushNewline(),"stream"}if(this.atLineEnd()){let s=yield*this.pushSpaces(!0);return yield*this.pushCount(t.length-s),yield*this.pushNewline(),"stream"}return yield Gt.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let t=this.charAt(0);if(!t&&!this.atEnd)return this.setNext("line-start");if(t==="-"||t==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");let s=this.peek(3);if((s==="---"||s==="...")&&pe(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&&!pe(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===":")&&pe(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(Cr),"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("..."))&&pe(n[3]))&&!(i===this.indentNext-1&&this.flowLevel===1&&(n[0]==="]"||n[0]==="}")))return this.flowLevel=0,yield Gt.FLOW_END,yield*this.parseLineStart();let r=0;for(;n[r]===",";)r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),n[r]){case void 0:return"flow";case"#":return yield*this.pushCount(n.length-r),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(Cr),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{let o=this.charAt(1);if(this.flowKey||pe(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=>pe(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 Gt.SCALAR,yield*this.pushToIndex(t+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let t=this.flowLevel>0,s=this.pos-1,i=this.pos-1,n;for(;n=this.buffer[++i];)if(n===":"){let r=this.buffer[i+1];if(pe(r)||t&&fi.has(r))break;s=i}else if(pe(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&&fi.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&&fi.has(n))break;s=i}return!n&&!this.atEnd?this.setNext("plain-scalar"):(yield Gt.SCALAR,yield*this.pushToIndex(s+1,!0),t?"flow":"doc")}*pushCount(t){return t>0?(yield this.buffer.substr(this.pos,t),this.pos+=t,t):0}*pushToIndex(t,s){let i=this.buffer.slice(this.pos,t);return i?(yield i,this.pos+=i.length,i.length):(s&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(Cr))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{let t=this.flowLevel>0,s=this.charAt(1);if(pe(s)||t&&fi.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(;!pe(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(Bg.has(s))s=this.buffer[++t];else if(s==="%"&&Fc.has(this.buffer[t+1])&&Fc.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)}};_c.Lexer=Ar});var Ir=P(jc=>{"use strict";var Nr=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}}}};jc.LineCounter=Nr});var Lr=P(Vc=>{"use strict";var Kg=os("process"),qc=di(),Vg=Pr();function Ie(e,t){for(let s=0;s<e.length;++s)if(e[s].type===t)return!0;return!1}function Bc(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 Kc(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 pi(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 Uc(e){if(e.start.type==="flow-seq-start")for(let t of e.items)t.sep&&!t.value&&!Ie(t.start,"explicit-key-ind")&&!Ie(t.sep,"map-value-ind")&&(t.key&&(t.value=t.key),delete t.key,Kc(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 Rr=class{constructor(t){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Vg.Lexer,this.onNewLine=t}*parse(t,s=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let i of this.lexer.lex(t,s))yield*this.next(i);s||(yield*this.end())}*next(t){if(this.source=t,Kg.env.LOG_TOKENS&&console.log("|",qc.prettyToken(t)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=t.length;return}let s=qc.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"&&Uc(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&&Bc(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":{Bc(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=pi(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(
|
|
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(Ie(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(Kc(s.key)&&!Ie(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(Ie(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]}):Ie(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&&!Ie(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||Ie(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=pi(i),r=ct(n);Uc(t);let o=t.end.splice(1,t.end.length);o.push(this.sourceToken);let a={type:"block-map",offset:t.offset,indent:t.indent,items:[{start:r,key:t,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(t)}}flowScalar(t){if(this.onNewLine){let s=this.source.indexOf(`
|
|
140
140
|
`)+1;for(;s!==0;)this.onNewLine(this.offset+s),s=this.source.indexOf(`
|
|
141
|
-
`,s)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let s=
|
|
142
|
-
`,"utf-8")}function
|
|
143
|
-
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var
|
|
141
|
+
`,s)+1}return{type:t,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(t){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;let s=pi(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=pi(t),i=ct(s);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:i,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(t,s){return this.type!=="comment"||this.indent<=s?!1:t.every(i=>i.type==="newline"||i.type==="space")}*documentEnd(t){this.type!=="doc-mode"&&(t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(t){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;case"space":case"comment":default:t.end?t.end.push(this.sourceToken):t.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}};Vc.Parser=Rr});var Yc=P(zt=>{"use strict";var Jc=br(),Jg=Bt(),Yt=Vt(),Hg=gn(),Wg=j(),Gg=Ir(),Hc=Lr();function Wc(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new Gg.LineCounter||null,prettyErrors:t}}function Yg(e,t={}){let{lineCounter:s,prettyErrors:i}=Wc(t),n=new Hc.Parser(s?.addNewLine),r=new Jc.Composer(t),o=Array.from(r.compose(n.parse(e)));if(i&&s)for(let a of o)a.errors.forEach(Yt.prettifyError(e,s)),a.warnings.forEach(Yt.prettifyError(e,s));return o.length>0?o:Object.assign([],{empty:!0},r.streamInfo())}function Gc(e,t={}){let{lineCounter:s,prettyErrors:i}=Wc(t),n=new Hc.Parser(s?.addNewLine),r=new Jc.Composer(t),o=null;for(let a of r.compose(n.parse(e),!0,e.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new Yt.YAMLParseError(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return i&&s&&(o.errors.forEach(Yt.prettifyError(e,s)),o.warnings.forEach(Yt.prettifyError(e,s))),o}function zg(e,t,s){let i;typeof t=="function"?i=t:s===void 0&&t&&typeof t=="object"&&(s=t);let n=Gc(e,s);if(!n)return null;if(n.warnings.forEach(r=>Hg.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 Qg(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 Jg.Document(e,i,s).toString(s)}zt.parse=zg;zt.parseAllDocuments=Yg;zt.parseDocument=Gc;zt.stringify=Qg});var Tr=P(q=>{"use strict";var Xg=br(),Zg=Bt(),ey=Xn(),Or=Vt(),ty=xt(),Re=j(),sy=Ce(),iy=K(),ny=Pe(),ry=Ne(),oy=di(),ay=Pr(),ly=Ir(),cy=Lr(),mi=Yc(),zc=vt();q.Composer=Xg.Composer;q.Document=Zg.Document;q.Schema=ey.Schema;q.YAMLError=Or.YAMLError;q.YAMLParseError=Or.YAMLParseError;q.YAMLWarning=Or.YAMLWarning;q.Alias=ty.Alias;q.isAlias=Re.isAlias;q.isCollection=Re.isCollection;q.isDocument=Re.isDocument;q.isMap=Re.isMap;q.isNode=Re.isNode;q.isPair=Re.isPair;q.isScalar=Re.isScalar;q.isSeq=Re.isSeq;q.Pair=sy.Pair;q.Scalar=iy.Scalar;q.YAMLMap=ny.YAMLMap;q.YAMLSeq=ry.YAMLSeq;q.CST=oy;q.Lexer=ay.Lexer;q.LineCounter=ly.LineCounter;q.Parser=cy.Parser;q.parse=mi.parse;q.parseAllDocuments=mi.parseAllDocuments;q.parseDocument=mi.parseDocument;q.stringify=mi.stringify;q.visit=zc.visit;q.visitAsync=zc.visitAsync});import{readFile as nf,writeFile as rf,mkdir as of,rename as Uo,copyFile as af,access as lf,realpath as cf}from"node:fs/promises";import{join as Ko,dirname as uf}from"node:path";function Bo(){return{version:1,disabled:{}}}async function cs(e){let t=e??Di(),s;try{s=await nf(t,"utf-8")}catch(i){if(i?.code==="ENOENT")return I("skill-state: file not found, returning empty state"),Bo();throw i}try{let i=JSON.parse(s);if(!i||typeof i!="object"||i.version!==1||typeof i.disabled!="object"||i.disabled===null)throw new Error("invalid schema");return i}catch{let i=t+".bak";I(`skill-state: parse error, backing up to ${i}`);try{await af(t,i)}catch{}return console.error(`Warning: skill-state.json was corrupted. Backup saved to ${i}. Starting fresh.`),Bo()}}async function Ji(e,t){let s=t??Di();await of(uf(s),{recursive:!0}),await rf(s,JSON.stringify(e,null,2)+`
|
|
142
|
+
`,"utf-8")}function Vo(e,t,s,i){let n=e.disabled[t]??={},r=n[s]??={};r[i]=!0}function Jo(e,t,s,i){let n=e.disabled[t];if(!n)return;let r=n[s];r&&(delete r[i],Object.keys(r).length===0&&delete n[s],Object.keys(n).length===0&&delete e.disabled[t])}function df(e){return e.replace(/[.+?^${}()|[\]\\]/g,"\\$&")}function ff(e){if(e==="*"||e==="all")return{kind:"all",test:()=>!0};if(e.includes("*")){let t=new RegExp("^"+df(e).replace(/\*/g,".*")+"$");return{kind:"wildcard",test:s=>t.test(s)}}return e.endsWith(":")||e.endsWith("-")?{kind:"prefix",test:t=>t.startsWith(e)}:{kind:"exact",test:t=>t===e}}function Hi(e,t){let s=ff(t);return e.filter(i=>s.test(i.name)||s.test(i.dirName))}function Ho(e){return Ko(e,"SKILL.md")}function us(e){return Ko(e,"SKILL.md.disabled")}async function ls(e){try{return await lf(e),!0}catch{return!1}}async function Wo(e){try{return await cf(e)}catch{return e}}async function Go(e){let t=await Wo(e),s=Ho(t),i=us(t);return!await ls(s)&&await ls(i)?!1:(await Uo(s,i),!0)}async function Yo(e){let t=await Wo(e),s=Ho(t),i=us(t);return!await ls(i)&&await ls(s)?!1:(await Uo(i,s),!0)}import{readFile as Vv,realpath as Jv}from"fs/promises";import{existsSync as Hv}from"fs";import{execFile as vf}from"child_process";import{promisify as kf}from"util";import{mkdtemp as zo,readdir as Sf,readFile as ps,rm as ms,cp as $f,access as hs,stat as ea,lstat as xf,symlink as Ef,mkdir as Cf}from"fs/promises";import{join as ce,resolve as zi,relative as Af,basename as ta}from"path";import{homedir as Qo}from"os";import{tmpdir as Xo}from"os";import{readdir as pf,readFile as mf,stat as hf}from"fs/promises";import{join as gf}from"path";var yf=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"]),bf=512*1024;async function ds(e){let t=[];async function s(i,n){let r;try{r=await pf(i)}catch{return}for(let o of r){if(o===".git"||o==="node_modules")continue;let a=gf(i,o),l=n?`${n}/${o}`:o;try{let c=await hf(a);if(c.isDirectory())await s(a,l);else if(c.isFile()){let f=o.includes(".")?`.${o.split(".").pop().toLowerCase()}`:"";if(yf.has(f)||c.size>bf)continue;try{let d=await mf(a,"utf-8");t.push({relPath:l,content:d,lineCount:d.split(`
|
|
143
|
+
`).length})}catch{}}}catch{continue}}}return await s(e,""),t}var Gi=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 wf(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=Wi(m.hint,S);i.push(`${g}${w} ${u.dim(v)}`)}else{let v=Wi(m.label,s-b);i.push(`${g}${u.bold(v)}`)}}else{let S=Wi(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 Wi(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 Gi(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=wf(i,t,o);a>0&&n.write(`\x1B[${a}F`);let f=Math.max(c.length,a),d="";for(let p=0;p<f;p++)d+=`\x1B[2K${p<c.length?c[p]:""}
|
|
144
144
|
`;n.write(d),a=f}return l(),new Promise(c=>{let f="",d=null;function p(){r.removeListener("data",h),typeof r.setRawMode=="function"&&r.setRawMode(!1),r.pause(),n.write("\x1B[?25h"),d&&clearTimeout(d)}function m(g){p(),c(g)}function y(g){if(i.searchActive){if(g==="\x1B"){i.searchActive=!1,i.filter="",i.applyFilter(t),l();return}if(g==="\r"||g===`
|
|
145
145
|
`){i.searchActive=!1,l();return}if(g==="\x7F"||g==="\b"){i.filter.length>0?(i.filter=i.filter.slice(0,-1),i.applyFilter(t)):i.searchActive=!1,l();return}if(g===""){p(),process.kill(process.pid,"SIGINT");return}if(g==="\x1B[A"){i.moveUp(),l();return}if(g==="\x1B[B"){i.moveDown(),l();return}if(g===" "){i.toggleCurrent(),l();return}if(g.length===1&&g>=" "&&g<="~"){i.filter+=g,i.applyFilter(t),l();return}return}switch(g){case"\x1B[A":case"k":i.moveUp(),l();break;case"\x1B[B":case"j":i.moveDown(),l();break;case" ":i.toggleCurrent(),l();break;case"a":i.toggleAll(),l();break;case"/":i.searchActive=!0,l();break;case"\r":case`
|
|
146
|
-
`:m(i.getSelectedIndices());break;case"\x1B":i.filter!==""?(i.filter="",i.applyFilter(t),l()):m([]);break;case"\x7F":case"\b":i.filter.length>0&&(i.filter=i.filter.slice(0,-1),i.applyFilter(t),l());break;case"":p(),process.kill(process.pid,"SIGINT");break}}function h(g){if(f.length>0){if(f+=g,d&&clearTimeout(d),f.length>=3&&f[1]==="["){let w=f.slice(0,3),k=f.slice(3);f="",y(w),k&&h(k);return}let b=f;f="",y("\x1B");for(let w=1;w<b.length;w++)y(b[w]);return}for(let b=0;b<g.length;b++){let w=g[b];if(w==="\x1B"){let k=g.slice(b);if(k.length>=3&&k[1]==="[")y(k.slice(0,3)),b+=2;else if(k.length>=2){f=k,d=setTimeout(()=>{let S=f;f="",y("\x1B");for(let v=1;v<S.length;v++)y(S[v])},50);return}else{f="\x1B",d=setTimeout(()=>{f="",y("\x1B")},50);return}}else y(w)}}r.on("data",h)})}var
|
|
146
|
+
`:m(i.getSelectedIndices());break;case"\x1B":i.filter!==""?(i.filter="",i.applyFilter(t),l()):m([]);break;case"\x7F":case"\b":i.filter.length>0&&(i.filter=i.filter.slice(0,-1),i.applyFilter(t),l());break;case"":p(),process.kill(process.pid,"SIGINT");break}}function h(g){if(f.length>0){if(f+=g,d&&clearTimeout(d),f.length>=3&&f[1]==="["){let w=f.slice(0,3),k=f.slice(3);f="",y(w),k&&h(k);return}let b=f;f="",y("\x1B");for(let w=1;w<b.length;w++)y(b[w]);return}for(let b=0;b<g.length;b++){let w=g[b];if(w==="\x1B"){let k=g.slice(b);if(k.length>=3&&k[1]==="[")y(k.slice(0,3)),b+=2;else if(k.length>=2){f=k,d=setTimeout(()=>{let S=f;f="",y("\x1B");for(let v=1;v<S.length;v++)y(S[v])},50);return}else{f="\x1B",d=setTimeout(()=>{f="",y("\x1B")},50);return}}else y(w)}}r.on("data",h)})}var ke=kf(vf),Pf=/^[a-zA-Z0-9_-]+$/,Nf=/^[a-zA-Z0-9._-]+$/,If=/^[a-zA-Z0-9][a-zA-Z0-9._-]*$/,Zo=128,Rf=/^https?:\/\/github\.com\/([^/]+)\/([^/]+?)(?:\/tree\/(.+))?\/?$/;function Qi(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 sa(e){if(!e.includes("/")&&!e.includes("\\"))return!1;try{return(await ea(zi(e))).isDirectory()}catch{return!1}}function Lf(e){let t;e==="~"?t=Qo():e.startsWith("~/")||e.startsWith("~\\")?t=zi(Qo(),e.slice(2)):t=zi(e);let s=ta(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(Qi(e))return Lf(e);let t=Rf.exec(e);if(t){let[,d,p,m]=t,y=p.endsWith(".git")?p.slice(0,-4):p;e=`github:${d}/${y}${m?`#${m}`:""}`}if(!e.startsWith("github:"))throw new Error(`Invalid source format. Got: "${e}"
|
|
147
147
|
Supported formats:
|
|
148
148
|
github:owner/repo[#ref]
|
|
149
149
|
github:owner/repo#ref:path
|
|
150
150
|
https://github.com/owner/repo
|
|
151
151
|
https://github.com/owner/repo/tree/branch/path/to/skill
|
|
152
152
|
/path/to/local/skill
|
|
153
|
-
./relative/path/to/skill`);let s=e.slice(7),i=s.indexOf("#"),n,r=null,o=null;if(i!==-1){n=s.slice(0,i);let d=s.slice(i+1);if(!d)throw new Error("Invalid source: ref cannot be empty after #");let p=d.indexOf(":");if(p!==-1){if(r=d.slice(0,p),!r)throw new Error("Invalid source: ref cannot be empty before :");o=d.slice(p+1)||null}else r=d}else{let d=s.indexOf(":");d!==-1?(n=s.slice(0,d),o=s.slice(d+1)||null):n=s}let a=n.indexOf("/");if(a===-1)throw new Error(`Invalid source: format must be github:owner/repo. Got: "${e}"`);let l=n.slice(0,a),c=n.slice(a+1);if(!l)throw new Error("Invalid source: owner cannot be empty");if(!c)throw new Error("Invalid source: repo cannot be empty");if(!Pf.test(l))throw new Error(`Invalid source: owner contains invalid characters: "${l}". Allowed: [a-zA-Z0-9_-]`);if(!Nf.test(c))throw new Error(`Invalid source: repo contains invalid characters: "${c}". Allowed: [a-zA-Z0-9._-]`);let f={owner:l,repo:c,ref:r,subpath:o,cloneUrl:`https://github.com/${l}/${c}.git`,sshCloneUrl:`git@github.com:${l}/${c}.git`};return I(`install: parsed source -> owner=${l} repo=${c} ref=${r} subpath=${o}`),f}async function
|
|
154
|
-
`)){let r=n.match(/\trefs\/(?:heads|tags)\/(.+)$/);r&&s.add(r[1])}let i=e.ref.split("/");for(let n=1;n<i.length;n++){let r=i.slice(0,n).join("/");if(s.has(r)){let o=i.slice(n).join("/");return I(`install: resolved ref="${r}" subpath="${o}"`),{...e,ref:r,subpath:o||null}}}}catch(t){I(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function Me(e){if(!e)throw new Error("Invalid skill name: name cannot be empty");if(e.includes("\0"))throw new Error("Invalid skill name: contains unsafe characters (null byte)");if(e.includes(".."))throw new Error("Invalid skill name: contains unsafe characters (..)");if(e.includes("/")||e.includes("\\"))throw new Error("Invalid skill name: contains unsafe characters (path separator)");if(e.startsWith("."))throw new Error("Invalid skill name: must not start with a dot");if(e.length>Zo)throw new Error(`Invalid skill name: exceeds maximum length of ${Zo} characters`);if(!If.test(e))throw new Error(`Invalid skill name: "${e}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return e}function Of(e){let t=e.split(/[/\\]/).filter(Boolean),s=t.length>0?t[t.length-1]:e;return Me(s)}function
|
|
153
|
+
./relative/path/to/skill`);let s=e.slice(7),i=s.indexOf("#"),n,r=null,o=null;if(i!==-1){n=s.slice(0,i);let d=s.slice(i+1);if(!d)throw new Error("Invalid source: ref cannot be empty after #");let p=d.indexOf(":");if(p!==-1){if(r=d.slice(0,p),!r)throw new Error("Invalid source: ref cannot be empty before :");o=d.slice(p+1)||null}else r=d}else{let d=s.indexOf(":");d!==-1?(n=s.slice(0,d),o=s.slice(d+1)||null):n=s}let a=n.indexOf("/");if(a===-1)throw new Error(`Invalid source: format must be github:owner/repo. Got: "${e}"`);let l=n.slice(0,a),c=n.slice(a+1);if(!l)throw new Error("Invalid source: owner cannot be empty");if(!c)throw new Error("Invalid source: repo cannot be empty");if(!Pf.test(l))throw new Error(`Invalid source: owner contains invalid characters: "${l}". Allowed: [a-zA-Z0-9_-]`);if(!Nf.test(c))throw new Error(`Invalid source: repo contains invalid characters: "${c}". Allowed: [a-zA-Z0-9._-]`);let f={owner:l,repo:c,ref:r,subpath:o,cloneUrl:`https://github.com/${l}/${c}.git`,sshCloneUrl:`git@github.com:${l}/${c}.git`};return I(`install: parsed source -> owner=${l} repo=${c} ref=${r} subpath=${o}`),f}async function gs(e){if(e.subpath!==null||!e.ref||!e.ref.includes("/"))return e;try{let{stdout:t}=await ke("git",["ls-remote","--heads","--tags",e.cloneUrl],{timeout:15e3}),s=new Set;for(let n of t.split(`
|
|
154
|
+
`)){let r=n.match(/\trefs\/(?:heads|tags)\/(.+)$/);r&&s.add(r[1])}let i=e.ref.split("/");for(let n=1;n<i.length;n++){let r=i.slice(0,n).join("/");if(s.has(r)){let o=i.slice(n).join("/");return I(`install: resolved ref="${r}" subpath="${o}"`),{...e,ref:r,subpath:o||null}}}}catch(t){I(`install: ls-remote failed, treating entire ref as branch: ${t}`)}return e}function Me(e){if(!e)throw new Error("Invalid skill name: name cannot be empty");if(e.includes("\0"))throw new Error("Invalid skill name: contains unsafe characters (null byte)");if(e.includes(".."))throw new Error("Invalid skill name: contains unsafe characters (..)");if(e.includes("/")||e.includes("\\"))throw new Error("Invalid skill name: contains unsafe characters (path separator)");if(e.startsWith("."))throw new Error("Invalid skill name: must not start with a dot");if(e.length>Zo)throw new Error(`Invalid skill name: exceeds maximum length of ${Zo} characters`);if(!If.test(e))throw new Error(`Invalid skill name: "${e}" does not match allowed pattern [a-zA-Z0-9][a-zA-Z0-9._-]*`);return e}function Of(e){let t=e.split(/[/\\]/).filter(Boolean),s=t.length>0?t[t.length-1]:e;return Me(s)}function ia(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 ke("git",["--version"]),I("install: git available")}catch{throw new Error("git is required for installing skills. Install git from https://git-scm.com")}}function Tf(e){if(e.killed)return!1;let t=(e.stderr||e.message||"").toLowerCase();return t.includes("authentication failed")||t.includes("could not read username")||t.includes("repository not found")||t.includes("returned error: 403")||t.includes("returned error: 401")||t.includes("terminal prompts disabled")||t.includes("permission denied")}function fs(e){return e.killed?"Clone timed out after 60 seconds":`Clone failed: ${e.stderr||e.message}`}async function Yi(e,t,s){if(t!==null&&/^[0-9a-f]{40}$/i.test(t))return await ke("git",["clone","--no-checkout",e,s],{timeout:6e4}),await ke("git",["checkout",t],{cwd:s,timeout:3e4}),s;let n=["clone","--depth","1"];return t&&n.push("--branch",t),n.push(e,s),await ke("git",n,{timeout:6e4}),s}async function Fe(e,t="auto"){I(`install: cloning ${e.owner}/${e.repo}${e.ref?` (ref: ${e.ref})`:""} (transport: ${t})`);let s=await zo(ce(Xo(),"asm-install-"));if(t==="ssh"||t==="https"){let i=t==="ssh"?e.sshCloneUrl:e.cloneUrl;try{return await Yi(i,e.ref,s)}catch(n){throw await le(s),new Error(fs(n))}}try{return await Yi(e.cloneUrl,e.ref,s)}catch(i){if(!Tf(i))throw await le(s),new Error(fs(i));I("install: HTTPS clone failed with auth error, retrying with SSH..."),await le(s);let n=await zo(ce(Xo(),"asm-install-"));try{return await Yi(e.sshCloneUrl,e.ref,n)}catch(r){throw await le(n),new Error(`Clone failed with both transports:
|
|
155
155
|
HTTPS: ${fs(i)}
|
|
156
|
-
SSH: ${fs(r)}`)}}}async function _e(e){let t=
|
|
157
|
-
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of
|
|
158
|
-
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;I(`install: target ${e} \u2014 no conflict`)}}var
|
|
159
|
-
`),s=!1,i=!1;for(let n of t){if(n.trim()==="---")if(s){i=!0;continue}else{s=!0;continue}if(i&&n.trim().length>0)return!0}return!1}function
|
|
156
|
+
SSH: ${fs(r)}`)}}}async function _e(e){let t=ce(e,"SKILL.md"),s;try{s=await ps(t,"utf-8")}catch{throw new Error("Not a valid skill: SKILL.md not found in repository root")}let i=X(s),n=e.split(/[/\\]/).pop()||"unknown",r=i.name||n,o=ae(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 ys(e,t=5){let s=[];try{let n=await ps(ce(e,"SKILL.md"),"utf-8"),r=X(n);return s.push({relPath:"",name:r.name||ta(e),version:ae(r),description:(r.description||"").replace(/\s*\n\s*/g," ").trim(),effort:r.effort||r["metadata.effort"]||void 0,license:(r.license||"").trim(),creator:(r["metadata.creator"]||"").trim(),compatibility:(r.compatibility||"").trim(),allowedTools:Fi(r),tokenCount:bt(n)}),s}catch{}async function i(n,r,o){let a;try{a=await Sf(n)}catch{return}for(let l of a){if(l===".git"||l==="node_modules")continue;let c=ce(n,l);try{if(!(await ea(c)).isDirectory())continue}catch{continue}let f=r?`${r}/${l}`:l,d=o+1,p=ce(c,"SKILL.md");try{let m=await ps(p,"utf-8"),y=X(m);s.push({relPath:f,name:y.name||l,version:ae(y),description:(y.description||"").replace(/\s*\n\s*/g," ").trim(),effort:y.effort||y["metadata.effort"]||void 0,license:(y.license||"").trim(),creator:(y["metadata.creator"]||"").trim(),compatibility:(y.compatibility||"").trim(),allowedTools:Fi(y),tokenCount:bt(m)})}catch{d<t&&await i(c,f,d)}}}return await i(e,"",0),s.sort((n,r)=>n.name.localeCompare(r.name)),s}async function Mf(e,t=ke){let s=ce(e,"scripts"),i=ce(s,"package.json");try{await hs(i)}catch{I(`install: no scripts/package.json in ${e}; skipping npm install`);return}I(`install: installing script dependencies in ${s}`);try{await t("npm",["install"],{cwd:s,timeout:12e4})}catch(n){throw new Error(`Installed skill, but failed to install dependencies in scripts/: ${n.stderr||n.message}`)}}var Df=[{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 na(e){let t=[],s=await ds(e);for(let{relPath:i,content:n}of s){let r=n.split(`
|
|
157
|
+
`);for(let o=0;o<r.length;o++)for(let{category:a,pattern:l}of Df)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 bs(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 hs(e.targetDir),await ms(e.targetDir,{recursive:!0,force:!0})}catch{}let s=e.sourceDir;try{await $f(s,e.targetDir,{recursive:!0})}catch(a){throw new Error(`Failed to install: ${a.message}`)}let i=ce(e.targetDir,".git");try{await ms(i,{recursive:!0,force:!0})}catch{}I(`install: copied files to ${e.targetDir}`);let n=ce(e.targetDir,"SKILL.md");try{await hs(n)}catch{throw new Error("Installation verification failed: SKILL.md not found at target")}await Mf(e.targetDir);let r=await ps(n,"utf-8"),o=X(r);return{success:!0,path:e.targetDir,name:o.name||e.skillName,version:ae(o),provider:e.providerLabel,source:t}}async function ra(e,t){let s=await bs(e);for(let i of t){if(i.name===e.providerName)continue;let n=e.scope==="project"?i.project:i.global,r=oe(n),o=ce(r,e.skillName);await Cf(r,{recursive:!0});try{if((await xf(o)).isSymbolicLink())await ms(o);else{I(`install: skipping ${o} \u2014 existing non-symlink directory`);continue}}catch{}let a=Af(r,e.targetDir);await Ef(a,o,"dir"),I(`install: symlinked ${o} -> ${a}`)}return s.provider=`All (${t.map(i=>i.label).join(", ")})`,s}async function le(e){try{await ms(e,{recursive:!0,force:!0})}catch{}}async function oa(){try{await ke("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 aa(e,t){let s=["--yes","skills","add",e];t&&s.push("--skill",t),I(`install: running npx ${s.join(" ")}`);try{let i=await ke("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 la(e){if(e.isLocal)return e.localPath;let t=`https://github.com/${e.owner}/${e.repo}`;return e.ref?`${t}/tree/${e.ref}${e.subpath?`/${e.subpath}`:""}`:t}async function Xe(e,t,s){let i=e.providers.filter(m=>m.enabled);if(t==="all"){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");return{provider:i.find(y=>y.name==="agents")||i[0],allProviders:i}}if(t){let m=e.providers.find(y=>y.name===t);if(!m){let y=e.providers.map(h=>h.name).join(", ");throw new Error(`Unknown provider: "${t}". Valid providers: ${y}, all`)}if(!m.enabled)throw new Error(`Provider "${t}" is disabled. Enable it in your config or choose another provider.`);return{provider:m,allProviders:null}}if(i.length===1)return{provider:i[0],allProviders:null};if(!s){if(i.length===0)throw new Error("No providers are enabled. Enable a provider in your config.");let m=i.map(y=>y.name).join(", ");throw new Error(`--tool (or --provider) is required in non-interactive mode. Available: ${m}, all`)}let n=e.preferences.selectedTools,o=n&&n.length>0?new Set(n):null,a=e.providers.map(m=>({label:`${m.label} (${m.name})`,hint:m.global,checked:o?o.has(m.name):m.name==="agents"})),l=await Qe({items:a});if(l.length===0)throw new Error("No tools selected. Aborting.");let c=l.map(m=>e.providers[m]),f=c.map(m=>m.name),{saveSelectedTools:d}=await import("./config-FRM3YOMA.js");return await d(f),c.length===1?{provider:c[0],allProviders:null}:{provider:c.find(m=>m.name==="agents")||c[0],allProviders:c}}function Xi(e,t,s,i,n,r,o="global"){let a=o==="project"?n.project:n.global,l=oe(a),c=ce(l,i);return{source:e,tempDir:t,sourceDir:s,targetDir:c,skillName:i,force:r,providerName:n.name,providerLabel:n.label,scope:o}}async function ca(e,t){try{if(await hs(e),I(`install: target ${e} \u2014 conflict (exists)${t?", force overwrite":""}`),!t)throw new Error(`Skill already exists at: ${e}
|
|
158
|
+
Use --force to overwrite.`)}catch(s){if(s.message?.includes("--force"))throw s;I(`install: target ${e} \u2014 no conflict`)}}var Xc=fo(Tr(),1);import{readFile as uy}from"fs/promises";import{join as dy}from"path";var Qc=500;function fy(e){let t=e.split(`
|
|
159
|
+
`),s=!1,i=!1;for(let n of t){if(n.trim()==="---")if(s){i=!0;continue}else{s=!0;continue}if(i&&n.trim().length>0)return!0}return!1}function py(e){let t=e.split(`
|
|
160
160
|
`),s=-1;for(let i=0;i<t.length;i++)if(t[i].trim()==="---")if(s===-1)s=i+1;else return t.slice(s,i).join(`
|
|
161
|
-
`);return null}function
|
|
161
|
+
`);return null}function my(e){let t=py(e);if(t===null)return null;try{return(0,Xc.parse)(t),null}catch(s){return s.message||"invalid YAML"}}async function Zc(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=dy(e.path,"SKILL.md"),n=await uy(i,"utf-8");fy(n)||t.push({category:"empty-body",message:"SKILL.md contains only frontmatter with no body content"});let r=my(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>Qc&&t.push({category:"high-file-count",message:`Skill has ${s} files (threshold: ${Qc})`}),t}import{join as Sy}from"path";import{homedir as $y}from"os";import{readFile as hy,writeFile as gy,mkdir as yy}from"fs/promises";import{dirname as by}from"path";async function wy(e){try{let t=await hy(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 vy(e,t,s){let i={fetched_at:new Date().toISOString(),ttl_seconds:s,data:t};try{await yy(by(e),{recursive:!0}),await gy(e,JSON.stringify(i,null,2),"utf-8"),I(`http: wrote cache -> ${e}`)}catch(n){I(`http: failed to write cache: ${n}`)}}function ky(e){let t=new Date(e.fetched_at).getTime();return(Date.now()-t)/1e3<e.ttl_seconds}async function eu(e,t,s={}){let i=s.ttl??3600,n=s.noCache??!1,r=await wy(t);if(r&&!n&&ky(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 vy(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 xy=/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/,Ey=/^[a-zA-Z0-9_-]+$/,iu=/^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9._-]+$/,Cy=/^[0-9a-f]{40}$/,Ay=/^\d+\.\d+\.\d+(-[a-zA-Z0-9.]+)?(\+[a-zA-Z0-9.]+)?$/,Py=/^[a-z0-9-]+$/,Ny=/^sha256:[0-9a-f]{64}$/,tu=["pass","warning","dangerous"];function hi(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:xy,maxLength:128},{field:"author",pattern:Ey,maxLength:39},{field:"description",maxLength:256},{field:"repository",pattern:iu},{field:"commit",pattern:Cy},{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"||!tu.includes(r))&&t.push({field:"security_verdict",message:`"security_verdict" must be one of: ${tu.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"||!Ay.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`}),Py.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"||!Ny.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 Iy(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 Ry(e,t,s=2){let i=[];for(let n of t){if(e===n)continue;let r=Iy(e,n);r<=s&&i.push({existingName:n,distance:r})}return i.sort((n,r)=>n.distance-r.distance)}var Mr=process.env.ASM_REGISTRY_URL??"https://raw.githubusercontent.com/luongnv89/asm-registry/main/index.json",Ly=process.env.ASM_REGISTRY_CACHE??Sy($y(),".config","agent-skill-manager","registry-cache.json"),Oy=3600;function Qt(e){if(e.startsWith("github:")||e.startsWith("http://")||e.startsWith("https://")||e.startsWith("/")||e.startsWith("./")||e.startsWith("../")||e.startsWith("~/")||e==="~"||e==="."||e==="..")return!1;let t=(e.match(/\//g)||[]).length;if(t>1)return!1;if(t===1){let[s,i]=e.split("/");return/^[a-zA-Z0-9_-]+$/.test(s)&&/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(i)}return/^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/.test(e)}function Dr(e){return Qt(e)?e.includes("/"):!1}async function Fr(e){let t=await eu(Mr,Ly,{ttl:Oy,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=hi(i);if(n.length>0){I(`registry: dropping invalid manifest entry (${i?.name??"unknown"}): ${n.map(r=>r.message).join(", ")}`);continue}if(!iu.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 Ty(e,t){return t.manifests.filter(s=>s.name.toLowerCase()===e.toLowerCase())}function My(e,t,s){return s.manifests.find(i=>i.author.toLowerCase()===e.toLowerCase()&&i.name.toLowerCase()===t.toLowerCase())??null}function su(e,t,s=5){return Ry(e,t.manifests.map(n=>n.name),3).slice(0,s).map(n=>n.existingName)}async function nu(e,t){let s=await Fr(t);if(!s)return I("registry: failed to fetch index \u2014 skipping registry resolution"),{resolved:null,multipleMatches:[],suggestions:[]};if(Dr(e)){let[r,o]=e.split("/"),a=My(r,o,s);if(a)return{resolved:{manifest:a,source:"registry"},multipleMatches:[],suggestions:[]};let l=su(o,s);return{resolved:null,multipleMatches:[],suggestions:l}}let i=Ty(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=su(e,s);return{resolved:null,multipleMatches:[],suggestions:n}}function ru(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 Dy,access as au,mkdir as Fy,cp as ou,rm as _y,symlink as jy}from"fs/promises";import{join as lu,basename as qy}from"path";function By(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 cu(e){let t;try{t=await Dy(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=By(s);if(!i.valid)throw new Error(`Invalid manifest:
|
|
162
162
|
${i.errors.join(`
|
|
163
|
-
`)}`);return s}async function
|
|
163
|
+
`)}`);return s}async function Uy(e){try{return await au(e),!0}catch{return!1}}function Ky(e,t){return e.providers.find(s=>s.name===t&&s.enabled)}function Vy(e,t,s,i){let n=Ky(e,t);if(!n)return null;let r=s==="global"?n.global:n.project,o=oe(r),a=qy(i);return!a||a==="."||a===".."?null:lu(o,a)}function Jy(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 uu(e,t,s){let i=s?.config??await B(),n=s?.installedSkills??await Z(i,"both"),r=[];for(let c of e.skills){if(t.scopeFilter!=="both"&&c.scope!==t.scopeFilter){I(`import: skipping "${c.name}" \u2014 scope "${c.scope}" filtered out`);continue}let f=Vy(i,c.provider,c.scope,c.dirName);if(!f){r.push({skillName:c.name,provider:c.provider,scope:c.scope,status:"failed",reason:`Provider "${c.provider}" not found or not enabled.`});continue}let d=await Uy(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=Jy(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 Fy(lu(f,".."),{recursive:!0}),d&&await _y(f,{recursive:!0,force:!0}),c.isSymlink&&c.symlinkTarget)try{await au(c.symlinkTarget),await jy(c.symlinkTarget,f),I(`import: symlinked "${c.name}" -> ${c.symlinkTarget} at ${f}`)}catch{await ou(p.realPath,f,{recursive:!0}),I(`import: symlink target unreachable, copied "${c.name}" from ${p.realPath} to ${f}`)}else await ou(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 Hy,writeFile as Wy,access as Gy}from"fs/promises";import{join as Yy}from"path";function zy(e){return`---
|
|
164
164
|
name: ${e}
|
|
165
165
|
description: ""
|
|
166
166
|
license: ""
|
|
@@ -181,62 +181,62 @@ as instructions for when and how to use this skill.
|
|
|
181
181
|
## Instructions
|
|
182
182
|
|
|
183
183
|
- Step-by-step instructions for the agent
|
|
184
|
-
`}async function
|
|
185
|
-
`)}import{access as tb,lstat as sb,mkdir as ib,readdir as nb,readFile as hu,rm as rb,stat as gu,symlink as ob}from"fs/promises";import{join as mi}from"path";async function _r(e){let t;try{t=await gu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=mi(e,"SKILL.md"),i;try{i=await hu(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=te(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ue(n)}}async function yu(e,t,s,i){let n=mi(t,s),r=!1;try{await tb(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await rb(n,{recursive:!0,force:!0})}await ib(t,{recursive:!0}),await ob(e,n,"dir")}async function jr(e){let t;try{t=await gu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=await nb(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=mi(e,n);try{if(!(await sb(r)).isDirectory())continue}catch{continue}let o=mi(r,"SKILL.md");try{let a=await hu(o,"utf-8"),l=te(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ue(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as Nb,writeFile as Ib,readdir as Ru,access as Lu,mkdir as Rb,rm as Lb}from"fs/promises";import{join as He,resolve as Ou,dirname as Ob}from"path";import{homedir as Tb}from"os";import{fileURLToPath as Mb}from"url";import{readdir as ab,readFile as lb}from"fs/promises";import{join as cb}from"path";function qr(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var ub=10,db=5,fb=3,pb=1;function mb(e,t){let s=qr(e),i=qr(t.name),n=qr(t.description),r=0;for(let o of s)i.has(o)&&(r+=ub),n.has(o)&&(r+=fb),t.name.toLowerCase().includes(o)&&(r+=db),t.description.toLowerCase().includes(o)&&(r+=pb);return r}async function bu(e){let t=new Map,s;try{s=await ab(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=cb(e,i);try{let r=await lb(n,"utf-8"),o=JSON.parse(r);for(let a of o.skills)"license"in a||(a.license=""),"creator"in a||(a.creator=""),"compatibility"in a||(a.compatibility=""),"allowedTools"in a||(a.allowedTools=[]),"verified"in a||(a.verified=!1);t.set(`${o.owner}/${o.repo}`,o)}catch{}}return t}async function ut(){let e=await bu(ho()),t=await bu(yt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var hb=["license","creator","version"];function wu(e){return hb.includes(e)}function vu(e,t){return e[t]||""}function gb(e,t){if(t.has){for(let s of t.has)if(wu(s)&&!vu(e,s))return!1}if(t.missing){for(let s of t.missing)if(wu(s)&&vu(e,s))return!1}return!0}function ku(e){let t=[];return e.license||t.push("license"),e.creator||t.push("creator"),(!e.version||e.version==="0.0.0")&&t.push("version"),t}async function hi(e,t=20,s){let i=await ut(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!gb(a,s))continue;let l=r?1:mb(e,a);l>0&&n.push({skill:a,repo:{owner:o.owner,repo:o.repo},score:l})}return n.sort((o,a)=>a.score-o.score),n.slice(0,t)}async function Su(){return(await ut()).reduce((t,s)=>t+s.skillCount,0)}import{readdir as yb,readFile as $u,stat as Eu}from"fs/promises";import{join as Br}from"path";var bb=[{id:"marketing",title:"Marketing Skills",description:"Marketing, growth, SEO, ASO, affiliate, sales, and conversion skills.",tags:["marketing","growth","seo"],keywords:["marketing","growth","seo","aso","affiliate","sales","copy","copywriting","conversion","cro","brand","social","campaign"]},{id:"writing",title:"Writing Skills",description:"Writing, editing, documentation, publishing, and content-production skills.",tags:["writing","content","docs"],keywords:["write","writing","writer","blog","article","content","docs","documentation","draft","copy","readme","paper","thesis","proposal"]},{id:"research",title:"Research Skills",description:"Research, academic, literature-review, citation, paper, and analysis skills.",tags:["research","academic","analysis"],keywords:["research","academic","scholar","paper","literature","citation","review","analysis","summar","evaluate","verify"]},{id:"engineering",title:"Engineering Skills",description:"Coding, debugging, testing, architecture, review, and software engineering skills.",tags:["engineering","coding","testing"],keywords:["code","coding","debug","test","testing","coverage","review","refactor","architecture","typescript","python","javascript","build","cli","api"]},{id:"frontend-design",title:"Frontend & Design Skills",description:"Frontend, UI, UX, visual design, component, theme, and landing-page skills.",tags:["frontend","design","ui"],keywords:["frontend","ui","ux","design","component","react","css","html","figma","theme","landing","layout","visual","brand","logo"]},{id:"devops",title:"DevOps Skills",description:"Deployment, CI/CD, infrastructure, cloud, Docker, Kubernetes, and automation skills.",tags:["devops","infra","automation"],keywords:["devops","deploy","deployment","ci","cd","pipeline","docker","kubernetes","terraform","ansible","cloud","infra","infrastructure","workflow","release"]},{id:"data-ai",title:"Data & AI Skills",description:"Data, analytics, AI, model, prompt, agent, and automation skills.",tags:["data","ai","agents"],keywords:["data","analytics","analysis","ai","agent","llm","model","prompt","openai","claude","gemini","automation","dataset","sql"]},{id:"product-business",title:"Product & Business Skills",description:"Product, strategy, PRD, planning, finance, resume, and business workflow skills.",tags:["product","business","planning"],keywords:["product","prd","strategy","planning","business","finance","resume","career","startup","market","competitor","customer","sales"]}],xu=2,wb=80,vb=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],kb=["bundles","data/bundles",".asm/bundles"];function Qt(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Cu(e,t,s){let i=Qt(e),n=Qt(t),r=Qt(s),o=`${i}-${n}`;return r.startsWith(o)?r:`${o}-${r}`}function Sb(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function $b(e,t){let s=Sb(e);return t.keywords.some(i=>s.includes(i))}function Au(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function xb(e){let t=new Set,s=[];for(let i of e){let n=`${i.installUrl||""}\0${i.name}`;t.has(n)||(t.add(n),s.push(i))}return s}function Pu(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function Ur(e){let t=[];if(!e.skills||e.skills.length<xu)return t;for(let s of bb){let i=e.skills.filter(r=>$b(r,s)).slice(0,wb);if(i.length<xu)continue;let n=Cu(e.owner,e.repo,s.id);t.push({version:1,name:n,description:`${s.description} Derived from ${e.owner}/${e.repo}.`,author:`ASM (${e.owner}/${e.repo})`,createdAt:e.updatedAt,tags:["repo-derived","inferred",...s.tags,Qt(e.owner),Qt(e.repo)],skills:Pu(i.map(Au)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function Eb(e,t,s){if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e,n=Array.isArray(i.skills)?i.skills:[];if(n.length===0)return null;let r=new Map(t.skills.map(l=>[l.name,l])),o=xb(n.map(l=>{if(typeof l=="string"){let p=r.get(l);return p?Au(p):null}if(!l||typeof l!="object"||Array.isArray(l))return null;let c=l,f=typeof c.name=="string"?c.name:"";if(!f)return null;let d=r.get(f);return d?{name:d.name,installUrl:d.installUrl,description:typeof c.description=="string"&&c.description?c.description:d.description||void 0,version:typeof c.version=="string"&&c.version?c.version:d.version||void 0}:null}).filter(l=>l!==null));if(o.length===0)return null;let a=typeof i.name=="string"&&i.name?i.name:s.replace(/\.json$/,"");return{version:1,name:Cu(t.owner,t.repo,a),description:typeof i.description=="string"&&i.description?i.description:`Bundle from ${t.owner}/${t.repo}.`,author:typeof i.author=="string"&&i.author?i.author:`ASM (${t.owner}/${t.repo})`,createdAt:typeof i.createdAt=="string"&&i.createdAt?i.createdAt:t.updatedAt,tags:Array.isArray(i.tags)?["repo-derived","explicit",...i.tags.filter(l=>typeof l=="string")]:["repo-derived","explicit"],skills:Pu(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function Cb(e){try{return(await Eu(e)).isFile()}catch{return!1}}async function Ab(e){try{return(await Eu(e)).isDirectory()}catch{return!1}}async function Pb(e){let t=[];for(let s of vb){let i=Br(e,s);if(await Cb(i))try{t.push({relPath:s,data:JSON.parse(await $u(i,"utf-8"))})}catch{}}for(let s of kb){let i=Br(e,s);if(!await Ab(i))continue;let n=[];try{n=await yb(i)}catch{continue}for(let r of n.filter(o=>o.endsWith(".json")).sort()){let o=`${s}/${r}`;try{t.push({relPath:o,data:JSON.parse(await $u(Br(i,r),"utf-8"))})}catch{}}}return t}async function Nu(e,t){let s=[],i=await Pb(e);for(let n of i){let r=n.data,o=Array.isArray(r?.bundles)?r.bundles:[r];for(let a of o){let l=Eb(a,t,n.relPath);l&&s.push(l)}}return gi(s)}function gi(e){let t=new Map;for(let s of e){let i=t.get(s.name);(!i||s.explicit&&!i.explicit)&&t.set(s.name,s)}return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}function Iu(e){let t=e.bundles||[],s=Ur(e);return gi([...t,...s])}var Db=Mb(import.meta.url),Fb=Ob(Db),Je=He(Tb(),".config","agent-skill-manager","bundles"),yi=Ou(Fb,"..","data","bundles");function _b(e){let t=[];if(typeof e!="object"||e===null||Array.isArray(e))return{valid:!1,errors:["Bundle must be a JSON object."]};let s=e;if(s.version!==1&&t.push(`Unsupported bundle version: ${JSON.stringify(s.version)}. Expected 1.`),(typeof s.name!="string"||!s.name)&&t.push("Missing or empty 'name' field."),(typeof s.description!="string"||!s.description)&&t.push("Missing or empty 'description' field."),(typeof s.author!="string"||!s.author)&&t.push("Missing or empty 'author' field."),typeof s.createdAt!="string"&&t.push("Missing or invalid 'createdAt' field."),!Array.isArray(s.skills))return t.push("Missing or invalid 'skills' array."),{valid:!1,errors:t};s.skills.length===0&&t.push("Bundle must contain at least one skill.");for(let i=0;i<s.skills.length;i++){let n=s.skills[i];if(typeof n!="object"||n===null){t.push(`skills[${i}]: must be an object.`);continue}let r=n;(typeof r.name!="string"||!r.name)&&t.push(`skills[${i}]: missing or empty 'name'.`),(typeof r.installUrl!="string"||!r.installUrl)&&t.push(`skills[${i}]: missing or empty 'installUrl'.`)}return s.tags!==void 0&&(Array.isArray(s.tags)?s.tags.some(i=>typeof i!="string")&&t.push("'tags' must contain only strings."):t.push("'tags' must be an array of strings if provided.")),{valid:t.length===0,errors:t}}function Tu(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function Mu(e,t){let s=t??await Le(),i=s.skills[e.name]||s.skills[e.dirName],n;return e.isSymlink&&e.symlinkTarget?n=e.symlinkTarget:i?.source?n=i.source:n=e.path,{name:e.name,installUrl:n,description:e.description||void 0,version:e.version||void 0}}async function jb(){await Rb(Je,{recursive:!0})}function Zt(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(t=t.replace(/^\.+|\.+$/g,""),!t||t==="."||t==="..")throw new Error("Invalid bundle name: results in an empty filename after sanitization.");return t}async function Vr(e){await jb();let t=`${Zt(e.name)}.json`,s=He(Je,t);return await Ib(s,JSON.stringify(e,null,2)+`
|
|
186
|
-
`,"utf-8"),I(`bundle: saved to ${s}`),s}async function
|
|
184
|
+
`}async function du(e,t){await Hy(t,{recursive:!0});let s=Yy(t,"SKILL.md"),i=zy(e);await Wy(s,i,"utf-8")}async function fu(e){try{return await Gy(e),!0}catch{return!1}}import{readdir as Qy,stat as Xy}from"fs/promises";import{join as Zy}from"path";async function eb(e){let t=0;try{let i=(await Qy(e,{recursive:!0})).map(async r=>{try{let o=await Xy(Zy(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 mu(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 eb(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 tb(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 _r(e,t,s=20){let i=Math.round(e/t*s),n=s-i;return u.green("#".repeat(i))+u.dim("-".repeat(n))}var pu={claude:"Claude Code",codex:"Codex",openclaw:"OpenClaw",agents:"Agents"};function hu(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(tb(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])=>(pu[l]||l).length));for(let[l,c]of s){let f=pu[l]||l,d=xo(l,f.padEnd(n)),p=String(c).padStart(4);t.push(` ${d} ${p} ${_r(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} ${_r(e.byScope.global,r)}`),t.push(` ${"project".padEnd(n)} ${a} ${_r(e.byScope.project,r)}`),t.push(""),t.push(u.bold(" Duplicates")),e.duplicateGroups>0?(t.push(` ${u.yellow(`${e.duplicateGroups} group(s), ${e.duplicateInstances} total instance(s)`)}`),t.push(u.dim(` Run ${u.bold("asm audit")} to review`))):t.push(` ${u.green("None")}`),t.push(""),t.join(`
|
|
185
|
+
`)}import{access as sb,lstat as ib,mkdir as nb,readdir as rb,readFile as gu,rm as ob,stat as yu,symlink as ab}from"fs/promises";import{join as gi}from"path";async function jr(e){let t;try{t=await yu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=gi(e,"SKILL.md"),i;try{i=await gu(s,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}`)}let n=X(i);if(!n.name)throw new Error(`Invalid SKILL.md in ${e}: missing "name" in frontmatter`);return{name:n.name,version:ae(n)}}async function bu(e,t,s,i){let n=gi(t,s),r=!1;try{await sb(n),r=!0}catch{}if(r){if(!i)throw new Error(`Target already exists: ${n}. Use --force to overwrite.`);await ob(n,{recursive:!0,force:!0})}await nb(t,{recursive:!0}),await ab(e,n,"dir")}async function qr(e){let t;try{t=await yu(e)}catch{throw new Error(`Path does not exist: ${e}`)}if(!t.isDirectory())throw new Error(`Path is not a directory: ${e}`);let s=await rb(e),i=[];for(let n of s){if(n.startsWith(".")||n==="node_modules")continue;let r=gi(e,n);try{if(!(await ib(r)).isDirectory())continue}catch{continue}let o=gi(r,"SKILL.md");try{let a=await gu(o,"utf-8"),l=X(a);l.name&&i.push({absPath:r,dirName:n,name:l.name,version:ae(l)})}catch{}}return i.sort((n,r)=>n.name.localeCompare(r.name)),i}import{readFile as Ib,writeFile as Rb,readdir as Lu,access as Ou,mkdir as Lb,rm as Ob}from"fs/promises";import{join as He,resolve as Tu,dirname as Tb}from"path";import{homedir as Mb}from"os";import{fileURLToPath as Db}from"url";import{readdir as lb,readFile as cb}from"fs/promises";import{join as ub}from"path";function Br(e){let t=new Set,s=e.toLowerCase().split(/[\s\-_.,;:()[\]{}"']+/);for(let i of s)i.length>=2&&t.add(i);return t}var db=10,fb=5,pb=3,mb=1;function hb(e,t){let s=Br(e),i=Br(t.name),n=Br(t.description),r=0;for(let o of s)i.has(o)&&(r+=db),n.has(o)&&(r+=pb),t.name.toLowerCase().includes(o)&&(r+=fb),t.description.toLowerCase().includes(o)&&(r+=mb);return r}async function wu(e){let t=new Map,s;try{s=await lb(e)}catch{return t}for(let i of s){if(!i.endsWith(".json"))continue;let n=ub(e,i);try{let r=await cb(n,"utf-8"),o=JSON.parse(r);for(let a of o.skills)"license"in a||(a.license=""),"creator"in a||(a.creator=""),"compatibility"in a||(a.compatibility=""),"allowedTools"in a||(a.allowedTools=[]),"verified"in a||(a.verified=!1);t.set(`${o.owner}/${o.repo}`,o)}catch{}}return t}async function ut(){let e=await wu(go()),t=await wu(yt()),s=new Map(e);for(let[i,n]of t)s.set(i,n);return Array.from(s.values())}var gb=["license","creator","version"];function vu(e){return gb.includes(e)}function ku(e,t){return e[t]||""}function yb(e,t){if(t.has){for(let s of t.has)if(vu(s)&&!ku(e,s))return!1}if(t.missing){for(let s of t.missing)if(vu(s)&&ku(e,s))return!1}return!0}function Su(e){let t=[];return e.license||t.push("license"),e.creator||t.push("creator"),(!e.version||e.version==="0.0.0")&&t.push("version"),t}async function yi(e,t=20,s){let i=await ut(),n=[],r=!e&&s;for(let o of i)for(let a of o.skills){if(s&&!yb(a,s))continue;let l=r?1:hb(e,a);l>0&&n.push({skill:a,repo:{owner:o.owner,repo:o.repo},score:l})}return n.sort((o,a)=>a.score-o.score),n.slice(0,t)}async function $u(){return(await ut()).reduce((t,s)=>t+s.skillCount,0)}import{readdir as bb,readFile as xu,stat as Cu}from"fs/promises";import{join as Ur}from"path";var wb=[{id:"marketing",title:"Marketing Skills",description:"Marketing, growth, SEO, ASO, affiliate, sales, and conversion skills.",tags:["marketing","growth","seo"],keywords:["marketing","growth","seo","aso","affiliate","sales","copy","copywriting","conversion","cro","brand","social","campaign"]},{id:"writing",title:"Writing Skills",description:"Writing, editing, documentation, publishing, and content-production skills.",tags:["writing","content","docs"],keywords:["write","writing","writer","blog","article","content","docs","documentation","draft","copy","readme","paper","thesis","proposal"]},{id:"research",title:"Research Skills",description:"Research, academic, literature-review, citation, paper, and analysis skills.",tags:["research","academic","analysis"],keywords:["research","academic","scholar","paper","literature","citation","review","analysis","summar","evaluate","verify"]},{id:"engineering",title:"Engineering Skills",description:"Coding, debugging, testing, architecture, review, and software engineering skills.",tags:["engineering","coding","testing"],keywords:["code","coding","debug","test","testing","coverage","review","refactor","architecture","typescript","python","javascript","build","cli","api"]},{id:"frontend-design",title:"Frontend & Design Skills",description:"Frontend, UI, UX, visual design, component, theme, and landing-page skills.",tags:["frontend","design","ui"],keywords:["frontend","ui","ux","design","component","react","css","html","figma","theme","landing","layout","visual","brand","logo"]},{id:"devops",title:"DevOps Skills",description:"Deployment, CI/CD, infrastructure, cloud, Docker, Kubernetes, and automation skills.",tags:["devops","infra","automation"],keywords:["devops","deploy","deployment","ci","cd","pipeline","docker","kubernetes","terraform","ansible","cloud","infra","infrastructure","workflow","release"]},{id:"data-ai",title:"Data & AI Skills",description:"Data, analytics, AI, model, prompt, agent, and automation skills.",tags:["data","ai","agents"],keywords:["data","analytics","analysis","ai","agent","llm","model","prompt","openai","claude","gemini","automation","dataset","sql"]},{id:"product-business",title:"Product & Business Skills",description:"Product, strategy, PRD, planning, finance, resume, and business workflow skills.",tags:["product","business","planning"],keywords:["product","prd","strategy","planning","business","finance","resume","career","startup","market","competitor","customer","sales"]}],Eu=2,vb=80,kb=["asm-bundles.json","asm.bundle.json",".asm/bundles.json",".asm/bundle.json"],Sb=["bundles","data/bundles",".asm/bundles"];function Xt(e){return e.toLowerCase().replace(/[^a-z0-9._-]+/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function Au(e,t,s){let i=Xt(e),n=Xt(t),r=Xt(s),o=`${i}-${n}`;return r.startsWith(o)?r:`${o}-${r}`}function $b(e){return[e.name,e.description,e.relPath,e.installUrl].filter(Boolean).join(" ").toLowerCase()}function xb(e,t){let s=$b(e);return t.keywords.some(i=>s.includes(i))}function Pu(e){return{name:e.name,installUrl:e.installUrl,description:e.description||void 0,version:e.version||void 0}}function Eb(e){let t=new Set,s=[];for(let i of e){let n=`${i.installUrl||""}\0${i.name}`;t.has(n)||(t.add(n),s.push(i))}return s}function Nu(e){return[...e].sort((t,s)=>t.name.localeCompare(s.name))}function Kr(e){let t=[];if(!e.skills||e.skills.length<Eu)return t;for(let s of wb){let i=e.skills.filter(r=>xb(r,s)).slice(0,vb);if(i.length<Eu)continue;let n=Au(e.owner,e.repo,s.id);t.push({version:1,name:n,description:`${s.description} Derived from ${e.owner}/${e.repo}.`,author:`ASM (${e.owner}/${e.repo})`,createdAt:e.updatedAt,tags:["repo-derived","inferred",...s.tags,Xt(e.owner),Xt(e.repo)],skills:Nu(i.map(Pu)),sourceRepo:{owner:e.owner,repo:e.repo,repoUrl:e.repoUrl},inferred:!0})}return t}function Cb(e,t,s){if(!e||typeof e!="object"||Array.isArray(e))return null;let i=e,n=Array.isArray(i.skills)?i.skills:[];if(n.length===0)return null;let r=new Map(t.skills.map(l=>[l.name,l])),o=Eb(n.map(l=>{if(typeof l=="string"){let p=r.get(l);return p?Pu(p):null}if(!l||typeof l!="object"||Array.isArray(l))return null;let c=l,f=typeof c.name=="string"?c.name:"";if(!f)return null;let d=r.get(f);return d?{name:d.name,installUrl:d.installUrl,description:typeof c.description=="string"&&c.description?c.description:d.description||void 0,version:typeof c.version=="string"&&c.version?c.version:d.version||void 0}:null}).filter(l=>l!==null));if(o.length===0)return null;let a=typeof i.name=="string"&&i.name?i.name:s.replace(/\.json$/,"");return{version:1,name:Au(t.owner,t.repo,a),description:typeof i.description=="string"&&i.description?i.description:`Bundle from ${t.owner}/${t.repo}.`,author:typeof i.author=="string"&&i.author?i.author:`ASM (${t.owner}/${t.repo})`,createdAt:typeof i.createdAt=="string"&&i.createdAt?i.createdAt:t.updatedAt,tags:Array.isArray(i.tags)?["repo-derived","explicit",...i.tags.filter(l=>typeof l=="string")]:["repo-derived","explicit"],skills:Nu(o),sourceRepo:{owner:t.owner,repo:t.repo,repoUrl:t.repoUrl,relPath:s},explicit:!0}}async function Ab(e){try{return(await Cu(e)).isFile()}catch{return!1}}async function Pb(e){try{return(await Cu(e)).isDirectory()}catch{return!1}}async function Nb(e){let t=[];for(let s of kb){let i=Ur(e,s);if(await Ab(i))try{t.push({relPath:s,data:JSON.parse(await xu(i,"utf-8"))})}catch{}}for(let s of Sb){let i=Ur(e,s);if(!await Pb(i))continue;let n=[];try{n=await bb(i)}catch{continue}for(let r of n.filter(o=>o.endsWith(".json")).sort()){let o=`${s}/${r}`;try{t.push({relPath:o,data:JSON.parse(await xu(Ur(i,r),"utf-8"))})}catch{}}}return t}async function Iu(e,t){let s=[],i=await Nb(e);for(let n of i){let r=n.data,o=Array.isArray(r?.bundles)?r.bundles:[r];for(let a of o){let l=Cb(a,t,n.relPath);l&&s.push(l)}}return bi(s)}function bi(e){let t=new Map;for(let s of e){let i=t.get(s.name);(!i||s.explicit&&!i.explicit)&&t.set(s.name,s)}return Array.from(t.values()).sort((s,i)=>s.name.localeCompare(i.name))}function Ru(e){let t=e.bundles||[],s=Kr(e);return bi([...t,...s])}var Fb=Db(import.meta.url),_b=Tb(Fb),Je=He(Mb(),".config","agent-skill-manager","bundles"),wi=Tu(_b,"..","data","bundles");function jb(e){let t=[];if(typeof e!="object"||e===null||Array.isArray(e))return{valid:!1,errors:["Bundle must be a JSON object."]};let s=e;if(s.version!==1&&t.push(`Unsupported bundle version: ${JSON.stringify(s.version)}. Expected 1.`),(typeof s.name!="string"||!s.name)&&t.push("Missing or empty 'name' field."),(typeof s.description!="string"||!s.description)&&t.push("Missing or empty 'description' field."),(typeof s.author!="string"||!s.author)&&t.push("Missing or empty 'author' field."),typeof s.createdAt!="string"&&t.push("Missing or invalid 'createdAt' field."),!Array.isArray(s.skills))return t.push("Missing or invalid 'skills' array."),{valid:!1,errors:t};s.skills.length===0&&t.push("Bundle must contain at least one skill.");for(let i=0;i<s.skills.length;i++){let n=s.skills[i];if(typeof n!="object"||n===null){t.push(`skills[${i}]: must be an object.`);continue}let r=n;(typeof r.name!="string"||!r.name)&&t.push(`skills[${i}]: missing or empty 'name'.`),(typeof r.installUrl!="string"||!r.installUrl)&&t.push(`skills[${i}]: missing or empty 'installUrl'.`)}return s.tags!==void 0&&(Array.isArray(s.tags)?s.tags.some(i=>typeof i!="string")&&t.push("'tags' must contain only strings."):t.push("'tags' must be an array of strings if provided.")),{valid:t.length===0,errors:t}}function Mu(e,t,s,i,n){return{version:1,name:e,description:t,author:s,createdAt:new Date().toISOString(),skills:i,tags:n}}async function Du(e,t){let s=t??await Oe(),i=s.skills[e.name]||s.skills[e.dirName],n;return e.isSymlink&&e.symlinkTarget?n=e.symlinkTarget:i?.source?n=i.source:n=e.path,{name:e.name,installUrl:n,description:e.description||void 0,version:e.version||void 0}}async function qb(){await Lb(Je,{recursive:!0})}function es(e){let t=e.toLowerCase().replace(/[^a-z0-9._-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"");if(t=t.replace(/^\.+|\.+$/g,""),!t||t==="."||t==="..")throw new Error("Invalid bundle name: results in an empty filename after sanitization.");return t}async function Vr(e){await qb();let t=`${es(e.name)}.json`,s=He(Je,t);return await Rb(s,JSON.stringify(e,null,2)+`
|
|
186
|
+
`,"utf-8"),I(`bundle: saved to ${s}`),s}async function Zt(e){let t;try{t=await Ib(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=jb(s);if(!i.valid)throw new Error(`Invalid bundle:
|
|
187
187
|
${i.errors.join(`
|
|
188
|
-
`)}`);return s}async function
|
|
189
|
-
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let f of
|
|
190
|
-
`)}function
|
|
188
|
+
`)}`);return s}async function ts(e){if(e.includes("/")||e.includes("\\")||e.endsWith(".json")){let i=Tu(e);return Zt(i)}let t=`${es(e)}.json`,s=He(Je,t);try{return await Zt(s)}catch(i){if(i?.message?.includes("Bundle file not found")){let n=He(wi,t);try{return await Zt(n)}catch(r){if(r?.message?.includes("Bundle file not found")){let o=await Bb(e);if(o)return o;throw new Error(`Bundle file not found: ${s}`)}throw r}}throw i}}async function Fu(){let e=[];try{await Ou(wi);let s;try{s=await Lu(wi)}catch{s=[]}for(let i of s){if(!i.endsWith(".json"))continue;let n=He(wi,i);try{let r=await Zt(n);e.push(r)}catch{I(`bundle: skipping invalid predefined file ${n}`)}}}catch{}e.push(...await _u());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 _u(){try{return(await ut()).flatMap(t=>Ru(t))}catch(e){return I(`bundle: failed to load repo-derived bundles: ${e}`),[]}}async function Bb(e){let t=es(e),s=await _u();return s.find(i=>i.name===e)||s.find(i=>es(i.name)===t)||null}async function ju(){let e=[];try{await Ou(Je)}catch{return e}let t;try{t=await Lu(Je)}catch{return e}for(let s of t){if(!s.endsWith(".json"))continue;let i=He(Je,s);try{let n=await Zt(i);e.push(n)}catch{I(`bundle: skipping invalid file ${i}`)}}return e.sort((s,i)=>s.name.localeCompare(i.name)),e}async function qu(e){let t=`${es(e)}.json`,s=He(Je,t);try{return await Ob(s),I(`bundle: removed ${s}`),!0}catch(i){if(i?.code==="ENOENT")return!1;throw i}}import{readFile as Qb,realpath as Xb}from"fs/promises";import{join as Zb,resolve as ew,relative as tw}from"path";var Ku=[{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 Ub(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 Kb(e){let t=new Map;for(let{relPath:n,content:r}of e){let o=r.split(`
|
|
189
|
+
`);for(let a=0;a<o.length;a++){let l=o[a],c=l.trim();for(let f of Ku)if(f.pattern.test(l)){let d=f.category;t.has(d)||t.set(d,{description:f.description,matches:[]});let p=c.length>120?c.slice(0,120)+"...":c;t.get(d).matches.push({file:n,line:a+1,match:p,severity:f.severity})}}}let s=[];for(let[n,r]of t)s.push({category:n,description:r.description,matches:r.matches});let i={critical:0,warning:1,info:2};return s.sort((n,r)=>{let o=Math.min(...n.matches.map(l=>i[l.severity])),a=Math.min(...r.matches.map(l=>i[l.severity]));return o-a}),s}function Vb(e){let t=new Map;for(let r of e)for(let o of r.matches)for(let a of Ku)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 Jb(e,t,s){let i=0,n=0;for(let l of e)for(let c of l.matches)c.severity==="critical"&&i++,c.severity==="warning"&&n++;let r=t.some(l=>l.type==="shell"),o=t.some(l=>l.type==="code-execution"),a=t.some(l=>l.type==="network");return r&&a?{verdict:"dangerous",reason:"Skill has both shell execution and network access -- potential data exfiltration risk."}:o&&a?{verdict:"dangerous",reason:"Skill has dynamic code execution and network access -- potential remote code execution risk."}:i>=10?{verdict:"dangerous",reason:`${i} critical findings detected. High concentration of risky patterns.`}:r||o?{verdict:"warning",reason:r?"Skill executes shell commands. Review commands carefully before installing.":"Skill uses dynamic code execution. Review usage carefully."}:i>0?{verdict:"warning",reason:`${i} critical finding${i>1?"s":""} detected. Manual review recommended.`}:n>0?{verdict:"caution",reason:`${n} warning${n>1?"s":""} found. Generally acceptable but worth reviewing.`}:s&&s.publicRepos!==null&&s.publicRepos<3?{verdict:"caution",reason:"No code issues found, but the author has very few public repositories."}:{verdict:"safe",reason:"No suspicious patterns detected."}}async function Le(e,t,s,i){I(`security-audit: scanning ${e}`);let n=await ds(e),r=n.reduce((d,p)=>d+p.lineCount,0),o=null;s&&i&&(o=await Ub(s,i));let a=Kb(n),l=Vb(a),{verdict:c,reason:f}=Jb(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,Hb={"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"},Bu={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 Gb(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 Jr(e,t){return e.length>t?e.slice(0,t-3)+"...":e}function vi(e){return e.toLocaleString("en-US")}function Vu(e){return e.replace(/\x1b\[[0-9;]*m/g,"")}function Uu(e){return Vu(e).length}function Yb(e){let t=new Map;for(let s of e){let i=`${s.file}:${s.line}`,n=t.get(i);(!n||Bu[s.severity]<Bu[n.severity])&&t.set(i,s)}return Array.from(t.values())}function zb(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 ki(e){let t=[],s=Wb(e.verdict),i=Vu(s),n=` ${R.bold(e.skillName)}`,r=` ${e.skillName}`,o=We-4,a=Math.max(1,o-r.length-i.length);if(t.push(""),t.push(R.dim(" +-- ")+R.bold("Security Audit")+R.dim(" "+"-".repeat(We-19)+"+")),t.push(R.dim(" |")+n+" ".repeat(a)+s+R.dim("|")),t.push(R.dim(" |")+R.dim(` ${vi(e.totalFiles)} files | ${vi(e.totalLines)} lines`)+" ".repeat(Math.max(1,o-` ${vi(e.totalFiles)} files | ${vi(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=Gb(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=Yb(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=Hb[d.category],k=w?R.dim(`PERM: ${w}`):"",S=` ${g} ${R.bold(d.category)} (${b.join(", ")})`;if(k){let O=Uu(S),D=Uu(k),T=Math.max(2,We-O-D);t.push(S+" ".repeat(T)+k)}else t.push(S);let v=zb(p),C=Math.min(24,Math.max(...v.map(O=>O.file.length))),E=0,x=3;for(let O of v){if(E>=x)break;let D=Jr(O.file,24),T=R.dim(D.padEnd(C));if(O.entries.length===1){let A=O.entries[0],N=Jr(A.match,50);t.push(` ${T} :${A.line} ${R.dim("--")} ${A.severity==="critical"?N:R.dim(N)}`),E++}else if(O.entries.length<=3){let A=O.entries.map(_=>`:${_.line}`).join(", "),N=Jr(O.entries[0].match,40);t.push(` ${T} ${A} ${R.dim("--")} ${R.dim(N)}`),E++}else{let N=O.entries.slice(0,3).map(L=>`:${L.line}`).join(", "),_=O.entries.length-3;t.push(` ${T} ${N} ${R.dim(`(+${_} more)`)}`),E++}}let M=v.length-Math.min(v.length,x);if(M>0){let O=p.length-v.slice(0,x).reduce((D,T)=>D+T.entries.length,0);O>0&&t.push(` ${R.dim(`... ${O} more in ${M} file${M>1?"s":""}`)}`)}t.push("")}}t.push(R.dim(" "+"=".repeat(We-2)));let l=new Date(e.scannedAt),c=`${l.getFullYear()}-${String(l.getMonth()+1).padStart(2,"0")}-${String(l.getDate()).padStart(2,"0")} ${String(l.getHours()).padStart(2,"0")}:${String(l.getMinutes()).padStart(2,"0")}`,f=e.source&&!e.source.fetchError?`github.com/${e.source.owner}`:"";if(f){let d=Math.max(2,We-2-c.length-f.length);t.push(R.dim(` ${c}${" ".repeat(d)}${f}`))}else t.push(R.dim(` ${c}`));return t.push(""),t.join(`
|
|
190
|
+
`)}function Hr(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 Si(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 sw(e){return e.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\[/g,"\\[").replace(/\]/g,"\\]").replace(/</g,"<").replace(/>/g,">").replace(/\|/g,"\\|")}function Wr(e){return sw(Si(e))}var Ge="luongnv89/asm-registry";async function iw(e){let t=Zb(e,"SKILL.md"),s;try{s=await Qb(t,"utf-8")}catch{throw new Error(`No SKILL.md found in ${e}. Run "asm init" to create one.`)}let i=X(s);if(!i.name)throw new Error("SKILL.md is missing required field: name");if(!i.description)throw new Error("SKILL.md is missing required field: description");let n=ae(i),r=i.tags?i.tags.split(/[\s,]+/).map(o=>o.trim().toLowerCase()).filter(Boolean):[];return{name:i.name,description:i.description.replace(/\s*\n\s*/g," ").trim(),version:n,license:i.license||"MIT",creator:i.creator||"",tags:r}}async function nw(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 rw(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 ow(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 aw(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 lw(){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 cw(e){switch(e){case"safe":case"caution":return"pass";case"warning":return"warning";case"dangerous":return"dangerous"}}function Ju(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 uw(e){let t=Ju({metadata:e.metadata,author:e.metadata.creator||"unknown",commit:e.commit,repository:e.repository,securityVerdict:e.registryVerdict}),s=hi(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 Hu(e){let t=ew(e.path);I(`publish: starting for ${t}`),await nw(t);let s=await iw(t);I(`publish: parsed metadata for "${s.name}"`);let n=await(e._auditFn??Le)(t,s.name),r=cw(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 rw(t),a=await aw(t),l=await ow(t),c=await Xb(t),f=tw(l,c),d=f&&f!=="."?f:void 0,m=await(e._checkGhCliFn??lw)();if(!m.available||!m.authenticated){let U=m.available?"gh CLI not authenticated":"gh CLI not found";return uw({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=Ju({metadata:s,author:y,commit:o,repository:a,skillPath:d,securityVerdict:r}),g=hi(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=Si(s.name),ze=Si(y);process.stderr.write(`
|
|
191
191
|
About to publish "${U}" by ${ze} to ${Ge}.
|
|
192
192
|
Security verdict: ${r}
|
|
193
193
|
|
|
194
|
-
Proceed? [y/N] `);let re=await new Promise(
|
|
195
|
-
`)&&(process.stdin.removeListener("data",
|
|
196
|
-
`,S=Buffer.from(k,"utf-8").toString("base64"),{stdout:v,exitCode:C}=await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/main`,"--jq",".object.sha"]);if(C!==0)return{success:!1,manifest:h,prUrl:null,error:`Failed to read fork's main branch. Ensure the fork exists at ${y}/asm-registry.`,securityVerdict:r,securityReport:n};let E=v.trim(),{exitCode:x}=await H(["gh","api",`repos/${y}/asm-registry/git/refs`,"-X","POST","-f",`ref=refs/heads/${b}`,"-f",`sha=${E}`]);x!==0&&await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/${b}`,"-X","PATCH","-f",`sha=${E}`,"-f","force=true"]);let{stderr:M,exitCode:O}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}`,"-X","PUT","-f",`message=Publish ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`]);if(O!==0){let{stdout:U,exitCode:ze}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}?ref=${b}`,"-q",".sha"]),re=U.trim();if(ze===0&&re){let{exitCode:
|
|
197
|
-
`),{stdout:L,stderr:F,exitCode:ne}=await H(["gh","pr","create","--repo",Ge,"--head",`${y}:${b}`,"--title",N,"--body",_]),
|
|
194
|
+
Proceed? [y/N] `);let re=await new Promise(de=>{let ve="",rs=ht=>{ve+=ht.toString(),ve.includes(`
|
|
195
|
+
`)&&(process.stdin.removeListener("data",rs),process.stdin.pause(),de(ve.trim()))};process.stdin.resume(),process.stdin.on("data",rs)});if(re.toLowerCase()!=="y"&&re.toLowerCase()!=="yes")return{success:!1,manifest:h,prUrl:null,error:"Publish aborted by user.",securityVerdict:r,securityReport:n}}I(`publish: forking ${Ge}`),await H(["gh","repo","fork",Ge,"--clone=false"]);let b=`publish/${y}/${s.name}`,w=`manifests/${y}/${s.name}.json`,k=JSON.stringify(h,null,2)+`
|
|
196
|
+
`,S=Buffer.from(k,"utf-8").toString("base64"),{stdout:v,exitCode:C}=await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/main`,"--jq",".object.sha"]);if(C!==0)return{success:!1,manifest:h,prUrl:null,error:`Failed to read fork's main branch. Ensure the fork exists at ${y}/asm-registry.`,securityVerdict:r,securityReport:n};let E=v.trim(),{exitCode:x}=await H(["gh","api",`repos/${y}/asm-registry/git/refs`,"-X","POST","-f",`ref=refs/heads/${b}`,"-f",`sha=${E}`]);x!==0&&await H(["gh","api",`repos/${y}/asm-registry/git/refs/heads/${b}`,"-X","PATCH","-f",`sha=${E}`,"-f","force=true"]);let{stderr:M,exitCode:O}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}`,"-X","PUT","-f",`message=Publish ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`]);if(O!==0){let{stdout:U,exitCode:ze}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}?ref=${b}`,"-q",".sha"]),re=U.trim();if(ze===0&&re){let{exitCode:de}=await H(["gh","api",`repos/${y}/asm-registry/contents/${w}`,"-X","PUT","-f",`message=Update ${y}/${s.name}`,"-f",`content=${S}`,"-f",`branch=${b}`,"-f",`sha=${re}`]);if(de!==0)return{success:!1,manifest:h,prUrl:null,error:"Failed to write manifest to registry fork.",securityVerdict:r,securityReport:n}}else return{success:!1,manifest:h,prUrl:null,error:`Failed to write manifest to registry fork. ${M}`,securityVerdict:r,securityReport:n}}let D=Wr(s.name),T=Wr(s.description),A=Wr(s.license),N=`Publish ${y}/${Si(s.name)}`,_=[`## Skill: ${D}`,"",`**Author:** ${y}`,`**Version:** ${s.version}`,`**Description:** ${T}`,`**License:** ${A}`,`**Repository:** ${a}`,`**Commit:** \`${o}\``,`**Security verdict:** ${r}`,"","---","","*This PR was generated by `asm publish`.*"].join(`
|
|
197
|
+
`),{stdout:L,stderr:F,exitCode:ne}=await H(["gh","pr","create","--repo",Ge,"--head",`${y}:${b}`,"--title",N,"--body",_]),V=null;if(ne===0)V=L.trim();else{let U=F.match(/https:\/\/github\.com\/[^\s]+\/pull\/\d+/);U&&(V=U[0])}return V?{success:!0,manifest:h,prUrl:V,error:null,securityVerdict:r,securityReport:n}:{success:!1,manifest:h,prUrl:null,error:`Failed to create PR against ${Ge}. ${F}`,securityVerdict:r,securityReport:n}}function Wu(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(`
|
|
198
198
|
`).map(i=>` ${i}`).join(`
|
|
199
199
|
`)].join(`
|
|
200
|
-
`):""}import{execFile as
|
|
201
|
-
`)[0];if(!n)return null;let r=n.split(/\s+/)[0];return r&&/^[0-9a-f]{40}$/.test(r)?r:null}catch(s){return I(`updater: git ls-remote failed for ${e}: ${s}`),null}}function
|
|
202
|
-
`)}function
|
|
203
|
-
`)[0],n=i.match(/(\d+\.\d+\.\d+)/);return{name:"GitHub CLI available",status:"pass",message:n?n[1]:i}}catch{return{name:"GitHub CLI available",status:"fail",message:"gh not found",fix:"Install GitHub CLI: https://cli.github.com"}}}async function
|
|
204
|
-
`);if(i.length<2)return{name:"Disk space",status:"warn",message:"Could not parse df output"};let n=i[1].split(/\s+/),r=parseInt(n[3],10);if(isNaN(r))return{name:"Disk space",status:"warn",message:"Could not parse available space"};let o=r/1024,a=o/1024;return o>100?{name:"Disk space",status:"pass",message:`OK (${a>=1?`${a.toFixed(1)} GB free`:`${Math.round(o)} MB free`})`}:{name:"Disk space",status:"fail",message:`${Math.round(o)} MB free (requires > 100 MB)`,fix:"Free disk space in home directory"}}catch{return{name:"Disk space",status:"warn",message:"Could not check disk space"}}}async function
|
|
205
|
-
`)}function
|
|
200
|
+
`):""}import{execFile as dw}from"child_process";import{promisify as fw}from"util";import{rm as $i,rename as Gu,cp as Yu,access as pw,mkdir as mw}from"fs/promises";import{join as xi}from"path";import{homedir as zu}from"os";var Gr=fw(dw);async function hw(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 gw(e,t){try{let s=["ls-remote",e];t?s.push(t):s.push("HEAD");let{stdout:i}=await Gr("git",s,{timeout:1e4}),n=i.split(`
|
|
201
|
+
`)[0];if(!n)return null;let r=n.split(/\s+/)[0];return r&&/^[0-9a-f]{40}$/.test(r)?r:null}catch(s){return I(`updater: git ls-remote failed for ${e}: ${s}`),null}}function Yr(e){return e.sourceType?e.sourceType:e.source.startsWith("local:")?"local":"github"}function Qu(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 yw(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 zr(e){let t=e?.readLockFn??Oe,s=e?.fetchRegistryIndexFn??Fr,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])=>Yr(l)==="registry"||l.registryName)&&(r=await s());let a=await hw(n,5,async([l,c])=>{let f=Yr(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:ge(c.commitHash),latestCommit:ge(h.commit),source:c.source,sourceType:f,status:g?"outdated":"up-to-date"}}}let d=Qu(c.source);if(!d)return{name:l,installedCommit:ge(c.commitHash),latestCommit:"unknown",source:c.source,sourceType:f,status:"error",error:"Cannot determine remote URL"};let p=await gw(d,c.ref);if(!p)return{name:l,installedCommit:ge(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:ge(c.commitHash),latestCommit:ge(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 bw(e,t,s,i){if(Yr(t)==="local")return{name:e,status:"skipped",reason:"Local skill (not updatable)"};let r=Qu(t.source);if(!r)return{name:e,status:"failed",reason:"Cannot determine remote URL"};let o=xi(zu(),".config","agent-skill-manager",".tmp",`${e}-${Date.now()}`);try{let a=xi(zu(),".config","agent-skill-manager",".tmp");await mw(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 Gr("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 Gr("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??Le,C=yw(t.source);if(f=(await v(o,e,C?.owner,C?.repo)).verdict,f==="dangerous")return{name:e,status:"skipped",reason:"Security audit: dangerous \u2014 update blocked",securityVerdict:f};if(f==="warning"||f==="caution"){if(!s)return{name:e,status:"skipped",reason:`Security audit: ${f} \u2014 use --yes to override`,securityVerdict:f};I(`updater: security audit ${f} for ${e} \u2014 proceeding (--yes)`)}}catch(v){return I(`updater: security audit failed for ${e}: ${v.message}`),{name:e,status:"failed",reason:`Security audit failed \u2014 skipping update: ${v.message}`}}let d=i?.loadConfigFn??B,p=i?.resolveProviderPathFn??oe,y=(await d()).providers.find(v=>v.name===t.provider),h=y?y.global:`~/.${t.provider}/skills`,g=p(h),b=xi(g,e),w=xi(o,".git");try{await $i(w,{recursive:!0,force:!0})}catch{}try{await pw(b)}catch{let v=i?.writeLockEntryFn??wt;return await Yu(o,b,{recursive:!0}),await v(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:ge(t.commitHash),newCommit:ge(c),securityVerdict:f}}let k=`${b}.bak-${Date.now()}`;try{await Gu(b,k),await Yu(o,b,{recursive:!0}),await $i(k,{recursive:!0,force:!0})}catch(v){try{await $i(b,{recursive:!0,force:!0}),await Gu(k,b)}catch{}return{name:e,status:"failed",reason:`Atomic swap failed: ${v.message}`}}return await(i?.writeLockEntryFn??wt)(e,{...t,commitHash:c,installedAt:new Date().toISOString()}),{name:e,status:"updated",oldCommit:ge(t.commitHash),newCommit:ge(c),securityVerdict:f}}finally{try{await $i(o,{recursive:!0,force:!0})}catch{}}}async function Xu(e,t,s){let i=s?.readLockFn??Oe,n=s?.checkOutdatedFn??zr,r=s?.updateSkillFn??bw,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 ge(e){return!e||e==="unknown"?"unknown":e.slice(0,7)}function Zu(e,t){if(e.entries.length===0)return"No skills installed.";let s=d=>d,i=t?u.red:s,n=t?u.green:s,r=t?u.yellow:s,o=t?u.dim:s,a=`${"Skill".padEnd(22)}${"Installed".padEnd(14)}${"Latest".padEnd(14)}Source`,l="\u2500".repeat(60),c=[a,l];for(let d of e.entries){let p=d.name.padEnd(22),m=d.installedCommit.padEnd(14),y,h;switch(d.status){case"outdated":y=i(d.latestCommit.padEnd(14)),h=d.sourceType;break;case"up-to-date":y=n(d.latestCommit.padEnd(14)),h=o("(up to date)");break;case"untracked":y=r("untracked".padEnd(14)),h=r("untracked");break;case"error":y=o("error".padEnd(14)),h=o(d.error||"error");break}c.push(`${p}${m}${y}${h}`)}c.push("");let f=[];return e.outdatedCount>0&&f.push(i(`${e.outdatedCount} outdated`)),e.upToDateCount>0&&f.push(n(`${e.upToDateCount} up to date`)),e.untrackedCount>0&&f.push(r(`${e.untrackedCount} untracked`)),e.errorCount>0&&f.push(o(`${e.errorCount} error`)),c.push(f.join(", ")),c.join(`
|
|
202
|
+
`)}function ed(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 td(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 Rw}from"child_process";import{promisify as Lw}from"util";import{access as sd,readFile as nd,readdir as Ow,writeFile as Tw,rm as Mw,stat as rd}from"fs/promises";import{join as Qr}from"path";import{homedir as Dw}from"os";import{constants as id}from"fs";import{access as ww,realpath as vw,stat as kw}from"fs/promises";import{constants as Sw}from"fs";import{delimiter as $w,resolve as xw,sep as Ew}from"path";var Cw="asm";function Aw(e){if(!e)return[];let t=new Set,s=[];for(let i of e.split($w)){let n=i.trim();if(!n)continue;let r=n.endsWith(Ew)?n.slice(0,-1):n;t.has(r)||(t.add(r),s.push(r))}return s}async function Pw(e){try{if(!(await kw(e)).isFile())return!1}catch{return!1}try{return await ww(e,Sw.X_OK),!0}catch{return!1}}async function Nw(e){try{return await vw(e)}catch{return e}}async function Iw(e=process.env.PATH){let t=new Set,s=[];for(let i of Aw(e)){let n=xw(i,Cw);if(!await Pw(n))continue;let r=await Nw(n);t.has(r)||(t.add(r),s.push({path:n,realPath:r}))}return s}async function Ei(e=process.env.PATH){let t=await Iw(e);if(t.length===0)return{resolved:null,shadowed:[]};let[s,...i]=t;return{resolved:s,shadowed:i}}var ft=Lw(Rw);async function Fw(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 _w(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 jw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("gh",["--version"],{timeout:5e3}),i=s.trim().split(`
|
|
203
|
+
`)[0],n=i.match(/(\d+\.\d+\.\d+)/);return{name:"GitHub CLI available",status:"pass",message:n?n[1]:i}}catch{return{name:"GitHub CLI available",status:"fail",message:"gh not found",fix:"Install GitHub CLI: https://cli.github.com"}}}async function qw(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 Bw(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 Uw(e){try{let t=Qr(e,".asm-doctor-write-test");return await Tw(t,"test","utf-8"),await Mw(t),{writable:!0,exists:!0}}catch{}try{return await sd(e,id.W_OK),{writable:!0,exists:!0}}catch{}try{return await sd(e,id.F_OK),{writable:!1,exists:!0}}catch{return{writable:!0,exists:!1}}}async function Kw(e){let t=e.providers.filter(r=>r.enabled),s=0,i=0;for(let r of t){let o=oe(r.global);i++,(await Uw(o)).writable&&s++}if(s===i)return{name:"Agent directories writable",status:"pass",message:`${s}/${i} providers`};let n=i-s;return{name:"Agent directories writable",status:"warn",message:`${s}/${i} providers (${n} not writable)`,fix:"Fix permissions on agent skill directories"}}async function Vw(){let e=gt();try{let t=await nd(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 Jw(){let e=ho();try{let t=await nd(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 Hw(){try{let e=await fetch(Mr,{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=oe(l.global),f=Qr(c,o);try{(await rd(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 Gw(e,t){let s=new Set(Object.keys(t.skills)),i=[];for(let n of e.providers.filter(r=>r.enabled)){let r=oe(n.global);try{let o=await Ow(r);for(let a of o)try{(await rd(Qr(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 Yw(e){let t=e?.execFn??ft;try{let{stdout:s}=await t("df",["-Pk",Dw()],{timeout:5e3}),i=s.trim().split(`
|
|
204
|
+
`);if(i.length<2)return{name:"Disk space",status:"warn",message:"Could not parse df output"};let n=i[1].split(/\s+/),r=parseInt(n[3],10);if(isNaN(r))return{name:"Disk space",status:"warn",message:"Could not parse available space"};let o=r/1024,a=o/1024;return o>100?{name:"Disk space",status:"pass",message:`OK (${a>=1?`${a.toFixed(1)} GB free`:`${Math.round(o)} MB free`})`}:{name:"Disk space",status:"fail",message:`${Math.round(o)} MB free (requires > 100 MB)`,fix:"Free disk space in home directory"}}catch{return{name:"Disk space",status:"warn",message:"Could not check disk space"}}}async function zw(){try{let e=await Ei();if(e.shadowed.length===0)return e.resolved?{name:"No PATH shadowing",status:"pass",message:`single install at ${e.resolved.path}`}:{name:"No PATH shadowing",status:"pass",message:"asm not yet on PATH"};let t=e.resolved,s=e.shadowed[0].path,i=e.shadowed.length>1?` (+${e.shadowed.length-1} more)`:"";return{name:"No PATH shadowing",status:"warn",message:`resolved ${t.path}, shadowed ${s}${i}`,fix:"Remove the duplicate install (`npm uninstall -g agent-skill-manager`) and keep only one."}}catch(e){return{name:"No PATH shadowing",status:"warn",message:`Could not scan PATH: ${e?.message??e}`}}}async function od(){let e=await B(),t=await Oe(),i=(await Promise.allSettled([Fw(),_w(),jw(),qw(),Bw(),Kw(e),Vw(),Jw(),Hw(),Ww(e,t),Gw(e,t),Yw(),zw()])).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 Qw={pass:"\u2705",warn:"\u26A0\uFE0F ",fail:"\u274C"};function ad(e){let t=["Checking your environment...",""];for(let s of e.checks){let n=` ${Qw[s.status]} ${s.name}${s.message?` (${s.message})`:""}`;if(t.push(n),s.fix&&s.status!=="pass"){let r;s.fix.startsWith("Run: ")?r=s.fix:/^[a-z/~]/.test(s.fix)?r=`Run: ${s.fix}`:r=`Fix: ${s.fix}`,t.push(` \u2192 ${r}`)}}return t.push(""),t.push(`${e.passed} passed, ${e.warnings} warning${e.warnings!==1?"s":""}, ${e.failures} error${e.failures!==1?"s":""}`),t.join(`
|
|
205
|
+
`)}function ld(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 Zr,writeFile as Xw,stat as pt,copyFile as Zw,readdir as pd}from"fs/promises";import{join as mt,resolve as to,basename as we,isAbsolute as so}from"path";var eo="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`).",cd=["name","description","version","license","author","creator","compatibility","allowed-tools","effort","tags","metadata"],ud=["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"],ev=["confirm","confirmation","error","errors","fail","failure","caution","warning","prerequisite","prerequisites","requires","requirements","rollback","dry-run","dry run","safety","validate","validation","check","backup"],tv=["acceptance criteria","expected output","expected result","edge case","edge cases","test","tests","testing","verify","verification","assert","example input","example output","given","then"],sv=["reference","references","see","template","templates","script","scripts","helper","helpers","link"],iv=["when to use","quick start","overview","instructions","steps","workflow","phases","progressive"];function md(e){let t=e.split(`
|
|
206
206
|
`);if(t.length===0||t[0].trim()!=="---")return{rawFrontmatter:null,body:e};for(let s=1;s<t.length;s++)if(t[s].trim()==="---"){let i=t.slice(1,s).join(`
|
|
207
207
|
`),n=t.slice(s+1).join(`
|
|
208
208
|
`);return{rawFrontmatter:i,body:n}}return{rawFrontmatter:t.slice(1).join(`
|
|
209
|
-
`),body:""}}function
|
|
210
|
-
`).length:0}function so(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function iv(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function xi(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function nv(e){return/```[\s\S]+?```/m.test(e)}function rv(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function ov(e,t,s,i){let n=[],r=[],o=0;s!==null?(o+=2,n.push("Has YAML frontmatter block.")):(n.push("SKILL.md has no YAML frontmatter."),r.push("Add a YAML frontmatter block delimited by `---` with at least `name` and `description` fields."));let a=!!(e.name&&e.name.trim()),l=!!(e.description&&e.description.trim());a?o+=1.5:(n.push("Missing required field: name."),r.push("Add `name:` to frontmatter (use the skill directory name).")),l?o+=1.5:(n.push("Missing required field: description."),r.push("Add a one-line `description:` to frontmatter."));let c=ue(e);c&&c!=="0.0.0"?o+=1:(n.push("Missing or default version."),r.push("Set `metadata.version` (or top-level `version`) using semver (e.g. 0.1.0).")),!!(e.author||e["metadata.author"]||e.creator||e["metadata.creator"])?o+=1:(n.push("Missing `author`."),r.push("Add an `author` field so users know who authored and maintains the skill.")),!!e.license?o+=1:(n.push("Missing `license`."),r.push("Add a `license` field (e.g. `license: MIT`)."));let m=t.trim().length>=20,y=iv(t,1);if(m?(o+=1,n.push("Body has meaningful content.")):(n.push("Body content is too short (<20 chars of instructions)."),r.push("Flesh out the markdown body with at least one paragraph of instructions for the agent.")),y?(o+=1,n.push("Body uses markdown headings.")):(n.push("Body has no markdown headings."),r.push("Add section headings (e.g. `## When to Use`, `## Instructions`) so the agent can navigate the skill quickly.")),i){let h=i.find(g=>g.toLowerCase()==="readme.md");h&&(n.push(`\`${h}\` found at skill root; move it to a subdirectory (e.g., \`docs/README.md\`).`),r.push(Zr))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function av(e,t){let s=[],i=[],n=0,r=(e.description||"").trim();if(!r)return s.push("No description."),i.push("Write a one-sentence description that says specifically what the skill does and when to use it."),{id:"description",name:"Description quality",score:0,max:10,findings:s,suggestions:i};let o=so(r);s.push(`Description is ${o} words.`),o>=8&&o<=40?n+=4:o>=5&&o<8?(n+=2,i.push("Lengthen the description slightly so it names both the action and the trigger (aim for 8\u201320 words).")):o>=41&&o<=60?(n+=2,i.push("Trim the description \u2014 aim for under 40 words. Move the long version to the markdown body.")):o>60?(n+=0,i.push("Description is too long. Keep it under 40 words; put detail in the body.")):(n+=0,i.push("Description is too short. Aim for 8\u201320 words."));let a=r.split(/\s+/)[0]?.toLowerCase().replace(/[^\w-]/g,"");return!!(a&&(cd.includes(a)||cd.includes(a.replace(/s$/,""))))?(n+=3,s.push("Starts with an action verb.")):(s.push(`Does not start with a recognized action verb (got "${a??""}").`),i.push('Start the description with an imperative action verb (e.g. "Generate...", "Analyze...", "Review...").')),/\buse when\b|\btrigger\b|\bwhen\b|\bfor\b/i.test(r)||/\b(before|after|during)\b/i.test(r)?(n+=3,s.push("Mentions a trigger or use-case signal.")):(s.push("No explicit trigger / use-case phrase."),i.push('Name the trigger in the description \u2014 e.g. "Use when...", "for reviewing...", "before publishing...".')),{id:"description",name:"Description quality",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function lv(e,t){let s=[],i=[],n=0,r=xi(t,sv);r.length>=2?(n+=3,s.push(`Progressive disclosure cues present: ${r.slice(0,3).join(", ")}.`)):r.length===1?(n+=1,i.push('Add clearer section labels \u2014 e.g. "## When to Use" and "## Instructions" \u2014 to support progressive disclosure.')):i.push('Structure the body with "## When to Use" and "## Instructions" sections so the agent reads only what it needs.'),rv(t)?(n+=2,s.push("Uses lists or numbered steps.")):(s.push("No lists or steps detected."),i.push("Use bulleted or numbered steps to narrow the agent's degrees of freedom."));let o=nv(t),a=/\bexample\b/i.test(t);o&&a?(n+=2,s.push("Includes example code block.")):o||a?(n+=1,i.push('Back up examples with fenced code blocks labelled under "## Example" so the agent sees concrete input/output.')):i.push('Add an "## Example" section with a fenced code block showing the desired output.');let l=(t.match(/^\s*[-*0-9.]*\s*(Do|Use|Run|Call|Check|Validate|Return|Emit|Write|Read|Ask|Confirm|Avoid|Never|Always)\b/gim)||[]).length;l>=3?(n+=2,s.push(`Uses imperative voice (${l} cues).`)):l>=1?(n+=1,i.push("Favor imperative voice (Do / Use / Avoid / Never) to narrow the agent's choices.")):i.push('Rewrite instructions in the imperative mood \u2014 e.g. "Run `git status` first" instead of "you might want to run".');let c=so(t);return c>=80&&c<=3e3?(n+=1,s.push(`Body length within healthy range (${c} words).`)):c<80?(s.push(`Body is very short (${c} words).`),i.push("Expand the instructions; an underspecified skill gives the agent too much freedom.")):(s.push(`Body is very long (${c} words).`),i.push("Split large content into referenced files; keep SKILL.md focused under ~3000 words.")),{id:"prompt-engineering",name:"Prompt engineering",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function cv(e,t){let s=[],i=[],n=0,r=so(t);s.push(`Body is ${r} words.`),r>=120&&r<=1500?n+=4:r>=60&&r<120?(n+=2,i.push("Expand instructions slightly \u2014 too little context can push the agent to improvise.")):r>1500&&r<=3e3?(n+=2,i.push("Consider moving large sections into referenced files (e.g. `references/*.md`) and linking them instead of inlining.")):r>3e3&&(n+=0,i.push("Body is over 3000 words \u2014 split long content into referenced files or templates."));let o=xi(t,tv);o.length>=2?(n+=3,s.push(`References external files or links (${o.slice(0,3).join(", ")}).`)):o.length===1?(n+=1,i.push('Link out to supporting files (e.g. "see `references/examples.md`") instead of inlining them.')):i.push('Offload verbose content to referenced files and link to them ("see `./templates/x.md`").');let l=(t.match(/```[\s\S]+?```/g)||[]).filter(c=>md(c)>60);return l.length===0?(n+=2,s.push("No oversized code blocks.")):(s.push(`${l.length} code block(s) longer than 60 lines.`),i.push("Move large code blocks into referenced template files; link to them from SKILL.md.")),/\btoken\b|\bbudget\b|\bcontext window\b/i.test(t)&&(n+=1,s.push("Mentions tokens/budget/context window.")),{id:"context-efficiency",name:"Context efficiency",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function uv(e,t){let s=[],i=[],n=0,r=xi(t,Zw);r.length>=4?(n+=4,s.push(`Covers multiple safety cues (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=2,s.push(`Mentions a few safety cues: ${r.join(", ")}.`),i.push("Add explicit error-handling and confirmation steps so the agent knows how to recover from failures.")):r.length===1?(n+=1,i.push('Expand the safety section \u2014 include prerequisites, validation steps, and what to do "on error".')):i.push("Describe prerequisites, confirmation prompts, and error-handling steps to reduce blast radius.");let o=/\b(rm\s|delete|remove|drop|force|overwrite|destructive)\b/i.test(t),a=/\bconfirm\b|\bdry-?run\b|\bare you sure\b|\bbackup\b/i.test(t);return o&&a?(n+=3,s.push("Destructive actions paired with confirmation/dry-run.")):o?(s.push("References destructive actions without explicit confirmation/dry-run."),i.push("Pair any destructive command with an explicit confirmation prompt, dry-run flag, or backup step.")):n+=1.5,/\bprerequisit/i.test(t)||/\brequire/i.test(t)||/\bdepend/i.test(t)?(n+=3,s.push("Declares prerequisites or requirements.")):(s.push("No prerequisites / requirements section."),i.push('Add a "## Prerequisites" block listing required tools, credentials, and environment state.')),{id:"safety",name:"Safety & guardrails",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function dv(e,t){let s=[],i=[],n=0,r=xi(t,ev);return r.length>=4?(n+=5,s.push(`Many testability cues present (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=3,s.push(`Some testability cues: ${r.join(", ")}.`),i.push('Add an "## Acceptance Criteria" block listing verifiable outputs or checklist items.')):r.length===1?(n+=1,i.push('Add concrete "expected output" examples so the agent can self-check.')):i.push('Add a "## Acceptance Criteria" section with testable statements (e.g. "produces a JSON report with overall_score").'),/expected\s+(output|result|response)/i.test(t)?(n+=3,s.push("Describes expected output/result.")):i.push('Include an "Expected output" example so reviewers and the agent can verify correctness.'),/\bedge case|gotcha|pitfall|limitation/i.test(t)?(n+=2,s.push("Mentions edge cases or limitations.")):i.push('Add a short "Edge cases" list to describe inputs the skill should reject or handle carefully.'),{id:"testability",name:"Testability",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function fv(e,t){let s=[],i=[],n=0,r=(e.name||"").trim();if(r){let l=/^[a-z][a-z0-9-]*$/.test(r),c=r.length<=40;l&&c?(n+=4,s.push(`name "${r}" follows kebab-case convention.`)):(l||(s.push(`name "${r}" is not lowercase kebab-case.`),i.push(`Rename to lowercase kebab-case (e.g. "${r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}").`)),c||s.push(`name is ${r.length} chars; keep it <= 40.`))}else i.push("Add a kebab-case `name` (e.g. `my-skill`).");let o=t.match(/^#{1,6}\s+(.+)$/gm)||[];return o.length>0&&(o.filter(f=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(f)).length/o.length>=.5?(n+=3,s.push("Most headings use action/imperative labels.")):(n+=1,i.push("Rename body headings to action-oriented labels (e.g. `## Instructions`, `## When to Use`)."))),/(?:\s\s|\bTODO\b|\bFIXME\b|\?{2,})/.test(e.description||"")?i.push("Clean up description \u2014 remove TODOs, FIXMEs, double spaces, or trailing punctuation."):(n+=2,s.push("Description looks clean (no TODO/FIXME/stray noise).")),{id:"naming",name:"Naming & conventions",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function ts(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=te(t),{rawFrontmatter:o,body:a}=pd(t),l=[ov(r,a,o,n),av(r,a),lv(r,a),cv(r,a),uv(r,a),dv(r,a),fv(r,a)];if(r.name&&we(s)===r.name){let g=l.find(b=>b.id==="naming");g.score<g.max&&(g.score=Math.min(g.max,g.score+1),g.findings.push("Directory name matches frontmatter `name`."))}let c=l.reduce((g,b)=>g+b.score,0),f=l.reduce((g,b)=>g+b.max,0),d=Math.round(c/f*100),p="F";d>=90?p="A":d>=80?p="B":d>=65?p="C":d>=50&&(p="D");let m=[];l.find(g=>g.id==="structure")?.suggestions.includes(Zr)&&m.push(Zr);let h=[...l].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of h){for(let b of g.suggestions){if(m.length>=3)break;m.includes(b)||m.push(b)}if(m.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:l,overallScore:d,grade:p,topSuggestions:m,frontmatter:r}}async function hd(e){let t=to(e)?e:eo(e),s;try{s=await pt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Xr(i,"utf-8"),ts({content:n,skillPath:we(t)==="SKILL.md"?we(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=mt(t,"SKILL.md");try{n=await Xr(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await fd(t)}catch{r=void 0}return ts({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function pv(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function mv(e){let t=e.split(`
|
|
209
|
+
`),body:""}}function hd(e){return e?e.split(`
|
|
210
|
+
`).length:0}function io(e){return e?e.split(/\s+/).map(t=>t.trim()).filter(Boolean).length:0}function nv(e,t=1){return(e.match(/^#{1,6}\s+\S/gm)||[]).length>=t}function Ci(e,t){let s=e.toLowerCase();return t.filter(i=>s.includes(i))}function rv(e){return/```[\s\S]+?```/m.test(e)}function ov(e){return/^\s*[-*]\s+\S/m.test(e)||/^\s*\d+\.\s+\S/m.test(e)}function av(e,t,s,i){let n=[],r=[],o=0;s!==null?(o+=2,n.push("Has YAML frontmatter block.")):(n.push("SKILL.md has no YAML frontmatter."),r.push("Add a YAML frontmatter block delimited by `---` with at least `name` and `description` fields."));let a=!!(e.name&&e.name.trim()),l=!!(e.description&&e.description.trim());a?o+=1.5:(n.push("Missing required field: name."),r.push("Add `name:` to frontmatter (use the skill directory name).")),l?o+=1.5:(n.push("Missing required field: description."),r.push("Add a one-line `description:` to frontmatter."));let c=ae(e);c&&c!=="0.0.0"?o+=1:(n.push("Missing or default version."),r.push("Set `metadata.version` (or top-level `version`) using semver (e.g. 0.1.0).")),!!(e.author||e["metadata.author"]||e.creator||e["metadata.creator"])?o+=1:(n.push("Missing `author`."),r.push("Add an `author` field so users know who authored and maintains the skill.")),!!e.license?o+=1:(n.push("Missing `license`."),r.push("Add a `license` field (e.g. `license: MIT`)."));let m=t.trim().length>=20,y=nv(t,1);if(m?(o+=1,n.push("Body has meaningful content.")):(n.push("Body content is too short (<20 chars of instructions)."),r.push("Flesh out the markdown body with at least one paragraph of instructions for the agent.")),y?(o+=1,n.push("Body uses markdown headings.")):(n.push("Body has no markdown headings."),r.push("Add section headings (e.g. `## When to Use`, `## Instructions`) so the agent can navigate the skill quickly.")),i){let h=i.find(g=>g.toLowerCase()==="readme.md");h&&(n.push(`\`${h}\` found at skill root; move it to a subdirectory (e.g., \`docs/README.md\`).`),r.push(eo))}return{id:"structure",name:"Structure & completeness",score:Math.round(o),max:10,findings:n,suggestions:r}}function lv(e,t){let s=[],i=[],n=0,r=(e.description||"").trim();if(!r)return s.push("No description."),i.push("Write a one-sentence description that says specifically what the skill does and when to use it."),{id:"description",name:"Description quality",score:0,max:10,findings:s,suggestions:i};let o=io(r);s.push(`Description is ${o} words.`),o>=8&&o<=40?n+=4:o>=5&&o<8?(n+=2,i.push("Lengthen the description slightly so it names both the action and the trigger (aim for 8\u201320 words).")):o>=41&&o<=60?(n+=2,i.push("Trim the description \u2014 aim for under 40 words. Move the long version to the markdown body.")):o>60?(n+=0,i.push("Description is too long. Keep it under 40 words; put detail in the body.")):(n+=0,i.push("Description is too short. Aim for 8\u201320 words."));let a=r.split(/\s+/)[0]?.toLowerCase().replace(/[^\w-]/g,"");return!!(a&&(ud.includes(a)||ud.includes(a.replace(/s$/,""))))?(n+=3,s.push("Starts with an action verb.")):(s.push(`Does not start with a recognized action verb (got "${a??""}").`),i.push('Start the description with an imperative action verb (e.g. "Generate...", "Analyze...", "Review...").')),/\buse when\b|\btrigger\b|\bwhen\b|\bfor\b/i.test(r)||/\b(before|after|during)\b/i.test(r)?(n+=3,s.push("Mentions a trigger or use-case signal.")):(s.push("No explicit trigger / use-case phrase."),i.push('Name the trigger in the description \u2014 e.g. "Use when...", "for reviewing...", "before publishing...".')),{id:"description",name:"Description quality",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function cv(e,t){let s=[],i=[],n=0,r=Ci(t,iv);r.length>=2?(n+=3,s.push(`Progressive disclosure cues present: ${r.slice(0,3).join(", ")}.`)):r.length===1?(n+=1,i.push('Add clearer section labels \u2014 e.g. "## When to Use" and "## Instructions" \u2014 to support progressive disclosure.')):i.push('Structure the body with "## When to Use" and "## Instructions" sections so the agent reads only what it needs.'),ov(t)?(n+=2,s.push("Uses lists or numbered steps.")):(s.push("No lists or steps detected."),i.push("Use bulleted or numbered steps to narrow the agent's degrees of freedom."));let o=rv(t),a=/\bexample\b/i.test(t);o&&a?(n+=2,s.push("Includes example code block.")):o||a?(n+=1,i.push('Back up examples with fenced code blocks labelled under "## Example" so the agent sees concrete input/output.')):i.push('Add an "## Example" section with a fenced code block showing the desired output.');let l=(t.match(/^\s*[-*0-9.]*\s*(Do|Use|Run|Call|Check|Validate|Return|Emit|Write|Read|Ask|Confirm|Avoid|Never|Always)\b/gim)||[]).length;l>=3?(n+=2,s.push(`Uses imperative voice (${l} cues).`)):l>=1?(n+=1,i.push("Favor imperative voice (Do / Use / Avoid / Never) to narrow the agent's choices.")):i.push('Rewrite instructions in the imperative mood \u2014 e.g. "Run `git status` first" instead of "you might want to run".');let c=io(t);return c>=80&&c<=3e3?(n+=1,s.push(`Body length within healthy range (${c} words).`)):c<80?(s.push(`Body is very short (${c} words).`),i.push("Expand the instructions; an underspecified skill gives the agent too much freedom.")):(s.push(`Body is very long (${c} words).`),i.push("Split large content into referenced files; keep SKILL.md focused under ~3000 words.")),{id:"prompt-engineering",name:"Prompt engineering",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function uv(e,t){let s=[],i=[],n=0,r=io(t);s.push(`Body is ${r} words.`),r>=120&&r<=1500?n+=4:r>=60&&r<120?(n+=2,i.push("Expand instructions slightly \u2014 too little context can push the agent to improvise.")):r>1500&&r<=3e3?(n+=2,i.push("Consider moving large sections into referenced files (e.g. `references/*.md`) and linking them instead of inlining.")):r>3e3&&(n+=0,i.push("Body is over 3000 words \u2014 split long content into referenced files or templates."));let o=Ci(t,sv);o.length>=2?(n+=3,s.push(`References external files or links (${o.slice(0,3).join(", ")}).`)):o.length===1?(n+=1,i.push('Link out to supporting files (e.g. "see `references/examples.md`") instead of inlining them.')):i.push('Offload verbose content to referenced files and link to them ("see `./templates/x.md`").');let l=(t.match(/```[\s\S]+?```/g)||[]).filter(c=>hd(c)>60);return l.length===0?(n+=2,s.push("No oversized code blocks.")):(s.push(`${l.length} code block(s) longer than 60 lines.`),i.push("Move large code blocks into referenced template files; link to them from SKILL.md.")),/\btoken\b|\bbudget\b|\bcontext window\b/i.test(t)&&(n+=1,s.push("Mentions tokens/budget/context window.")),{id:"context-efficiency",name:"Context efficiency",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function dv(e,t){let s=[],i=[],n=0,r=Ci(t,ev);r.length>=4?(n+=4,s.push(`Covers multiple safety cues (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=2,s.push(`Mentions a few safety cues: ${r.join(", ")}.`),i.push("Add explicit error-handling and confirmation steps so the agent knows how to recover from failures.")):r.length===1?(n+=1,i.push('Expand the safety section \u2014 include prerequisites, validation steps, and what to do "on error".')):i.push("Describe prerequisites, confirmation prompts, and error-handling steps to reduce blast radius.");let o=/\b(rm\s|delete|remove|drop|force|overwrite|destructive)\b/i.test(t),a=/\bconfirm\b|\bdry-?run\b|\bare you sure\b|\bbackup\b/i.test(t);return o&&a?(n+=3,s.push("Destructive actions paired with confirmation/dry-run.")):o?(s.push("References destructive actions without explicit confirmation/dry-run."),i.push("Pair any destructive command with an explicit confirmation prompt, dry-run flag, or backup step.")):n+=1.5,/\bprerequisit/i.test(t)||/\brequire/i.test(t)||/\bdepend/i.test(t)?(n+=3,s.push("Declares prerequisites or requirements.")):(s.push("No prerequisites / requirements section."),i.push('Add a "## Prerequisites" block listing required tools, credentials, and environment state.')),{id:"safety",name:"Safety & guardrails",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function fv(e,t){let s=[],i=[],n=0,r=Ci(t,tv);return r.length>=4?(n+=5,s.push(`Many testability cues present (${r.slice(0,4).join(", ")}).`)):r.length>=2?(n+=3,s.push(`Some testability cues: ${r.join(", ")}.`),i.push('Add an "## Acceptance Criteria" block listing verifiable outputs or checklist items.')):r.length===1?(n+=1,i.push('Add concrete "expected output" examples so the agent can self-check.')):i.push('Add a "## Acceptance Criteria" section with testable statements (e.g. "produces a JSON report with overall_score").'),/expected\s+(output|result|response)/i.test(t)?(n+=3,s.push("Describes expected output/result.")):i.push('Include an "Expected output" example so reviewers and the agent can verify correctness.'),/\bedge case|gotcha|pitfall|limitation/i.test(t)?(n+=2,s.push("Mentions edge cases or limitations.")):i.push('Add a short "Edge cases" list to describe inputs the skill should reject or handle carefully.'),{id:"testability",name:"Testability",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function pv(e,t){let s=[],i=[],n=0,r=(e.name||"").trim();if(r){let l=/^[a-z][a-z0-9-]*$/.test(r),c=r.length<=40;l&&c?(n+=4,s.push(`name "${r}" follows kebab-case convention.`)):(l||(s.push(`name "${r}" is not lowercase kebab-case.`),i.push(`Rename to lowercase kebab-case (e.g. "${r.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}").`)),c||s.push(`name is ${r.length} chars; keep it <= 40.`))}else i.push("Add a kebab-case `name` (e.g. `my-skill`).");let o=t.match(/^#{1,6}\s+(.+)$/gm)||[];return o.length>0&&(o.filter(f=>/^#{1,6}\s+([A-Z][a-z]+|Use|How|When|Workflow|Instructions|Examples|Steps|Acceptance)/.test(f)).length/o.length>=.5?(n+=3,s.push("Most headings use action/imperative labels.")):(n+=1,i.push("Rename body headings to action-oriented labels (e.g. `## Instructions`, `## When to Use`)."))),/(?:\s\s|\bTODO\b|\bFIXME\b|\?{2,})/.test(e.description||"")?i.push("Clean up description \u2014 remove TODOs, FIXMEs, double spaces, or trailing punctuation."):(n+=2,s.push("Description looks clean (no TODO/FIXME/stray noise).")),{id:"naming",name:"Naming & conventions",score:Math.min(10,Math.round(n)),max:10,findings:s,suggestions:i}}function ss(e){let{content:t,skillPath:s,skillMdPath:i,rootEntries:n}=e,r=X(t),{rawFrontmatter:o,body:a}=md(t),l=[av(r,a,o,n),lv(r,a),cv(r,a),uv(r,a),dv(r,a),fv(r,a),pv(r,a)];if(r.name&&we(s)===r.name){let g=l.find(b=>b.id==="naming");g.score<g.max&&(g.score=Math.min(g.max,g.score+1),g.findings.push("Directory name matches frontmatter `name`."))}let c=l.reduce((g,b)=>g+b.score,0),f=l.reduce((g,b)=>g+b.max,0),d=Math.round(c/f*100),p="F";d>=90?p="A":d>=80?p="B":d>=65?p="C":d>=50&&(p="D");let m=[];l.find(g=>g.id==="structure")?.suggestions.includes(eo)&&m.push(eo);let h=[...l].sort((g,b)=>g.score/g.max-b.score/b.max);for(let g of h){for(let b of g.suggestions){if(m.length>=3)break;m.includes(b)||m.push(b)}if(m.length>=3)break}return{skillPath:s,skillMdPath:i,evaluatedAt:new Date().toISOString(),categories:l,overallScore:d,grade:p,topSuggestions:m,frontmatter:r}}async function gd(e){let t=so(e)?e:to(e),s;try{s=await pt(t)}catch{throw new Error(`Skill path does not exist: ${t}`)}let i,n;if(s.isFile())return i=t,n=await Zr(i,"utf-8"),ss({content:n,skillPath:we(t)==="SKILL.md"?we(t):t,skillMdPath:i});if(!s.isDirectory())throw new Error(`Skill path is not a directory or file: ${t}`);i=mt(t,"SKILL.md");try{n=await Zr(i,"utf-8")}catch{throw new Error(`SKILL.md not found in ${t}. Run "asm init" to create one.`)}let r;try{r=await pd(t)}catch{r=void 0}return ss({content:n,skillPath:t,skillMdPath:i,rootEntries:r})}function mv(e){return e<=20?"low":e<=80?"medium":e<=250?"high":"max"}function hv(e){let t=e.split(`
|
|
211
211
|
`),s=[],i=[],n=0;for(;n<t.length;){let c=t[n];if(!c.trim()){n++;continue}let d=c.match(/^([A-Za-z_][\w-]*):\s*(.*)$/);if(!d)return{newFrontmatter:e,changed:!1};let p=d[1],m=d[2];if(m===""||m===">"||m==="|"){let y=[c];for(n++;n<t.length;){let h=t[n];if(h.trim()===""){y.push(h),n++;continue}if(/^\s+/.test(h))y.push(h),n++;else break}i.push({key:p,text:y.join(`
|
|
212
|
-
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let f=
|
|
213
|
-
`),changed:a}}function
|
|
212
|
+
`)})}else s.push({key:p,text:c}),n++}let r=c=>{let f=cd.indexOf(c);return f===-1?cd.length+1:f},o=[...s].sort((c,f)=>{let d=r(c.key),p=r(f.key);return d!==p?d-p:s.indexOf(c)-s.indexOf(f)}),a=o.some((c,f)=>c!==s[f]);return{newFrontmatter:[...o.map(c=>c.text),...i.map(c=>c.text)].join(`
|
|
213
|
+
`),changed:a}}function gv(e,t={}){let s=[],i=[],n=e.replace(/\r\n/g,`
|
|
214
214
|
`);n!==e&&s.push({id:"normalise-line-endings",description:"Convert CRLF line endings to LF."});let r=n.split(`
|
|
215
215
|
`),o=r.map(g=>g.replace(/[ \t]+$/g,""));o.some((g,b)=>g!==r[b])&&s.push({id:"strip-trailing-whitespace",description:"Strip trailing whitespace from lines."}),n=o.join(`
|
|
216
|
-
`);let{rawFrontmatter:a,body:l}=
|
|
216
|
+
`);let{rawFrontmatter:a,body:l}=md(n),c=X(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=Xr(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=Xr(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=mv(hd(l));f=Xr(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=hv(f);m.changed&&(s.push({id:"reorder-frontmatter",description:"Reorder frontmatter fields to canonical order."}),f=m.newFrontmatter);let y=l.replace(/^\n+/,""),h=`---
|
|
217
217
|
${f.replace(/^\n+|\n+$/g,"")}
|
|
218
218
|
---
|
|
219
219
|
|
|
220
220
|
${y}`;return h.endsWith(`
|
|
221
221
|
`)||(h+=`
|
|
222
222
|
`),e.replace(/\r\n/g,`
|
|
223
|
-
`),{newContent:h,applied:s,skipped:i}}function
|
|
223
|
+
`),{newContent:h,applied:s,skipped:i}}function Xr(e,t,s){if(new RegExp(`^${t}:\\s*`,"m").test(e))return e;let n=/[:#{}\[\],&*?|<>=!%@`"']/.test(s)?JSON.stringify(s):s,r=e.length===0||e.endsWith(`
|
|
224
224
|
`)?"":`
|
|
225
225
|
`;return`${e}${r}${t}: ${n}
|
|
226
|
-
`}function
|
|
226
|
+
`}function yv(e,t,s="SKILL.md"){if(e===t)return"";let i=e.split(`
|
|
227
227
|
`),n=t.split(`
|
|
228
228
|
`),r=[`--- a/${s}`,`+++ b/${s}`],o=0;for(;o<i.length&&o<n.length&&i[o]===n[o];)o++;let a=0;for(;a<i.length-o&&a<n.length-o&&i[i.length-1-a]===n[n.length-1-a];)a++;let l=i.slice(o,i.length-a),c=n.slice(o,n.length-a),f=o+1,d=o+1;r.push(`@@ -${f},${l.length} +${d},${c.length} @@`);let p=i.slice(Math.max(0,o-3),o).map(y=>` ${y}`),m=i.slice(i.length-a,Math.min(i.length,i.length-a+3)).map(y=>` ${y}`);r.push(...p);for(let y of l)r.push(`-${y}`);for(let y of c)r.push(`+${y}`);return r.push(...m),r.join(`
|
|
229
|
-
`)}async function
|
|
230
|
-
`)}function
|
|
229
|
+
`)}async function yd(e,t){let s=so(e)?e:to(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 Zr(i,"utf-8")}catch{throw new Error(`SKILL.md not found at ${i}.`)}let o=gv(r,{gitAuthor:t.gitAuthor}),a=yv(r,o.newContent),l=null;return!t.dryRun&&o.newContent!==r&&(l=`${i}.bak`,await Zw(i,l),await Xw(i,o.newContent,"utf-8")),{report:ss({content:t.dryRun?r:o.newContent,skillPath:s,skillMdPath:i}),applied:o.applied,skipped:o.skipped,diff:a,dryRun:t.dryRun,backupPath:l,skillMdPath:i}}async function bd(){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 bv(e,t,s=20){let i=Math.round(e/t*s);return"\u2588".repeat(i)+"\u2591".repeat(Math.max(0,s-i))}function Ai(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} ${bv(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=wv(i.raw);if(n&&n.length>0){t.push(""),t.push(`${i.id}@${i.version} breakdown:`);for(let r of n){let o=r.passed?"\u221A":r.severity==="warning"?"\u26A0":"\xD7";t.push(` ${o} ${r.label}`),r.passed||t.push(` [${r.severity}] ${r.message}`)}continue}if(i.findings.length!==0){t.push(""),t.push(`${i.id}@${i.version} findings:`);for(let r of i.findings)t.push(` [${r.severity}] ${r.message}`)}}return t.join(`
|
|
230
|
+
`)}function wv(e){if(!e||typeof e!="object")return null;let t=e.checks;if(!Array.isArray(t))return null;let s=[];for(let i of t){if(!i||typeof i!="object")return null;let 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 wd(e){return JSON.stringify(e,null,2)}function vd(e){let t=[];if(e.applied.length===0&&e.skipped.length===0)return t.push("No fixes needed \u2014 SKILL.md is already clean."),t.join(`
|
|
231
231
|
`);if(e.applied.length>0){t.push(`${e.dryRun?"Would apply":"Applied"} ${e.applied.length} fix(es):`);for(let s of e.applied)t.push(` \u2022 ${s.description}`)}if(e.skipped.length>0){t.push(""),t.push(`Skipped ${e.skipped.length} issue(s) (not auto-fixable):`);for(let s of e.skipped)t.push(` \u2022 ${s.description}`)}return e.diff&&(t.push(""),t.push("Diff:"),t.push(e.diff)),!e.dryRun&&e.backupPath&&(t.push(""),t.push(`Backup: ${e.backupPath}`)),t.join(`
|
|
232
|
-
`)}async function
|
|
233
|
-
`)}function
|
|
232
|
+
`)}async function vv(e){let t;try{t=await pd(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 dd(e){let t=mt(e,"SKILL.md");try{if((await pt(t)).isFile())return{kind:"single",skillDirs:[e]}}catch{}let s=await vv(e);return s.length>0?{kind:"collection",skillDirs:s}:{kind:"none",skillDirs:[]}}function no(e){return e?!!(e.startsWith("github:")||/^https?:\/\/github\.com\//i.test(e)):!1}function fd(e){return{skillPath:e,skillMdPath:mt(e,"SKILL.md"),label:we(e)}}async function kd(e,t={}){if(!e)throw new Error("resolveEvalInput: input must be a non-empty string");if(no(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 dd(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(fd),isCollection:o.kind==="collection",cleanup:r.cleanup,provenance:{input:e,remote:!0,sourceRef:r.sourceRef,commitSha:r.commitSha,tempPath:r.rootDir}}}let s=so(e)?e:to(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 dd(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(fd),isCollection:n.kind==="collection",cleanup:async()=>{},provenance:{input:e,remote:!1,sourceRef:null}}}function Sd(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 $d(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 xd(e,t=28){let s=[];return s.push(""),s.push("Batch summary:"),s.push(` Skills evaluated: ${e.aggregate.succeeded}/${e.aggregate.total}`+(e.aggregate.failed>0?` (${e.aggregate.failed} failed)`:"")),e.aggregate.meanScore!==null&&s.push(` Mean score: ${e.aggregate.meanScore}/100`),e.aggregate.top&&s.push(` Top: ${e.aggregate.top.label} (${e.aggregate.top.score}/100)`),e.aggregate.bottom&&e.aggregate.bottom.label!==e.aggregate.top?.label&&s.push(` Bottom: ${e.aggregate.bottom.label} (${e.aggregate.bottom.score}/100)`),e.provenance.remote&&(e.provenance.sourceRef&&s.push(` Source: ${e.provenance.sourceRef}`),e.provenance.commitSha&&s.push(` Commit: ${e.provenance.commitSha}`),e.provenance.tempPath&&s.push(` Fetched to: ${e.provenance.tempPath}`)),s.join(`
|
|
233
|
+
`)}function Ed(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?Pi(t.report,null):null}))}}function Pi(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 kv=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function Sv(e){if(typeof e!="string")return null;let t=kv.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 $v(e,t){let s=Sv(e);if(!s)throw new Error(`invalid semver: ${t} "${e}"`);return s}var ro=new Map;function oo(e){if(!e||typeof e.id!="string"||e.id.length===0)throw new Error("register: provider.id is required");if($v(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=ro.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),ro.set(e.id,t)}function Ni(){let e=[];for(let t of ro.values())for(let s of t)e.push(s);return e}import{stat as xv}from"fs/promises";var Cd="quality",Ad="1.0.0",Pd=1;function Ev(e){return e.topSuggestions.map(t=>({severity:"info",message:t}))}function Cv(e){return e.categories.map(t=>({id:t.id,name:t.name,score:t.score,max:t.max}))}var Nd={id:Cd,version:Ad,schemaVersion:Pd,description:"Static linter for SKILL.md structure, description, and safety.",async applicable(e){try{return(await xv(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 gd(e.skillPath);return{providerId:Cd,providerVersion:Ad,schemaVersion:Pd,score:s.overallScore,passed:s.grade!=="F",categories:Cv(s),findings:Ev(s),raw:s,startedAt:"",durationMs:0}}};var Td=fo(Tr(),1);import{readFile as Av,stat as Pv}from"fs/promises";import{basename as Nv}from"path";var Id="skill-best-practice",Rd="1.1.0",Ld=1,Iv=new Set(["name","description","license","allowed-tools","metadata","compatibility","effort"]),Od=new Set(["low","medium","high","xhigh","max"]),ao=250,Rv=/^\d+\.\d+\.\d+$/;function Lv(e){if(!e.startsWith("---"))return null;let t=e.split(`
|
|
234
234
|
`);if(t.length<3||t[0]?.trim()!=="---")return null;let s=t.findIndex((i,n)=>n>0&&i.trim()==="---");return s===-1?null:t.slice(1,s).join(`
|
|
235
|
-
`)}function
|
|
236
|
-
`)&&!f.includes("\r")&&!f.includes("<")&&!f.includes(">")&&f.length<=1024;W(s,"description-shape","Description follows skill-best-practice formatting rules",E,"error",E?"Description is single-line, angle-bracket free, and within 1024 characters.":"Description must be a single line, avoid angle brackets, and stay within 1024 characters.");let x=f.length<=
|
|
237
|
-
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function
|
|
238
|
-
---`,3);return s===-1?"":t.slice(s+4)}async function
|
|
239
|
-
`,"utf-8"),I(`ingester: wrote index to ${c}`),{success:!0,repoIndex:a}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await
|
|
235
|
+
`)}function Ii(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 Ri(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 Ov(e){let t=await Av(e.skillMdPath,"utf-8"),s=[],i=Lv(t);if(i===null){W(s,"missing-frontmatter","Frontmatter exists",!1,"error","SKILL.md must start with a YAML frontmatter block.");let E=Ri(e,s,null);return{score:0,passed:!1,findings:s.map(Ii),raw:E}}W(s,"frontmatter-present","Frontmatter exists",!0,"error","SKILL.md contains a YAML frontmatter block.");let n;try{n=(0,Td.parse)(i)}catch(E){W(s,"invalid-yaml","Frontmatter parses as YAML",!1,"error",`Invalid YAML in frontmatter: ${E?.message??String(E)}`);let x=Ri(e,s,null);return{score:0,passed:!1,findings:s.map(Ii),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=Ri(e,s,null);return{score:0,passed:!1,findings:s.map(Ii),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=>!Iv.has(E));W(s,"allowed-keys","Allowed top-level keys only",o.length===0,"error",o.length===0?"Frontmatter uses only the allowed top-level keys.":`Unexpected frontmatter key(s): ${o.sort().join(", ")}.`);let a=r.name,l=typeof a=="string"?a.trim():"";if(W(s,"name-present","Name is present and non-empty",l.length>0,"error",l.length>0?"Frontmatter includes a non-empty `name`.":"Frontmatter must include a non-empty string `name`."),l.length>0){let E=/^[a-z0-9-]+$/.test(l)&&!l.startsWith("-")&&!l.endsWith("-")&&!l.includes("--")&&l.length<=64;W(s,"name-kebab-case","Name follows skill-best-practice naming rules",E,"error",E?"Name follows the skill-best-practice kebab-case naming rules.":"Name must be kebab-case, avoid consecutive/edge hyphens, and stay within 64 characters.")}let c=r.description,f=typeof c=="string"?c.trim():"";if(W(s,"description-present","Description is present and non-empty",f.length>0,"error",f.length>0?"Frontmatter includes a non-empty `description`.":"Frontmatter must include a non-empty string `description`."),f.length>0){let E=!f.includes(`
|
|
236
|
+
`)&&!f.includes("\r")&&!f.includes("<")&&!f.includes(">")&&f.length<=1024;W(s,"description-shape","Description follows skill-best-practice formatting rules",E,"error",E?"Description is single-line, angle-bracket free, and within 1024 characters.":"Description must be a single line, avoid angle brackets, and stay within 1024 characters.");let x=f.length<=ao;W(s,"description-runtime-budget","Description fits the runtime context budget",x,"warning",x?`Description is ${f.length} chars (target \u2264 ${ao}).`:`Description is ${f.length} chars; target \u2264 ${ao}. 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"&&Od.has(d.trim()),"error",d===void 0||typeof d=="string"&&Od.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=Rv.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=Nv(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=Ri(e,s,r),v=S.checkCount===0?100:Math.round(S.passedChecks/S.checkCount*100),C=s.filter(E=>!E.passed).map(Ii);return{score:v,passed:C.every(E=>E.severity!=="error"),findings:C,raw:S}}var Md={id:Id,version:Rd,schemaVersion:Ld,description:"Deterministic SKILL.md best-practice validation (rules aligned with the skill-creator standard, v1.7.1).",async applicable(e){try{return(await Pv(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 Ov(e);return{providerId:Id,providerVersion:Rd,schemaVersion:Ld,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 Dd(){oo(Nd),oo(Md)}var Fd=!1;function Li(){Fd||(Dd(),Fd=!0)}function Oi(){return Li(),Ni()}function _d(e){if(e instanceof Error)return e.message;if(typeof e=="string")return e;try{return JSON.stringify(e)}catch{return String(e)}}function jd(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 Ti(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: ${_d(p)}`;return jd(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 jd(r,i,f,_d(c),"provider-threw")}finally{a&&clearTimeout(a)}}function Tv(e){return e>=90?"A":e>=80?"B":e>=65?"C":e>=50?"D":"F"}function qd(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 Bd(e,t){return{providerId:e.providerId,providerVersion:e.providerVersion,schemaVersion:e.schemaVersion,passed:e.passed,overallScore:e.score,grade:Tv(e.score),categories:e.categories.map(s=>({id:s.id,name:s.name,score:s.score,max:s.max})),evaluatedAt:e.startedAt,evaluatedVersion:t}}function is(e){return[...e].sort((t,s)=>t.id==="quality"&&s.id!=="quality"?-1:s.id==="quality"&&t.id!=="quality"?1:t.id.localeCompare(s.id))}var ee={SKILL_NOT_FOUND:"SKILL_NOT_FOUND",AUDIT_FAILED:"AUDIT_FAILED",INSTALL_FAILED:"INSTALL_FAILED",PUBLISH_FAILED:"PUBLISH_FAILED",NETWORK_ERROR:"NETWORK_ERROR",INVALID_ARGUMENT:"INVALID_ARGUMENT",UNKNOWN_ERROR:"UNKNOWN_ERROR"};function Ye(){let e=console.log,t=console.info,s=(...i)=>process.stderr.write(i.map(String).join(" ")+`
|
|
237
|
+
`);return console.log=s,console.info=s,()=>{console.log=e,console.info=t}}function Ud(e){return{timestamp:new Date().toISOString(),asm_version:jo,duration_ms:Math.round(performance.now()-e)}}function Q(e,t,s){let i={version:1,command:e,status:"ok",data:t,meta:Ud(s)},n=process.stdout.isTTY?2:0;return JSON.stringify(i,null,n)}function te(e,t,s,i,n){let r={version:1,command:e,status:"error",error:{code:t,message:s,...n!==void 0?{details:n}:{}},meta:Ud(i)},o=process.stdout.isTTY?2:0;return JSON.stringify(r,null,o)}import{writeFile as Fv,mkdir as _v,unlink as jv,readFile as qv,readdir as Bv}from"fs/promises";import{join as ns}from"path";function lo(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 Kd(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=lo(o[0].relPath);for(let f=1;f<o.length;f++){let d=lo(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:lo(f.relPath).root})),reason:l.priority===4?"first occurrence (no priority match)":`${l.root} priority`})}return{kept:s,decisions:i}}var Mv=[{label:"obfuscation:atob",pattern:/\batob\s*\(/},{label:"obfuscation:base64",pattern:/(?:^|[=:\s])[A-Za-z0-9+/]{40,}={1,2}(?:\s|$)/m},{label:"obfuscation:hex-escape",pattern:/\\x[0-9a-fA-F]{2}(?:\\x[0-9a-fA-F]{2}){3,}/},{label:"credential-leak:api-key",pattern:/\bAPI_KEY\s*=\s*['"][^'"]+['"]/},{label:"credential-leak:secret",pattern:/\bSECRET_KEY\s*=\s*['"][^'"]+['"]/},{label:"credential-leak:password",pattern:/\bPASSWORD\s*=\s*['"][^'"]+['"]/}];function Vd(e,t){let s=[];(!e.name||!e.name.trim())&&s.push("missing frontmatter field: name"),(!e.description||!e.description.trim())&&s.push("missing frontmatter field: description"),Dv(t).trim().length<20&&s.push("SKILL.md body too short (less than 20 chars of instructions)");for(let{label:n,pattern:r}of Mv)r.test(t)&&s.push(`malicious pattern detected: ${n}`);return{verified:s.length===0,reasons:s}}function Dv(e){let t=e.trimStart();if(!t.startsWith("---"))return t;let s=t.indexOf(`
|
|
238
|
+
---`,3);return s===-1?"":t.slice(s+4)}async function Uv(){let e=yt();return await _v(e,{recursive:!0}),e}function Kv(e,t){return`github:${e.owner}/${e.repo}${e.ref?`#${e.ref}`:""}${t?`:${t}`:""}`}async function Jd(e){await De();let t;try{t=Te(e)}catch(i){return{success:!1,repoIndex:null,error:i.message}}if(t.isLocal)return{success:!1,repoIndex:null,error:"Local paths are not supported for indexing. Use a GitHub source instead."};I(`ingester: cloning ${t.owner}/${t.repo}`);let s=null;try{s=await Fe(t),I(`ingester: discovering skills in ${s}`);let i=await ys(s);I(`ingester: found ${i.length} skills`);let{kept:n,decisions:r}=Kd(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=ns(s,f.relPath,"SKILL.md"),p="";try{p=await qv(d,"utf-8")}catch{I(`ingester: could not read SKILL.md at ${d}`)}let m=Vd(f,p);m.verified||I(`ingester: ${f.name} not verified: ${m.reasons.join(", ")}`);let y=typeof f.tokenCount=="number"?f.tokenCount:p?bt(p):void 0,h,g;if(p){let b;try{b=await Bv(ns(s,f.relPath))}catch{b=void 0}try{let w=ss({content:p,skillPath:f.relPath||f.name,skillMdPath:d,rootEntries:b});h={overallScore:w.overallScore,grade:w.grade,categories:w.categories.map(k=>({id:k.id,name:k.name,score:k.score,max:k.max})),evaluatedAt:w.evaluatedAt,evaluatedVersion:f.version||void 0}}catch(w){I(`ingester: eval failed for ${f.name}: ${w}`)}try{let w={skillPath:ns(s,f.relPath),skillMdPath:d},S=(await Promise.all(is(Oi()).map(async v=>(await v.applicable(w,{})).ok?Ti(v,w):null))).filter(v=>v!==null).map(v=>Bd(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:Kv(t,f.relPath),relPath:f.relPath,verified:m.verified,tokenCount:y,evalSummary:h,evalSummaries:g})}let a={repoUrl:t.cloneUrl,owner:t.owner,repo:t.repo,updatedAt:new Date().toISOString(),skillCount:o.length,skills:o};a.bundles=bi([...await Iu(s,a),...Kr(a)]);let l=await Uv(),c=ns(l,`${t.owner}_${t.repo}.json`);return await Fv(c,JSON.stringify(a,null,2)+`
|
|
239
|
+
`,"utf-8"),I(`ingester: wrote index to ${c}`),{success:!0,repoIndex:a}}catch(i){return{success:!1,repoIndex:null,error:i.message}}finally{s&&await le(s)}}async function Hd(){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 Wd(e,t){let s=yt(),i=ns(s,`${e}_${t}.json`);try{return await jv(i),!0}catch{return!1}}import{join as co,resolve as Gd}from"path";function Wv(e){switch(e){case"dangerous":return 3;case"warning":return 2;case"caution":return 1;default:return 0}}function uo(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+Wv(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],o=r==="local"?"project":r;o==="global"||o==="project"||o==="both"?s.flags.scope=o:($(`Invalid scope: "${r}". Must be global, local, project, or both.`),process.exit(2))}else if(n==="--sort"){i++;let r=t[i];r==="name"||r==="version"||r==="location"?s.flags.sort=r:($(`Invalid sort: "${r}". Must be name, version, or location.`),process.exit(2))}else if(n==="--provider"||n==="-p"||n==="--tool")i++,s.flags.provider=t[i]||null;else if(n==="--name")i++,s.flags.name=t[i]||null;else if(n==="--force"||n==="-f")s.flags.force=!0;else if(n==="--path")i++,s.flags.path=t[i]||null;else if(n==="--all")s.flags.all=!0;else if(n==="--verbose"||n==="-V")s.flags.verbose=!0;else if(n==="--flat")s.flags.flat=!0;else if(n==="--compact")s.flags.compact=!0;else if(n==="--summary")s.flags.summary=!0;else if(n==="--group-by"){i++;let r=t[i];r==="tool"||r==="scope"||r==="effort"?s.flags.groupBy=r:($(`Invalid --group-by: "${r}". Must be tool, scope, or effort.`),process.exit(2))}else if(n==="--limit"){i++;let r=t[i],o=Number(r);(!Number.isFinite(o)||o<0||!Number.isInteger(o))&&($(`Invalid --limit: "${r}". Must be a non-negative integer (0 means no limit).`),process.exit(2)),s.flags.limit=o}else if(n==="--installed")s.flags.installed=!0;else if(n==="--available")s.flags.available=!0;else if(n==="--concurrency"){i++;let r=t[i],o=Number(r);(!Number.isFinite(o)||o<1||!Number.isInteger(o))&&($(`Invalid --concurrency: "${r}". Must be a positive integer.`),process.exit(2)),s.flags.concurrency=o}else if(n==="--keep")s.flags.keep=!0;else if(n==="--transport"||n==="-t"){i++;let r=t[i];r==="https"||r==="ssh"||r==="auto"?s.flags.transport=r:($(`Invalid transport: "${r}". Must be https, ssh, or auto.`),process.exit(2))}else if(n==="--method"||n==="-m"){i++;let r=t[i];r==="default"||r==="vercel"?s.flags.method=r:($(`Invalid method: "${r}". Must be default or vercel.`),process.exit(2))}else n==="--skill"?(i++,s.flags.path=t[i]||null):n==="--dry-run"?s.flags.dryRun=!0:n==="--fix"?s.flags.fix=!0:n==="--machine"?s.flags.machine=!0:n==="--no-cache"?s.flags.noCache=!0:n==="--has"?(i++,t[i]&&s.flags.has.push(t[i])):n==="--missing"?(i++,t[i]&&s.flags.missing.push(t[i])):n==="--add"?(i++,s.flags.add=t[i]||null):n==="--remove"?(i++,s.flags.remove=t[i]||null):n==="--description"?(i++,s.flags.description=t[i]||null):n==="--author"?(i++,s.flags.author=t[i]||null):n==="--tags"?(i++,s.flags.tags=t[i]||null):n==="--predefined"?s.flags.predefined=!0:n.startsWith("-")?($(`Unknown option: ${n}`),console.error('Run "asm --help" for usage.'),process.exit(2)):s.command?s.subcommand?s.positional.push(n):s.subcommand=n:s.command=n;i++}return s}function $(e){console.error(u.red(`Error: ${e}`))}function Yv(){console.log(`${u.blueBold("agent-skill-manager")} (${u.bold("asm")}) ${Vi}
|
|
240
240
|
|
|
241
241
|
Interactive TUI and CLI for managing installed skills for AI coding agents.
|
|
242
242
|
|
|
@@ -283,11 +283,11 @@ ${u.bold("Global Options:")}
|
|
|
283
283
|
--sort <field> Sort by: name, version, or location (default: name)
|
|
284
284
|
--flat Show one row per tool instance (list, search)
|
|
285
285
|
-y, --yes Skip confirmation prompts
|
|
286
|
-
-V, --verbose Show debug output`)}function
|
|
286
|
+
-V, --verbose Show debug output`)}function zv(){console.log(`${u.bold("Usage:")} asm list [options]
|
|
287
287
|
|
|
288
288
|
List all discovered skills. By default, skills installed across multiple
|
|
289
289
|
tools are grouped into a single row with tool badges. When more than
|
|
290
|
-
${
|
|
290
|
+
${Bi} skills are present, a compact summary is
|
|
291
291
|
automatically prepended above the table.
|
|
292
292
|
|
|
293
293
|
${u.bold("Options:")}
|
|
@@ -317,7 +317,7 @@ ${u.bold("Examples:")}
|
|
|
317
317
|
asm list -s project ${u.dim("Only project-scoped skills")}
|
|
318
318
|
asm list --sort version ${u.dim("Sort by version")}
|
|
319
319
|
asm list --json ${u.dim("Output as JSON")}
|
|
320
|
-
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
320
|
+
asm list --machine ${u.dim("Machine-readable v1 envelope output")}`)}function Qv(){console.log(`${u.bold("Usage:")} asm search <query> [options]
|
|
321
321
|
|
|
322
322
|
Search both installed skills and the skill index. Results show installation
|
|
323
323
|
status and include copy-paste install commands for available skills.
|
|
@@ -340,7 +340,7 @@ ${u.bold("Examples:")}
|
|
|
340
340
|
asm search "test" --installed ${u.dim("Search installed skills only")}
|
|
341
341
|
asm search "test" --available ${u.dim("Search available skills only")}
|
|
342
342
|
asm search openspec --json ${u.dim("Output matches as JSON")}
|
|
343
|
-
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
343
|
+
asm search openspec --machine ${u.dim("Machine-readable v1 envelope output")}`)}function Xv(){console.log(`${u.bold("Usage:")} asm inspect <skill-name> [options]
|
|
344
344
|
|
|
345
345
|
Show detailed information for a skill. The <skill-name> is the directory name.
|
|
346
346
|
Shows version, description, file count, and all provider installations.
|
|
@@ -354,7 +354,7 @@ ${u.bold("Options:")}
|
|
|
354
354
|
${u.bold("Examples:")}
|
|
355
355
|
asm inspect code-review ${u.dim("Show details for code-review")}
|
|
356
356
|
asm inspect code-review --json ${u.dim("Output as JSON")}
|
|
357
|
-
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function
|
|
357
|
+
asm inspect code-review -s global ${u.dim("Global installations only")}`)}function Zv(){console.log(`${u.bold("Usage:")} asm uninstall <skill-name> [options]
|
|
358
358
|
|
|
359
359
|
Remove a skill and its associated rule files. Shows a removal plan
|
|
360
360
|
before proceeding and asks for confirmation.
|
|
@@ -370,7 +370,7 @@ ${u.bold("Examples:")}
|
|
|
370
370
|
asm uninstall code-review ${u.dim("Remove with confirmation")}
|
|
371
371
|
asm uninstall code-review -y ${u.dim("Remove without confirmation")}
|
|
372
372
|
asm uninstall code-review -s project ${u.dim("Remove project copy only")}
|
|
373
|
-
asm uninstall code-review -p claude ${u.dim("Remove from Claude only")}`)}function
|
|
373
|
+
asm uninstall code-review -p claude ${u.dim("Remove from Claude only")}`)}function ek(){console.log(`${u.bold("Usage:")} asm audit [subcommand] [options]
|
|
374
374
|
|
|
375
375
|
Detect duplicate skills or run security audits on installed/remote skills.
|
|
376
376
|
|
|
@@ -396,7 +396,7 @@ ${u.bold("Examples:")}
|
|
|
396
396
|
asm audit security code-review --json ${u.dim("Output audit as JSON")}
|
|
397
397
|
asm audit security code-review --machine ${u.dim("Machine-readable v1 envelope output")}
|
|
398
398
|
asm audit security https://github.com/user/skills/tree/main/skills/agent-config
|
|
399
|
-
${u.dim("Audit a skill from a subfolder URL")}`)}function
|
|
399
|
+
${u.dim("Audit a skill from a subfolder URL")}`)}function tk(){console.log(`${u.bold("Usage:")} asm publish [path] [options]
|
|
400
400
|
|
|
401
401
|
Validate a skill, run a security audit, generate a registry manifest,
|
|
402
402
|
and open a PR against the asm-registry.
|
|
@@ -419,7 +419,7 @@ ${u.bold("Examples:")}
|
|
|
419
419
|
asm publish --dry-run ${u.dim("Preview manifest without side effects")}
|
|
420
420
|
asm publish --force ${u.dim("Override warning-level security findings")}
|
|
421
421
|
asm publish --json ${u.dim("Output as JSON")}
|
|
422
|
-
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function
|
|
422
|
+
asm publish --machine ${u.dim("Machine-readable v1 envelope output")}`)}function sk(){console.log(`${u.bold("Usage:")} asm outdated [options]
|
|
423
423
|
|
|
424
424
|
Show which installed skills have newer versions available.
|
|
425
425
|
|
|
@@ -432,7 +432,7 @@ ${u.bold("Options:")}
|
|
|
432
432
|
${u.bold("Examples:")}
|
|
433
433
|
asm outdated ${u.dim("Show outdated skills")}
|
|
434
434
|
asm outdated --json ${u.dim("Output as JSON")}
|
|
435
|
-
asm outdated --machine ${u.dim("Machine-readable output")}`)}function
|
|
435
|
+
asm outdated --machine ${u.dim("Machine-readable output")}`)}function ik(){console.log(`${u.bold("Usage:")} asm update [name...] [options]
|
|
436
436
|
|
|
437
437
|
Update outdated skills to their latest version with security re-audit.
|
|
438
438
|
|
|
@@ -450,7 +450,7 @@ ${u.bold("Examples:")}
|
|
|
450
450
|
asm update ${u.dim("Update all outdated skills")}
|
|
451
451
|
asm update code-review ${u.dim("Update a specific skill")}
|
|
452
452
|
asm update --yes ${u.dim("Skip confirmation prompts")}
|
|
453
|
-
asm update --json ${u.dim("Output as JSON")}`)}function
|
|
453
|
+
asm update --json ${u.dim("Output as JSON")}`)}function nk(){console.log(`${u.bold("Usage:")} asm config <subcommand>
|
|
454
454
|
|
|
455
455
|
Manage configuration. Config is stored at ~/.config/agent-skill-manager/.
|
|
456
456
|
|
|
@@ -466,13 +466,13 @@ ${u.bold("Options:")}
|
|
|
466
466
|
${u.bold("Examples:")}
|
|
467
467
|
asm config show ${u.dim("View current config")}
|
|
468
468
|
asm config edit ${u.dim("Edit in $EDITOR")}
|
|
469
|
-
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function
|
|
470
|
-
${u.yellow(`${c.length} skill${c.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(l)}else if(e.flags.summary)console.log(
|
|
471
|
-
`))}}async function
|
|
472
|
-
`)),e.flags.flat?console.log(
|
|
473
|
-
${u.bold("Proceed with removal?")} [y/N] `);let m=await G();m.toLowerCase()!=="y"&&m.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let f;try{f=await
|
|
469
|
+
asm config reset -y ${u.dim("Reset without confirmation")}`)}async function zd(e){for(let t of e)t.warnings=await Zc(t)}async function rk(e){if(e.flags.help){zv();return}let t=performance.now(),s=await B(),i=await Z(s,e.flags.scope),n=await cs(),r=new Set(i.map(l=>`${l.dirName}||${l.provider}||${l.scope}`)),o=await Qd(s,n,e.flags.scope,e.flags.provider,r);i=[...i,...o],e.flags.provider&&e.command==="list"&&(i=i.filter(l=>l.provider===e.flags.provider)),await zd(i);let a=_i(i,e.flags.sort);if(e.flags.machine){let l=a.map(c=>({name:c.name,version:c.version,description:c.description,scope:c.scope,provider:c.provider,path:c.path}));console.log(Q("list",l,t));return}if(e.flags.json)console.log(Y(a));else if(e.flags.flat){let l=qi(a),c=a.filter(f=>f.warnings&&f.warnings.length>0);c.length>0&&(l+=`
|
|
470
|
+
${u.yellow(`${c.length} skill${c.length===1?"":"s"} with warnings -- use --json for details`)}`),console.log(l)}else if(e.flags.summary)console.log(Ui(a));else if(e.flags.groupBy){let{skills:l,hint:c}=as(a,e.flags.limit);console.log(Ao(l,e.flags.groupBy)),c&&console.log(c)}else if(e.flags.compact){let{skills:l,hint:c}=as(a,e.flags.limit);console.log(Co(l)),c&&console.log(c)}else{let l=[];a.length>Bi&&(l.push(Ui(a,{showHint:!1})),l.push(""));let{skills:c,hint:f}=as(a,e.flags.limit);l.push(Po(c)),f&&l.push(f),console.log(l.join(`
|
|
471
|
+
`))}}async function ok(e){if(e.flags.help){Qv();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;i||(e.flags.machine&&(t?.(),console.log(te("search",ee.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 Z(f,e.flags.scope);e.flags.provider&&(d=d.filter(m=>m.provider===e.flags.provider));let p=bo(d,i);o=_i(p,e.flags.sort)}let a=[];if(r&&(a=await yi(i),o.length>0)){let f=new Set(o.map(d=>d.name.toLowerCase()));a=a.filter(d=>!f.has(d.skill.name.toLowerCase()))}if(e.flags.machine){t?.();let f=o.map(p=>({name:p.name,description:p.description,source:"installed",url:null,match_count:1})),d=a.map(p=>({name:p.skill.name,description:p.skill.description,source:"index",url:p.skill.installUrl,match_count:1}));console.log(Q("search",[...f,...d],s));return}if(e.flags.json){let f=o.map(p=>({name:p.name,description:p.description,version:p.version,scope:p.scope,provider:p.provider,status:"installed"})),d=a.map(p=>({name:p.skill.name,description:p.skill.description,version:p.skill.version,repo:`${p.repo.owner}/${p.repo.repo}`,installCommand:`asm install ${p.skill.installUrl}`,status:"available"}));console.log(Y([...f,...d]));return}let l=o.length>0,c=a.length>0;if(!l&&!c){console.error(`No skills matching "${i}".`),console.error(u.dim("Try ingesting more repos with: asm index ingest <repo>"));return}if(l&&(console.error(u.bold(`Installed skills matching "${i}":
|
|
472
|
+
`)),e.flags.flat?console.log(qi(o)):console.log(No(o,i))),c){l&&console.error("");let f=Io(a.map(d=>({name:d.skill.name,version:d.skill.version,description:d.skill.description,verified:d.skill.verified,repoLabel:`${d.repo.owner}/${d.repo.repo}`,installUrl:d.skill.installUrl})),i);console.error(f)}}async function ak(e){if(e.flags.help){Xv();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 Z(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 zd(n),e.flags.json?console.log(Y(n.length===1?n[0]:n)):console.log(await Ro(n))}async function lk(e){if(e.flags.help){Zv();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 Z(s,e.flags.scope),n={};e.flags.provider&&(n.providerFilter=e.flags.provider),e.flags.scope&&e.flags.scope!=="both"&&(n.scopeFilter=e.flags.scope);let r=vo(t,i,s,n),o=await So(r);o.length===0&&($(`Skill "${t}" not found or nothing to remove.`),process.exit(1));let a=i.filter(m=>m.dirName===t),l=n.providerFilter,c=null;l&&(c=ko(r,a,l)),console.error(u.bold("Removal plan:")),console.error(` ${u.dim("Scope:")} ${n.scopeFilter||"both"}`),l&&(console.error(` ${u.dim("Tool:")} ${l}`),c?.needed&&console.error(` ${u.yellow("\u26A0 Real folder relocation:")} ${c.fromPath} \u2192 ${c.toPath} (${c.toProvider})`)),console.error("");for(let m of o)console.error(` ${u.red("\u2022")} ${Eo(m)}`);if(!e.flags.yes){process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2)),process.stderr.write(`
|
|
473
|
+
${u.bold("Proceed with removal?")} [y/N] `);let m=await G();m.toLowerCase()!=="y"&&m.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let f;try{f=await ji(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=>Gd(m.path))),p=a.filter(m=>!d.has(Gd(m.originalPath)));try{l&&p.length>0?c?.needed&&!c.repointOnly&&await To(t,c.toProvider):await Oo(t)}catch{}console.error(u.green(`
|
|
474
474
|
Done.`))}function G(){return new Promise(e=>{let t="",s=!1;function i(){process.stdin.removeListener("data",r),process.stdin.removeListener("end",o),process.stdin.pause(),clearTimeout(a)}function n(l){s||(s=!0,i(),e(l))}function r(l){t+=l,t.includes(`
|
|
475
|
-
`)&&n(t.trim())}function o(){n(t.trim())}let a=setTimeout(()=>{n(t.trim())},3e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",r),process.stdin.on("end",o),process.stdin.resume()})}function
|
|
475
|
+
`)&&n(t.trim())}function o(){n(t.trim())}let a=setTimeout(()=>{n(t.trim())},3e4);process.stdin.setEncoding("utf-8"),process.stdin.on("data",r),process.stdin.on("end",o),process.stdin.resume()})}function ck(){console.log(`${u.bold("Usage:")} asm disable <target> [options]
|
|
476
476
|
asm disable --all [options]
|
|
477
477
|
|
|
478
478
|
Disable skills without uninstalling them. Disabling renames a skill's
|
|
@@ -505,7 +505,7 @@ ${u.bold("Examples:")}
|
|
|
505
505
|
asm disable openspec: ${u.dim("# prefix (colon)")}
|
|
506
506
|
asm disable asc- ${u.dim("# prefix (hyphen)")}
|
|
507
507
|
asm disable --all ${u.dim("# everything")}
|
|
508
|
-
asm disable code-review --tool claude --scope local`)}function
|
|
508
|
+
asm disable code-review --tool claude --scope local`)}function uk(){console.log(`${u.bold("Usage:")} asm enable <target> [options]
|
|
509
509
|
asm enable --all [options]
|
|
510
510
|
|
|
511
511
|
Re-enable skills previously disabled with ${u.bold("asm disable")}. Enabling renames
|
|
@@ -533,15 +533,15 @@ ${u.bold("Examples:")}
|
|
|
533
533
|
asm enable code-review
|
|
534
534
|
asm enable '*-review'
|
|
535
535
|
asm enable openspec:
|
|
536
|
-
asm enable --all`)}async function
|
|
537
|
-
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let c=await cs(),f=[];try{for(let d of a){await Go(d.representative.path);for(let p of d.siblings)
|
|
538
|
-
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let f=[];try{for(let d of l){await Yo(d.representative.path);for(let p of d.siblings)Jo(n,p.dirName,p.provider,p.scope),f.push({name:p.name,provider:p.provider,scope:p.scope,action:"enabled"}),!e.flags.json&&!e.flags.machine&&console.log(`${u.green("\u2713")} enabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await
|
|
539
|
-
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a=Do(o.instances),l=a[0].path;for(let c=1;c<a.length;c++){let f=a[c],d=wo(f,i),p=await
|
|
540
|
-
Done.`))}}async function
|
|
541
|
-
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function
|
|
542
|
-
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await
|
|
543
|
-
Summary:`)),a.dangerous>0&&console.log(` ${u.red(`${a.dangerous} dangerous`)}`),a.warning>0&&console.log(` ${u.yellow(`${a.warning} warning`)}`),a.caution>0&&console.log(` ${a.caution} caution`),a.safe>0&&console.log(` ${u.green(`${a.safe} safe`)}`),console.log("")}}async function
|
|
544
|
-
`);let a=await
|
|
536
|
+
asm enable --all`)}async function Qd(e,t,s,i,n){let r=new Map(e.providers.map(a=>[a.name,a])),o=[];for(let[a,l]of Object.entries(t.disabled))for(let[c,f]of Object.entries(l)){if(i&&c!==i)continue;let d=r.get(c);if(d)for(let p of["global","project"]){if(!f[p]||s==="global"&&p!=="global"||s==="project"&&p!=="project"||n?.has(`${a}||${c}||${p}`))continue;let m=p==="global"?d.global:d.project;if(!m)continue;let y=oe(m),h=co(y,a),g=us(h);if(!Hv(g))continue;let b={};try{b=X(await Vv(g,"utf-8"))}catch{}let w=h;try{w=await Jv(h)}catch{}o.push({name:b.name||a,version:b["metadata.version"]||b.version||"0.0.0",description:(b.description||"").replace(/\s*\n\s*/g," ").trim(),creator:b["metadata.creator"]||"",license:(b.license||"").trim(),compatibility:(b.compatibility||"").trim(),allowedTools:[],dirName:a,path:h,originalPath:h,location:`${p}-${c}`,scope:p,provider:c,providerLabel:d.label,isSymlink:!1,symlinkTarget:null,realPath:w,disabled:!0})}}return o}function Xd(e,t){if(e.flags.json)console.log(JSON.stringify(t,null,2));else if(e.flags.machine)for(let s of t)console.log([s.name,s.provider,s.scope,s.action].join(" "))}function Zd(e,t){let s=new Map;for(let n of t){let r=s.get(n.realPath)??[];r.push(n),s.set(n.realPath,r)}let i=new Map;for(let n of e)i.has(n.realPath)||i.set(n.realPath,{realPath:n.realPath,representative:n,siblings:s.get(n.realPath)??[n]});return[...i.values()]}async function dk(e){if(e.flags.help){ck();return}let t=e.subcommand;if(!t&&!e.flags.all){$("Missing target. Provide a skill name/pattern or use --all."),process.exitCode=2;return}if(t&&e.flags.all){$("Provide either a target or --all, not both."),process.exitCode=2;return}let s=await B(),i=e.flags.provider,n=(await Z(s,e.flags.scope)).filter(d=>d.provider!=="plugin"&&d.provider!=="codex-plugin"),r=i?n.filter(d=>d.provider===i):n,o=e.flags.all?r:Hi(r,t);if(o.length===0){let d=t?` for '${t}'`:"";console.log(u.dim(`No matching active skills${d}.`));return}let a=Zd(o,n),l=new Set(o.map(d=>`${d.realPath}||${d.provider}||${d.scope}`));if(!e.flags.json&&!e.flags.machine){let d=a.reduce((p,m)=>p+m.siblings.length,0);console.log(u.bold(`Will disable ${d} skill instance(s):`));for(let p of a){for(let m of p.siblings){let y=l.has(`${m.realPath}||${m.provider}||${m.scope}`)?"":u.yellow(" (shared via symlink)");console.log(` ${u.dim("\u2022")} ${m.name} (${m.provider}, ${m.scope})${y}`)}p.siblings.length>1&&console.log(u.yellow(` \u26A0 ${p.representative.name} shares one SKILL.md across ${p.siblings.length} tools \u2014 disabling affects all of them.`))}if(!e.flags.yes&&process.stdin.isTTY){process.stdout.write(`
|
|
537
|
+
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let c=await cs(),f=[];try{for(let d of a){await Go(d.representative.path);for(let p of d.siblings)Vo(c,p.dirName,p.provider,p.scope),f.push({name:p.name,provider:p.provider,scope:p.scope,action:"disabled"}),!e.flags.json&&!e.flags.machine&&console.log(`${u.green("\u2713")} disabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await Ji(c)}Xd(e,f)}async function fk(e){if(e.flags.help){uk();return}let t=e.subcommand;if(!t&&!e.flags.all){$("Missing target. Provide a skill name/pattern or use --all."),process.exitCode=2;return}if(t&&e.flags.all){$("Provide either a target or --all, not both."),process.exitCode=2;return}let s=await B(),i=e.flags.provider,n=await cs(),r=await Qd(s,n,e.flags.scope),o=i?r.filter(d=>d.provider===i):r,a=e.flags.all?o:Hi(o,t);if(a.length===0){let d=t?` for '${t}'`:"";console.log(u.dim(`No matching disabled skills${d}.`));return}let l=Zd(a,r),c=new Set(a.map(d=>`${d.realPath}||${d.provider}||${d.scope}`));if(!e.flags.json&&!e.flags.machine){let d=l.reduce((p,m)=>p+m.siblings.length,0);console.log(u.bold(`Will enable ${d} skill instance(s):`));for(let p of l){for(let m of p.siblings){let y=c.has(`${m.realPath}||${m.provider}||${m.scope}`)?"":u.yellow(" (shared via symlink)");console.log(` ${u.dim("\u2022")} ${m.name} (${m.provider}, ${m.scope})${y}`)}p.siblings.length>1&&console.log(u.yellow(` \u26A0 ${p.representative.name} shares one SKILL.md across ${p.siblings.length} tools \u2014 enabling affects all of them.`))}if(!e.flags.yes&&process.stdin.isTTY){process.stdout.write(`
|
|
538
|
+
${u.bold("Proceed?")} [y/N] `);let p=await G();if(p.toLowerCase()!=="y"&&p.toLowerCase()!=="yes"){console.log("Aborted.");return}}}let f=[];try{for(let d of l){await Yo(d.representative.path);for(let p of d.siblings)Jo(n,p.dirName,p.provider,p.scope),f.push({name:p.name,provider:p.provider,scope:p.scope,action:"enabled"}),!e.flags.json&&!e.flags.machine&&console.log(`${u.green("\u2713")} enabled ${p.name} (${p.provider}, ${p.scope})`)}}finally{await Ji(n)}Xd(e,f)}async function pk(e){if(e.flags.help){ek();return}let t=performance.now(),s=e.subcommand??"duplicates";if(s==="security"){await mk(e,t);return}s!=="duplicates"&&($(`Unknown audit subcommand: "${s}". Use: duplicates, security`),process.exit(2));let i=await B(),n=await Z(i,"both"),r=Ki(n);if(e.flags.machine){let o={duplicate_groups:r.duplicateGroups.map(a=>({name:a.key,count:a.instances.length,instances:a.instances.map(l=>({path:l.path,scope:l.scope,provider:l.provider}))})),total_duplicates:r.duplicateGroups.length};console.log(Q("audit duplicates",o,t));return}if(e.flags.json){console.log(_o(r));return}if(console.log(Fo(r)),e.flags.yes&&r.duplicateGroups.length>0){console.error(u.bold(`
|
|
539
|
+
Auto-removing duplicates...`));for(let o of r.duplicateGroups){let a=Do(o.instances),l=a[0].path;for(let c=1;c<a.length;c++){let f=a[c],d=wo(f,i),p=await ji(d,l);for(let m of p)console.error(m)}}console.error(u.green(`
|
|
540
|
+
Done.`))}}async function mk(e,t){let s=e.positional[0];e.flags.all?await hk(e,t):s?s.startsWith("github:")||s.startsWith("https://github.com/")?await gk(e,s,t):await yk(e,s,t):(e.flags.machine&&(console.log(te("audit security",ee.INVALID_ARGUMENT,"Missing target. Provide a skill name, GitHub source, or use --all.",t)),process.exit(2)),$(`Missing target. Provide a skill name, GitHub source, or use --all.
|
|
541
|
+
Usage: asm audit security <name|github:owner/repo> [--all]`),process.exit(2))}async function hk(e,t){let s=await B(),i=await Z(s,e.flags.scope);if(i.length===0){e.flags.machine?console.log(Q("audit security",[],t)):e.flags.json?console.log("[]"):console.log("No skills found to audit.");return}let n=new Set,r=i.filter(a=>n.has(a.realPath)?!1:(n.add(a.realPath),!0));console.error(`Auditing ${r.length} skill${r.length>1?"s":""}...
|
|
542
|
+
`);let o=[];for(let a of r){console.error(` Scanning ${u.bold(a.name)}...`);let l=await Le(a.realPath,a.name);o.push(l)}if(e.flags.machine)console.log(Q("audit security",uo(o),t));else if(e.flags.json)console.log(JSON.stringify(o,null,2));else{for(let l of o)console.log(ki(l));let a={safe:0,caution:0,warning:0,dangerous:0};for(let l of o)a[l.verdict]++;console.log(u.bold(`
|
|
543
|
+
Summary:`)),a.dangerous>0&&console.log(` ${u.red(`${a.dangerous} dangerous`)}`),a.warning>0&&console.log(` ${u.yellow(`${a.warning} warning`)}`),a.caution>0&&console.log(` ${a.caution} caution`),a.safe>0&&console.log(` ${u.green(`${a.safe} safe`)}`),console.log("")}}async function gk(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 gs(n),console.error(`Cloning ${t} for audit...`),i=await Fe(n,e.flags.transport);let{join:r}=await import("path"),o=n.subpath?r(i,n.subpath):i,{name:a}=await _e(o),l=await Le(o,a,n.owner,n.repo);e.flags.machine?console.log(Q("audit security",uo([l]),s)):e.flags.json?console.log(Hr(l)):console.log(ki(l))}catch(n){e.flags.machine&&(console.log(te("audit security",ee.AUDIT_FAILED,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}finally{i&&await le(i)}}async function yk(e,t,s){let i=await B(),r=(await Z(i,e.flags.scope)).filter(l=>l.dirName===t);r.length===0&&(e.flags.machine&&(console.log(te("audit security",ee.SKILL_NOT_FOUND,`Skill "${t}" not found.`,s)),process.exit(1)),$(`Skill "${t}" not found. Use "asm list" to see installed skills.`),process.exit(1));let o=r[0];console.error(`Auditing installed skill: ${u.bold(o.name)}...
|
|
544
|
+
`);let a=await Le(o.realPath,o.name);e.flags.machine?console.log(Q("audit security",uo([a]),s)):e.flags.json?console.log(Hr(a)):console.log(ki(a))}async function bk(e){if(e.flags.help){nk();return}let t=e.subcommand;switch(t||($("Missing subcommand. Use: show, path, reset, or edit."),console.error('Run "asm config --help" for usage.'),process.exit(2)),t){case"show":{let s=await B();console.log(Y(s));break}case"path":{console.log(gt());break}case"reset":{if(!e.flags.yes){process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2)),process.stderr.write(`${u.bold("Reset config to defaults?")} [y/N] `);let i=await G();i.toLowerCase()!=="y"&&i.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let s=mo();await yo(s),console.error(u.green("Config reset to defaults."));break}case"edit":{let s=process.env.VISUAL||process.env.EDITOR||"vi",[i,n]=qo(s),r=gt();await B();let{spawn:o}=await import("child_process");await new Promise((a,l)=>{let c=o(i,[...n,r],{stdio:"inherit"});c.on("close",()=>a()),c.on("error",l)});break}default:$(`Unknown config subcommand: "${t}". Use: show, path, reset, or edit.`),process.exit(2)}}function wk(){console.log(`${u.bold("Usage:")} asm install <source> [options]
|
|
545
545
|
|
|
546
546
|
Install a skill from a GitHub repository, the curated registry, or a local path.
|
|
547
547
|
|
|
@@ -613,27 +613,27 @@ ${u.bold("Subfolder URL:")}
|
|
|
613
613
|
${u.bold("Vercel skills CLI:")}
|
|
614
614
|
asm install github:user/skills --method vercel --skill my-skill
|
|
615
615
|
asm install https://github.com/user/skills -m vercel --skill my-skill -y
|
|
616
|
-
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function
|
|
616
|
+
${u.dim("Delegates to npx skills add for Vercel tracking, then registers in asm")}`)}async function vk(e,t,s,i,n,r,o,a,l="global"){let c=await _e(i),f=await na(i),d=i===s?null:i.split(/[/\\]/).pop(),p=n||d||t.repo,m=Me(p),y=a.find(C=>C.name.toLowerCase()===c.name.toLowerCase()&&C.provider===o.name),h,g=!!y;y?y.version===c.version?h=e.flags.force?"REINSTALL":`UPDATE: ${y.version} (same version)`:h=`UPDATE: ${y.version} \u2192 ${c.version}`:h="NEW";let b=Xi(t,s,i,m,o,e.flags.force||g,l),w=f.some(C=>["Shell commands","Code execution","Credentials"].includes(C.category)),k=f.some(C=>["External URLs"].includes(C.category)),S=w?"high":k?"medium":"safe",v=w?u.red("[!] High Risk"):k?u.yellow("[~] Medium Risk"):u.green("[ok] Safe");return{metadata:c,skillName:m,warnings:f,installStatus:h,riskLevel:S,riskLabel:v,plan:b}}function kk(e,t,s,i,n,r){let{metadata:o,warnings:a,installStatus:l,riskLabel:c,plan:f}=e;if(n&&r){let d=u.dim(`[${r.index}/${r.total}]`),p=l==="NEW"?u.green(`[${l}]`):u.yellow(`[${l}]`);console.info(`${d} ${u.bold(o.name)} v${o.version} ${p} ${c}`)}else{let d=l==="NEW"?u.green(`[${l}]`):u.yellow(`[${l}]`);if(console.info(` ${u.bold(o.name)} v${o.version} ${d}`),console.info(`
|
|
617
617
|
${u.bold("Install preview:")}`),console.info(` ${u.bold("Name:")} ${o.name}`),console.info(` ${u.bold("Version:")} ${o.version}`),o.description&&console.info(` ${u.bold("Description:")} ${u.dim(o.description)}`),o.effort&&console.info(` ${u.bold("Effort:")} ${$o(o.effort)}`),console.info(` ${u.bold("Source:")} ${t}`),i?(console.info(` ${u.bold("Tool:")} All (${i.map(p=>p.label).join(", ")})`),console.info(` ${u.bold("Primary:")} ${s.label} (${s.name})`),console.info(` ${u.bold("Symlinks:")} ${i.filter(p=>p.name!==s.name).map(p=>p.label).join(", ")}`)):console.info(` ${u.bold("Tool:")} ${s.label} (${s.name})`),console.info(` ${u.bold("Scope:")} ${f.scope==="project"?"Project":"Global"}`),console.info(` ${u.bold("Target:")} ${f.targetDir}`),console.info(` ${u.bold("Status:")} ${d}`),console.info(` ${u.bold("Risk:")} ${c}`),a.length>0){console.info(`
|
|
618
618
|
${u.bold("Security warnings:")}`);let p=new Map;for(let m of a){let y=p.get(m.category)||[];y.push(m),p.set(m.category,y)}for(let[m,y]of p){let g=["Shell commands","Code execution","Credentials"].includes(m)?u.red(`[${m}]`):u.yellow(`[${m}]`);console.info(`
|
|
619
|
-
${g} ${u.dim(`(${y.length} match${y.length>1?"es":""})`)}`);for(let b of y.slice(0,5))console.info(` ${u.dim(`${b.file}:${b.line}`)} -- ${b.match}`);y.length>5&&console.info(u.dim(` ... and ${y.length-5} more`))}}}}async function
|
|
620
|
-
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(f)}`),c=()=>{n?
|
|
621
|
-
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:A,multipleMatches:N,suggestions:_}=await
|
|
622
|
-
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let L=N.slice(0,5);for(let re=0;re<L.length;re++){let
|
|
623
|
-
Select a skill [1-${L.length}]: `;process.stderr.write(F);let ne=await new Promise(re=>{let
|
|
624
|
-
Did you mean: ${_.map(L=>u.cyan(L)).join(", ")}?`),process.exit(1)):(console.info(` ${u.dim("Not found in registry \u2014 trying existing sources...")}`),r="pre-indexed")}console.info(l("Parsing source"));let f=Te(i),d=!!f.isLocal;if(d){let A=f.localPath;console.info(` ${u.dim(`local: ${A}`)}`);let{stat:N}=await import("fs/promises");try{if(!(await N(A)).isDirectory())throw new Error(`Path is not a directory: ${A}`)}catch(_){throw _.code==="ENOENT"?new Error(`Path does not exist: ${A}`):_}}else await De(),f=await
|
|
625
|
-
`);for(let F=0;F<N.length;F++){let ne=u.cyan(` ${String(F+1).padStart(String(N.length).length)})`);console.info(`${ne} ${u.bold(N[F].name)} ${u.dim(`v${N[F].version}`)} ${u.dim(`(${N[F].relPath})`)}`),N[F].description&&console.info(` ${u.dim(N[F].description)}`)}console.info(l("Selecting skills")),a--;let _;if(e.flags.all&&(e.flags.yes||!process.stdin.isTTY))_=N.map(F=>F.relPath),console.info(` Selected all ${u.bold(String(_.length))} skills`);else if(process.stdin.isTTY)if(N.length===1)_=[N[0].relPath],console.info(` Auto-selected: ${u.bold(N[0].name)} ${u.dim(`v${N[0].version}`)}`);else{let F=N.map(
|
|
619
|
+
${g} ${u.dim(`(${y.length} match${y.length>1?"es":""})`)}`);for(let b of y.slice(0,5))console.info(` ${u.dim(`${b.file}:${b.line}`)} -- ${b.match}`);y.length>5&&console.info(u.dim(` ... and ${y.length-5} more`))}}}}async function Sk(e,t){return t?await ra(e,t):await bs(e)}async function $k(e){if(e.flags.help){wk();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;i||($("Missing required argument: <source>"),console.error('Run "asm install --help" for usage.'),process.exit(2));let n=null,r="github",o=8,a=0,l=f=>(a++,`
|
|
620
|
+
${u.cyan(`[Step ${a}/${o}]`)} ${u.bold(f)}`),c=()=>{n?le(n).finally(()=>process.exit(1)):process.exit(1)};process.on("SIGINT",c),process.on("SIGTERM",c);try{if(!Qi(i)&&await sa(i)&&(i=`./${i}`),Qt(i)){console.info(`
|
|
621
|
+
${u.cyan("\u25CF")} Resolving "${u.bold(i)}" from registry...`);let{resolved:A,multipleMatches:N,suggestions:_}=await nu(i,{noCache:e.flags.noCache});if(A){r="registry";let L=A.manifest,F=L.repository.replace("https://github.com/","");i=L.skill_path?`github:${F}#${L.commit}:${L.skill_path}`:`github:${F}#${L.commit}`,console.info(` ${u.green("\u2713")} Resolved: ${u.bold(`${L.author}/${L.name}`)} @ ${L.commit.slice(0,7)}`)}else if(N.length>0){console.info(`
|
|
622
|
+
${u.yellow("\u26A0")} Multiple skills found for "${u.bold(i)}":`);let L=N.slice(0,5);for(let re=0;re<L.length;re++){let de=L[re];console.info(` ${u.cyan(`${re+1}.`)} ${u.bold(`${de.author}/${de.name}`)} \u2014 ${de.description}`)}process.stdin.isTTY||($(`Ambiguous skill name "${i}". Use a scoped name: asm install author/name`),process.exit(2));let F=`
|
|
623
|
+
Select a skill [1-${L.length}]: `;process.stderr.write(F);let ne=await new Promise(re=>{let de="",ve=!1,rs=setTimeout(()=>{ve||(ve=!0,process.stdin.removeListener("data",ht),re(de.trim()))},3e4);function ht(sf){de=sf.toString().trim(),ve||(ve=!0,clearTimeout(rs),process.stdin.removeListener("data",ht),re(de))}process.stdin.setEncoding("utf-8"),process.stdin.on("data",ht)}),V=parseInt(ne,10);(isNaN(V)||V<1||V>L.length)&&($("Invalid selection. Aborting."),process.exit(2));let U=L[V-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 Dr(i)?($(`Skill "${i}" not found in the registry.`),_.length>0&&console.error(`
|
|
624
|
+
Did you mean: ${_.map(L=>u.cyan(L)).join(", ")}?`),process.exit(1)):(console.info(` ${u.dim("Not found in registry \u2014 trying existing sources...")}`),r="pre-indexed")}console.info(l("Parsing source"));let f=Te(i),d=!!f.isLocal;if(d){let A=f.localPath;console.info(` ${u.dim(`local: ${A}`)}`);let{stat:N}=await import("fs/promises");try{if(!(await N(A)).isDirectory())throw new Error(`Path is not a directory: ${A}`)}catch(_){throw _.code==="ENOENT"?new Error(`Path does not exist: ${A}`):_}}else await De(),f=await gs(f),console.info(` ${u.dim(i)}`);if(e.flags.method==="vercel"){console.info(l("Installing via Vercel skills CLI")),await oa();let A=la(f),N=e.flags.path||null;console.info(` ${u.dim(`npx skills add ${A}${N?` --skill ${N}`:""}`)}`);let{stdout:_,stderr:L}=await aa(A,N);_.trim()&&console.info(` ${u.dim(_.trim())}`),L.trim()&&console.error(` ${u.dim(L.trim())}`),console.info(` ${u.green("\u2713")} Vercel skills CLI install completed`),e.flags.force=!0,console.info(` ${u.dim("Continuing with asm install to register in local inventory...")}`)}console.info(l("Selecting provider"));let p=await B(),{provider:m,allProviders:y}=await Xe(p,e.flags.provider,!!process.stdin.isTTY);console.info(l("Selecting scope"));let h;if(e.flags.scope==="global"||e.flags.scope==="project")h=e.flags.scope,console.info(` ${u.dim(`scope: ${h}`)}${h==="global"?` (${m.global})`:` (${m.project})`}`);else if(!process.stdin.isTTY||e.flags.yes)h="global",console.info(` ${u.dim("scope: global (default)")} (${m.global})`);else{let A=[{label:`Global (${m.global})`,hint:"Available in all projects",checked:!0},{label:`Project (${m.project})`,hint:"Available only in this project",checked:!1}];console.info("");let N=await Qe({items:A});if(N.length===0)throw new Error("No scope selected. Aborting.");h=N[0]===0?"global":"project",console.info(` Selected: ${u.bold(h)} ${u.dim(`(${h==="global"?m.global:m.project})`)}`)}if(d)console.info(l("Reading local source")),console.info(` ${u.dim(f.localPath)}`),n=null;else{console.info(l("Cloning repository"));let A=e.flags.transport,N=A==="ssh"?f.sshCloneUrl:A==="https"?f.cloneUrl:`${f.cloneUrl} ${u.dim("(auto)")}`;console.info(` ${N}${f.ref?` ${u.dim(`(ref: ${f.ref})`)}`:""}${f.subpath?` ${u.dim(`(path: ${f.subpath})`)}`:""}`),n=await Fe(f,A)}let g=d?f.localPath:n;console.info(l("Scanning for skills"));let{join:b}=await import("path"),w=[],k=e.flags.path||f.subpath,S=[],v=!1,C=g,E="";if(k){let A=b(g,k),N=!1;try{await _e(A),N=!0}catch{if(!e.flags.all)throw new Error(`No SKILL.md found at path "${k}" in the repository.`);let{stat:_}=await import("fs/promises");try{if(!(await _(A)).isDirectory())throw new Error(`No SKILL.md found at path "${k}" in the repository.`)}catch(L){throw L&&L.code==="ENOENT"?new Error(`No SKILL.md found at path "${k}" in the repository.`):L}v=!0,C=A,E=k}N&&(console.info(` Found skill at ${u.bold(k)}`),S=[{skillDir:A,nameOverride:e.flags.name}])}else{let A=!1;try{await _e(g),A=!0}catch{}if(A){let N=await _e(g);console.info(` Found: ${u.bold(N.name)} v${N.version}`),S=[{skillDir:g,nameOverride:e.flags.name}]}else v=!0}if(v){console.info(E?` No SKILL.md at ${u.bold(E)}. Scanning subdirectories...`:" No SKILL.md at root. Scanning subdirectories...");let A=await ys(C),N=E?A.map(F=>({...F,relPath:`${E}/${F.relPath}`})):A;if(N.length===0)throw new Error(E?`No skills found under path "${E}". Skills must have a SKILL.md file.`:"No skills found in this repository. Skills must have a SKILL.md file.");console.info(` Found ${u.bold(String(N.length))} skill(s):
|
|
625
|
+
`);for(let F=0;F<N.length;F++){let ne=u.cyan(` ${String(F+1).padStart(String(N.length).length)})`);console.info(`${ne} ${u.bold(N[F].name)} ${u.dim(`v${N[F].version}`)} ${u.dim(`(${N[F].relPath})`)}`),N[F].description&&console.info(` ${u.dim(N[F].description)}`)}console.info(l("Selecting skills")),a--;let _;if(e.flags.all&&(e.flags.yes||!process.stdin.isTTY))_=N.map(F=>F.relPath),console.info(` Selected all ${u.bold(String(_.length))} skills`);else if(process.stdin.isTTY)if(N.length===1)_=[N[0].relPath],console.info(` Auto-selected: ${u.bold(N[0].name)} ${u.dim(`v${N[0].version}`)}`);else{let F=N.map(V=>({label:V.name,hint:`v${V.version}${V.description?" "+V.description:""}`,checked:!!e.flags.all}));console.info("");let ne=await Qe({items:F});if(ne.length===0)throw new Error("No skills selected. Aborting.");_=ne.map(V=>N[V].relPath),console.info(` Selected ${u.bold(String(_.length))} skill(s)`)}else{$(`Repository contains ${N.length} skills. Use --path <subdir> to pick one or --all to install all.
|
|
626
626
|
Available skills:
|
|
627
627
|
${N.map(F=>` --path ${F.relPath}`).join(`
|
|
628
|
-
`)}`),process.exit(2);return}let L=
|
|
628
|
+
`)}`),process.exit(2);return}let L=ia(_);if(L.length>0){let F=L.map(V=>` - ${V.name}: ${V.paths.map(U=>`"${U}"`).join(", ")}`).join(`
|
|
629
629
|
`),ne=new Error(`Duplicate skill names detected in selection:
|
|
630
630
|
${F}
|
|
631
|
-
Choose one path per skill name or install with --path.`);throw ne.duplicates=L,ne}S=_.map(F=>({skillDir:b(g,F),nameOverride:_.length===1?e.flags.name:null})),a++}console.info(l("Inspecting skills"));let x=await
|
|
631
|
+
Choose one path per skill name or install with --path.`);throw ne.duplicates=L,ne}S=_.map(F=>({skillDir:b(g,F),nameOverride:_.length===1?e.flags.name:null})),a++}console.info(l("Inspecting skills"));let x=await Z(p,"both"),M=[],O=S.length>1;for(let A=0;A<S.length;A++){let{skillDir:N,nameOverride:_}=S[A],L=await vk(e,f,g,N,_,p,m,x,h);M.push(L),kk(L,i,m,y,O,O?{index:A+1,total:S.length}:void 0)}if(O){console.info(""),console.info(` ${u.bold("Install settings:")}`),console.info(` ${u.bold("Source:")} ${i}`),console.info(y?` ${u.bold("Tool:")} All (${y.map(F=>F.label).join(", ")})`:` ${u.bold("Tool:")} ${m.label} (${m.name})`),console.info(` ${u.bold("Scope:")} ${h==="project"?"Project":"Global"}`);let A=M.filter(F=>F.riskLevel==="high").length,N=M.filter(F=>F.riskLevel==="medium").length,_=M.filter(F=>F.riskLevel==="safe").length,L=[];_>0&&L.push(u.green(`${_} Safe`)),N>0&&L.push(u.yellow(`${N} Medium Risk`)),A>0&&L.push(u.red(`${A} High Risk`)),console.info(` ${u.bold("Risk:")} ${L.join(", ")}`)}if(console.info(l("Installing")),!e.flags.yes){let A=M.some(F=>F.riskLevel==="high");process.stdin.isTTY||($("Cannot prompt for confirmation in non-interactive mode. Use --yes to skip."),process.exit(2));let N=O?`${M.length} skills`:`"${M[0].metadata.name}"`,_=A?`
|
|
632
632
|
${u.red("[!]")} ${u.bold(`Install ${N}? Some have high-risk patterns.`)} [y/N] `:`
|
|
633
|
-
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(_);let L=await G();A?L.toLowerCase()!=="y"&&L.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)):(L.toLowerCase()==="n"||L.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let D=n?await Mo(n):null,T=[];for(let A=0;A<M.length;A++){let N=M[A],_=O?u.dim(`[${A+1}/${M.length}]`)+" ":" ";try{console.info(`${_}Installing ${u.bold(N.metadata.name)}...`);let L=await
|
|
633
|
+
${u.bold(`Install ${N}?`)} [Y/n] `;process.stderr.write(_);let L=await G();A?L.toLowerCase()!=="y"&&L.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)):(L.toLowerCase()==="n"||L.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let D=n?await Mo(n):null,T=[];for(let A=0;A<M.length;A++){let N=M[A],_=O?u.dim(`[${A+1}/${M.length}]`)+" ":" ";try{console.info(`${_}Installing ${u.bold(N.metadata.name)}...`);let L=await Sk(N.plan,y);w.push(L),console.info(`${_}${u.green("\u2713")} ${N.metadata.name} installed to ${u.dim(N.plan.targetDir)}`);try{let F=d?`local:${f.localPath}`:`github:${f.owner}/${f.repo}`,ne=d?"local":r==="registry"?"registry":"github";await wt(L.name,{source:F,commitHash:D||"unknown",ref:f.ref||"main",installedAt:new Date().toISOString(),provider:N.plan.providerName,sourceType:ne,...r==="registry"?{registryName:L.name}:{}})}catch{}}catch(L){T.push({name:N.metadata.name,error:L.message}),console.error(`${_}${u.red("\u2717")} ${u.bold(N.metadata.name)} \u2014 ${u.red(L.message)}`)}}if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),T.length>0){console.error(`
|
|
634
634
|
${u.yellow(`${T.length} skill(s) failed to install:`)}`);for(let A of T)console.error(` ${u.red("\u2717")} ${A.name}: ${A.error}`)}if(e.flags.machine){t?.();let A=w.map(N=>({name:N.name,path:N.path,version:N.version,provider:N.provider,source:N.source,resolution_source:r}));console.log(Q("install",A.length===1?A[0]:A,s))}else if(e.flags.json){let A=w.map(N=>({...N,resolutionSource:r}));console.log(JSON.stringify(A.length===1?A[0]:A,null,2))}else w.length===1?console.error(u.green(`
|
|
635
635
|
Done! Installed "${w[0].name}" to ${w[0].path}`)):w.length>0&&console.error(`
|
|
636
|
-
${u.green(`Done! Installed ${w.length} skill(s) successfully.`)}`)}catch(f){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(
|
|
636
|
+
${u.green(`Done! Installed ${w.length} skill(s) successfully.`)}`)}catch(f){if(process.removeListener("SIGINT",c),process.removeListener("SIGTERM",c),e.flags.machine)t?.(),console.log(te("install",ee.INSTALL_FAILED,f.message,s,f?.duplicates?{duplicates:f.duplicates}:void 0));else if(e.flags.json){let d={success:!1,error:f.message};f?.duplicates&&(d.duplicates=f.duplicates),console.log(JSON.stringify(d,null,2))}else $(f.message);process.exit(1)}finally{n&&await le(n),t?.()}}function xk(){console.log(`${u.bold("Usage:")} asm export [options]
|
|
637
637
|
|
|
638
638
|
Export skill inventory as a portable JSON manifest. Useful for backup,
|
|
639
639
|
sharing, or scripting.
|
|
@@ -646,7 +646,7 @@ ${u.bold("Options:")}
|
|
|
646
646
|
${u.bold("Examples:")}
|
|
647
647
|
asm export ${u.dim("Export all skills")}
|
|
648
648
|
asm export -s global ${u.dim("Export global skills only")}
|
|
649
|
-
asm export > skills.json ${u.dim("Save to file")}`)}async function
|
|
649
|
+
asm export > skills.json ${u.dim("Save to file")}`)}async function Ek(e){if(e.flags.help){xk();return}let t=await B(),s=await Z(t,e.flags.scope),i=ru(s);console.log(JSON.stringify(i,null,2))}function Ck(){console.log(`${u.bold("Usage:")} asm import <file> [options]
|
|
650
650
|
|
|
651
651
|
Import skills from a previously exported JSON manifest. Recreates skill
|
|
652
652
|
installations based on the manifest metadata.
|
|
@@ -668,9 +668,9 @@ ${u.bold("Examples:")}
|
|
|
668
668
|
asm import skills.json --force ${u.dim("Overwrite existing skills")}
|
|
669
669
|
asm import skills.json -s global ${u.dim("Import only global skills")}
|
|
670
670
|
asm export > backup.json ${u.dim("Export first, then import later")}
|
|
671
|
-
asm import backup.json ${u.dim("Restore from backup")}`)}async function
|
|
672
|
-
${u.bold("Proceed?")} [y/N] `);let l=await G();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await
|
|
673
|
-
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let l of a.results){let c=l.status==="installed"?u.green("+++"):l.status==="skipped"?u.yellow("---"):l.status==="dry-run"?u.cyan("~~~"):u.red("!!!"),f=l.reason?` ${u.dim(l.reason)}`:"",d=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${f}${d}`)}console.error(""),console.error(`${u.bold("Summary:")} ${a.total} total, ${u.green(String(a.installed))} installed, ${u.yellow(String(a.skipped))} skipped, ${u.red(String(a.failed))} failed`),a.failed>0&&(process.exitCode=1)}function
|
|
671
|
+
asm import backup.json ${u.dim("Restore from backup")}`)}async function Ak(e){if(e.flags.help){Ck();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 cu(i)}catch(l){$(l.message),process.exit(1)}let r=n.skills.length;if(r===0){e.flags.json?console.log(JSON.stringify({total:0,installed:0,skipped:0,failed:0,results:[]},null,2)):console.log("Manifest contains no skills. Nothing to import.");return}let o=e.flags.scope==="both"?"all scopes":e.flags.scope;if(console.error(`${u.bold("Importing")} ${r} skill${r>1?"s":""} from ${u.dim(i)}`),console.error(` Scope filter: ${o}`),e.flags.force&&console.error(` ${u.yellow("Force mode: existing skills will be overwritten")}`),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
672
|
+
${u.bold("Proceed?")} [y/N] `);let l=await G();l.toLowerCase()!=="y"&&l.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let a=await uu(n,{force:e.flags.force,dryRun:!1,scopeFilter:e.flags.scope});if(e.flags.json){console.log(JSON.stringify(a,null,2));return}if(a.total===0){console.error(`
|
|
673
|
+
Nothing to import after scope filtering (--scope ${e.flags.scope}). All skills in the manifest were excluded.`);return}console.error("");for(let l of a.results){let c=l.status==="installed"?u.green("+++"):l.status==="skipped"?u.yellow("---"):l.status==="dry-run"?u.cyan("~~~"):u.red("!!!"),f=l.reason?` ${u.dim(l.reason)}`:"",d=l.path?` ${u.dim(l.path)}`:"";console.error(` ${c} ${l.skillName} (${l.provider}/${l.scope})${f}${d}`)}console.error(""),console.error(`${u.bold("Summary:")} ${a.total} total, ${u.green(String(a.installed))} installed, ${u.yellow(String(a.skipped))} skipped, ${u.red(String(a.failed))} failed`),a.failed>0&&(process.exitCode=1)}function Pk(){console.log(`${u.bold("Usage:")} asm init <name> [options]
|
|
674
674
|
|
|
675
675
|
Scaffold a new skill directory with a SKILL.md template. Creates a
|
|
676
676
|
ready-to-edit skill in the target tool's skill folder.
|
|
@@ -685,8 +685,8 @@ ${u.bold("Options:")}
|
|
|
685
685
|
${u.bold("Examples:")}
|
|
686
686
|
asm init my-skill ${u.dim("Scaffold (interactive tool)")}
|
|
687
687
|
asm init my-skill -p claude ${u.dim("Scaffold in Claude Code")}
|
|
688
|
-
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function
|
|
689
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await
|
|
688
|
+
asm init my-skill --path ./skills ${u.dim("Scaffold in custom directory")}`)}async function Nk(e){if(e.flags.help){Pk();return}let t=e.subcommand;t||($("Missing required argument: <name>"),console.error('Run "asm init --help" for usage.'),process.exit(2));let s=Me(t),i;if(e.flags.path){let{resolve:n}=await import("path");i=n(e.flags.path)}else{let n=await B(),{provider:r}=await Xe(n,e.flags.provider,!!process.stdin.isTTY),{join:o}=await import("path"),{resolveProviderPath:a}=await import("./config-FRM3YOMA.js"),l=a(n.providers.find(c=>c.name===r.name).global);i=o(l,s)}if(await fu(i)&&!e.flags.force){process.stdin.isTTY||($(`Directory already exists: ${i}. Use --force to overwrite.`),process.exit(2)),process.stderr.write(`${u.yellow(`Directory already exists: ${i}`)}
|
|
689
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await du(s,i),console.error(u.green(`Done! Created skill "${s}" at ${i}`))}function Ik(){console.log(`${u.bold("Usage:")} asm stats [options]
|
|
690
690
|
|
|
691
691
|
Show aggregate skill metrics with provider distribution charts,
|
|
692
692
|
scope breakdown, disk usage, and duplicate summary.
|
|
@@ -700,7 +700,7 @@ ${u.bold("Options:")}
|
|
|
700
700
|
${u.bold("Examples:")}
|
|
701
701
|
asm stats ${u.dim("Show full dashboard")}
|
|
702
702
|
asm stats -s global ${u.dim("Global skills only")}
|
|
703
|
-
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function
|
|
703
|
+
asm stats --json ${u.dim("Output raw data as JSON")}`)}async function Rk(e){if(e.flags.help){Ik();return}let t=await B(),s=await Z(t,e.flags.scope);if(s.length===0){console.log("No skills found.");return}let i=Ki(s),n=await mu(s,i);if(e.flags.json)if(e.flags.verbose)console.log(Y(n));else{let{perSkillDiskBytes:r,...o}=n;console.log(Y(o))}else console.log(hu(n))}function Lk(){console.log(`${u.bold("Usage:")} asm doctor [options]
|
|
704
704
|
|
|
705
705
|
Run environment health checks and diagnostics. Validates all
|
|
706
706
|
prerequisites for using asm \u2014 git, GitHub CLI, Node.js, config,
|
|
@@ -715,7 +715,7 @@ ${u.bold("Options:")}
|
|
|
715
715
|
${u.bold("Examples:")}
|
|
716
716
|
asm doctor ${u.dim("Run all health checks")}
|
|
717
717
|
asm doctor --json ${u.dim("Output as JSON")}
|
|
718
|
-
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function
|
|
718
|
+
asm doctor --machine ${u.dim("Machine-readable v1 envelope output")}`)}async function Ok(e){if(e.flags.help){Lk();return}let t=performance.now(),s=await od();if(e.flags.machine){let i={checks:s.checks.map(n=>({name:n.name,status:n.status,message:n.message,...n.fix?{fix:n.fix}:{}})),passed:s.passed,warnings:s.warnings,failures:s.failures};console.log(Q("doctor",i,t))}else e.flags.json?console.log(ld(s)):console.log(ad(s));s.failures>0&&process.exit(1)}function Tk(){console.log(`${u.bold("Usage:")} asm eval <target> [options]
|
|
719
719
|
|
|
720
720
|
Evaluate a skill's SKILL.md against best practices and produce a scored quality
|
|
721
721
|
report with recommendations. Zero configuration \u2014 just point it at a skill
|
|
@@ -751,8 +751,8 @@ ${u.bold("Examples:")}
|
|
|
751
751
|
asm eval ./my-skill --fix ${u.dim("Auto-fix deterministic issues")}
|
|
752
752
|
asm eval ./my-skill --fix --dry-run ${u.dim("Preview fixes as diff")}
|
|
753
753
|
asm eval ./my-skill --machine ${u.dim("Machine-readable v1 envelope")}
|
|
754
|
-
asm eval-providers list ${u.dim("List registered eval providers")}`)}function
|
|
755
|
-
`))}function
|
|
754
|
+
asm eval-providers list ${u.dim("List registered eval providers")}`)}function Mk(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 Dk(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 gs(i);let n=await Fe(i,t),r=i.subpath?co(n,i.subpath):n,o=null;try{let{execFile:c}=await import("child_process"),{promisify:f}=await import("util"),d=f(c),{stdout:p}=await d("git",["-C",n,"rev-parse","HEAD"],{timeout:5e3}),m=p.trim();/^[0-9a-f]{40}$/i.test(m)&&(o=m)}catch{}let a=`github:${i.owner}/${i.repo}${i.ref?`#${i.ref}`:""}${i.subpath?`:${i.subpath}`:""}`;return{rootDir:r,cleanup:async()=>{s||await le(n)},sourceRef:a,commitSha:o}}async function Yd(e){Li();try{let t={skillPath:e.skillPath,skillMdPath:e.skillMdPath},s=(await Promise.all(is(Oi()).map(async r=>(await r.applicable(t,{})).ok?Ti(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 Mk(i),{report:{...i.raw,providers:is(s.map(qd))},error:null}}catch(t){return{report:null,error:t?.message??String(t)}}}async function Fk(e){if(e.flags.help){Tk();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand;if(i||(e.flags.machine&&(t?.(),console.log(te("eval",ee.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(no(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(te("eval",ee.INVALID_ARGUMENT,r,s)),process.exit(2)),$(r),process.exit(2)}try{let r=await bd(),o=await yd(i,{dryRun:e.flags.dryRun,gitAuthor:r});if(e.flags.machine){t?.(),console.log(Q("eval",Pi(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(Ai(o.report)),console.log(""),console.log(vd(o));return}catch(r){e.flags.machine&&(t?.(),console.log(te("eval",ee.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 kd(i,{fetchRemote:r=>Dk(r,e.flags.transport,e.flags.keep)})}catch(r){e.flags.machine&&(t?.(),console.log(te("eval",ee.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 Yd(c);if(!f)throw new Error(d??"eval failed");if(e.flags.machine){t?.();let p=Pi(f,null),m=n.provenance.remote?{...p,provenance:{input:n.provenance.input,remote:!0,source_ref:n.provenance.sourceRef??null,commit_sha:n.provenance.commitSha??null,temp_path:n.provenance.tempPath??null}}:p;console.log(Q("eval",m,s));return}if(e.flags.json){n.provenance.remote?console.log(JSON.stringify({...f,provenance:{input:n.provenance.input,remote:!0,sourceRef:n.provenance.sourceRef??null,commitSha:n.provenance.commitSha??null,tempPath:n.provenance.tempPath??null}},null,2)):console.log(wd(f));return}console.log(Ai(f)),n.provenance.remote&&_k(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 $d(n.targets,r,async c=>{let{report:f,error:d}=await Yd(c);return{label:c.label,skillPath:c.skillPath,report:f,error:d}}),a=Sd(o),l={provenance:n.provenance,aggregate:a,results:o};if(e.flags.machine){t?.(),console.log(Q("eval",Ed(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(Ai(c.report)):(console.log(`Skill evaluation: ${c.skillPath}`),console.log(` ${u.red("error:")} ${c.error??"unknown failure"}`)),console.log("");console.log(xd(l)),n.provenance.remote&&e.flags.verbose}catch(r){e.flags.machine&&(t?.(),console.log(te("eval",ee.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 _k(e){let t=[];t.push(""),t.push(u.dim("Fetched remote skill:")),e.sourceRef&&t.push(u.dim(` Source: ${e.sourceRef}`)),e.commitSha&&t.push(u.dim(` Commit: ${e.commitSha}`)),e.tempPath&&t.push(u.dim(` Temp: ${e.tempPath}`)),console.log(t.join(`
|
|
755
|
+
`))}function jk(){console.log(`${u.bold("Usage:")} asm eval-providers <subcommand> [options]
|
|
756
756
|
|
|
757
757
|
Manage evaluation providers registered with the ${u.bold("asm eval")} framework.
|
|
758
758
|
Providers implement the ${u.bold("EvalProvider")} contract (see src/eval/types.ts) and
|
|
@@ -768,7 +768,7 @@ ${u.bold("Options:")}
|
|
|
768
768
|
|
|
769
769
|
${u.bold("Examples:")}
|
|
770
770
|
asm eval-providers list ${u.dim("Show registered providers")}
|
|
771
|
-
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function
|
|
771
|
+
asm eval-providers list --json ${u.dim("Machine-readable listing")}`)}async function qk(e){if(e.flags.help){jk();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":{Li();let s=Ni();if(e.flags.json){console.log(Y(s.map(a=>({id:a.id,version:a.version,schemaVersion:a.schemaVersion,description:a.description,requires:a.requires??[]}))));return}if(s.length===0){console.log("No eval providers registered.");return}let i=["id","version","schemaVersion","description","requires"],n=s.map(a=>[a.id,a.version,String(a.schemaVersion),a.description,a.requires&&a.requires.length>0?a.requires.join(","):"-"]),r=i.map((a,l)=>Math.max(a.length,...n.map(c=>c[l].length))),o=a=>a.map((l,c)=>l.padEnd(r[c])).join(" ");console.log(u.bold(o(i))),console.log(r.map(a=>"-".repeat(a)).join(" "));for(let a of n)console.log(o(a));return}default:$(`Unknown eval-providers subcommand: "${t}". Use: list`),console.error('Run "asm eval-providers --help" for usage.'),process.exit(2)}}function Bk(){console.log(`${u.bold("Usage:")} asm link <path> [<path2> ...] [options]
|
|
772
772
|
|
|
773
773
|
Symlink a local skill directory into an agent's skill folder. Useful
|
|
774
774
|
for local development \u2014 changes to the source are reflected immediately.
|
|
@@ -792,13 +792,13 @@ ${u.bold("Examples:")}
|
|
|
792
792
|
asm link ./my-skill -p claude ${u.dim("Link to Claude Code")}
|
|
793
793
|
asm link ./my-skill --name alias ${u.dim("Link with custom name")}
|
|
794
794
|
asm link ./my-skills-folder ${u.dim("Link all skills in folder")}
|
|
795
|
-
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function
|
|
796
|
-
${u.bold("Overwrite?")} [y/N] `);let n=await G();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function
|
|
795
|
+
asm link ./skill1 ./skill2 ./skill3 -p claude ${u.dim("Link multiple skills at once")}`)}async function Uk(e,t){if(t)return!0;let{access:s}=await import("fs/promises"),i=!1;try{await s(e),i=!0}catch{}if(!i)return!1;if(!process.stdin.isTTY)throw new Error(`Target already exists: ${e}. Use --force to overwrite.`);process.stderr.write(`${u.yellow(`Target already exists: ${e}`)}
|
|
796
|
+
${u.bold("Overwrite?")} [y/N] `);let n=await G();return n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0)),!0}async function Mi(e,t,s,i){let{join:n}=await import("path"),r=n(t,s),o=await Uk(r,i);return await bu(e,t,s,o),{name:s,symlinkPath:r,targetPath:e}}async function Kk(e){if(e.flags.help){Bk();return}let t=[];if(e.subcommand&&t.push(e.subcommand),t.push(...e.positional),t.length===0&&($("Missing required argument: <path>"),console.error('Run "asm link --help" for usage.'),process.exit(2)),t.length>1){e.flags.name&&($("--name cannot be used when linking multiple paths. Link each skill individually to use --name."),process.exit(2));let y=await B(),{provider:h}=await Xe(y,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:g}=await import("./config-FRM3YOMA.js"),b=g(y.providers.find(C=>C.name===h.name).global),{resolve:w,basename:k}=await import("path"),S=[],v=[];for(let C of t){let E=w(C),x=!1,M=null;try{await jr(E),x=!0}catch(O){let D=O instanceof Error?O.message:String(O);D.startsWith("Path does not exist")||D.startsWith("Path is not a directory")||D.startsWith("No SKILL.md found")||(M=D)}if(M){v.push({name:C,error:M}),e.flags.json||console.error(u.red(` Failed to process "${C}": ${M}`));continue}if(x){let O=k(E);try{let D=await Mi(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 qr(E)}catch(D){let T=D instanceof Error?D.message:String(D),A=T;T.startsWith("Path does not exist")&&Qt(C)&&(A=`${T} \u2014 "${C}" looks like a registry name; try "asm install ${C}" first.`),v.push({name:C,error:A}),e.flags.json||console.error(u.red(` Failed to process "${C}": ${A}`));continue}if(O.length===0){let D=`No SKILL.md found in ${E} or its immediate subdirectories.`;v.push({name:C,error:D}),e.flags.json||console.error(u.red(` ${D}`));continue}for(let D of O)try{let T=await Mi(D.absPath,b,D.dirName,!!e.flags.force);S.push(T),e.flags.json||console.error(u.green(` Linked "${T.name}" -> ${T.targetPath}`))}catch(T){let A=T instanceof Error?T.message:String(T);v.push({name:D.name,error:A}),e.flags.json||console.error(u.red(` Failed to link "${D.name}": ${A}`))}}}e.flags.json?console.log(Y({success:v.length===0,linked:S,failures:v})):v.length>0?console.error(u.yellow(`
|
|
797
797
|
${S.length} linked, ${v.length} failed.`)):console.error(u.green(`
|
|
798
|
-
Done! Linked ${S.length} skill(s) successfully.`)),v.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await
|
|
799
|
-
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await G();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],m=[];for(let y of a){let h=e.flags.name&&a.length===1?Me(e.flags.name):y.dirName;try{let g=await
|
|
798
|
+
Done! Linked ${S.length} skill(s) successfully.`)),v.length>0&&process.exit(1);return}let s=t[0],{resolve:i,basename:n}=await import("path"),r=i(s),o=!1;try{await jr(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 qr(r)}catch(y){let h=y instanceof Error?y.message:String(y);h.startsWith("Path does not exist")?($(`No such skill or path: ${s}`),Qt(s)?(console.error(` "${s}" looks like a registry name, not a local path.`),console.error(` Install it first: ${u.bold(`asm install ${s}`)}`),console.error(` Or pass a local path: ${u.bold(`asm link ./path/to/${s}`)}`)):console.error(' Pass a local directory containing SKILL.md, or run "asm install <name>" first.')):$(h),process.exit(1)}a.length===0&&($(`No SKILL.md found in ${r} or its immediate subdirectories.`),process.exit(1)),e.flags.name&&a.length>1&&($(`--name cannot be used when linking multiple skills (found ${a.length} skills). Link each skill individually to use --name.`),process.exit(2))}let l=await B(),{provider:c}=await Xe(l,e.flags.provider,!!process.stdin.isTTY),{resolveProviderPath:f}=await import("./config-FRM3YOMA.js"),d=f(l.providers.find(y=>y.name===c.name).global);if(o){let y=e.flags.name?Me(e.flags.name):n(r),h;try{h=await Mi(r,d,y,!!e.flags.force)}catch(g){let b=g instanceof Error?g.message:String(g);e.flags.json?console.log(Y({success:!1,error:b})):$(b),process.exit(2)}e.flags.json?console.log(Y({success:!0,...h})):(console.error(u.green(`Done! Linked "${h.name}" -> ${h.targetPath}`)),console.error(` Symlink: ${h.symlinkPath}`),console.error(u.dim(` If you move or delete the source, run "asm uninstall ${h.name}" to clean up.`)));return}console.error(`Found ${u.bold(String(a.length))} skill(s) in ${r}:`);for(let y of a)console.error(` ${u.bold(y.name)} ${u.dim(`v${y.version}`)} ${u.dim(`(${y.dirName}/)`)}`);if(process.stdin.isTTY&&!e.flags.force){process.stderr.write(`
|
|
799
|
+
${u.bold(`Link ${a.length} skill(s)?`)} [Y/n] `);let y=await G();(y.toLowerCase()==="n"||y.toLowerCase()==="no")&&(console.error("Aborted."),process.exit(0))}let p=[],m=[];for(let y of a){let h=e.flags.name&&a.length===1?Me(e.flags.name):y.dirName;try{let g=await Mi(y.absPath,d,h,!!e.flags.force);p.push(g),e.flags.json||console.error(u.green(` Linked "${g.name}" -> ${g.targetPath}`))}catch(g){let b=g instanceof Error?g.message:String(g);m.push({name:y.name,error:b}),e.flags.json||console.error(u.red(` Failed to link "${y.name}": ${b}`))}}e.flags.json?console.log(Y({success:m.length===0,linked:p,failures:m})):m.length>0?console.error(u.yellow(`
|
|
800
800
|
${p.length} linked, ${m.length} failed.`)):console.error(u.green(`
|
|
801
|
-
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}function
|
|
801
|
+
Done! Linked ${p.length} skill(s) successfully.`)),m.length>0&&process.exit(1)}function Vk(){console.log(`${u.bold("Usage:")} asm index <subcommand> [options]
|
|
802
802
|
|
|
803
803
|
Manage the skill index for searching available skills from indexed repos.
|
|
804
804
|
|
|
@@ -822,10 +822,10 @@ ${u.bold("Examples:")}
|
|
|
822
822
|
asm index search marketing --has license ${u.dim("Only with license")}
|
|
823
823
|
asm index search "" --missing creator ${u.dim("Skills missing creator")}
|
|
824
824
|
asm index list ${u.dim("List indexed repos")}
|
|
825
|
-
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function
|
|
826
|
-
`));for(let o of r){let a=o.skill.verified?u.blue(" [verified]"):"";console.error(`${u.cyan(o.skill.name)} ${u.dim(`v${o.skill.version}`)}${a} ${u.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let c of Lo(o.skill.description,80))console.error(` ${c}`);let l=
|
|
827
|
-
`)}}break}case"list":{let s=await
|
|
828
|
-
`));for(let n of s)console.error(`${u.cyan(`${n.owner}/${n.repo}`)} - ${n.skillCount} skills ${u.dim(`(${new Date(n.updatedAt).toLocaleDateString()})`)}`)}break}case"remove":{let s=e.positional[0];s||($("Missing required argument: <owner/repo>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let[i,n]=s.split("/");if((!i||!n)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove")} ${u.cyan(`${i}/${n}`)} ${u.bold("from index?")} [y/N] `);let o=await G();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await
|
|
825
|
+
asm index remove obra/superpowers ${u.dim("Remove from index")}`)}async function Jk(e){if(e.flags.help){Vk();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 Jd(s);i.success||($(`Failed to ingest: ${i.error}`),process.exit(1)),i.repoIndex&&(e.flags.json?console.log(Y({success:!0,owner:i.repoIndex.owner,repo:i.repoIndex.repo,skillCount:i.repoIndex.skillCount,updatedAt:i.repoIndex.updatedAt})):(console.error(u.green(`Successfully indexed ${i.repoIndex.owner}/${i.repoIndex.repo}`)),console.error(` Skills found: ${i.repoIndex.skillCount}`)));break}case"search":{let s=e.positional.join(" ");!s&&e.flags.has.length===0&&e.flags.missing.length===0&&($("Missing required argument: <query>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let i={};e.flags.has.length>0&&(i.has=e.flags.has),e.flags.missing.length>0&&(i.missing=e.flags.missing);let r=i.has||i.missing?await yi(s||"",20,i):await yi(s);if(r.length===0){e.flags.json?console.log(Y([])):(console.info("No skills found matching your query."),console.error(u.dim("Try ingesting more repos with: asm index ingest <repo>")));return}if(e.flags.json)console.log(Y(r.map(o=>({name:o.skill.name,description:o.skill.description,version:o.skill.version,license:o.skill.license||"",creator:o.skill.creator||"",compatibility:o.skill.compatibility||"",allowedTools:o.skill.allowedTools||[],verified:o.skill.verified===!0,installUrl:o.skill.installUrl,installCommand:`asm install ${o.skill.installUrl}`,repo:`${o.repo.owner}/${o.repo.repo}`}))));else{console.error(u.bold(`Found ${r.length} skills:
|
|
826
|
+
`));for(let o of r){let a=o.skill.verified?u.blue(" [verified]"):"";console.error(`${u.cyan(o.skill.name)} ${u.dim(`v${o.skill.version}`)}${a} ${u.dim(`[${o.repo.owner}/${o.repo.repo}]`)}`);for(let c of Lo(o.skill.description,80))console.error(` ${c}`);let l=Su(o.skill);l.length>0&&console.error(` ${u.yellow(`\u26A0 Missing: ${l.join(", ")}`)}`),console.error(` ${u.green(`asm install ${o.skill.installUrl}`)}
|
|
827
|
+
`)}}break}case"list":{let s=await Hd();if(s.length===0){e.flags.json?console.log(Y([])):(console.info("No repositories indexed."),console.error(u.dim("Add repos with: asm index ingest <repo>")));return}let i=await $u();if(e.flags.json)console.log(Y(s));else{console.error(u.bold(`Indexed Repositories (${i} total skills):
|
|
828
|
+
`));for(let n of s)console.error(`${u.cyan(`${n.owner}/${n.repo}`)} - ${n.skillCount} skills ${u.dim(`(${new Date(n.updatedAt).toLocaleDateString()})`)}`)}break}case"remove":{let s=e.positional[0];s||($("Missing required argument: <owner/repo>"),console.error('Run "asm index --help" for usage.'),process.exit(2));let[i,n]=s.split("/");if((!i||!n)&&($("Invalid format. Use: <owner/repo>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove")} ${u.cyan(`${i}/${n}`)} ${u.bold("from index?")} [y/N] `);let o=await G();o.toLowerCase()!=="y"&&o.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}await Wd(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 Hk(){console.log(`${u.bold("Usage:")} asm bundle <subcommand> [options]
|
|
829
829
|
|
|
830
830
|
Create, install, and manage curated skill bundles. A bundle is a reusable
|
|
831
831
|
recipe of skills for a particular workflow, domain, or project setup.
|
|
@@ -861,14 +861,14 @@ ${u.bold("Examples:")}
|
|
|
861
861
|
asm bundle modify my-workflow --add github:u/r ${u.dim("Add a skill to bundle")}
|
|
862
862
|
asm bundle modify my-workflow --remove skill ${u.dim("Remove a skill from bundle")}
|
|
863
863
|
asm bundle export my-workflow ${u.dim("Export to ./my-workflow.json")}
|
|
864
|
-
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function
|
|
865
|
-
`));let g=await Qe({items:h});g.length===0&&($("No skills selected. Bundle not created."),process.exit(1)),a=g.map(b=>o[b])}let{readLock:l}=await import("./lock-6S53S4SC.js"),c=await l(),f=await Promise.all(a.map(h=>
|
|
866
|
-
${u.bold("Description")} (optional, press Enter to skip): `);let h=await G();h.trim()&&(d=h.trim()),process.stderr.write(`${u.bold("Author")} (optional, press Enter to skip): `);let g=await G();g.trim()&&(p=g.trim())}let m=
|
|
864
|
+
asm bundle export my-workflow out.json ${u.dim("Export bundle to file")}`)}async function Wk(e){if(e.flags.help){Hk();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 Z(i,e.flags.scope);n.length===0&&($("No skills found to include in the bundle."),process.exit(1));let r=new Set,o=n.filter(h=>{let g=h.name.toLowerCase();return r.has(g)?!1:(r.add(g),!0)}),a=o;if(process.stdin.isTTY&&!e.flags.yes){let h=o.map(b=>({label:`${b.name} v${b.version}`,hint:b.description?b.description.slice(0,60)+(b.description.length>60?"...":""):`(${b.provider}/${b.scope})`,checked:!0}));console.error(u.bold(`Select skills for bundle "${s}":
|
|
865
|
+
`));let g=await Qe({items:h});g.length===0&&($("No skills selected. Bundle not created."),process.exit(1)),a=g.map(b=>o[b])}let{readLock:l}=await import("./lock-6S53S4SC.js"),c=await l(),f=await Promise.all(a.map(h=>Du(h,c))),d=`Bundle of ${f.length} skills`,p="unknown";try{let{execSync:h}=await import("child_process"),g=h("git config user.name",{encoding:"utf-8"}).trim();g&&(p=g)}catch{}if(process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`
|
|
866
|
+
${u.bold("Description")} (optional, press Enter to skip): `);let h=await G();h.trim()&&(d=h.trim()),process.stderr.write(`${u.bold("Author")} (optional, press Enter to skip): `);let g=await G();g.trim()&&(p=g.trim())}let m=Mu(s,d,p,f),y=await Vr(m);e.flags.json?console.log(JSON.stringify(m,null,2)):(console.error(u.green(`Bundle "${s}" created with ${f.length} skill(s).`)),console.error(` Saved to: ${u.dim(y)}`));break}case"install":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle install <name|file>"),process.exit(2));let i;try{i=await ts(s)}catch(d){$(d.message),process.exit(1)}console.error(`${u.bold("Bundle:")} ${i.name} (${i.skills.length} skills)`),i.description&&console.error(` ${u.dim(i.description)}`),console.error("");for(let d of i.skills){let p=d.version?` v${d.version}`:"";console.error(` ${u.cyan(d.name)}${u.dim(p)} ${u.dim(`-> ${d.installUrl}`)}`)}if(!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`
|
|
867
867
|
${u.bold("Install all skills from this bundle?")} [y/N] `);let d=await G();d.toLowerCase()!=="y"&&d.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let n=[],r=await B(),{provider:o}=await Xe(r,e.flags.provider,!1),a=e.flags.scope==="global"||e.flags.scope==="project"?e.flags.scope:"global";for(let d of i.skills){console.error(`
|
|
868
|
-
Installing ${u.bold(d.name)}...`);try{(d.installUrl.startsWith("github:")||d.installUrl.startsWith("https://github.com/"))&&await De();let m=Te(d.installUrl),y=!!m.isLocal,h=null;try{let g,b;y?(g=m.localPath,b=m.localPath):(h=await Fe(m,e.flags.transport),g=h,b=m.subpath?
|
|
868
|
+
Installing ${u.bold(d.name)}...`);try{(d.installUrl.startsWith("github:")||d.installUrl.startsWith("https://github.com/"))&&await De();let m=Te(d.installUrl),y=!!m.isLocal,h=null;try{let g,b;y?(g=m.localPath,b=m.localPath):(h=await Fe(m,e.flags.transport),g=h,b=m.subpath?co(h,m.subpath):h);let w=await _e(b),k=Me(d.name||w.name||m.repo),S=Xi(m,g,b,k,o,e.flags.force,a);try{await ca(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 bs(S),n.push({name:d.name,status:"installed"}),console.error(` ${u.green("+++")} ${d.name} installed`)}finally{h&&await le(h)}}catch(p){n.push({name:d.name,status:"failed",reason:p.message}),console.error(` ${u.red("!!!")} ${d.name}: ${p.message}`)}}let l=n.filter(d=>d.status==="installed").length,c=n.filter(d=>d.status==="skipped").length,f=n.filter(d=>d.status==="failed").length;e.flags.json?console.log(JSON.stringify({bundleName:i.name,total:n.length,installed:l,skipped:c,failed:f,results:n},null,2)):(console.error(""),console.error(`${u.bold("Summary:")} ${n.length} total, ${u.green(String(l))} installed, `+(c>0?`${u.dim(String(c))} skipped, `:"")+`${u.red(String(f))} failed`)),f>0&&(process.exitCode=1);break}case"list":{if(!!e.flags.predefined){let n=await Fu();if(n.length===0){e.flags.json?console.log("[]"):console.log("No predefined bundles found.");return}if(e.flags.json)console.log(JSON.stringify(n,null,2));else{console.error(u.bold(`Pre-defined Bundles (${n.length}):
|
|
869
869
|
`));for(let r of n){let o=r.tags&&r.tags.length>0?` ${u.dim(`[${r.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(r.name)} ${u.dim(`(${r.skills.length} skills)`)}${o}`),r.description&&console.error(` ${u.dim(r.description)}`)}console.error(`
|
|
870
|
-
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await
|
|
871
|
-
`));for(let n of i){let r=n.tags&&n.tags.length>0?` ${u.dim(`[${n.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(n.name)} ${u.dim(`(${n.skills.length} skills)`)}${r}`),n.description&&console.error(` ${u.dim(n.description)}`),n.author&&console.error(` ${u.dim(`by ${n.author}`)}`)}}break}case"show":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle show <name|file>"),process.exit(2));let i;try{i=await
|
|
872
|
-
${u.bold(`Skills (${i.skills.length})`)}:`);for(let n of i.skills){let r=n.version?` v${n.version}`:"";console.error(` ${u.cyan(n.name)}${u.dim(r)}`),n.description&&console.error(` ${u.dim(n.description)}`),console.error(` ${u.dim(`install: ${n.installUrl}`)}`)}}break}case"remove":{let s=e.positional[0];if(s||($("Missing required argument: <name>"),console.error("Usage: asm bundle remove <name>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove bundle")} ${u.cyan(s)}${u.bold("?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await
|
|
873
|
-
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(u.green(`Exported to ${o}`));break}default:$(`Unknown subcommand: "${t}". Use: create, install, list, show, remove, modify, or export`),console.error('Run "asm bundle --help" for usage.'),process.exit(2)}}async function
|
|
874
|
-
`)),console.log(JSON.stringify(n.manifest,null,2));return}n.prUrl&&(console.error(u.green("Published successfully!")),console.error(""),console.error(` PR: ${n.prUrl}`),console.error(` Manifest: manifests/${n.manifest?.author}/${n.manifest?.name}.json`),console.error(` Security: ${n.securityVerdict}`),console.error(""),console.error(u.dim("The registry maintainers will review your submission.")))}catch(n){let r={success:!1,manifest:null,prUrl:null,error:n.message,securityVerdict:"pass",securityReport:{scannedAt:new Date().toISOString(),skillName:"",skillPath:"",source:null,codeScans:[],permissions:[],totalFiles:0,totalLines:0,verdict:"safe",verdictReason:""}};e.flags.machine&&(t?.(),console.log(
|
|
870
|
+
${u.dim("Install a bundle with: asm bundle install <name>")}`)}return}let i=await ju();if(i.length===0){e.flags.json?console.log("[]"):(console.log("No bundles found."),console.error(u.dim("Create one with: asm bundle create <name>")),console.error(u.dim("List pre-defined bundles with: asm bundle list --predefined")));return}if(e.flags.json)console.log(JSON.stringify(i,null,2));else{console.error(u.bold(`Saved Bundles (${i.length}):
|
|
871
|
+
`));for(let n of i){let r=n.tags&&n.tags.length>0?` ${u.dim(`[${n.tags.join(", ")}]`)}`:"";console.error(` ${u.cyan(n.name)} ${u.dim(`(${n.skills.length} skills)`)}${r}`),n.description&&console.error(` ${u.dim(n.description)}`),n.author&&console.error(` ${u.dim(`by ${n.author}`)}`)}}break}case"show":{let s=e.positional[0];s||($("Missing required argument: <name|file>"),console.error("Usage: asm bundle show <name|file>"),process.exit(2));let i;try{i=await ts(s)}catch(n){$(n.message),process.exit(1)}if(e.flags.json)console.log(JSON.stringify(i,null,2));else{console.error(u.bold(`Bundle: ${i.name}`)),i.description&&console.error(` ${i.description}`),i.author&&console.error(` ${u.dim(`Author: ${i.author}`)}`),console.error(` ${u.dim(`Created: ${new Date(i.createdAt).toLocaleString()}`)}`),i.tags&&i.tags.length>0&&console.error(` ${u.dim(`Tags: ${i.tags.join(", ")}`)}`),console.error(`
|
|
872
|
+
${u.bold(`Skills (${i.skills.length})`)}:`);for(let n of i.skills){let r=n.version?` v${n.version}`:"";console.error(` ${u.cyan(n.name)}${u.dim(r)}`),n.description&&console.error(` ${u.dim(n.description)}`),console.error(` ${u.dim(`install: ${n.installUrl}`)}`)}}break}case"remove":{let s=e.positional[0];if(s||($("Missing required argument: <name>"),console.error("Usage: asm bundle remove <name>"),process.exit(2)),!e.flags.yes&&process.stdin.isTTY){process.stderr.write(`${u.bold("Remove bundle")} ${u.cyan(s)}${u.bold("?")} [y/N] `);let n=await G();n.toLowerCase()!=="y"&&n.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}let i;try{i=await qu(s)}catch(n){$(n.message),process.exit(1)}i?console.error(u.green(`Bundle "${s}" removed.`)):($(`Bundle "${s}" not found.`),process.exit(1));break}case"modify":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle modify <name> [--add <installUrl>] [--remove <skillName>] [--description <desc>] [--author <author>] [--tags <tag,...>]"),process.exit(2));let i;try{i=await ts(s)}catch(d){$(d.message),process.exit(1)}let n=!1,r=e.flags.add;if(r){let d={name:r.split("/").pop()?.replace(/\.json$/,"")??r,installUrl:r};i.skills.push(d),n=!0,console.error(u.green(`Added skill from ${r}`))}let o=e.flags.remove;if(o){let d=i.skills.length;i.skills=i.skills.filter(p=>p.name.toLowerCase()!==o.toLowerCase()),i.skills.length<d?(n=!0,console.error(u.green(`Removed skill "${o}"`))):console.error(u.dim(`Skill "${o}" not found in bundle (no change)`))}let a=e.flags.description;a!==null&&(i.description=a,n=!0);let l=e.flags.author;l!==null&&(i.author=l,n=!0);let c=e.flags.tags;if(c!==null&&(i.tags=c.split(",").map(d=>d.trim()).filter(d=>d.length>0),n=!0),!n&&process.stdin.isTTY&&!e.flags.yes&&!r&&!o&&a===null&&l===null&&c===null){console.error(u.bold(`Modifying bundle "${i.name}"`)),console.error(` Current skills: ${i.skills.map(y=>y.name).join(", ")}`),console.error(` Description: ${i.description}`),console.error(` Author: ${i.author}`),console.error(` Tags: ${i.tags?.join(", ")??"(none)"}`),console.error(""),process.stderr.write(`${u.bold("New description")} (Enter to keep current): `);let d=await G();d.trim()&&(i.description=d.trim(),n=!0),process.stderr.write(`${u.bold("New author")} (Enter to keep current): `);let p=await G();p.trim()&&(i.author=p.trim(),n=!0),process.stderr.write(`${u.bold("New tags (comma-separated)")} (Enter to keep current): `);let m=await G();m.trim()&&(i.tags=m.split(",").map(y=>y.trim()).filter(y=>y.length>0),n=!0)}if(!n){console.error(u.dim("No changes made to bundle."));break}i.skills.length===0&&($("Bundle must contain at least one skill after modification."),process.exit(1));let f=await Vr(i);e.flags.json?console.log(JSON.stringify(i,null,2)):(console.error(u.green(`Bundle "${i.name}" updated (${i.skills.length} skill(s)).`)),console.error(` Saved to: ${u.dim(f)}`));break}case"export":{let s=e.positional[0];s||($("Missing required argument: <name>"),console.error("Usage: asm bundle export <name> [output-file]"),process.exit(2));let i;try{i=await ts(s)}catch(l){$(l.message),process.exit(1)}let n=e.positional[1]??`./${s}.json`,{resolve:r}=await import("path"),o=r(n);if(!e.flags.force){let{access:l}=await import("fs/promises");try{if(await l(o),process.stdin.isTTY&&!e.flags.yes){process.stderr.write(`File ${u.bold(o)} already exists. Overwrite? [y/N] `);let c=await G();c.toLowerCase()!=="y"&&c.toLowerCase()!=="yes"&&(console.error("Aborted."),process.exit(0))}else e.flags.yes||($(`File "${o}" already exists. Use --force to overwrite.`),process.exit(1))}catch{}}let{writeFile:a}=await import("fs/promises");await a(o,JSON.stringify(i,null,2)+`
|
|
873
|
+
`,"utf-8"),e.flags.json?console.log(JSON.stringify({exported:!0,path:o,bundle:i},null,2)):console.error(u.green(`Exported to ${o}`));break}default:$(`Unknown subcommand: "${t}". Use: create, install, list, show, remove, modify, or export`),console.error('Run "asm bundle --help" for usage.'),process.exit(2)}}async function Gk(e){if(e.flags.help){tk();return}let t=e.flags.machine?Ye():void 0,s=performance.now(),i=e.subcommand||".";try{let n=await Hu({path:i,dryRun:e.flags.dryRun,force:e.flags.force,yes:e.flags.yes});if(e.flags.machine){t?.(),n.success||(console.log(te("publish",ee.PUBLISH_FAILED,n.error||"Publish failed",s,{manifest:n.manifest,security_verdict:n.securityVerdict,fallback:n.fallback??!1})),process.exit(1)),console.log(Q("publish",{manifest:n.manifest,pr_url:n.prUrl,status:n.securityVerdict},s));return}if(e.flags.json){console.log(JSON.stringify({success:n.success,manifest:n.manifest,pr_url:n.prUrl,error:n.error,security_verdict:n.securityVerdict},null,2)),n.success||process.exit(1);return}if(n.success||($(n.error||"Publish failed."),process.exit(1)),n.fallback){console.log(u.yellow("Manifest generated (gh CLI unavailable):")),console.log(Wu(n));return}if(e.flags.dryRun){console.error(u.dim(`Dry run \u2014 no PR created.
|
|
874
|
+
`)),console.log(JSON.stringify(n.manifest,null,2));return}n.prUrl&&(console.error(u.green("Published successfully!")),console.error(""),console.error(` PR: ${n.prUrl}`),console.error(` Manifest: manifests/${n.manifest?.author}/${n.manifest?.name}.json`),console.error(` Security: ${n.securityVerdict}`),console.error(""),console.error(u.dim("The registry maintainers will review your submission.")))}catch(n){let r={success:!1,manifest:null,prUrl:null,error:n.message,securityVerdict:"pass",securityReport:{scannedAt:new Date().toISOString(),skillName:"",skillPath:"",source:null,codeScans:[],permissions:[],totalFiles:0,totalLines:0,verdict:"safe",verdictReason:""}};e.flags.machine&&(t?.(),console.log(te("publish",ee.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 Yk(e){if(e.flags.help){sk();return}let t=e.flags.machine?Ye():void 0,s=performance.now();try{let i=await zr();if(e.flags.machine){t?.();let r=i.entries.map(o=>({name:o.name,installed_commit:o.installedCommit,latest_commit:o.latestCommit,source:o.sourceType,status:o.status}));console.log(Q("outdated",r,s));return}if(e.flags.json){console.log(ed(i));return}let n=!e.flags.noColor&&process.stdout.isTTY!==!1;console.log(Zu(i,n)),i.outdatedCount>0&&(process.exitCode=1)}catch(i){e.flags.machine&&(t?.(),console.log(te("outdated",ee.UNKNOWN_ERROR,i.message,s)),process.exit(1)),$(i.message),process.exit(1)}}async function zk(e){if(e.flags.help){ik();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 Xu(i.length>0?i:null,e.flags.yes);if(e.flags.machine){t?.();let o=n.results.map(a=>({name:a.name,status:a.status,reason:a.reason||null,old_commit:a.oldCommit||null,new_commit:a.newCommit||null,security_verdict:a.securityVerdict||null}));console.log(Q("update",o,s));return}if(e.flags.json){console.log(td(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(te("update",ee.UNKNOWN_ERROR,n.message,s)),process.exit(1)),$(n.message),process.exit(1)}}async function ef(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&&po(!0),t.flags.version){console.log(`asm ${Vi}`);let s=await Ei();if(t.flags.verbose&&s.resolved&&(console.log(` path: ${s.resolved.path}`),s.resolved.realPath!==s.resolved.path&&console.log(` real: ${s.resolved.realPath}`)),s.shadowed.length>0&&s.resolved){console.error(""),console.error(u.yellow(`Warning: ${s.shadowed.length+1} \`asm\` binaries on PATH \u2014 you may be running a shadowed install.`)),console.error(` resolved: ${s.resolved.path}`);for(let i of s.shadowed)console.error(` shadowed: ${i.path}`);console.error(u.dim(" Remove the stale global install (npm uninstall -g agent-skill-manager) and keep only one.")),console.error(u.dim(" See: https://github.com/luongnv89/asm#troubleshooting"))}return}if(!t.command&&t.flags.help){Yv();return}if(t.command)switch(t.command){case"list":await rk(t);break;case"search":await ok(t);break;case"inspect":await ak(t);break;case"uninstall":await lk(t);break;case"disable":await dk(t);break;case"enable":await fk(t);break;case"audit":await pk(t);break;case"install":await $k(t);break;case"config":await bk(t);break;case"export":await Ek(t);break;case"import":await Ak(t);break;case"init":await Nk(t);break;case"stats":await Rk(t);break;case"link":await Kk(t);break;case"index":await Jk(t);break;case"bundle":await Wk(t);break;case"publish":await Gk(t);break;case"outdated":await Yk(t);break;case"update":await zk(t);break;case"doctor":await Ok(t);break;case"eval":await Fk(t);break;case"eval-providers":await qk(t);break;default:$(`Unknown command: "${t.command}"`),console.error('Run "asm --help" for usage.'),process.exit(2)}}function tf(e){let t=e.slice(2);if(t.length===0)return!1;let s=["list","search","inspect","uninstall","audit","config","install","export","import","init","stats","link","index","bundle","publish","outdated","update","doctor","eval","eval-providers","disable","enable"],i=t[0];return!!(s.includes(i)||i==="--help"||i==="-h"||i==="--version"||i==="-v"||i.startsWith("-")||i.length>0)}if(tf(process.argv))await ef(process.argv);else{let{main:e}=await import("./src-TIH4UJL5.js");await e().catch(t=>{console.error("Fatal error:",t),process.exit(1)})}
|