cligr 1.0.9 → 1.0.10

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 CHANGED
@@ -31,6 +31,7 @@ Example config:
31
31
  tools:
32
32
  kubefwd:
33
33
  cmd: kubectl port-forward $1 $2:$3
34
+ restart: yes
34
35
 
35
36
  groups:
36
37
  myapp:
@@ -60,6 +61,8 @@ cligr groups -v # List groups with details
60
61
 
61
62
  ## Restart Policies
62
63
 
64
+ Restart can be set on a **tool** (as a default) or on a **group** (to override the tool default).
65
+
63
66
  - `yes` - Always restart on exit
64
67
  - `no` - Never restart
65
68
  - `unless-stopped` - Restart unless killed by cligr
package/dist/index.js CHANGED
@@ -1,44 +1,44 @@
1
1
  #!/usr/bin/env node
2
- import Q from"fs";import Pn from"os";import X from"path";function Ke(e){return typeof e>"u"||e===null}function Yn(e){return typeof e=="object"&&e!==null}function Un(e){return Array.isArray(e)?e:Ke(e)?[]:[e]}function Kn(e,n){var r,i,o,l;if(n)for(l=Object.keys(n),r=0,i=l.length;r<i;r+=1)o=l[r],e[o]=n[o];return e}function Wn(e,n){var r="",i;for(i=0;i<n;i+=1)r+=e;return r}function zn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Jn=Ke,qn=Yn,Qn=Un,Xn=Wn,Vn=zn,Zn=Kn,A={isNothing:Jn,isObject:qn,toArray:Qn,repeat:Xn,isNegativeZero:Vn,extend:Zn};function We(e,n){var r="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(r+=`
3
-
4
- `+e.mark.snippet),i+" "+r):i}function W(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=We(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}W.prototype=Object.create(Error.prototype);W.prototype.constructor=W;W.prototype.toString=function(n){return this.name+": "+We(this,n)};var b=W;function pe(e,n,r,i,o){var l="",t="",a=Math.floor(o/2)-1;return i-n>a&&(l=" ... ",n=i-a+l.length),r-i>a&&(t=" ...",r=i+a-t.length),{str:l+e.slice(n,r).replace(/\t/g,"\u2192")+t,pos:i-n+l.length}}function de(e,n){return A.repeat(" ",n-e.length)+e}function er(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var r=/\r?\n|\r|\0/g,i=[0],o=[],l,t=-1;l=r.exec(e.buffer);)o.push(l.index),i.push(l.index+l[0].length),e.position<=l.index&&t<0&&(t=i.length-2);t<0&&(t=i.length-1);var a="",c,u,f=Math.min(e.line+n.linesAfter,o.length).toString().length,s=n.maxLength-(n.indent+f+3);for(c=1;c<=n.linesBefore&&!(t-c<0);c++)u=pe(e.buffer,i[t-c],o[t-c],e.position-(i[t]-i[t-c]),s),a=A.repeat(" ",n.indent)+de((e.line-c+1).toString(),f)+" | "+u.str+`
5
- `+a;for(u=pe(e.buffer,i[t],o[t],e.position,s),a+=A.repeat(" ",n.indent)+de((e.line+1).toString(),f)+" | "+u.str+`
6
- `,a+=A.repeat("-",n.indent+f+3+u.pos)+`^
7
- `,c=1;c<=n.linesAfter&&!(t+c>=o.length);c++)u=pe(e.buffer,i[t+c],o[t+c],e.position-(i[t]-i[t+c]),s),a+=A.repeat(" ",n.indent)+de((e.line+c+1).toString(),f)+" | "+u.str+`
8
- `;return a.replace(/\n$/,"")}var nr=er,rr=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],ir=["scalar","sequence","mapping"];function or(e){var n={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(i){n[String(i)]=r})}),n}function tr(e,n){if(n=n||{},Object.keys(n).forEach(function(r){if(rr.indexOf(r)===-1)throw new b('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(r){return r},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=or(n.styleAliases||null),ir.indexOf(this.kind)===-1)throw new b('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var C=tr;function ke(e,n){var r=[];return e[n].forEach(function(i){var o=r.length;r.forEach(function(l,t){l.tag===i.tag&&l.kind===i.kind&&l.multi===i.multi&&(o=t)}),r[o]=i}),r}function lr(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,r;function i(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(n=0,r=arguments.length;n<r;n+=1)arguments[n].forEach(i);return e}function me(e){return this.extend(e)}me.prototype.extend=function(n){var r=[],i=[];if(n instanceof C)i.push(n);else if(Array.isArray(n))i=i.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(r=r.concat(n.implicit)),n.explicit&&(i=i.concat(n.explicit));else throw new b("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");r.forEach(function(l){if(!(l instanceof C))throw new b("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(l.loadKind&&l.loadKind!=="scalar")throw new b("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(l.multi)throw new b("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),i.forEach(function(l){if(!(l instanceof C))throw new b("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(me.prototype);return o.implicit=(this.implicit||[]).concat(r),o.explicit=(this.explicit||[]).concat(i),o.compiledImplicit=ke(o,"implicit"),o.compiledExplicit=ke(o,"explicit"),o.compiledTypeMap=lr(o.compiledImplicit,o.compiledExplicit),o};var ze=me,Je=new C("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),qe=new C("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Qe=new C("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Xe=new ze({explicit:[Je,qe,Qe]});function ar(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function cr(){return null}function sr(e){return e===null}var Ve=new C("tag:yaml.org,2002:null",{kind:"scalar",resolve:ar,construct:cr,predicate:sr,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function ur(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function fr(e){return e==="true"||e==="True"||e==="TRUE"}function pr(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Ze=new C("tag:yaml.org,2002:bool",{kind:"scalar",resolve:ur,construct:fr,predicate:pr,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function dr(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function hr(e){return 48<=e&&e<=55}function mr(e){return 48<=e&&e<=57}function gr(e){if(e===null)return!1;var n=e.length,r=0,i=!1,o;if(!n)return!1;if(o=e[r],(o==="-"||o==="+")&&(o=e[++r]),o==="0"){if(r+1===n)return!0;if(o=e[++r],o==="b"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(o!=="0"&&o!=="1")return!1;i=!0}return i&&o!=="_"}if(o==="x"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(!dr(e.charCodeAt(r)))return!1;i=!0}return i&&o!=="_"}if(o==="o"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(!hr(e.charCodeAt(r)))return!1;i=!0}return i&&o!=="_"}}if(o==="_")return!1;for(;r<n;r++)if(o=e[r],o!=="_"){if(!mr(e.charCodeAt(r)))return!1;i=!0}return!(!i||o==="_")}function xr(e){var n=e,r=1,i;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),i=n[0],(i==="-"||i==="+")&&(i==="-"&&(r=-1),n=n.slice(1),i=n[0]),n==="0")return 0;if(i==="0"){if(n[1]==="b")return r*parseInt(n.slice(2),2);if(n[1]==="x")return r*parseInt(n.slice(2),16);if(n[1]==="o")return r*parseInt(n.slice(2),8)}return r*parseInt(n,10)}function vr(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!A.isNegativeZero(e)}var en=new C("tag:yaml.org,2002:int",{kind:"scalar",resolve:gr,construct:xr,predicate:vr,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),yr=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function wr(e){return!(e===null||!yr.test(e)||e[e.length-1]==="_")}function Ar(e){var n,r;return n=e.replace(/_/g,"").toLowerCase(),r=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:r*parseFloat(n,10)}var Cr=/^[-+]?[0-9]+e/;function Sr(e,n){var r;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(A.isNegativeZero(e))return"-0.0";return r=e.toString(10),Cr.test(r)?r.replace("e",".e"):r}function Er(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||A.isNegativeZero(e))}var nn=new C("tag:yaml.org,2002:float",{kind:"scalar",resolve:wr,construct:Ar,predicate:Er,represent:Sr,defaultStyle:"lowercase"}),rn=Xe.extend({implicit:[Ve,Ze,en,nn]}),on=rn,tn=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),ln=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function br(e){return e===null?!1:tn.exec(e)!==null||ln.exec(e)!==null}function Tr(e){var n,r,i,o,l,t,a,c=0,u=null,f,s,p;if(n=tn.exec(e),n===null&&(n=ln.exec(e)),n===null)throw new Error("Date resolve error");if(r=+n[1],i=+n[2]-1,o=+n[3],!n[4])return new Date(Date.UTC(r,i,o));if(l=+n[4],t=+n[5],a=+n[6],n[7]){for(c=n[7].slice(0,3);c.length<3;)c+="0";c=+c}return n[9]&&(f=+n[10],s=+(n[11]||0),u=(f*60+s)*6e4,n[9]==="-"&&(u=-u)),p=new Date(Date.UTC(r,i,o,l,t,a,c)),u&&p.setTime(p.getTime()-u),p}function Ir(e){return e.toISOString()}var an=new C("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:br,construct:Tr,instanceOf:Date,represent:Ir});function Or(e){return e==="<<"||e===null}var cn=new C("tag:yaml.org,2002:merge",{kind:"scalar",resolve:Or}),we=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
9
- \r`;function _r(e){if(e===null)return!1;var n,r,i=0,o=e.length,l=we;for(r=0;r<o;r++)if(n=l.indexOf(e.charAt(r)),!(n>64)){if(n<0)return!1;i+=6}return i%8===0}function kr(e){var n,r,i=e.replace(/[\r\n=]/g,""),o=i.length,l=we,t=0,a=[];for(n=0;n<o;n++)n%4===0&&n&&(a.push(t>>16&255),a.push(t>>8&255),a.push(t&255)),t=t<<6|l.indexOf(i.charAt(n));return r=o%4*6,r===0?(a.push(t>>16&255),a.push(t>>8&255),a.push(t&255)):r===18?(a.push(t>>10&255),a.push(t>>2&255)):r===12&&a.push(t>>4&255),new Uint8Array(a)}function Fr(e){var n="",r=0,i,o,l=e.length,t=we;for(i=0;i<l;i++)i%3===0&&i&&(n+=t[r>>18&63],n+=t[r>>12&63],n+=t[r>>6&63],n+=t[r&63]),r=(r<<8)+e[i];return o=l%3,o===0?(n+=t[r>>18&63],n+=t[r>>12&63],n+=t[r>>6&63],n+=t[r&63]):o===2?(n+=t[r>>10&63],n+=t[r>>4&63],n+=t[r<<2&63],n+=t[64]):o===1&&(n+=t[r>>2&63],n+=t[r<<4&63],n+=t[64],n+=t[64]),n}function Lr(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var sn=new C("tag:yaml.org,2002:binary",{kind:"scalar",resolve:_r,construct:kr,predicate:Lr,represent:Fr}),Nr=Object.prototype.hasOwnProperty,Pr=Object.prototype.toString;function Rr(e){if(e===null)return!0;var n=[],r,i,o,l,t,a=e;for(r=0,i=a.length;r<i;r+=1){if(o=a[r],t=!1,Pr.call(o)!=="[object Object]")return!1;for(l in o)if(Nr.call(o,l))if(!t)t=!0;else return!1;if(!t)return!1;if(n.indexOf(l)===-1)n.push(l);else return!1}return!0}function Dr(e){return e!==null?e:[]}var un=new C("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Rr,construct:Dr}),Mr=Object.prototype.toString;function $r(e){if(e===null)return!0;var n,r,i,o,l,t=e;for(l=new Array(t.length),n=0,r=t.length;n<r;n+=1){if(i=t[n],Mr.call(i)!=="[object Object]"||(o=Object.keys(i),o.length!==1))return!1;l[n]=[o[0],i[o[0]]]}return!0}function jr(e){if(e===null)return[];var n,r,i,o,l,t=e;for(l=new Array(t.length),n=0,r=t.length;n<r;n+=1)i=t[n],o=Object.keys(i),l[n]=[o[0],i[o[0]]];return l}var fn=new C("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:$r,construct:jr}),Hr=Object.prototype.hasOwnProperty;function Gr(e){if(e===null)return!0;var n,r=e;for(n in r)if(Hr.call(r,n)&&r[n]!==null)return!1;return!0}function Br(e){return e!==null?e:{}}var pn=new C("tag:yaml.org,2002:set",{kind:"mapping",resolve:Gr,construct:Br}),Ae=on.extend({implicit:[an,cn],explicit:[sn,un,fn,pn]}),L=Object.prototype.hasOwnProperty,V=1,dn=2,hn=3,Z=4,he=1,Yr=2,Fe=3,Ur=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Kr=/[\x85\u2028\u2029]/,Wr=/[,\[\]\{\}]/,mn=/^(?:!|!!|![a-z\-]+!)$/i,gn=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Le(e){return Object.prototype.toString.call(e)}function I(e){return e===10||e===13}function R(e){return e===9||e===32}function T(e){return e===9||e===32||e===10||e===13}function j(e){return e===44||e===91||e===93||e===123||e===125}function zr(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function Jr(e){return e===120?2:e===117?4:e===85?8:0}function qr(e){return 48<=e&&e<=57?e-48:-1}function Ne(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
10
- `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function Qr(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function xn(e,n,r){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:r}):e[n]=r}var vn=new Array(256),yn=new Array(256);for(P=0;P<256;P++)vn[P]=Ne(P)?1:0,yn[P]=Ne(P);var P;function Xr(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||Ae,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function wn(e,n){var r={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return r.snippet=nr(r),new b(n,r)}function h(e,n){throw wn(e,n)}function ee(e,n){e.onWarning&&e.onWarning.call(null,wn(e,n))}var Pe={YAML:function(n,r,i){var o,l,t;n.version!==null&&h(n,"duplication of %YAML directive"),i.length!==1&&h(n,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),o===null&&h(n,"ill-formed argument of the YAML directive"),l=parseInt(o[1],10),t=parseInt(o[2],10),l!==1&&h(n,"unacceptable YAML version of the document"),n.version=i[0],n.checkLineBreaks=t<2,t!==1&&t!==2&&ee(n,"unsupported YAML version of the document")},TAG:function(n,r,i){var o,l;i.length!==2&&h(n,"TAG directive accepts exactly two arguments"),o=i[0],l=i[1],mn.test(o)||h(n,"ill-formed tag handle (first argument) of the TAG directive"),L.call(n.tagMap,o)&&h(n,'there is a previously declared suffix for "'+o+'" tag handle'),gn.test(l)||h(n,"ill-formed tag prefix (second argument) of the TAG directive");try{l=decodeURIComponent(l)}catch{h(n,"tag prefix is malformed: "+l)}n.tagMap[o]=l}};function F(e,n,r,i){var o,l,t,a;if(n<r){if(a=e.input.slice(n,r),i)for(o=0,l=a.length;o<l;o+=1)t=a.charCodeAt(o),t===9||32<=t&&t<=1114111||h(e,"expected valid JSON character");else Ur.test(a)&&h(e,"the stream contains non-printable characters");e.result+=a}}function Re(e,n,r,i){var o,l,t,a;for(A.isObject(r)||h(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(r),t=0,a=o.length;t<a;t+=1)l=o[t],L.call(n,l)||(xn(n,l,r[l]),i[l]=!0)}function H(e,n,r,i,o,l,t,a,c){var u,f;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),u=0,f=o.length;u<f;u+=1)Array.isArray(o[u])&&h(e,"nested arrays are not supported inside keys"),typeof o=="object"&&Le(o[u])==="[object Object]"&&(o[u]="[object Object]");if(typeof o=="object"&&Le(o)==="[object Object]"&&(o="[object Object]"),o=String(o),n===null&&(n={}),i==="tag:yaml.org,2002:merge")if(Array.isArray(l))for(u=0,f=l.length;u<f;u+=1)Re(e,n,l[u],r);else Re(e,n,l,r);else!e.json&&!L.call(r,o)&&L.call(n,o)&&(e.line=t||e.line,e.lineStart=a||e.lineStart,e.position=c||e.position,h(e,"duplicated mapping key")),xn(n,o,l),delete r[o];return n}function Ce(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):h(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function w(e,n,r){for(var i=0,o=e.input.charCodeAt(e.position);o!==0;){for(;R(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(n&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(I(o))for(Ce(e),o=e.input.charCodeAt(e.position),i++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return r!==-1&&i!==0&&e.lineIndent<r&&ee(e,"deficient indentation"),i}function ie(e){var n=e.position,r;return r=e.input.charCodeAt(n),!!((r===45||r===46)&&r===e.input.charCodeAt(n+1)&&r===e.input.charCodeAt(n+2)&&(n+=3,r=e.input.charCodeAt(n),r===0||T(r)))}function Se(e,n){n===1?e.result+=" ":n>1&&(e.result+=A.repeat(`
11
- `,n-1))}function Vr(e,n,r){var i,o,l,t,a,c,u,f,s=e.kind,p=e.result,d;if(d=e.input.charCodeAt(e.position),T(d)||j(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96||(d===63||d===45)&&(o=e.input.charCodeAt(e.position+1),T(o)||r&&j(o)))return!1;for(e.kind="scalar",e.result="",l=t=e.position,a=!1;d!==0;){if(d===58){if(o=e.input.charCodeAt(e.position+1),T(o)||r&&j(o))break}else if(d===35){if(i=e.input.charCodeAt(e.position-1),T(i))break}else{if(e.position===e.lineStart&&ie(e)||r&&j(d))break;if(I(d))if(c=e.line,u=e.lineStart,f=e.lineIndent,w(e,!1,-1),e.lineIndent>=n){a=!0,d=e.input.charCodeAt(e.position);continue}else{e.position=t,e.line=c,e.lineStart=u,e.lineIndent=f;break}}a&&(F(e,l,t,!1),Se(e,e.line-c),l=t=e.position,a=!1),R(d)||(t=e.position+1),d=e.input.charCodeAt(++e.position)}return F(e,l,t,!1),e.result?!0:(e.kind=s,e.result=p,!1)}function Zr(e,n){var r,i,o;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,i=o=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(F(e,i,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)i=e.position,e.position++,o=e.position;else return!0;else I(r)?(F(e,i,o,!0),Se(e,w(e,!1,n)),i=o=e.position):e.position===e.lineStart&&ie(e)?h(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);h(e,"unexpected end of the stream within a single quoted scalar")}function ei(e,n){var r,i,o,l,t,a;if(a=e.input.charCodeAt(e.position),a!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;(a=e.input.charCodeAt(e.position))!==0;){if(a===34)return F(e,r,e.position,!0),e.position++,!0;if(a===92){if(F(e,r,e.position,!0),a=e.input.charCodeAt(++e.position),I(a))w(e,!1,n);else if(a<256&&vn[a])e.result+=yn[a],e.position++;else if((t=Jr(a))>0){for(o=t,l=0;o>0;o--)a=e.input.charCodeAt(++e.position),(t=zr(a))>=0?l=(l<<4)+t:h(e,"expected hexadecimal character");e.result+=Qr(l),e.position++}else h(e,"unknown escape sequence");r=i=e.position}else I(a)?(F(e,r,i,!0),Se(e,w(e,!1,n)),r=i=e.position):e.position===e.lineStart&&ie(e)?h(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}h(e,"unexpected end of the stream within a double quoted scalar")}function ni(e,n){var r=!0,i,o,l,t=e.tag,a,c=e.anchor,u,f,s,p,d,x=Object.create(null),m,v,y,g;if(g=e.input.charCodeAt(e.position),g===91)f=93,d=!1,a=[];else if(g===123)f=125,d=!0,a={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=a),g=e.input.charCodeAt(++e.position);g!==0;){if(w(e,!0,n),g=e.input.charCodeAt(e.position),g===f)return e.position++,e.tag=t,e.anchor=c,e.kind=d?"mapping":"sequence",e.result=a,!0;r?g===44&&h(e,"expected the node content, but found ','"):h(e,"missed comma between flow collection entries"),v=m=y=null,s=p=!1,g===63&&(u=e.input.charCodeAt(e.position+1),T(u)&&(s=p=!0,e.position++,w(e,!0,n))),i=e.line,o=e.lineStart,l=e.position,G(e,n,V,!1,!0),v=e.tag,m=e.result,w(e,!0,n),g=e.input.charCodeAt(e.position),(p||e.line===i)&&g===58&&(s=!0,g=e.input.charCodeAt(++e.position),w(e,!0,n),G(e,n,V,!1,!0),y=e.result),d?H(e,a,x,v,m,y,i,o,l):s?a.push(H(e,null,x,v,m,y,i,o,l)):a.push(m),w(e,!0,n),g=e.input.charCodeAt(e.position),g===44?(r=!0,g=e.input.charCodeAt(++e.position)):r=!1}h(e,"unexpected end of the stream within a flow collection")}function ri(e,n){var r,i,o=he,l=!1,t=!1,a=n,c=0,u=!1,f,s;if(s=e.input.charCodeAt(e.position),s===124)i=!1;else if(s===62)i=!0;else return!1;for(e.kind="scalar",e.result="";s!==0;)if(s=e.input.charCodeAt(++e.position),s===43||s===45)he===o?o=s===43?Fe:Yr:h(e,"repeat of a chomping mode identifier");else if((f=qr(s))>=0)f===0?h(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):t?h(e,"repeat of an indentation width identifier"):(a=n+f-1,t=!0);else break;if(R(s)){do s=e.input.charCodeAt(++e.position);while(R(s));if(s===35)do s=e.input.charCodeAt(++e.position);while(!I(s)&&s!==0)}for(;s!==0;){for(Ce(e),e.lineIndent=0,s=e.input.charCodeAt(e.position);(!t||e.lineIndent<a)&&s===32;)e.lineIndent++,s=e.input.charCodeAt(++e.position);if(!t&&e.lineIndent>a&&(a=e.lineIndent),I(s)){c++;continue}if(e.lineIndent<a){o===Fe?e.result+=A.repeat(`
12
- `,l?1+c:c):o===he&&l&&(e.result+=`
13
- `);break}for(i?R(s)?(u=!0,e.result+=A.repeat(`
14
- `,l?1+c:c)):u?(u=!1,e.result+=A.repeat(`
15
- `,c+1)):c===0?l&&(e.result+=" "):e.result+=A.repeat(`
16
- `,c):e.result+=A.repeat(`
17
- `,l?1+c:c),l=!0,t=!0,c=0,r=e.position;!I(s)&&s!==0;)s=e.input.charCodeAt(++e.position);F(e,r,e.position,!1)}return!0}function De(e,n){var r,i=e.tag,o=e.anchor,l=[],t,a=!1,c;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),c=e.input.charCodeAt(e.position);c!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,h(e,"tab characters must not be used in indentation")),!(c!==45||(t=e.input.charCodeAt(e.position+1),!T(t))));){if(a=!0,e.position++,w(e,!0,-1)&&e.lineIndent<=n){l.push(null),c=e.input.charCodeAt(e.position);continue}if(r=e.line,G(e,n,hn,!1,!0),l.push(e.result),w(e,!0,-1),c=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>n)&&c!==0)h(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return a?(e.tag=i,e.anchor=o,e.kind="sequence",e.result=l,!0):!1}function ii(e,n,r){var i,o,l,t,a,c,u=e.tag,f=e.anchor,s={},p=Object.create(null),d=null,x=null,m=null,v=!1,y=!1,g;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),g=e.input.charCodeAt(e.position);g!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,h(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),l=e.line,(g===63||g===58)&&T(i))g===63?(v&&(H(e,s,p,d,x,null,t,a,c),d=x=m=null),y=!0,v=!0,o=!0):v?(v=!1,o=!0):h(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,g=i;else{if(t=e.line,a=e.lineStart,c=e.position,!G(e,r,dn,!1,!0))break;if(e.line===l){for(g=e.input.charCodeAt(e.position);R(g);)g=e.input.charCodeAt(++e.position);if(g===58)g=e.input.charCodeAt(++e.position),T(g)||h(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(H(e,s,p,d,x,null,t,a,c),d=x=m=null),y=!0,v=!1,o=!1,d=e.tag,x=e.result;else if(y)h(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=f,!0}else if(y)h(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=f,!0}if((e.line===l||e.lineIndent>n)&&(v&&(t=e.line,a=e.lineStart,c=e.position),G(e,n,Z,!0,o)&&(v?x=e.result:m=e.result),v||(H(e,s,p,d,x,m,t,a,c),d=x=m=null),w(e,!0,-1),g=e.input.charCodeAt(e.position)),(e.line===l||e.lineIndent>n)&&g!==0)h(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return v&&H(e,s,p,d,x,null,t,a,c),y&&(e.tag=u,e.anchor=f,e.kind="mapping",e.result=s),y}function oi(e){var n,r=!1,i=!1,o,l,t;if(t=e.input.charCodeAt(e.position),t!==33)return!1;if(e.tag!==null&&h(e,"duplication of a tag property"),t=e.input.charCodeAt(++e.position),t===60?(r=!0,t=e.input.charCodeAt(++e.position)):t===33?(i=!0,o="!!",t=e.input.charCodeAt(++e.position)):o="!",n=e.position,r){do t=e.input.charCodeAt(++e.position);while(t!==0&&t!==62);e.position<e.length?(l=e.input.slice(n,e.position),t=e.input.charCodeAt(++e.position)):h(e,"unexpected end of the stream within a verbatim tag")}else{for(;t!==0&&!T(t);)t===33&&(i?h(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(n-1,e.position+1),mn.test(o)||h(e,"named tag handle cannot contain such characters"),i=!0,n=e.position+1)),t=e.input.charCodeAt(++e.position);l=e.input.slice(n,e.position),Wr.test(l)&&h(e,"tag suffix cannot contain flow indicator characters")}l&&!gn.test(l)&&h(e,"tag name cannot contain such characters: "+l);try{l=decodeURIComponent(l)}catch{h(e,"tag name is malformed: "+l)}return r?e.tag=l:L.call(e.tagMap,o)?e.tag=e.tagMap[o]+l:o==="!"?e.tag="!"+l:o==="!!"?e.tag="tag:yaml.org,2002:"+l:h(e,'undeclared tag handle "'+o+'"'),!0}function ti(e){var n,r;if(r=e.input.charCodeAt(e.position),r!==38)return!1;for(e.anchor!==null&&h(e,"duplication of an anchor property"),r=e.input.charCodeAt(++e.position),n=e.position;r!==0&&!T(r)&&!j(r);)r=e.input.charCodeAt(++e.position);return e.position===n&&h(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function li(e){var n,r,i;if(i=e.input.charCodeAt(e.position),i!==42)return!1;for(i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!T(i)&&!j(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&h(e,"name of an alias node must contain at least one character"),r=e.input.slice(n,e.position),L.call(e.anchorMap,r)||h(e,'unidentified alias "'+r+'"'),e.result=e.anchorMap[r],w(e,!0,-1),!0}function G(e,n,r,i,o){var l,t,a,c=1,u=!1,f=!1,s,p,d,x,m,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,l=t=a=Z===r||hn===r,i&&w(e,!0,-1)&&(u=!0,e.lineIndent>n?c=1:e.lineIndent===n?c=0:e.lineIndent<n&&(c=-1)),c===1)for(;oi(e)||ti(e);)w(e,!0,-1)?(u=!0,a=l,e.lineIndent>n?c=1:e.lineIndent===n?c=0:e.lineIndent<n&&(c=-1)):a=!1;if(a&&(a=u||o),(c===1||Z===r)&&(V===r||dn===r?m=n:m=n+1,v=e.position-e.lineStart,c===1?a&&(De(e,v)||ii(e,v,m))||ni(e,m)?f=!0:(t&&ri(e,m)||Zr(e,m)||ei(e,m)?f=!0:li(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&h(e,"alias node should not have any properties")):Vr(e,m,V===r)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):c===0&&(f=a&&De(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&h(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),s=0,p=e.implicitTypes.length;s<p;s+=1)if(x=e.implicitTypes[s],x.resolve(e.result)){e.result=x.construct(e.result),e.tag=x.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(L.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,d=e.typeMap.multi[e.kind||"fallback"],s=0,p=d.length;s<p;s+=1)if(e.tag.slice(0,d[s].tag.length)===d[s].tag){x=d[s];break}x||h(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&h(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+x.kind+'", not "'+e.kind+'"'),x.resolve(e.result,e.tag)?(e.result=x.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):h(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function ai(e){var n=e.position,r,i,o,l=!1,t;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(t=e.input.charCodeAt(e.position))!==0&&(w(e,!0,-1),t=e.input.charCodeAt(e.position),!(e.lineIndent>0||t!==37));){for(l=!0,t=e.input.charCodeAt(++e.position),r=e.position;t!==0&&!T(t);)t=e.input.charCodeAt(++e.position);for(i=e.input.slice(r,e.position),o=[],i.length<1&&h(e,"directive name must not be less than one character in length");t!==0;){for(;R(t);)t=e.input.charCodeAt(++e.position);if(t===35){do t=e.input.charCodeAt(++e.position);while(t!==0&&!I(t));break}if(I(t))break;for(r=e.position;t!==0&&!T(t);)t=e.input.charCodeAt(++e.position);o.push(e.input.slice(r,e.position))}t!==0&&Ce(e),L.call(Pe,i)?Pe[i](e,i,o):ee(e,'unknown document directive "'+i+'"')}if(w(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,w(e,!0,-1)):l&&h(e,"directives end mark is expected"),G(e,e.lineIndent-1,Z,!1,!0),w(e,!0,-1),e.checkLineBreaks&&Kr.test(e.input.slice(n,e.position))&&ee(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ie(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,w(e,!0,-1));return}if(e.position<e.length-1)h(e,"end of the stream or a document separator is expected");else return}function An(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
18
- `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new Xr(e,n),i=e.indexOf("\0");for(i!==-1&&(r.position=i,h(r,"null byte is not allowed in input")),r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)ai(r);return r.documents}function ci(e,n,r){n!==null&&typeof n=="object"&&typeof r>"u"&&(r=n,n=null);var i=An(e,r);if(typeof n!="function")return i;for(var o=0,l=i.length;o<l;o+=1)n(i[o])}function si(e,n){var r=An(e,n);if(r.length!==0){if(r.length===1)return r[0];throw new b("expected a single document in the stream, but found more")}}var ui=ci,fi=si,Cn={loadAll:ui,load:fi},Sn=Object.prototype.toString,En=Object.prototype.hasOwnProperty,Ee=65279,pi=9,z=10,di=13,hi=32,mi=33,gi=34,ge=35,xi=37,vi=38,yi=39,wi=42,bn=44,Ai=45,ne=58,Ci=61,Si=62,Ei=63,bi=64,Tn=91,In=93,Ti=96,On=123,Ii=124,_n=125,S={};S[0]="\\0";S[7]="\\a";S[8]="\\b";S[9]="\\t";S[10]="\\n";S[11]="\\v";S[12]="\\f";S[13]="\\r";S[27]="\\e";S[34]='\\"';S[92]="\\\\";S[133]="\\N";S[160]="\\_";S[8232]="\\L";S[8233]="\\P";var Oi=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],_i=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function ki(e,n){var r,i,o,l,t,a,c;if(n===null)return{};for(r={},i=Object.keys(n),o=0,l=i.length;o<l;o+=1)t=i[o],a=String(n[t]),t.slice(0,2)==="!!"&&(t="tag:yaml.org,2002:"+t.slice(2)),c=e.compiledTypeMap.fallback[t],c&&En.call(c.styleAliases,a)&&(a=c.styleAliases[a]),r[t]=a;return r}function Fi(e){var n,r,i;if(n=e.toString(16).toUpperCase(),e<=255)r="x",i=2;else if(e<=65535)r="u",i=4;else if(e<=4294967295)r="U",i=8;else throw new b("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+r+A.repeat("0",i-n.length)+n}var Li=1,J=2;function Ni(e){this.schema=e.schema||Ae,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=A.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=ki(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?J:Li,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Me(e,n){for(var r=A.repeat(" ",n),i=0,o=-1,l="",t,a=e.length;i<a;)o=e.indexOf(`
19
- `,i),o===-1?(t=e.slice(i),i=a):(t=e.slice(i,o+1),i=o+1),t.length&&t!==`
2
+ import Q from"fs";import Nn from"os";import X from"path";function Ke(e){return typeof e>"u"||e===null}function Yn(e){return typeof e=="object"&&e!==null}function Un(e){return Array.isArray(e)?e:Ke(e)?[]:[e]}function Kn(e,n){var r,i,o,l;if(n)for(l=Object.keys(n),r=0,i=l.length;r<i;r+=1)o=l[r],e[o]=n[o];return e}function Wn(e,n){var r="",i;for(i=0;i<n;i+=1)r+=e;return r}function zn(e){return e===0&&Number.NEGATIVE_INFINITY===1/e}var Jn=Ke,qn=Yn,Qn=Un,Xn=Wn,Vn=zn,Zn=Kn,C={isNothing:Jn,isObject:qn,toArray:Qn,repeat:Xn,isNegativeZero:Vn,extend:Zn};function We(e,n){var r="",i=e.reason||"(unknown reason)";return e.mark?(e.mark.name&&(r+='in "'+e.mark.name+'" '),r+="("+(e.mark.line+1)+":"+(e.mark.column+1)+")",!n&&e.mark.snippet&&(r+=`
3
+
4
+ `+e.mark.snippet),i+" "+r):i}function W(e,n){Error.call(this),this.name="YAMLException",this.reason=e,this.mark=n,this.message=We(this,!1),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=new Error().stack||""}W.prototype=Object.create(Error.prototype);W.prototype.constructor=W;W.prototype.toString=function(n){return this.name+": "+We(this,n)};var S=W;function pe(e,n,r,i,o){var l="",t="",s=Math.floor(o/2)-1;return i-n>s&&(l=" ... ",n=i-s+l.length),r-i>s&&(t=" ...",r=i+s-t.length),{str:l+e.slice(n,r).replace(/\t/g,"\u2192")+t,pos:i-n+l.length}}function de(e,n){return C.repeat(" ",n-e.length)+e}function er(e,n){if(n=Object.create(n||null),!e.buffer)return null;n.maxLength||(n.maxLength=79),typeof n.indent!="number"&&(n.indent=1),typeof n.linesBefore!="number"&&(n.linesBefore=3),typeof n.linesAfter!="number"&&(n.linesAfter=2);for(var r=/\r?\n|\r|\0/g,i=[0],o=[],l,t=-1;l=r.exec(e.buffer);)o.push(l.index),i.push(l.index+l[0].length),e.position<=l.index&&t<0&&(t=i.length-2);t<0&&(t=i.length-1);var s="",a,u,f=Math.min(e.line+n.linesAfter,o.length).toString().length,c=n.maxLength-(n.indent+f+3);for(a=1;a<=n.linesBefore&&!(t-a<0);a++)u=pe(e.buffer,i[t-a],o[t-a],e.position-(i[t]-i[t-a]),c),s=C.repeat(" ",n.indent)+de((e.line-a+1).toString(),f)+" | "+u.str+`
5
+ `+s;for(u=pe(e.buffer,i[t],o[t],e.position,c),s+=C.repeat(" ",n.indent)+de((e.line+1).toString(),f)+" | "+u.str+`
6
+ `,s+=C.repeat("-",n.indent+f+3+u.pos)+`^
7
+ `,a=1;a<=n.linesAfter&&!(t+a>=o.length);a++)u=pe(e.buffer,i[t+a],o[t+a],e.position-(i[t]-i[t+a]),c),s+=C.repeat(" ",n.indent)+de((e.line+a+1).toString(),f)+" | "+u.str+`
8
+ `;return s.replace(/\n$/,"")}var nr=er,rr=["kind","multi","resolve","construct","instanceOf","predicate","represent","representName","defaultStyle","styleAliases"],ir=["scalar","sequence","mapping"];function or(e){var n={};return e!==null&&Object.keys(e).forEach(function(r){e[r].forEach(function(i){n[String(i)]=r})}),n}function tr(e,n){if(n=n||{},Object.keys(n).forEach(function(r){if(rr.indexOf(r)===-1)throw new S('Unknown option "'+r+'" is met in definition of "'+e+'" YAML type.')}),this.options=n,this.tag=e,this.kind=n.kind||null,this.resolve=n.resolve||function(){return!0},this.construct=n.construct||function(r){return r},this.instanceOf=n.instanceOf||null,this.predicate=n.predicate||null,this.represent=n.represent||null,this.representName=n.representName||null,this.defaultStyle=n.defaultStyle||null,this.multi=n.multi||!1,this.styleAliases=or(n.styleAliases||null),ir.indexOf(this.kind)===-1)throw new S('Unknown kind "'+this.kind+'" is specified for "'+e+'" YAML type.')}var A=tr;function _e(e,n){var r=[];return e[n].forEach(function(i){var o=r.length;r.forEach(function(l,t){l.tag===i.tag&&l.kind===i.kind&&l.multi===i.multi&&(o=t)}),r[o]=i}),r}function lr(){var e={scalar:{},sequence:{},mapping:{},fallback:{},multi:{scalar:[],sequence:[],mapping:[],fallback:[]}},n,r;function i(o){o.multi?(e.multi[o.kind].push(o),e.multi.fallback.push(o)):e[o.kind][o.tag]=e.fallback[o.tag]=o}for(n=0,r=arguments.length;n<r;n+=1)arguments[n].forEach(i);return e}function he(e){return this.extend(e)}he.prototype.extend=function(n){var r=[],i=[];if(n instanceof A)i.push(n);else if(Array.isArray(n))i=i.concat(n);else if(n&&(Array.isArray(n.implicit)||Array.isArray(n.explicit)))n.implicit&&(r=r.concat(n.implicit)),n.explicit&&(i=i.concat(n.explicit));else throw new S("Schema.extend argument should be a Type, [ Type ], or a schema definition ({ implicit: [...], explicit: [...] })");r.forEach(function(l){if(!(l instanceof A))throw new S("Specified list of YAML types (or a single Type object) contains a non-Type object.");if(l.loadKind&&l.loadKind!=="scalar")throw new S("There is a non-scalar type in the implicit list of a schema. Implicit resolving of such types is not supported.");if(l.multi)throw new S("There is a multi type in the implicit list of a schema. Multi tags can only be listed as explicit.")}),i.forEach(function(l){if(!(l instanceof A))throw new S("Specified list of YAML types (or a single Type object) contains a non-Type object.")});var o=Object.create(he.prototype);return o.implicit=(this.implicit||[]).concat(r),o.explicit=(this.explicit||[]).concat(i),o.compiledImplicit=_e(o,"implicit"),o.compiledExplicit=_e(o,"explicit"),o.compiledTypeMap=lr(o.compiledImplicit,o.compiledExplicit),o};var ze=he,Je=new A("tag:yaml.org,2002:str",{kind:"scalar",construct:function(e){return e!==null?e:""}}),qe=new A("tag:yaml.org,2002:seq",{kind:"sequence",construct:function(e){return e!==null?e:[]}}),Qe=new A("tag:yaml.org,2002:map",{kind:"mapping",construct:function(e){return e!==null?e:{}}}),Xe=new ze({explicit:[Je,qe,Qe]});function sr(e){if(e===null)return!0;var n=e.length;return n===1&&e==="~"||n===4&&(e==="null"||e==="Null"||e==="NULL")}function ar(){return null}function cr(e){return e===null}var Ve=new A("tag:yaml.org,2002:null",{kind:"scalar",resolve:sr,construct:ar,predicate:cr,represent:{canonical:function(){return"~"},lowercase:function(){return"null"},uppercase:function(){return"NULL"},camelcase:function(){return"Null"},empty:function(){return""}},defaultStyle:"lowercase"});function ur(e){if(e===null)return!1;var n=e.length;return n===4&&(e==="true"||e==="True"||e==="TRUE")||n===5&&(e==="false"||e==="False"||e==="FALSE")}function fr(e){return e==="true"||e==="True"||e==="TRUE"}function pr(e){return Object.prototype.toString.call(e)==="[object Boolean]"}var Ze=new A("tag:yaml.org,2002:bool",{kind:"scalar",resolve:ur,construct:fr,predicate:pr,represent:{lowercase:function(e){return e?"true":"false"},uppercase:function(e){return e?"TRUE":"FALSE"},camelcase:function(e){return e?"True":"False"}},defaultStyle:"lowercase"});function dr(e){return 48<=e&&e<=57||65<=e&&e<=70||97<=e&&e<=102}function mr(e){return 48<=e&&e<=55}function hr(e){return 48<=e&&e<=57}function gr(e){if(e===null)return!1;var n=e.length,r=0,i=!1,o;if(!n)return!1;if(o=e[r],(o==="-"||o==="+")&&(o=e[++r]),o==="0"){if(r+1===n)return!0;if(o=e[++r],o==="b"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(o!=="0"&&o!=="1")return!1;i=!0}return i&&o!=="_"}if(o==="x"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(!dr(e.charCodeAt(r)))return!1;i=!0}return i&&o!=="_"}if(o==="o"){for(r++;r<n;r++)if(o=e[r],o!=="_"){if(!mr(e.charCodeAt(r)))return!1;i=!0}return i&&o!=="_"}}if(o==="_")return!1;for(;r<n;r++)if(o=e[r],o!=="_"){if(!hr(e.charCodeAt(r)))return!1;i=!0}return!(!i||o==="_")}function xr(e){var n=e,r=1,i;if(n.indexOf("_")!==-1&&(n=n.replace(/_/g,"")),i=n[0],(i==="-"||i==="+")&&(i==="-"&&(r=-1),n=n.slice(1),i=n[0]),n==="0")return 0;if(i==="0"){if(n[1]==="b")return r*parseInt(n.slice(2),2);if(n[1]==="x")return r*parseInt(n.slice(2),16);if(n[1]==="o")return r*parseInt(n.slice(2),8)}return r*parseInt(n,10)}function vr(e){return Object.prototype.toString.call(e)==="[object Number]"&&e%1===0&&!C.isNegativeZero(e)}var en=new A("tag:yaml.org,2002:int",{kind:"scalar",resolve:gr,construct:xr,predicate:vr,represent:{binary:function(e){return e>=0?"0b"+e.toString(2):"-0b"+e.toString(2).slice(1)},octal:function(e){return e>=0?"0o"+e.toString(8):"-0o"+e.toString(8).slice(1)},decimal:function(e){return e.toString(10)},hexadecimal:function(e){return e>=0?"0x"+e.toString(16).toUpperCase():"-0x"+e.toString(16).toUpperCase().slice(1)}},defaultStyle:"decimal",styleAliases:{binary:[2,"bin"],octal:[8,"oct"],decimal:[10,"dec"],hexadecimal:[16,"hex"]}}),yr=new RegExp("^(?:[-+]?(?:[0-9][0-9_]*)(?:\\.[0-9_]*)?(?:[eE][-+]?[0-9]+)?|\\.[0-9_]+(?:[eE][-+]?[0-9]+)?|[-+]?\\.(?:inf|Inf|INF)|\\.(?:nan|NaN|NAN))$");function wr(e){return!(e===null||!yr.test(e)||e[e.length-1]==="_")}function Cr(e){var n,r;return n=e.replace(/_/g,"").toLowerCase(),r=n[0]==="-"?-1:1,"+-".indexOf(n[0])>=0&&(n=n.slice(1)),n===".inf"?r===1?Number.POSITIVE_INFINITY:Number.NEGATIVE_INFINITY:n===".nan"?NaN:r*parseFloat(n,10)}var Ar=/^[-+]?[0-9]+e/;function Er(e,n){var r;if(isNaN(e))switch(n){case"lowercase":return".nan";case"uppercase":return".NAN";case"camelcase":return".NaN"}else if(Number.POSITIVE_INFINITY===e)switch(n){case"lowercase":return".inf";case"uppercase":return".INF";case"camelcase":return".Inf"}else if(Number.NEGATIVE_INFINITY===e)switch(n){case"lowercase":return"-.inf";case"uppercase":return"-.INF";case"camelcase":return"-.Inf"}else if(C.isNegativeZero(e))return"-0.0";return r=e.toString(10),Ar.test(r)?r.replace("e",".e"):r}function br(e){return Object.prototype.toString.call(e)==="[object Number]"&&(e%1!==0||C.isNegativeZero(e))}var nn=new A("tag:yaml.org,2002:float",{kind:"scalar",resolve:wr,construct:Cr,predicate:br,represent:Er,defaultStyle:"lowercase"}),rn=Xe.extend({implicit:[Ve,Ze,en,nn]}),on=rn,tn=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9])-([0-9][0-9])$"),ln=new RegExp("^([0-9][0-9][0-9][0-9])-([0-9][0-9]?)-([0-9][0-9]?)(?:[Tt]|[ \\t]+)([0-9][0-9]?):([0-9][0-9]):([0-9][0-9])(?:\\.([0-9]*))?(?:[ \\t]*(Z|([-+])([0-9][0-9]?)(?::([0-9][0-9]))?))?$");function Sr(e){return e===null?!1:tn.exec(e)!==null||ln.exec(e)!==null}function Ir(e){var n,r,i,o,l,t,s,a=0,u=null,f,c,p;if(n=tn.exec(e),n===null&&(n=ln.exec(e)),n===null)throw new Error("Date resolve error");if(r=+n[1],i=+n[2]-1,o=+n[3],!n[4])return new Date(Date.UTC(r,i,o));if(l=+n[4],t=+n[5],s=+n[6],n[7]){for(a=n[7].slice(0,3);a.length<3;)a+="0";a=+a}return n[9]&&(f=+n[10],c=+(n[11]||0),u=(f*60+c)*6e4,n[9]==="-"&&(u=-u)),p=new Date(Date.UTC(r,i,o,l,t,s,a)),u&&p.setTime(p.getTime()-u),p}function Tr(e){return e.toISOString()}var sn=new A("tag:yaml.org,2002:timestamp",{kind:"scalar",resolve:Sr,construct:Ir,instanceOf:Date,represent:Tr});function kr(e){return e==="<<"||e===null}var an=new A("tag:yaml.org,2002:merge",{kind:"scalar",resolve:kr}),we=`ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=
9
+ \r`;function Or(e){if(e===null)return!1;var n,r,i=0,o=e.length,l=we;for(r=0;r<o;r++)if(n=l.indexOf(e.charAt(r)),!(n>64)){if(n<0)return!1;i+=6}return i%8===0}function _r(e){var n,r,i=e.replace(/[\r\n=]/g,""),o=i.length,l=we,t=0,s=[];for(n=0;n<o;n++)n%4===0&&n&&(s.push(t>>16&255),s.push(t>>8&255),s.push(t&255)),t=t<<6|l.indexOf(i.charAt(n));return r=o%4*6,r===0?(s.push(t>>16&255),s.push(t>>8&255),s.push(t&255)):r===18?(s.push(t>>10&255),s.push(t>>2&255)):r===12&&s.push(t>>4&255),new Uint8Array(s)}function Pr(e){var n="",r=0,i,o,l=e.length,t=we;for(i=0;i<l;i++)i%3===0&&i&&(n+=t[r>>18&63],n+=t[r>>12&63],n+=t[r>>6&63],n+=t[r&63]),r=(r<<8)+e[i];return o=l%3,o===0?(n+=t[r>>18&63],n+=t[r>>12&63],n+=t[r>>6&63],n+=t[r&63]):o===2?(n+=t[r>>10&63],n+=t[r>>4&63],n+=t[r<<2&63],n+=t[64]):o===1&&(n+=t[r>>2&63],n+=t[r<<4&63],n+=t[64],n+=t[64]),n}function Fr(e){return Object.prototype.toString.call(e)==="[object Uint8Array]"}var cn=new A("tag:yaml.org,2002:binary",{kind:"scalar",resolve:Or,construct:_r,predicate:Fr,represent:Pr}),Lr=Object.prototype.hasOwnProperty,Nr=Object.prototype.toString;function Rr(e){if(e===null)return!0;var n=[],r,i,o,l,t,s=e;for(r=0,i=s.length;r<i;r+=1){if(o=s[r],t=!1,Nr.call(o)!=="[object Object]")return!1;for(l in o)if(Lr.call(o,l))if(!t)t=!0;else return!1;if(!t)return!1;if(n.indexOf(l)===-1)n.push(l);else return!1}return!0}function Dr(e){return e!==null?e:[]}var un=new A("tag:yaml.org,2002:omap",{kind:"sequence",resolve:Rr,construct:Dr}),Mr=Object.prototype.toString;function $r(e){if(e===null)return!0;var n,r,i,o,l,t=e;for(l=new Array(t.length),n=0,r=t.length;n<r;n+=1){if(i=t[n],Mr.call(i)!=="[object Object]"||(o=Object.keys(i),o.length!==1))return!1;l[n]=[o[0],i[o[0]]]}return!0}function Gr(e){if(e===null)return[];var n,r,i,o,l,t=e;for(l=new Array(t.length),n=0,r=t.length;n<r;n+=1)i=t[n],o=Object.keys(i),l[n]=[o[0],i[o[0]]];return l}var fn=new A("tag:yaml.org,2002:pairs",{kind:"sequence",resolve:$r,construct:Gr}),jr=Object.prototype.hasOwnProperty;function Hr(e){if(e===null)return!0;var n,r=e;for(n in r)if(jr.call(r,n)&&r[n]!==null)return!1;return!0}function Br(e){return e!==null?e:{}}var pn=new A("tag:yaml.org,2002:set",{kind:"mapping",resolve:Hr,construct:Br}),Ce=on.extend({implicit:[sn,an],explicit:[cn,un,fn,pn]}),F=Object.prototype.hasOwnProperty,V=1,dn=2,mn=3,Z=4,me=1,Yr=2,Pe=3,Ur=/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x84\x86-\x9F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,Kr=/[\x85\u2028\u2029]/,Wr=/[,\[\]\{\}]/,hn=/^(?:!|!!|![a-z\-]+!)$/i,gn=/^(?:!|[^,\[\]\{\}])(?:%[0-9a-f]{2}|[0-9a-z\-#;\/\?:@&=\+\$,_\.!~\*'\(\)\[\]])*$/i;function Fe(e){return Object.prototype.toString.call(e)}function T(e){return e===10||e===13}function R(e){return e===9||e===32}function I(e){return e===9||e===32||e===10||e===13}function G(e){return e===44||e===91||e===93||e===123||e===125}function zr(e){var n;return 48<=e&&e<=57?e-48:(n=e|32,97<=n&&n<=102?n-97+10:-1)}function Jr(e){return e===120?2:e===117?4:e===85?8:0}function qr(e){return 48<=e&&e<=57?e-48:-1}function Le(e){return e===48?"\0":e===97?"\x07":e===98?"\b":e===116||e===9?" ":e===110?`
10
+ `:e===118?"\v":e===102?"\f":e===114?"\r":e===101?"\x1B":e===32?" ":e===34?'"':e===47?"/":e===92?"\\":e===78?"\x85":e===95?"\xA0":e===76?"\u2028":e===80?"\u2029":""}function Qr(e){return e<=65535?String.fromCharCode(e):String.fromCharCode((e-65536>>10)+55296,(e-65536&1023)+56320)}function xn(e,n,r){n==="__proto__"?Object.defineProperty(e,n,{configurable:!0,enumerable:!0,writable:!0,value:r}):e[n]=r}var vn=new Array(256),yn=new Array(256);for(N=0;N<256;N++)vn[N]=Le(N)?1:0,yn[N]=Le(N);var N;function Xr(e,n){this.input=e,this.filename=n.filename||null,this.schema=n.schema||Ce,this.onWarning=n.onWarning||null,this.legacy=n.legacy||!1,this.json=n.json||!1,this.listener=n.listener||null,this.implicitTypes=this.schema.compiledImplicit,this.typeMap=this.schema.compiledTypeMap,this.length=e.length,this.position=0,this.line=0,this.lineStart=0,this.lineIndent=0,this.firstTabInLine=-1,this.documents=[]}function wn(e,n){var r={name:e.filename,buffer:e.input.slice(0,-1),position:e.position,line:e.line,column:e.position-e.lineStart};return r.snippet=nr(r),new S(n,r)}function m(e,n){throw wn(e,n)}function ee(e,n){e.onWarning&&e.onWarning.call(null,wn(e,n))}var Ne={YAML:function(n,r,i){var o,l,t;n.version!==null&&m(n,"duplication of %YAML directive"),i.length!==1&&m(n,"YAML directive accepts exactly one argument"),o=/^([0-9]+)\.([0-9]+)$/.exec(i[0]),o===null&&m(n,"ill-formed argument of the YAML directive"),l=parseInt(o[1],10),t=parseInt(o[2],10),l!==1&&m(n,"unacceptable YAML version of the document"),n.version=i[0],n.checkLineBreaks=t<2,t!==1&&t!==2&&ee(n,"unsupported YAML version of the document")},TAG:function(n,r,i){var o,l;i.length!==2&&m(n,"TAG directive accepts exactly two arguments"),o=i[0],l=i[1],hn.test(o)||m(n,"ill-formed tag handle (first argument) of the TAG directive"),F.call(n.tagMap,o)&&m(n,'there is a previously declared suffix for "'+o+'" tag handle'),gn.test(l)||m(n,"ill-formed tag prefix (second argument) of the TAG directive");try{l=decodeURIComponent(l)}catch{m(n,"tag prefix is malformed: "+l)}n.tagMap[o]=l}};function P(e,n,r,i){var o,l,t,s;if(n<r){if(s=e.input.slice(n,r),i)for(o=0,l=s.length;o<l;o+=1)t=s.charCodeAt(o),t===9||32<=t&&t<=1114111||m(e,"expected valid JSON character");else Ur.test(s)&&m(e,"the stream contains non-printable characters");e.result+=s}}function Re(e,n,r,i){var o,l,t,s;for(C.isObject(r)||m(e,"cannot merge mappings; the provided source object is unacceptable"),o=Object.keys(r),t=0,s=o.length;t<s;t+=1)l=o[t],F.call(n,l)||(xn(n,l,r[l]),i[l]=!0)}function j(e,n,r,i,o,l,t,s,a){var u,f;if(Array.isArray(o))for(o=Array.prototype.slice.call(o),u=0,f=o.length;u<f;u+=1)Array.isArray(o[u])&&m(e,"nested arrays are not supported inside keys"),typeof o=="object"&&Fe(o[u])==="[object Object]"&&(o[u]="[object Object]");if(typeof o=="object"&&Fe(o)==="[object Object]"&&(o="[object Object]"),o=String(o),n===null&&(n={}),i==="tag:yaml.org,2002:merge")if(Array.isArray(l))for(u=0,f=l.length;u<f;u+=1)Re(e,n,l[u],r);else Re(e,n,l,r);else!e.json&&!F.call(r,o)&&F.call(n,o)&&(e.line=t||e.line,e.lineStart=s||e.lineStart,e.position=a||e.position,m(e,"duplicated mapping key")),xn(n,o,l),delete r[o];return n}function Ae(e){var n;n=e.input.charCodeAt(e.position),n===10?e.position++:n===13?(e.position++,e.input.charCodeAt(e.position)===10&&e.position++):m(e,"a line break is expected"),e.line+=1,e.lineStart=e.position,e.firstTabInLine=-1}function w(e,n,r){for(var i=0,o=e.input.charCodeAt(e.position);o!==0;){for(;R(o);)o===9&&e.firstTabInLine===-1&&(e.firstTabInLine=e.position),o=e.input.charCodeAt(++e.position);if(n&&o===35)do o=e.input.charCodeAt(++e.position);while(o!==10&&o!==13&&o!==0);if(T(o))for(Ae(e),o=e.input.charCodeAt(e.position),i++,e.lineIndent=0;o===32;)e.lineIndent++,o=e.input.charCodeAt(++e.position);else break}return r!==-1&&i!==0&&e.lineIndent<r&&ee(e,"deficient indentation"),i}function ie(e){var n=e.position,r;return r=e.input.charCodeAt(n),!!((r===45||r===46)&&r===e.input.charCodeAt(n+1)&&r===e.input.charCodeAt(n+2)&&(n+=3,r=e.input.charCodeAt(n),r===0||I(r)))}function Ee(e,n){n===1?e.result+=" ":n>1&&(e.result+=C.repeat(`
11
+ `,n-1))}function Vr(e,n,r){var i,o,l,t,s,a,u,f,c=e.kind,p=e.result,d;if(d=e.input.charCodeAt(e.position),I(d)||G(d)||d===35||d===38||d===42||d===33||d===124||d===62||d===39||d===34||d===37||d===64||d===96||(d===63||d===45)&&(o=e.input.charCodeAt(e.position+1),I(o)||r&&G(o)))return!1;for(e.kind="scalar",e.result="",l=t=e.position,s=!1;d!==0;){if(d===58){if(o=e.input.charCodeAt(e.position+1),I(o)||r&&G(o))break}else if(d===35){if(i=e.input.charCodeAt(e.position-1),I(i))break}else{if(e.position===e.lineStart&&ie(e)||r&&G(d))break;if(T(d))if(a=e.line,u=e.lineStart,f=e.lineIndent,w(e,!1,-1),e.lineIndent>=n){s=!0,d=e.input.charCodeAt(e.position);continue}else{e.position=t,e.line=a,e.lineStart=u,e.lineIndent=f;break}}s&&(P(e,l,t,!1),Ee(e,e.line-a),l=t=e.position,s=!1),R(d)||(t=e.position+1),d=e.input.charCodeAt(++e.position)}return P(e,l,t,!1),e.result?!0:(e.kind=c,e.result=p,!1)}function Zr(e,n){var r,i,o;if(r=e.input.charCodeAt(e.position),r!==39)return!1;for(e.kind="scalar",e.result="",e.position++,i=o=e.position;(r=e.input.charCodeAt(e.position))!==0;)if(r===39)if(P(e,i,e.position,!0),r=e.input.charCodeAt(++e.position),r===39)i=e.position,e.position++,o=e.position;else return!0;else T(r)?(P(e,i,o,!0),Ee(e,w(e,!1,n)),i=o=e.position):e.position===e.lineStart&&ie(e)?m(e,"unexpected end of the document within a single quoted scalar"):(e.position++,o=e.position);m(e,"unexpected end of the stream within a single quoted scalar")}function ei(e,n){var r,i,o,l,t,s;if(s=e.input.charCodeAt(e.position),s!==34)return!1;for(e.kind="scalar",e.result="",e.position++,r=i=e.position;(s=e.input.charCodeAt(e.position))!==0;){if(s===34)return P(e,r,e.position,!0),e.position++,!0;if(s===92){if(P(e,r,e.position,!0),s=e.input.charCodeAt(++e.position),T(s))w(e,!1,n);else if(s<256&&vn[s])e.result+=yn[s],e.position++;else if((t=Jr(s))>0){for(o=t,l=0;o>0;o--)s=e.input.charCodeAt(++e.position),(t=zr(s))>=0?l=(l<<4)+t:m(e,"expected hexadecimal character");e.result+=Qr(l),e.position++}else m(e,"unknown escape sequence");r=i=e.position}else T(s)?(P(e,r,i,!0),Ee(e,w(e,!1,n)),r=i=e.position):e.position===e.lineStart&&ie(e)?m(e,"unexpected end of the document within a double quoted scalar"):(e.position++,i=e.position)}m(e,"unexpected end of the stream within a double quoted scalar")}function ni(e,n){var r=!0,i,o,l,t=e.tag,s,a=e.anchor,u,f,c,p,d,x=Object.create(null),h,v,y,g;if(g=e.input.charCodeAt(e.position),g===91)f=93,d=!1,s=[];else if(g===123)f=125,d=!0,s={};else return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=s),g=e.input.charCodeAt(++e.position);g!==0;){if(w(e,!0,n),g=e.input.charCodeAt(e.position),g===f)return e.position++,e.tag=t,e.anchor=a,e.kind=d?"mapping":"sequence",e.result=s,!0;r?g===44&&m(e,"expected the node content, but found ','"):m(e,"missed comma between flow collection entries"),v=h=y=null,c=p=!1,g===63&&(u=e.input.charCodeAt(e.position+1),I(u)&&(c=p=!0,e.position++,w(e,!0,n))),i=e.line,o=e.lineStart,l=e.position,H(e,n,V,!1,!0),v=e.tag,h=e.result,w(e,!0,n),g=e.input.charCodeAt(e.position),(p||e.line===i)&&g===58&&(c=!0,g=e.input.charCodeAt(++e.position),w(e,!0,n),H(e,n,V,!1,!0),y=e.result),d?j(e,s,x,v,h,y,i,o,l):c?s.push(j(e,null,x,v,h,y,i,o,l)):s.push(h),w(e,!0,n),g=e.input.charCodeAt(e.position),g===44?(r=!0,g=e.input.charCodeAt(++e.position)):r=!1}m(e,"unexpected end of the stream within a flow collection")}function ri(e,n){var r,i,o=me,l=!1,t=!1,s=n,a=0,u=!1,f,c;if(c=e.input.charCodeAt(e.position),c===124)i=!1;else if(c===62)i=!0;else return!1;for(e.kind="scalar",e.result="";c!==0;)if(c=e.input.charCodeAt(++e.position),c===43||c===45)me===o?o=c===43?Pe:Yr:m(e,"repeat of a chomping mode identifier");else if((f=qr(c))>=0)f===0?m(e,"bad explicit indentation width of a block scalar; it cannot be less than one"):t?m(e,"repeat of an indentation width identifier"):(s=n+f-1,t=!0);else break;if(R(c)){do c=e.input.charCodeAt(++e.position);while(R(c));if(c===35)do c=e.input.charCodeAt(++e.position);while(!T(c)&&c!==0)}for(;c!==0;){for(Ae(e),e.lineIndent=0,c=e.input.charCodeAt(e.position);(!t||e.lineIndent<s)&&c===32;)e.lineIndent++,c=e.input.charCodeAt(++e.position);if(!t&&e.lineIndent>s&&(s=e.lineIndent),T(c)){a++;continue}if(e.lineIndent<s){o===Pe?e.result+=C.repeat(`
12
+ `,l?1+a:a):o===me&&l&&(e.result+=`
13
+ `);break}for(i?R(c)?(u=!0,e.result+=C.repeat(`
14
+ `,l?1+a:a)):u?(u=!1,e.result+=C.repeat(`
15
+ `,a+1)):a===0?l&&(e.result+=" "):e.result+=C.repeat(`
16
+ `,a):e.result+=C.repeat(`
17
+ `,l?1+a:a),l=!0,t=!0,a=0,r=e.position;!T(c)&&c!==0;)c=e.input.charCodeAt(++e.position);P(e,r,e.position,!1)}return!0}function De(e,n){var r,i=e.tag,o=e.anchor,l=[],t,s=!1,a;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=l),a=e.input.charCodeAt(e.position);a!==0&&(e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation")),!(a!==45||(t=e.input.charCodeAt(e.position+1),!I(t))));){if(s=!0,e.position++,w(e,!0,-1)&&e.lineIndent<=n){l.push(null),a=e.input.charCodeAt(e.position);continue}if(r=e.line,H(e,n,mn,!1,!0),l.push(e.result),w(e,!0,-1),a=e.input.charCodeAt(e.position),(e.line===r||e.lineIndent>n)&&a!==0)m(e,"bad indentation of a sequence entry");else if(e.lineIndent<n)break}return s?(e.tag=i,e.anchor=o,e.kind="sequence",e.result=l,!0):!1}function ii(e,n,r){var i,o,l,t,s,a,u=e.tag,f=e.anchor,c={},p=Object.create(null),d=null,x=null,h=null,v=!1,y=!1,g;if(e.firstTabInLine!==-1)return!1;for(e.anchor!==null&&(e.anchorMap[e.anchor]=c),g=e.input.charCodeAt(e.position);g!==0;){if(!v&&e.firstTabInLine!==-1&&(e.position=e.firstTabInLine,m(e,"tab characters must not be used in indentation")),i=e.input.charCodeAt(e.position+1),l=e.line,(g===63||g===58)&&I(i))g===63?(v&&(j(e,c,p,d,x,null,t,s,a),d=x=h=null),y=!0,v=!0,o=!0):v?(v=!1,o=!0):m(e,"incomplete explicit mapping pair; a key node is missed; or followed by a non-tabulated empty line"),e.position+=1,g=i;else{if(t=e.line,s=e.lineStart,a=e.position,!H(e,r,dn,!1,!0))break;if(e.line===l){for(g=e.input.charCodeAt(e.position);R(g);)g=e.input.charCodeAt(++e.position);if(g===58)g=e.input.charCodeAt(++e.position),I(g)||m(e,"a whitespace character is expected after the key-value separator within a block mapping"),v&&(j(e,c,p,d,x,null,t,s,a),d=x=h=null),y=!0,v=!1,o=!1,d=e.tag,x=e.result;else if(y)m(e,"can not read an implicit mapping pair; a colon is missed");else return e.tag=u,e.anchor=f,!0}else if(y)m(e,"can not read a block mapping entry; a multiline key may not be an implicit key");else return e.tag=u,e.anchor=f,!0}if((e.line===l||e.lineIndent>n)&&(v&&(t=e.line,s=e.lineStart,a=e.position),H(e,n,Z,!0,o)&&(v?x=e.result:h=e.result),v||(j(e,c,p,d,x,h,t,s,a),d=x=h=null),w(e,!0,-1),g=e.input.charCodeAt(e.position)),(e.line===l||e.lineIndent>n)&&g!==0)m(e,"bad indentation of a mapping entry");else if(e.lineIndent<n)break}return v&&j(e,c,p,d,x,null,t,s,a),y&&(e.tag=u,e.anchor=f,e.kind="mapping",e.result=c),y}function oi(e){var n,r=!1,i=!1,o,l,t;if(t=e.input.charCodeAt(e.position),t!==33)return!1;if(e.tag!==null&&m(e,"duplication of a tag property"),t=e.input.charCodeAt(++e.position),t===60?(r=!0,t=e.input.charCodeAt(++e.position)):t===33?(i=!0,o="!!",t=e.input.charCodeAt(++e.position)):o="!",n=e.position,r){do t=e.input.charCodeAt(++e.position);while(t!==0&&t!==62);e.position<e.length?(l=e.input.slice(n,e.position),t=e.input.charCodeAt(++e.position)):m(e,"unexpected end of the stream within a verbatim tag")}else{for(;t!==0&&!I(t);)t===33&&(i?m(e,"tag suffix cannot contain exclamation marks"):(o=e.input.slice(n-1,e.position+1),hn.test(o)||m(e,"named tag handle cannot contain such characters"),i=!0,n=e.position+1)),t=e.input.charCodeAt(++e.position);l=e.input.slice(n,e.position),Wr.test(l)&&m(e,"tag suffix cannot contain flow indicator characters")}l&&!gn.test(l)&&m(e,"tag name cannot contain such characters: "+l);try{l=decodeURIComponent(l)}catch{m(e,"tag name is malformed: "+l)}return r?e.tag=l:F.call(e.tagMap,o)?e.tag=e.tagMap[o]+l:o==="!"?e.tag="!"+l:o==="!!"?e.tag="tag:yaml.org,2002:"+l:m(e,'undeclared tag handle "'+o+'"'),!0}function ti(e){var n,r;if(r=e.input.charCodeAt(e.position),r!==38)return!1;for(e.anchor!==null&&m(e,"duplication of an anchor property"),r=e.input.charCodeAt(++e.position),n=e.position;r!==0&&!I(r)&&!G(r);)r=e.input.charCodeAt(++e.position);return e.position===n&&m(e,"name of an anchor node must contain at least one character"),e.anchor=e.input.slice(n,e.position),!0}function li(e){var n,r,i;if(i=e.input.charCodeAt(e.position),i!==42)return!1;for(i=e.input.charCodeAt(++e.position),n=e.position;i!==0&&!I(i)&&!G(i);)i=e.input.charCodeAt(++e.position);return e.position===n&&m(e,"name of an alias node must contain at least one character"),r=e.input.slice(n,e.position),F.call(e.anchorMap,r)||m(e,'unidentified alias "'+r+'"'),e.result=e.anchorMap[r],w(e,!0,-1),!0}function H(e,n,r,i,o){var l,t,s,a=1,u=!1,f=!1,c,p,d,x,h,v;if(e.listener!==null&&e.listener("open",e),e.tag=null,e.anchor=null,e.kind=null,e.result=null,l=t=s=Z===r||mn===r,i&&w(e,!0,-1)&&(u=!0,e.lineIndent>n?a=1:e.lineIndent===n?a=0:e.lineIndent<n&&(a=-1)),a===1)for(;oi(e)||ti(e);)w(e,!0,-1)?(u=!0,s=l,e.lineIndent>n?a=1:e.lineIndent===n?a=0:e.lineIndent<n&&(a=-1)):s=!1;if(s&&(s=u||o),(a===1||Z===r)&&(V===r||dn===r?h=n:h=n+1,v=e.position-e.lineStart,a===1?s&&(De(e,v)||ii(e,v,h))||ni(e,h)?f=!0:(t&&ri(e,h)||Zr(e,h)||ei(e,h)?f=!0:li(e)?(f=!0,(e.tag!==null||e.anchor!==null)&&m(e,"alias node should not have any properties")):Vr(e,h,V===r)&&(f=!0,e.tag===null&&(e.tag="?")),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):a===0&&(f=s&&De(e,v))),e.tag===null)e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);else if(e.tag==="?"){for(e.result!==null&&e.kind!=="scalar"&&m(e,'unacceptable node kind for !<?> tag; it should be "scalar", not "'+e.kind+'"'),c=0,p=e.implicitTypes.length;c<p;c+=1)if(x=e.implicitTypes[c],x.resolve(e.result)){e.result=x.construct(e.result),e.tag=x.tag,e.anchor!==null&&(e.anchorMap[e.anchor]=e.result);break}}else if(e.tag!=="!"){if(F.call(e.typeMap[e.kind||"fallback"],e.tag))x=e.typeMap[e.kind||"fallback"][e.tag];else for(x=null,d=e.typeMap.multi[e.kind||"fallback"],c=0,p=d.length;c<p;c+=1)if(e.tag.slice(0,d[c].tag.length)===d[c].tag){x=d[c];break}x||m(e,"unknown tag !<"+e.tag+">"),e.result!==null&&x.kind!==e.kind&&m(e,"unacceptable node kind for !<"+e.tag+'> tag; it should be "'+x.kind+'", not "'+e.kind+'"'),x.resolve(e.result,e.tag)?(e.result=x.construct(e.result,e.tag),e.anchor!==null&&(e.anchorMap[e.anchor]=e.result)):m(e,"cannot resolve a node with !<"+e.tag+"> explicit tag")}return e.listener!==null&&e.listener("close",e),e.tag!==null||e.anchor!==null||f}function si(e){var n=e.position,r,i,o,l=!1,t;for(e.version=null,e.checkLineBreaks=e.legacy,e.tagMap=Object.create(null),e.anchorMap=Object.create(null);(t=e.input.charCodeAt(e.position))!==0&&(w(e,!0,-1),t=e.input.charCodeAt(e.position),!(e.lineIndent>0||t!==37));){for(l=!0,t=e.input.charCodeAt(++e.position),r=e.position;t!==0&&!I(t);)t=e.input.charCodeAt(++e.position);for(i=e.input.slice(r,e.position),o=[],i.length<1&&m(e,"directive name must not be less than one character in length");t!==0;){for(;R(t);)t=e.input.charCodeAt(++e.position);if(t===35){do t=e.input.charCodeAt(++e.position);while(t!==0&&!T(t));break}if(T(t))break;for(r=e.position;t!==0&&!I(t);)t=e.input.charCodeAt(++e.position);o.push(e.input.slice(r,e.position))}t!==0&&Ae(e),F.call(Ne,i)?Ne[i](e,i,o):ee(e,'unknown document directive "'+i+'"')}if(w(e,!0,-1),e.lineIndent===0&&e.input.charCodeAt(e.position)===45&&e.input.charCodeAt(e.position+1)===45&&e.input.charCodeAt(e.position+2)===45?(e.position+=3,w(e,!0,-1)):l&&m(e,"directives end mark is expected"),H(e,e.lineIndent-1,Z,!1,!0),w(e,!0,-1),e.checkLineBreaks&&Kr.test(e.input.slice(n,e.position))&&ee(e,"non-ASCII line breaks are interpreted as content"),e.documents.push(e.result),e.position===e.lineStart&&ie(e)){e.input.charCodeAt(e.position)===46&&(e.position+=3,w(e,!0,-1));return}if(e.position<e.length-1)m(e,"end of the stream or a document separator is expected");else return}function Cn(e,n){e=String(e),n=n||{},e.length!==0&&(e.charCodeAt(e.length-1)!==10&&e.charCodeAt(e.length-1)!==13&&(e+=`
18
+ `),e.charCodeAt(0)===65279&&(e=e.slice(1)));var r=new Xr(e,n),i=e.indexOf("\0");for(i!==-1&&(r.position=i,m(r,"null byte is not allowed in input")),r.input+="\0";r.input.charCodeAt(r.position)===32;)r.lineIndent+=1,r.position+=1;for(;r.position<r.length-1;)si(r);return r.documents}function ai(e,n,r){n!==null&&typeof n=="object"&&typeof r>"u"&&(r=n,n=null);var i=Cn(e,r);if(typeof n!="function")return i;for(var o=0,l=i.length;o<l;o+=1)n(i[o])}function ci(e,n){var r=Cn(e,n);if(r.length!==0){if(r.length===1)return r[0];throw new S("expected a single document in the stream, but found more")}}var ui=ai,fi=ci,An={loadAll:ui,load:fi},En=Object.prototype.toString,bn=Object.prototype.hasOwnProperty,be=65279,pi=9,z=10,di=13,mi=32,hi=33,gi=34,ge=35,xi=37,vi=38,yi=39,wi=42,Sn=44,Ci=45,ne=58,Ai=61,Ei=62,bi=63,Si=64,In=91,Tn=93,Ii=96,kn=123,Ti=124,On=125,b={};b[0]="\\0";b[7]="\\a";b[8]="\\b";b[9]="\\t";b[10]="\\n";b[11]="\\v";b[12]="\\f";b[13]="\\r";b[27]="\\e";b[34]='\\"';b[92]="\\\\";b[133]="\\N";b[160]="\\_";b[8232]="\\L";b[8233]="\\P";var ki=["y","Y","yes","Yes","YES","on","On","ON","n","N","no","No","NO","off","Off","OFF"],Oi=/^[-+]?[0-9_]+(?::[0-9_]+)+(?:\.[0-9_]*)?$/;function _i(e,n){var r,i,o,l,t,s,a;if(n===null)return{};for(r={},i=Object.keys(n),o=0,l=i.length;o<l;o+=1)t=i[o],s=String(n[t]),t.slice(0,2)==="!!"&&(t="tag:yaml.org,2002:"+t.slice(2)),a=e.compiledTypeMap.fallback[t],a&&bn.call(a.styleAliases,s)&&(s=a.styleAliases[s]),r[t]=s;return r}function Pi(e){var n,r,i;if(n=e.toString(16).toUpperCase(),e<=255)r="x",i=2;else if(e<=65535)r="u",i=4;else if(e<=4294967295)r="U",i=8;else throw new S("code point within a string may not be greater than 0xFFFFFFFF");return"\\"+r+C.repeat("0",i-n.length)+n}var Fi=1,J=2;function Li(e){this.schema=e.schema||Ce,this.indent=Math.max(1,e.indent||2),this.noArrayIndent=e.noArrayIndent||!1,this.skipInvalid=e.skipInvalid||!1,this.flowLevel=C.isNothing(e.flowLevel)?-1:e.flowLevel,this.styleMap=_i(this.schema,e.styles||null),this.sortKeys=e.sortKeys||!1,this.lineWidth=e.lineWidth||80,this.noRefs=e.noRefs||!1,this.noCompatMode=e.noCompatMode||!1,this.condenseFlow=e.condenseFlow||!1,this.quotingType=e.quotingType==='"'?J:Fi,this.forceQuotes=e.forceQuotes||!1,this.replacer=typeof e.replacer=="function"?e.replacer:null,this.implicitTypes=this.schema.compiledImplicit,this.explicitTypes=this.schema.compiledExplicit,this.tag=null,this.result="",this.duplicates=[],this.usedDuplicates=null}function Me(e,n){for(var r=C.repeat(" ",n),i=0,o=-1,l="",t,s=e.length;i<s;)o=e.indexOf(`
19
+ `,i),o===-1?(t=e.slice(i),i=s):(t=e.slice(i,o+1),i=o+1),t.length&&t!==`
20
20
  `&&(l+=r),l+=t;return l}function xe(e,n){return`
21
- `+A.repeat(" ",e.indent*n)}function Pi(e,n){var r,i,o;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(o=e.implicitTypes[r],o.resolve(n))return!0;return!1}function re(e){return e===hi||e===pi}function q(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==Ee||65536<=e&&e<=1114111}function $e(e){return q(e)&&e!==Ee&&e!==di&&e!==z}function je(e,n,r){var i=$e(e),o=i&&!re(e);return(r?i:i&&e!==bn&&e!==Tn&&e!==In&&e!==On&&e!==_n)&&e!==ge&&!(n===ne&&!o)||$e(n)&&!re(n)&&e===ge||n===ne&&o}function Ri(e){return q(e)&&e!==Ee&&!re(e)&&e!==Ai&&e!==Ei&&e!==ne&&e!==bn&&e!==Tn&&e!==In&&e!==On&&e!==_n&&e!==ge&&e!==vi&&e!==wi&&e!==mi&&e!==Ii&&e!==Ci&&e!==Si&&e!==yi&&e!==gi&&e!==xi&&e!==bi&&e!==Ti}function Di(e){return!re(e)&&e!==ne}function K(e,n){var r=e.charCodeAt(n),i;return r>=55296&&r<=56319&&n+1<e.length&&(i=e.charCodeAt(n+1),i>=56320&&i<=57343)?(r-55296)*1024+i-56320+65536:r}function kn(e){var n=/^\n* /;return n.test(e)}var Fn=1,ve=2,Ln=3,Nn=4,$=5;function Mi(e,n,r,i,o,l,t,a){var c,u=0,f=null,s=!1,p=!1,d=i!==-1,x=-1,m=Ri(K(e,0))&&Di(K(e,e.length-1));if(n||t)for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=K(e,c),!q(u))return $;m=m&&je(u,f,a),f=u}else{for(c=0;c<e.length;u>=65536?c+=2:c++){if(u=K(e,c),u===z)s=!0,d&&(p=p||c-x-1>i&&e[x+1]!==" ",x=c);else if(!q(u))return $;m=m&&je(u,f,a),f=u}p=p||d&&c-x-1>i&&e[x+1]!==" "}return!s&&!p?m&&!t&&!o(e)?Fn:l===J?$:ve:r>9&&kn(e)?$:t?l===J?$:ve:p?Nn:Ln}function $i(e,n,r,i,o){e.dump=function(){if(n.length===0)return e.quotingType===J?'""':"''";if(!e.noCompatMode&&(Oi.indexOf(n)!==-1||_i.test(n)))return e.quotingType===J?'"'+n+'"':"'"+n+"'";var l=e.indent*Math.max(1,r),t=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-l),a=i||e.flowLevel>-1&&r>=e.flowLevel;function c(u){return Pi(e,u)}switch(Mi(n,a,e.indent,t,c,e.quotingType,e.forceQuotes&&!i,o)){case Fn:return n;case ve:return"'"+n.replace(/'/g,"''")+"'";case Ln:return"|"+He(n,e.indent)+Ge(Me(n,l));case Nn:return">"+He(n,e.indent)+Ge(Me(ji(n,t),l));case $:return'"'+Hi(n)+'"';default:throw new b("impossible error: invalid scalar style")}}()}function He(e,n){var r=kn(e)?String(n):"",i=e[e.length-1]===`
21
+ `+C.repeat(" ",e.indent*n)}function Ni(e,n){var r,i,o;for(r=0,i=e.implicitTypes.length;r<i;r+=1)if(o=e.implicitTypes[r],o.resolve(n))return!0;return!1}function re(e){return e===mi||e===pi}function q(e){return 32<=e&&e<=126||161<=e&&e<=55295&&e!==8232&&e!==8233||57344<=e&&e<=65533&&e!==be||65536<=e&&e<=1114111}function $e(e){return q(e)&&e!==be&&e!==di&&e!==z}function Ge(e,n,r){var i=$e(e),o=i&&!re(e);return(r?i:i&&e!==Sn&&e!==In&&e!==Tn&&e!==kn&&e!==On)&&e!==ge&&!(n===ne&&!o)||$e(n)&&!re(n)&&e===ge||n===ne&&o}function Ri(e){return q(e)&&e!==be&&!re(e)&&e!==Ci&&e!==bi&&e!==ne&&e!==Sn&&e!==In&&e!==Tn&&e!==kn&&e!==On&&e!==ge&&e!==vi&&e!==wi&&e!==hi&&e!==Ti&&e!==Ai&&e!==Ei&&e!==yi&&e!==gi&&e!==xi&&e!==Si&&e!==Ii}function Di(e){return!re(e)&&e!==ne}function K(e,n){var r=e.charCodeAt(n),i;return r>=55296&&r<=56319&&n+1<e.length&&(i=e.charCodeAt(n+1),i>=56320&&i<=57343)?(r-55296)*1024+i-56320+65536:r}function _n(e){var n=/^\n* /;return n.test(e)}var Pn=1,ve=2,Fn=3,Ln=4,$=5;function Mi(e,n,r,i,o,l,t,s){var a,u=0,f=null,c=!1,p=!1,d=i!==-1,x=-1,h=Ri(K(e,0))&&Di(K(e,e.length-1));if(n||t)for(a=0;a<e.length;u>=65536?a+=2:a++){if(u=K(e,a),!q(u))return $;h=h&&Ge(u,f,s),f=u}else{for(a=0;a<e.length;u>=65536?a+=2:a++){if(u=K(e,a),u===z)c=!0,d&&(p=p||a-x-1>i&&e[x+1]!==" ",x=a);else if(!q(u))return $;h=h&&Ge(u,f,s),f=u}p=p||d&&a-x-1>i&&e[x+1]!==" "}return!c&&!p?h&&!t&&!o(e)?Pn:l===J?$:ve:r>9&&_n(e)?$:t?l===J?$:ve:p?Ln:Fn}function $i(e,n,r,i,o){e.dump=function(){if(n.length===0)return e.quotingType===J?'""':"''";if(!e.noCompatMode&&(ki.indexOf(n)!==-1||Oi.test(n)))return e.quotingType===J?'"'+n+'"':"'"+n+"'";var l=e.indent*Math.max(1,r),t=e.lineWidth===-1?-1:Math.max(Math.min(e.lineWidth,40),e.lineWidth-l),s=i||e.flowLevel>-1&&r>=e.flowLevel;function a(u){return Ni(e,u)}switch(Mi(n,s,e.indent,t,a,e.quotingType,e.forceQuotes&&!i,o)){case Pn:return n;case ve:return"'"+n.replace(/'/g,"''")+"'";case Fn:return"|"+je(n,e.indent)+He(Me(n,l));case Ln:return">"+je(n,e.indent)+He(Me(Gi(n,t),l));case $:return'"'+ji(n)+'"';default:throw new S("impossible error: invalid scalar style")}}()}function je(e,n){var r=_n(e)?String(n):"",i=e[e.length-1]===`
22
22
  `,o=i&&(e[e.length-2]===`
23
23
  `||e===`
24
24
  `),l=o?"+":i?"":"-";return r+l+`
25
- `}function Ge(e){return e[e.length-1]===`
26
- `?e.slice(0,-1):e}function ji(e,n){for(var r=/(\n+)([^\n]*)/g,i=function(){var u=e.indexOf(`
25
+ `}function He(e){return e[e.length-1]===`
26
+ `?e.slice(0,-1):e}function Gi(e,n){for(var r=/(\n+)([^\n]*)/g,i=function(){var u=e.indexOf(`
27
27
  `);return u=u!==-1?u:e.length,r.lastIndex=u,Be(e.slice(0,u),n)}(),o=e[0]===`
28
- `||e[0]===" ",l,t;t=r.exec(e);){var a=t[1],c=t[2];l=c[0]===" ",i+=a+(!o&&!l&&c!==""?`
29
- `:"")+Be(c,n),o=l}return i}function Be(e,n){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,i,o=0,l,t=0,a=0,c="";i=r.exec(e);)a=i.index,a-o>n&&(l=t>o?t:a,c+=`
30
- `+e.slice(o,l),o=l+1),t=a;return c+=`
31
- `,e.length-o>n&&t>o?c+=e.slice(o,t)+`
32
- `+e.slice(t+1):c+=e.slice(o),c.slice(1)}function Hi(e){for(var n="",r=0,i,o=0;o<e.length;r>=65536?o+=2:o++)r=K(e,o),i=S[r],!i&&q(r)?(n+=e[o],r>=65536&&(n+=e[o+1])):n+=i||Fi(r);return n}function Gi(e,n,r){var i="",o=e.tag,l,t,a;for(l=0,t=r.length;l<t;l+=1)a=r[l],e.replacer&&(a=e.replacer.call(r,String(l),a)),(_(e,n,a,!1,!1)||typeof a>"u"&&_(e,n,null,!1,!1))&&(i!==""&&(i+=","+(e.condenseFlow?"":" ")),i+=e.dump);e.tag=o,e.dump="["+i+"]"}function Ye(e,n,r,i){var o="",l=e.tag,t,a,c;for(t=0,a=r.length;t<a;t+=1)c=r[t],e.replacer&&(c=e.replacer.call(r,String(t),c)),(_(e,n+1,c,!0,!0,!1,!0)||typeof c>"u"&&_(e,n+1,null,!0,!0,!1,!0))&&((!i||o!=="")&&(o+=xe(e,n)),e.dump&&z===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=l,e.dump=o||"[]"}function Bi(e,n,r){var i="",o=e.tag,l=Object.keys(r),t,a,c,u,f;for(t=0,a=l.length;t<a;t+=1)f="",i!==""&&(f+=", "),e.condenseFlow&&(f+='"'),c=l[t],u=r[c],e.replacer&&(u=e.replacer.call(r,c,u)),_(e,n,c,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),_(e,n,u,!1,!1)&&(f+=e.dump,i+=f));e.tag=o,e.dump="{"+i+"}"}function Yi(e,n,r,i){var o="",l=e.tag,t=Object.keys(r),a,c,u,f,s,p;if(e.sortKeys===!0)t.sort();else if(typeof e.sortKeys=="function")t.sort(e.sortKeys);else if(e.sortKeys)throw new b("sortKeys must be a boolean or a function");for(a=0,c=t.length;a<c;a+=1)p="",(!i||o!=="")&&(p+=xe(e,n)),u=t[a],f=r[u],e.replacer&&(f=e.replacer.call(r,u,f)),_(e,n+1,u,!0,!0,!0)&&(s=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,s&&(e.dump&&z===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,s&&(p+=xe(e,n)),_(e,n+1,f,!0,s)&&(e.dump&&z===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,o+=p));e.tag=l,e.dump=o||"{}"}function Ue(e,n,r){var i,o,l,t,a,c;for(o=r?e.explicitTypes:e.implicitTypes,l=0,t=o.length;l<t;l+=1)if(a=o[l],(a.instanceOf||a.predicate)&&(!a.instanceOf||typeof n=="object"&&n instanceof a.instanceOf)&&(!a.predicate||a.predicate(n))){if(r?a.multi&&a.representName?e.tag=a.representName(n):e.tag=a.tag:e.tag="?",a.represent){if(c=e.styleMap[a.tag]||a.defaultStyle,Sn.call(a.represent)==="[object Function]")i=a.represent(n,c);else if(En.call(a.represent,c))i=a.represent[c](n,c);else throw new b("!<"+a.tag+'> tag resolver accepts not "'+c+'" style');e.dump=i}return!0}return!1}function _(e,n,r,i,o,l,t){e.tag=null,e.dump=r,Ue(e,r,!1)||Ue(e,r,!0);var a=Sn.call(e.dump),c=i,u;i&&(i=e.flowLevel<0||e.flowLevel>n);var f=a==="[object Object]"||a==="[object Array]",s,p;if(f&&(s=e.duplicates.indexOf(r),p=s!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&n>0)&&(o=!1),p&&e.usedDuplicates[s])e.dump="*ref_"+s;else{if(f&&p&&!e.usedDuplicates[s]&&(e.usedDuplicates[s]=!0),a==="[object Object]")i&&Object.keys(e.dump).length!==0?(Yi(e,n,e.dump,o),p&&(e.dump="&ref_"+s+e.dump)):(Bi(e,n,e.dump),p&&(e.dump="&ref_"+s+" "+e.dump));else if(a==="[object Array]")i&&e.dump.length!==0?(e.noArrayIndent&&!t&&n>0?Ye(e,n-1,e.dump,o):Ye(e,n,e.dump,o),p&&(e.dump="&ref_"+s+e.dump)):(Gi(e,n,e.dump),p&&(e.dump="&ref_"+s+" "+e.dump));else if(a==="[object String]")e.tag!=="?"&&$i(e,e.dump,n,l,c);else{if(a==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new b("unacceptable kind of an object to dump "+a)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function Ui(e,n){var r=[],i=[],o,l;for(ye(e,r,i),o=0,l=i.length;o<l;o+=1)n.duplicates.push(r[i[o]]);n.usedDuplicates=new Array(l)}function ye(e,n,r){var i,o,l;if(e!==null&&typeof e=="object")if(o=n.indexOf(e),o!==-1)r.indexOf(o)===-1&&r.push(o);else if(n.push(e),Array.isArray(e))for(o=0,l=e.length;o<l;o+=1)ye(e[o],n,r);else for(i=Object.keys(e),o=0,l=i.length;o<l;o+=1)ye(e[i[o]],n,r)}function Ki(e,n){n=n||{};var r=new Ni(n);r.noRefs||Ui(e,r);var i=e;return r.replacer&&(i=r.replacer.call({"":i},"",i)),_(r,0,i,!0,!0)?r.dump+`
33
- `:""}var Wi=Ki,zi={dump:Wi};function be(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var Ji=C,qi=ze,Qi=Xe,Xi=rn,Vi=on,Zi=Ae,eo=Cn.load,no=Cn.loadAll,ro=zi.dump,io=b,oo={binary:sn,float:nn,map:Qe,null:Ve,pairs:fn,set:pn,timestamp:an,bool:Ze,int:en,merge:cn,omap:un,seq:qe,str:Je},to=be("safeLoad","load"),lo=be("safeLoadAll","loadAll"),ao=be("safeDump","dump"),Te={Type:Ji,Schema:qi,FAILSAFE_SCHEMA:Qi,JSON_SCHEMA:Xi,CORE_SCHEMA:Vi,DEFAULT_SCHEMA:Zi,load:eo,loadAll:no,dump:ro,YAMLException:io,types:oo,safeLoad:to,safeLoadAll:lo,safeDump:ao};var oe=".cligr.yml",E=class extends Error{constructor(n){super(n),this.name="ConfigError"}},O=class{configPath;constructor(n){if(n)this.configPath=X.resolve(n);else{let r=X.join(Pn.homedir(),oe),i=X.resolve(oe);Q.existsSync(r)?this.configPath=r:Q.existsSync(i)?this.configPath=i:this.configPath=r}}load(){if(!Q.existsSync(this.configPath))throw new E(`Config file not found. Looking for:
34
- - ${X.join(Pn.homedir(),oe)}
35
- - ${X.resolve(oe)}`);let n=Q.readFileSync(this.configPath,"utf-8"),r;try{r=Te.load(n)}catch(i){throw new E(`Invalid YAML: ${i.message}`)}return this.validate(r)}validate(n){if(!n||typeof n!="object")throw new E("Config must be an object");let r=n;if(!r.groups||typeof r.groups!="object")throw new E('Config must have a "groups" object');for(let[i,o]of Object.entries(r.groups))if(o&&typeof o=="object"){let l=o;this.validateItems(l.items,i),this.validateDisabledItems(l.items,l.disabledItems,i)}return r}validateItems(n,r){if(n==null)return;if(typeof n!="object"||Array.isArray(n))throw new E(`Group "${r}": items must be an object with named entries, e.g.:
28
+ `||e[0]===" ",l,t;t=r.exec(e);){var s=t[1],a=t[2];l=a[0]===" ",i+=s+(!o&&!l&&a!==""?`
29
+ `:"")+Be(a,n),o=l}return i}function Be(e,n){if(e===""||e[0]===" ")return e;for(var r=/ [^ ]/g,i,o=0,l,t=0,s=0,a="";i=r.exec(e);)s=i.index,s-o>n&&(l=t>o?t:s,a+=`
30
+ `+e.slice(o,l),o=l+1),t=s;return a+=`
31
+ `,e.length-o>n&&t>o?a+=e.slice(o,t)+`
32
+ `+e.slice(t+1):a+=e.slice(o),a.slice(1)}function ji(e){for(var n="",r=0,i,o=0;o<e.length;r>=65536?o+=2:o++)r=K(e,o),i=b[r],!i&&q(r)?(n+=e[o],r>=65536&&(n+=e[o+1])):n+=i||Pi(r);return n}function Hi(e,n,r){var i="",o=e.tag,l,t,s;for(l=0,t=r.length;l<t;l+=1)s=r[l],e.replacer&&(s=e.replacer.call(r,String(l),s)),(O(e,n,s,!1,!1)||typeof s>"u"&&O(e,n,null,!1,!1))&&(i!==""&&(i+=","+(e.condenseFlow?"":" ")),i+=e.dump);e.tag=o,e.dump="["+i+"]"}function Ye(e,n,r,i){var o="",l=e.tag,t,s,a;for(t=0,s=r.length;t<s;t+=1)a=r[t],e.replacer&&(a=e.replacer.call(r,String(t),a)),(O(e,n+1,a,!0,!0,!1,!0)||typeof a>"u"&&O(e,n+1,null,!0,!0,!1,!0))&&((!i||o!=="")&&(o+=xe(e,n)),e.dump&&z===e.dump.charCodeAt(0)?o+="-":o+="- ",o+=e.dump);e.tag=l,e.dump=o||"[]"}function Bi(e,n,r){var i="",o=e.tag,l=Object.keys(r),t,s,a,u,f;for(t=0,s=l.length;t<s;t+=1)f="",i!==""&&(f+=", "),e.condenseFlow&&(f+='"'),a=l[t],u=r[a],e.replacer&&(u=e.replacer.call(r,a,u)),O(e,n,a,!1,!1)&&(e.dump.length>1024&&(f+="? "),f+=e.dump+(e.condenseFlow?'"':"")+":"+(e.condenseFlow?"":" "),O(e,n,u,!1,!1)&&(f+=e.dump,i+=f));e.tag=o,e.dump="{"+i+"}"}function Yi(e,n,r,i){var o="",l=e.tag,t=Object.keys(r),s,a,u,f,c,p;if(e.sortKeys===!0)t.sort();else if(typeof e.sortKeys=="function")t.sort(e.sortKeys);else if(e.sortKeys)throw new S("sortKeys must be a boolean or a function");for(s=0,a=t.length;s<a;s+=1)p="",(!i||o!=="")&&(p+=xe(e,n)),u=t[s],f=r[u],e.replacer&&(f=e.replacer.call(r,u,f)),O(e,n+1,u,!0,!0,!0)&&(c=e.tag!==null&&e.tag!=="?"||e.dump&&e.dump.length>1024,c&&(e.dump&&z===e.dump.charCodeAt(0)?p+="?":p+="? "),p+=e.dump,c&&(p+=xe(e,n)),O(e,n+1,f,!0,c)&&(e.dump&&z===e.dump.charCodeAt(0)?p+=":":p+=": ",p+=e.dump,o+=p));e.tag=l,e.dump=o||"{}"}function Ue(e,n,r){var i,o,l,t,s,a;for(o=r?e.explicitTypes:e.implicitTypes,l=0,t=o.length;l<t;l+=1)if(s=o[l],(s.instanceOf||s.predicate)&&(!s.instanceOf||typeof n=="object"&&n instanceof s.instanceOf)&&(!s.predicate||s.predicate(n))){if(r?s.multi&&s.representName?e.tag=s.representName(n):e.tag=s.tag:e.tag="?",s.represent){if(a=e.styleMap[s.tag]||s.defaultStyle,En.call(s.represent)==="[object Function]")i=s.represent(n,a);else if(bn.call(s.represent,a))i=s.represent[a](n,a);else throw new S("!<"+s.tag+'> tag resolver accepts not "'+a+'" style');e.dump=i}return!0}return!1}function O(e,n,r,i,o,l,t){e.tag=null,e.dump=r,Ue(e,r,!1)||Ue(e,r,!0);var s=En.call(e.dump),a=i,u;i&&(i=e.flowLevel<0||e.flowLevel>n);var f=s==="[object Object]"||s==="[object Array]",c,p;if(f&&(c=e.duplicates.indexOf(r),p=c!==-1),(e.tag!==null&&e.tag!=="?"||p||e.indent!==2&&n>0)&&(o=!1),p&&e.usedDuplicates[c])e.dump="*ref_"+c;else{if(f&&p&&!e.usedDuplicates[c]&&(e.usedDuplicates[c]=!0),s==="[object Object]")i&&Object.keys(e.dump).length!==0?(Yi(e,n,e.dump,o),p&&(e.dump="&ref_"+c+e.dump)):(Bi(e,n,e.dump),p&&(e.dump="&ref_"+c+" "+e.dump));else if(s==="[object Array]")i&&e.dump.length!==0?(e.noArrayIndent&&!t&&n>0?Ye(e,n-1,e.dump,o):Ye(e,n,e.dump,o),p&&(e.dump="&ref_"+c+e.dump)):(Hi(e,n,e.dump),p&&(e.dump="&ref_"+c+" "+e.dump));else if(s==="[object String]")e.tag!=="?"&&$i(e,e.dump,n,l,a);else{if(s==="[object Undefined]")return!1;if(e.skipInvalid)return!1;throw new S("unacceptable kind of an object to dump "+s)}e.tag!==null&&e.tag!=="?"&&(u=encodeURI(e.tag[0]==="!"?e.tag.slice(1):e.tag).replace(/!/g,"%21"),e.tag[0]==="!"?u="!"+u:u.slice(0,18)==="tag:yaml.org,2002:"?u="!!"+u.slice(18):u="!<"+u+">",e.dump=u+" "+e.dump)}return!0}function Ui(e,n){var r=[],i=[],o,l;for(ye(e,r,i),o=0,l=i.length;o<l;o+=1)n.duplicates.push(r[i[o]]);n.usedDuplicates=new Array(l)}function ye(e,n,r){var i,o,l;if(e!==null&&typeof e=="object")if(o=n.indexOf(e),o!==-1)r.indexOf(o)===-1&&r.push(o);else if(n.push(e),Array.isArray(e))for(o=0,l=e.length;o<l;o+=1)ye(e[o],n,r);else for(i=Object.keys(e),o=0,l=i.length;o<l;o+=1)ye(e[i[o]],n,r)}function Ki(e,n){n=n||{};var r=new Li(n);r.noRefs||Ui(e,r);var i=e;return r.replacer&&(i=r.replacer.call({"":i},"",i)),O(r,0,i,!0,!0)?r.dump+`
33
+ `:""}var Wi=Ki,zi={dump:Wi};function Se(e,n){return function(){throw new Error("Function yaml."+e+" is removed in js-yaml 4. Use yaml."+n+" instead, which is now safe by default.")}}var Ji=A,qi=ze,Qi=Xe,Xi=rn,Vi=on,Zi=Ce,eo=An.load,no=An.loadAll,ro=zi.dump,io=S,oo={binary:cn,float:nn,map:Qe,null:Ve,pairs:fn,set:pn,timestamp:sn,bool:Ze,int:en,merge:an,omap:un,seq:qe,str:Je},to=Se("safeLoad","load"),lo=Se("safeLoadAll","loadAll"),so=Se("safeDump","dump"),Ie={Type:Ji,Schema:qi,FAILSAFE_SCHEMA:Qi,JSON_SCHEMA:Xi,CORE_SCHEMA:Vi,DEFAULT_SCHEMA:Zi,load:eo,loadAll:no,dump:ro,YAMLException:io,types:oo,safeLoad:to,safeLoadAll:lo,safeDump:so};var oe=".cligr.yml",E=class extends Error{constructor(n){super(n),this.name="ConfigError"}},k=class{configPath;constructor(n){if(n)this.configPath=X.resolve(n);else{let r=X.join(Nn.homedir(),oe),i=X.resolve(oe);Q.existsSync(r)?this.configPath=r:Q.existsSync(i)?this.configPath=i:this.configPath=r}}load(){if(!Q.existsSync(this.configPath))throw new E(`Config file not found. Looking for:
34
+ - ${X.join(Nn.homedir(),oe)}
35
+ - ${X.resolve(oe)}`);let n=Q.readFileSync(this.configPath,"utf-8"),r;try{r=Ie.load(n)}catch(i){throw new E(`Invalid YAML: ${i.message}`)}return this.validate(r)}validate(n){if(!n||typeof n!="object")throw new E("Config must be an object");let r=n;if(!r.groups||typeof r.groups!="object")throw new E('Config must have a "groups" object');for(let[i,o]of Object.entries(r.groups))if(o&&typeof o=="object"){let l=o;this.validateItems(l.items,i),this.validateDisabledItems(l.items,l.disabledItems,i)}return r}validateItems(n,r){if(n==null)return;if(typeof n!="object"||Array.isArray(n))throw new E(`Group "${r}": items must be an object with named entries, e.g.:
36
36
  items:
37
- serviceName: "value1,value2"`);let i=new Set;for(let[o,l]of Object.entries(n)){if(typeof l!="string")throw new E(`Group "${r}": item "${o}" must have a string value`);if(i.has(o))throw new E(`Group "${r}": duplicate item name "${o}". Item names must be unique within a group.`);i.add(o)}}validateDisabledItems(n,r,i){if(r==null)return;if(!Array.isArray(r))throw new E(`Group "${i}": disabledItems must be an array of strings`);let o=new Set,l=n&&typeof n=="object"&&!Array.isArray(n)?new Set(Object.keys(n)):new Set;for(let t of r){if(typeof t!="string")throw new E(`Group "${i}": disabledItems must be an array of strings`);if(o.has(t))throw new E(`Group "${i}": disabledItems contains duplicate "${t}"`);if(o.add(t),!l.has(t))throw new E(`Group "${i}": disabledItems entry "${t}" does not match any item`)}}normalizeItems(n){return Object.entries(n).map(([r,i])=>({name:r,value:i}))}getGroup(n){let r=this.load(),i=r.groups[n];if(!i){let f=Object.keys(r.groups).join(", ");throw new E(`Unknown group: ${n}. Available: ${f}`)}let o=new Set(i.disabledItems||[]),l={};for(let[f,s]of Object.entries(i.items||{}))o.has(f)||(l[f]=s);let t=this.normalizeItems(l),a=null,c=null;r.tools&&r.tools[i.tool]?(a=r.tools[i.tool].cmd,c=i.tool):(c=null,a=null);let u=i.params||{};return{config:i,items:t,tool:c,toolTemplate:a,params:u}}saveConfig(n){let r=Te.dump(n,{indent:2,lineWidth:-1});Q.writeFileSync(this.configPath,r,"utf-8")}toggleItem(n,r,i){let o=this.load(),l=o.groups[n];if(!l)throw new E(`Unknown group: ${n}`);if(!Object.hasOwn(l.items||{},r))throw new E(`Item "${r}" not found in group "${n}"`);let t=new Set(l.disabledItems||[]);i?t.delete(r):t.add(r),t.size===0?delete l.disabledItems:l.disabledItems=Array.from(t),this.saveConfig(o)}listGroups(){let n=this.load();return Object.keys(n.groups)}};var D=class{static expandNamedParams(n,r){let i=n;for(let[o,l]of Object.entries(r)){let t=`$${o}`;i=i.replaceAll(t,l)}return i}static expand(n,r,i,o={}){let l=r.value.split(",").map(c=>c.trim()),t=r.name,a=n;for(let c=l.length-1;c>=0;c--){let u=`$${c+1}`;a=a.replaceAll(u,l[c])}return a=this.expandNamedParams(a,o),{name:t,args:l,fullCmd:a}}static parseItem(n,r,i,o,l={}){if(r){let t=this.expand(r,i,o,l),a=r.match(/\$\d+/g)||[],c=0;for(let u of a){let f=parseInt(u.substring(1),10);f>c&&(c=f)}if(c>0&&t.args.length>c){let u=t.args.slice(c);t.fullCmd=`${t.fullCmd} ${u.join(" ")}`}return t}else{let t=i.value.split(",").map(u=>u.trim()),a=i.name,c=n?`${n} ${i.value}`:i.value;return{name:a,args:t,fullCmd:c}}}};import{spawn as so}from"child_process";import{EventEmitter as uo}from"events";import{promises as M}from"fs";import te from"path";import co from"os";var B=class{pidsDir;constructor(){this.pidsDir=te.join(co.homedir(),".cligr","pids")}async ensureDir(){try{await M.mkdir(this.pidsDir,{recursive:!0})}catch(n){if(n.code!=="EEXIST")throw n}}sanitizeItemName(n){return n.replace(/[<>:"/\\|?*]/g,"_")}getPidFilePath(n,r){let i=this.sanitizeItemName(r);return te.join(this.pidsDir,`${n}_${i}.pid`)}async writePid(n){await this.ensureDir();let r=this.getPidFilePath(n.groupName,n.itemName);await M.writeFile(r,JSON.stringify(n,null,2),"utf-8")}async readPidsByGroup(n){await this.ensureDir();let r=[];try{let i=await M.readdir(this.pidsDir),o=`${n}_`;for(let l of i)if(l.startsWith(o)&&l.endsWith(".pid"))try{let t=await M.readFile(te.join(this.pidsDir,l),"utf-8");r.push(JSON.parse(t))}catch{continue}}catch{return[]}return r}async readAllPids(){await this.ensureDir();let n=[];try{let r=await M.readdir(this.pidsDir);for(let i of r)if(i.endsWith(".pid"))try{let o=await M.readFile(te.join(this.pidsDir,i),"utf-8");n.push(JSON.parse(o))}catch{continue}}catch{return[]}return n}async deletePid(n,r){let i=this.getPidFilePath(n,r);try{await M.unlink(i)}catch(o){if(o.code!=="ENOENT")throw o}}async deleteGroupPids(n){let r=await this.readPidsByGroup(n);for(let i of r)await this.deletePid(i.groupName,i.itemName)}isPidRunning(n){try{return process.kill(n,0),!0}catch{return!1}}isPidEntryValid(n){if(!this.isPidRunning(n.pid))return!1;let r=Date.now()-5*60*1e3;return n.startTime>r}async cleanupStalePids(){let n=await this.readAllPids(),r=[];for(let i of n)this.isPidEntryValid(i)||(r.push(i),await this.deletePid(i.groupName,i.itemName));return r}async getRunningGroups(){let n=await this.readAllPids(),r=new Set(n.map(i=>i.groupName));return Array.from(r)}};var Ie=class{constructor(n,r,i="running"){this.item=n,this.process=r,this.status=i}},Y=class extends uo{groups=new Map;restartTimestamps=new Map;maxRestarts=3;restartWindow=1e4;pidStore=new B;spawnGroup(n,r,i){if(this.groups.has(n))throw new Error(`Group ${n} is already running`);let o=[];for(let l of r){let t=this.spawnProcess(l,n,i);o.push(new Ie(l,t))}this.groups.set(n,o),this.emit("group-started",n)}async restartGroup(n,r,i){this.isGroupRunning(n)&&await this.killGroup(n),this.spawnGroup(n,r,i)}spawnProcess(n,r,i){let{cmd:o,args:l}=this.parseCommand(n.fullCmd),t=so(o,l,{stdio:["inherit","pipe","pipe"],shell:!1,windowsHide:!0});if(this.pidStore.deletePid(r,n.name).catch(()=>{}),t.pid){let c={pid:t.pid,groupName:r,itemName:n.name,startTime:Date.now(),restartPolicy:i,fullCmd:n.fullCmd};this.pidStore.writePid(c).catch(u=>{console.error(`[${n.name}] Failed to write PID file:`,u)})}let a=(c,u)=>{let s=c.toString("utf-8").split(`
38
- `);for(let p of s)p.length>0&&this.emit("process-log",r,n.name,p,u)};return t.stdout&&t.stdout.on("data",c=>{process.stdout.write(`[${n.name}] ${c}`),a(c,!1)}),t.stderr&&t.stderr.on("data",c=>{process.stderr.write(`[${n.name}] ${c}`),a(c,!0)}),t.on("exit",(c,u)=>{this.handleExit(r,n,i,c,u)}),t}parseCommand(n){let r=[],i="",o=!1,l="";for(let t=0;t<n.length;t++){let a=n[t],c=n[t+1];(a==='"'||a==="'")&&!o?(o=!0,l=a):a===l&&o?(o=!1,l=""):a===" "&&!o?i&&(r.push(i),i=""):i+=a}return i&&r.push(i),{cmd:r[0]||"",args:r.slice(1)}}handleExit(n,r,i,o,l){if(l==="SIGTERM"&&!this.groups.has(n)){this.pidStore.deletePid(n,r.name).catch(()=>{});return}if(i==="unless-stopped"&&l==="SIGTERM"){this.pidStore.deletePid(n,r.name).catch(()=>{});return}if(i==="no"){this.pidStore.deletePid(n,r.name).catch(()=>{});return}let t=`${n}-${r.name}`,a=Date.now(),u=(this.restartTimestamps.get(t)||[]).filter(f=>a-f<this.restartWindow);if(u.push(a),this.restartTimestamps.set(t,u),u.length>this.maxRestarts){console.error(`[${r.name}] Crash loop detected. Stopping restarts.`),this.pidStore.deletePid(n,r.name).catch(()=>{});return}setTimeout(()=>{console.log(`[${r.name}] Restarting... (exit code: ${o})`);let f=this.spawnProcess(r,n,i);this.emit("item-restarted",n,r.name);let s=this.groups.get(n);if(s){let p=s.find(d=>d.item.name===r.name);p&&(p.process=f)}},1e3)}killGroup(n){let r=this.groups.get(n);if(!r)return Promise.resolve();let i=r.map(o=>this.killProcess(o.process));return this.groups.delete(n),Promise.all(i).then(async()=>{await this.pidStore.deleteGroupPids(n),this.emit("group-stopped",n)})}killPid(n){return new Promise((r,i)=>{try{process.kill(n,"SIGTERM");let o=setTimeout(()=>{try{process.kill(n,"SIGKILL")}catch{}},5e3),l=setInterval(()=>{this.pidStore.isPidRunning(n)||(clearTimeout(o),clearInterval(l),r())},100);this.pidStore.isPidRunning(n)||(clearTimeout(o),clearInterval(l),r())}catch(o){i(o)}})}killProcess(n){return new Promise(r=>{n.kill("SIGTERM");let i=setTimeout(()=>{n.killed||n.kill("SIGKILL")},5e3);n.on("exit",()=>{clearTimeout(i),r()}),(n.killed||n.exitCode!==null)&&(clearTimeout(i),r())})}killAll(){let n=[];for(let r of this.groups.keys())n.push(this.killGroup(r));return Promise.all(n).then(()=>{})}async cleanupStalePids(){await this.pidStore.cleanupStalePids()}getGroupStatus(n){let r=this.groups.get(n);return r?r.map(i=>i.status):[]}isGroupRunning(n){return this.groups.has(n)}getRunningGroups(){return Array.from(this.groups.keys())}};async function Oe(e){let n=new O,r=new Y,i=new B;try{await i.cleanupStalePids();let{config:o,items:l,tool:t,toolTemplate:a,params:c}=n.getGroup(e),u=l.map((f,s)=>D.parseItem(t,a,f,s,c));return r.spawnGroup(e,u,o.restart),console.log(`Started group ${e} with ${u.length} process(es)`),console.log("Press Ctrl+C to stop..."),new Promise(f=>{let s=async()=>{console.log(`
39
- Shutting down...`),process.removeListener("SIGINT",s),process.removeListener("SIGTERM",s),await r.killAll(),f(0)};process.on("SIGINT",s),process.on("SIGTERM",s)})}catch(o){if(o instanceof Error&&o.name==="ConfigError")return console.error(o.message),1;throw o}}async function Rn(e){let n=new O;try{let{config:r}=n.getGroup(e);console.log(`
40
- Group: ${e}`),console.log(`Tool: ${r.tool}`),console.log(`Restart: ${r.restart}`),console.log(`
41
- Items:`);let i=new Set(r.disabledItems||[]);for(let[o,l]of Object.entries(r.items||{})){let t=i.has(o)?" [disabled]":"";console.log(` ${o}: ${l}${t}`)}return console.log(""),0}catch(r){if(r instanceof Error&&r.name==="ConfigError")return console.error(r.message),1;throw r}}import{spawn as fo,spawnSync as Mn}from"child_process";import U from"fs";import po from"os";import _e from"path";var Dn=".cligr.yml",ho=`# Cligr Configuration
37
+ serviceName: "value1,value2"`);let i=new Set;for(let[o,l]of Object.entries(n)){if(typeof l!="string")throw new E(`Group "${r}": item "${o}" must have a string value`);if(i.has(o))throw new E(`Group "${r}": duplicate item name "${o}". Item names must be unique within a group.`);i.add(o)}}validateDisabledItems(n,r,i){if(r==null)return;if(!Array.isArray(r))throw new E(`Group "${i}": disabledItems must be an array of strings`);let o=new Set,l=n&&typeof n=="object"&&!Array.isArray(n)?new Set(Object.keys(n)):new Set;for(let t of r){if(typeof t!="string")throw new E(`Group "${i}": disabledItems must be an array of strings`);if(o.has(t))throw new E(`Group "${i}": disabledItems contains duplicate "${t}"`);if(o.add(t),!l.has(t))throw new E(`Group "${i}": disabledItems entry "${t}" does not match any item`)}}normalizeItems(n){return Object.entries(n).map(([r,i])=>({name:r,value:i}))}getGroup(n){let r=this.load(),i=r.groups[n];if(!i){let c=Object.keys(r.groups).join(", ");throw new E(`Unknown group: ${n}. Available: ${c}`)}let o=new Set(i.disabledItems||[]),l={};for(let[c,p]of Object.entries(i.items||{}))o.has(c)||(l[c]=p);let t=this.normalizeItems(l),s=null,a=null;r.tools&&r.tools[i.tool]?(s=r.tools[i.tool].cmd,a=i.tool):(a=null,s=null);let u=i.params||{},f=i.restart??r.tools?.[i.tool]?.restart;return{config:i,items:t,tool:a,toolTemplate:s,params:u,restart:f}}getEffectiveRestart(n){let r=this.load(),i=r.groups[n];if(!i){let o=Object.keys(r.groups).join(", ");throw new E(`Unknown group: ${n}. Available: ${o}`)}return i.restart??(r.tools&&r.tools[i.tool]?.restart)??void 0}saveConfig(n){let r=Ie.dump(n,{indent:2,lineWidth:-1});Q.writeFileSync(this.configPath,r,"utf-8")}toggleItem(n,r,i){let o=this.load(),l=o.groups[n];if(!l)throw new E(`Unknown group: ${n}`);if(!Object.hasOwn(l.items||{},r))throw new E(`Item "${r}" not found in group "${n}"`);let t=new Set(l.disabledItems||[]);i?t.delete(r):t.add(r),t.size===0?delete l.disabledItems:l.disabledItems=Array.from(t),this.saveConfig(o)}listGroups(){let n=this.load();return Object.keys(n.groups)}};var D=class{static expandNamedParams(n,r){let i=n;for(let[o,l]of Object.entries(r)){let t=`$${o}`;i=i.replaceAll(t,l)}return i}static expand(n,r,i,o={}){let l=r.value.split(",").map(a=>a.trim()),t=r.name,s=n;for(let a=l.length-1;a>=0;a--){let u=`$${a+1}`;s=s.replaceAll(u,l[a])}return s=this.expandNamedParams(s,o),{name:t,args:l,fullCmd:s}}static parseItem(n,r,i,o,l={}){if(r){let t=this.expand(r,i,o,l),s=r.match(/\$\d+/g)||[],a=0;for(let u of s){let f=parseInt(u.substring(1),10);f>a&&(a=f)}if(a>0&&t.args.length>a){let u=t.args.slice(a);t.fullCmd=`${t.fullCmd} ${u.join(" ")}`}return t}else{let t=i.value.split(",").map(u=>u.trim()),s=i.name,a=n?`${n} ${i.value}`:i.value;return{name:s,args:t,fullCmd:a}}}};import{spawn as co}from"child_process";import{EventEmitter as uo}from"events";import{promises as M}from"fs";import te from"path";import ao from"os";var B=class{pidsDir;constructor(){this.pidsDir=te.join(ao.homedir(),".cligr","pids")}async ensureDir(){try{await M.mkdir(this.pidsDir,{recursive:!0})}catch(n){if(n.code!=="EEXIST")throw n}}sanitizeItemName(n){return n.replace(/[<>:"/\\|?*]/g,"_")}getPidFilePath(n,r){let i=this.sanitizeItemName(r);return te.join(this.pidsDir,`${n}_${i}.pid`)}async writePid(n){await this.ensureDir();let r=this.getPidFilePath(n.groupName,n.itemName);await M.writeFile(r,JSON.stringify(n,null,2),"utf-8")}async readPidsByGroup(n){await this.ensureDir();let r=[];try{let i=await M.readdir(this.pidsDir),o=`${n}_`;for(let l of i)if(l.startsWith(o)&&l.endsWith(".pid"))try{let t=await M.readFile(te.join(this.pidsDir,l),"utf-8");r.push(JSON.parse(t))}catch{continue}}catch{return[]}return r}async readAllPids(){await this.ensureDir();let n=[];try{let r=await M.readdir(this.pidsDir);for(let i of r)if(i.endsWith(".pid"))try{let o=await M.readFile(te.join(this.pidsDir,i),"utf-8");n.push(JSON.parse(o))}catch{continue}}catch{return[]}return n}async deletePid(n,r){let i=this.getPidFilePath(n,r);try{await M.unlink(i)}catch(o){if(o.code!=="ENOENT")throw o}}async deleteGroupPids(n){let r=await this.readPidsByGroup(n);for(let i of r)await this.deletePid(i.groupName,i.itemName)}isPidRunning(n){try{return process.kill(n,0),!0}catch{return!1}}isPidEntryValid(n){if(!this.isPidRunning(n.pid))return!1;let r=Date.now()-5*60*1e3;return n.startTime>r}async cleanupStalePids(){let n=await this.readAllPids(),r=[];for(let i of n)this.isPidEntryValid(i)||(r.push(i),await this.deletePid(i.groupName,i.itemName));return r}async getRunningGroups(){let n=await this.readAllPids(),r=new Set(n.map(i=>i.groupName));return Array.from(r)}};var Te=class{constructor(n,r,i="running"){this.item=n;this.process=r;this.status=i}},Y=class extends uo{groups=new Map;restartTimestamps=new Map;maxRestarts=3;restartWindow=1e4;pidStore=new B;spawnGroup(n,r,i){if(this.groups.has(n))throw new Error(`Group ${n} is already running`);let o=[];for(let l of r){let t=this.spawnProcess(l,n,i);o.push(new Te(l,t))}this.groups.set(n,o),this.emit("group-started",n)}async restartGroup(n,r,i){this.isGroupRunning(n)&&await this.killGroup(n),this.spawnGroup(n,r,i)}spawnProcess(n,r,i){let{cmd:o,args:l}=this.parseCommand(n.fullCmd),t=co(o,l,{stdio:["inherit","pipe","pipe"],shell:!1,windowsHide:!0});if(this.pidStore.deletePid(r,n.name).catch(()=>{}),t.pid){let a={pid:t.pid,groupName:r,itemName:n.name,startTime:Date.now(),restartPolicy:i,fullCmd:n.fullCmd};this.pidStore.writePid(a).catch(u=>{console.error(`[${n.name}] Failed to write PID file:`,u)})}let s=(a,u)=>{let c=a.toString("utf-8").split(`
38
+ `);for(let p of c)p.length>0&&this.emit("process-log",r,n.name,p,u)};return t.stdout&&t.stdout.on("data",a=>{process.stdout.write(`[${n.name}] ${a}`),s(a,!1)}),t.stderr&&t.stderr.on("data",a=>{process.stderr.write(`[${n.name}] ${a}`),s(a,!0)}),t.on("exit",(a,u)=>{this.handleExit(r,n,i,a,u)}),t}parseCommand(n){let r=[],i="",o=!1,l="";for(let t=0;t<n.length;t++){let s=n[t],a=n[t+1];(s==='"'||s==="'")&&!o?(o=!0,l=s):s===l&&o?(o=!1,l=""):s===" "&&!o?i&&(r.push(i),i=""):i+=s}return i&&r.push(i),{cmd:r[0]||"",args:r.slice(1)}}handleExit(n,r,i,o,l){if(l==="SIGTERM"&&!this.groups.has(n)){this.pidStore.deletePid(n,r.name).catch(()=>{});return}if(i==="unless-stopped"&&l==="SIGTERM"){this.pidStore.deletePid(n,r.name).catch(()=>{});return}if(i==="no"){this.pidStore.deletePid(n,r.name).catch(()=>{});return}let t=`${n}-${r.name}`,s=Date.now(),u=(this.restartTimestamps.get(t)||[]).filter(f=>s-f<this.restartWindow);if(u.push(s),this.restartTimestamps.set(t,u),u.length>this.maxRestarts){console.error(`[${r.name}] Crash loop detected. Stopping restarts.`),this.pidStore.deletePid(n,r.name).catch(()=>{});return}setTimeout(()=>{console.log(`[${r.name}] Restarting... (exit code: ${o})`);let f=this.spawnProcess(r,n,i);this.emit("item-restarted",n,r.name);let c=this.groups.get(n);if(c){let p=c.find(d=>d.item.name===r.name);p&&(p.process=f)}},1e3)}killGroup(n){let r=this.groups.get(n);if(!r)return Promise.resolve();let i=r.map(o=>this.killProcess(o.process));return this.groups.delete(n),Promise.all(i).then(async()=>{await this.pidStore.deleteGroupPids(n),this.emit("group-stopped",n)})}killPid(n){return new Promise((r,i)=>{try{process.kill(n,"SIGTERM");let o=setTimeout(()=>{try{process.kill(n,"SIGKILL")}catch{}},5e3),l=setInterval(()=>{this.pidStore.isPidRunning(n)||(clearTimeout(o),clearInterval(l),r())},100);this.pidStore.isPidRunning(n)||(clearTimeout(o),clearInterval(l),r())}catch(o){i(o)}})}killProcess(n){return new Promise(r=>{n.kill("SIGTERM");let i=setTimeout(()=>{n.killed||n.kill("SIGKILL")},5e3);n.on("exit",()=>{clearTimeout(i),r()}),(n.killed||n.exitCode!==null)&&(clearTimeout(i),r())})}killAll(){let n=[];for(let r of this.groups.keys())n.push(this.killGroup(r));return Promise.all(n).then(()=>{})}async cleanupStalePids(){await this.pidStore.cleanupStalePids()}getGroupStatus(n){let r=this.groups.get(n);return r?r.map(i=>i.status):[]}isGroupRunning(n){return this.groups.has(n)}getRunningGroups(){return Array.from(this.groups.keys())}};async function ke(e){let n=new k,r=new Y,i=new B;try{await i.cleanupStalePids();let{config:o,items:l,tool:t,toolTemplate:s,params:a,restart:u}=n.getGroup(e),f=l.map((c,p)=>D.parseItem(t,s,c,p,a));return r.spawnGroup(e,f,u),console.log(`Started group ${e} with ${f.length} process(es)`),console.log("Press Ctrl+C to stop..."),new Promise(c=>{let p=async()=>{console.log(`
39
+ Shutting down...`),process.removeListener("SIGINT",p),process.removeListener("SIGTERM",p),await r.killAll(),c(0)};process.on("SIGINT",p),process.on("SIGTERM",p)})}catch(o){if(o instanceof Error&&o.name==="ConfigError")return console.error(o.message),1;throw o}}async function Rn(e){let n=new k;try{let{config:r,restart:i}=n.getGroup(e);console.log(`
40
+ Group: ${e}`),console.log(`Tool: ${r.tool}`),console.log(`Restart: ${i}`),console.log(`
41
+ Items:`);let o=new Set(r.disabledItems||[]);for(let[l,t]of Object.entries(r.items||{})){let s=o.has(l)?" [disabled]":"";console.log(` ${l}: ${t}${s}`)}return console.log(""),0}catch(r){if(r instanceof Error&&r.name==="ConfigError")return console.error(r.message),1;throw r}}import{spawn as fo,spawnSync as Mn}from"child_process";import U from"fs";import po from"os";import Oe from"path";var Dn=".cligr.yml",mo=`# Cligr Configuration
42
42
 
43
43
  groups:
44
44
  web:
@@ -64,18 +64,18 @@ tools:
64
64
  # - $1 = name (first value)
65
65
  # - $2, $3... = additional arguments
66
66
  # - If no tool specified, executes directly
67
- `;function mo(){let e=process.platform;return Mn(e==="win32"?"where":"which",["code"],{stdio:"ignore"}).status===0?"code":process.env.EDITOR?process.env.EDITOR:e==="win32"?"notepad.exe":"vim"}function go(e,n){let r=process.platform;if(Mn(r==="win32"?"where":"which",[n],{stdio:"ignore"}).status!==0&&n!==process.env.EDITOR)throw new Error(`Editor '${n}' not found.
67
+ `;function ho(){let e=process.platform;return Mn(e==="win32"?"where":"which",["code"],{stdio:"ignore"}).status===0?"code":process.env.EDITOR?process.env.EDITOR:e==="win32"?"notepad.exe":"vim"}function go(e,n){let r=process.platform;if(Mn(r==="win32"?"where":"which",[n],{stdio:"ignore"}).status!==0&&n!==process.env.EDITOR)throw new Error(`Editor '${n}' not found.
68
68
  Install VS Code or set EDITOR environment variable.
69
69
 
70
70
  Example:
71
71
  export EDITOR=vim
72
- cligr config`);fo(n,[e],{detached:!0,stdio:"ignore",shell:r==="win32"}).unref()}function xo(e){let n=_e.dirname(e);U.existsSync(n)||U.mkdirSync(n,{recursive:!0}),U.writeFileSync(e,ho,"utf-8")}async function $n(){try{let e=_e.join(po.homedir(),Dn),n=_e.resolve(Dn),r;U.existsSync(e)?r=e:U.existsSync(n)?r=n:r=e,U.existsSync(r)||xo(r);let i=mo();return go(r,i),console.log(`Opening ${r} in ${i}...`),0}catch(e){return console.error(`Error: ${e.message}`),1}}async function jn(e){let n=new O;try{let r=n.listGroups();if(r.length===0)return 0;if(e){let i=n.load(),o=[];for(let u of r){let f=i.groups[u];o.push({name:u,tool:f.tool||"(none)",restart:f.restart||"(none)",itemCount:Object.keys(f.items||{}).length})}let l=Math.max(5,...o.map(u=>u.name.length)),t=Math.max(4,...o.map(u=>u.tool.length)),a=Math.max(7,...o.map(u=>u.restart.length)),c="GROUP".padEnd(l)+" "+"TOOL".padEnd(t)+" "+"RESTART".padEnd(a)+" ITEMS";console.log(c);for(let u of o){let f=u.name.padEnd(l)+" "+u.tool.padEnd(t)+" "+u.restart.padEnd(a)+" "+String(u.itemCount);console.log(f)}}else for(let i of r)console.log(i);return 0}catch(r){return console.error(r.message),1}}import vo from"http";async function Hn(e){let n=e?parseInt(e,10):7373,r=new O,i=new Y;await i.cleanupStalePids();let o=[],l=(f,s)=>{let p=`event: ${f}
73
- data: ${JSON.stringify(s)}
72
+ cligr config`);fo(n,[e],{detached:!0,stdio:"ignore",shell:r==="win32"}).unref()}function xo(e){let n=Oe.dirname(e);U.existsSync(n)||U.mkdirSync(n,{recursive:!0}),U.writeFileSync(e,mo,"utf-8")}async function $n(){try{let e=Oe.join(po.homedir(),Dn),n=Oe.resolve(Dn),r;U.existsSync(e)?r=e:U.existsSync(n)?r=n:r=e,U.existsSync(r)||xo(r);let i=ho();return go(r,i),console.log(`Opening ${r} in ${i}...`),0}catch(e){return console.error(`Error: ${e.message}`),1}}async function Gn(e){let n=new k;try{let r=n.listGroups();if(r.length===0)return 0;if(e){let i=n.load(),o=[];for(let u of r){let f=i.groups[u];o.push({name:u,tool:f.tool||"(none)",restart:n.getEffectiveRestart(u)||"(none)",itemCount:Object.keys(f.items||{}).length})}let l=Math.max(5,...o.map(u=>u.name.length)),t=Math.max(4,...o.map(u=>u.tool.length)),s=Math.max(7,...o.map(u=>u.restart.length)),a="GROUP".padEnd(l)+" "+"TOOL".padEnd(t)+" "+"RESTART".padEnd(s)+" ITEMS";console.log(a);for(let u of o){let f=u.name.padEnd(l)+" "+u.tool.padEnd(t)+" "+u.restart.padEnd(s)+" "+String(u.itemCount);console.log(f)}}else for(let i of r)console.log(i);return 0}catch(r){return console.error(r.message),1}}import vo from"http";async function jn(e){let n=e?parseInt(e,10):7373,r=new k,i=new Y;await i.cleanupStalePids();let o=[],l=(f,c)=>{let p=`event: ${f}
73
+ data: ${JSON.stringify(c)}
74
74
 
75
- `;for(let d=o.length-1;d>=0;d--){let x=o[d];try{x.write(p)}catch{o.splice(d,1);try{x.end()}catch{}}}};i.on("group-started",f=>{l("status",{type:"group-started",groupName:f})}),i.on("group-stopped",f=>{l("status",{type:"group-stopped",groupName:f})}),i.on("item-restarted",(f,s)=>{l("status",{type:"item-restarted",groupName:f,itemName:s})}),i.on("process-log",(f,s,p,d)=>{l("log",{group:f,item:s,line:p,isError:d})});let t=vo.createServer((f,s)=>{let p=new URL(f.url||"/",`http://localhost:${n}`);if(s.setHeader("Access-Control-Allow-Origin","*"),s.setHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS"),s.setHeader("Access-Control-Allow-Headers","Content-Type"),f.method==="OPTIONS"){s.writeHead(204),s.end();return}if(p.pathname==="/"){s.setHeader("Content-Type","text/html"),s.writeHead(200),s.end(yo());return}if(p.pathname==="/api/groups"){try{let m=r.load(),v=Object.entries(m.groups).map(([y,g])=>({name:y,tool:g.tool,restart:g.restart,items:Object.entries(g.items||{}).map(([k,N])=>({name:k,value:N,enabled:!(g.disabledItems||[]).includes(k)})),running:i.isGroupRunning(y)}));s.setHeader("Content-Type","application/json"),s.writeHead(200),s.end(JSON.stringify({groups:v}))}catch(m){s.setHeader("Content-Type","application/json"),s.writeHead(500),s.end(JSON.stringify({error:m.message}))}return}if(p.pathname==="/api/events"){s.setHeader("Content-Type","text/event-stream"),s.setHeader("Cache-Control","no-cache"),s.setHeader("Connection","keep-alive"),s.writeHead(200),s.write(`:ok
75
+ `;for(let d=o.length-1;d>=0;d--){let x=o[d];try{x.write(p)}catch{o.splice(d,1);try{x.end()}catch{}}}};i.on("group-started",f=>{l("status",{type:"group-started",groupName:f})}),i.on("group-stopped",f=>{l("status",{type:"group-stopped",groupName:f})}),i.on("item-restarted",(f,c)=>{l("status",{type:"item-restarted",groupName:f,itemName:c})}),i.on("process-log",(f,c,p,d)=>{l("log",{group:f,item:c,line:p,isError:d})});let t=vo.createServer((f,c)=>{let p=new URL(f.url||"/",`http://localhost:${n}`);if(c.setHeader("Access-Control-Allow-Origin","*"),c.setHeader("Access-Control-Allow-Methods","GET, POST, OPTIONS"),c.setHeader("Access-Control-Allow-Headers","Content-Type"),f.method==="OPTIONS"){c.writeHead(204),c.end();return}if(p.pathname==="/"){c.setHeader("Content-Type","text/html"),c.writeHead(200),c.end(yo());return}if(p.pathname==="/api/groups"){try{let h=r.load(),v=Object.entries(h.groups).map(([y,g])=>({name:y,tool:g.tool,restart:r.getEffectiveRestart(y),items:Object.entries(g.items||{}).map(([_,L])=>({name:_,value:L,enabled:!(g.disabledItems||[]).includes(_)})),running:i.isGroupRunning(y)}));c.setHeader("Content-Type","application/json"),c.writeHead(200),c.end(JSON.stringify({groups:v}))}catch(h){c.setHeader("Content-Type","application/json"),c.writeHead(500),c.end(JSON.stringify({error:h.message}))}return}if(p.pathname==="/api/events"){c.setHeader("Content-Type","text/event-stream"),c.setHeader("Cache-Control","no-cache"),c.setHeader("Connection","keep-alive"),c.writeHead(200),c.write(`:ok
76
76
 
77
- `),o.push(s),f.on("close",()=>{let m=o.indexOf(s);m!==-1&&o.splice(m,1)});return}let d=p.pathname.match(/^\/api\/groups\/([^/]+)\/toggle$/);if(d&&f.method==="POST"){let m=decodeURIComponent(d[1]),v="";f.on("data",y=>v+=y),f.on("end",async()=>{let y;try{y=JSON.parse(v)}catch{s.writeHead(400),s.end(JSON.stringify({error:"Invalid JSON"}));return}let{enabled:g}=y;try{if(g){let{config:k,items:N,tool:le,toolTemplate:ae,params:ce}=r.getGroup(m),se=N.map((ue,fe)=>D.parseItem(le,ae,ue,fe,ce));i.spawnGroup(m,se,k.restart)}else await i.killGroup(m);s.setHeader("Content-Type","application/json"),s.writeHead(200),s.end(JSON.stringify({success:!0}))}catch(k){s.setHeader("Content-Type","application/json"),s.writeHead(500),s.end(JSON.stringify({error:k.message}))}});return}let x=p.pathname.match(/^\/api\/groups\/([^/]+)\/items\/([^/]+)\/toggle$/);if(x&&f.method==="POST"){let m=decodeURIComponent(x[1]),v=decodeURIComponent(x[2]),y="";f.on("data",g=>y+=g),f.on("end",async()=>{let g;try{g=JSON.parse(y)}catch{s.writeHead(400),s.end(JSON.stringify({error:"Invalid JSON"}));return}let{enabled:k}=g;try{if(r.toggleItem(m,v,k),i.isGroupRunning(m)){let{config:N,items:le,tool:ae,toolTemplate:ce,params:se}=r.getGroup(m),ue=le.map((fe,Bn)=>D.parseItem(ae,ce,fe,Bn,se));await i.restartGroup(m,ue,N.restart)}s.setHeader("Content-Type","application/json"),s.writeHead(200),s.end(JSON.stringify({success:!0}))}catch(N){s.setHeader("Content-Type","application/json"),s.writeHead(500),s.end(JSON.stringify({error:N.message}))}});return}s.writeHead(404),s.end("Not found")});t.on("error",f=>{f.code==="EADDRINUSE"?(console.error(`Port ${n} is already in use`),process.exit(1)):(console.error("Server error:",f),process.exit(2))});let a,c=new Promise(f=>{a=f}),u=async()=>{console.log(`
78
- Shutting down...`),t.close(),await i.killAll(),a(0)};return process.on("SIGINT",u),process.on("SIGTERM",u),t.listen(n,()=>{console.log(`cligr serve running at http://localhost:${n}`)}),c}function yo(){return`<!DOCTYPE html>
77
+ `),o.push(c),f.on("close",()=>{let h=o.indexOf(c);h!==-1&&o.splice(h,1)});return}let d=p.pathname.match(/^\/api\/groups\/([^/]+)\/toggle$/);if(d&&f.method==="POST"){let h=decodeURIComponent(d[1]),v="";f.on("data",y=>v+=y),f.on("end",async()=>{let y;try{y=JSON.parse(v)}catch{c.writeHead(400),c.end(JSON.stringify({error:"Invalid JSON"}));return}let{enabled:g}=y;try{if(g){let{items:_,tool:L,toolTemplate:le,params:se,restart:ae}=r.getGroup(h),ce=_.map((ue,fe)=>D.parseItem(L,le,ue,fe,se));i.spawnGroup(h,ce,ae)}else await i.killGroup(h);c.setHeader("Content-Type","application/json"),c.writeHead(200),c.end(JSON.stringify({success:!0}))}catch(_){c.setHeader("Content-Type","application/json"),c.writeHead(500),c.end(JSON.stringify({error:_.message}))}});return}let x=p.pathname.match(/^\/api\/groups\/([^/]+)\/items\/([^/]+)\/toggle$/);if(x&&f.method==="POST"){let h=decodeURIComponent(x[1]),v=decodeURIComponent(x[2]),y="";f.on("data",g=>y+=g),f.on("end",async()=>{let g;try{g=JSON.parse(y)}catch{c.writeHead(400),c.end(JSON.stringify({error:"Invalid JSON"}));return}let{enabled:_}=g;try{if(r.toggleItem(h,v,_),i.isGroupRunning(h)){let{items:L,tool:le,toolTemplate:se,params:ae,restart:ce}=r.getGroup(h),ue=L.map((fe,Bn)=>D.parseItem(le,se,fe,Bn,ae));await i.restartGroup(h,ue,ce)}c.setHeader("Content-Type","application/json"),c.writeHead(200),c.end(JSON.stringify({success:!0}))}catch(L){c.setHeader("Content-Type","application/json"),c.writeHead(500),c.end(JSON.stringify({error:L.message}))}});return}c.writeHead(404),c.end("Not found")});t.on("error",f=>{f.code==="EADDRINUSE"?(console.error(`Port ${n} is already in use`),process.exit(1)):(console.error("Server error:",f),process.exit(2))});let s,a=new Promise(f=>{s=f}),u=async()=>{console.log(`
78
+ Shutting down...`),t.close(),await i.killAll(),s(0)};return process.on("SIGINT",u),process.on("SIGTERM",u),t.listen(n,()=>{console.log(`cligr serve running at http://localhost:${n}`)}),a}function yo(){return`<!DOCTYPE html>
79
79
  <html>
80
80
  <head>
81
81
  <meta charset="utf-8">
@@ -273,7 +273,7 @@ Shutting down...`),t.close(),await i.killAll(),a(0)};return process.on("SIGINT",
273
273
  fetchGroups();
274
274
  </script>
275
275
  </body>
276
- </html>`}async function wo(){let e=process.argv.slice(2);if(e.length===0){Gn(),process.exit(1);return}let[n,...r]=e,i=!1;if(["config","up","ls","groups","serve"].includes(n)){let l=n,t;if(l==="groups"){let c=r.findIndex(u=>u==="-v"||u==="--verbose");c!==-1&&(i=!0,r.splice(c,1))}if(t=r[0],l!=="config"&&l!=="groups"&&l!=="serve"&&!t){console.error("Error: group name required"),Gn(),process.exit(1);return}let a=0;switch(l){case"config":a=await $n();break;case"up":a=await Oe(t);break;case"ls":a=await Rn(t);break;case"groups":a=await jn(i);break;case"serve":a=await Hn(r[0]);break}process.exit(a)}else{let l=await Oe(n);process.exit(l)}}function Gn(){console.log(`
276
+ </html>`}async function wo(){let e=process.argv.slice(2);if(e.length===0){Hn(),process.exit(1);return}let[n,...r]=e,i=!1;if(["config","up","ls","groups","serve"].includes(n)){let l=n,t;if(l==="groups"){let a=r.findIndex(u=>u==="-v"||u==="--verbose");a!==-1&&(i=!0,r.splice(a,1))}if(t=r[0],l!=="config"&&l!=="groups"&&l!=="serve"&&!t){console.error("Error: group name required"),Hn(),process.exit(1);return}let s=0;switch(l){case"config":s=await $n();break;case"up":s=await ke(t);break;case"ls":s=await Rn(t);break;case"groups":s=await Gn(i);break;case"serve":s=await jn(r[0]);break}process.exit(s)}else{let l=await ke(n);process.exit(l)}}function Hn(){console.log(`
277
277
  Usage: cligr <group> | <command> [options]
278
278
 
279
279
  Commands:
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cligr",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "main": "dist/index.js",
5
5
  "bin": {
6
6
  "cligr": "dist/index.js"
@@ -28,7 +28,7 @@ export async function groupsCommand(verbose: boolean): Promise<number> {
28
28
  details.push({
29
29
  name,
30
30
  tool: group.tool || '(none)',
31
- restart: group.restart || '(none)',
31
+ restart: loader.getEffectiveRestart(name) || '(none)',
32
32
  itemCount: Object.keys(group.items || {}).length,
33
33
  });
34
34
  }
@@ -4,11 +4,11 @@ export async function lsCommand(groupName: string): Promise<number> {
4
4
  const loader = new ConfigLoader();
5
5
 
6
6
  try {
7
- const { config } = loader.getGroup(groupName);
7
+ const { config, restart } = loader.getGroup(groupName);
8
8
 
9
9
  console.log(`\nGroup: ${groupName}`);
10
10
  console.log(`Tool: ${config.tool}`);
11
- console.log(`Restart: ${config.restart}`);
11
+ console.log(`Restart: ${restart}`);
12
12
  console.log('\nItems:');
13
13
 
14
14
  const disabled = new Set(config.disabledItems || []);
@@ -69,7 +69,7 @@ export async function serveCommand(portArg?: string): Promise<number> {
69
69
  const groups = Object.entries(config.groups).map(([name, group]) => ({
70
70
  name,
71
71
  tool: group.tool,
72
- restart: group.restart,
72
+ restart: loader.getEffectiveRestart(name),
73
73
  items: Object.entries(group.items || {}).map(([itemName, value]) => ({
74
74
  name: itemName,
75
75
  value,
@@ -119,11 +119,11 @@ export async function serveCommand(portArg?: string): Promise<number> {
119
119
  const { enabled } = parsed;
120
120
  try {
121
121
  if (enabled) {
122
- const { config, items, tool, toolTemplate, params } = loader.getGroup(groupName);
122
+ const { items, tool, toolTemplate, params, restart } = loader.getGroup(groupName);
123
123
  const processItems = items.map((item, index) =>
124
124
  TemplateExpander.parseItem(tool, toolTemplate, item, index, params)
125
125
  );
126
- manager.spawnGroup(groupName, processItems, config.restart);
126
+ manager.spawnGroup(groupName, processItems, restart);
127
127
  } else {
128
128
  await manager.killGroup(groupName);
129
129
  }
@@ -159,11 +159,11 @@ export async function serveCommand(portArg?: string): Promise<number> {
159
159
  loader.toggleItem(groupName, itemName, enabled);
160
160
 
161
161
  if (manager.isGroupRunning(groupName)) {
162
- const { config, items, tool, toolTemplate, params } = loader.getGroup(groupName);
162
+ const { items, tool, toolTemplate, params, restart } = loader.getGroup(groupName);
163
163
  const processItems = items.map((item, index) =>
164
164
  TemplateExpander.parseItem(tool, toolTemplate, item, index, params)
165
165
  );
166
- await manager.restartGroup(groupName, processItems, config.restart);
166
+ await manager.restartGroup(groupName, processItems, restart);
167
167
  }
168
168
 
169
169
  res.setHeader('Content-Type', 'application/json');
@@ -13,7 +13,7 @@ export async function upCommand(groupName: string): Promise<number> {
13
13
  await pidStore.cleanupStalePids();
14
14
 
15
15
  // Load group config
16
- const { config, items, tool, toolTemplate, params } = loader.getGroup(groupName);
16
+ const { config, items, tool, toolTemplate, params, restart } = loader.getGroup(groupName);
17
17
 
18
18
  // Build process items
19
19
  const processItems = items.map((item, index) =>
@@ -21,7 +21,7 @@ export async function upCommand(groupName: string): Promise<number> {
21
21
  );
22
22
 
23
23
  // Spawn all processes
24
- manager.spawnGroup(groupName, processItems, config.restart);
24
+ manager.spawnGroup(groupName, processItems, restart);
25
25
 
26
26
  console.log(`Started group ${groupName} with ${processItems.length} process(es)`);
27
27
  console.log('Press Ctrl+C to stop...');
@@ -147,7 +147,7 @@ export class ConfigLoader {
147
147
  }));
148
148
  }
149
149
 
150
- getGroup(name: string): { config: GroupConfig; items: ItemEntry[]; tool: string | null; toolTemplate: string | null; params: Record<string, string> } {
150
+ getGroup(name: string): { config: GroupConfig; items: ItemEntry[]; tool: string | null; toolTemplate: string | null; params: Record<string, string>; restart: GroupConfig['restart'] } {
151
151
  const config = this.load();
152
152
  const group = config.groups[name];
153
153
 
@@ -178,8 +178,21 @@ export class ConfigLoader {
178
178
  }
179
179
 
180
180
  const params = group.params || {};
181
+ const restart = group.restart ?? config.tools?.[group.tool]?.restart;
181
182
 
182
- return { config: group, items, tool, toolTemplate, params };
183
+ return { config: group, items, tool, toolTemplate, params, restart };
184
+ }
185
+
186
+ getEffectiveRestart(groupName: string): GroupConfig['restart'] {
187
+ const config = this.load();
188
+ const group = config.groups[groupName];
189
+
190
+ if (!group) {
191
+ const available = Object.keys(config.groups).join(', ');
192
+ throw new ConfigError(`Unknown group: ${groupName}. Available: ${available}`);
193
+ }
194
+
195
+ return group.restart ?? (config.tools && config.tools[group.tool]?.restart) ?? undefined;
183
196
  }
184
197
 
185
198
  saveConfig(config: CliGrConfig): void {
@@ -1,5 +1,6 @@
1
1
  export interface ToolConfig {
2
2
  cmd: string;
3
+ restart?: 'yes' | 'no' | 'unless-stopped';
3
4
  }
4
5
 
5
6
  export interface ItemEntry {
@@ -198,6 +198,31 @@ groups:
198
198
  assert.ok(output.includes('postgres'));
199
199
  });
200
200
 
201
+ it('should show inherited restart from tool in ls output', async () => {
202
+ const configContent = `
203
+ tools:
204
+ docker:
205
+ cmd: docker run -it --rm
206
+ restart: yes
207
+
208
+ groups:
209
+ web:
210
+ tool: docker
211
+ items:
212
+ nginx: nginx
213
+ `;
214
+
215
+ fs.writeFileSync(testConfigPath, configContent);
216
+ resetOutput();
217
+
218
+ const exitCode = await lsCommand('web');
219
+
220
+ assert.strictEqual(exitCode, 0);
221
+ const output = getLogOutput();
222
+ assert.ok(output.includes('Group: web'));
223
+ assert.ok(output.includes('Restart: yes'));
224
+ });
225
+
201
226
  it('should list items with correct arguments', async () => {
202
227
  const configContent = `
203
228
  groups:
@@ -644,6 +669,32 @@ groups:
644
669
  assert.ok(output.includes('1')); // item count for direct
645
670
  });
646
671
 
672
+ it('should show inherited restart from tool in verbose mode', async () => {
673
+ const configContent = `
674
+ tools:
675
+ docker:
676
+ cmd: docker run
677
+ restart: yes
678
+
679
+ groups:
680
+ web:
681
+ tool: docker
682
+ items:
683
+ nginx: nginx
684
+ `;
685
+ fs.writeFileSync(testConfigPath, configContent);
686
+ resetOutput();
687
+
688
+ const exitCode = await groupsCommand(true);
689
+
690
+ assert.strictEqual(exitCode, 0);
691
+ const output = getLogOutput();
692
+ assert.ok(output.includes('GROUP'));
693
+ assert.ok(output.includes('RESTART'));
694
+ assert.ok(output.includes('web'));
695
+ assert.ok(output.includes('yes'));
696
+ });
697
+
647
698
  it('should handle empty groups list', async () => {
648
699
  const configContent = `
649
700
  groups: {}
@@ -532,5 +532,77 @@ groups:
532
532
  assert.strictEqual(loader.getGroup('restart-no').config.restart, 'no');
533
533
  assert.strictEqual(loader.getGroup('restart-unless-stopped').config.restart, 'unless-stopped');
534
534
  });
535
+
536
+ it('should inherit restart from tool when group has no restart', () => {
537
+ const configContent = `
538
+ tools:
539
+ docker:
540
+ cmd: docker run
541
+ restart: yes
542
+
543
+ groups:
544
+ web:
545
+ tool: docker
546
+ items:
547
+ nginx: nginx
548
+ `;
549
+
550
+ fs.writeFileSync(testConfigPath, configContent);
551
+
552
+ const loader = new ConfigLoader();
553
+ const result = loader.getGroup('web');
554
+
555
+ assert.strictEqual(result.config.restart, undefined);
556
+ assert.strictEqual(result.restart, 'yes');
557
+ assert.strictEqual(loader.getEffectiveRestart('web'), 'yes');
558
+ });
559
+
560
+ it('should allow group restart to override tool restart', () => {
561
+ const configContent = `
562
+ tools:
563
+ docker:
564
+ cmd: docker run
565
+ restart: yes
566
+
567
+ groups:
568
+ web:
569
+ tool: docker
570
+ restart: no
571
+ items:
572
+ nginx: nginx
573
+ `;
574
+
575
+ fs.writeFileSync(testConfigPath, configContent);
576
+
577
+ const loader = new ConfigLoader();
578
+ const result = loader.getGroup('web');
579
+
580
+ assert.strictEqual(result.config.restart, 'no');
581
+ assert.strictEqual(result.restart, 'no');
582
+ assert.strictEqual(loader.getEffectiveRestart('web'), 'no');
583
+ });
584
+
585
+ it('should return undefined restart when neither group nor tool defines it', () => {
586
+ const configContent = `
587
+ tools:
588
+ docker:
589
+ cmd: docker run
590
+
591
+ groups:
592
+ web:
593
+ tool: docker
594
+ items:
595
+ nginx: nginx
596
+ `;
597
+
598
+ fs.writeFileSync(testConfigPath, configContent);
599
+
600
+ const loader = new ConfigLoader();
601
+ const result = loader.getGroup('web');
602
+
603
+ assert.strictEqual(result.config.restart, undefined);
604
+ assert.strictEqual(result.restart, undefined);
605
+ assert.strictEqual(loader.getEffectiveRestart('web'), undefined);
606
+ });
535
607
  });
536
608
  });