useakit 0.2.0-dev.26 → 0.2.0-dev.27

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.
Files changed (3) hide show
  1. package/README.md +12 -0
  2. package/dist/index.mjs +102 -94
  3. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,80 +1,80 @@
1
1
  #!/usr/bin/env node
2
- import{createRequire as e}from"node:module";import{parseArgs as t,styleText as n}from"node:util";import r,{stdin as i,stdout as a}from"node:process";import o,*as s from"node:readline";import{ReadStream as c}from"node:tty";import{existsSync as l,watch as u}from"node:fs";import{basename as d,dirname as f,join as p,parse as m,relative as h,resolve as g,sep as _}from"node:path";import{homedir as v,hostname as y,tmpdir as b,userInfo as x}from"node:os";import{appendFile as S,chmod as C,copyFile as w,mkdir as T,open as E,readFile as D,readdir as ee,rename as te,rm as O,stat as ne,unlink as re,writeFile as k}from"node:fs/promises";import{createHash as ie,randomUUID as ae}from"node:crypto";import{execFileSync as oe,spawn as se}from"node:child_process";import{fileURLToPath as ce}from"node:url";var A=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),le=/* @__PURE__ */ e(import.meta.url);const ue=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),de=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,fe=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,pe=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,me=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,he=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,ge=/\t{1,1000}/y,_e=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,ve=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,ye=/\p{M}+/gu,be={limit:1/0,ellipsis:``},xe=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?xe(i,be,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[ve,l],[pe,0],[me,o],[ge,s],[_e,c],[he,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(ye,``)){let t=e.codePointAt(0)||0;if(S=de(t)?2:fe(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===he?ue(e.slice(p,n.lastIndex)):n===_e?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},Se={limit:1/0,ellipsis:``,ellipsisWidth:0},j=(e,t={})=>xe(e,Se,t).width,Ce=`]8;;`,we=RegExp(`(?:\\[(?<code>\\d+)m|\\${Ce}(?<uri>.*))`,`y`),Te=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Ee=e=>`[${e}m`,De=e=>`${Ce}${e}`,Oe=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:j(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=j(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Ce,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},ke=e=>{let t=e.split(` `),n=t.length;for(;n&&!j(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Ae=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=j(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=j(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Oe(s,r,t),c=j(s.at(-1)??``)}else{if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Oe(s,r,t),c=j(s.at(-1)??``);continue}s.push(``),c=0}c+i>t&&n.wordWrap===!1?(Oe(s,r,t),c=j(s.at(-1)??``)):(s[s.length-1]+=r,c+=i)}}n.trim!==!1&&(s=s.map(e=>ke(e)));let l=s.join(`
3
- `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){we.lastIndex=e+1;let t=we.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
4
- `){a&&(r+=De(``));let e=i?Te(i):void 0;i&&e&&(r+=Ee(e))}else t===`
5
- `&&(i&&Te(i)&&(r+=Ee(i)),a&&(r+=De(a)))}return r},je=/\r?\n/;function Me(e,t,n){return String(e).normalize().split(je).map(e=>Ae(e,t,n)).join(`
6
- `)}var M=(/* @__PURE__ */ A(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})))();function Ne(e,t,n){if(!n.some(e=>!e.disabled))return e;let r=e+t,i=Math.max(n.length-1,0),a=r<0?i:r>i?0:r;return n[a]?.disabled?Ne(a,t<0?-1:1,n):a}const N={actions:/* @__PURE__ */ new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:/* @__PURE__ */ new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]]),messages:{cancel:`Canceled`,error:`Something went wrong`},withGuide:!0,accessible:void 0,date:{monthNames:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],messages:{required:`Please enter a valid date`,invalidMonth:`There are only 12 months in a year`,invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Pe(e){if(e!==void 0)return e;if(N.accessible!==void 0)return N.accessible;let t=process.env.ACCESSIBLE;return t!==void 0&&t!==``&&t!==`0`&&t!==`false`}function Fe(e,t){if(typeof e==`string`)return N.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Fe(n,t))return!0;return!1}function Ie(e,t){if(e===t)return;let n=e.split(`
2
+ import{createRequire as e}from"node:module";import{parseArgs as t,styleText as n}from"node:util";import r,{stdin as i,stdout as a}from"node:process";import o,*as s from"node:readline";import{ReadStream as c}from"node:tty";import{existsSync as l,watch as u}from"node:fs";import{basename as d,dirname as f,join as p,parse as m,relative as h,resolve as g,sep as _}from"node:path";import{arch as v,homedir as y,hostname as b,platform as x,tmpdir as S,userInfo as C}from"node:os";import{appendFile as w,chmod as T,copyFile as E,mkdir as D,open as ee,readFile as O,readdir as te,rename as ne,rm as k,stat as re,unlink as ie,writeFile as A}from"node:fs/promises";import{createHash as ae,randomUUID as oe}from"node:crypto";import{execFile as se,execFileSync as ce,spawn as le}from"node:child_process";import{fileURLToPath as ue}from"node:url";var j=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t,t.exports),e=null),t.exports),de=/* @__PURE__ */ e(import.meta.url);const fe=(()=>{let e=/[\uD800-\uDBFF][\uDC00-\uDFFF]/g;return t=>{let n=0;for(e.lastIndex=0;e.test(t);)n+=1;return t.length-n}})(),pe=e=>e===12288||e>=65281&&e<=65376||e>=65504&&e<=65510,me=e=>e===8987||e===9001||e>=12272&&e<=12287||e>=12289&&e<=12350||e>=12441&&e<=12543||e>=12549&&e<=12591||e>=12593&&e<=12686||e>=12688&&e<=12771||e>=12783&&e<=12830||e>=12832&&e<=12871||e>=12880&&e<=19903||e>=65040&&e<=65049||e>=65072&&e<=65106||e>=65108&&e<=65126||e>=65128&&e<=65131||e>=127488&&e<=127490||e>=127504&&e<=127547||e>=127552&&e<=127560||e>=131072&&e<=196605||e>=196608&&e<=262141,he=/[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]|\u001b\]8;[^;]*;.*?(?:\u0007|\u001b\u005c)/y,ge=/[\x00-\x08\x0A-\x1F\x7F-\x9F]{1,1000}/y,_e=/(?:(?![\uFF61-\uFF9F\uFF00-\uFFEF])[\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}\p{Script=Hangul}\p{Script=Tangut}]){1,1000}/uy,ve=/\t{1,1000}/y,ye=/[\u{1F1E6}-\u{1F1FF}]{2}|\u{1F3F4}[\u{E0061}-\u{E007A}]{2}[\u{E0030}-\u{E0039}\u{E0061}-\u{E007A}]{1,3}\u{E007F}|(?:\p{Emoji}\uFE0F\u20E3?|\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation})(?:\u200D(?:\p{Emoji_Modifier_Base}\p{Emoji_Modifier}?|\p{Emoji_Presentation}|\p{Emoji}\uFE0F\u20E3?))*/uy,be=/(?:[\x20-\x7E\xA0-\xFF](?!\uFE0F)){1,1000}/y,xe=/\p{M}+/gu,Se={limit:1/0,ellipsis:``},Ce=(e,t={},n={})=>{let r=t.limit??1/0,i=t.ellipsis??``,a=t?.ellipsisWidth??(i?Ce(i,Se,n).width:0),o=n.controlWidth??0,s=n.tabWidth??8,c=n.emojiWidth??2,l=n.regularWidth??1,u=n.wideWidth??2,d=[[be,l],[he,0],[ge,o],[ve,s],[ye,c],[_e,u]],f=0,p=0,m=e.length,h=0,g=!1,_=m,v=Math.max(0,r-a),y=0,b=0,x=0,S=0;outer:for(;;){if(b>y||p>=m&&p>f){let t=e.slice(y,b)||e.slice(f,p);h=0;for(let e of t.replaceAll(xe,``)){let t=e.codePointAt(0)||0;if(S=pe(t)?2:me(t)?u:l,x+S>v&&(_=Math.min(_,Math.max(y,f)+h)),x+S>r){g=!0;break outer}h+=e.length,x+=S}y=b=0}if(p>=m)break outer;for(let t=0,n=d.length;t<n;t++){let[n,i]=d[t];if(n.lastIndex=p,n.test(e)){if(h=n===_e?fe(e.slice(p,n.lastIndex)):n===ye?1:n.lastIndex-p,S=h*i,x+S>v&&(_=Math.min(_,p+Math.floor((v-x)/i))),x+S>r){g=!0;break outer}x+=S,y=f,b=p,p=f=n.lastIndex;continue outer}}p+=1}return{width:g?v:x,index:g?_:m,truncated:g,ellipsed:g&&r>=a}},we={limit:1/0,ellipsis:``,ellipsisWidth:0},M=(e,t={})=>Ce(e,we,t).width,Te=`]8;;`,Ee=RegExp(`(?:\\[(?<code>\\d+)m|\\${Te}(?<uri>.*))`,`y`),De=e=>{if(e>=30&&e<=37||e>=90&&e<=97)return 39;if(e>=40&&e<=47||e>=100&&e<=107)return 49;if(e===1||e===2)return 22;if(e===3)return 23;if(e===4)return 24;if(e===7)return 27;if(e===8)return 28;if(e===9)return 29;if(e===0)return 0},Oe=e=>`[${e}m`,ke=e=>`${Te}${e}`,Ae=(e,t,n)=>{let r=t[Symbol.iterator](),i=!1,a=!1,o=e.at(-1),s=o===void 0?0:M(o),c=r.next(),l=r.next(),u=0;for(;!c.done;){let o=c.value,d=M(o);s+d<=n?e[e.length-1]+=o:(e.push(o),s=0),(o===`\x1B`||o===`›`)&&(i=!0,a=t.startsWith(Te,u+1)),i?a?o===`\x07`&&(i=!1,a=!1):o===`m`&&(i=!1):(s+=d,s===n&&!l.done&&(e.push(``),s=0)),c=l,l=r.next(),u+=o.length}o=e.at(-1),!s&&o!==void 0&&o.length&&e.length>1&&(e[e.length-2]+=e.pop())},je=e=>{let t=e.split(` `),n=t.length;for(;n&&!M(t[n-1]);)n--;return n===t.length?e:t.slice(0,n).join(` `)+t.slice(n).join(``)},Me=(e,t,n={})=>{if(n.trim!==!1&&e.trim()===``)return``;let r=``,i,a,o=e.split(` `),s=[``],c=0;for(let e=0;e<o.length;e++){let r=o[e];if(n.trim!==!1){let e=s.at(-1)??``,t=e.trimStart();e.length!==t.length&&(s[s.length-1]=t,c=M(t))}e!==0&&(c>=t&&(n.wordWrap===!1||n.trim===!1)&&(s.push(``),c=0),(c||n.trim===!1)&&(s[s.length-1]+=` `,c++));let i=M(r);if(n.hard&&i>t){let e=t-c,n=1+Math.floor((i-e-1)/t);Math.floor((i-1)/t)<n&&s.push(``),Ae(s,r,t),c=M(s.at(-1)??``)}else{if(c+i>t&&c&&i){if(n.wordWrap===!1&&c<t){Ae(s,r,t),c=M(s.at(-1)??``);continue}s.push(``),c=0}c+i>t&&n.wordWrap===!1?(Ae(s,r,t),c=M(s.at(-1)??``)):(s[s.length-1]+=r,c+=i)}}n.trim!==!1&&(s=s.map(e=>je(e)));let l=s.join(`
3
+ `),u=!1;for(let e=0;e<l.length;e++){let t=l[e];if(r+=t,u)u=!1;else if(u=t>=`\ud800`&&t<=`\udbff`,u)continue;if(t===`\x1B`||t===`›`){Ee.lastIndex=e+1;let t=Ee.exec(l)?.groups;if(t?.code!==void 0){let e=Number.parseFloat(t.code);i=e===39?void 0:e}else t?.uri!==void 0&&(a=t.uri.length===0?void 0:t.uri)}if(l[e+1]===`
4
+ `){a&&(r+=ke(``));let e=i?De(i):void 0;i&&e&&(r+=Oe(e))}else t===`
5
+ `&&(i&&De(i)&&(r+=Oe(i)),a&&(r+=ke(a)))}return r},Ne=/\r?\n/;function Pe(e,t,n){return String(e).normalize().split(Ne).map(e=>Me(e,t,n)).join(`
6
+ `)}var N=(/* @__PURE__ */ j(((e,t)=>{let n={to(e,t){return t?`[${t+1};${e+1}H`:`[${e+1}G`},move(e,t){let n=``;return e<0?n+=`[${-e}D`:e>0&&(n+=`[${e}C`),t<0?n+=`[${-t}A`:t>0&&(n+=`[${t}B`),n},up:(e=1)=>`[${e}A`,down:(e=1)=>`[${e}B`,forward:(e=1)=>`[${e}C`,backward:(e=1)=>`[${e}D`,nextLine:(e=1)=>`\x1B[E`.repeat(e),prevLine:(e=1)=>`\x1B[F`.repeat(e),left:`\x1B[G`,hide:`\x1B[?25l`,show:`\x1B[?25h`,save:`\x1B7`,restore:`\x1B8`};t.exports={cursor:n,scroll:{up:(e=1)=>`\x1B[S`.repeat(e),down:(e=1)=>`\x1B[T`.repeat(e)},erase:{screen:`\x1B[2J`,up:(e=1)=>`\x1B[1J`.repeat(e),down:(e=1)=>`\x1B[J`.repeat(e),line:`\x1B[2K`,lineEnd:`\x1B[K`,lineStart:`\x1B[1K`,lines(e){let t=``;for(let r=0;r<e;r++)t+=this.line+(r<e-1?n.up():``);return e&&(t+=n.left),t}},beep:`\x07`}})))();function Fe(e,t,n){if(!n.some(e=>!e.disabled))return e;let r=e+t,i=Math.max(n.length-1,0),a=r<0?i:r>i?0:r;return n[a]?.disabled?Fe(a,t<0?-1:1,n):a}const P={actions:/* @__PURE__ */ new Set([`up`,`down`,`left`,`right`,`space`,`enter`,`cancel`]),aliases:/* @__PURE__ */ new Map([[`k`,`up`],[`j`,`down`],[`h`,`left`],[`l`,`right`],[``,`cancel`],[`escape`,`cancel`]]),messages:{cancel:`Canceled`,error:`Something went wrong`},withGuide:!0,accessible:void 0,date:{monthNames:[`January`,`February`,`March`,`April`,`May`,`June`,`July`,`August`,`September`,`October`,`November`,`December`],messages:{required:`Please enter a valid date`,invalidMonth:`There are only 12 months in a year`,invalidDay:(e,t)=>`There are only ${e} days in ${t}`,afterMin:e=>`Date must be on or after ${e.toISOString().slice(0,10)}`,beforeMax:e=>`Date must be on or before ${e.toISOString().slice(0,10)}`}}};function Ie(e){if(e!==void 0)return e;if(P.accessible!==void 0)return P.accessible;let t=process.env.ACCESSIBLE;return t!==void 0&&t!==``&&t!==`0`&&t!==`false`}function Le(e,t){if(typeof e==`string`)return P.aliases.get(e)===t;for(let n of e)if(n!==void 0&&Le(n,t))return!0;return!1}function Re(e,t){if(e===t)return;let n=e.split(`
7
7
  `),r=t.split(`
8
- `),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}const Le=globalThis.process.platform.startsWith(`win`),Re=Symbol(`clack:cancel`);function ze(e){return e===Re}function Be(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Ve({input:e=i,output:t=a,overwrite:n=!0,hideCursor:r=!0}={}){let o=s.createInterface({input:e,output:t,prompt:``,tabSize:1});s.emitKeypressEvents(e,o),e instanceof c&&e.isTTY&&e.setRawMode(!0);let l=(i,{name:a,sequence:o})=>{if(Fe([String(i),a,o],`cancel`)){r&&t.write(M.cursor.show),process.exit(0);return}if(!n)return;let c=a===`return`?0:-1,u=a===`return`?-1:0;s.moveCursor(t,c,u,()=>{s.clearLine(t,1,()=>{e.once(`keypress`,l)})})};return r&&t.write(M.cursor.hide),e.once(`keypress`,l),()=>{e.off(`keypress`,l),r&&t.write(M.cursor.show),e instanceof c&&e.isTTY&&!Le&&e.setRawMode(!1),o.terminal=!1,o.close()}}const He=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,Ue=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function We(e,t,n,r=n,i=n,o){return Me(t,He(e??a)-n.length,{hard:!0,trim:!1}).split(`
8
+ `),i=Math.max(n.length,r.length),a=[];for(let e=0;e<i;e++)n[e]!==r[e]&&a.push(e);return{lines:a,numLinesBefore:n.length,numLinesAfter:r.length,numLines:i}}const ze=globalThis.process.platform.startsWith(`win`),Be=Symbol(`clack:cancel`);function Ve(e){return e===Be}function He(e,t){let n=e;n.isTTY&&n.setRawMode(t)}function Ue({input:e=i,output:t=a,overwrite:n=!0,hideCursor:r=!0}={}){let o=s.createInterface({input:e,output:t,prompt:``,tabSize:1});s.emitKeypressEvents(e,o),e instanceof c&&e.isTTY&&e.setRawMode(!0);let l=(i,{name:a,sequence:o})=>{if(Le([String(i),a,o],`cancel`)){r&&t.write(N.cursor.show),process.exit(0);return}if(!n)return;let c=a===`return`?0:-1,u=a===`return`?-1:0;s.moveCursor(t,c,u,()=>{s.clearLine(t,1,()=>{e.once(`keypress`,l)})})};return r&&t.write(N.cursor.hide),e.once(`keypress`,l),()=>{e.off(`keypress`,l),r&&t.write(N.cursor.show),e instanceof c&&e.isTTY&&!ze&&e.setRawMode(!1),o.terminal=!1,o.close()}}const We=e=>`columns`in e&&typeof e.columns==`number`?e.columns:80,Ge=e=>`rows`in e&&typeof e.rows==`number`?e.rows:20;function Ke(e,t,n,r=n,i=n,o){return Pe(t,We(e??a)-n.length,{hard:!0,trim:!1}).split(`
9
9
  `).map((e,t,a)=>{let s=o?o(e,t):e;return t===0?`${r}${s}`:t===a.length-1?`${i}${s}`:`${n}${s}`}).join(`
10
- `)}function Ge(e,t){if(`~standard`in e){let n=e[`~standard`].validate(t);return n instanceof Promise?n.then(e=>e.issues?.at(0)?.message):n.issues?.at(0)?.message}return e(t)}var Ke=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=/* @__PURE__ */ new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;get accessible(){return Pe(this.opts.accessible)}constructor(e,t=!0){let{input:n=i,output:r=a,render:o,signal:s,...c}=e;this.opts=c,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=o.bind(this),this._track=t,this._abortSignal=s,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(Re);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=o.createInterface({input:this.input,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(`keypress`,this.onKeypress),Be(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(M.cursor.show),this.output.off(`resize`,this.render),Be(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(M.cursor.show),this.output.off(`resize`,this.render),Be(this.input,!1),e(Re)})})}_isActionKey(e,t){return e===` `}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit(`value`,this.value)}_setUserInput(e,t){this.userInput=e??``,this.emit(`userInput`,this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:`u`}),this._setUserInput(``)}async onKeypress(e,t){if(this.state!==`validating`){if(this._track&&t.name!==`return`&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:`h`}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&N.aliases.has(t.name)&&this.emit(`cursor`,N.aliases.get(t.name)),N.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),this.emit(`key`,e,t),t?.name===`return`&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=Ge(this.opts.validate,this.value),t;e instanceof Promise?(this.state=`validating`,this.render(),t=await e):t=e,t&&(this.error=t instanceof Error?t.message:t,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}Fe([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
11
- `),Be(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Me(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
12
- `).length-1;this.output.write(M.cursor.move(-999,e*-1))}render(){let e=Me(this._render(this)??``,process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(M.cursor.hide);else{let t=Ie(this._prevFrame,e),n=Ue(this.output);if(this.restoreCursor(),t){let r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n),a=t.lines.find(e=>e>=r);if(a===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(M.cursor.move(0,a-i)),this.output.write(M.erase.lines(1));let t=e.split(`
13
- `);this.output.write(t[a]),this._prevFrame=e,this.output.write(M.cursor.move(0,t.length-a-1));return}if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(M.cursor.move(0,e))}this.output.write(M.erase.down());let t=e.split(`
10
+ `)}function qe(e,t){if(`~standard`in e){let n=e[`~standard`].validate(t);return n instanceof Promise?n.then(e=>e.issues?.at(0)?.message):n.issues?.at(0)?.message}return e(t)}var Je=class{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame=``;_subscribers=/* @__PURE__ */ new Map;_cursor=0;state=`initial`;error=``;value;userInput=``;get accessible(){return Ie(this.opts.accessible)}constructor(e,t=!0){let{input:n=i,output:r=a,render:o,signal:s,...c}=e;this.opts=c,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=o.bind(this),this._track=t,this._abortSignal=s,this.input=n,this.output=r}unsubscribe(){this._subscribers.clear()}setSubscriber(e,t){let n=this._subscribers.get(e)??[];n.push(t),this._subscribers.set(e,n)}on(e,t){this.setSubscriber(e,{cb:t})}once(e,t){this.setSubscriber(e,{cb:t,once:!0})}emit(e,...t){let n=this._subscribers.get(e)??[],r=[];for(let e of n)e.cb(...t),e.once&&r.push(()=>n.splice(n.indexOf(e),1));for(let e of r)e()}prompt(){return new Promise(e=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state=`cancel`,this.close(),e(Be);this._abortSignal.addEventListener(`abort`,()=>{this.state=`cancel`,this.close()},{once:!0})}this.rl=o.createInterface({input:this.input,tabSize:2,prompt:``,escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0&&this._setUserInput(this.opts.initialUserInput,!0),this.input.on(`keypress`,this.onKeypress),He(this.input,!0),this.output.on(`resize`,this.render),this.render(),this.once(`submit`,()=>{this.output.write(N.cursor.show),this.output.off(`resize`,this.render),He(this.input,!1),e(this.value)}),this.once(`cancel`,()=>{this.output.write(N.cursor.show),this.output.off(`resize`,this.render),He(this.input,!1),e(Be)})})}_isActionKey(e,t){return e===` `}_shouldSubmit(e,t){return!0}_setValue(e){this.value=e,this.emit(`value`,this.value)}_setUserInput(e,t){this.userInput=e??``,this.emit(`userInput`,this.userInput),t&&this._track&&this.rl&&(this.rl.write(this.userInput),this._cursor=this.rl.cursor)}_clearUserInput(){this.rl?.write(null,{ctrl:!0,name:`u`}),this._setUserInput(``)}async onKeypress(e,t){if(this.state!==`validating`){if(this._track&&t.name!==`return`&&(t.name&&this._isActionKey(e,t)&&this.rl?.write(null,{ctrl:!0,name:`h`}),this._cursor=this.rl?.cursor??0,this._setUserInput(this.rl?.line)),this.state===`error`&&(this.state=`active`),t?.name&&(!this._track&&P.aliases.has(t.name)&&this.emit(`cursor`,P.aliases.get(t.name)),P.actions.has(t.name)&&this.emit(`cursor`,t.name)),e&&(e.toLowerCase()===`y`||e.toLowerCase()===`n`)&&this.emit(`confirm`,e.toLowerCase()===`y`),this.emit(`key`,e,t),t?.name===`return`&&this._shouldSubmit(e,t)){if(this.opts.validate){let e=qe(this.opts.validate,this.value),t;e instanceof Promise?(this.state=`validating`,this.render(),t=await e):t=e,t&&(this.error=t instanceof Error?t.message:t,this.state=`error`,this.rl?.write(this.userInput))}this.state!==`error`&&(this.state=`submit`)}Le([e,t?.name,t?.sequence],`cancel`)&&(this.state=`cancel`),(this.state===`submit`||this.state===`cancel`)&&this.emit(`finalize`),this.render(),(this.state===`submit`||this.state===`cancel`)&&this.close()}}close(){this.input.unpipe(),this.input.removeListener(`keypress`,this.onKeypress),this.output.write(`
11
+ `),He(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.unsubscribe()}restoreCursor(){let e=Pe(this._prevFrame,process.stdout.columns,{hard:!0,trim:!1}).split(`
12
+ `).length-1;this.output.write(N.cursor.move(-999,e*-1))}render(){let e=Pe(this._render(this)??``,process.stdout.columns,{hard:!0,trim:!1});if(e!==this._prevFrame){if(this.state===`initial`)this.output.write(N.cursor.hide);else{let t=Re(this._prevFrame,e),n=Ge(this.output);if(this.restoreCursor(),t){let r=Math.max(0,t.numLinesAfter-n),i=Math.max(0,t.numLinesBefore-n),a=t.lines.find(e=>e>=r);if(a===void 0){this._prevFrame=e;return}if(t.lines.length===1){this.output.write(N.cursor.move(0,a-i)),this.output.write(N.erase.lines(1));let t=e.split(`
13
+ `);this.output.write(t[a]),this._prevFrame=e,this.output.write(N.cursor.move(0,t.length-a-1));return}if(t.lines.length>1){if(r<i)a=r;else{let e=a-i;e>0&&this.output.write(N.cursor.move(0,e))}this.output.write(N.erase.down());let t=e.split(`
14
14
  `).slice(a);this.output.write(t.join(`
15
- `)),this._prevFrame=e;return}}this.output.write(M.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},qe=class extends Ke{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(M.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Je=class extends Ke{options;cursor=0;get _value(){return this.options[this.cursor]?.value}get _enabledOptions(){return this.options.filter(e=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,t=this.value!==void 0&&this.value.length===e.length;this.value=t?[]:e.map(e=>e.value)}toggleInvert(){let e=this.value;if(!e)return;let t=this._enabledOptions.filter(t=>!e.includes(t.value));this.value=t.map(e=>e.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let t=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0);this.cursor=this.options[t]?.disabled?Ne(t,1,this.options):t,this.on(`key`,(e,t)=>{t.name===`a`&&this.toggleAll(),t.name===`i`&&this.toggleInvert()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=Ne(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=Ne(this.cursor,1,this.options);break;case`space`:this.toggleValue()}})}};let Ye=class extends Ke{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n]?.disabled?Ne(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=Ne(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=Ne(this.cursor,1,this.options)}this.changeValue()})}};function Xe(){return r.platform===`win32`?!!r.env.CI||!!r.env.WT_SESSION||!!r.env.TERMINUS_SUBLIME||r.env.ConEmuTask===`{cmd::Cmder}`||r.env.TERM_PROGRAM===`Terminus-Sublime`||r.env.TERM_PROGRAM===`vscode`||r.env.TERM===`xterm-256color`||r.env.TERM===`alacritty`||r.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:r.env.TERM!==`linux`}const Ze=Xe(),Qe=()=>process.env.CI===`true`,P=(e,t)=>Ze?e:t,$e=P(`◆`,`*`),et=P(`■`,`x`),tt=P(`▲`,`x`),nt=P(`◇`,`o`),rt=P(`┌`,`T`),F=P(`│`,`|`),it=P(`└`,`—`),at=P(`●`,`>`),ot=P(`○`,` `),st=P(`◻`,`[•]`),ct=P(`◼`,`[+]`),lt=P(`◻`,`[ ]`),ut=P(`●`,`•`),dt=P(`◆`,`*`),ft=P(`▲`,`!`),pt=P(`■`,`x`),mt=e=>{switch(e){case`initial`:case`active`:return n(`cyan`,$e);case`cancel`:return n(`red`,et);case`error`:return n(`yellow`,tt);case`submit`:return n(`green`,nt);case`validating`:return n(`dim`,$e)}},ht=e=>{switch(e){case`initial`:case`active`:return n(`cyan`,F);case`cancel`:return n(`red`,F);case`error`:return n(`yellow`,F);case`submit`:return n(`green`,F)}};function gt(e,t){let r=[`${t?`${n(`cyan`,F)} `:``}${e.join(` • `)}`];return t&&r.push(n(`cyan`,it)),r}const _t=(e,t,n,r,i,a=!1)=>{let o=t,s=0;if(a)for(let t=r-1;t>=n;t--){let n=e[t];if(n&&(o-=n.length),s++,o<=i)break}else for(let t=n;t<r;t++){let n=e[t];if(n&&(o-=n.length),s++,o<=i)break}return{lineCount:o,removals:s}},vt=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:a=1/0,columnPadding:o=0,rowPadding:s=4})=>{let c=He(i)-o,l=Ue(i),u=n(`dim`,`...`),d=Math.max(l-s,0),f=Math.max(Math.min(a,d),5),p=0;e>=f-3&&(p=Math.max(Math.min(e-f+3,t.length-f),0));let m=f<t.length&&p>0,h=f<t.length&&p+f<t.length,g=Math.min(p+f,t.length),_=[],v=0;m&&v++,h&&v++;let y=p+ +!!m,b=g-+!!h;for(let n=y;n<b;n++){let i=t[n],a=Me(i?r(i,n===e):``,c,{hard:!0,trim:!1}).split(`
16
- `);_.push(a),v+=a.length}if(v>d){let t=0,n=0,r=v,i=e-y,a=d,o=()=>_t(_,r,0,i,a),s=()=>_t(_,r,i+1,_.length,a,!0);m?({lineCount:r,removals:t}=o(),r>a&&(h||--a,{lineCount:r,removals:n}=s())):(h||--a,{lineCount:r,removals:n}=s(),r>a&&(--a,{lineCount:r,removals:t}=o())),t>0&&(m=!0,_.splice(0,t)),n>0&&(h=!0,_.splice(_.length-n,n))}let x=[];m&&x.push(u);for(let e of _)for(let t of e)x.push(t);return h&&x.push(u),x},yt=e=>{let t=e.active??`Yes`,r=e.inactive??`No`;return new qe({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??N.withGuide,a=`${mt(this.state)} `,o=i?`${n(`gray`,F)} `:``,s=We(e.output,e.message,o,a),c=`${i?`${n(`gray`,F)}
15
+ `)),this._prevFrame=e;return}}this.output.write(N.erase.down())}this.output.write(e),this.state===`initial`&&(this.state=`active`),this._prevFrame=e}}},Ye=class extends Je{get cursor(){return+!this.value}get _value(){return this.cursor===0}constructor(e){super(e,!1),this.value=!!e.initialValue,this.on(`userInput`,()=>{this.value=this._value}),this.on(`confirm`,e=>{this.output.write(N.cursor.move(0,-1)),this.value=e,this.state=`submit`,this.close()}),this.on(`cursor`,()=>{this.value=!this.value})}},Xe=class extends Je{options;cursor=0;get _value(){return this.options[this.cursor]?.value}get _enabledOptions(){return this.options.filter(e=>e.disabled!==!0)}toggleAll(){let e=this._enabledOptions,t=this.value!==void 0&&this.value.length===e.length;this.value=t?[]:e.map(e=>e.value)}toggleInvert(){let e=this.value;if(!e)return;let t=this._enabledOptions.filter(t=>!e.includes(t.value));this.value=t.map(e=>e.value)}toggleValue(){this.value===void 0&&(this.value=[]);let e=this.value.includes(this._value);this.value=e?this.value.filter(e=>e!==this._value):[...this.value,this._value]}constructor(e){super(e,!1),this.options=e.options,this.value=[...e.initialValues??[]];let t=Math.max(this.options.findIndex(({value:t})=>t===e.cursorAt),0);this.cursor=this.options[t]?.disabled?Fe(t,1,this.options):t,this.on(`key`,(e,t)=>{t.name===`a`&&this.toggleAll(),t.name===`i`&&this.toggleInvert()}),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=Fe(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=Fe(this.cursor,1,this.options);break;case`space`:this.toggleValue()}})}};let Ze=class extends Je{options;cursor=0;get _selectedValue(){return this.options[this.cursor]}changeValue(){let e=this._selectedValue;this.value=e===void 0?void 0:e.value}constructor(e){super(e,!1),this.options=e.options;let t=this.options.findIndex(({value:t})=>t===e.initialValue),n=t===-1?0:t;this.cursor=this.options[n]?.disabled?Fe(n,1,this.options):n,this.changeValue(),this.on(`cursor`,e=>{switch(e){case`left`:case`up`:this.cursor=Fe(this.cursor,-1,this.options);break;case`down`:case`right`:this.cursor=Fe(this.cursor,1,this.options)}this.changeValue()})}};function Qe(){return r.platform===`win32`?!!r.env.CI||!!r.env.WT_SESSION||!!r.env.TERMINUS_SUBLIME||r.env.ConEmuTask===`{cmd::Cmder}`||r.env.TERM_PROGRAM===`Terminus-Sublime`||r.env.TERM_PROGRAM===`vscode`||r.env.TERM===`xterm-256color`||r.env.TERM===`alacritty`||r.env.TERMINAL_EMULATOR===`JetBrains-JediTerm`:r.env.TERM!==`linux`}const $e=Qe(),et=()=>process.env.CI===`true`,F=(e,t)=>$e?e:t,tt=F(`◆`,`*`),nt=F(`■`,`x`),rt=F(`▲`,`x`),it=F(`◇`,`o`),at=F(`┌`,`T`),I=F(`│`,`|`),ot=F(`└`,`—`),st=F(`●`,`>`),ct=F(`○`,` `),lt=F(`◻`,`[•]`),ut=F(`◼`,`[+]`),dt=F(`◻`,`[ ]`),ft=F(`●`,`•`),pt=F(`◆`,`*`),mt=F(`▲`,`!`),ht=F(`■`,`x`),gt=e=>{switch(e){case`initial`:case`active`:return n(`cyan`,tt);case`cancel`:return n(`red`,nt);case`error`:return n(`yellow`,rt);case`submit`:return n(`green`,it);case`validating`:return n(`dim`,tt)}},_t=e=>{switch(e){case`initial`:case`active`:return n(`cyan`,I);case`cancel`:return n(`red`,I);case`error`:return n(`yellow`,I);case`submit`:return n(`green`,I)}};function vt(e,t){let r=[`${t?`${n(`cyan`,I)} `:``}${e.join(` • `)}`];return t&&r.push(n(`cyan`,ot)),r}const yt=(e,t,n,r,i,a=!1)=>{let o=t,s=0;if(a)for(let t=r-1;t>=n;t--){let n=e[t];if(n&&(o-=n.length),s++,o<=i)break}else for(let t=n;t<r;t++){let n=e[t];if(n&&(o-=n.length),s++,o<=i)break}return{lineCount:o,removals:s}},bt=({cursor:e,options:t,style:r,output:i=process.stdout,maxItems:a=1/0,columnPadding:o=0,rowPadding:s=4})=>{let c=We(i)-o,l=Ge(i),u=n(`dim`,`...`),d=Math.max(l-s,0),f=Math.max(Math.min(a,d),5),p=0;e>=f-3&&(p=Math.max(Math.min(e-f+3,t.length-f),0));let m=f<t.length&&p>0,h=f<t.length&&p+f<t.length,g=Math.min(p+f,t.length),_=[],v=0;m&&v++,h&&v++;let y=p+ +!!m,b=g-+!!h;for(let n=y;n<b;n++){let i=t[n],a=Pe(i?r(i,n===e):``,c,{hard:!0,trim:!1}).split(`
16
+ `);_.push(a),v+=a.length}if(v>d){let t=0,n=0,r=v,i=e-y,a=d,o=()=>yt(_,r,0,i,a),s=()=>yt(_,r,i+1,_.length,a,!0);m?({lineCount:r,removals:t}=o(),r>a&&(h||--a,{lineCount:r,removals:n}=s())):(h||--a,{lineCount:r,removals:n}=s(),r>a&&(--a,{lineCount:r,removals:t}=o())),t>0&&(m=!0,_.splice(0,t)),n>0&&(h=!0,_.splice(_.length-n,n))}let x=[];m&&x.push(u);for(let e of _)for(let t of e)x.push(t);return h&&x.push(u),x},xt=e=>{let t=e.active??`Yes`,r=e.inactive??`No`;return new Ye({active:t,inactive:r,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue??!0,render(){let i=e.withGuide??P.withGuide,a=`${gt(this.state)} `,o=i?`${n(`gray`,I)} `:``,s=Ke(e.output,e.message,o,a),c=`${i?`${n(`gray`,I)}
17
17
  `:``}${s}
18
- `,l=this.value?t:r;switch(this.state){case`submit`:return`${c}${i?`${n(`gray`,F)} `:``}${n(`dim`,l)}`;case`cancel`:return`${c}${i?`${n(`gray`,F)} `:``}${n([`strikethrough`,`dim`],l)}${i?`
19
- ${n(`gray`,F)}`:``}`;default:{let a=i?`${n(`cyan`,F)} `:``,o=i?n(`cyan`,it):``;return`${c}${a}${this.value?`${n(`green`,at)} ${t}`:`${n(`dim`,ot)} ${n(`dim`,t)}`}${e.vertical?i?`
20
- ${n(`cyan`,F)} `:`
21
- `:` ${n(`dim`,`/`)} `}${this.value?`${n(`dim`,ot)} ${n(`dim`,r)}`:`${n(`green`,at)} ${r}`}
18
+ `,l=this.value?t:r;switch(this.state){case`submit`:return`${c}${i?`${n(`gray`,I)} `:``}${n(`dim`,l)}`;case`cancel`:return`${c}${i?`${n(`gray`,I)} `:``}${n([`strikethrough`,`dim`],l)}${i?`
19
+ ${n(`gray`,I)}`:``}`;default:{let a=i?`${n(`cyan`,I)} `:``,o=i?n(`cyan`,ot):``;return`${c}${a}${this.value?`${n(`green`,st)} ${t}`:`${n(`dim`,ct)} ${n(`dim`,t)}`}${e.vertical?i?`
20
+ ${n(`cyan`,I)} `:`
21
+ `:` ${n(`dim`,`/`)} `}${this.value?`${n(`dim`,ct)} ${n(`dim`,r)}`:`${n(`green`,st)} ${r}`}
22
22
  ${o}
23
- `}}}}).prompt()},bt=[`${n(`dim`,`↑/↓`)} to navigate`,`${n(`dim`,`Space:`)} select`,`${n(`dim`,`Enter:`)} confirm`],xt=(e,t)=>e.split(`
23
+ `}}}}).prompt()},St=[`${n(`dim`,`↑/↓`)} to navigate`,`${n(`dim`,`Space:`)} select`,`${n(`dim`,`Enter:`)} confirm`],Ct=(e,t)=>e.split(`
24
24
  `).map(e=>t(e)).join(`
25
- `),St=e=>{let t=(e,t)=>{let r=e.label??String(e.value);return t===`disabled`?`${n(`gray`,lt)} ${xt(r,e=>n([`strikethrough`,`gray`],e))}${e.hint?` ${n(`dim`,`(${e.hint??`disabled`})`)}`:``}`:t===`active`?`${n(`cyan`,st)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`selected`?`${n(`green`,ct)} ${xt(r,e=>n(`dim`,e))}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`cancelled`?`${xt(r,e=>n([`strikethrough`,`dim`],e))}`:t===`active-selected`?`${n(`green`,ct)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`submitted`?`${xt(r,e=>n(`dim`,e))}`:`${n(`dim`,lt)} ${xt(r,e=>n(`dim`,e))}`},r=e.required??!0,i=e.showInstructions??!0;return new Je({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:r,cursorAt:e.cursorAt,validate(e){if(r&&(e===void 0||e.length===0))return`Please select at least one option.
26
- ${n(`reset`,n(`dim`,`Press ${n([`gray`,`bgWhite`,`inverse`],` space `)} to select, ${n(`gray`,n(`bgWhite`,n(`inverse`,` enter `)))} to submit`))}`},render(){let r=e.withGuide??N.withGuide,a=We(e.output,e.message,r?`${ht(this.state)} `:``,`${mt(this.state)} `),o=`${r?`${n(`gray`,F)}
25
+ `),wt=e=>{let t=(e,t)=>{let r=e.label??String(e.value);return t===`disabled`?`${n(`gray`,dt)} ${Ct(r,e=>n([`strikethrough`,`gray`],e))}${e.hint?` ${n(`dim`,`(${e.hint??`disabled`})`)}`:``}`:t===`active`?`${n(`cyan`,lt)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`selected`?`${n(`green`,ut)} ${Ct(r,e=>n(`dim`,e))}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`cancelled`?`${Ct(r,e=>n([`strikethrough`,`dim`],e))}`:t===`active-selected`?`${n(`green`,ut)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`:t===`submitted`?`${Ct(r,e=>n(`dim`,e))}`:`${n(`dim`,dt)} ${Ct(r,e=>n(`dim`,e))}`},r=e.required??!0,i=e.showInstructions??!0;return new Xe({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValues:e.initialValues,required:r,cursorAt:e.cursorAt,validate(e){if(r&&(e===void 0||e.length===0))return`Please select at least one option.
26
+ ${n(`reset`,n(`dim`,`Press ${n([`gray`,`bgWhite`,`inverse`],` space `)} to select, ${n(`gray`,n(`bgWhite`,n(`inverse`,` enter `)))} to submit`))}`},render(){let r=e.withGuide??P.withGuide,a=Ke(e.output,e.message,r?`${_t(this.state)} `:``,`${gt(this.state)} `),o=`${r?`${n(`gray`,I)}
27
27
  `:``}${a}
28
- `,s=this.value??[],c=(e,n)=>{if(e.disabled)return t(e,`disabled`);let r=s.includes(e.value);return n&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,n?`active`:`inactive`)};switch(this.state){case`submit`:{let i=this.options.filter(({value:e})=>s.includes(e)).map(e=>t(e,`submitted`)).join(n(`dim`,`, `))||n(`dim`,`none`);return`${o}${We(e.output,i,r?`${n(`gray`,F)} `:``)}`}case`cancel`:{let i=this.options.filter(({value:e})=>s.includes(e)).map(e=>t(e,`cancelled`)).join(n(`dim`,`, `));return i.trim()===``?`${o}${n(`gray`,F)}`:`${o}${We(e.output,i,r?`${n(`gray`,F)} `:``)}${r?`
29
- ${n(`gray`,F)}`:``}`}case`error`:{let t=r?`${n(`yellow`,F)} `:``,i=this.error.split(`
30
- `).map((e,t)=>t===0?`${r?`${n(`yellow`,it)} `:``}${n(`yellow`,e)}`:` ${e}`).join(`
28
+ `,s=this.value??[],c=(e,n)=>{if(e.disabled)return t(e,`disabled`);let r=s.includes(e.value);return n&&r?t(e,`active-selected`):r?t(e,`selected`):t(e,n?`active`:`inactive`)};switch(this.state){case`submit`:{let i=this.options.filter(({value:e})=>s.includes(e)).map(e=>t(e,`submitted`)).join(n(`dim`,`, `))||n(`dim`,`none`);return`${o}${Ke(e.output,i,r?`${n(`gray`,I)} `:``)}`}case`cancel`:{let i=this.options.filter(({value:e})=>s.includes(e)).map(e=>t(e,`cancelled`)).join(n(`dim`,`, `));return i.trim()===``?`${o}${n(`gray`,I)}`:`${o}${Ke(e.output,i,r?`${n(`gray`,I)} `:``)}${r?`
29
+ ${n(`gray`,I)}`:``}`}case`error`:{let t=r?`${n(`yellow`,I)} `:``,i=this.error.split(`
30
+ `).map((e,t)=>t===0?`${r?`${n(`yellow`,ot)} `:``}${n(`yellow`,e)}`:` ${e}`).join(`
31
31
  `),a=o.split(`
32
32
  `).length,s=i.split(`
33
- `).length+1;return`${o}${t}${vt({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:a+s,style:c}).join(`
33
+ `).length+1;return`${o}${t}${bt({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:a+s,style:c}).join(`
34
34
  ${t}`)}
35
35
  ${i}
36
- `}default:{let t=r?`${n(`cyan`,F)} `:``,a=o.split(`
37
- `).length,s=i?gt(bt,r):r?[n(`cyan`,it)]:[],l=s.join(`
38
- `),u=s.length+1;return`${o}${t}${vt({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:a+u,style:c}).join(`
36
+ `}default:{let t=r?`${n(`cyan`,I)} `:``,a=o.split(`
37
+ `).length,s=i?vt(St,r):r?[n(`cyan`,ot)]:[],l=s.join(`
38
+ `),u=s.length+1;return`${o}${t}${bt({output:e.output,options:this.options,cursor:this.cursor,maxItems:e.maxItems,columnPadding:t.length,rowPadding:a+u,style:c}).join(`
39
39
  ${t}`)}
40
40
  ${l}
41
- `}}}}).prompt()},I={message:(e=[],{symbol:t=n(`gray`,F),secondarySymbol:r=n(`gray`,F),output:i=process.stdout,spacing:a=1,withGuide:o}={})=>{let s=[],c=o??N.withGuide,l=c?r:``,u=c?`${t} `:``,d=c?`${r} `:``;for(let e=0;e<a;e++)s.push(l);let f=Array.isArray(e)?e:e.split(`
41
+ `}}}}).prompt()},L={message:(e=[],{symbol:t=n(`gray`,I),secondarySymbol:r=n(`gray`,I),output:i=process.stdout,spacing:a=1,withGuide:o}={})=>{let s=[],c=o??P.withGuide,l=c?r:``,u=c?`${t} `:``,d=c?`${r} `:``;for(let e=0;e<a;e++)s.push(l);let f=Array.isArray(e)?e:e.split(`
42
42
  `);if(f.length>0){let[e,...n]=f;e.length>0?s.push(`${u}${e}`):s.push(c?t:``);for(let e of n)e.length>0?s.push(`${d}${e}`):s.push(c?r:``)}i.write(`${s.join(`
43
43
  `)}
44
- `)},info:(e,t)=>{I.message(e,{...t,symbol:n(`blue`,ut)})},success:(e,t)=>{I.message(e,{...t,symbol:n(`green`,dt)})},step:(e,t)=>{I.message(e,{...t,symbol:n(`green`,nt)})},warn:(e,t)=>{I.message(e,{...t,symbol:n(`yellow`,ft)})},warning:(e,t)=>{I.warn(e,t)},error:(e,t)=>{I.message(e,{...t,symbol:n(`red`,pt)})}},Ct=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??N.withGuide?`${n(`gray`,it)} `:``;r.write(`${i}${n(`red`,e)}
44
+ `)},info:(e,t)=>{L.message(e,{...t,symbol:n(`blue`,ft)})},success:(e,t)=>{L.message(e,{...t,symbol:n(`green`,pt)})},step:(e,t)=>{L.message(e,{...t,symbol:n(`green`,it)})},warn:(e,t)=>{L.message(e,{...t,symbol:n(`yellow`,mt)})},warning:(e,t)=>{L.warn(e,t)},error:(e,t)=>{L.message(e,{...t,symbol:n(`red`,ht)})}},Tt=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??P.withGuide?`${n(`gray`,ot)} `:``;r.write(`${i}${n(`red`,e)}
45
45
 
46
- `)},wt=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??N.withGuide?`${n(`gray`,rt)} `:``;r.write(`${i}${e}
47
- `)},L=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??N.withGuide?`${n(`gray`,F)}
48
- ${n(`gray`,it)} `:``;r.write(`${i}${e}
46
+ `)},Et=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??P.withGuide?`${n(`gray`,at)} `:``;r.write(`${i}${e}
47
+ `)},R=(e=``,t)=>{let r=t?.output??process.stdout,i=t?.withGuide??P.withGuide?`${n(`gray`,I)}
48
+ ${n(`gray`,ot)} `:``;r.write(`${i}${e}
49
49
 
50
- `)},Tt=e=>n(`magenta`,e),Et=({indicator:e=`dots`,onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:a,frames:o=Ze?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],delay:s=Ze?80:120,signal:c,...l}={})=>{let u=Qe(),d,f,p=!1,m=!1,h=``,g,_=performance.now(),v=He(r),y=l?.styleFrame??Tt,b=e=>{let n=e>1?a??N.messages.error:i??N.messages.cancel;m=e===1,p&&(O(n,e),m&&typeof t==`function`&&t())},x=()=>b(2),S=()=>b(1),C=()=>{process.on(`uncaughtExceptionMonitor`,x),process.on(`unhandledRejection`,x),process.on(`SIGINT`,S),process.on(`SIGTERM`,S),process.on(`exit`,b),c&&c.addEventListener(`abort`,S)},w=()=>{process.removeListener(`uncaughtExceptionMonitor`,x),process.removeListener(`unhandledRejection`,x),process.removeListener(`SIGINT`,S),process.removeListener(`SIGTERM`,S),process.removeListener(`exit`,b),c&&c.removeEventListener(`abort`,S)},T=()=>{if(g===void 0)return;u&&r.write(`
51
- `);let e=Me(g,v,{hard:!0,trim:!1}).split(`
52
- `);e.length>1&&r.write(M.cursor.up(e.length-1)),r.write(M.cursor.to(0)),r.write(M.erase.down())},E=e=>e.replace(/\.+$/,``),D=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},ee=l.withGuide??N.withGuide,te=(t=``)=>{p=!0,d=Ve({output:r}),h=E(t),_=performance.now(),ee&&r.write(`${n(`gray`,F)}
53
- `);let i=0,a=0;C(),f=setInterval(()=>{if(u&&h===g)return;T(),g=h;let t=y(o[i]),n;if(u)n=`${t} ${h}...`;else if(e===`timer`)n=`${t} ${h} ${D(_)}`;else{let e=`.`.repeat(Math.floor(a)).slice(0,3);n=`${t} ${h}${e}`}let s=Me(n,v,{hard:!0,trim:!1});r.write(s),i=i+1<o.length?i+1:0,a=a<4?a+.125:0},s)},O=(t=``,i=0,a=!1)=>{if(!p)return;p=!1,clearInterval(f),T();let o=i===0?n(`green`,nt):i===1?n(`red`,et):n(`red`,tt);h=t??h,a||(e===`timer`?r.write(`${o} ${h} ${D(_)}
50
+ `)},Dt=e=>n(`magenta`,e),Ot=({indicator:e=`dots`,onCancel:t,output:r=process.stdout,cancelMessage:i,errorMessage:a,frames:o=$e?[`◒`,`◐`,`◓`,`◑`]:[`•`,`o`,`O`,`0`],delay:s=$e?80:120,signal:c,...l}={})=>{let u=et(),d,f,p=!1,m=!1,h=``,g,_=performance.now(),v=We(r),y=l?.styleFrame??Dt,b=e=>{let n=e>1?a??P.messages.error:i??P.messages.cancel;m=e===1,p&&(te(n,e),m&&typeof t==`function`&&t())},x=()=>b(2),S=()=>b(1),C=()=>{process.on(`uncaughtExceptionMonitor`,x),process.on(`unhandledRejection`,x),process.on(`SIGINT`,S),process.on(`SIGTERM`,S),process.on(`exit`,b),c&&c.addEventListener(`abort`,S)},w=()=>{process.removeListener(`uncaughtExceptionMonitor`,x),process.removeListener(`unhandledRejection`,x),process.removeListener(`SIGINT`,S),process.removeListener(`SIGTERM`,S),process.removeListener(`exit`,b),c&&c.removeEventListener(`abort`,S)},T=()=>{if(g===void 0)return;u&&r.write(`
51
+ `);let e=Pe(g,v,{hard:!0,trim:!1}).split(`
52
+ `);e.length>1&&r.write(N.cursor.up(e.length-1)),r.write(N.cursor.to(0)),r.write(N.erase.down())},E=e=>e.replace(/\.+$/,``),D=e=>{let t=(performance.now()-e)/1e3,n=Math.floor(t/60),r=Math.floor(t%60);return n>0?`[${n}m ${r}s]`:`[${r}s]`},ee=l.withGuide??P.withGuide,O=(t=``)=>{p=!0,d=Ue({output:r}),h=E(t),_=performance.now(),ee&&r.write(`${n(`gray`,I)}
53
+ `);let i=0,a=0;C(),f=setInterval(()=>{if(u&&h===g)return;T(),g=h;let t=y(o[i]),n;if(u)n=`${t} ${h}...`;else if(e===`timer`)n=`${t} ${h} ${D(_)}`;else{let e=`.`.repeat(Math.floor(a)).slice(0,3);n=`${t} ${h}${e}`}let s=Pe(n,v,{hard:!0,trim:!1});r.write(s),i=i+1<o.length?i+1:0,a=a<4?a+.125:0},s)},te=(t=``,i=0,a=!1)=>{if(!p)return;p=!1,clearInterval(f),T();let o=i===0?n(`green`,it):i===1?n(`red`,nt):n(`red`,rt);h=t??h,a||(e===`timer`?r.write(`${o} ${h} ${D(_)}
54
54
  `):r.write(`${o} ${h}
55
- `)),w(),d()};return{start:te,stop:(e=``)=>O(e,0),message:(e=``)=>{h=E(e??h)},cancel:(e=``)=>O(e,1),error:(e=``)=>O(e,2),clear:()=>O(``,0,!0),get isCancelled(){return m}}},Dt=[`${n(`dim`,`↑/↓`)} to navigate`,`${n(`dim`,`Enter:`)} confirm`],Ot=(e,t)=>e.includes(`
55
+ `)),w(),d()};return{start:O,stop:(e=``)=>te(e,0),message:(e=``)=>{h=E(e??h)},cancel:(e=``)=>te(e,1),error:(e=``)=>te(e,2),clear:()=>te(``,0,!0),get isCancelled(){return m}}},kt=[`${n(`dim`,`↑/↓`)} to navigate`,`${n(`dim`,`Enter:`)} confirm`],At=(e,t)=>e.includes(`
56
56
  `)?e.split(`
57
57
  `).map(e=>t(e)).join(`
58
- `):t(e),kt=e=>{let t=(e,t)=>{if(e===void 0)return``;let r=e.label??String(e.value);switch(t){case`disabled`:return`${n(`gray`,ot)} ${Ot(r,e=>n(`gray`,e))}${e.hint?` ${n(`dim`,`(${e.hint??`disabled`})`)}`:``}`;case`selected`:return`${Ot(r,e=>n(`dim`,e))}`;case`active`:return`${n(`green`,at)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`;case`cancelled`:return`${Ot(r,e=>n([`strikethrough`,`dim`],e))}`;default:return`${n(`dim`,ot)} ${Ot(r,e=>n(`dim`,e))}`}},r=e.showInstructions??!0;return new Ye({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let i=e.withGuide??N.withGuide,a=`${mt(this.state)} `,o=`${ht(this.state)} `,s=We(e.output,e.message,o,a),c=`${i?`${n(`gray`,F)}
58
+ `):t(e),jt=e=>{let t=(e,t)=>{if(e===void 0)return``;let r=e.label??String(e.value);switch(t){case`disabled`:return`${n(`gray`,ct)} ${At(r,e=>n(`gray`,e))}${e.hint?` ${n(`dim`,`(${e.hint??`disabled`})`)}`:``}`;case`selected`:return`${At(r,e=>n(`dim`,e))}`;case`active`:return`${n(`green`,st)} ${r}${e.hint?` ${n(`dim`,`(${e.hint})`)}`:``}`;case`cancelled`:return`${At(r,e=>n([`strikethrough`,`dim`],e))}`;default:return`${n(`dim`,ct)} ${At(r,e=>n(`dim`,e))}`}},r=e.showInstructions??!0;return new Ze({options:e.options,signal:e.signal,input:e.input,output:e.output,initialValue:e.initialValue,render(){let i=e.withGuide??P.withGuide,a=`${gt(this.state)} `,o=`${_t(this.state)} `,s=Ke(e.output,e.message,o,a),c=`${i?`${n(`gray`,I)}
59
59
  `:``}${s}
60
- `;switch(this.state){case`submit`:{let r=i?`${n(`gray`,F)} `:``;return`${c}${We(e.output,t(this.options[this.cursor],`selected`),r)}`}case`cancel`:{let r=i?`${n(`gray`,F)} `:``;return`${c}${We(e.output,t(this.options[this.cursor],`cancelled`),r)}${i?`
61
- ${n(`gray`,F)}`:``}`}default:{let a=i?`${n(`cyan`,F)} `:``,o=c.split(`
62
- `).length,s=r?gt(Dt,i):i?[n(`cyan`,it)]:[],l=s.join(`
63
- `),u=s.length+1;return`${c}${a}${vt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:o+u,style:(e,n)=>t(e,e.disabled?`disabled`:n?`active`:`inactive`)}).join(`
60
+ `;switch(this.state){case`submit`:{let r=i?`${n(`gray`,I)} `:``;return`${c}${Ke(e.output,t(this.options[this.cursor],`selected`),r)}`}case`cancel`:{let r=i?`${n(`gray`,I)} `:``;return`${c}${Ke(e.output,t(this.options[this.cursor],`cancelled`),r)}${i?`
61
+ ${n(`gray`,I)}`:``}`}default:{let a=i?`${n(`cyan`,I)} `:``,o=c.split(`
62
+ `).length,s=r?vt(kt,i):i?[n(`cyan`,ot)]:[],l=s.join(`
63
+ `),u=s.length+1;return`${c}${a}${bt({output:e.output,cursor:this.cursor,options:this.options,maxItems:e.maxItems,columnPadding:a.length,rowPadding:o+u,style:(e,n)=>t(e,e.disabled?`disabled`:n?`active`:`inactive`)}).join(`
64
64
  ${a}`)}
65
65
  ${l}
66
- `}}}}).prompt()};`${n(`gray`,F)}`;const At=[`stable`,`beta`],jt=[`latest`,...At],Mt=e=>At.includes(e),Nt=e=>jt.includes(e);function Pt(e,t,n){if(n===`latest`)return{version:t,fellBack:!1};let r=e[n];return r===null?{version:t,fellBack:!0}:{version:r,fellBack:!1}}var Ft=`0.2.0`;const It=[{id:`claude-code`,name:`Claude Code`,projectDir:`.claude/skills`,globalDir:`.claude/skills`,marker:`.claude`},{id:`codex`,name:`Codex`,projectDir:`.agents/skills`,globalDir:`.agents/skills`,marker:`.codex`},{id:`cursor`,name:`Cursor`,projectDir:`.agents/skills`,globalDir:`.cursor/skills`,marker:`.cursor`},{id:`gemini-cli`,name:`Gemini CLI`,projectDir:`.agents/skills`,globalDir:`.gemini/skills`,marker:`.gemini`}],Lt=e=>e===`global`?v():process.cwd();function Rt(e=v()){return It.filter(t=>l(p(e,t.marker)))}function zt(e){return It.find(t=>t.id===e)}function Bt(e,t,n=Lt(t)){let r=e.map(e=>g(n,t===`global`?e.globalDir:e.projectDir));return[...new Set(r)]}const R=()=>!!(process.stdin.isTTY&&process.stdout.isTTY)&&!process.env.CI;function z(e){return ze(e)&&(Ct(`Cancelled.`),process.exit(130)),e}async function Vt(e,t){if(e.length>0)return e.map(e=>{let t=zt(e);if(!t)throw Error(`Unknown agent "${e}". Use one of: ${It.map(e=>e.id).join(`, `)}.`);return t});let n=Rt(),r=n.length>0?n:[zt(`claude-code`)];return!t||!R()?r:z(await St({message:`Which agents should get the skills?`,options:It.map(e=>({value:e.id,label:e.name,hint:n.includes(e)?`detected`:void 0})),initialValues:r.map(e=>e.id),required:!0})).map(e=>zt(e))}async function Ht(e,t){return e?`global`:!t||!R()?`project`:z(await kt({message:`Where should they go?`,options:[{value:`project`,label:`This project`,hint:process.cwd()},{value:`global`,label:`Everywhere`,hint:`your home folder`}],initialValue:`project`}))}const Ut=`kit/`;function Wt(e){let t=[],n=[];for(let r of e)r.startsWith(`kit/`)?n.push(r.slice(4)):t.push(r);return{skills:t,kits:n}}async function Gt(e,t,n){if(t.length>0)return qt(e,t,n,`skill`);if(!n||!R())throw Error("Name the skills to add, like `a-kit add my-skill`.");let r=z(await St({message:`Which skills?`,options:e.map(e=>({value:e.id,label:Zt(e),hint:e.description.length>60?`${e.description.slice(0,57)}…`:e.description})),required:!0}));return e.filter(e=>r.includes(e.id))}const Kt=(e,t,n)=>qt(e,t,n,`kit`);async function qt(e,t,n,r){let i=[];for(let a of t){let t=Jt(e,a,r),o=t.length===1?t[0]:await Yt(t,n,r);i.includes(o)||i.push(o)}return i}function Jt(e,t,n){let r=t.lastIndexOf(`/`),i=t.slice(r+1),a=r===-1?null:t.slice(0,r).trim().toLowerCase(),o=e.filter(e=>e.name===i&&(a===null||e.organizationName.toLowerCase()===a));if(o.length===0)throw Error(a===null?`There's no ${n} named "${i}" in your agent kit. See them with \`a-kit list\`.`:`There's no ${n} named "${i}" in an organization called "${t.slice(0,r)}". See them with \`a-kit list\`.`);return o}async function Yt(e,t,n){let r=e[0].name,i=n===`kit`?Ut:``;if(!t||!R()){let t=e.map(e=>{let t=i+Xt(e);return`\`a-kit add ${/\s/.test(t)?`"${t}"`:t}\``});throw Error(`More than one of your organizations has a ${n} named "${r}". Say which one: ${t.join(` or `)}.`)}let a=z(await kt({message:`More than one of your organizations has ${n===`kit`?`kit/${r}`:`"${r}"`}. Which one?`,options:e.map(e=>({value:e.id,label:Xt(e)}))}));return e.find(e=>e.id===a)}const Xt=e=>`${e.organizationName}/${e.name}`,Zt=e=>e.showOrganization?`${e.name} (${e.organizationName})`:e.name;async function Qt(e,t,n){let r=()=>e.map(e=>e.name).join(`, `);if(t){let n=t.trim().toLowerCase(),i=e.find(e=>e.id===t||e.name.toLowerCase()===n);if(!i)throw Error(`--org: none of your organizations is "${t}". Yours: ${r()}.`);return i}if(e.length===0)throw Error(`You're not in an organization yet. Create one on the web.`);if(e.length===1)return e[0];if(!n||!R())throw Error(`Which organization should the new skill go to? Pass --org with one of: ${r()}.`);let i=z(await kt({message:`Which organization should the new skill go to?`,options:e.map(e=>({value:e.id,label:e.name}))}));return e.find(e=>e.id===i)}function B(e){let t=h(process.cwd(),e);return t&&!t.startsWith(`..`)?t:e}const $t=/* @__PURE__ */ new Set([`.DS_Store`,`Thumbs.db`,`desktop.ini`,`.git`,`.idea`,`.vscode`,`node_modules`,`__pycache__`,`4913`]);function en(e){return e.split(`/`).some(e=>$t.has(e)||/^\..*\.sw[a-p]$/.test(e)||e.endsWith(`~`)||/^#.*#$/.test(e)||e.startsWith(`.#`)||e.endsWith(`.tmp`))}const tn=e=>ie(`sha256`).update(e).digest(`hex`);async function nn(e){let t=await ee(e,{recursive:!0,withFileTypes:!0}),n=[];for(let r of t){if(!r.isFile())continue;let t=h(e,p(r.parentPath,r.name)).split(_).join(`/`);if(en(t))continue;let i=new Uint8Array(await D(p(e,t)));n.push({path:t,size:i.byteLength,sha256:tn(i),bytes:i})}return n.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function rn(e,t){let n=new Map(t.filter(e=>!en(e.path)).map(e=>[e.path,e.sha256])),r=new Set(e.map(e=>e.path)),i=e.filter(e=>n.get(e.path)!==e.sha256),a=[...n.keys()].filter(e=>!r.has(e));return{upserts:i,deletes:a,paths:[...i.map(e=>e.path),...a].sort()}}function an(e,t){let n=e=>e.filter(e=>!en(e.path)).map(e=>`${e.path}\0${e.sha256}`).sort().join(`
67
- `);return n(e)===n(t)}function on(e){try{let t=new TextDecoder(`utf-8`,{fatal:!0}).decode(e.bytes);if(!t.includes(`\0`))return{path:e.path,content:t,encoding:`utf8`}}catch{}return{path:e.path,content:Buffer.from(e.bytes).toString(`base64`),encoding:`base64`}}async function sn(e,t){await O(e,{recursive:!0,force:!0});for(let n of t){let t=p(e,n.path);await T(f(t),{recursive:!0}),await k(t,n.bytes)}}function cn(e){return e.length===0?`nothing`:e.length>3?`${e.length} files`:e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)}`}function ln(e,t){let n=e.find(e=>e.path===t);return n?new TextDecoder().decode(n.bytes):void 0}const un=`SKILL.md`,V={maxFiles:200,maxFileBytes:1048576,maxSkillBytes:10485760,maxPathLength:255},dn=/[\u0000-\u001f\u007f\\:]/;function fn(e){if(e.trim()===``)return`The path is empty.`;if(e.length>V.maxPathLength)return`Paths can be at most ${V.maxPathLength} characters.`;if(e.startsWith(`/`))return`Use a relative path, without a leading /.`;if(dn.test(e))return`Paths can't contain \\, : or control characters.`;for(let t of e.split(`/`)){if(t===``)return`The path has an empty folder name (//).`;if(t===`.`||t===`..`)return`The path can't contain . or .. folders.`;if(t!==t.trim())return`Names can't start or end with a space.`}return null}function pn(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function mn(e,t){let n=pn(e)?pn(e).split(`/`):[];for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(n.length===0)return null;n.pop()}else n.push(e)}return n.join(`/`)}var H=/* @__PURE__ */ A((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),hn=/* @__PURE__ */ A((e=>{var t=H();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),gn=/* @__PURE__ */ A((e=>{var t=H(),n=hn();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||e&&!a.some(e=>e.startsWith(n))||r.push(`%TAG ${t} ${n}`);return r.join(`
68
- `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),_n=/* @__PURE__ */ A((e=>{var t=H(),n=hn();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=/* @__PURE__ */ new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=/* @__PURE__ */ new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=/* @__PURE__ */ Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),vn=/* @__PURE__ */ A((e=>{function t(e,n,r,i){if(i&&typeof i==`object`){if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}}return e.call(n,r,i)}e.applyReviver=t})),yn=/* @__PURE__ */ A((e=>{var t=H();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),bn=/* @__PURE__ */ A((e=>{var t=vn(),n=H(),r=yn();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:/* @__PURE__ */ new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),xn=/* @__PURE__ */ A((e=>{var t=_n(),n=hn(),r=H(),i=bn(),a=yn(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let o;for(let e of i){if(e===this)break;e.anchor===this.source&&(o=e)}if(o&&t){let{anchors:e,doc:n,maxAliasCount:r}=t,i=e.get(o);
66
+ `}}}}).prompt()};`${n(`gray`,I)}`;const Mt=[`stable`,`beta`],Nt=[`latest`,...Mt],Pt=e=>Mt.includes(e),Ft=e=>Nt.includes(e);function It(e,t,n){if(n===`latest`)return{version:t,fellBack:!1};let r=e[n];return r===null?{version:t,fellBack:!0}:{version:r,fellBack:!1}}var Lt=`0.2.0`;const Rt=[{id:`claude-code`,name:`Claude Code`,projectDir:`.claude/skills`,globalDir:`.claude/skills`,marker:`.claude`},{id:`codex`,name:`Codex`,projectDir:`.agents/skills`,globalDir:`.agents/skills`,marker:`.codex`},{id:`cursor`,name:`Cursor`,projectDir:`.agents/skills`,globalDir:`.cursor/skills`,marker:`.cursor`},{id:`gemini-cli`,name:`Gemini CLI`,projectDir:`.agents/skills`,globalDir:`.gemini/skills`,marker:`.gemini`}],zt=e=>e===`global`?y():process.cwd();function Bt(e=y()){return Rt.filter(t=>l(p(e,t.marker)))}function Vt(e){return Rt.find(t=>t.id===e)}function Ht(e,t,n=zt(t)){let r=e.map(e=>g(n,t===`global`?e.globalDir:e.projectDir));return[...new Set(r)]}const z=()=>!!(process.stdin.isTTY&&process.stdout.isTTY)&&!process.env.CI;function B(e){return Ve(e)&&(Tt(`Cancelled.`),process.exit(130)),e}async function Ut(e,t){if(e.length>0)return e.map(e=>{let t=Vt(e);if(!t)throw Error(`Unknown agent "${e}". Use one of: ${Rt.map(e=>e.id).join(`, `)}.`);return t});let n=Bt(),r=n.length>0?n:[Vt(`claude-code`)];return!t||!z()?r:B(await wt({message:`Which agents should get the skills?`,options:Rt.map(e=>({value:e.id,label:e.name,hint:n.includes(e)?`detected`:void 0})),initialValues:r.map(e=>e.id),required:!0})).map(e=>Vt(e))}async function Wt(e,t){return e?`global`:!t||!z()?`project`:B(await jt({message:`Where should they go?`,options:[{value:`project`,label:`This project`,hint:process.cwd()},{value:`global`,label:`Everywhere`,hint:`your home folder`}],initialValue:`project`}))}const Gt=`kit/`;function Kt(e){let t=[],n=[];for(let r of e)r.startsWith(`kit/`)?n.push(r.slice(4)):t.push(r);return{skills:t,kits:n}}async function qt(e,t,n){if(t.length>0)return Yt(e,t,n,`skill`);if(!n||!z())throw Error("Name the skills to add, like `a-kit add my-skill`.");let r=B(await wt({message:`Which skills?`,options:e.map(e=>({value:e.id,label:$t(e),hint:e.description.length>60?`${e.description.slice(0,57)}…`:e.description})),required:!0}));return e.filter(e=>r.includes(e.id))}const Jt=(e,t,n)=>Yt(e,t,n,`kit`);async function Yt(e,t,n,r){let i=[];for(let a of t){let t=Xt(e,a,r),o=t.length===1?t[0]:await Zt(t,n,r);i.includes(o)||i.push(o)}return i}function Xt(e,t,n){let r=t.lastIndexOf(`/`),i=t.slice(r+1),a=r===-1?null:t.slice(0,r).trim().toLowerCase(),o=e.filter(e=>e.name===i&&(a===null||e.organizationName.toLowerCase()===a));if(o.length===0)throw Error(a===null?`There's no ${n} named "${i}" in your agent kit. See them with \`a-kit list\`.`:`There's no ${n} named "${i}" in an organization called "${t.slice(0,r)}". See them with \`a-kit list\`.`);return o}async function Zt(e,t,n){let r=e[0].name,i=n===`kit`?Gt:``;if(!t||!z()){let t=e.map(e=>{let t=i+Qt(e);return`\`a-kit add ${/\s/.test(t)?`"${t}"`:t}\``});throw Error(`More than one of your organizations has a ${n} named "${r}". Say which one: ${t.join(` or `)}.`)}let a=B(await jt({message:`More than one of your organizations has ${n===`kit`?`kit/${r}`:`"${r}"`}. Which one?`,options:e.map(e=>({value:e.id,label:Qt(e)}))}));return e.find(e=>e.id===a)}const Qt=e=>`${e.organizationName}/${e.name}`,$t=e=>e.showOrganization?`${e.name} (${e.organizationName})`:e.name;async function en(e,t,n){let r=()=>e.map(e=>e.name).join(`, `);if(t){let n=t.trim().toLowerCase(),i=e.find(e=>e.id===t||e.name.toLowerCase()===n);if(!i)throw Error(`--org: none of your organizations is "${t}". Yours: ${r()}.`);return i}if(e.length===0)throw Error(`You're not in an organization yet. Create one on the web.`);if(e.length===1)return e[0];if(!n||!z())throw Error(`Which organization should the new skill go to? Pass --org with one of: ${r()}.`);let i=B(await jt({message:`Which organization should the new skill go to?`,options:e.map(e=>({value:e.id,label:e.name}))}));return e.find(e=>e.id===i)}function V(e){let t=h(process.cwd(),e);return t&&!t.startsWith(`..`)?t:e}const tn=/* @__PURE__ */ new Set([`.DS_Store`,`Thumbs.db`,`desktop.ini`,`.git`,`.idea`,`.vscode`,`node_modules`,`__pycache__`,`4913`]);function nn(e){return e.split(`/`).some(e=>tn.has(e)||/^\..*\.sw[a-p]$/.test(e)||e.endsWith(`~`)||/^#.*#$/.test(e)||e.startsWith(`.#`)||e.endsWith(`.tmp`))}const rn=e=>ae(`sha256`).update(e).digest(`hex`);async function an(e){let t=await te(e,{recursive:!0,withFileTypes:!0}),n=[];for(let r of t){if(!r.isFile())continue;let t=h(e,p(r.parentPath,r.name)).split(_).join(`/`);if(nn(t))continue;let i=new Uint8Array(await O(p(e,t)));n.push({path:t,size:i.byteLength,sha256:rn(i),bytes:i})}return n.sort((e,t)=>e.path<t.path?-1:+(e.path>t.path))}function on(e,t){let n=new Map(t.filter(e=>!nn(e.path)).map(e=>[e.path,e.sha256])),r=new Set(e.map(e=>e.path)),i=e.filter(e=>n.get(e.path)!==e.sha256),a=[...n.keys()].filter(e=>!r.has(e));return{upserts:i,deletes:a,paths:[...i.map(e=>e.path),...a].sort()}}function sn(e,t){let n=e=>e.filter(e=>!nn(e.path)).map(e=>`${e.path}\0${e.sha256}`).sort().join(`
67
+ `);return n(e)===n(t)}function cn(e){try{let t=new TextDecoder(`utf-8`,{fatal:!0}).decode(e.bytes);if(!t.includes(`\0`))return{path:e.path,content:t,encoding:`utf8`}}catch{}return{path:e.path,content:Buffer.from(e.bytes).toString(`base64`),encoding:`base64`}}async function ln(e,t){await k(e,{recursive:!0,force:!0});for(let n of t){let t=p(e,n.path);await D(f(t),{recursive:!0}),await A(t,n.bytes)}}function un(e){return e.length===0?`nothing`:e.length>3?`${e.length} files`:e.length===1?e[0]:`${e.slice(0,-1).join(`, `)} and ${e.at(-1)}`}function dn(e,t){let n=e.find(e=>e.path===t);return n?new TextDecoder().decode(n.bytes):void 0}const fn=`SKILL.md`,H={maxFiles:200,maxFileBytes:1048576,maxSkillBytes:10485760,maxPathLength:255},pn=/[\u0000-\u001f\u007f\\:]/;function mn(e){if(e.trim()===``)return`The path is empty.`;if(e.length>H.maxPathLength)return`Paths can be at most ${H.maxPathLength} characters.`;if(e.startsWith(`/`))return`Use a relative path, without a leading /.`;if(pn.test(e))return`Paths can't contain \\, : or control characters.`;for(let t of e.split(`/`)){if(t===``)return`The path has an empty folder name (//).`;if(t===`.`||t===`..`)return`The path can't contain . or .. folders.`;if(t!==t.trim())return`Names can't start or end with a space.`}return null}function hn(e){let t=e.lastIndexOf(`/`);return t===-1?``:e.slice(0,t)}function gn(e,t){let n=hn(e)?hn(e).split(`/`):[];for(let e of t.split(`/`))if(e!==``&&e!==`.`){if(e===`..`){if(n.length===0)return null;n.pop()}else n.push(e)}return n.join(`/`)}var U=/* @__PURE__ */ j((e=>{let t=Symbol.for(`yaml.alias`),n=Symbol.for(`yaml.document`),r=Symbol.for(`yaml.map`),i=Symbol.for(`yaml.pair`),a=Symbol.for(`yaml.scalar`),o=Symbol.for(`yaml.seq`),s=Symbol.for(`yaml.node.type`),c=e=>!!e&&typeof e==`object`&&e[s]===t,l=e=>!!e&&typeof e==`object`&&e[s]===n,u=e=>!!e&&typeof e==`object`&&e[s]===r,d=e=>!!e&&typeof e==`object`&&e[s]===i,f=e=>!!e&&typeof e==`object`&&e[s]===a,p=e=>!!e&&typeof e==`object`&&e[s]===o;function m(e){if(e&&typeof e==`object`)switch(e[s]){case r:case o:return!0}return!1}function h(e){if(e&&typeof e==`object`)switch(e[s]){case t:case r:case a:case o:return!0}return!1}e.ALIAS=t,e.DOC=n,e.MAP=r,e.NODE_TYPE=s,e.PAIR=i,e.SCALAR=a,e.SEQ=o,e.hasAnchor=e=>(f(e)||m(e))&&!!e.anchor,e.isAlias=c,e.isCollection=m,e.isDocument=l,e.isMap=u,e.isNode=h,e.isPair=d,e.isScalar=f,e.isSeq=p})),_n=/* @__PURE__ */ j((e=>{var t=U();let n=Symbol(`break visit`),r=Symbol(`skip children`),i=Symbol(`remove node`);function a(e,n){let r=l(n);t.isDocument(e)?o(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):o(null,e,r,Object.freeze([]))}a.BREAK=n,a.SKIP=r,a.REMOVE=i;function o(e,r,a,s){let c=u(e,r,a,s);if(t.isNode(c)||t.isPair(c))return d(e,s,c),o(e,c,a,s);if(typeof c!=`symbol`){if(t.isCollection(r)){s=Object.freeze(s.concat(r));for(let e=0;e<r.items.length;++e){let t=o(e,r.items[e],a,s);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){s=Object.freeze(s.concat(r));let e=o(`key`,r.key,a,s);if(e===n)return n;e===i&&(r.key=null);let t=o(`value`,r.value,a,s);if(t===n)return n;t===i&&(r.value=null)}}return c}async function s(e,n){let r=l(n);t.isDocument(e)?await c(null,e.contents,r,Object.freeze([e]))===i&&(e.contents=null):await c(null,e,r,Object.freeze([]))}s.BREAK=n,s.SKIP=r,s.REMOVE=i;async function c(e,r,a,o){let s=await u(e,r,a,o);if(t.isNode(s)||t.isPair(s))return d(e,o,s),c(e,s,a,o);if(typeof s!=`symbol`){if(t.isCollection(r)){o=Object.freeze(o.concat(r));for(let e=0;e<r.items.length;++e){let t=await c(e,r.items[e],a,o);if(typeof t==`number`)e=t-1;else if(t===n)return n;else t===i&&(r.items.splice(e,1),--e)}}else if(t.isPair(r)){o=Object.freeze(o.concat(r));let e=await c(`key`,r.key,a,o);if(e===n)return n;e===i&&(r.key=null);let t=await c(`value`,r.value,a,o);if(t===n)return n;t===i&&(r.value=null)}}return s}function l(e){return typeof e==`object`&&(e.Collection||e.Node||e.Value)?Object.assign({Alias:e.Node,Map:e.Node,Scalar:e.Node,Seq:e.Node},e.Value&&{Map:e.Value,Scalar:e.Value,Seq:e.Value},e.Collection&&{Map:e.Collection,Seq:e.Collection},e):e}function u(e,n,r,i){if(typeof r==`function`)return r(e,n,i);if(t.isMap(n))return r.Map?.(e,n,i);if(t.isSeq(n))return r.Seq?.(e,n,i);if(t.isPair(n))return r.Pair?.(e,n,i);if(t.isScalar(n))return r.Scalar?.(e,n,i);if(t.isAlias(n))return r.Alias?.(e,n,i)}function d(e,n,r){let i=n[n.length-1];if(t.isCollection(i))i.items[e]=r;else if(t.isPair(i))e===`key`?i.key=r:i.value=r;else if(t.isDocument(i))i.contents=r;else{let e=t.isAlias(i)?`alias`:`scalar`;throw Error(`Cannot replace node with ${e} parent`)}}e.visit=a,e.visitAsync=s})),vn=/* @__PURE__ */ j((e=>{var t=U(),n=_n();let r={"!":`%21`,",":`%2C`,"[":`%5B`,"]":`%5D`,"{":`%7B`,"}":`%7D`},i=e=>e.replace(/[!,[\]{}]/g,e=>r[e]);var a=class e{constructor(t,n){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},e.defaultYaml,t),this.tags=Object.assign({},e.defaultTags,n)}clone(){let t=new e(this.yaml,this.tags);return t.docStart=this.docStart,t}atDocument(){let t=new e(this.yaml,this.tags);switch(this.yaml.version){case`1.1`:this.atNextDocument=!0;break;case`1.2`:this.atNextDocument=!1,this.yaml={explicit:e.defaultYaml.explicit,version:`1.2`},this.tags=Object.assign({},e.defaultTags)}return t}add(t,n){this.atNextDocument&&=(this.yaml={explicit:e.defaultYaml.explicit,version:`1.1`},this.tags=Object.assign({},e.defaultTags),!1);let r=t.trim().split(/[ \t]+/),i=r.shift();switch(i){case`%TAG`:{if(r.length!==2&&(n(0,`%TAG directive should contain exactly two parts`),r.length<2))return!1;let[e,t]=r;return this.tags[e]=t,!0}case`%YAML`:{if(this.yaml.explicit=!0,r.length!==1)return n(0,`%YAML directive should contain exactly one part`),!1;let[e]=r;if(e===`1.1`||e===`1.2`)return this.yaml.version=e,!0;{let t=/^\d+\.\d+$/.test(e);return n(6,`Unsupported YAML version ${e}`,t),!1}}default:return n(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e===`!`)return`!`;if(e[0]!==`!`)return t(`Not a valid tag: ${e}`),null;if(e[1]===`<`){let n=e.slice(2,-1);return n===`!`||n===`!!`?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==`>`&&t(`Verbatim tags must end with a >`),n)}let[,n,r]=e.match(/^(.*!)([^!]*)$/s);r||t(`The ${e} tag has no suffix`);let i=this.tags[n];if(i)try{return i+decodeURIComponent(r)}catch(e){return t(String(e)),null}return n===`!`?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(let[t,n]of Object.entries(this.tags))if(e.startsWith(n))return t+i(e.substring(n.length));return e[0]===`!`?e:`!<${e}>`}toString(e){let r=this.yaml.explicit?[`%YAML ${this.yaml.version||`1.2`}`]:[],i=Object.entries(this.tags),a;if(e&&i.length>0&&t.isNode(e.contents)){let r={};n.visit(e.contents,(e,n)=>{t.isNode(n)&&n.tag&&(r[n.tag]=!0)}),a=Object.keys(r)}else a=[];for(let[t,n]of i)t===`!!`&&n===`tag:yaml.org,2002:`||e&&!a.some(e=>e.startsWith(n))||r.push(`%TAG ${t} ${n}`);return r.join(`
68
+ `)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),yn=/* @__PURE__ */ j((e=>{var t=U(),n=_n();function r(e){if(/[\x00-\x19\s,[\]{}]/.test(e)){let t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(e)}`;throw Error(t)}return!0}function i(e){let t=/* @__PURE__ */ new Set;return n.visit(e,{Value(e,n){n.anchor&&t.add(n.anchor)}}),t}function a(e,t){for(let n=1;;++n){let r=`${e}${n}`;if(!t.has(r))return r}}function o(e,n){let r=[],o=/* @__PURE__ */ new Map,s=null;return{onAnchor:t=>{r.push(t),s??=i(e);let o=a(n,s);return s.add(o),o},setAnchors:()=>{for(let e of r){let n=o.get(e);if(typeof n==`object`&&n.anchor&&(t.isScalar(n.node)||t.isCollection(n.node)))n.node.anchor=n.anchor;else{let t=/* @__PURE__ */ Error(`Failed to resolve repeated object (this should not happen)`);throw t.source=e,t}}},sourceObjects:o}}e.anchorIsValid=r,e.anchorNames=i,e.createNodeAnchors=o,e.findNewAnchor=a})),bn=/* @__PURE__ */ j((e=>{function t(e,n,r,i){if(i&&typeof i==`object`){if(Array.isArray(i))for(let n=0,r=i.length;n<r;++n){let r=i[n],a=t(e,i,String(n),r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}else if(i instanceof Map)for(let n of Array.from(i.keys())){let r=i.get(n),a=t(e,i,n,r);a===void 0?i.delete(n):a!==r&&i.set(n,a)}else if(i instanceof Set)for(let n of Array.from(i)){let r=t(e,i,n,n);r===void 0?i.delete(n):r!==n&&(i.delete(n),i.add(r))}else for(let[n,r]of Object.entries(i)){let a=t(e,i,n,r);a===void 0?delete i[n]:a!==r&&(i[n]=a)}}return e.call(n,r,i)}e.applyReviver=t})),xn=/* @__PURE__ */ j((e=>{var t=U();function n(e,r,i){if(Array.isArray(e))return e.map((e,t)=>n(e,String(t),i));if(e&&typeof e.toJSON==`function`){if(!i||!t.hasAnchor(e))return e.toJSON(r,i);let n={aliasCount:0,count:1,res:void 0};i.anchors.set(e,n),i.onCreate=e=>{n.res=e,delete i.onCreate};let a=e.toJSON(r,i);return i.onCreate&&i.onCreate(a),a}return typeof e==`bigint`&&!i?.keep?Number(e):e}e.toJS=n})),Sn=/* @__PURE__ */ j((e=>{var t=bn(),n=U(),r=xn();e.NodeBase=class{constructor(e){Object.defineProperty(this,n.NODE_TYPE,{value:e})}clone(){let e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:i,maxAliasCount:a,onAnchor:o,reviver:s}={}){if(!n.isDocument(e))throw TypeError(`A document argument is required`);let c={anchors:/* @__PURE__ */ new Map,doc:e,keep:!0,mapAsMap:i===!0,mapKeyWarned:!1,maxAliasCount:typeof a==`number`?a:100},l=r.toJS(this,``,c);if(typeof o==`function`)for(let{count:e,res:t}of c.anchors.values())o(t,e);return typeof s==`function`?t.applyReviver(s,{"":l},``,l):l}}})),Cn=/* @__PURE__ */ j((e=>{var t=yn(),n=_n(),r=U(),i=Sn(),a=xn(),o=class extends i.NodeBase{constructor(e){super(r.ALIAS),this.source=e,Object.defineProperty(this,"tag",{set(){throw Error(`Alias nodes cannot have tags`)}})}resolve(e,t){if(t?.maxAliasCount===0)throw ReferenceError(`Alias resolution is disabled`);let i;t?.aliasResolveCache?i=t.aliasResolveCache:(i=[],n.visit(e,{Node:(e,t)=>{(r.isAlias(t)||r.hasAnchor(t))&&i.push(t)}}),t&&(t.aliasResolveCache=i));let o;for(let e of i){if(e===this)break;e.anchor===this.source&&(o=e)}if(o&&t){let{anchors:e,doc:n,maxAliasCount:r}=t,i=e.get(o);
69
69
  /* istanbul ignore if */
70
- if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(r>=0&&(i.count+=1,i.aliasCount===0&&(i.aliasCount=s(n,o,e)),i.count*i.aliasCount>r))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return o}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),U=/* @__PURE__ */ A((e=>{var t=H(),n=bn(),r=yn();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),Sn=/* @__PURE__ */ A((e=>{var t=xn(),n=H(),r=U();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??(f.anchor=c(e)),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),Cn=/* @__PURE__ */ A((e=>{var t=Sn(),n=H(),r=bn();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=/* @__PURE__ */ new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:/* @__PURE__ */ new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),wn=/* @__PURE__ */ A((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
70
+ if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This should not happen: Alias anchor was not resolved?`);if(r>=0&&(i.count+=1,i.aliasCount===0&&(i.aliasCount=s(n,o,e)),i.count*i.aliasCount>r))throw ReferenceError(`Excessive alias count indicates a resource exhaustion attack`)}return o}toJSON(e,t){if(!t)return{source:this.source};let n=this.resolve(t.doc,t);if(!n){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw ReferenceError(e)}return t.anchors.get(n).res}toString(e,n,r){let i=`*${this.source}`;if(e){if(t.anchorIsValid(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){let e=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw Error(e)}if(e.implicitKey)return`${i} `}return i}};function s(e,t,n){if(r.isAlias(t)){let r=t.resolve(e),i=n&&r&&n.get(r);return i?i.count*i.aliasCount:0}if(r.isCollection(t)){let r=0;for(let i of t.items){let t=s(e,i,n);t>r&&(r=t)}return r}if(r.isPair(t)){let r=s(e,t.key,n),i=s(e,t.value,n);return Math.max(r,i)}return 1}e.Alias=o})),W=/* @__PURE__ */ j((e=>{var t=U(),n=Sn(),r=xn();let i=e=>!e||typeof e!=`function`&&typeof e!=`object`;var a=class extends n.NodeBase{constructor(e){super(t.SCALAR),this.value=e}toJSON(e,t){return t?.keep?this.value:r.toJS(this.value,e,t)}toString(){return String(this.value)}};a.BLOCK_FOLDED=`BLOCK_FOLDED`,a.BLOCK_LITERAL=`BLOCK_LITERAL`,a.PLAIN=`PLAIN`,a.QUOTE_DOUBLE=`QUOTE_DOUBLE`,a.QUOTE_SINGLE=`QUOTE_SINGLE`,e.Scalar=a,e.isScalarValue=i})),wn=/* @__PURE__ */ j((e=>{var t=Cn(),n=U(),r=W();function i(e,t,n){if(t){let e=n.filter(e=>e.tag===t),r=e.find(e=>!e.format)??e[0];if(!r)throw Error(`Tag ${t} not found`);return r}return n.find(t=>t.identify?.(e)&&!t.format)}function a(e,a,o){if(n.isDocument(e)&&(e=e.contents),n.isNode(e))return e;if(n.isPair(e)){let t=o.schema[n.MAP].createNode?.(o.schema,null,o);return t.items.push(e),t}(e instanceof String||e instanceof Number||e instanceof Boolean||typeof BigInt<`u`&&e instanceof BigInt)&&(e=e.valueOf());let{aliasDuplicateObjects:s,onAnchor:c,onTagObj:l,schema:u,sourceObjects:d}=o,f;if(s&&e&&typeof e==`object`){if(f=d.get(e),f)return f.anchor??(f.anchor=c(e)),new t.Alias(f.anchor);f={anchor:null,node:null},d.set(e,f)}a?.startsWith(`!!`)&&(a=`tag:yaml.org,2002:`+a.slice(2));let p=i(e,a,u.tags);if(!p){if(e&&typeof e.toJSON==`function`&&(e=e.toJSON()),!e||typeof e!=`object`){let t=new r.Scalar(e);return f&&(f.node=t),t}p=e instanceof Map?u[n.MAP]:Symbol.iterator in Object(e)?u[n.SEQ]:u[n.MAP]}l&&(l(p),delete o.onTagObj);let m=p?.createNode?p.createNode(o.schema,e,o):typeof p?.nodeClass?.from==`function`?p.nodeClass.from(o.schema,e,o):new r.Scalar(e);return a?m.tag=a:p.default||(m.tag=p.tag),f&&(f.node=m),m}e.createNode=a})),Tn=/* @__PURE__ */ j((e=>{var t=wn(),n=U(),r=Sn();function i(e,n,r){let i=r;for(let e=n.length-1;e>=0;--e){let t=n[e];if(typeof t==`number`&&Number.isInteger(t)&&t>=0){let e=[];e[t]=i,i=e}else i=/* @__PURE__ */ new Map([[t,i]])}return t.createNode(i,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw Error(`This should not happen, please report a bug.`)},schema:e,sourceObjects:/* @__PURE__ */ new Map})}let a=e=>e==null||typeof e==`object`&&!!e[Symbol.iterator]().next().done;e.Collection=class extends r.NodeBase{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){let t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(t=>n.isNode(t)||n.isPair(t)?t.clone(e):t),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(a(e))this.add(t);else{let[r,...a]=e,o=this.get(r,!0);if(n.isCollection(o))o.addIn(a,t);else if(o===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}deleteIn(e){let[t,...r]=e;if(r.length===0)return this.delete(t);let i=this.get(t,!0);if(n.isCollection(i))return i.deleteIn(r);throw Error(`Expected YAML collection at ${t}. Remaining path: ${r}`)}getIn(e,t){let[r,...i]=e,a=this.get(r,!0);return i.length===0?!t&&n.isScalar(a)?a.value:a:n.isCollection(a)?a.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!n.isPair(t))return!1;let r=t.value;return r==null||e&&n.isScalar(r)&&r.value==null&&!r.commentBefore&&!r.comment&&!r.tag})}hasIn(e){let[t,...r]=e;if(r.length===0)return this.has(t);let i=this.get(t,!0);return n.isCollection(i)?i.hasIn(r):!1}setIn(e,t){let[r,...a]=e;if(a.length===0)this.set(r,t);else{let e=this.get(r,!0);if(n.isCollection(e))e.setIn(a,t);else if(e===void 0&&this.schema)this.set(r,i(this.schema,a,t));else throw Error(`Expected YAML collection at ${r}. Remaining path: ${a}`)}}},e.collectionFromPath=i,e.isEmptyPath=a})),En=/* @__PURE__ */ j((e=>{let t=e=>e.replace(/^(?!$)(?: $)?/gm,`#`);function n(e,t){return/^\n+$/.test(e)?e.substring(1):t?e.replace(/^(?! *$)/gm,t):e}e.indentComment=n,e.lineComment=(e,t,r)=>e.endsWith(`
71
71
  `)?n(r,t):r.includes(`
72
72
  `)?`
73
- `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),Tn=/* @__PURE__ */ A((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
73
+ `+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),Dn=/* @__PURE__ */ j((e=>{let t=`block`,n=`quoted`;function r(e,r,a=`flow`,{indentAtStart:o,lineWidth:s=80,minContentWidth:c=20,onFold:l,onOverflow:u}={}){if(!s||s<0)return e;s<c&&(c=0);let d=Math.max(1+c,1+s-r.length);if(e.length<=d)return e;let f=[],p={},m=s-r.length;typeof o==`number`&&(o>s-Math.max(2,c)?f.push(0):m=s-o);let h,g,_=!1,v=-1,y=-1,b=-1;a===t&&(v=i(e,v,r.length),v!==-1&&(m=v+d));for(let o;o=e[v+=1];){if(a===n&&o===`\\`){switch(y=v,e[v+1]){case`x`:v+=3;break;case`u`:v+=5;break;case`U`:v+=9;break;default:v+=1}b=v}if(o===`
74
74
  `)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
75
75
  `&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
76
76
  `&&t!==` `&&(h=v)}if(v>=m){if(h)f.push(h),m=h+d,h=void 0;else if(a===n){for(;g===` `||g===` `;)g=o,o=e[v+=1],_=!0;let t=v>b+1?v-2:y-1;if(p[t])return e;f.push(t),p[t]=!0,m=t+d,h=void 0}else _=!0}}g=o}if(_&&u&&u(),f.length===0)return e;l&&l();let x=e.slice(0,f[0]);for(let t=0;t<f.length;++t){let i=f[t],o=f[t+1]||e.length;i===0?x=`\n${r}${e.slice(0,o)}`:(a===n&&p[i]&&(x+=`${e[i]}\\`),x+=`\n${r}${e.slice(i+1,o)}`)}return x}function i(e,t,n){let r=t,i=t+1,a=e[i];for(;a===` `||a===` `;)if(t<i+n)a=e[++t];else{do a=e[++t];while(a&&a!==`
77
- `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),En=/* @__PURE__ */ A((e=>{var t=U(),n=Tn();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
77
+ `);r=t,i=t+1,a=e[i]}return r}e.FOLD_BLOCK=t,e.FOLD_FLOW=`flow`,e.FOLD_QUOTED=n,e.foldFlowLines=r})),On=/* @__PURE__ */ j((e=>{var t=W(),n=Dn();let r=(e,t)=>({indentAtStart:t?e.indent.length:e.indentAtStart,lineWidth:e.options.lineWidth,minContentWidth:e.options.minContentWidth}),i=e=>/^(%|---|\.\.\.)/m.test(e);function a(e,t,n){if(!t||t<0)return!1;let r=t-n,i=e.length;if(i<=r)return!1;for(let t=0,n=0;t<i;++t)if(e[t]===`
78
78
  `){if(t-n>r)return!0;if(n=t+1,i-n<=r)return!1}return!0}function o(e,t){let a=JSON.stringify(e);if(t.options.doubleQuotedAsJSON)return a;let{implicitKey:o}=t,s=t.options.doubleQuotedMinMultiLineLength,c=t.indent||(i(e)?` `:``),l=``,u=0;for(let e=0,t=a[e];t;t=a[++e])if(t===` `&&a[e+1]===`\\`&&a[e+2]===`n`&&(l+=a.slice(u,e)+`\\ `,e+=1,u=e,t=`\\`),t===`\\`)switch(a[e+1]){case`u`:{l+=a.slice(u,e);let t=a.substr(e+2,4);switch(t){case`0000`:l+=`\\0`;break;case`0007`:l+=`\\a`;break;case`000b`:l+=`\\v`;break;case`001b`:l+=`\\e`;break;case`0085`:l+=`\\N`;break;case`00a0`:l+=`\\_`;break;case`2028`:l+=`\\L`;break;case`2029`:l+=`\\P`;break;default:t.substr(0,2)===`00`?l+=`\\x`+t.substr(2):l+=a.substr(e,6)}e+=5,u=e+1}break;case`n`:if(o||a[e+2]===`"`||a.length<s)e+=1;else{for(l+=a.slice(u,e)+`
79
79
 
80
80
  `;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
@@ -92,29 +92,29 @@ if(i||=(a.toJS(o,null,t),e.get(o)),i?.res===void 0)throw ReferenceError(`This sh
92
92
  $&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,`$1$2`).replace(/\n+/g,`$&${g}`),i=!1,a=r(u,!0);p!==`folded`&&o!==t.Scalar.BLOCK_FOLDED&&(a.onOverflow=()=>{i=!0});let c=n.foldFlowLines(`${T}${e}${b}`,g,n.FOLD_BLOCK,a);if(!i)return`>${E}\n${g}${c}`}return s=s.replace(/\n+/g,`$&${g}`),`|${E}\n${g}${T}${s}${b}`}function d(e,a,o,s){let{type:l,value:d}=e,{actualString:f,implicitKey:p,indent:m,indentStep:h,inFlow:g}=a;if(p&&d.includes(`
93
93
  `)||g&&/[[\]{},]/.test(d))return c(d,a);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(d))return p||g||!d.includes(`
94
94
  `)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
95
- `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),Dn=/* @__PURE__ */ A((e=>{var t=_n(),n=H(),r=wn(),i=En();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:/* @__PURE__ */ new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=/* @__PURE__ */ new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),On=/* @__PURE__ */ A((e=>{var t=H(),n=U(),r=Dn(),i=wn();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
95
+ `))return u(e,a,o,s);if(i(d)){if(m===``)return a.forceBlockIndent=!0,u(e,a,o,s);if(p&&m===h)return c(d,a)}let _=d.replace(/\n+/g,`$&\n${m}`);if(f){let e=e=>e.default&&e.tag!==`tag:yaml.org,2002:str`&&e.test?.test(_),{compat:t,tags:n}=a.doc.schema;if(n.some(e)||t?.some(e))return c(d,a)}return p?_:n.foldFlowLines(_,m,n.FOLD_FLOW,r(a,!1))}function f(e,n,r,i){let{implicitKey:a,inFlow:l}=n,f=typeof e.value==`string`?e:Object.assign({},e,{value:String(e.value)}),{type:p}=e;p!==t.Scalar.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(f.value)&&(p=t.Scalar.QUOTE_DOUBLE);let m=e=>{switch(e){case t.Scalar.BLOCK_FOLDED:case t.Scalar.BLOCK_LITERAL:return a||l?c(f.value,n):u(f,n,r,i);case t.Scalar.QUOTE_DOUBLE:return o(f.value,n);case t.Scalar.QUOTE_SINGLE:return s(f.value,n);case t.Scalar.PLAIN:return d(f,n,r,i);default:return null}},h=m(p);if(h===null){let{defaultKeyType:e,defaultStringType:t}=n.options,r=a&&e||t;if(h=m(r),h===null)throw Error(`Unsupported default string type ${r}`)}return h}e.stringifyString=f})),kn=/* @__PURE__ */ j((e=>{var t=yn(),n=U(),r=En(),i=On();function a(e,t){let n=Object.assign({blockQuote:!0,commentString:r.stringifyComment,defaultKeyType:null,defaultStringType:`PLAIN`,directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:`false`,flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:`null`,simpleKeys:!1,singleQuote:null,trailingComma:!1,trueStr:`true`,verifyAliasOrder:!0},e.schema.toStringOptions,t),i;switch(n.collectionStyle){case`block`:i=!1;break;case`flow`:i=!0;break;default:i=null}return{anchors:/* @__PURE__ */ new Set,doc:e,flowCollectionPadding:n.flowCollectionPadding?` `:``,indent:``,indentStep:typeof n.indent==`number`?` `.repeat(n.indent):` `,inFlow:i,options:n}}function o(e,t){if(t.tag){let n=e.filter(e=>e.tag===t.tag);if(n.length>0)return n.find(e=>e.format===t.format)??n[0]}let r,i;if(n.isScalar(t)){i=t.value;let n=e.filter(e=>e.identify?.(i));if(n.length>1){let e=n.filter(e=>e.test);e.length>0&&(n=e)}r=n.find(e=>e.format===t.format)??n.find(e=>!e.format)}else i=t,r=e.find(e=>e.nodeClass&&i instanceof e.nodeClass);if(!r){let e=i?.constructor?.name??(i===null?`null`:typeof i);throw Error(`Tag not resolved for ${e} value`)}return r}function s(e,r,{anchors:i,doc:a}){if(!a.directives)return``;let o=[],s=(n.isScalar(e)||n.isCollection(e))&&e.anchor;s&&t.anchorIsValid(s)&&(i.add(s),o.push(`&${s}`));let c=e.tag??(r.default?null:r.tag);return c&&o.push(a.directives.tagString(c)),o.join(` `)}function c(e,t,r,a){if(n.isPair(e))return e.toString(t,r,a);if(n.isAlias(e)){if(t.doc.directives)return e.toString(t);if(t.resolvedAliases?.has(e))throw TypeError(`Cannot stringify circular structure without alias nodes`);t.resolvedAliases?t.resolvedAliases.add(e):t.resolvedAliases=/* @__PURE__ */ new Set([e]),e=e.resolve(t.doc)}let c,l=n.isNode(e)?e:t.doc.createNode(e,{onTagObj:e=>c=e});c??=o(t.doc.schema.tags,l);let u=s(l,c,t);u.length>0&&(t.indentAtStart=(t.indentAtStart??0)+u.length+1);let d=typeof c.stringify==`function`?c.stringify(l,t,r,a):n.isScalar(l)?i.stringifyString(l,t,r,a):l.toString(t,r,a);return u?n.isScalar(l)||d[0]===`{`||d[0]===`[`?`${u} ${d}`:`${u}\n${t.indent}${d}`:d}e.createStringifyContext=a,e.stringify=c})),An=/* @__PURE__ */ j((e=>{var t=U(),n=W(),r=kn(),i=En();function a({key:e,value:a},o,s,c){let{allNullValues:l,doc:u,indent:d,indentStep:f,options:{commentString:p,indentSeq:m,simpleKeys:h}}=o,g=t.isNode(e)&&e.comment||null;if(h){if(g)throw Error(`With simple keys, key nodes cannot have comments`);if(t.isCollection(e)||!t.isNode(e)&&typeof e==`object`)throw Error(`With simple keys, collection cannot be used as a key value`)}let _=!h&&(!e||g&&a==null&&!o.inFlow||t.isCollection(e)||(t.isScalar(e)?e.type===n.Scalar.BLOCK_FOLDED||e.type===n.Scalar.BLOCK_LITERAL:typeof e==`object`));o=Object.assign({},o,{allNullValues:!1,implicitKey:!_&&(h||!l),indent:d+f});let v=!1,y=!1,b=r.stringify(e,o,()=>v=!0,()=>y=!0);if(!_&&!o.inFlow&&b.length>1024){if(h)throw Error(`With simple keys, single line scalar must not span more than 1024 characters`);_=!0}if(o.inFlow){if(l||a==null)return v&&s&&s(),b===``?`?`:_?`? ${b}`:b}else if(l&&!h||a==null&&_)return b=`? ${b}`,g&&!v?b+=i.lineComment(b,o.indent,p(g)):y&&c&&c(),b;v&&(g=null),_?(g&&(b+=i.lineComment(b,o.indent,p(g))),b=`? ${b}\n${d}:`):(b=`${b}:`,g&&(b+=i.lineComment(b,o.indent,p(g))));let x,S,C;t.isNode(a)?(x=!!a.spaceBefore,S=a.commentBefore,C=a.comment):(x=!1,S=null,C=null,a&&typeof a==`object`&&(a=u.createNode(a))),o.implicitKey=!1,!_&&!g&&t.isScalar(a)&&(o.indentAtStart=b.length+1),y=!1,!m&&f.length>=2&&!o.inFlow&&!_&&t.isSeq(a)&&!a.flow&&!a.tag&&!a.anchor&&(o.indent=o.indent.substring(2));let w=!1,T=r.stringify(a,o,()=>w=!0,()=>y=!0),E=` `;if(g||x||S){if(E=x?`
96
96
  `:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
97
97
  `&&C&&(E=`
98
98
 
99
99
  `):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
100
100
  `),n=t!==-1,r=o.inFlow??a.flow??a.items.length===0;if(n||!r){let r=!1;if(n&&(e===`&`||e===`!`)){let n=T.indexOf(` `);e===`&`&&n!==-1&&n<t&&T[n+1]===`!`&&(n=T.indexOf(` `,n+1)),(n===-1||t<n)&&(r=!0)}r||(E=`\n${o.indent}`)}}else(T===``||T[0]===`
101
- `)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),kn=/* @__PURE__ */ A((e=>{var t=le(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),An=/* @__PURE__ */ A((e=>{var t=H(),n=U();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){let i=s(e,r);if(t.isSeq(i))for(let t of i.items)o(e,n,t);else if(Array.isArray(i))for(let t of i)o(e,n,t);else o(e,n,i)}function o(e,n,r){let i=s(e,r);if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}function s(e,n){return e&&t.isAlias(n)?n.resolve(e.doc,e):n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),jn=/* @__PURE__ */ A((e=>{var t=kn(),n=An(),r=Dn(),i=H(),a=yn();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=/* @__PURE__ */ new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),W=/* @__PURE__ */ A((e=>{var t=Sn(),n=On(),r=jn(),i=H();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?/* @__PURE__ */ new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),Mn=/* @__PURE__ */ A((e=>{var t=H(),n=Dn(),r=wn();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
101
+ `)&&(E=``);return b+=E+T,o.inFlow?w&&s&&s():C&&!w?b+=i.lineComment(b,o.indent,p(C)):y&&c&&c(),b}e.stringifyPair=a})),jn=/* @__PURE__ */ j((e=>{var t=de(`process`);function n(e,...t){e===`debug`&&console.log(...t)}function r(e,n){(e===`debug`||e===`warn`)&&(typeof t.emitWarning==`function`?t.emitWarning(n):console.warn(n))}e.debug=n,e.warn=r})),Mn=/* @__PURE__ */ j((e=>{var t=U(),n=W();let r={identify:e=>e===`<<`||typeof e==`symbol`&&e.description===`<<`,default:`key`,tag:`tag:yaml.org,2002:merge`,test:/^<<$/,resolve:()=>Object.assign(new n.Scalar(Symbol(`<<`)),{addToJSMap:a}),stringify:()=>`<<`},i=(e,i)=>(r.identify(i)||t.isScalar(i)&&(!i.type||i.type===n.Scalar.PLAIN)&&r.identify(i.value))&&e?.doc.schema.tags.some(e=>e.tag===r.tag&&e.default);function a(e,n,r){let i=s(e,r);if(t.isSeq(i))for(let t of i.items)o(e,n,t);else if(Array.isArray(i))for(let t of i)o(e,n,t);else o(e,n,i)}function o(e,n,r){let i=s(e,r);if(!t.isMap(i))throw Error(`Merge sources must be maps or map aliases`);let a=i.toJSON(null,e,Map);for(let[e,t]of a)n instanceof Map?n.has(e)||n.set(e,t):n instanceof Set?n.add(e):Object.prototype.hasOwnProperty.call(n,e)||Object.defineProperty(n,e,{value:t,writable:!0,enumerable:!0,configurable:!0});return n}function s(e,n){return e&&t.isAlias(n)?n.resolve(e.doc,e):n}e.addMergeToJSMap=a,e.isMergeKey=i,e.merge=r})),Nn=/* @__PURE__ */ j((e=>{var t=jn(),n=Mn(),r=kn(),i=U(),a=xn();function o(e,t,{key:r,value:o}){if(i.isNode(r)&&r.addToJSMap)r.addToJSMap(e,t,o);else if(n.isMergeKey(e,r))n.addMergeToJSMap(e,t,o);else{let n=a.toJS(r,``,e);if(t instanceof Map)t.set(n,a.toJS(o,n,e));else if(t instanceof Set)t.add(n);else{let i=s(r,n,e),c=a.toJS(o,i,e);i in t?Object.defineProperty(t,i,{value:c,writable:!0,enumerable:!0,configurable:!0}):t[i]=c}}return t}function s(e,n,a){if(n===null)return``;if(typeof n!=`object`)return String(n);if(i.isNode(e)&&a?.doc){let n=r.createStringifyContext(a.doc,{});n.anchors=/* @__PURE__ */ new Set;for(let e of a.anchors.keys())n.anchors.add(e.anchor);n.inFlow=!0,n.inStringifyKey=!0;let i=e.toString(n);if(!a.mapKeyWarned){let e=JSON.stringify(i);e.length>40&&(e=e.substring(0,36)+`..."`),t.warn(a.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${e}. Set mapAsMap: true to use object keys.`),a.mapKeyWarned=!0}return i}return JSON.stringify(n)}e.addPairToJSMap=o})),Pn=/* @__PURE__ */ j((e=>{var t=wn(),n=An(),r=Nn(),i=U();function a(e,n,r){return new o(t.createNode(e,void 0,r),t.createNode(n,void 0,r))}var o=class e{constructor(e,t=null){Object.defineProperty(this,i.NODE_TYPE,{value:i.PAIR}),this.key=e,this.value=t}clone(t){let{key:n,value:r}=this;return i.isNode(n)&&(n=n.clone(t)),i.isNode(r)&&(r=r.clone(t)),new e(n,r)}toJSON(e,t){let n=t?.mapAsMap?/* @__PURE__ */ new Map:{};return r.addPairToJSMap(t,n,this)}toString(e,t,r){return e?.doc?n.stringifyPair(this,e,t,r):JSON.stringify(this)}};e.Pair=o,e.createPair=a})),Fn=/* @__PURE__ */ j((e=>{var t=U(),n=kn(),r=En();function i(e,t,n){return(t.inFlow??e.flow?o:a)(e,t,n)}function a({comment:e,items:i},a,{blockItemPrefix:o,flowChars:c,itemIndent:l,onChompKeep:u,onComment:d}){let{indent:f,options:{commentString:p}}=a,m=Object.assign({},a,{indent:l,type:null}),h=!1,g=[];for(let e=0;e<i.length;++e){let c=i[e],u=null;if(t.isNode(c))!h&&c.spaceBefore&&g.push(``),s(a,g,c.commentBefore,h),c.comment&&(u=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(!h&&e.spaceBefore&&g.push(``),s(a,g,e.commentBefore,h))}h=!1;let d=n.stringify(c,m,()=>u=null,()=>h=!0);u&&(d+=r.lineComment(d,l,p(u))),h&&u&&(h=!1),g.push(o+d)}let _;if(g.length===0)_=c.start+c.end;else{_=g[0];for(let e=1;e<g.length;++e){let t=g[e];_+=t?`\n${f}${t}`:`
102
102
  `}}return e?(_+=`
103
103
  `+r.indentComment(p(e),f),d&&d()):h&&u&&u(),_}function o({items:e},i,{flowChars:a,itemIndent:o}){let{indent:c,indentStep:l,flowCollectionPadding:u,options:{commentString:d}}=i;o+=l;let f=Object.assign({},i,{indent:o,inFlow:!0,type:null}),p=!1,m=0,h=[];for(let a=0;a<e.length;++a){let c=e[a],l=null;if(t.isNode(c))c.spaceBefore&&h.push(``),s(i,h,c.commentBefore,!1),c.comment&&(l=c.comment);else if(t.isPair(c)){let e=t.isNode(c.key)?c.key:null;e&&(e.spaceBefore&&h.push(``),s(i,h,e.commentBefore,!1),e.comment&&(p=!0));let n=t.isNode(c.value)?c.value:null;n?(n.comment&&(l=n.comment),n.commentBefore&&(p=!0)):c.value==null&&e?.comment&&(l=e.comment)}l&&(p=!0);let u=n.stringify(c,f,()=>l=null);p||=h.length>m||u.includes(`
104
104
  `),a<e.length-1?u+=`,`:i.options.trailingComma&&(i.options.lineWidth>0&&(p||=h.reduce((e,t)=>e+t.length+2,2)+(u.length+2)>i.options.lineWidth),p&&(u+=`,`)),l&&(u+=r.lineComment(u,o,d(l))),h.push(u),m=h.length}let{start:g,end:_}=a;if(h.length===0)return g+_;if(!p){let e=h.reduce((e,t)=>e+t.length+2,2);p=i.options.lineWidth>0&&e>i.options.lineWidth}if(p){let e=g;for(let t of h)e+=t?`\n${l}${c}${t}`:`
105
- `;return`${e}\n${c}${_}`}return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),G=/* @__PURE__ */ A((e=>{var t=Mn(),n=jn(),r=Cn(),i=H(),a=W(),o=U();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?/* @__PURE__ */ new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),Nn=/* @__PURE__ */ A((e=>{var t=H(),n=G();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),K=/* @__PURE__ */ A((e=>{var t=Sn(),n=Mn(),r=Cn(),i=H(),a=U(),o=yn(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),Pn=/* @__PURE__ */ A((e=>{var t=H(),n=K();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),Fn=/* @__PURE__ */ A((e=>{var t=En();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),In=/* @__PURE__ */ A((e=>{var t=U();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),Ln=/* @__PURE__ */ A((e=>{var t=U();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),Rn=/* @__PURE__ */ A((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}e.stringifyNumber=t})),zn=/* @__PURE__ */ A((e=>{var t=U(),n=Rn();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Bn=/* @__PURE__ */ A((e=>{var t=Rn();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),Vn=/* @__PURE__ */ A((e=>{var t=Nn(),n=In(),r=Pn(),i=Fn(),a=Ln(),o=zn(),s=Bn();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),Hn=/* @__PURE__ */ A((e=>{var t=U(),n=Nn(),r=Pn();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),Un=/* @__PURE__ */ A((e=>{var t=le(`buffer`),n=U(),r=En();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
106
- `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),Wn=/* @__PURE__ */ A((e=>{var t=H(),n=W(),r=U(),i=K();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),Gn=/* @__PURE__ */ A((e=>{var t=H(),n=yn(),r=G(),i=K(),a=Wn(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=/* @__PURE__ */ new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),Kn=/* @__PURE__ */ A((e=>{var t=U();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),qn=/* @__PURE__ */ A((e=>{var t=U(),n=Rn();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Jn=/* @__PURE__ */ A((e=>{var t=Rn();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),Yn=/* @__PURE__ */ A((e=>{var t=H(),n=W(),r=G(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),Xn=/* @__PURE__ */ A((e=>{var t=Rn();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),Zn=/* @__PURE__ */ A((e=>{var t=Nn(),n=In(),r=Pn(),i=Fn(),a=Un(),o=Kn(),s=qn(),c=Jn(),l=An(),u=Gn(),d=Wn(),f=Yn(),p=Xn();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),Qn=/* @__PURE__ */ A((e=>{var t=Nn(),n=In(),r=Pn(),i=Fn(),a=Ln(),o=zn(),s=Bn(),c=Vn(),l=Hn(),u=Un(),d=An(),f=Gn(),p=Wn(),m=Zn(),h=Yn(),g=Xn();let _=/* @__PURE__ */ new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),$n=/* @__PURE__ */ A((e=>{var t=H(),n=Nn(),r=Pn(),i=Fn(),a=Qn();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),er=/* @__PURE__ */ A((e=>{var t=H(),n=Dn(),r=wn();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
105
+ `;return`${e}\n${c}${_}`}return`${g}${u}${h.join(` `)}${u}${_}`}function s({indent:e,options:{commentString:t}},n,i,a){if(i&&a&&(i=i.replace(/^\n+/,``)),i){let a=r.indentComment(t(i),e);n.push(a.trimStart())}}e.stringifyCollection=i})),In=/* @__PURE__ */ j((e=>{var t=Fn(),n=Nn(),r=Tn(),i=U(),a=Pn(),o=W();function s(e,t){let n=i.isScalar(t)?t.value:t;for(let r of e)if(i.isPair(r)&&(r.key===t||r.key===n||i.isScalar(r.key)&&r.key.value===n))return r}e.YAMLMap=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:map`}constructor(e){super(i.MAP,e),this.items=[]}static from(e,t,n){let{keepUndefined:r,replacer:i}=n,o=new this(e),s=(e,s)=>{if(typeof i==`function`)s=i.call(t,e,s);else if(Array.isArray(i)&&!i.includes(e))return;(s!==void 0||r)&&o.items.push(a.createPair(e,s,n))};if(t instanceof Map)for(let[e,n]of t)s(e,n);else if(t&&typeof t==`object`)for(let e of Object.keys(t))s(e,t[e]);return typeof e.sortMapEntries==`function`&&o.items.sort(e.sortMapEntries),o}add(e,t){let n;n=i.isPair(e)?e:!e||typeof e!=`object`||!(`key`in e)?new a.Pair(e,e?.value):new a.Pair(e.key,e.value);let r=s(this.items,n.key),c=this.schema?.sortMapEntries;if(r){if(!t)throw Error(`Key ${n.key} already set`);i.isScalar(r.value)&&o.isScalarValue(n.value)?r.value.value=n.value:r.value=n.value}else if(c){let e=this.items.findIndex(e=>c(n,e)<0);e===-1?this.items.push(n):this.items.splice(e,0,n)}else this.items.push(n)}delete(e){let t=s(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){let n=s(this.items,e)?.value;return(!t&&i.isScalar(n)?n.value:n)??void 0}has(e){return!!s(this.items,e)}set(e,t){this.add(new a.Pair(e,t),!0)}toJSON(e,t,r){let i=r?new r:t?.mapAsMap?/* @__PURE__ */ new Map:{};t?.onCreate&&t.onCreate(i);for(let e of this.items)n.addPairToJSMap(t,i,e);return i}toString(e,n,r){if(!e)return JSON.stringify(this);for(let e of this.items)if(!i.isPair(e))throw Error(`Map items must all be pairs; found ${JSON.stringify(e)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),t.stringifyCollection(this,e,{blockItemPrefix:``,flowChars:{start:`{`,end:`}`},itemIndent:e.indent||``,onChompKeep:r,onComment:n})}},e.findPair=s})),Ln=/* @__PURE__ */ j((e=>{var t=U(),n=In();e.map={collection:`map`,default:!0,nodeClass:n.YAMLMap,tag:`tag:yaml.org,2002:map`,resolve(e,n){return t.isMap(e)||n(`Expected a mapping for this tag`),e},createNode:(e,t,r)=>n.YAMLMap.from(e,t,r)}})),Rn=/* @__PURE__ */ j((e=>{var t=wn(),n=Fn(),r=Tn(),i=U(),a=W(),o=xn(),s=class extends r.Collection{static get tagName(){return`tag:yaml.org,2002:seq`}constructor(e){super(i.SEQ,e),this.items=[]}add(e){this.items.push(e)}delete(e){let t=c(e);return typeof t==`number`&&this.items.splice(t,1).length>0}get(e,t){let n=c(e);if(typeof n!=`number`)return;let r=this.items[n];return!t&&i.isScalar(r)?r.value:r}has(e){let t=c(e);return typeof t==`number`&&t<this.items.length}set(e,t){let n=c(e);if(typeof n!=`number`)throw Error(`Expected a valid index, not ${e}.`);let r=this.items[n];i.isScalar(r)&&a.isScalarValue(t)?r.value=t:this.items[n]=t}toJSON(e,t){let n=[];t?.onCreate&&t.onCreate(n);let r=0;for(let e of this.items)n.push(o.toJS(e,String(r++),t));return n}toString(e,t,r){return e?n.stringifyCollection(this,e,{blockItemPrefix:`- `,flowChars:{start:`[`,end:`]`},itemIndent:(e.indent||``)+` `,onChompKeep:r,onComment:t}):JSON.stringify(this)}static from(e,n,r){let{replacer:i}=r,a=new this(e);if(n&&Symbol.iterator in Object(n)){let e=0;for(let o of n){if(typeof i==`function`){let t=n instanceof Set?o:String(e++);o=i.call(n,t,o)}a.items.push(t.createNode(o,void 0,r))}}return a}};function c(e){let t=i.isScalar(e)?e.value:e;return t&&typeof t==`string`&&(t=Number(t)),typeof t==`number`&&Number.isInteger(t)&&t>=0?t:null}e.YAMLSeq=s})),zn=/* @__PURE__ */ j((e=>{var t=U(),n=Rn();e.seq={collection:`seq`,default:!0,nodeClass:n.YAMLSeq,tag:`tag:yaml.org,2002:seq`,resolve(e,n){return t.isSeq(e)||n(`Expected a sequence for this tag`),e},createNode:(e,t,r)=>n.YAMLSeq.from(e,t,r)}})),Bn=/* @__PURE__ */ j((e=>{var t=On();e.string={identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify(e,n,r,i){return n=Object.assign({actualString:!0},n),t.stringifyString(e,n,r,i)}}})),Vn=/* @__PURE__ */ j((e=>{var t=W();let n={identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new t.Scalar(null),stringify:({source:e},t)=>typeof e==`string`&&n.test.test(e)?e:t.options.nullStr};e.nullTag=n})),Hn=/* @__PURE__ */ j((e=>{var t=W();let n={identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:e=>new t.Scalar(e[0]===`t`||e[0]===`T`),stringify({source:e,value:t},r){return e&&n.test.test(e)&&t===(e[0]===`t`||e[0]===`T`)?e:t?r.options.trueStr:r.options.falseStr}};e.boolTag=n})),Un=/* @__PURE__ */ j((e=>{function t({format:e,minFractionDigits:t,tag:n,value:r}){if(typeof r==`bigint`)return String(r);let i=typeof r==`number`?r:Number(r);if(!isFinite(i))return isNaN(i)?`.nan`:i<0?`-.inf`:`.inf`;let a=Object.is(r,-0)?`-0`:JSON.stringify(r);if(!e&&t&&(!n||n===`tag:yaml.org,2002:float`)&&/^-?\d/.test(a)&&!a.includes(`e`)){let e=a.indexOf(`.`);e<0&&(e=a.length,a+=`.`);let n=t-(a.length-e-1);for(;n-->0;)a+=`0`}return a}e.stringifyNumber=t})),Wn=/* @__PURE__ */ j((e=>{var t=W(),n=Un();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(e){let n=new t.Scalar(parseFloat(e)),r=e.indexOf(`.`);return r!==-1&&e[e.length-1]===`0`&&(n.minFractionDigits=e.length-r-1),n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),Gn=/* @__PURE__ */ j((e=>{var t=Un();let n=e=>typeof e==`bigint`||Number.isInteger(e),r=(e,t,n,{intAsBigInt:r})=>r?BigInt(e):parseInt(e.substring(t),n);function i(e,r,i){let{value:a}=e;return n(a)&&a>=0?i+a.toString(r):t.stringifyNumber(e)}e.int={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9]+$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},e.intHex={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^0x[0-9a-fA-F]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)},e.intOct={identify:e=>n(e)&&e>=0,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^0o[0-7]+$/,resolve:(e,t,n)=>r(e,2,8,n),stringify:e=>i(e,8,`0o`)}})),Kn=/* @__PURE__ */ j((e=>{var t=Ln(),n=Vn(),r=zn(),i=Bn(),a=Hn(),o=Wn(),s=Gn();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),qn=/* @__PURE__ */ j((e=>{var t=W(),n=Ln(),r=zn();function i(e){return typeof e==`bigint`||Number.isInteger(e)}let a=({value:e})=>JSON.stringify(e),o=[{identify:e=>typeof e==`string`,default:!0,tag:`tag:yaml.org,2002:str`,resolve:e=>e,stringify:a},{identify:e=>e==null,createNode:()=>new t.Scalar(null),default:!0,tag:`tag:yaml.org,2002:null`,test:/^null$/,resolve:()=>null,stringify:a},{identify:e=>typeof e==`boolean`,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^true$|^false$/,resolve:e=>e===`true`,stringify:a},{identify:i,default:!0,tag:`tag:yaml.org,2002:int`,test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(e,t,{intAsBigInt:n})=>n?BigInt(e):parseInt(e,10),stringify:({value:e})=>i(e)?e.toString():JSON.stringify(e)},{identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:e=>parseFloat(e),stringify:a}];e.schema=[n.map,r.seq].concat(o,{default:!0,tag:``,test:/^/,resolve(e,t){return t(`Unresolved plain scalar ${JSON.stringify(e)}`),e}})})),Jn=/* @__PURE__ */ j((e=>{var t=de(`buffer`),n=W(),r=On();e.binary={identify:e=>e instanceof Uint8Array,default:!1,tag:`tag:yaml.org,2002:binary`,resolve(e,n){if(typeof t.Buffer==`function`)return t.Buffer.from(e,`base64`);if(typeof atob==`function`){let t=atob(e.replace(/[\n\r]/g,``)),n=new Uint8Array(t.length);for(let e=0;e<t.length;++e)n[e]=t.charCodeAt(e);return n}return n(`This environment does not support reading binary tags; either Buffer or atob is required`),e},stringify({comment:e,type:i,value:a},o,s,c){if(!a)return``;let l=a,u;if(typeof t.Buffer==`function`)u=l instanceof t.Buffer?l.toString(`base64`):t.Buffer.from(l.buffer).toString(`base64`);else if(typeof btoa==`function`){let e=``;for(let t=0;t<l.length;++t)e+=String.fromCharCode(l[t]);u=btoa(e)}else throw Error(`This environment does not support writing binary tags; either Buffer or btoa is required`);if(i??=n.Scalar.BLOCK_LITERAL,i!==n.Scalar.QUOTE_DOUBLE){let e=Math.max(o.options.lineWidth-o.indent.length,o.options.minContentWidth),t=Math.ceil(u.length/e),r=Array(t);for(let n=0,i=0;n<t;++n,i+=e)r[n]=u.substr(i,e);u=r.join(i===n.Scalar.BLOCK_LITERAL?`
106
+ `:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),Yn=/* @__PURE__ */ j((e=>{var t=U(),n=Pn(),r=W(),i=Rn();function a(e,i){if(t.isSeq(e))for(let a=0;a<e.items.length;++a){let o=e.items[a];if(!t.isPair(o)){if(t.isMap(o)){o.items.length>1&&i(`Each pair must have its own sequence indicator`);let e=o.items[0]||new n.Pair(new r.Scalar(null));if(o.commentBefore&&(e.key.commentBefore=e.key.commentBefore?`${o.commentBefore}\n${e.key.commentBefore}`:o.commentBefore),o.comment){let t=e.value??e.key;t.comment=t.comment?`${o.comment}\n${t.comment}`:o.comment}o=e}e.items[a]=t.isPair(o)?o:new n.Pair(o)}}else i(`Expected a sequence for this tag`);return e}function o(e,t,r){let{replacer:a}=r,o=new i.YAMLSeq(e);o.tag=`tag:yaml.org,2002:pairs`;let s=0;if(t&&Symbol.iterator in Object(t))for(let e of t){typeof a==`function`&&(e=a.call(t,String(s++),e));let i,c;if(Array.isArray(e)){if(e.length===2)i=e[0],c=e[1];else throw TypeError(`Expected [key, value] tuple: ${e}`)}else if(e&&e instanceof Object){let t=Object.keys(e);if(t.length===1)i=t[0],c=e[i];else throw TypeError(`Expected tuple with one key, not ${t.length} keys`)}else i=e;o.items.push(n.createPair(i,c,r))}return o}let s={collection:`seq`,default:!1,tag:`tag:yaml.org,2002:pairs`,resolve:a,createNode:o};e.createPairs=o,e.pairs=s,e.resolvePairs=a})),Xn=/* @__PURE__ */ j((e=>{var t=U(),n=xn(),r=In(),i=Rn(),a=Yn(),o=class e extends i.YAMLSeq{constructor(){super(),this.add=r.YAMLMap.prototype.add.bind(this),this.delete=r.YAMLMap.prototype.delete.bind(this),this.get=r.YAMLMap.prototype.get.bind(this),this.has=r.YAMLMap.prototype.has.bind(this),this.set=r.YAMLMap.prototype.set.bind(this),this.tag=e.tag}toJSON(e,r){if(!r)return super.toJSON(e);let i=/* @__PURE__ */ new Map;r?.onCreate&&r.onCreate(i);for(let e of this.items){let a,o;if(t.isPair(e)?(a=n.toJS(e.key,``,r),o=n.toJS(e.value,a,r)):a=n.toJS(e,``,r),i.has(a))throw Error(`Ordered maps must not include duplicate keys`);i.set(a,o)}return i}static from(e,t,n){let r=a.createPairs(e,t,n),i=new this;return i.items=r.items,i}};o.tag=`tag:yaml.org,2002:omap`;let s={collection:`seq`,identify:e=>e instanceof Map,nodeClass:o,default:!1,tag:`tag:yaml.org,2002:omap`,resolve(e,n){let r=a.resolvePairs(e,n),i=[];for(let{key:e}of r.items)t.isScalar(e)&&(i.includes(e.value)?n(`Ordered maps must not include duplicate keys: ${e.value}`):i.push(e.value));return Object.assign(new o,r)},createNode:(e,t,n)=>o.from(e,t,n)};e.YAMLOMap=o,e.omap=s})),Zn=/* @__PURE__ */ j((e=>{var t=W();function n({value:e,source:t},n){return t&&(e?r:i).test.test(t)?t:e?n.options.trueStr:n.options.falseStr}let r={identify:e=>e===!0,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new t.Scalar(!0),stringify:n},i={identify:e=>e===!1,default:!0,tag:`tag:yaml.org,2002:bool`,test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new t.Scalar(!1),stringify:n};e.falseTag=i,e.trueTag=r})),Qn=/* @__PURE__ */ j((e=>{var t=W(),n=Un();let r={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:e=>e.slice(-3).toLowerCase()===`nan`?NaN:e[0]===`-`?-1/0:1/0,stringify:n.stringifyNumber};e.float={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(e){let n=new t.Scalar(parseFloat(e.replace(/_/g,``))),r=e.indexOf(`.`);if(r!==-1){let t=e.substring(r+1).replace(/_/g,``);t[t.length-1]===`0`&&(n.minFractionDigits=t.length)}return n},stringify:n.stringifyNumber},e.floatExp={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`EXP`,test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:e=>parseFloat(e.replace(/_/g,``)),stringify(e){let t=Number(e.value);return isFinite(t)?t.toExponential():n.stringifyNumber(e)}},e.floatNaN=r})),$n=/* @__PURE__ */ j((e=>{var t=Un();let n=e=>typeof e==`bigint`||Number.isInteger(e);function r(e,t,n,{intAsBigInt:r}){let i=e[0];if((i===`-`||i===`+`)&&(t+=1),e=e.substring(t).replace(/_/g,``),r){switch(n){case 2:e=`0b${e}`;break;case 8:e=`0o${e}`;break;case 16:e=`0x${e}`}let t=BigInt(e);return i===`-`?BigInt(-1)*t:t}let a=parseInt(e,n);return i===`-`?-1*a:a}function i(e,r,i){let{value:a}=e;if(n(a)){let e=a.toString(r);return a<0?`-`+i+e.substr(1):i+e}return t.stringifyNumber(e)}let a={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`BIN`,test:/^[-+]?0b[0-1_]+$/,resolve:(e,t,n)=>r(e,2,2,n),stringify:e=>i(e,2,`0b`)},o={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`OCT`,test:/^[-+]?0[0-7_]+$/,resolve:(e,t,n)=>r(e,1,8,n),stringify:e=>i(e,8,`0`)},s={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,test:/^[-+]?[0-9][0-9_]*$/,resolve:(e,t,n)=>r(e,0,10,n),stringify:t.stringifyNumber},c={identify:n,default:!0,tag:`tag:yaml.org,2002:int`,format:`HEX`,test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(e,t,n)=>r(e,2,16,n),stringify:e=>i(e,16,`0x`)};e.int=s,e.intBin=a,e.intHex=c,e.intOct=o})),er=/* @__PURE__ */ j((e=>{var t=U(),n=Pn(),r=In(),i=class e extends r.YAMLMap{constructor(t){super(t),this.tag=e.tag}add(e){let i;i=t.isPair(e)?e:e&&typeof e==`object`&&`key`in e&&`value`in e&&e.value===null?new n.Pair(e.key,null):new n.Pair(e,null),r.findPair(this.items,i.key)||this.items.push(i)}get(e,n){let i=r.findPair(this.items,e);return!n&&t.isPair(i)?t.isScalar(i.key)?i.key.value:i.key:i}set(e,t){if(typeof t!=`boolean`)throw Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);let i=r.findPair(this.items,e);i&&!t?this.items.splice(this.items.indexOf(i),1):!i&&t&&this.items.push(new n.Pair(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,n){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,n);throw Error(`Set items must all have null values`)}static from(e,t,r){let{replacer:i}=r,a=new this(e);if(t&&Symbol.iterator in Object(t))for(let e of t)typeof i==`function`&&(e=i.call(t,e,e)),a.items.push(n.createPair(e,null,r));return a}};i.tag=`tag:yaml.org,2002:set`;let a={collection:`map`,identify:e=>e instanceof Set,nodeClass:i,default:!1,tag:`tag:yaml.org,2002:set`,createNode:(e,t,n)=>i.from(e,t,n),resolve(e,n){if(t.isMap(e)){if(e.hasAllNullValues(!0))return Object.assign(new i,e);n(`Set items must all have null values`)}else n(`Expected a mapping for this tag`);return e}};e.YAMLSet=i,e.set=a})),tr=/* @__PURE__ */ j((e=>{var t=Un();function n(e,t){let n=e[0],r=n===`-`||n===`+`?e.substring(1):e,i=e=>t?BigInt(e):Number(e),a=r.replace(/_/g,``).split(`:`).reduce((e,t)=>e*i(60)+i(t),i(0));return n===`-`?i(-1)*a:a}function r(e){let{value:n}=e,r=e=>e;if(typeof n==`bigint`)r=e=>BigInt(e);else if(isNaN(n)||!isFinite(n))return t.stringifyNumber(e);let i=``;n<0&&(i=`-`,n*=r(-1));let a=r(60),o=[n%a];return n<60?o.unshift(0):(n=(n-o[0])/a,o.unshift(n%a),n>=60&&(n=(n-o[0])/a,o.unshift(n))),i+o.map(e=>String(e).padStart(2,`0`)).join(`:`).replace(/000000\d*$/,``)}let i={identify:e=>typeof e==`bigint`||Number.isInteger(e),default:!0,tag:`tag:yaml.org,2002:int`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(e,t,{intAsBigInt:r})=>n(e,r),stringify:r},a={identify:e=>typeof e==`number`,default:!0,tag:`tag:yaml.org,2002:float`,format:`TIME`,test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:e=>n(e,!1),stringify:r},o={identify:e=>e instanceof Date,default:!0,tag:`tag:yaml.org,2002:timestamp`,test:RegExp(`^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$`),resolve(e){let t=e.match(o.test);if(!t)throw Error(`!!timestamp expects a date, starting with yyyy-mm-dd`);let[,r,i,a,s,c,l]=t.map(Number),u=t[7]?Number((t[7]+`00`).substr(1,3)):0,d=Date.UTC(r,i-1,a,s||0,c||0,l||0,u),f=t[8];if(f&&f!==`Z`){let e=n(f,!1);Math.abs(e)<30&&(e*=60),d-=6e4*e}return new Date(d)},stringify:({value:e})=>e?.toISOString().replace(/(T00:00:00)?\.000Z$/,``)??``};e.floatTime=a,e.intTime=i,e.timestamp=o})),nr=/* @__PURE__ */ j((e=>{var t=Ln(),n=Vn(),r=zn(),i=Bn(),a=Jn(),o=Zn(),s=Qn(),c=$n(),l=Mn(),u=Xn(),d=Yn(),f=er(),p=tr();e.schema=[t.map,r.seq,i.string,n.nullTag,o.trueTag,o.falseTag,c.intBin,c.intOct,c.int,c.intHex,s.floatNaN,s.floatExp,s.float,a.binary,l.merge,u.omap,d.pairs,f.set,p.intTime,p.floatTime,p.timestamp]})),rr=/* @__PURE__ */ j((e=>{var t=Ln(),n=Vn(),r=zn(),i=Bn(),a=Hn(),o=Wn(),s=Gn(),c=Kn(),l=qn(),u=Jn(),d=Mn(),f=Xn(),p=Yn(),m=nr(),h=er(),g=tr();let _=/* @__PURE__ */ new Map([[`core`,c.schema],[`failsafe`,[t.map,r.seq,i.string]],[`json`,l.schema],[`yaml11`,m.schema],[`yaml-1.1`,m.schema]]),v={binary:u.binary,bool:a.boolTag,float:o.float,floatExp:o.floatExp,floatNaN:o.floatNaN,floatTime:g.floatTime,int:s.int,intHex:s.intHex,intOct:s.intOct,intTime:g.intTime,map:t.map,merge:d.merge,null:n.nullTag,omap:f.omap,pairs:p.pairs,seq:r.seq,set:h.set,timestamp:g.timestamp},y={"tag:yaml.org,2002:binary":u.binary,"tag:yaml.org,2002:merge":d.merge,"tag:yaml.org,2002:omap":f.omap,"tag:yaml.org,2002:pairs":p.pairs,"tag:yaml.org,2002:set":h.set,"tag:yaml.org,2002:timestamp":g.timestamp};function b(e,t,n){let r=_.get(t);if(r&&!e)return n&&!r.includes(d.merge)?r.concat(d.merge):r.slice();let i=r;if(!i){if(Array.isArray(e))i=[];else{let e=Array.from(_.keys()).filter(e=>e!==`yaml11`).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown schema "${t}"; use one of ${e} or define customTags array`)}}if(Array.isArray(e))for(let t of e)i=i.concat(t);else typeof e==`function`&&(i=e(i.slice()));return n&&(i=i.concat(d.merge)),i.reduce((e,t)=>{let n=typeof t==`string`?v[t]:t;if(!n){let e=JSON.stringify(t),n=Object.keys(v).map(e=>JSON.stringify(e)).join(`, `);throw Error(`Unknown custom tag ${e}; use one of ${n}`)}return e.includes(n)||e.push(n),e},[])}e.coreKnownTags=y,e.getTags=b})),ir=/* @__PURE__ */ j((e=>{var t=U(),n=Ln(),r=zn(),i=Bn(),a=rr();let o=(e,t)=>e.key<t.key?-1:+(e.key>t.key);e.Schema=class e{constructor({compat:e,customTags:s,merge:c,resolveKnownTags:l,schema:u,sortMapEntries:d,toStringDefaults:f}){this.compat=Array.isArray(e)?a.getTags(e,`compat`):e?a.getTags(null,e):null,this.name=typeof u==`string`&&u||`core`,this.knownTags=l?a.coreKnownTags:{},this.tags=a.getTags(s,this.name,c),this.toStringOptions=f??null,Object.defineProperty(this,t.MAP,{value:n.map}),Object.defineProperty(this,t.SCALAR,{value:i.string}),Object.defineProperty(this,t.SEQ,{value:r.seq}),this.sortMapEntries=typeof d==`function`?d:d===!0?o:null}clone(){let t=Object.create(e.prototype,Object.getOwnPropertyDescriptors(this));return t.tags=this.tags.slice(),t}}})),ar=/* @__PURE__ */ j((e=>{var t=U(),n=kn(),r=En();function i(e,i){let a=[],o=i.directives===!0;if(i.directives!==!1&&e.directives){let t=e.directives.toString(e);t?(a.push(t),o=!0):e.directives.docStart&&(o=!0)}o&&a.push(`---`);let s=n.createStringifyContext(e,i),{commentString:c}=s.options;if(e.commentBefore){a.length!==1&&a.unshift(``);let t=c(e.commentBefore);a.unshift(r.indentComment(t,``))}let l=!1,u=null;if(e.contents){if(t.isNode(e.contents)){if(e.contents.spaceBefore&&o&&a.push(``),e.contents.commentBefore){let t=c(e.contents.commentBefore);a.push(r.indentComment(t,``))}s.forceBlockIndent=!!e.comment,u=e.contents.comment}let i=u?void 0:()=>l=!0,d=n.stringify(e.contents,s,()=>u=null,i);u&&(d+=r.lineComment(d,``,c(u))),(d[0]===`|`||d[0]===`>`)&&a[a.length-1]===`---`?a[a.length-1]=`--- ${d}`:a.push(d)}else a.push(n.stringify(e.contents,s));if(e.directives?.docEnd){if(e.comment){let t=c(e.comment);t.includes(`
107
107
  `)?(a.push(`...`),a.push(r.indentComment(t,``))):a.push(`... ${t}`)}else a.push(`...`)}else{let t=e.comment;t&&l&&(t=t.replace(/^\n+/,``)),t&&((!l||u)&&a[a.length-1]!==``&&a.push(``),a.push(r.indentComment(c(t),``)))}return a.join(`
108
108
  `)+`
109
- `}e.stringifyDocument=i})),tr=/* @__PURE__ */ A((e=>{var t=xn(),n=Cn(),r=H(),i=W(),a=yn(),o=$n(),s=er(),c=_n(),l=vn(),u=Sn(),d=gn(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents!=null&&(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:/* @__PURE__ */ new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),nr=/* @__PURE__ */ A((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
110
- `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),rr=/* @__PURE__ */ A((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:b&&n===`seq-item-ind`||(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),ir=/* @__PURE__ */ A((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
111
- `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),ar=/* @__PURE__ */ A((e=>{var t=ir();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),or=/* @__PURE__ */ A((e=>{var t=H();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),sr=/* @__PURE__ */ A((e=>{var t=W(),n=G(),r=rr(),i=ir(),a=ar(),o=or();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new((f?.nodeClass)??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
109
+ `}e.stringifyDocument=i})),or=/* @__PURE__ */ j((e=>{var t=Cn(),n=Tn(),r=U(),i=Pn(),a=xn(),o=ir(),s=ar(),c=yn(),l=bn(),u=wn(),d=vn(),f=class e{constructor(e,t,n){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,r.NODE_TYPE,{value:r.DOC});let i=null;typeof t==`function`||Array.isArray(t)?i=t:n===void 0&&t&&(n=t,t=void 0);let a=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:`warn`,prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:`1.2`},n);this.options=a;let{version:o}=a;n?._directives?(this.directives=n._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new d.Directives({version:o}),this.setSchema(o,n),this.contents=e===void 0?null:this.createNode(e,i,n)}clone(){let t=Object.create(e.prototype,{[r.NODE_TYPE]:{value:r.DOC}});return t.commentBefore=this.commentBefore,t.comment=this.comment,t.errors=this.errors.slice(),t.warnings=this.warnings.slice(),t.options=Object.assign({},this.options),this.directives&&(t.directives=this.directives.clone()),t.schema=this.schema.clone(),t.contents=r.isNode(this.contents)?this.contents.clone(t.schema):this.contents,this.range&&(t.range=this.range.slice()),t}add(e){p(this.contents)&&this.contents.add(e)}addIn(e,t){p(this.contents)&&this.contents.addIn(e,t)}createAlias(e,n){if(!e.anchor){let t=c.anchorNames(this);e.anchor=!n||t.has(n)?c.findNewAnchor(n||`a`,t):n}return new t.Alias(e.anchor)}createNode(e,t,n){let i;if(typeof t==`function`)e=t.call({"":e},``,e),i=t;else if(Array.isArray(t)){let e=t.filter(e=>typeof e==`number`||e instanceof String||e instanceof Number).map(String);e.length>0&&(t=t.concat(e)),i=t}else n===void 0&&t&&(n=t,t=void 0);let{aliasDuplicateObjects:a,anchorPrefix:o,flow:s,keepUndefined:l,onTagObj:d,tag:f}=n??{},{onAnchor:p,setAnchors:m,sourceObjects:h}=c.createNodeAnchors(this,o||`a`),g={aliasDuplicateObjects:a??!0,keepUndefined:l??!1,onAnchor:p,onTagObj:d,replacer:i,schema:this.schema,sourceObjects:h},_=u.createNode(e,f,g);return s&&r.isCollection(_)&&(_.flow=!0),m(),_}createPair(e,t,n={}){let r=this.createNode(e,null,n),a=this.createNode(t,null,n);return new i.Pair(r,a)}delete(e){return p(this.contents)?this.contents.delete(e):!1}deleteIn(e){return n.isEmptyPath(e)?this.contents!=null&&(this.contents=null,!0):p(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return r.isCollection(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return n.isEmptyPath(e)?!t&&r.isScalar(this.contents)?this.contents.value:this.contents:r.isCollection(this.contents)?this.contents.getIn(e,t):void 0}has(e){return r.isCollection(this.contents)?this.contents.has(e):!1}hasIn(e){return n.isEmptyPath(e)?this.contents!==void 0:r.isCollection(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=n.collectionFromPath(this.schema,[e],t):p(this.contents)&&this.contents.set(e,t)}setIn(e,t){n.isEmptyPath(e)?this.contents=t:this.contents==null?this.contents=n.collectionFromPath(this.schema,Array.from(e),t):p(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e==`number`&&(e=String(e));let n;switch(e){case`1.1`:this.directives?this.directives.yaml.version=`1.1`:this.directives=new d.Directives({version:`1.1`}),n={resolveKnownTags:!1,schema:`yaml-1.1`};break;case`1.2`:case`next`:this.directives?this.directives.yaml.version=e:this.directives=new d.Directives({version:e}),n={resolveKnownTags:!0,schema:`core`};break;case null:this.directives&&delete this.directives,n=null;break;default:{let t=JSON.stringify(e);throw Error(`Expected '1.1', '1.2' or null as first argument, but found: ${t}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(n)this.schema=new o.Schema(Object.assign(n,t));else throw Error(`With a null YAML version, the { schema: Schema } option is required`)}toJS({json:e,jsonArg:t,mapAsMap:n,maxAliasCount:r,onAnchor:i,reviver:o}={}){let s={anchors:/* @__PURE__ */ new Map,doc:this,keep:!e,mapAsMap:n===!0,mapKeyWarned:!1,maxAliasCount:typeof r==`number`?r:100},c=a.toJS(this.contents,t??``,s);if(typeof i==`function`)for(let{count:e,res:t}of s.anchors.values())i(t,e);return typeof o==`function`?l.applyReviver(o,{"":c},``,c):c}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw Error(`Document with errors cannot be stringified`);if(`indent`in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){let t=JSON.stringify(e.indent);throw Error(`"indent" option must be a positive integer, not ${t}`)}return s.stringifyDocument(this,e)}};function p(e){if(r.isCollection(e))return!0;throw Error(`Expected a YAML collection as document contents`)}e.Document=f})),sr=/* @__PURE__ */ j((e=>{var t=class extends Error{constructor(e,t,n,r){super(),this.name=e,this.code=n,this.message=r,this.pos=t}},n=class extends t{constructor(e,t,n){super(`YAMLParseError`,e,t,n)}},r=class extends t{constructor(e,t,n){super(`YAMLWarning`,e,t,n)}};e.YAMLError=t,e.YAMLParseError=n,e.YAMLWarning=r,e.prettifyError=(e,t)=>n=>{if(n.pos[0]===-1)return;n.linePos=n.pos.map(e=>t.linePos(e));let{line:r,col:i}=n.linePos[0];n.message+=` at line ${r}, column ${i}`;let a=i-1,o=e.substring(t.lineStarts[r-1],t.lineStarts[r]).replace(/[\n\r]+$/,``);if(a>=60&&o.length>80){let e=Math.min(a-39,o.length-79);o=`…`+o.substring(e),a-=e-1}if(o.length>80&&(o=o.substring(0,79)+`…`),r>1&&/^ *$/.test(o.substring(0,a))){let n=e.substring(t.lineStarts[r-2],t.lineStarts[r-1]);n.length>80&&(n=n.substring(0,79)+`…
110
+ `),o=n+o}if(/[^ ]/.test(o)){let e=1,t=n.linePos[1];t?.line===r&&t.col>i&&(e=Math.max(1,Math.min(t.col-i,80-a)));let s=` `.repeat(a)+`^`.repeat(e);n.message+=`:\n\n${o}\n${s}\n`}}})),cr=/* @__PURE__ */ j((e=>{function t(e,{flow:t,indicator:n,next:r,offset:i,onError:a,parentIndent:o,startOnNewline:s}){let c=!1,l=s,u=s,d=``,f=``,p=!1,m=!1,h=null,g=null,_=null,v=null,y=null,b=null,x=null;for(let i of e)switch(m&&=(i.type!==`space`&&i.type!==`newline`&&i.type!==`comma`&&a(i.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),!1),h&&=(l&&i.type!==`comment`&&i.type!==`newline`&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),null),i.type){case`space`:!t&&(n!==`doc-start`||r?.type!==`flow-collection`)&&i.source.includes(` `)&&(h=i),u=!0;break;case`comment`:{u||a(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let e=i.source.substring(1)||` `;d?d+=f+e:d=e,f=``,l=!1;break}case`newline`:l?d?d+=i.source:b&&n===`seq-item-ind`||(c=!0):f+=i.source,l=!0,p=!0,(g||_)&&(v=i),u=!0;break;case`anchor`:g&&a(i,`MULTIPLE_ANCHORS`,`A node can have at most one anchor`),i.source.endsWith(`:`)&&a(i.offset+i.source.length-1,`BAD_ALIAS`,`Anchor ending in : is ambiguous`,!0),g=i,x??=i.offset,l=!1,u=!1,m=!0;break;case`tag`:_&&a(i,`MULTIPLE_TAGS`,`A node can have at most one tag`),_=i,x??=i.offset,l=!1,u=!1,m=!0;break;case n:(g||_)&&a(i,`BAD_PROP_ORDER`,`Anchors and tags must be after the ${i.source} indicator`),b&&a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.source} in ${t??`collection`}`),b=i,l=n===`seq-item-ind`||n===`explicit-key-ind`,u=!1;break;case`comma`:if(t){y&&a(i,`UNEXPECTED_TOKEN`,`Unexpected , in ${t}`),y=i,l=!1,u=!1;break}default:a(i,`UNEXPECTED_TOKEN`,`Unexpected ${i.type} token`),l=!1,u=!1}let S=e[e.length-1],C=S?S.offset+S.source.length:i;return m&&r&&r.type!==`space`&&r.type!==`newline`&&r.type!==`comma`&&(r.type!==`scalar`||r.source!==``)&&a(r.offset,`MISSING_CHAR`,`Tags and anchors must be separated from the next token by white space`),h&&(l&&h.indent<=o||r?.type===`block-map`||r?.type===`block-seq`)&&a(h,`TAB_AS_INDENT`,`Tabs are not allowed as indentation`),{comma:y,found:b,spaceBefore:c,comment:d,hasNewline:p,anchor:g,tag:_,newlineAfterProp:v,end:C,start:x??C}}e.resolveProps=t})),lr=/* @__PURE__ */ j((e=>{function t(e){if(!e)return null;switch(e.type){case`alias`:case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:if(e.source.includes(`
111
+ `))return!0;if(e.end){for(let t of e.end)if(t.type===`newline`)return!0}return!1;case`flow-collection`:for(let n of e.items){for(let e of n.start)if(e.type===`newline`)return!0;if(n.sep){for(let e of n.sep)if(e.type===`newline`)return!0}if(t(n.key)||t(n.value))return!0}return!1;default:return!0}}e.containsNewline=t})),ur=/* @__PURE__ */ j((e=>{var t=lr();function n(e,n,r){if(n?.type===`flow-collection`){let i=n.end[0];i.indent===e&&(i.source===`]`||i.source===`}`)&&t.containsNewline(n)&&r(i,`BAD_INDENT`,`Flow end indicator should be more indented than parent`,!0)}}e.flowIndentCheck=n})),dr=/* @__PURE__ */ j((e=>{var t=U();function n(e,n,r){let{uniqueKeys:i}=e.options;if(i===!1)return!1;let a=typeof i==`function`?i:(e,n)=>e===n||t.isScalar(e)&&t.isScalar(n)&&e.value===n.value;return n.some(e=>a(e.key,r))}e.mapIncludes=n})),fr=/* @__PURE__ */ j((e=>{var t=Pn(),n=In(),r=cr(),i=lr(),a=ur(),o=dr();let s=`All mapping items must start at the same column`;function c({composeNode:e,composeEmptyNode:c},l,u,d,f){let p=new((f?.nodeClass)??n.YAMLMap)(l.schema);l.atRoot&&=!1;let m=u.offset,h=null;for(let n of u.items){let{start:f,key:g,sep:_,value:v}=n,y=r.resolveProps(f,{indicator:`explicit-key-ind`,next:g??_?.[0],offset:m,onError:d,parentIndent:u.indent,startOnNewline:!0}),b=!y.found;if(b){if(g&&(g.type===`block-seq`?d(m,`BLOCK_AS_IMPLICIT_KEY`,`A block sequence may not be used as an implicit map key`):`indent`in g&&g.indent!==u.indent&&d(m,`BAD_INDENT`,s)),!y.anchor&&!y.tag&&!_){h=y.end,y.comment&&(p.comment?p.comment+=`
112
112
  `+y.comment:p.comment=y.comment);continue}(y.newlineAfterProp||i.containsNewline(g))&&d(g??f[f.length-1],`MULTILINE_IMPLICIT_KEY`,`Implicit keys need to be on a single line`)}else y.found?.indent!==u.indent&&d(m,`BAD_INDENT`,s);l.atKey=!0;let x=y.end,S=g?e(l,g,y,d):c(l,x,f,null,y,d);l.schema.compat&&a.flowIndentCheck(u.indent,g,d),l.atKey=!1,o.mapIncludes(l,p.items,S)&&d(x,`DUPLICATE_KEY`,`Map keys must be unique`);let C=r.resolveProps(_??[],{indicator:`map-value-ind`,next:v,offset:S.range[2],onError:d,parentIndent:u.indent,startOnNewline:!g||g.type===`block-scalar`});if(m=C.end,C.found){b&&(v?.type===`block-map`&&!C.hasNewline&&d(m,`BLOCK_AS_IMPLICIT_KEY`,`Nested mappings are not allowed in compact mappings`),l.options.strict&&y.start<C.found.offset-1024&&d(S.range,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit block mapping key`));let r=v?e(l,v,C,d):c(l,m,_,null,C,d);l.schema.compat&&a.flowIndentCheck(u.indent,v,d),m=r.range[2];let i=new t.Pair(S,r);l.options.keepSourceTokens&&(i.srcToken=n),p.items.push(i)}else{b&&d(S.range,`MISSING_CHAR`,`Implicit map keys need to be followed by map values`),C.comment&&(S.comment?S.comment+=`
113
- `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),cr=/* @__PURE__ */ A((e=>{var t=K(),n=rr(),r=ar();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new((c?.nodeClass)??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found){if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),lr=/* @__PURE__ */ A((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),ur=/* @__PURE__ */ A((e=>{var t=H(),n=W(),r=G(),i=K(),a=lr(),o=rr(),s=ir(),c=or();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new((h?.nodeClass)??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
113
+ `+C.comment:S.comment=C.comment);let e=new t.Pair(S);l.options.keepSourceTokens&&(e.srcToken=n),p.items.push(e)}}return h&&h<m&&d(h,`IMPOSSIBLE`,`Map comment with trailing content`),p.range=[u.offset,m,h??m],p}e.resolveBlockMap=c})),pr=/* @__PURE__ */ j((e=>{var t=Rn(),n=cr(),r=ur();function i({composeNode:e,composeEmptyNode:i},a,o,s,c){let l=new((c?.nodeClass)??t.YAMLSeq)(a.schema);a.atRoot&&=!1,a.atKey&&=!1;let u=o.offset,d=null;for(let{start:t,value:c}of o.items){let f=n.resolveProps(t,{indicator:`seq-item-ind`,next:c,offset:u,onError:s,parentIndent:o.indent,startOnNewline:!0});if(!f.found){if(f.anchor||f.tag||c)c?.type===`block-seq`?s(f.end,`BAD_INDENT`,`All sequence items must start at the same column`):s(u,`MISSING_CHAR`,`Sequence item without - indicator`);else{d=f.end,f.comment&&(l.comment=f.comment);continue}}let p=c?e(a,c,f,s):i(a,f.end,t,null,f,s);a.schema.compat&&r.flowIndentCheck(o.indent,c,s),u=p.range[2],l.items.push(p)}return l.range=[o.offset,u,d??u],l}e.resolveBlockSeq=i})),mr=/* @__PURE__ */ j((e=>{function t(e,t,n,r){let i=``;if(e){let a=!1,o=``;for(let s of e){let{source:e,type:c}=s;switch(c){case`space`:a=!0;break;case`comment`:{n&&!a&&r(s,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`);let t=e.substring(1)||` `;i?i+=o+t:i=t,o=``;break}case`newline`:i&&(o+=e),a=!0;break;default:r(s,`UNEXPECTED_TOKEN`,`Unexpected ${c} at node end`)}t+=e.length}}return{comment:i,offset:t}}e.resolveEnd=t})),hr=/* @__PURE__ */ j((e=>{var t=U(),n=Pn(),r=In(),i=Rn(),a=mr(),o=cr(),s=lr(),c=dr();let l=`Block collections are not allowed within flow collections`,u=e=>e&&(e.type===`block-map`||e.type===`block-seq`);function d({composeNode:e,composeEmptyNode:d},f,p,m,h){let g=p.start.source===`{`,_=g?`flow map`:`flow sequence`,v=new((h?.nodeClass)??(g?r.YAMLMap:i.YAMLSeq))(f.schema);v.flow=!0;let y=f.atRoot;y&&(f.atRoot=!1),f.atKey&&=!1;let b=p.offset+p.start.source.length;for(let i=0;i<p.items.length;++i){let a=p.items[i],{start:h,key:y,sep:x,value:S}=a,C=o.resolveProps(h,{flow:_,indicator:`explicit-key-ind`,next:y??x?.[0],offset:b,onError:m,parentIndent:p.indent,startOnNewline:!1});if(!C.found){if(!C.anchor&&!C.tag&&!x&&!S){i===0&&C.comma?m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`):i<p.items.length-1&&m(C.start,`UNEXPECTED_TOKEN`,`Unexpected empty item in ${_}`),C.comment&&(v.comment?v.comment+=`
114
114
  `+C.comment:v.comment=C.comment),b=C.end;continue}!g&&f.options.strict&&s.containsNewline(y)&&m(y,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`)}if(i===0)C.comma&&m(C.comma,`UNEXPECTED_TOKEN`,`Unexpected , in ${_}`);else if(C.comma||m(C.start,`MISSING_CHAR`,`Missing , between ${_} items`),C.comment){let e=``;loop:for(let t of h)switch(t.type){case`comma`:case`space`:break;case`comment`:e=t.source.substring(1);break loop;default:break loop}if(e){let n=v.items[v.items.length-1];t.isPair(n)&&(n=n.value??n.key),n.comment?n.comment+=`
115
115
  `+e:n.comment=e,C.comment=C.comment.substring(e.length+1)}}if(!g&&!x&&!C.found){let t=S?e(f,S,C,m):d(f,C.end,x,null,C,m);v.items.push(t),b=t.range[2],u(S)&&m(t.range,`BLOCK_IN_FLOW`,l)}else{f.atKey=!0;let t=C.end,i=y?e(f,y,C,m):d(f,t,h,null,C,m);u(y)&&m(i.range,`BLOCK_IN_FLOW`,l),f.atKey=!1;let s=o.resolveProps(x??[],{flow:_,indicator:`map-value-ind`,next:S,offset:i.range[2],onError:m,parentIndent:p.indent,startOnNewline:!1});if(s.found){if(!g&&!C.found&&f.options.strict){if(x)for(let e of x){if(e===s.found)break;if(e.type===`newline`){m(e,`MULTILINE_IMPLICIT_KEY`,`Implicit keys of flow sequence pairs need to be on a single line`);break}}C.start<s.found.offset-1024&&m(s.found,`KEY_OVER_1024_CHARS`,`The : indicator must be at most 1024 chars after the start of an implicit flow sequence key`)}}else S&&(`source`in S&&S.source?.[0]===`:`?m(S,`MISSING_CHAR`,`Missing space after : in ${_}`):m(s.start,`MISSING_CHAR`,`Missing , or : between ${_} items`));let w=S?e(f,S,s,m):s.found?d(f,s.end,x,null,s,m):null;w?u(S)&&m(w.range,`BLOCK_IN_FLOW`,l):s.comment&&(i.comment?i.comment+=`
116
116
  `+s.comment:i.comment=s.comment);let T=new n.Pair(i,w);if(f.options.keepSourceTokens&&(T.srcToken=a),g){let e=v;c.mapIncludes(f,e.items,i)&&m(t,`DUPLICATE_KEY`,`Map keys must be unique`),e.items.push(T)}else{let e=new r.YAMLMap(f.schema);e.flow=!0,e.items.push(T);let t=(w??i).range;e.range=[i.range[0],t[1],t[2]],v.items.push(e)}b=w?w.range[2]:s.end}}let x=g?`}`:`]`,[S,...C]=p.end,w=b;if(S?.source===x)w=S.offset+S.source.length;else{let e=_[0].toUpperCase()+_.substring(1),t=y?`${e} must end with a ${x}`:`${e} in block collection must be sufficiently indented and end with a ${x}`;m(b,y?`MISSING_CHAR`:`BAD_INDENT`,t),S&&S.source.length!==1&&C.unshift(S)}if(C.length>0){let e=a.resolveEnd(C,w,f.options.strict,m);e.comment&&(v.comment?v.comment+=`
117
- `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),dr=/* @__PURE__ */ A((e=>{var t=H(),n=U(),r=G(),i=K(),a=sr(),o=cr(),s=ur();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),fr=/* @__PURE__ */ A((e=>{var t=U();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
117
+ `+e.comment:v.comment=e.comment),v.range=[p.offset,w,e.offset]}else v.range=[p.offset,w,w];return v}e.resolveFlowCollection=d})),gr=/* @__PURE__ */ j((e=>{var t=U(),n=W(),r=In(),i=Rn(),a=fr(),o=pr(),s=hr();function c(e,t,n,r,i,c){let l=n.type===`block-map`?a.resolveBlockMap(e,t,n,r,c):n.type===`block-seq`?o.resolveBlockSeq(e,t,n,r,c):s.resolveFlowCollection(e,t,n,r,c),u=l.constructor;return i===`!`||i===u.tagName?(l.tag=u.tagName,l):(i&&(l.tag=i),l)}function l(e,a,o,s,l){let u=s.tag,d=u?a.directives.tagName(u.source,e=>l(u,`TAG_RESOLVE_FAILED`,e)):null;if(o.type===`block-seq`){let{anchor:e,newlineAfterProp:t}=s,n=e&&u?e.offset>u.offset?e:u:e??u;n&&(!t||t.offset<n.offset)&&l(n,`MISSING_CHAR`,`Missing newline after block sequence props`)}let f=o.type===`block-map`?`map`:o.type===`block-seq`?`seq`:o.start.source===`{`?`map`:`seq`;if(!u||!d||d===`!`||d===r.YAMLMap.tagName&&f===`map`||d===i.YAMLSeq.tagName&&f===`seq`)return c(e,a,o,l,d);let p=a.schema.tags.find(e=>e.tag===d&&e.collection===f);if(!p){let t=a.schema.knownTags[d];if(t?.collection===f)a.schema.tags.push(Object.assign({},t,{default:!1})),p=t;else return t?l(u,`BAD_COLLECTION_TYPE`,`${t.tag} used for ${f} collection, but expects ${t.collection??`scalar`}`,!0):l(u,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${d}`,!0),c(e,a,o,l,d)}let m=c(e,a,o,l,d,p),h=p.resolve?.(m,e=>l(u,`TAG_RESOLVE_FAILED`,e),a.options)??m,g=t.isNode(h)?h:new n.Scalar(h);return g.range=m.range,g.tag=d,p?.format&&(g.format=p.format),g}e.composeCollection=l})),_r=/* @__PURE__ */ j((e=>{var t=W();function n(e,n,a){let o=n.offset,s=r(n,e.options.strict,a);if(!s)return{value:``,type:null,comment:``,range:[o,o,o]};let c=s.mode===`>`?t.Scalar.BLOCK_FOLDED:t.Scalar.BLOCK_LITERAL,l=n.source?i(n.source):[],u=l.length;for(let e=l.length-1;e>=0;--e){let t=l[e][1];if(t===``||t===`\r`)u=e;else break}if(u===0){let e=s.chomp===`+`&&l.length>0?`
118
118
  `.repeat(Math.max(1,l.length-1)):``,t=o+s.length;return n.source&&(t+=n.source.length),{value:e,type:c,comment:s.comment,range:[o,t,t]}}let d=n.indent+s.indent,f=n.offset+s.length,p=0;for(let t=0;t<u;++t){let[n,r]=l[t];if(r===``||r===`\r`)s.indent===0&&n.length>d&&(d=n.length);else{n.length<d&&a(f+n.length,`MISSING_CHAR`,`Block scalars with more-indented leading empty lines must use an explicit indentation indicator`),s.indent===0&&(d=n.length),p=t,d===0&&!e.atRoot&&a(f,`BAD_INDENT`,`Block scalar values in collections must be indented`);break}f+=n.length+r.length+1}for(let e=l.length-1;e>=u;--e)l[e][0].length>d&&(u=e+1);let m=``,h=``,g=!1;for(let e=0;e<p;++e)m+=l[e][0].slice(d)+`
119
119
  `;for(let e=p;e<u;++e){let[n,r]=l[e];f+=n.length+r.length+1;let i=r[r.length-1]===`\r`;
120
120
  /* istanbul ignore if already caught in lexer */
@@ -135,7 +135,7 @@ if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be les
135
135
  /* istanbul ignore if should not happen */
136
136
  if(t[0].type!==`block-scalar-header`)return r(t[0],`IMPOSSIBLE`,`Block scalar header not found`),null;let{source:i}=t[0],a=i[0],o=0,s=``,c=-1;for(let t=1;t<i.length;++t){let n=i[t];if(!s&&(n===`-`||n===`+`))s=n;else{let r=Number(n);!o&&r?o=r:c===-1&&(c=e+t)}}c!==-1&&r(c,`UNEXPECTED_TOKEN`,`Block scalar header includes extra characters: ${i}`);let l=!1,u=``,d=i.length;for(let e=1;e<t.length;++e){let i=t[e];switch(i.type){case`space`:l=!0;case`newline`:d+=i.source.length;break;case`comment`:n&&!l&&r(i,`MISSING_CHAR`,`Comments must be separated from other tokens by white space characters`),d+=i.source.length,u=i.source.substring(1);break;case`error`:r(i,`UNEXPECTED_TOKEN`,i.message),d+=i.source.length;break;
137
137
  /* istanbul ignore next should not happen */
138
- default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),pr=/* @__PURE__ */ A((e=>{var t=U(),n=lr();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;
138
+ default:{r(i,`UNEXPECTED_TOKEN`,`Unexpected token in block scalar header: ${i.type}`);let e=i.source;e&&typeof e==`string`&&(d+=e.length)}}}return{mode:a,indent:o,chomp:s,comment:u,length:d}}function i(e){let t=e.split(/\n( *)/),n=t[0],r=n.match(/^( *)/),i=[r?.[1]?[r[1],n.slice(r[1].length)]:[``,n]];for(let e=1;e<t.length;e+=2)i.push([t[e],t[e+1]]);return i}e.resolveBlockScalar=n})),vr=/* @__PURE__ */ j((e=>{var t=W(),n=mr();function r(e,r,o){let{offset:c,type:l,source:u,end:d}=e,f,p,m=(e,t,n)=>o(c+e,t,n);switch(l){case`scalar`:f=t.Scalar.PLAIN,p=i(u,m);break;case`single-quoted-scalar`:f=t.Scalar.QUOTE_SINGLE,p=a(u,m);break;case`double-quoted-scalar`:f=t.Scalar.QUOTE_DOUBLE,p=s(u,m);break;
139
139
  /* istanbul ignore next should not happen */
140
140
  default:return o(e,`UNEXPECTED_TOKEN`,`Expected a flow scalar value, but found: ${l}`),{value:``,type:null,comment:``,range:[c,c+u.length,c+u.length]}}let h=c+u.length,g=n.resolveEnd(d,h,r,o);return{value:p,type:f,comment:g.comment,range:[c,h,g.offset]}}function i(e,t){let n=``;switch(e[0]){
141
141
  /* istanbul ignore next should not happen */
@@ -152,10 +152,10 @@ case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;c
152
152
  `);)r===`
153
153
  `&&(n+=`
154
154
  `),t+=1,r=e[t+1];return n||=` `,{fold:n,offset:t}}let l={0:`\0`,a:`\x07`,b:`\b`,e:`\x1B`,f:`\f`,n:`
155
- `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=r})),mr=/* @__PURE__ */ A((e=>{var t=H(),n=U(),r=fr(),i=pr();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r){if(t.default&&t.test)o.push(t);else return t}for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),hr=/* @__PURE__ */ A((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),gr=/* @__PURE__ */ A((e=>{var t=xn(),n=H(),r=dr(),i=mr(),a=lr(),o=hr();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),_r=/* @__PURE__ */ A((e=>{var t=tr(),n=gr(),r=lr(),i=rr();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),vr=/* @__PURE__ */ A((e=>{var t=le(`process`),n=gn(),r=tr(),i=nr(),a=H(),o=_r(),s=lr();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
155
+ `,r:`\r`,t:` `,v:`\v`,N:`…`,_:`\xA0`,L:`\u2028`,P:`\u2029`," ":` `,'"':`"`,"/":`/`,"\\":`\\`," ":` `};function u(e,t,n,r){let i=e.substr(t,n),a=i.length===n&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;try{return String.fromCodePoint(a)}catch{let i=e.substr(t-2,n+2);return r(t-2,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),i}}e.resolveFlowScalar=r})),yr=/* @__PURE__ */ j((e=>{var t=U(),n=W(),r=_r(),i=vr();function a(e,a,c,l){let{value:u,type:d,comment:f,range:p}=a.type===`block-scalar`?r.resolveBlockScalar(e,a,l):i.resolveFlowScalar(a,e.options.strict,l),m=c?e.directives.tagName(c.source,e=>l(c,`TAG_RESOLVE_FAILED`,e)):null,h;h=e.options.stringKeys&&e.atKey?e.schema[t.SCALAR]:m?o(e.schema,u,m,c,l):a.type===`scalar`?s(e,u,a,l):e.schema[t.SCALAR];let g;try{let r=h.resolve(u,e=>l(c??a,`TAG_RESOLVE_FAILED`,e),e.options);g=t.isScalar(r)?r:new n.Scalar(r)}catch(e){let t=e instanceof Error?e.message:String(e);l(c??a,`TAG_RESOLVE_FAILED`,t),g=new n.Scalar(u)}return g.range=p,g.source=u,d&&(g.type=d),m&&(g.tag=m),h.format&&(g.format=h.format),f&&(g.comment=f),g}function o(e,n,r,i,a){if(r===`!`)return e[t.SCALAR];let o=[];for(let t of e.tags)if(!t.collection&&t.tag===r){if(t.default&&t.test)o.push(t);else return t}for(let e of o)if(e.test?.test(n))return e;let s=e.knownTags[r];return s&&!s.collection?(e.tags.push(Object.assign({},s,{default:!1,test:void 0})),s):(a(i,`TAG_RESOLVE_FAILED`,`Unresolved tag: ${r}`,r!==`tag:yaml.org,2002:str`),e[t.SCALAR])}function s({atKey:e,directives:n,schema:r},i,a,o){let s=r.tags.find(t=>(t.default===!0||e&&t.default===`key`)&&t.test?.test(i))||r[t.SCALAR];if(r.compat){let e=r.compat.find(e=>e.default&&e.test?.test(i))??r[t.SCALAR];s.tag!==e.tag&&o(a,`TAG_RESOLVE_FAILED`,`Value may be parsed as either ${n.tagString(s.tag)} or ${n.tagString(e.tag)}`,!0)}return s}e.composeScalar=a})),br=/* @__PURE__ */ j((e=>{function t(e,t,n){if(t){n??=t.length;for(let r=n-1;r>=0;--r){let n=t[r];switch(n.type){case`space`:case`comment`:case`newline`:e-=n.source.length;continue}for(n=t[++r];n?.type===`space`;)e+=n.source.length,n=t[++r];break}}return e}e.emptyScalarPosition=t})),xr=/* @__PURE__ */ j((e=>{var t=Cn(),n=U(),r=gr(),i=yr(),a=mr(),o=br();let s={composeNode:c,composeEmptyNode:l};function c(e,t,a,o){let c=e.atKey,{spaceBefore:d,comment:f,anchor:p,tag:m}=a,h,g=!0;switch(t.type){case`alias`:h=u(e,t,o),(p||m)&&o(t,`ALIAS_PROPS`,`An alias node must not specify any properties`);break;case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`block-scalar`:h=i.composeScalar(e,t,m,o),p&&(h.anchor=p.source.substring(1));break;case`block-map`:case`block-seq`:case`flow-collection`:try{h=r.composeCollection(s,e,t,a,o),p&&(h.anchor=p.source.substring(1))}catch(e){o(t,`RESOURCE_EXHAUSTION`,e instanceof Error?e.message:String(e))}break;default:o(t,`UNEXPECTED_TOKEN`,t.type===`error`?t.message:`Unsupported token (type: ${t.type})`),g=!1}return h??=l(e,t.offset,void 0,null,a,o),p&&h.anchor===``&&o(p,`BAD_ALIAS`,`Anchor cannot be an empty string`),c&&e.options.stringKeys&&(!n.isScalar(h)||typeof h.value!=`string`||h.tag&&h.tag!==`tag:yaml.org,2002:str`)&&o(m??t,`NON_STRING_KEY`,`With stringKeys, all keys must be strings`),d&&(h.spaceBefore=!0),f&&(t.type===`scalar`&&t.source===``?h.comment=f:h.commentBefore=f),e.options.keepSourceTokens&&g&&(h.srcToken=t),h}function l(e,t,n,r,{spaceBefore:a,comment:s,anchor:c,tag:l,end:u},d){let f={type:`scalar`,offset:o.emptyScalarPosition(t,n,r),indent:-1,source:``},p=i.composeScalar(e,f,l,d);return c&&(p.anchor=c.source.substring(1),p.anchor===``&&d(c,`BAD_ALIAS`,`Anchor cannot be an empty string`)),a&&(p.spaceBefore=!0),s&&(p.comment=s,p.range[2]=u),p}function u({options:e},{offset:n,source:r,end:i},o){let s=new t.Alias(r.substring(1));s.source===``&&o(n,`BAD_ALIAS`,`Alias cannot be an empty string`),s.source.endsWith(`:`)&&o(n+r.length-1,`BAD_ALIAS`,`Alias ending in : is ambiguous`,!0);let c=n+r.length,l=a.resolveEnd(i,c,e.strict,o);return s.range=[n,c,l.offset],l.comment&&(s.comment=l.comment),s}e.composeEmptyNode=l,e.composeNode=c})),Sr=/* @__PURE__ */ j((e=>{var t=or(),n=xr(),r=mr(),i=cr();function a(e,a,{offset:o,start:s,value:c,end:l},u){let d=Object.assign({_directives:a},e),f=new t.Document(void 0,d),p={atKey:!1,atRoot:!0,directives:f.directives,options:f.options,schema:f.schema},m=i.resolveProps(s,{indicator:`doc-start`,next:c??l?.[0],offset:o,onError:u,parentIndent:0,startOnNewline:!0});m.found&&(f.directives.docStart=!0,c&&(c.type===`block-map`||c.type===`block-seq`)&&!m.hasNewline&&u(m.end,`MISSING_CHAR`,`Block collection cannot start on same line with directives-end marker`)),f.contents=c?n.composeNode(p,c,m,u):n.composeEmptyNode(p,m.end,s,null,m,u);let h=f.contents.range[2],g=r.resolveEnd(l,h,!1,u);return g.comment&&(f.comment=g.comment),f.range=[o,h,g.offset],f}e.composeDoc=a})),Cr=/* @__PURE__ */ j((e=>{var t=de(`process`),n=vn(),r=or(),i=sr(),a=U(),o=Sr(),s=mr();function c(e){if(typeof e==`number`)return[e,e+1];if(Array.isArray(e))return e.length===2?e:[e[0],e[1]];let{offset:t,source:n}=e;return[t,t+(typeof n==`string`?n.length:1)]}function l(e){let t=``,n=!1,r=!1;for(let i=0;i<e.length;++i){let a=e[i];switch(a[0]){case`#`:t+=(t===``?``:r?`
156
156
 
157
157
  `:`
158
- `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),yr=/* @__PURE__ */ A((e=>{var t=fr(),n=pr(),r=nr(),i=En();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
158
+ `)+(a.substring(1)||` `),n=!0,r=!1;break;case`%`:e[i+1]?.[0]!==`#`&&(i+=1),n=!1;break;default:n||(r=!0),n=!1}}return{comment:t,afterEmptyLine:r}}e.Composer=class{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(e,t,n,r)=>{let a=c(e);r?this.warnings.push(new i.YAMLWarning(a,t,n)):this.errors.push(new i.YAMLParseError(a,t,n))},this.directives=new n.Directives({version:e.version||`1.2`}),this.options=e}decorate(e,t){let{comment:n,afterEmptyLine:r}=l(this.prelude);if(n){let i=e.contents;if(t)e.comment=e.comment?`${e.comment}\n${n}`:n;else if(r||e.directives.docStart||!i)e.commentBefore=n;else if(a.isCollection(i)&&!i.flow&&i.items.length>0){let e=i.items[0];a.isPair(e)&&(e=e.key);let t=e.commentBefore;e.commentBefore=t?`${n}\n${t}`:n}else{let e=i.commentBefore;i.commentBefore=e?`${n}\n${e}`:n}}if(t){for(let t=0;t<this.errors.length;++t)e.errors.push(this.errors[t]);for(let t=0;t<this.warnings.length;++t)e.warnings.push(this.warnings[t])}else e.errors=this.errors,e.warnings=this.warnings;this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:l(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,n=-1){for(let t of e)yield*this.next(t);yield*this.end(t,n)}*next(e){switch(t.env.LOG_STREAM&&console.dir(e,{depth:null}),e.type){case`directive`:this.directives.add(e.source,(t,n,r)=>{let i=c(e);i[0]+=t,this.onError(i,`BAD_DIRECTIVE`,n,r)}),this.prelude.push(e.source),this.atDirectives=!0;break;case`document`:{let t=o.composeDoc(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,`MISSING_CHAR`,`Missing directives-end/doc-start indicator line`),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case`byte-order-mark`:case`space`:break;case`comment`:case`newline`:this.prelude.push(e.source);break;case`error`:{let t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,n=new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,t);this.atDirectives||!this.doc?this.errors.push(n):this.doc.errors.push(n);break}case`doc-end`:{if(!this.doc){this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unexpected doc-end without preceding document`));break}this.doc.directives.docEnd=!0;let t=s.resolveEnd(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){let e=this.doc.comment;this.doc.comment=e?`${e}\n${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new i.YAMLParseError(c(e),`UNEXPECTED_TOKEN`,`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){let e=Object.assign({_directives:this.directives},this.options),n=new r.Document(void 0,e);this.atDirectives&&this.onError(t,`MISSING_CHAR`,`Missing directives-end indicator line`),n.range=[0,t,t],this.decorate(n,!1),yield n}}}})),wr=/* @__PURE__ */ j((e=>{var t=_r(),n=vr(),r=sr(),i=On();function a(e,i=!0,a){if(e){let o=(e,t,n)=>{let i=typeof e==`number`?e:Array.isArray(e)?e[0]:e.offset;if(a)a(i,t,n);else throw new r.YAMLParseError([i,i+1],t,n)};switch(e.type){case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return n.resolveFlowScalar(e,i,o);case`block-scalar`:return t.resolveBlockScalar({options:{strict:i}},e,o)}}return null}function o(e,t){let{implicitKey:n=!1,indent:r,inFlow:a=!1,offset:o=-1,type:s=`PLAIN`}=t,c=i.stringifyString({type:s,value:e},{implicitKey:n,indent:r>0?` `.repeat(r):``,inFlow:a,options:{blockQuote:!0,lineWidth:-1}}),u=t.end??[{type:`newline`,offset:-1,indent:r,source:`
159
159
  `}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
160
160
  `),t=c.substring(0,e),n=c.substring(e+1)+`
161
161
  `,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
@@ -163,11 +163,11 @@ case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;c
163
163
  `),r=t.substring(0,n),i=t.substring(n+1)+`
164
164
  `;if(e.type===`block-scalar`){let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);t.source=r,e.source=i}else{let{offset:t}=e,n=`indent`in e?e.indent:-1,a=[{type:`block-scalar-header`,offset:t,indent:n,source:r}];l(a,`end`in e?e.end:void 0)||a.push({type:`newline`,offset:-1,indent:n,source:`
165
165
  `});for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:`block-scalar`,indent:n,props:a,source:i})}}function l(e,t){if(t)for(let n of t)switch(n.type){case`space`:case`comment`:e.push(n);break;case`newline`:return e.push(n),!0}return!1}function u(e,t,n){switch(e.type){case`scalar`:case`double-quoted-scalar`:case`single-quoted-scalar`:e.type=n,e.source=t;break;case`block-scalar`:{let r=e.props.slice(1),i=t.length;e.props[0].type===`block-scalar-header`&&(i-=e.props[0].source.length);for(let e of r)e.offset+=i;delete e.props,Object.assign(e,{type:n,source:t,end:r});break}case`block-map`:case`block-seq`:{let r={type:`newline`,offset:e.offset+t.length,indent:e.indent,source:`
166
- `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),br=/* @__PURE__ */ A((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),xr=/* @__PURE__ */ A((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),Sr=/* @__PURE__ */ A((e=>{var t=yr(),n=br(),r=xr();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);
166
+ `};delete e.items,Object.assign(e,{type:n,source:t,end:[r]});break}default:{let r=`indent`in e?e.indent:-1,i=`end`in e&&Array.isArray(e.end)?e.end.filter(e=>e.type===`space`||e.type===`comment`||e.type===`newline`):[];for(let t of Object.keys(e))t!==`type`&&t!==`offset`&&delete e[t];Object.assign(e,{type:n,indent:r,source:t,end:i})}}}e.createScalarToken=o,e.resolveAsScalar=a,e.setScalarValue=s})),Tr=/* @__PURE__ */ j((e=>{let t=e=>`type`in e?n(e):r(e);function n(e){switch(e.type){case`block-scalar`:{let t=``;for(let r of e.props)t+=n(r);return t+e.source}case`block-map`:case`block-seq`:{let t=``;for(let n of e.items)t+=r(n);return t}case`flow-collection`:{let t=e.start.source;for(let n of e.items)t+=r(n);for(let n of e.end)t+=n.source;return t}case`document`:{let t=r(e);if(e.end)for(let n of e.end)t+=n.source;return t}default:{let t=e.source;if(`end`in e&&e.end)for(let n of e.end)t+=n.source;return t}}}function r({start:e,key:t,sep:r,value:i}){let a=``;for(let t of e)a+=t.source;if(t&&(a+=n(t)),r)for(let e of r)a+=e.source;return i&&(a+=n(i)),a}e.stringify=t})),Er=/* @__PURE__ */ j((e=>{let t=Symbol(`break visit`),n=Symbol(`skip children`),r=Symbol(`remove item`);function i(e,t){`type`in e&&e.type===`document`&&(e={start:e.start,value:e.value}),a(Object.freeze([]),e,t)}i.BREAK=t,i.SKIP=n,i.REMOVE=r,i.itemAtPath=(e,t)=>{let n=e;for(let[e,r]of t){let t=n?.[e];if(t&&`items`in t)n=t.items[r];else return}return n},i.parentCollection=(e,t)=>{let n=i.itemAtPath(e,t.slice(0,-1)),r=t[t.length-1][0],a=n?.[r];if(a&&`items`in a)return a;throw Error(`Parent collection not found`)};function a(e,n,i){let o=i(n,e);if(typeof o==`symbol`)return o;for(let s of[`key`,`value`]){let c=n[s];if(c&&`items`in c){for(let n=0;n<c.items.length;++n){let o=a(Object.freeze(e.concat([[s,n]])),c.items[n],i);if(typeof o==`number`)n=o-1;else if(o===t)return t;else o===r&&(c.items.splice(n,1),--n)}typeof o==`function`&&s===`key`&&(o=o(n,e))}}return typeof o==`function`?o(n,e):o}e.visit=i})),Dr=/* @__PURE__ */ j((e=>{var t=wr(),n=Tr(),r=Er();let i=e=>!!e&&`items`in e,a=e=>!!e&&(e.type===`scalar`||e.type===`single-quoted-scalar`||e.type===`double-quoted-scalar`||e.type===`block-scalar`);
167
167
  /* istanbul ignore next */
168
168
  function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:return`<FLOW_END>`;case``:return`<SCALAR>`;default:return JSON.stringify(e)}}function s(e){switch(e){case``:return`byte-order-mark`;case``:return`doc-mode`;case``:return`flow-error-end`;case``:return`scalar`;case`---`:return`doc-start`;case`...`:return`doc-end`;case``:case`
169
169
  `:case`\r
170
- `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),Cr=/* @__PURE__ */ A((e=>{var t=Sr();function n(e){switch(e){case void 0:case` `:case`
170
+ `:return`newline`;case`-`:return`seq-item-ind`;case`?`:return`explicit-key-ind`;case`:`:return`map-value-ind`;case`{`:return`flow-map-start`;case`}`:return`flow-map-end`;case`[`:return`flow-seq-start`;case`]`:return`flow-seq-end`;case`,`:return`comma`}switch(e[0]){case` `:case` `:return`space`;case`#`:return`comment`;case`%`:return`directive-line`;case`*`:return`alias`;case`&`:return`anchor`;case`!`:return`tag`;case`'`:return`single-quoted-scalar`;case`"`:return`double-quoted-scalar`;case`|`:case`>`:return`block-scalar-header`}return null}e.createScalarToken=t.createScalarToken,e.resolveAsScalar=t.resolveAsScalar,e.setScalarValue=t.setScalarValue,e.stringify=n.stringify,e.visit=r.visit,e.BOM=``,e.DOCUMENT=``,e.FLOW_END=``,e.SCALAR=``,e.isCollection=i,e.isScalar=a,e.prettyToken=o,e.tokenType=s})),Or=/* @__PURE__ */ j((e=>{var t=Dr();function n(e){switch(e){case void 0:case` `:case`
171
171
  `:case`\r`:case` `:return!0;default:return!1}}let r=/* @__PURE__ */ new Set(`0123456789ABCDEFabcdef`),i=/* @__PURE__ */ new Set(`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()`),a=/* @__PURE__ */ new Set(`,[]{}`),o=/* @__PURE__ */ new Set(` ,[]{}
172
172
  \r `),s=e=>!e||o.has(e);e.Lexer=class{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer=``,this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!=`string`)throw TypeError(`source is not a string`);this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let n=this.next??`stream`;for(;n&&(t||this.hasChars(1));)n=yield*this.parseNext(n)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===` `||t===` `;)t=this.buffer[++e];return!t||t===`#`||t===`
173
173
  `||t===`\r`&&this.buffer[e+1]===`
@@ -186,7 +186,7 @@ function o(e){switch(e){case``:return`<BOM>`;case``:return`<DOC>`;case``:re
186
186
  `,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
187
187
  `){let e=this.continueScalar(i+1);if(e===-1)break;i=Math.max(i,e-2)}}else{if(e&&a.has(o))break;r=i}return!o&&!this.atEnd?this.setNext(`plain-scalar`):(yield t.SCALAR,yield*this.pushToIndex(r+1,!0),e?`flow`:`doc`)}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){let n=this.buffer.slice(this.pos,e);return n?(yield n,this.pos+=n.length,n.length):(t&&(yield``),0)}*pushIndicators(){let e=0;loop:for(;;){switch(this.charAt(0)){case`!`:e+=yield*this.pushTag(),e+=yield*this.pushSpaces(!0);continue loop;case`&`:e+=yield*this.pushUntil(s),e+=yield*this.pushSpaces(!0);continue loop;case`-`:case`?`:case`:`:{let t=this.flowLevel>0,r=this.charAt(1);if(n(r)||t&&a.has(r)){t?this.flowKey&&=!1:this.indentNext=this.indentValue+1,e+=yield*this.pushCount(1),e+=yield*this.pushSpaces(!0);continue loop}}}break loop}return e}*pushTag(){if(this.charAt(1)===`<`){let e=this.pos+2,t=this.buffer[e];for(;!n(t)&&t!==`>`;)t=this.buffer[++e];return yield*this.pushToIndex(t===`>`?e+1:e,!1)}{let e=this.pos+1,t=this.buffer[e];for(;t;)if(i.has(t))t=this.buffer[++e];else if(t===`%`&&r.has(this.buffer[e+1])&&r.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){let e=this.buffer[this.pos];return e===`
188
188
  `?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
189
- `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),wr=/* @__PURE__ */ A((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),Tr=/* @__PURE__ */ A((e=>{var t=le(`process`),n=Sr(),r=Cr();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;
189
+ `?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,n;do n=this.buffer[++t];while(n===` `||e&&n===` `);let r=t-this.pos;return r>0&&(yield this.buffer.substr(this.pos,r),this.pos=t),r}*pushUntil(e){let t=this.pos,n=this.buffer[t];for(;!e(n);)n=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}})),kr=/* @__PURE__ */ j((e=>{e.LineCounter=class{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,n=this.lineStarts.length;for(;t<n;){let r=t+n>>1;this.lineStarts[r]<e?t=r+1:n=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};let r=this.lineStarts[t-1];return{line:t,col:e-r+1}}}}})),Ar=/* @__PURE__ */ j((e=>{var t=de(`process`),n=Dr(),r=Or();function i(e,t){for(let n=0;n<e.length;++n)if(e[n].type===t)return!0;return!1}function a(e){for(let t=0;t<e.length;++t)switch(e[t].type){case`space`:case`comment`:case`newline`:break;default:return t}return-1}function o(e){switch(e?.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:case`flow-collection`:return!0;default:return!1}}function s(e){switch(e.type){case`document`:return e.start;case`block-map`:{let t=e.items[e.items.length-1];return t.sep??t.start}case`block-seq`:return e.items[e.items.length-1].start;
190
190
  /* istanbul ignore next should not happen */
191
191
  default:return[]}}function c(e){if(e.length===0)return[];let t=e.length;loop:for(;--t>=0;)switch(e[t].type){case`doc-start`:case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:case`newline`:break loop}for(;e[++t]?.type===`space`;);return e.splice(t,e.length)}function l(e,t){if(t.length<1e5)Array.prototype.push.apply(e,t);else for(let n=0;n<t.length;++n)e.push(t[n])}function u(e){if(e.start.type===`flow-seq-start`)for(let t of e.items)t.sep&&!t.value&&!i(t.start,`explicit-key-ind`)&&!i(t.sep,`map-value-ind`)&&(t.key&&(t.value=t.key),delete t.key,o(t.value)?t.value.end?l(t.value.end,t.sep):t.value.end=t.sep:l(t.start,t.sep),delete t.sep)}e.Parser=class{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source=``,this.type=``,this.lexer=new r.Lexer,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(let n of this.lexer.lex(e,t))yield*this.next(n);t||(yield*this.end())}*next(e){if(this.source=e,t.env.LOG_TOKENS&&console.log(`|`,n.prettyToken(e)),this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}let r=n.tokenType(e);if(!r){let t=`Not a YAML token: ${e}`;yield*this.pop({type:`error`,offset:this.offset,message:t,source:e}),this.offset+=e.length}else if(r===`scalar`)this.atNewLine=!1,this.atScalar=!0,this.type=`scalar`;else{switch(this.type=r,yield*this.step(),r){case`newline`:this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case`space`:this.atNewLine&&e[0]===` `&&(this.indent+=e.length);break;case`explicit-key-ind`:case`map-value-ind`:case`seq-item-ind`:this.atNewLine&&(this.indent+=e.length);break;case`doc-mode`:case`flow-error-end`:return;default:this.atNewLine=!1}this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){let e=this.peek(1);if(this.type===`doc-end`&&e?.type!==`doc-end`){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:`doc-end`,offset:this.offset,source:this.source})}else{if(!e)return yield*this.stream();switch(e.type){case`document`:return yield*this.document(e);case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return yield*this.scalar(e);case`block-scalar`:return yield*this.blockScalar(e);case`block-map`:return yield*this.blockMap(e);case`block-seq`:return yield*this.blockSequence(e);case`flow-collection`:return yield*this.flowCollection(e);case`doc-end`:return yield*this.documentEnd(e)}
192
192
  /* istanbul ignore next should not happen */
@@ -202,15 +202,24 @@ default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.l
202
202
  /* istanbul ignore else should not happen */
203
203
  n?this.stack.push(n):(yield*this.pop(),yield*this.step())}else{let t=this.peek(2);if(t.type===`block-map`&&(this.type===`map-value-ind`&&t.indent===e.indent||this.type===`newline`&&!t.items[t.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type===`map-value-ind`&&t.type!==`flow-collection`){let n=c(s(t));u(e);let r=e.end.splice(1,e.end.length);r.push(this.sourceToken);let i={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:n,key:e,sep:r}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=i}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let e=this.source.indexOf(`
204
204
  `)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
205
- `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),Er=/* @__PURE__ */ A((e=>{var t=vr(),n=tr(),r=nr(),i=kn(),a=H(),o=wr(),s=Tr();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Dr=(/* @__PURE__ */ A((e=>{var t=vr(),n=tr(),r=$n(),i=nr(),a=xn(),o=H(),s=W(),c=U(),l=G(),u=K();Sr();var d=Cr(),f=wr(),p=Tr(),m=Er(),h=hn();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync})))();const Or=/^---[ \t]*$/;function kr(e){let t=Mr(e,0);if(!Or.test(e.slice(0,t).replace(/\r$/,``)))return`no-frontmatter`;let n=Nr(e,t),r=n;for(;n<e.length;){let t=Mr(e,n);if(Or.test(e.slice(n,t).replace(/\r$/,``)))return{yamlFrom:r,yamlTo:n,bodyFrom:Nr(e,t)};n=Nr(e,t)}return`unclosed`}function Ar(e){let t=kr(e);if(typeof t==`string`)return{ok:!1,reason:t};let n=e.slice(t.yamlFrom,t.yamlTo),r=(0,Dr.parseDocument)(n,{prettyErrors:!1}),i=e=>t.yamlFrom+e,a=r.errors.map(e=>({message:e.message.split(`
206
- `)[0],from:i(e.pos[0]),to:i(Math.max(e.pos[1],e.pos[0]+1))})),o=r.contents,s=o===null||(0,Dr.isMap)(o),c=[];if((0,Dr.isMap)(o)){let e=jr(()=>r.toJS());for(let t of o.items){if(!(0,Dr.isScalar)(t.key)||!t.key.range)continue;let[n,r]=t.key.range,a=t.value?.range;c.push({key:String(t.key.value),keyFrom:i(n),keyTo:i(r),value:e?.[String(t.key.value)]??null,valueFrom:i(a?.[0]??r),valueTo:i(a?.[1]??r)})}}return{ok:!0,block:t,yamlErrors:a,isMapping:s,entries:c,body:e.slice(t.bodyFrom)}}function jr(e){try{let t=e();return t&&typeof t==`object`?t:null}catch{return null}}function Mr(e,t){let n=e.indexOf(`
207
- `,t);return n===-1?e.length:n}function Nr(e,t){return Math.min(t+1,e.length)}const Pr=/!?\[[^\]\n]*\]\(\s*<?([^)\s>]+)>?(?:\s+"[^"]*")?\s*\)/g,Fr=/^[a-z0-9]+(-[a-z0-9]+)*$/;function Ir(e,t){let n=[],r=e.slice(t);for(let e of r.matchAll(Pr)){let r=e[1];if(/^([a-z][a-z0-9+.-]*:|#|\/\/)/i.test(r))continue;let i=Br(r.split(`#`)[0].split(`?`)[0]);if(i===``)continue;let a=t+e.index+e[0].indexOf(r);n.push({target:r,path:i,from:a,to:a+r.length})}return n}function Lr(e){if(e.startsWith(`/`))return null;let t=[`\0self`];for(let n of e.split(`/`))if(n!==``&&n!==`.`){if(n===`..`){if(t.length===0)return null;t.pop()}else t.push(n)}let n=t[0];return n&&n!==`\0self`&&Fr.test(n)?n:null}function Rr(e){let t=Ar(e),n=t.ok?t.block.bodyFrom:0,r=[];for(let t of Ir(e,n)){let e=Lr(t.path);e&&r.push({...t,name:e})}return r}function zr(e){let t=Ar(e),n=t.ok?t.entries.find(e=>e.key===`name`)?.value:null,r=Rr(e).map(e=>e.name);return[...new Set(r)].filter(e=>e!==n)}function Br(e){try{return decodeURIComponent(e)}catch{return e}}const Vr=`report-session-issue`,Hr=/skills\/([a-z0-9][a-z0-9-]*)\/SKILL\.md/g;function Ur(e,t){if(e===`Skill`){let e=t?.skill;return typeof e==`string`?[Wr(e)]:[]}return[...(typeof t==`string`?t:JSON.stringify(t??``)).matchAll(Hr)].map(e=>e[1])}const Wr=e=>e.slice(e.lastIndexOf(`:`)+1).replace(/^\//,``);function Gr(e){let t=e.events.findIndex(e=>Kr(e));if(t===-1)return e;let n=t;for(let r=t;r>=0;r--){let t=e.events[r];if(t.type===`user`&&t.message.content.some(e=>e.type===`text`)){n=r;break}}let r=e.events.slice(0,n);return{...e,events:r,loaded:[...new Set(r.flatMap(qr))]}}function Kr(e){return qr(e).includes(Vr)}function qr(e){return e.type===`system`?[]:e.message.content.flatMap(t=>t.type===`tool_use`?Ur(t.name,t.input):t.type===`text`&&e.type===`user`?[...t.text.matchAll(/<command-name>\/?([\w:-]+)<\/command-name>/g)].map(e=>Wr(e[1])):[])}const Jr=e=>e?zr(new TextDecoder().decode(e)):[];async function Yr(e,t,n,r,i){let a=[],o=[],s=new Set(n.map(e=>e.name)),c=[...n];for(;c.length>0;){let n=c.shift();for(let l of n.references){if(s.has(l))continue;s.add(l);let u=t.find(e=>e.name===l&&e.organizationId===n.organizationId);if(!u){o.push({name:l,by:n.name});continue}let d=Xr(u,r,i);a.push({skill:u,by:n.name,status:d}),d===`new`&&c.push({name:u.name,organizationId:u.organizationId,references:await Zr(e,u.id)})}}return{dependencies:a,missing:o}}function Xr(e,t,n){let r=t.skills[e.name];return r?r.id===e.id?`installed`:`conflict`:e.name===`report-session-issue`?`new`:n.some(t=>l(p(t,e.name)))?`conflict`:`new`}async function Zr(e,t){let n=(await e.getSkill(t)).files.find(e=>e.path===un);return n?Jr(await e.getBlob(t,n.sha256)):[]}async function Qr(e,t,n){let{dependencies:r,missing:i}=e;for(let{name:e,by:t}of i)I.warn(`${t} links to ${e}, which isn't in its organization.`);let a=r.filter(e=>e.status===`new`),o=r.filter(e=>e.status===`conflict`);if(a.length===0&&o.length===0)return[];let s=/* @__PURE__ */ new Map;for(let e of[...a,...o])s.set(e.by,[...s.get(e.by)??[],e.skill.name]);I.info([...s].map(([e,t])=>`${e} uses ${t.length===1?`another skill`:`${t.length} other skills`}: ${t.join(`, `)}`).join(`
208
- `));let c=n&&R(),l=[];a.length>0&&(!c||z(await yt({message:`Install ${a.length===1?a[0].skill.name:`these ${a.length} skills`} too?`,initialValue:!0})))&&l.push(...a.map(e=>e.skill));let u=t.map(B).join(`, `);for(let{skill:e}of o){let t=`There's already a different skill named ${e.name} in ${u}.`;c?z(await yt({message:`${t} Replace it with the one from agent kit?`,initialValue:!1}))&&l.push(e):I.warn(`${t} Left it alone; \`a-kit add ${e.name}\` replaces it.`)}return l}const $r=e=>ie(`sha256`).update(e).digest(`hex`);async function ei(e,t,n,r=`latest`){let i=await e.getSkill(t,r);if(!/^[a-z0-9-]+$/.test(i.name))throw Error(`"${i.name}" isn't a valid skill name.`);let a=[];for(let t of i.files){let n=fn(t.path);if(n)throw Error(`${i.name}: ${t.path}: ${n}`);let r=await e.getBlob(i.id,t.sha256);if($r(r)!==t.sha256)throw Error(`${i.name}: ${t.path} didn't download intact.`);a.push({path:t.path,bytes:r})}for(let e of n){let t=p(e,i.name);await O(t,{recursive:!0,force:!0});for(let e of a){let n=p(t,e.path);await T(f(n),{recursive:!0}),await k(n,e.bytes)}}let o=a.find(e=>e.path===un)?.bytes;return{...i,references:Jr(o)}}function q(){return(process.env.AGENT_KIT_API_URL??`https://api-dev.agent-kit.fausanchez.com`??`http://localhost:8787`).replace(/\/+$/,``)}function J(){return process.env.AGENT_KIT_CONFIG_DIR?process.env.AGENT_KIT_CONFIG_DIR:process.platform===`win32`&&process.env.APPDATA?p(process.env.APPDATA,`agent-kit`):p(process.env.XDG_CONFIG_HOME??p(v(),`.config`),`agent-kit`)}const ti=()=>p(J(),`credentials.json`);async function ni(){try{return JSON.parse(await D(ti(),`utf8`))}catch{return{}}}async function ri(){return(await ni())[q()]??null}async function ii(e){let t=await ni();e?t[q()]=e:delete t[q()];let n=ti();await T(f(n),{recursive:!0,mode:448}),await k(n,JSON.stringify(t,null,2)+`
209
- `,{mode:384}),await C(n,384)}const ai=()=>p(J(),`settings.json`);async function oi(){try{return JSON.parse(await D(ai(),`utf8`))}catch{return{}}}async function si(e){let t={...await oi(),...e};await T(J(),{recursive:!0,mode:448}),await k(ai(),JSON.stringify(t,null,2)+`
210
- `)}function ci(e=process.env){let t=e=>e!==void 0&&[`0`,`false`,`off`,`no`].includes(e.toLowerCase());return(e=>e!==void 0&&e!==``&&!t(e))(e.DO_NOT_TRACK)||t(e.AGENT_KIT_TELEMETRY)}const li=(e,t,n)=>({id:e.id,version:e.version,agents:t,...n!==`latest`&&{channel:n}}),ui=e=>Mt(e.channel)?e.channel:`latest`,Y=(e,t=process.cwd())=>e===`global`?p(J(),`global.lock.json`):p(t,`agent-kit.lock.json`);async function X(e){try{let t=JSON.parse(await D(e,`utf8`));return{version:1,kits:t.kits??{},skills:t.skills??{}}}catch{return{version:1,kits:{},skills:{}}}}async function di(e,t){let n=e=>Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t))),r=Object.fromEntries(Object.entries(n(t.skills)).map(([e,t])=>{let{kits:n,...r}=t;return[e,n?.length?{...r,kits:[...n].sort()}:r]})),i=Object.keys(t.kits).length>0?n(t.kits):void 0;await T(f(e),{recursive:!0}),await k(e,JSON.stringify({version:t.version,kits:i,skills:r},null,2)+`
211
- `)}const fi=(e,t)=>Object.entries(e.skills).find(([,e])=>e.id===t)?.[0];var pi=class extends Error{name;folder;paths;constructor(e,t,n){super(`${B(t)} has edits that aren't in agent kit (${cn(n)}). Push them with \`a-kit push ${e}\`, or pass --force to throw them away.`),this.name=e,this.folder=t,this.paths=n}};async function mi(e,t){for(let n of e){if(!l(n))continue;let{paths:e}=rn(await nn(n),t);if(e.length>0)return{folder:n,paths:e}}return null}async function hi(e,t,n,r){let i=await e.getVersion(n.id,n.version).catch(()=>null);return i?mi(r.map(e=>p(e,t)),i.files):null}async function gi(e,t,n){return!t||t.id!==n.id||t.version===n.version?n.files:(await e.getVersion(t.id,t.version)).files}async function _i(e,t,n,{force:r}){let i=await e.getSkill(n),{entry:a}=t,o=await mi(t.existing,await gi(e,a,i));if(o&&!r)throw new pi(t.name,o.folder,o.paths);let s=a?.id===n?a.version:null,c=t.folders.every(e=>l(e));if(!o&&c&&s===i.version)return{kind:`unchanged`,skill:i,from:s};let u=t.folders.map(e=>f(e)),d=await ei(e,n,u),m=await X(t.lockFile);if(d.name!==t.name){for(let e of u)await O(p(e,t.name),{recursive:!0,force:!0});delete m.skills[t.name]}return m.skills[d.name]={id:d.id,version:d.version,agents:t.agents.map(e=>e.id)},await di(t.lockFile,m),{kind:`pulled`,skill:d,from:s}}function vi(e,t,n){let r={install:[],tag:[],untag:[],remove:[],clashes:[]};for(let i of n){let n=fi(e,i.id);if(n===void 0){e.skills[i.name]?r.clashes.push(i):r.install.push(i);continue}let a=e.skills[n].kits;a&&!a.includes(t)&&r.tag.push(n)}let i=new Set(n.map(e=>e.id));for(let[n,a]of Object.entries(e.skills))a.kits?.includes(t)&&!i.has(a.id)&&(a.kits.length>1?r.untag.push(n):r.remove.push(n));return r}function yi(e,t,n){if(t===n)return;let r=e.kits[t];if(r){delete e.kits[t],e.kits[n]=r;for(let r of Object.values(e.skills))r.kits?.includes(t)&&(r.kits=[...new Set(r.kits.map(e=>e===t?n:e))])}}async function bi(e,t,n,r){t.kits[n.name]={id:n.id,agents:r.agents};let i=vi(t,n.name,n.skills),a={installed:[],removed:[],skipped:[],kept:[]};for(let e of i.clashes)I.warn(`${e.name} from kit/${n.name} wasn't installed: another skill named ${e.name} already is.`),a.skipped.push(e.name);for(let e of i.tag){let r=t.skills[e];r.kits=[...r.kits??[],n.name]}for(let e of i.untag){let r=t.skills[e];r.kits=r.kits.filter(e=>e!==n.name)}let o=new Set(i.install.map(e=>e.id)),s=r.reinstall?n.skills.filter(e=>!i.clashes.some(t=>t.id===e.id)):i.install,c=Et();for(let i of s){let s=fi(t,i.id),l=s?t.skills[s]:void 0,u=l&&!l.kits?l.agents:r.agents;c.start(`Installing ${i.name}`);let d;try{d=await ei(e,i.id,r.dirsOf(u))}catch(e){throw c.error(`${i.name} failed`),e}c.stop(`${d.name} v${d.version}`),s&&s!==d.name&&delete t.skills[s],t.skills[d.name]={id:d.id,version:d.version,agents:u,kits:o.has(i.id)?[n.name]:l?.kits&&[.../* @__PURE__ */ new Set([...l.kits,n.name])]},o.has(i.id)&&a.installed.push(d.name)}for(let o of i.remove){let i=t.skills[o],s=await hi(e,o,i,r.dirsOf(i.agents));s?(I.warn(`${o} was taken out of kit/${n.name}, but it has edits that aren't in agent kit (${cn(s.paths)}); left it. Push them with \`a-kit push ${o}\`, or delete its folder.`),a.kept.push(o)):(await xi(t,o,r.dirsOf),a.removed.push(o))}return a}async function xi(e,t,n){let r=e.skills[t];if(/^[a-z0-9-]+$/.test(t))for(let e of n(r.agents))await O(p(e,t),{recursive:!0,force:!0});delete e.skills[t]}var Z=class extends Error{status;code;diagnostics;constructor(e,t,n,r=[]){super(n),this.status=e,this.code=t,this.diagnostics=r}};function Si(e,t,n=fetch){async function r(r,i={}){let a;try{a=await n(`${e}${r}`,{...i,headers:{"User-Agent":`a-kit/${Ft}`,...i.body?{"Content-Type":`application/json`}:{},...t?{Authorization:`Bearer ${t}`}:{},...i.headers}})}catch{throw new Z(0,`NETWORK`,`Couldn't reach ${e}.`)}if(!a.ok){let e=await a.json().catch(()=>null);throw a.status===401?new Z(401,`UNAUTHORIZED`,"You're not logged in. Run `a-kit login`."):new Z(a.status,e?.code??`HTTP_ERROR`,e?.message??`${i.method??`GET`} ${r} failed (${a.status})`,e?.diagnostics??[])}return a}let i=async(e,t)=>await(await r(e,t)).json();return{me:()=>i(`/me`),logout:()=>r(`/auth/logout`,{method:`POST`}),startLogin:()=>i(`/auth/cli`,{method:`POST`}),pollLogin:e=>i(`/auth/cli/token`,{method:`POST`,body:JSON.stringify({deviceCode:e})}),listSkills:async()=>{let[e,t]=await Promise.all([i(`/skills`),i(`/orgs`)]),n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>({...e,organizationName:n.get(e.organizationId)??``,showOrganization:t.length>1}))},listKits:async()=>{let[e,t]=await Promise.all([i(`/kits`),i(`/orgs`)]),n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>({...e,organizationName:n.get(e.organizationId)??``,showOrganization:t.length>1}))},getKit:e=>i(`/kits/${e}`),listOrganizations:()=>i(`/orgs`),reportActivations:(e,t)=>i(`/activations`,{method:`POST`,body:JSON.stringify({activations:e}),signal:t}),search:e=>i(`/search?q=${encodeURIComponent(e)}`),getSkill:(e,t=`latest`)=>i(`/skills/${e}${t===`latest`?``:`?channel=${t}`}`),getVersion:(e,t)=>i(`/skills/${e}/versions/${t}`),saveSkill:(e,t)=>i(`/skills/${e}`,{method:`PUT`,body:JSON.stringify(t)}),createSkill:(e,t)=>i(`/orgs/${e}/skills`,{method:`POST`,body:JSON.stringify(t)}),createReport:(e,t)=>i(`/orgs/${e}/reports`,{method:`POST`,body:JSON.stringify(t)}),getBlob:async(e,t)=>new Uint8Array(await(await r(`/skills/${e}/blobs/${t}`)).arrayBuffer())}}function Ci(e){let[t,n]=process.platform===`darwin`?[`open`,[e]]:process.platform===`win32`?[`cmd`,[`/c`,`start`,``,e.replace(/&/g,`^&`)]]:[`xdg-open`,[e]];try{let e=se(t,n,{stdio:`ignore`,detached:!0});e.on(`error`,()=>{}),e.unref()}catch{}}const wi=e=>new Promise(t=>setTimeout(t,e));async function Ti(){let e=await Si(q()).startLogin();I.step(`Your code: ${e.userCode}\nApprove it in your browser: ${e.verificationUrl}`),Ci(e.verificationUrl);let t=Et();t.start(`Waiting for you to approve it`);let n=Si(q()),r=Date.now()+e.expiresIn*1e3;for(;Date.now()<r;){await wi(e.interval*1e3);let r;try{r=await n.pollLogin(e.deviceCode)}catch(e){if(e instanceof Z&&e.status===410)break;if(e instanceof Z&&e.code===`NETWORK`)continue;throw t.error(`Login failed`),e}if(r.status===`approved`){let n={token:r.token,user:r.user,webUrl:new URL(e.verificationUrl).origin};return await ii(n),t.stop(`Logged in as ${r.user.email}`),n}}throw t.error(`The code expired`),Error(`The login expired before it was approved. Run it again.`)}async function Ei(){let e=await ri();if(!e)return null;try{let t=await Si(q(),e.token).me();return{...e,user:t}}catch(e){if(e instanceof Z&&e.status===401)return await ii(null),null;throw e}}async function Q(){let e=await ri();if(!e)throw Error("You're not logged in. Run `a-kit login` first.");return{api:Si(q(),e.token),credentials:e}}const Di=(e=v())=>p(process.env.CLAUDE_CONFIG_DIR??p(e,`.claude`),`settings.json`),Oi=(e,t)=>`node "${e}" hook claude-code --api "${t}"`,ki=e=>typeof e.command==`string`&&e.command.includes(`a-kit.mjs`)&&e.command.includes(` hook claude-code`),Ai=[`telemetry`,`autoUpdate`],ji={telemetry:[{event:`PostToolUse`,matcher:`Skill`},{event:`UserPromptSubmit`}],autoUpdate:[{event:`SessionStart`,matcher:`startup|resume`}]};function Mi(e){if(!e.hooks)return e;let t={};for(let[n,r]of Object.entries(e.hooks)){if(!Array.isArray(r)){t[n]=r;continue}let e=r.map(e=>({...e,hooks:e.hooks?.filter(e=>!ki(e))})).filter((e,t)=>(e.hooks?.length??0)>0||!r[t].hooks);e.length>0&&(t[n]=e)}let{hooks:n,...r}=e;return Object.keys(t).length>0?{...r,hooks:t}:r}function Ni(e,t,n=Ai){let r=Mi(e),i={...r.hooks};for(let{event:e,matcher:r}of n.flatMap(e=>ji[e])){let n={type:`command`,command:t,async:!0,timeout:10};i[e]=[...i[e]??[],r?{matcher:r,hooks:[n]}:{hooks:[n]}]}return Object.keys(i).length>0?{...r,hooks:i}:r}const Pi=(e,t,n)=>e.hooks?.[t]?.some(e=>e.hooks?.some(e=>ki(e)&&(!n||e.command===n)))??!1;function Fi(e,t,n){return ji[t].every(({event:t})=>Pi(e,t,n))}function Ii(e,t,n){return Ai.every(r=>n.includes(r)?Fi(e,r,t):ji[r].every(({event:t})=>!Pi(e,t)))}function Li(e){if(e.hook_event_name===`PostToolUse`&&e.tool_name===`Skill`){let t=e.tool_input?.skill??e.tool_input?.command,n=typeof t==`string`?t.replace(/^\//,``):``;return Ri(n)?{name:n,trigger:`model`}:null}if(e.hook_event_name===`UserPromptSubmit`&&typeof e.prompt==`string`){let t=e.prompt.match(/^\s*\/([^\s]+)/)?.[1]??``;return Ri(t)?{name:t,trigger:`user`}:null}return null}const Ri=e=>/^[a-z0-9][a-z0-9-]*$/.test(e),zi=()=>p(J(),`bin`,`a-kit.mjs`);function Bi(){let e=ce(import.meta.url);return e.endsWith(`.mjs`)?e:null}async function Vi(){let e=await oi();return Ai.filter(t=>e[t]!==!1)}async function Hi(e=Bi(),t=Di(),n){let r=n??await Vi(),i=await Ki(t);if(i===`invalid`)return{status:`skipped`,reason:`${t} isn't valid JSON`};if(r.length===0)return Ai.some(e=>Fi(i,e))?(await qi(t,Mi(i)),{status:`installed`,added:[]}):{status:`already`};if(!e)return{status:`skipped`,reason:`not running from a build`};let a=zi();await T(f(a),{recursive:!0}),e!==a&&await w(e,a);let o=Oi(a,q());if(Ii(i,o,r))return{status:`already`};let s=r.filter(e=>!Fi(i,e));return await qi(t,Ni(i,o,r)),{status:`installed`,added:s}}async function Ui(e=Di()){let t=await Ki(e);return t===`invalid`?[]:Ai.filter(e=>Fi(t,e))}const Wi={telemetry:"Claude Code now reports to agent kit each time it loads one of these skills, so your organization sees which ones get used. Turn it off with `a-kit telemetry off`.",autoUpdate:"Claude Code now updates the skills you installed everywhere (-g) in the background when a session starts, at most once an hour. Turn it off with `a-kit auto-update off`."};async function Gi(e){if(e.includes(`claude-code`))try{let e=await Hi();if(e.status===`installed`)for(let t of e.added)I.info(Wi[t])}catch{}}async function Ki(e){let t;try{t=await D(e,`utf8`)}catch{return{}}if(!t.trim())return{};try{let e=JSON.parse(t);return typeof e==`object`&&e&&!Array.isArray(e)?e:`invalid`}catch{return`invalid`}}async function qi(e,t){await T(f(e),{recursive:!0}),await k(e,JSON.stringify(t,null,2)+`
212
- `)}const Ji=(e=`npx -y useakit@next`)=>`---
213
- name: ${Vr}
205
+ `,e)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:return this.flowScalar(this.type);case`block-scalar-header`:return{type:`block-scalar`,offset:this.offset,indent:this.indent,props:[this.sourceToken],source:``};case`flow-map-start`:case`flow-seq-start`:return{type:`flow-collection`,offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case`seq-item-ind`:return{type:`block-seq`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case`explicit-key-ind`:{this.onKeyLine=!0;let t=c(s(e));return t.push(this.sourceToken),{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,explicitKey:!0}]}}case`map-value-ind`:{this.onKeyLine=!0;let t=c(s(e));return{type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:t,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!==`comment`||this.indent<=t?!1:e.every(e=>e.type===`newline`||e.type===`space`)}*documentEnd(e){this.type!==`doc-mode`&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case`comma`:case`doc-start`:case`doc-end`:case`flow-seq-end`:case`flow-map-end`:case`map-value-ind`:yield*this.pop(),yield*this.step();break;case`newline`:this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type===`newline`&&(yield*this.pop())}}}})),jr=/* @__PURE__ */ j((e=>{var t=Cr(),n=or(),r=sr(),i=jn(),a=U(),o=kr(),s=Ar();function c(e){let t=e.prettyErrors!==!1;return{lineCounter:e.lineCounter||t&&new o.LineCounter||null,prettyErrors:t}}function l(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=Array.from(l.compose(o.parse(e)));if(a&&i)for(let t of u)t.errors.forEach(r.prettifyError(e,i)),t.warnings.forEach(r.prettifyError(e,i));return u.length>0?u:Object.assign([],{empty:!0},l.streamInfo())}function u(e,n={}){let{lineCounter:i,prettyErrors:a}=c(n),o=new s.Parser(i?.addNewLine),l=new t.Composer(n),u=null;for(let t of l.compose(o.parse(e),!0,e.length))if(!u)u=t;else if(u.options.logLevel!==`silent`){u.errors.push(new r.YAMLParseError(t.range.slice(0,2),`MULTIPLE_DOCS`,`Source contains multiple documents; please use YAML.parseAllDocuments()`));break}return a&&i&&(u.errors.forEach(r.prettifyError(e,i)),u.warnings.forEach(r.prettifyError(e,i))),u}function d(e,t,n){let r;typeof t==`function`?r=t:n===void 0&&t&&typeof t==`object`&&(n=t);let a=u(e,n);if(!a)return null;if(a.warnings.forEach(e=>i.warn(a.options.logLevel,e)),a.errors.length>0){if(a.options.logLevel!==`silent`)throw a.errors[0];a.errors=[]}return a.toJS(Object.assign({reviver:r},n))}function f(e,t,r){let i=null;if(typeof t==`function`||Array.isArray(t)?i=t:r===void 0&&t&&(r=t),typeof r==`string`&&(r=r.length),typeof r==`number`){let e=Math.round(r);r=e<1?void 0:e>8?{indent:8}:{indent:e}}if(e===void 0){let{keepUndefined:e}=r??t??{};if(!e)return}return a.isDocument(e)&&!i?e.toString(r):new n.Document(e,i,r).toString(r)}e.parse=d,e.parseAllDocuments=l,e.parseDocument=u,e.stringify=f})),Mr=(/* @__PURE__ */ j((e=>{var t=Cr(),n=or(),r=ir(),i=sr(),a=Cn(),o=U(),s=Pn(),c=W(),l=In(),u=Rn();Dr();var d=Or(),f=kr(),p=Ar(),m=jr(),h=_n();e.Composer=t.Composer,e.Document=n.Document,e.Schema=r.Schema,e.YAMLError=i.YAMLError,e.YAMLParseError=i.YAMLParseError,e.YAMLWarning=i.YAMLWarning,e.Alias=a.Alias,e.isAlias=o.isAlias,e.isCollection=o.isCollection,e.isDocument=o.isDocument,e.isMap=o.isMap,e.isNode=o.isNode,e.isPair=o.isPair,e.isScalar=o.isScalar,e.isSeq=o.isSeq,e.Pair=s.Pair,e.Scalar=c.Scalar,e.YAMLMap=l.YAMLMap,e.YAMLSeq=u.YAMLSeq,e.Lexer=d.Lexer,e.LineCounter=f.LineCounter,e.Parser=p.Parser,e.parse=m.parse,e.parseAllDocuments=m.parseAllDocuments,e.parseDocument=m.parseDocument,e.stringify=m.stringify,e.visit=h.visit,e.visitAsync=h.visitAsync})))();const Nr=/^---[ \t]*$/;function Pr(e){let t=Lr(e,0);if(!Nr.test(e.slice(0,t).replace(/\r$/,``)))return`no-frontmatter`;let n=Rr(e,t),r=n;for(;n<e.length;){let t=Lr(e,n);if(Nr.test(e.slice(n,t).replace(/\r$/,``)))return{yamlFrom:r,yamlTo:n,bodyFrom:Rr(e,t)};n=Rr(e,t)}return`unclosed`}function Fr(e){let t=Pr(e);if(typeof t==`string`)return{ok:!1,reason:t};let n=e.slice(t.yamlFrom,t.yamlTo),r=(0,Mr.parseDocument)(n,{prettyErrors:!1}),i=e=>t.yamlFrom+e,a=r.errors.map(e=>({message:e.message.split(`
206
+ `)[0],from:i(e.pos[0]),to:i(Math.max(e.pos[1],e.pos[0]+1))})),o=r.contents,s=o===null||(0,Mr.isMap)(o),c=[];if((0,Mr.isMap)(o)){let e=Ir(()=>r.toJS());for(let t of o.items){if(!(0,Mr.isScalar)(t.key)||!t.key.range)continue;let[n,r]=t.key.range,a=t.value?.range;c.push({key:String(t.key.value),keyFrom:i(n),keyTo:i(r),value:e?.[String(t.key.value)]??null,valueFrom:i(a?.[0]??r),valueTo:i(a?.[1]??r)})}}return{ok:!0,block:t,yamlErrors:a,isMapping:s,entries:c,body:e.slice(t.bodyFrom)}}function Ir(e){try{let t=e();return t&&typeof t==`object`?t:null}catch{return null}}function Lr(e,t){let n=e.indexOf(`
207
+ `,t);return n===-1?e.length:n}function Rr(e,t){return Math.min(t+1,e.length)}const zr=/!?\[[^\]\n]*\]\(\s*<?([^)\s>]+)>?(?:\s+"[^"]*")?\s*\)/g,Br=/^[a-z0-9]+(-[a-z0-9]+)*$/;function Vr(e,t){let n=[],r=e.slice(t);for(let e of r.matchAll(zr)){let r=e[1];if(/^([a-z][a-z0-9+.-]*:|#|\/\/)/i.test(r))continue;let i=Gr(r.split(`#`)[0].split(`?`)[0]);if(i===``)continue;let a=t+e.index+e[0].indexOf(r);n.push({target:r,path:i,from:a,to:a+r.length})}return n}function Hr(e){if(e.startsWith(`/`))return null;let t=[`\0self`];for(let n of e.split(`/`))if(n!==``&&n!==`.`){if(n===`..`){if(t.length===0)return null;t.pop()}else t.push(n)}let n=t[0];return n&&n!==`\0self`&&Br.test(n)?n:null}function Ur(e){let t=Fr(e),n=t.ok?t.block.bodyFrom:0,r=[];for(let t of Vr(e,n)){let e=Hr(t.path);e&&r.push({...t,name:e})}return r}function Wr(e){let t=Fr(e),n=t.ok?t.entries.find(e=>e.key===`name`)?.value:null,r=Ur(e).map(e=>e.name);return[...new Set(r)].filter(e=>e!==n)}function Gr(e){try{return decodeURIComponent(e)}catch{return e}}const Kr=`report-session-issue`,qr=/skills\/([a-z0-9][a-z0-9-]*)\/SKILL\.md/g;function Jr(e,t){if(e===`Skill`){let e=t?.skill;return typeof e==`string`?[Yr(e)]:[]}return[...(typeof t==`string`?t:JSON.stringify(t??``)).matchAll(qr)].map(e=>e[1])}const Yr=e=>e.slice(e.lastIndexOf(`:`)+1).replace(/^\//,``);function Xr(e){let t=e.events.findIndex(e=>Zr(e));if(t===-1)return e;let n=t;for(let r=t;r>=0;r--){let t=e.events[r];if(t.type===`user`&&t.message.content.some(e=>e.type===`text`)){n=r;break}}let r=e.events.slice(0,n);return{...e,events:r,loaded:[...new Set(r.flatMap(Qr))]}}function Zr(e){return Qr(e).includes(Kr)}function Qr(e){return e.type===`system`?[]:e.message.content.flatMap(t=>t.type===`tool_use`?Jr(t.name,t.input):t.type===`text`&&e.type===`user`?[...t.text.matchAll(/<command-name>\/?([\w:-]+)<\/command-name>/g)].map(e=>Yr(e[1])):[])}const $r=e=>e?Wr(new TextDecoder().decode(e)):[];async function ei(e,t,n,r,i){let a=[],o=[],s=new Set(n.map(e=>e.name)),c=[...n];for(;c.length>0;){let n=c.shift();for(let l of n.references){if(s.has(l))continue;s.add(l);let u=t.find(e=>e.name===l&&e.organizationId===n.organizationId);if(!u){o.push({name:l,by:n.name});continue}let d=ti(u,r,i);a.push({skill:u,by:n.name,status:d}),d===`new`&&c.push({name:u.name,organizationId:u.organizationId,references:await ni(e,u.id)})}}return{dependencies:a,missing:o}}function ti(e,t,n){let r=t.skills[e.name];return r?r.id===e.id?`installed`:`conflict`:e.name===`report-session-issue`?`new`:n.some(t=>l(p(t,e.name)))?`conflict`:`new`}async function ni(e,t){let n=(await e.getSkill(t)).files.find(e=>e.path===fn);return n?$r(await e.getBlob(t,n.sha256)):[]}async function ri(e,t,n){let{dependencies:r,missing:i}=e;for(let{name:e,by:t}of i)L.warn(`${t} links to ${e}, which isn't in its organization.`);let a=r.filter(e=>e.status===`new`),o=r.filter(e=>e.status===`conflict`);if(a.length===0&&o.length===0)return[];let s=/* @__PURE__ */ new Map;for(let e of[...a,...o])s.set(e.by,[...s.get(e.by)??[],e.skill.name]);L.info([...s].map(([e,t])=>`${e} uses ${t.length===1?`another skill`:`${t.length} other skills`}: ${t.join(`, `)}`).join(`
208
+ `));let c=n&&z(),l=[];a.length>0&&(!c||B(await xt({message:`Install ${a.length===1?a[0].skill.name:`these ${a.length} skills`} too?`,initialValue:!0})))&&l.push(...a.map(e=>e.skill));let u=t.map(V).join(`, `);for(let{skill:e}of o){let t=`There's already a different skill named ${e.name} in ${u}.`;c?B(await xt({message:`${t} Replace it with the one from agent kit?`,initialValue:!1}))&&l.push(e):L.warn(`${t} Left it alone; \`a-kit add ${e.name}\` replaces it.`)}return l}const ii=e=>ae(`sha256`).update(e).digest(`hex`);async function ai(e,t,n,r=`latest`){let i=await e.getSkill(t,r);if(!/^[a-z0-9-]+$/.test(i.name))throw Error(`"${i.name}" isn't a valid skill name.`);let a=[];for(let t of i.files){let n=mn(t.path);if(n)throw Error(`${i.name}: ${t.path}: ${n}`);let r=await e.getBlob(i.id,t.sha256);if(ii(r)!==t.sha256)throw Error(`${i.name}: ${t.path} didn't download intact.`);a.push({path:t.path,bytes:r})}for(let e of n){let t=p(e,i.name);await k(t,{recursive:!0,force:!0});for(let e of a){let n=p(t,e.path);await D(f(n),{recursive:!0}),await A(n,e.bytes)}}let o=a.find(e=>e.path===fn)?.bytes;return{...i,references:$r(o)}}function G(){return(process.env.AGENT_KIT_API_URL??`https://api-dev.agent-kit.fausanchez.com`??`http://localhost:8787`).replace(/\/+$/,``)}function K(){return process.env.AGENT_KIT_CONFIG_DIR?process.env.AGENT_KIT_CONFIG_DIR:process.platform===`win32`&&process.env.APPDATA?p(process.env.APPDATA,`agent-kit`):p(process.env.XDG_CONFIG_HOME??p(y(),`.config`),`agent-kit`)}const oi=()=>p(K(),`credentials.json`);async function si(){try{return JSON.parse(await O(oi(),`utf8`))}catch{return{}}}async function q(){return(await si())[G()]??null}async function ci(e){let t=await si();e?t[G()]=e:delete t[G()];let n=oi();await D(f(n),{recursive:!0,mode:448}),await A(n,JSON.stringify(t,null,2)+`
209
+ `,{mode:384}),await T(n,384)}const li=()=>p(K(),`settings.json`);async function J(){try{return JSON.parse(await O(li(),`utf8`))}catch{return{}}}async function ui(e){let t={...await J(),...e};await D(K(),{recursive:!0,mode:448}),await A(li(),JSON.stringify(t,null,2)+`
210
+ `)}function di(e=process.env){let t=e=>e!==void 0&&[`0`,`false`,`off`,`no`].includes(e.toLowerCase());return(e=>e!==void 0&&e!==``&&!t(e))(e.DO_NOT_TRACK)||t(e.AGENT_KIT_TELEMETRY)}const fi=(e,t,n)=>({id:e.id,version:e.version,agents:t,...n!==`latest`&&{channel:n}}),pi=e=>Pt(e.channel)?e.channel:`latest`,Y=(e,t=process.cwd())=>e===`global`?p(K(),`global.lock.json`):p(t,`agent-kit.lock.json`);async function X(e){try{let t=JSON.parse(await O(e,`utf8`));return{version:1,kits:t.kits??{},skills:t.skills??{}}}catch{return{version:1,kits:{},skills:{}}}}async function mi(e,t){let n=e=>Object.fromEntries(Object.entries(e).sort(([e],[t])=>e.localeCompare(t))),r=Object.fromEntries(Object.entries(n(t.skills)).map(([e,t])=>{let{kits:n,...r}=t;return[e,n?.length?{...r,kits:[...n].sort()}:r]})),i=Object.keys(t.kits).length>0?n(t.kits):void 0;await D(f(e),{recursive:!0}),await A(e,JSON.stringify({version:t.version,kits:i,skills:r},null,2)+`
211
+ `)}const hi=(e,t)=>Object.entries(e.skills).find(([,e])=>e.id===t)?.[0];var gi=class extends Error{name;folder;paths;constructor(e,t,n){super(`${V(t)} has edits that aren't in agent kit (${un(n)}). Push them with \`a-kit push ${e}\`, or pass --force to throw them away.`),this.name=e,this.folder=t,this.paths=n}};async function _i(e,t){for(let n of e){if(!l(n))continue;let{paths:e}=on(await an(n),t);if(e.length>0)return{folder:n,paths:e}}return null}async function vi(e,t,n,r){let i=await e.getVersion(n.id,n.version).catch(()=>null);return i?_i(r.map(e=>p(e,t)),i.files):null}async function yi(e,t,n){return!t||t.id!==n.id||t.version===n.version?n.files:(await e.getVersion(t.id,t.version)).files}async function bi(e,t,n,{force:r}){let i=await e.getSkill(n),{entry:a}=t,o=await _i(t.existing,await yi(e,a,i));if(o&&!r)throw new gi(t.name,o.folder,o.paths);let s=a?.id===n?a.version:null,c=t.folders.every(e=>l(e));if(!o&&c&&s===i.version)return{kind:`unchanged`,skill:i,from:s};let u=t.folders.map(e=>f(e)),d=await ai(e,n,u),m=await X(t.lockFile);if(d.name!==t.name){for(let e of u)await k(p(e,t.name),{recursive:!0,force:!0});delete m.skills[t.name]}return m.skills[d.name]={id:d.id,version:d.version,agents:t.agents.map(e=>e.id)},await mi(t.lockFile,m),{kind:`pulled`,skill:d,from:s}}function xi(e,t,n){let r={install:[],tag:[],untag:[],remove:[],clashes:[]};for(let i of n){let n=hi(e,i.id);if(n===void 0){e.skills[i.name]?r.clashes.push(i):r.install.push(i);continue}let a=e.skills[n].kits;a&&!a.includes(t)&&r.tag.push(n)}let i=new Set(n.map(e=>e.id));for(let[n,a]of Object.entries(e.skills))a.kits?.includes(t)&&!i.has(a.id)&&(a.kits.length>1?r.untag.push(n):r.remove.push(n));return r}function Si(e,t,n){if(t===n)return;let r=e.kits[t];if(r){delete e.kits[t],e.kits[n]=r;for(let r of Object.values(e.skills))r.kits?.includes(t)&&(r.kits=[...new Set(r.kits.map(e=>e===t?n:e))])}}async function Ci(e,t,n,r){t.kits[n.name]={id:n.id,agents:r.agents};let i=xi(t,n.name,n.skills),a={installed:[],removed:[],skipped:[],kept:[]};for(let e of i.clashes)L.warn(`${e.name} from kit/${n.name} wasn't installed: another skill named ${e.name} already is.`),a.skipped.push(e.name);for(let e of i.tag){let r=t.skills[e];r.kits=[...r.kits??[],n.name]}for(let e of i.untag){let r=t.skills[e];r.kits=r.kits.filter(e=>e!==n.name)}let o=new Set(i.install.map(e=>e.id)),s=r.reinstall?n.skills.filter(e=>!i.clashes.some(t=>t.id===e.id)):i.install,c=Ot();for(let i of s){let s=hi(t,i.id),l=s?t.skills[s]:void 0,u=l&&!l.kits?l.agents:r.agents;c.start(`Installing ${i.name}`);let d;try{d=await ai(e,i.id,r.dirsOf(u))}catch(e){throw c.error(`${i.name} failed`),e}c.stop(`${d.name} v${d.version}`),s&&s!==d.name&&delete t.skills[s],t.skills[d.name]={id:d.id,version:d.version,agents:u,kits:o.has(i.id)?[n.name]:l?.kits&&[.../* @__PURE__ */ new Set([...l.kits,n.name])]},o.has(i.id)&&a.installed.push(d.name)}for(let o of i.remove){let i=t.skills[o],s=await vi(e,o,i,r.dirsOf(i.agents));s?(L.warn(`${o} was taken out of kit/${n.name}, but it has edits that aren't in agent kit (${un(s.paths)}); left it. Push them with \`a-kit push ${o}\`, or delete its folder.`),a.kept.push(o)):(await wi(t,o,r.dirsOf),a.removed.push(o))}return a}async function wi(e,t,n){let r=e.skills[t];if(/^[a-z0-9-]+$/.test(t))for(let e of n(r.agents))await k(p(e,t),{recursive:!0,force:!0});delete e.skills[t]}var Z=class extends Error{status;code;diagnostics;constructor(e,t,n,r=[]){super(n),this.status=e,this.code=t,this.diagnostics=r}};function Q(e,t,n=fetch){async function r(r,i={}){let a;try{a=await n(`${e}${r}`,{...i,headers:{"User-Agent":`a-kit/${Lt}`,...i.body?{"Content-Type":`application/json`}:{},...t?{Authorization:`Bearer ${t}`}:{},...i.headers}})}catch{throw new Z(0,`NETWORK`,`Couldn't reach ${e}.`)}if(!a.ok){let e=await a.json().catch(()=>null);throw a.status===401?new Z(401,`UNAUTHORIZED`,"You're not logged in. Run `a-kit login`."):new Z(a.status,e?.code??`HTTP_ERROR`,e?.message??`${i.method??`GET`} ${r} failed (${a.status})`,e?.diagnostics??[])}return a}let i=async(e,t)=>await(await r(e,t)).json();return{me:()=>i(`/me`),logout:()=>r(`/auth/logout`,{method:`POST`}),startLogin:()=>i(`/auth/cli`,{method:`POST`}),pollLogin:e=>i(`/auth/cli/token`,{method:`POST`,body:JSON.stringify({deviceCode:e})}),listSkills:async()=>{let[e,t]=await Promise.all([i(`/skills`),i(`/orgs`)]),n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>({...e,organizationName:n.get(e.organizationId)??``,showOrganization:t.length>1}))},listKits:async()=>{let[e,t]=await Promise.all([i(`/kits`),i(`/orgs`)]),n=new Map(t.map(e=>[e.id,e.name]));return e.map(e=>({...e,organizationName:n.get(e.organizationId)??``,showOrganization:t.length>1}))},getKit:e=>i(`/kits/${e}`),listOrganizations:()=>i(`/orgs`),reportActivations:(e,t)=>i(`/activations`,{method:`POST`,body:JSON.stringify({activations:e}),signal:t}),sendHeartbeat:(e,t)=>i(`/machines/heartbeat`,{method:`POST`,body:JSON.stringify(e),signal:t}),search:e=>i(`/search?q=${encodeURIComponent(e)}`),getSkill:(e,t=`latest`)=>i(`/skills/${e}${t===`latest`?``:`?channel=${t}`}`),getVersion:(e,t)=>i(`/skills/${e}/versions/${t}`),saveSkill:(e,t)=>i(`/skills/${e}`,{method:`PUT`,body:JSON.stringify(t)}),createSkill:(e,t)=>i(`/orgs/${e}/skills`,{method:`POST`,body:JSON.stringify(t)}),createReport:(e,t)=>i(`/orgs/${e}/reports`,{method:`POST`,body:JSON.stringify(t)}),getBlob:async(e,t)=>new Uint8Array(await(await r(`/skills/${e}/blobs/${t}`)).arrayBuffer())}}function Ti(e){let[t,n]=process.platform===`darwin`?[`open`,[e]]:process.platform===`win32`?[`cmd`,[`/c`,`start`,``,e.replace(/&/g,`^&`)]]:[`xdg-open`,[e]];try{let e=le(t,n,{stdio:`ignore`,detached:!0});e.on(`error`,()=>{}),e.unref()}catch{}}const Ei=()=>p(K(),`bin`,`a-kit.mjs`);function Di(){let e=ue(import.meta.url);return e.endsWith(`.mjs`)?e:null}async function Oi(e){let t=Ei();return await D(f(t),{recursive:!0}),e!==t&&await E(e,t),t}async function ki(e,t,n,r=y()){let i=[Y(`global`)],a=Ai(n,r);a&&i.push(a);for(let n of i){let r=(await X(n)).skills[e];if(r?.agents.includes(t))return r}return null}function Ai(e,t){let n=e,{root:r}=m(e);for(;n&&n!==t;){let e=Y(`project`,n);if(l(e))return e;if(n===r)break;n=f(n)}return null}async function ji(){let e=p(K(),`machine.json`);try{let t=JSON.parse(await O(e,`utf8`));if(typeof t.id==`string`&&t.id)return t.id}catch{}let t=oe();return await D(f(e),{recursive:!0,mode:448}),await A(e,JSON.stringify({id:t},null,2)+`
212
+ `),t}async function Mi(e,t,n,r=/* @__PURE__ */ new Date){return{id:oe(),skillId:e.id,version:e.version,agent:t,machineId:await ji(),machineName:b()||null,trigger:n,occurredAt:r.toISOString()}}const Ni=()=>p(K(),`pending-activations.jsonl`);async function Pi(e,t){let n=`${Ni()}.${process.pid}`,r=[];try{await ne(Ni(),n),r=Ii(await O(n,`utf8`)),await k(n,{force:!0})}catch{}let i=[...r,t].slice(-500),a=0;for(let t=0;t<i.length;t+=100){let n=i.slice(t,t+100);try{await e(n),a+=n.length}catch(e){if(!Fi(e))continue;let n=i.slice(t);return await D(K(),{recursive:!0,mode:448}),await w(Ni(),n.map(e=>JSON.stringify(e)).join(`
213
+ `)+`
214
+ `),{sent:a,queued:n.length}}}return{sent:a,queued:0}}const Fi=e=>!(e instanceof Z)||e.status===0||e.status===429||e.status>=500;function Ii(e){return e.split(`
215
+ `).filter(Boolean).flatMap(e=>{try{return[JSON.parse(e)]}catch{return[]}})}const Li=(e,t)=>new Promise(n=>{se(e,t,{timeout:15e3},(e,t,r)=>{n({ok:!e,output:`${t}${r}`.trim()})})}),Ri=e=>new URL(e).host.toLowerCase().replace(/[^a-z0-9]+/g,`-`),zi=e=>`agent-kit-heartbeat-${Ri(e)}`,Bi=e=>`com.agent-kit.heartbeat.${Ri(e)}`;function Vi(e,t=process.platform,n=y()){if(t===`linux`){let t=p(process.env.XDG_CONFIG_HOME??p(n,`.config`),`systemd`,`user`);return[p(t,`${zi(e)}.service`),p(t,`${zi(e)}.timer`)]}return t===`darwin`?[p(n,`Library`,`LaunchAgents`,`${Bi(e)}.plist`)]:[]}function Hi(e){let t=e=>`"${e.replace(/(["\\])/g,`\\$1`)}"`,n=e.configDir?`Environment=${t(`AGENT_KIT_CONFIG_DIR=${e.configDir}`)}\n`:``;return[`[Unit]\nDescription=agent kit heartbeat (${e.api})\n\n[Service]\nType=oneshot\n${n}ExecStart=${t(e.node)} ${t(e.script)} heartbeat send --api ${t(e.api)}\n`,`[Unit]\nDescription=agent kit heartbeat (${e.api})\n\n[Timer]\nOnBootSec=1min\nOnUnitActiveSec=300s\n\n[Install]\nWantedBy=timers.target\n`]}function Ui(e){let t=e=>e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/>/g,`&gt;`),n=[e.node,e.script,`heartbeat`,`send`,`--api`,e.api],r=e.configDir?` <key>EnvironmentVariables</key>\n <dict>\n <key>AGENT_KIT_CONFIG_DIR</key>\n <string>${t(e.configDir)}</string>\n </dict>\n`:``;return`<?xml version="1.0" encoding="UTF-8"?>
216
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
217
+ <plist version="1.0">
218
+ <dict>
219
+ <key>Label</key>\n <string>${t(Bi(e.api))}</string>\n <key>ProgramArguments</key>\n <array>\n`+n.map(e=>` <string>${t(e)}</string>\n`).join(``)+` </array>\n${r} <key>StartInterval</key>\n <integer>300</integer>\n <key>RunAtLoad</key>\n <true/>\n <key>StandardOutPath</key>\n <string>/dev/null</string>\n <key>StandardErrorPath</key>\n <string>/dev/null</string>\n</dict>\n</plist>\n`}async function Wi(e){let t=e.platform??process.platform,n=e.run??Li,r=Vi(e.api,t,e.home);if(r.length===0)return{status:`skipped`,reason:`the heartbeat timer only runs on Linux (systemd) and macOS`};let i=t===`linux`?Hi(e):[Ui(e)];if((await Promise.all(r.map(e=>O(e,`utf8`).catch(()=>null)))).every((e,t)=>e===i[t]))return{status:`already`};for(let[e,t]of r.entries())await D(f(t),{recursive:!0}),await A(t,i[e]);if(t===`linux`){await n(`systemctl`,[`--user`,`daemon-reload`]);let t=await n(`systemctl`,[`--user`,`enable`,`--now`,`${zi(e.api)}.timer`]);if(!t.ok)return await Ji(r),{status:`skipped`,reason:`systemd couldn't start it${t.output?`: ${t.output}`:``}`}}else{let t=`gui/${process.getuid?.()??501}`;await n(`launchctl`,[`bootout`,`${t}/${Bi(e.api)}`]);let i=await n(`launchctl`,[`bootstrap`,t,r[0]]);if(!i.ok)return await Ji(r),{status:`skipped`,reason:`launchd couldn't load it${i.output?`: ${i.output}`:``}`}}return{status:`installed`}}async function Gi(e,{platform:t=process.platform,home:n,run:r=Li}={}){if(!await Ki(e,t,n))return!1;let i=Vi(e,t,n);return t===`linux`?(await r(`systemctl`,[`--user`,`disable`,`--now`,`${zi(e)}.timer`]),await Ji(i),await r(`systemctl`,[`--user`,`daemon-reload`])):(await r(`launchctl`,[`bootout`,`${`gui/${process.getuid?.()??501}`}/${Bi(e)}`]),await Ji(i)),!0}async function Ki(e,t=process.platform,n){let r=Vi(e,t,n);return r.length!==0&&(await Promise.all(r.map(e=>O(e).then(()=>!0,()=>!1)))).every(Boolean)}async function qi(e=Li,t=process.platform){if(t!==`linux`)return null;let n=process.env.USER;if(!n)return null;let{ok:r,output:i}=await e(`loginctl`,[`show-user`,n,`--property=Linger`]);return r&&i.trim()===`Linger=no`?"The timer stops while you're logged out of this machine. To keep it reporting, run `loginctl enable-linger`.":null}async function Ji(e){for(let t of e)await k(t,{force:!0})}async function Yi(e){let t=await X(Y(`global`));return{machineId:await ji(),hostname:b()||`unknown`,platform:x(),arch:v(),cliVersion:Lt,agents:Bt().map(e=>e.id),skills:Object.entries(t.skills).map(([e,t])=>({id:t.id,name:e,version:t.version,...t.channel&&{channel:t.channel},agents:t.agents})),every:e?300:null}}const Xi=()=>p(K(),`heartbeat.json`);async function Zi(){try{return JSON.parse(await O(Xi(),`utf8`))}catch{return null}}async function Qi(){try{if(di()||(await J()).heartbeat===!1)return!1;let e=await q();if(!e)return!1;let t=await Yi(await Ki(G())),n=!0;try{await Q(G(),e.token).sendHeartbeat(t,AbortSignal.timeout(5e3))}catch{n=!1}return await D(K(),{recursive:!0,mode:448}),await A(Xi(),JSON.stringify({sentAt:(/* @__PURE__ */ new Date()).toISOString(),ok:n})+`
220
+ `),n}catch{return!1}}async function $i(e=Di()){try{if(!e||di()||(await J()).heartbeat===!1||!await q())return;let t=await Ki(G()),n=await Oi(e);if((await Wi({node:process.execPath,script:n,api:G(),configDir:process.env.AGENT_KIT_CONFIG_DIR})).status===`installed`&&!t){L.info("This machine now reports to agent kit every 5 minutes (its name, agents and global skills), so your organization's Machines page shows it. Turn it off with `a-kit heartbeat off`.");let e=await qi();e&&L.warn(e)}await Qi()}catch{}}const ea=e=>new Promise(t=>setTimeout(t,e));async function ta(){let e=await Q(G()).startLogin();L.step(`Your code: ${e.userCode}\nApprove it in your browser: ${e.verificationUrl}`),Ti(e.verificationUrl);let t=Ot();t.start(`Waiting for you to approve it`);let n=Q(G()),r=Date.now()+e.expiresIn*1e3;for(;Date.now()<r;){await ea(e.interval*1e3);let r;try{r=await n.pollLogin(e.deviceCode)}catch(e){if(e instanceof Z&&e.status===410)break;if(e instanceof Z&&e.code===`NETWORK`)continue;throw t.error(`Login failed`),e}if(r.status===`approved`){let n={token:r.token,user:r.user,webUrl:new URL(e.verificationUrl).origin};return await ci(n),t.stop(`Logged in as ${r.user.email}`),await $i(),n}}throw t.error(`The code expired`),Error(`The login expired before it was approved. Run it again.`)}async function na(){let e=await q();if(!e)return null;try{let t=await Q(G(),e.token).me();return{...e,user:t}}catch(e){if(e instanceof Z&&e.status===401)return await ci(null),null;throw e}}async function $(){let e=await q();if(!e)throw Error("You're not logged in. Run `a-kit login` first.");return{api:Q(G(),e.token),credentials:e}}const ra=(e=y())=>p(process.env.CLAUDE_CONFIG_DIR??p(e,`.claude`),`settings.json`),ia=(e,t)=>`node "${e}" hook claude-code --api "${t}"`,aa=e=>typeof e.command==`string`&&e.command.includes(`a-kit.mjs`)&&e.command.includes(` hook claude-code`),oa=[`telemetry`,`autoUpdate`],sa={telemetry:[{event:`PostToolUse`,matcher:`Skill`},{event:`UserPromptSubmit`}],autoUpdate:[{event:`SessionStart`,matcher:`startup|resume`}]};function ca(e){if(!e.hooks)return e;let t={};for(let[n,r]of Object.entries(e.hooks)){if(!Array.isArray(r)){t[n]=r;continue}let e=r.map(e=>({...e,hooks:e.hooks?.filter(e=>!aa(e))})).filter((e,t)=>(e.hooks?.length??0)>0||!r[t].hooks);e.length>0&&(t[n]=e)}let{hooks:n,...r}=e;return Object.keys(t).length>0?{...r,hooks:t}:r}function la(e,t,n=oa){let r=ca(e),i={...r.hooks};for(let{event:e,matcher:r}of n.flatMap(e=>sa[e])){let n={type:`command`,command:t,async:!0,timeout:10};i[e]=[...i[e]??[],r?{matcher:r,hooks:[n]}:{hooks:[n]}]}return Object.keys(i).length>0?{...r,hooks:i}:r}const ua=(e,t,n)=>e.hooks?.[t]?.some(e=>e.hooks?.some(e=>aa(e)&&(!n||e.command===n)))??!1;function da(e,t,n){return sa[t].every(({event:t})=>ua(e,t,n))}function fa(e,t,n){return oa.every(r=>n.includes(r)?da(e,r,t):sa[r].every(({event:t})=>!ua(e,t)))}function pa(e){if(e.hook_event_name===`PostToolUse`&&e.tool_name===`Skill`){let t=e.tool_input?.skill??e.tool_input?.command,n=typeof t==`string`?t.replace(/^\//,``):``;return ma(n)?{name:n,trigger:`model`}:null}if(e.hook_event_name===`UserPromptSubmit`&&typeof e.prompt==`string`){let t=e.prompt.match(/^\s*\/([^\s]+)/)?.[1]??``;return ma(t)?{name:t,trigger:`user`}:null}return null}const ma=e=>/^[a-z0-9][a-z0-9-]*$/.test(e);async function ha(){let e=await J();return oa.filter(t=>e[t]!==!1)}async function ga(e=Di(),t=ra(),n){let r=n??await ha(),i=await ba(t);if(i===`invalid`)return{status:`skipped`,reason:`${t} isn't valid JSON`};if(r.length===0)return oa.some(e=>da(i,e))?(await xa(t,ca(i)),{status:`installed`,added:[]}):{status:`already`};if(!e)return{status:`skipped`,reason:`not running from a build`};let a=await Oi(e),o=ia(a,G());if(fa(i,o,r))return{status:`already`};let s=r.filter(e=>!da(i,e));return await xa(t,la(i,o,r)),{status:`installed`,added:s}}async function _a(e=ra()){let t=await ba(e);return t===`invalid`?[]:oa.filter(e=>da(t,e))}const va={telemetry:"Claude Code now reports to agent kit each time it loads one of these skills, so your organization sees which ones get used. Turn it off with `a-kit telemetry off`.",autoUpdate:"Claude Code now updates the skills you installed everywhere (-g) in the background when a session starts, at most once an hour. Turn it off with `a-kit auto-update off`."};async function ya(e){if(e.includes(`claude-code`))try{let e=await ga();if(e.status===`installed`)for(let t of e.added)L.info(va[t])}catch{}await $i()}async function ba(e){let t;try{t=await O(e,`utf8`)}catch{return{}}if(!t.trim())return{};try{let e=JSON.parse(t);return typeof e==`object`&&e&&!Array.isArray(e)?e:`invalid`}catch{return`invalid`}}async function xa(e,t){await D(f(e),{recursive:!0}),await A(e,JSON.stringify(t,null,2)+`
221
+ `)}const Sa=(e=`npx -y useakit@next`)=>`---
222
+ name: ${Kr}
214
223
  description: Reports this conversation to agent kit because it went wrong, so it can become an eval. Use when the developer says the session went badly and asks to report it ("report this", "reportá esta conversación", "mandalo a agent kit"), or wants it turned into an eval.
215
224
  ---
216
225
 
@@ -249,35 +258,32 @@ Only the conversation up to the developer's request to report it is sent; this p
249
258
  4. **Confirm.** Tell the developer in a few lines: the title, the skills it links, what was taken out, and that long tool outputs and written files are cut to 2,000 characters (\`--full-outputs\` keeps them whole). Ask before sending.
250
259
 
251
260
  5. **Send.** Run the same command with \`--yes\` instead of \`--dry-run\`, and give the developer the link it prints. If it says they're not logged in, they run \`${e} login\` first.
252
- `;async function Yi(e){for(let t of e){let e=p(t,Vr);await T(e,{recursive:!0}),await k(p(e,`SKILL.md`),Ji())}}const Xi=e=>t=>Bt(t.map(e=>zt(e)).filter(e=>e!==void 0),e);async function Zi(e,t,n,r,i=`latest`,a){let o=Bt(n,r),s=Y(r),c=await X(s);await Yi(o);try{await Qi(e,c,t,n,o,i,a)}finally{await di(s,c)}return await Gi(n.map(e=>e.id)),{dirs:o,lockFile:s}}async function Qi(e,t,n,r,i,a=`latest`,o){let s=n.find((e,t)=>n.some((n,r)=>r<t&&n.name===e.name));if(s)throw Error(`You picked more than one skill named "${s.name}"; they'd install to the same folder. Pick one.`);let c=Et(),l=[];for(let o of n){c.start(`Installing ${o.name}`);try{let n=await ei(e,o.id,i,a);l.push(n),t.skills[n.name]=li(n,r.map(e=>e.id),a),c.stop(`${n.name} v${n.version}`+(a===`latest`?``:` (${a})`)),a!==`latest`&&n.channels[a]===null&&I.warn(`${n.name} has no ${a} release yet, so you got the latest. \`a-kit update\` follows ${a} once someone sets it.`)}catch(e){throw c.error(`${o.name} failed`),e}}if(!o)return;let u=await Qr(await Yr(e,o.catalog,l,t,i),i,o.ask);u.length>0&&await Qi(e,t,u,r,i)}async function $i(e,t){wt(`agent kit`);let{api:n}=await Q(),r=!t.yes,i=Wt(e),a=i.skills.length>0||i.kits.length===0,o=a?await n.listSkills():[],s=a?await Gt(o,i.skills,r):[],c=i.kits.length>0?await Kt(await n.listKits(),i.kits,r):[];c.length>0&&t.channel!==`latest`&&I.warn(`--channel ${t.channel} applies to skills you name; kits install and follow each skill's latest version.`);let l=await Vt(t.agent,r),u=t.global?`global`:`project`,d=Bt(l,u),f=Y(u),p=await X(f);await Yi(d);try{await Qi(n,p,s,l,d,t.channel,{catalog:o,ask:r});for(let e of c){let t=await bi(n,p,e,{agents:l.map(e=>e.id),dirsOf:Xi(u),reinstall:!0}),r=e.skills.length-t.skipped.length;I.success(`kit/${e.name}: ${r} skill${r===1?``:`s`} installed`+(t.removed.length?`, ${t.removed.join(`, `)} removed (no longer in it)`:``))}}finally{await di(f,p)}await Gi(l.map(e=>e.id)),L(`Installed in ${d.map(B).join(`, `)}`)}async function ea(e){switch(e){case`on`:{await si({autoUpdate:!0});let e=await Hi();e.status===`skipped`?I.warn(`Couldn't add the Claude Code hook: ${e.reason}.`):I.success(`Auto-update is on: Claude Code updates your global skills when a session starts, at most once an hour.`);return}case`off`:await si({autoUpdate:!1}),await Hi(),I.success("Auto-update is off. Update with `a-kit update -g`, or turn it back on with `a-kit auto-update on`.");return;case void 0:case`status`:{let e=(await oi()).autoUpdate!==!1,t=(await Ui()).includes(`autoUpdate`);console.log(`Auto-update is ${e?`on`:`off`}.`),console.log(`Claude Code: ${t?`updates the global skills when a session starts`:`no hook installed`}.`),console.log("\nWhen a Claude Code session starts, the skills and kits you installed everywhere (-g) update in the background, at most once an hour. A project's skills stay as they are until you run `a-kit update` there.");return}default:throw Error(`Unknown auto-update action "${e}". Use on, off or status.`)}}function ta(e,t){let n,r=null,i=!1,a=!1,o=()=>{n=void 0,a||(r?i=!0:r=e().catch(()=>{}).finally(()=>{r=null,i&&!a&&(i=!1,s())}))};function s(){a||(clearTimeout(n),n=setTimeout(o,t))}return{trigger:s,async stop(){a=!0,clearTimeout(n),await r},async idle(){for(;n!==void 0||r;)await(r??new Promise(e=>setTimeout(e,t)))}}}function na(e){return e.map(e=>{let t=zt(e);if(!t)throw Error(`Unknown agent "${e}". Use one of: ${It.map(e=>e.id).join(`, `)}.`);return t})}async function ra(e,t,n,r=Lt(t)){if(!/^[a-z0-9-]+$/.test(e))throw Error(`"${e}" isn't a skill name: use lowercase letters, numbers and hyphens.`);let i=Y(t,t===`global`?void 0:r),a=(await X(i)).skills[e],o=n.length>0?na(n):a?a.agents.map(e=>zt(e)).filter(e=>e!==void 0):It.filter(n=>l(p(Bt([n],t,r)[0],e)));o.length===0&&a&&(o=na([`claude-code`]));let s=Bt(o,t,r).map(t=>p(t,e));return{name:e,scope:t,lockFile:i,entry:a,agents:o,folders:s,existing:s.filter(e=>l(e))}}async function ia(e,t){if(e.existing.length===0)throw Error(`There's no ${e.name} folder in ${e.folders.map(e=>B(e)).join(` or `)||`your skills folders`}. Get it with \`a-kit pull ${e.name}\`.`);let n=await Promise.all(e.existing.map(async e=>({folder:e,files:await nn(e)}))),r=n[0];if(n.every(e=>an(e.files,r.files)))return r;let i=await t(),a=i?n.filter(e=>rn(e.files,i).paths.length>0):n;if(a.length===1)return a[0];throw Error(`${e.name} differs between ${n.map(e=>B(e.folder)).join(` and `)}. Say which to use with --agent, like \`--agent ${e.agents[0]?.id??`claude-code`}\`.`)}function aa(e,t){let n=1;for(let r=0;r<Math.min(t,e.length);r++)e.charCodeAt(r)===10&&n++;return n}function oa(e){return[...e].sort((e,t)=>Number(e.severity===`warning`)-Number(t.severity===`warning`)||(e.path??``).localeCompare(t.path??``)||(e.from??0)-(t.from??0))}function sa(e,t){if(e.path===null)return`skill`;let n=t(e.path);return e.from!==void 0&&n!==void 0?`${e.path}:${aa(n,e.from)}`:e.path}function ca(e,t,r=!!process.stdout.isTTY&&!process.env.NO_COLOR){let i=(e,t)=>r?n(e,t):t;return oa(e).map(e=>{let n=e.severity===`error`?i(`red`,`✗`):i(`yellow`,`▲`),r=e.fix?i(`dim`,` (fix: ${e.fix.label.toLowerCase()})`):``;return`${n} ${e.message} ${i(`dim`,sa(e,t))}${r}`})}const la=(e,t)=>`${e} ${t}${e===1?``:`s`}`,ua=()=>!!process.stdout.isTTY&&!process.env.NO_COLOR,da=(e,t)=>ua()?n(e,t):t,fa=e=>console.log(`${da(`green`,`✓`)} ${e}`),$=e=>console.error(`${da(`red`,`✗`)} ${e}`),pa=e=>console.log(da(`dim`,e)),ma=(e,t,n)=>`${e} v${t}${n?` (renamed from ${n})`:``}`;function ha(e,t){let n=t.diagnostics.filter(e=>e.severity===`error`).length;$(`${e} wasn't pushed: ${la(n,`error`)}`);for(let e of ca(t.diagnostics,t.textOf,ua()))console.error(` ${e}`)}function ga(e,t){for(let n of ca(e,t,ua()))console.log(` ${n}`)}const _a=new Map([{key:`name`,scope:`standard`,kind:`string`,required:!0,summary:`The skill's id and its /command. 1–64 lowercase letters, numbers and single hyphens.`},{key:`description`,scope:`standard`,kind:`string`,required:!0,summary:`What the skill does and when to use it. The agent reads it to decide when to load the skill. Up to 1024 characters.`},{key:`license`,scope:`standard`,kind:`string`,summary:`A license name, or the path of a license file in the skill.`},{key:`compatibility`,scope:`standard`,kind:`string`,summary:`Environment the skill needs (tools, network, OS). Up to 500 characters; only add it when it matters.`},{key:`metadata`,scope:`standard`,kind:`map`,summary:`Extra key: value pairs, both strings (author, version…).`,snippet:`
253
- author: `},{key:`allowed-tools`,scope:`standard`,kind:`tools`,summary:"Space-separated tools the skill may use without asking, like `Bash(git:*) Read`. Experimental."},{key:`when_to_use`,scope:`claude-code`,kind:`string`,summary:`More on when to use the skill, appended to the description in Claude Code's listing.`},{key:`argument-hint`,scope:`claude-code`,kind:`string`,summary:"Hint shown when typing the /command, like `[issue-number]`."},{key:`arguments`,scope:`claude-code`,kind:`tools`,summary:`Names for the /command's arguments, in order; use them as $name in the body.`},{key:`disable-model-invocation`,scope:`claude-code`,kind:`boolean`,summary:`true: only you can run it with its /command; Claude won't load it.`,snippet:`true`},{key:`user-invocable`,scope:`claude-code`,kind:`boolean`,summary:`false: hide it from the / menu, so only Claude loads it.`,snippet:`false`},{key:`disallowed-tools`,scope:`claude-code`,kind:`tools`,summary:`Tools taken away while the skill runs.`},{key:`model`,scope:`claude-code`,kind:`string`,summary:"Model to use while the skill runs, or `inherit`."},{key:`effort`,scope:`claude-code`,kind:{oneOf:[`low`,`medium`,`high`,`xhigh`,`max`]},summary:`Reasoning effort while the skill runs.`},{key:`context`,scope:`claude-code`,kind:{oneOf:[`fork`]},summary:"`fork` runs the skill in a subagent with its own context.",snippet:`fork`},{key:`agent`,scope:`claude-code`,kind:`string`,summary:"Subagent type to run in, with `context: fork`."},{key:`background`,scope:`claude-code`,kind:`boolean`,summary:"With `context: fork`, whether the subagent runs in the background."},{key:`hooks`,scope:`claude-code`,kind:`any`,summary:`Hooks registered while the skill is in use.`},{key:`paths`,scope:`claude-code`,kind:`tools`,summary:`Globs; Claude offers the skill when working on matching files.`},{key:`shell`,scope:`claude-code`,kind:{oneOf:[`bash`,`powershell`]},summary:"Shell for !`command` blocks in the body."}].map(e=>[e.key,e])),va=1024,ya=1536,ba=[`anthropic`,`claude`],xa=/<\/?[A-Za-z][^>]*>/;function Sa(e){let t=[];e.files.length>V.maxFiles&&t.push(ja(`A skill can have at most ${V.maxFiles} files.`));let n=0,r=/* @__PURE__ */ new Set;for(let i of e.files){n+=i.size;let e=fn(i.path);e&&t.push({severity:`error`,path:i.path,message:e}),r.has(i.path)&&t.push({severity:`error`,path:i.path,message:`Duplicate path.`}),r.add(i.path),i.size>V.maxFileBytes&&t.push({severity:`error`,path:i.path,message:`Files can be at most ${Pa(V.maxFileBytes)}.`})}for(let e of r){let n=e.split(`/`);for(let i=1;i<n.length;i++){let a=n.slice(0,i).join(`/`);r.has(a)&&t.push({severity:`error`,path:a,message:`${a} is a file, so it can't also be the folder of ${e}.`})}}return n>V.maxSkillBytes&&t.push(ja(`The whole skill can be at most ${Pa(V.maxSkillBytes)}.`)),e.skillMd===null?(t.push(ja(`Every skill needs a ${un} at its root.`)),t):(t.push(...Ca(e.skillMd,r,e.skills)),t)}function Ca(e,t,n){let r=[],i=(e,t,n,i,a)=>r.push({severity:e,path:un,message:t,from:n,to:i,fix:a}),a=Ar(e);if(!a.ok)return a.reason===`unclosed`?i(`error`,`The frontmatter has no closing --- line.`,0,3):i(`error`,`${un} must start with frontmatter: a --- line, name and description, and another --- line.`,0,Math.min(e.indexOf(`
261
+ `;async function Ca(e){for(let t of e){let e=p(t,Kr);await D(e,{recursive:!0}),await A(p(e,`SKILL.md`),Sa())}}const wa=e=>t=>Ht(t.map(e=>Vt(e)).filter(e=>e!==void 0),e);async function Ta(e,t,n,r,i=`latest`,a){let o=Ht(n,r),s=Y(r),c=await X(s);await Ca(o);try{await Ea(e,c,t,n,o,i,a)}finally{await mi(s,c)}return await ya(n.map(e=>e.id)),{dirs:o,lockFile:s}}async function Ea(e,t,n,r,i,a=`latest`,o){let s=n.find((e,t)=>n.some((n,r)=>r<t&&n.name===e.name));if(s)throw Error(`You picked more than one skill named "${s.name}"; they'd install to the same folder. Pick one.`);let c=Ot(),l=[];for(let o of n){c.start(`Installing ${o.name}`);try{let n=await ai(e,o.id,i,a);l.push(n),t.skills[n.name]=fi(n,r.map(e=>e.id),a),c.stop(`${n.name} v${n.version}`+(a===`latest`?``:` (${a})`)),a!==`latest`&&n.channels[a]===null&&L.warn(`${n.name} has no ${a} release yet, so you got the latest. \`a-kit update\` follows ${a} once someone sets it.`)}catch(e){throw c.error(`${o.name} failed`),e}}if(!o)return;let u=await ri(await ei(e,o.catalog,l,t,i),i,o.ask);u.length>0&&await Ea(e,t,u,r,i)}async function Da(e,t){Et(`agent kit`);let{api:n}=await $(),r=!t.yes,i=Kt(e),a=i.skills.length>0||i.kits.length===0,o=a?await n.listSkills():[],s=a?await qt(o,i.skills,r):[],c=i.kits.length>0?await Jt(await n.listKits(),i.kits,r):[];c.length>0&&t.channel!==`latest`&&L.warn(`--channel ${t.channel} applies to skills you name; kits install and follow each skill's latest version.`);let l=await Ut(t.agent,r),u=t.global?`global`:`project`,d=Ht(l,u),f=Y(u),p=await X(f);await Ca(d);try{await Ea(n,p,s,l,d,t.channel,{catalog:o,ask:r});for(let e of c){let t=await Ci(n,p,e,{agents:l.map(e=>e.id),dirsOf:wa(u),reinstall:!0}),r=e.skills.length-t.skipped.length;L.success(`kit/${e.name}: ${r} skill${r===1?``:`s`} installed`+(t.removed.length?`, ${t.removed.join(`, `)} removed (no longer in it)`:``))}}finally{await mi(f,p)}await ya(l.map(e=>e.id)),R(`Installed in ${d.map(V).join(`, `)}`)}async function Oa(e){switch(e){case`on`:{await ui({autoUpdate:!0});let e=await ga();e.status===`skipped`?L.warn(`Couldn't add the Claude Code hook: ${e.reason}.`):L.success(`Auto-update is on: Claude Code updates your global skills when a session starts, at most once an hour.`);return}case`off`:await ui({autoUpdate:!1}),await ga(),L.success("Auto-update is off. Update with `a-kit update -g`, or turn it back on with `a-kit auto-update on`.");return;case void 0:case`status`:{let e=(await J()).autoUpdate!==!1,t=(await _a()).includes(`autoUpdate`);console.log(`Auto-update is ${e?`on`:`off`}.`),console.log(`Claude Code: ${t?`updates the global skills when a session starts`:`no hook installed`}.`),console.log("\nWhen a Claude Code session starts, the skills and kits you installed everywhere (-g) update in the background, at most once an hour. A project's skills stay as they are until you run `a-kit update` there.");return}default:throw Error(`Unknown auto-update action "${e}". Use on, off or status.`)}}function ka(e,t){let n,r=null,i=!1,a=!1,o=()=>{n=void 0,a||(r?i=!0:r=e().catch(()=>{}).finally(()=>{r=null,i&&!a&&(i=!1,s())}))};function s(){a||(clearTimeout(n),n=setTimeout(o,t))}return{trigger:s,async stop(){a=!0,clearTimeout(n),await r},async idle(){for(;n!==void 0||r;)await(r??new Promise(e=>setTimeout(e,t)))}}}function Aa(e){return e.map(e=>{let t=Vt(e);if(!t)throw Error(`Unknown agent "${e}". Use one of: ${Rt.map(e=>e.id).join(`, `)}.`);return t})}async function ja(e,t,n,r=zt(t)){if(!/^[a-z0-9-]+$/.test(e))throw Error(`"${e}" isn't a skill name: use lowercase letters, numbers and hyphens.`);let i=Y(t,t===`global`?void 0:r),a=(await X(i)).skills[e],o=n.length>0?Aa(n):a?a.agents.map(e=>Vt(e)).filter(e=>e!==void 0):Rt.filter(n=>l(p(Ht([n],t,r)[0],e)));o.length===0&&a&&(o=Aa([`claude-code`]));let s=Ht(o,t,r).map(t=>p(t,e));return{name:e,scope:t,lockFile:i,entry:a,agents:o,folders:s,existing:s.filter(e=>l(e))}}async function Ma(e,t){if(e.existing.length===0)throw Error(`There's no ${e.name} folder in ${e.folders.map(e=>V(e)).join(` or `)||`your skills folders`}. Get it with \`a-kit pull ${e.name}\`.`);let n=await Promise.all(e.existing.map(async e=>({folder:e,files:await an(e)}))),r=n[0];if(n.every(e=>sn(e.files,r.files)))return r;let i=await t(),a=i?n.filter(e=>on(e.files,i).paths.length>0):n;if(a.length===1)return a[0];throw Error(`${e.name} differs between ${n.map(e=>V(e.folder)).join(` and `)}. Say which to use with --agent, like \`--agent ${e.agents[0]?.id??`claude-code`}\`.`)}function Na(e,t){let n=1;for(let r=0;r<Math.min(t,e.length);r++)e.charCodeAt(r)===10&&n++;return n}function Pa(e){return[...e].sort((e,t)=>Number(e.severity===`warning`)-Number(t.severity===`warning`)||(e.path??``).localeCompare(t.path??``)||(e.from??0)-(t.from??0))}function Fa(e,t){if(e.path===null)return`skill`;let n=t(e.path);return e.from!==void 0&&n!==void 0?`${e.path}:${Na(n,e.from)}`:e.path}function Ia(e,t,r=!!process.stdout.isTTY&&!process.env.NO_COLOR){let i=(e,t)=>r?n(e,t):t;return Pa(e).map(e=>{let n=e.severity===`error`?i(`red`,`✗`):i(`yellow`,`▲`),r=e.fix?i(`dim`,` (fix: ${e.fix.label.toLowerCase()})`):``;return`${n} ${e.message} ${i(`dim`,Fa(e,t))}${r}`})}const La=(e,t)=>`${e} ${t}${e===1?``:`s`}`,Ra=()=>!!process.stdout.isTTY&&!process.env.NO_COLOR,za=(e,t)=>Ra()?n(e,t):t,Ba=e=>console.log(`${za(`green`,`✓`)} ${e}`),Va=e=>console.error(`${za(`red`,`✗`)} ${e}`),Ha=e=>console.log(za(`dim`,e)),Ua=(e,t,n)=>`${e} v${t}${n?` (renamed from ${n})`:``}`;function Wa(e,t){let n=t.diagnostics.filter(e=>e.severity===`error`).length;Va(`${e} wasn't pushed: ${La(n,`error`)}`);for(let e of Ia(t.diagnostics,t.textOf,Ra()))console.error(` ${e}`)}function Ga(e,t){for(let n of Ia(e,t,Ra()))console.log(` ${n}`)}const Ka=new Map([{key:`name`,scope:`standard`,kind:`string`,required:!0,summary:`The skill's id and its /command. 1–64 lowercase letters, numbers and single hyphens.`},{key:`description`,scope:`standard`,kind:`string`,required:!0,summary:`What the skill does and when to use it. The agent reads it to decide when to load the skill. Up to 1024 characters.`},{key:`license`,scope:`standard`,kind:`string`,summary:`A license name, or the path of a license file in the skill.`},{key:`compatibility`,scope:`standard`,kind:`string`,summary:`Environment the skill needs (tools, network, OS). Up to 500 characters; only add it when it matters.`},{key:`metadata`,scope:`standard`,kind:`map`,summary:`Extra key: value pairs, both strings (author, version…).`,snippet:`
262
+ author: `},{key:`allowed-tools`,scope:`standard`,kind:`tools`,summary:"Space-separated tools the skill may use without asking, like `Bash(git:*) Read`. Experimental."},{key:`when_to_use`,scope:`claude-code`,kind:`string`,summary:`More on when to use the skill, appended to the description in Claude Code's listing.`},{key:`argument-hint`,scope:`claude-code`,kind:`string`,summary:"Hint shown when typing the /command, like `[issue-number]`."},{key:`arguments`,scope:`claude-code`,kind:`tools`,summary:`Names for the /command's arguments, in order; use them as $name in the body.`},{key:`disable-model-invocation`,scope:`claude-code`,kind:`boolean`,summary:`true: only you can run it with its /command; Claude won't load it.`,snippet:`true`},{key:`user-invocable`,scope:`claude-code`,kind:`boolean`,summary:`false: hide it from the / menu, so only Claude loads it.`,snippet:`false`},{key:`disallowed-tools`,scope:`claude-code`,kind:`tools`,summary:`Tools taken away while the skill runs.`},{key:`model`,scope:`claude-code`,kind:`string`,summary:"Model to use while the skill runs, or `inherit`."},{key:`effort`,scope:`claude-code`,kind:{oneOf:[`low`,`medium`,`high`,`xhigh`,`max`]},summary:`Reasoning effort while the skill runs.`},{key:`context`,scope:`claude-code`,kind:{oneOf:[`fork`]},summary:"`fork` runs the skill in a subagent with its own context.",snippet:`fork`},{key:`agent`,scope:`claude-code`,kind:`string`,summary:"Subagent type to run in, with `context: fork`."},{key:`background`,scope:`claude-code`,kind:`boolean`,summary:"With `context: fork`, whether the subagent runs in the background."},{key:`hooks`,scope:`claude-code`,kind:`any`,summary:`Hooks registered while the skill is in use.`},{key:`paths`,scope:`claude-code`,kind:`tools`,summary:`Globs; Claude offers the skill when working on matching files.`},{key:`shell`,scope:`claude-code`,kind:{oneOf:[`bash`,`powershell`]},summary:"Shell for !`command` blocks in the body."}].map(e=>[e.key,e])),qa=1024,Ja=1536,Ya=[`anthropic`,`claude`],Xa=/<\/?[A-Za-z][^>]*>/;function Za(e){let t=[];e.files.length>H.maxFiles&&t.push(oo(`A skill can have at most ${H.maxFiles} files.`));let n=0,r=/* @__PURE__ */ new Set;for(let i of e.files){n+=i.size;let e=mn(i.path);e&&t.push({severity:`error`,path:i.path,message:e}),r.has(i.path)&&t.push({severity:`error`,path:i.path,message:`Duplicate path.`}),r.add(i.path),i.size>H.maxFileBytes&&t.push({severity:`error`,path:i.path,message:`Files can be at most ${lo(H.maxFileBytes)}.`})}for(let e of r){let n=e.split(`/`);for(let i=1;i<n.length;i++){let a=n.slice(0,i).join(`/`);r.has(a)&&t.push({severity:`error`,path:a,message:`${a} is a file, so it can't also be the folder of ${e}.`})}}return n>H.maxSkillBytes&&t.push(oo(`The whole skill can be at most ${lo(H.maxSkillBytes)}.`)),e.skillMd===null?(t.push(oo(`Every skill needs a ${fn} at its root.`)),t):(t.push(...Qa(e.skillMd,r,e.skills)),t)}function Qa(e,t,n){let r=[],i=(e,t,n,i,a)=>r.push({severity:e,path:fn,message:t,from:n,to:i,fix:a}),a=Fr(e);if(!a.ok)return a.reason===`unclosed`?i(`error`,`The frontmatter has no closing --- line.`,0,3):i(`error`,`${fn} must start with frontmatter: a --- line, name and description, and another --- line.`,0,Math.min(e.indexOf(`
254
263
  `)===-1?e.length:e.indexOf(`
255
264
  `),80),{label:`Add frontmatter`,from:0,to:0,insert:`---
256
265
  name: my-skill
257
266
  description:
258
267
  ---
259
268
 
260
- `}),r;let{block:o,entries:s}=a;for(let e of a.yamlErrors)i(`error`,Aa(e.message),e.from,e.to);if(a.yamlErrors.length>0)return r;if(!a.isMapping)return i(`error`,`The frontmatter must be key: value lines.`,o.yamlFrom,o.yamlTo),r;let c=/* @__PURE__ */ new Map;for(let e of s)c.has(e.key)&&i(`error`,`\`${e.key}\` appears twice.`,e.keyFrom,e.keyTo),c.set(e.key,e);let l=o.yamlTo;for(let e of[`name`,`description`])c.has(e)||i(`error`,`The frontmatter needs a \`${e}\`.`,Math.max(0,o.yamlFrom-4),o.yamlFrom-1,{label:`Add ${e}`,from:l,to:l,insert:e===`name`?`name: my-skill
269
+ `}),r;let{block:o,entries:s}=a;for(let e of a.yamlErrors)i(`error`,ao(e.message),e.from,e.to);if(a.yamlErrors.length>0)return r;if(!a.isMapping)return i(`error`,`The frontmatter must be key: value lines.`,o.yamlFrom,o.yamlTo),r;let c=/* @__PURE__ */ new Map;for(let e of s)c.has(e.key)&&i(`error`,`\`${e.key}\` appears twice.`,e.keyFrom,e.keyTo),c.set(e.key,e);let l=o.yamlTo;for(let e of[`name`,`description`])c.has(e)||i(`error`,`The frontmatter needs a \`${e}\`.`,Math.max(0,o.yamlFrom-4),o.yamlFrom-1,{label:`Add ${e}`,from:l,to:l,insert:e===`name`?`name: my-skill
261
270
  `:`description:
262
- `});for(let e of s){let t=_a.get(e.key);if(t)Oa(t,e,i),t.scope===`claude-code`&&i(`warning`,`Only Claude Code reads \`${t.key}\`; claude.ai and the Skills API reject skills that have it.`,e.keyFrom,e.keyTo);else{let t=_a.get(e.key.toLowerCase().replace(/_/g,`-`));i(`warning`,t?`Unknown field \`${e.key}\`. Did you mean \`${t.key}\`?`:`Unknown field \`${e.key}\`. Claude Code ignores it, and claude.ai and the Skills API reject the skill.`,e.keyFrom,e.keyTo,t?{label:`Rename to ${t.key}`,from:e.keyFrom,to:e.keyTo,insert:t.key}:void 0)}}let u=c.get(`name`);if(u&&typeof u.value==`string`)for(let e of Ea(u.value)){let t=Da(u.value);i(`error`,e,u.valueFrom,u.valueTo,t&&t!==u.value?{label:`Change to ${t}`,from:u.valueFrom,to:u.valueTo,insert:t}:void 0)}let d=c.get(`description`);if(d&&typeof d.value==`string`){let e=d.value.trim(),t=[d.valueFrom,d.valueTo];if(e===``)i(`error`,wa,d.keyFrom,d.keyTo);else{let n=Ta(e);for(let e of n.errors)i(`error`,e,...t);for(let e of n.warnings)i(`warning`,e,...t);let r=c.get(`when_to_use`)?.value,a=e.length+(typeof r==`string`?r.length:0);a>ya&&i(`warning`,`description and when_to_use add up to ${a} characters; Claude Code cuts the listing at ${ya}.`,...t)}}let f=c.get(`compatibility`);f&&typeof f.value==`string`&&f.value.length>500&&i(`error`,`compatibility can be at most 500 characters.`,f.valueFrom,f.valueTo);let p=c.get(`metadata`);if(p&&Na(p.value))for(let[e,t]of Object.entries(p.value))typeof t!=`string`&&i(`warning`,`metadata.${e} should be a string; quote it.`,p.valueFrom,p.valueTo);let m=c.get(`allowed-tools`);return m&&Array.isArray(m.value)&&i(`warning`,`The spec expects allowed-tools as one space-separated string; only Claude Code accepts a list.`,m.valueFrom,m.valueTo),ka(e,o.bodyFrom,t,n,i),r}const wa=`The description is empty. Say what the skill does and when to use it.`;function Ta(e){let t=e.trim();if(t===``)return{errors:[wa],warnings:[]};let n=[],r=[];return t.length>va&&n.push(`The description is ${t.length} characters; the most is ${va}.`),xa.test(t)&&n.push(`The description can't contain XML tags.`),t.length<40&&r.push(`The description is short. Say what the skill does and when to use it, with the words a user would say.`),{errors:n,warnings:r}}function Ea(e){if(e===``)return[`The name is empty.`];let t=[];e.length>64&&t.push(`The name is ${e.length} characters; the most is 64.`),/^[a-z0-9-]+$/.test(e)?((e.startsWith(`-`)||e.endsWith(`-`))&&t.push(`The name can't start or end with a hyphen.`),e.includes(`--`)&&t.push(`The name can't have two hyphens in a row.`)):t.push(`Use only lowercase letters, numbers and hyphens in the name.`);let n=ba.find(t=>e.toLowerCase().includes(t));return n&&t.push(`The name can't contain the reserved word "${n}".`),t}function Da(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase();for(let e of ba)t=t.replaceAll(e,``);return t=t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/-+$/,``),t===``?null:t}function Oa(e,t,n){let{value:r}=t,i=[t.valueFrom,t.valueTo],a=e.kind;if(r===null)e.required&&n(`error`,`\`${e.key}\` is empty.`,t.keyFrom,t.keyTo);else if(a===`string`&&typeof r!=`string`)n(`error`,`\`${e.key}\` must be text.`,...i);else if(a===`boolean`&&typeof r!=`boolean`){let t=typeof r==`string`?Ma(r):null;n(`error`,`\`${e.key}\` must be true or false.`,...i,t===null?void 0:{label:`Change to ${t}`,from:i[0],to:i[1],insert:String(t)})}else a===`map`&&!Na(r)?n(`error`,`\`${e.key}\` must be indented key: value lines.`,...i):a===`tools`&&typeof r!=`string`&&!(Array.isArray(r)&&r.every(e=>typeof e==`string`))?n(`error`,`\`${e.key}\` must be a space-separated list of names.`,...i):typeof a==`object`&&!a.oneOf.includes(String(r))&&n(`error`,`\`${e.key}\` must be one of: ${a.oneOf.join(`, `)}.`,...i)}function ka(e,t,n,r,i){let a=e.slice(t);if(a.trim()===``){i(`warning`,`The skill has no instructions yet. Write them below the frontmatter.`,Math.max(0,t-4),t);return}let o=a.split(`
263
- `).length;o>500&&i(`warning`,`${un} has ${o} lines below the frontmatter. Keep it under 500 and move details to other files it links to.`,t,t+a.indexOf(`
264
- `));for(let{path:a,from:o,to:s}of Ir(e,t)){if(a.startsWith(`/`)){i(`warning`,`Link to files with a path relative to SKILL.md, without a leading /.`,o,s);continue}let e=mn(un,a);if(e===null){let e=Lr(a);if(e&&r?.has(e))continue;i(`warning`,e&&r?`There's no skill named \`${e}\` in this organization.`:`This link points outside the skill.`,o,s)}else!n.has(e)&&![...n].some(t=>t.startsWith(`${e}/`))&&i(`warning`,`There's no ${e} in this skill.`,o,s)}}function Aa(e){return/nested mappings|implicit keys/i.test(e)&&!/map values/i.test(e)?`This value has a colon in it. Wrap the whole value in quotes.`:/implicit map keys need to be followed by map values/i.test(e)?"Each frontmatter line needs a key, a colon and a value, like `key: value`.":`YAML: ${e.replace(/\.$/,``)}.`}function ja(e){return{severity:`error`,path:null,message:e}}function Ma(e){let t=e.trim().toLowerCase();return[`true`,`yes`,`on`,`1`].includes(t)?!0:![`false`,`no`,`off`,`0`].includes(t)&&null}function Na(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function Pa(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${Math.round(e/1048576*10)/10} MB`}var Fa=class extends Error{diagnostics;files;constructor(e,t){super(e[0]?.message??`The skill doesn't follow the format rules.`),this.diagnostics=e,this.files=t}textOf=e=>ln(this.files,e)},Ia=class extends Error{name;local;remote;constructor(e,t,n){super(`${e} is at v${n} in agent kit, and your copy is from v${t}. Push with --force to save yours over it, or set your edits aside and get v${n} with \`a-kit pull ${e} --force\`.`),this.name=e,this.local=t,this.remote=n}};async function La(e,t,n){if(t.name===`report-session-issue`&&!t.entry)throw Error(`${Vr} is the CLI's own skill; it comes with every install.`);let{entry:r}=t,i=n.source?{folder:n.source,files:await nn(n.source)}:await ia(t,async()=>r?(await e.getVersion(r.id,r.version)).files:null),{files:a}=i,o=ln(a,`SKILL.md`)??null,s=o&&zr(o).length>0?new Set((await e.listSkills()).map(e=>e.name)):void 0,c=Sa({files:a.map(({path:e,size:t})=>({path:e,size:t})),skillMd:o,skills:s});if(c.filter(e=>e.severity===`error`).length>0)throw new Fa(c,a);let l=c.filter(e=>e.severity===`warning`),u=await Ra(e,t,n);if(u&&r&&u.version!==r.version&&!n.force)throw new Ia(t.name,r.version,u.version);let d,f,p;try{if(!u)d=await e.createSkill(await n.organization(),{files:a.map(on)}),f=`created`,p=a.map(e=>e.path);else{let t=rn(a,u.files);p=t.paths,t.paths.length===0?(d=u,f=`unchanged`):(d=await e.saveSkill(u.id,{baseVersionId:u.versionId,upserts:t.upserts.map(on),deletes:t.deletes}),f=`pushed`)}}catch(n){if(n instanceof Z&&n.status===422)throw new Fa(n.diagnostics,a);if(n instanceof Z&&n.status===409&&u){let n=await e.getSkill(u.id);throw new Ia(t.name,u.version,n.version)}throw n}let m=f===`unchanged`&&r?.id===d.id&&r.version===d.version?{folder:i.folder,renamed:!1}:await za(t,i.folder,a,d);return{kind:f,skill:d,changed:p,folder:m.folder,renamedFrom:m.renamed?t.name:void 0,warnings:l,files:a}}async function Ra(e,t,n){if(t.entry)try{return await e.getSkill(t.entry.id)}catch(e){throw e instanceof Z&&e.status===404?Error(`${t.name} isn't in your agent kit anymore. Remove it from ${d(t.lockFile)} to push it as a new skill.`):e}let r=n.org?.trim().toLowerCase(),i=(await e.listSkills()).filter(e=>e.name===t.name&&(!r||e.organizationId.toLowerCase()===r||e.organizationName.toLowerCase()===r));if(i.length===0)return null;if(i.length>1)throw Error(`More than one of your organizations has a skill named "${t.name}". Say which with --org: ${i.map(e=>e.organizationName).join(`, `)}.`);let a=i[0];if(!n.force)throw Error(`${a.organizationName} already has a skill named "${t.name}", and this folder didn't come from it. Push with --force to save your folder as its next version, or get it with \`a-kit pull ${t.name} --force\`.`);return e.getSkill(a.id)}async function za(e,t,n,r){let i=await X(e.lockFile),a=r.name!==e.name&&/^[a-z0-9-]+$/.test(r.name)&&!e.folders.some(e=>l(p(f(e),r.name)))&&!i.skills[r.name],o=a?r.name:e.name,s=/* @__PURE__ */ new Set([...e.folders,t]),c=t;for(let e of s){let r=p(f(e),o);e===t&&(c=r),(e!==t||a)&&(await sn(r,n),a&&await O(e,{recursive:!0,force:!0}))}return a&&delete i.skills[e.name],i.skills[o]={id:r.id,version:r.version,agents:e.agents.map(e=>e.id)},await di(e.lockFile,i),{folder:c,renamed:a}}function Ba(e,t){let n=e.lastIndexOf(`/`);return n===-1?{name:e,org:t}:{name:e.slice(n+1),org:t??e.slice(0,n)}}async function Va(e,t){let n=t.global?`global`:`project`,{api:r}=await Q(),i=e.length===0,a=i?Object.keys((await X(Y(n))).skills):e,o=Ua(r,t),s=0,c=0;for(let e of a){let{name:a,org:l}=Ba(e,t.org);try{let e=await ra(a,n,t.agent);if(i&&e.existing.length===0)continue;let c=await La(r,e,{force:t.force,org:l,organization:()=>o(l)});if(c.kind===`unchanged`){i||pa(`${a} is up to date (v${c.skill.version}).`);continue}Ha(c),s++}catch(e){if(c++,e instanceof Fa)ha(a,e);else if(i)$(`${a}: ${e instanceof Error?e.message:e}`);else throw e}}i&&s===0&&c===0&&pa(`Nothing to push.`),c>0&&(process.exitCode=1)}function Ha(e){let{skill:t}=e;fa(ma(t.name,t.version,e.renamedFrom)+(e.kind===`created`?`, new in agent kit`:``)),ga(e.warnings,t=>ln(e.files,t))}function Ua(e,t){let n;return async r=>(n??=e.listOrganizations(),(await Qt(await n,r,!t.yes)).id)}async function Wa(e,t){if(!e)throw Error("Name the skill to watch, like `a-kit dev release`.");let n=t.global?`global`:`project`,r=Ba(e,t.org),{api:i}=await Q(),a=Ua(i,t),o=r.name,s=await ra(o,n,t.agent),{folder:c}=await ia(s,async()=>s.entry?(await i.getVersion(s.entry.id,s.entry.version)).files:null),l=``,d=!1,f,p,m=new Promise(e=>p=e),h=e=>{f?.close(),g.stop(),process.exitCode=e,p()},g=ta(async()=>{try{let e=await ra(o,n,t.agent),s=await La(i,e,{force:t.force,source:c,org:r.org,organization:()=>a(r.org)}),u=JSON.stringify(s.warnings.map(e=>e.message)),{version:f}=s.skill;if(s.kind===`unchanged`){d&&fa(`fixed, and the same as v${f}; nothing to push`),d=!1;return}d=!1,fa(s.kind===`created`?`${s.skill.name} is new in agent kit → v${f}`:`${cn(s.changed)} changed → v${f}`+(s.renamedFrom?` (renamed to ${s.skill.name})`:``)),u!==l&&(ga(s.warnings,e=>ln(s.files,e)),l=u),s.folder!==c&&(o=s.skill.name,c=s.folder,v())}catch(e){e instanceof Fa?(ha(o,e),l=``,d=!0):e instanceof Ia?($(e.message),h(1)):Ga(e)?($(`${B(c)} is gone; stopped watching.`),h(1)):e instanceof Z&&e.status===401?($(e.message),h(1)):($(e instanceof Error?e.message:String(e)),d=!0)}},300);function v(){f?.close(),f=u(c,{recursive:!0},(e,t)=>{let n=t?.toString().split(_).join(`/`);n&&en(n)||g.trigger()}),f.on(`error`,()=>{$(`Can't watch ${B(c)} anymore; stopped.`),h(1)}),console.log(`watching ${B(c)} …`)}v(),g.trigger();let y=()=>h(0);process.once(`SIGINT`,y),process.once(`SIGTERM`,y),await m,process.off(`SIGINT`,y),process.off(`SIGTERM`,y)}const Ga=e=>typeof e==`object`&&!!e&&e.code===`ENOENT`;async function Ka(e){wt(`agent kit`);let t=await Ei();t?I.success(`Logged in as ${t.user.email}`):t=await Ti();let n=Si(q(),t.token),r=await n.listSkills();if(r.length===0){L(`You don't have skills yet. Create one at ${t.webUrl}/app/skills, then run \`a-kit add\`.`);return}let i=!e.yes;if(i&&!R())throw Error("`a-kit init` asks questions. Pass --yes to install every skill, or use `a-kit add <skill>`.");let a=await Ht(e.global,i),o=await Vt(e.agent,i),s=i?z(await St({message:`Which skills?`,options:r.map(e=>({value:e.id,label:Zt(e)})),initialValues:r.map(e=>e.id),required:!0})):r.map(e=>e.id),{dirs:c}=await Zi(n,r.filter(e=>s.includes(e.id)),o,a,e.channel,{catalog:r,ask:i});L(`Installed in ${c.map(B).join(`, `)}`)}const qa=()=>p(J(),`auto-update.json`);async function Ja(e=Date.now(),t=36e5,n=qa()){if(Ya(await Xa(n),e,t))return!1;await T(f(n),{recursive:!0});let r=`${n}.claim`;try{await k(r,``,{flag:`wx`})}catch{let e=await ne(r).then(e=>e.mtimeMs,()=>null);return e!==null&&Date.now()-e>6e4&&await re(r).catch(()=>{}),!1}try{return!Ya(await Xa(n),e,t)&&(await k(n,JSON.stringify({startedAt:e})+`
265
- `),!0)}finally{await re(r).catch(()=>{})}}const Ya=(e,t,n)=>e!==null&&t-e<n&&e<=t;async function Xa(e){try{let{startedAt:t}=JSON.parse(await D(e,`utf8`));return typeof t==`number`?t:null}catch{return null}}const Za=(e,t)=>{se(process.execPath,[e,...t],{cwd:v(),detached:!0,stdio:`ignore`,windowsHide:!0}).unref()};async function Qa(e,t=Za,n=Date.now()){if((await oi()).autoUpdate===!1)return!1;let r=await X(Y(`global`));return Object.keys(r.skills).length===0&&Object.keys(r.kits).length===0||!await ri()||!await Ja(n)?!1:(t(e,[`update`,`--global`]),!0)}async function $a(e,t,n,r=v()){let i=[Y(`global`)],a=eo(n,r);a&&i.push(a);for(let n of i){let r=(await X(n)).skills[e];if(r?.agents.includes(t))return r}return null}function eo(e,t){let n=e,{root:r}=m(e);for(;n&&n!==t;){let e=Y(`project`,n);if(l(e))return e;if(n===r)break;n=f(n)}return null}async function to(){let e=p(J(),`machine.json`);try{let t=JSON.parse(await D(e,`utf8`));if(typeof t.id==`string`&&t.id)return t.id}catch{}let t=ae();return await T(f(e),{recursive:!0,mode:448}),await k(e,JSON.stringify({id:t},null,2)+`
266
- `),t}async function no(e,t,n,r=/* @__PURE__ */ new Date){return{id:ae(),skillId:e.id,version:e.version,agent:t,machineId:await to(),machineName:y()||null,trigger:n,occurredAt:r.toISOString()}}const ro=()=>p(J(),`pending-activations.jsonl`);async function io(e,t){let n=`${ro()}.${process.pid}`,r=[];try{await te(ro(),n),r=oo(await D(n,`utf8`)),await O(n,{force:!0})}catch{}let i=[...r,t].slice(-500),a=0;for(let t=0;t<i.length;t+=100){let n=i.slice(t,t+100);try{await e(n),a+=n.length}catch(e){if(!ao(e))continue;let n=i.slice(t);return await T(J(),{recursive:!0,mode:448}),await S(ro(),n.map(e=>JSON.stringify(e)).join(`
267
- `)+`
268
- `),{sent:a,queued:n.length}}}return{sent:a,queued:0}}const ao=e=>!(e instanceof Z)||e.status===0||e.status===429||e.status>=500;function oo(e){return e.split(`
269
- `).filter(Boolean).flatMap(e=>{try{return[JSON.parse(e)]}catch{return[]}})}async function so(e,t){try{if(t&&(process.env.AGENT_KIT_API_URL=t),e!==`claude-code`||process.stdin.isTTY)return;let n=JSON.parse(await co());if(n.hook_event_name===`SessionStart`){await Qa(Bi()??zi());return}if(ci()||(await oi()).telemetry===!1)return;let r=Li(n);if(!r)return;let i=await $a(r.name,e,typeof n.cwd==`string`?n.cwd:process.cwd());if(!i)return;let a=await ri();if(!a)return;let o=Si(q(),a.token);await io(async e=>{await o.reportActivations(e,AbortSignal.timeout(5e3))},await no(i,e,r.trigger))}catch{}}async function co(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}function lo(e){return{always:e.description,max:e.description+e.body+e.files}}function uo(e){let t=0,n=0,r=0,i=!1;for(let a of e){if(!a){r++;continue}let e=lo(a);t+=e.always,n+=e.max,a.source===`estimate`&&(i=!0)}return{always:t,max:n,missing:r,estimated:i}}function fo(e){let t=Math.abs(e);return t<1e3?`${Math.round(e)}t`:t<9950?`${mo((e/1e3).toFixed(1))}k`:t<999500?`${Math.round(e/1e3)}k`:`${mo((e/1e6).toFixed(1))}M`}const po=(e,t)=>`${t===`estimate`?`~`:``}${fo(e)}`,mo=e=>e.replace(/\.0$/,``);function ho(e,t,n){let r=e.map(e=>{let r=t.skills[e.name],i=n.skills[e.name],a=e.contextCost,o=e=>a?po(e,a.source):`—`;return{skill:e,installed:r!==void 0||i!==void 0,cells:[Zt(e),go(e),o(a?.description??0),o(a?.body??0),o(a?.files??0),[_o(`project`,r,e),_o(`global`,i,e)].filter(Boolean).join(`, `)]}}),i=[`SKILL`,`VERSION`,`DESC`,`BODY`,`FILES`,`INSTALLED`],a=i.map((e,t)=>Math.max(e.length,...r.map(e=>e.cells[t].length))),o=e=>e.map((t,n)=>n===e.length-1?t:t.padEnd(a[n])).join(` `).trimEnd(),s=r.filter(e=>e.installed),c=uo(s.map(e=>e.skill.contextCost)),l=c.estimated?`~`:``,u=[o(i),...r.map(e=>o(e.cells))];return u.push(s.length===0?`${`TOTAL`.padEnd(a[0])} nothing installed here`:`${`TOTAL`.padEnd(a[0])} ${l}${fo(c.always)} always · ${l}${fo(c.max)} max (${s.length} installed${c.missing?`, ${c.missing} not counted yet`:``})`),r.some(e=>e.skill.contextCost?.source===`estimate`)&&u.push(`~ estimated locally: add a Claude API key to the organization to count exactly.`),u}function go(e){return[`v${e.version}`,...At.filter(t=>e.channels[t]!==null).map(t=>`${t} v${e.channels[t]}`)].join(` · `)}function _o(e,t,n){if(!t)return null;let r=ui(t),{version:i}=Pt(n.channels,n.version,r),a=`in ${e}${r===`latest`?``:` on ${r}`}`;return t.version===i?a:`${a} at v${t.version}, run a-kit update${e===`global`?` -g`:``}`}async function vo(){let{api:e,credentials:t}=await Q(),[n,r]=await Promise.all([e.listSkills(),e.listKits()]);if(n.length===0){console.log(`You don't have skills yet. Create one at ${t.webUrl}/app/skills`);return}let i=await X(Y(`project`)),a=await X(Y(`global`));for(let e of ho(n,i,a))console.log(e);if(r.length===0)return;console.log(``);let o=Math.max(...r.map(e=>yo(e).length));for(let e of r){let t=[bo(i,e)&&`in project`,bo(a,e)&&`in global`].filter(Boolean);console.log(`${yo(e).padEnd(o)} ${xo(e)}`+(t.length?` (${t.join(`, `)})`:``))}}const yo=e=>`${Ut}${Zt(e)}`,bo=(e,t)=>Object.values(e.kits).some(e=>e.id===t.id);function xo(e){let t=e.skills.length;if(t===0)return`no skills`;let n=e.skills.slice(0,3).map(e=>e.name);return`${t} skill${t===1?``:`s`}: ${n.join(`, `)}${t>3?`, …`:``}`}async function So(){wt(`agent kit`);let e=await Ti();L(`Logged in as ${e.user.email}`)}async function Co(){let e=await ri();e?(await Si(q(),e.token).logout().catch(()=>{}),await ii(null),console.log(`Logged out ${e.user.email}.`)):console.log(`You're not logged in.`)}async function wo(){let e=await Ei();e?console.log(e.user.email):(console.log("You're not logged in. Run `a-kit login`."),process.exitCode=1)}async function To(e,t){if(e.length===0)throw Error("Name the skill to pull, like `a-kit pull release`. To refresh every installed skill, run `a-kit update`.");let n=t.global?`global`:`project`,r=!t.yes,{api:i}=await Q(),a,o=/* @__PURE__ */ new Set;for(let s of e){let{name:e,org:c}=Ba(s,t.org),l=await ra(e,n,t.agent),u=l.entry?.id;if(!u){a??=await i.listSkills();let[o]=await Gt(a,[c?`${c}/${e}`:e],r);u=o.id,l.existing.length===0&&t.agent.length===0&&(l=await ra(e,n,(await Vt([],r)).map(e=>e.id)))}let d=await _i(i,l,u,{force:t.force});for(let e of l.agents)o.add(e.id);await Yi([...new Set(l.folders.map(e=>f(e)))]),d.kind===`unchanged`?pa(`${d.skill.name} is up to date (v${d.skill.version}).`):fa(`${d.skill.name} v${d.skill.version}`+(d.from!==null&&d.from!==d.skill.version?` (was v${d.from})`:``))}await Gi([...o])}const Eo={maxTitleLength:120,maxNoteLength:4e3,maxSkills:50,maxTranscriptBytes:8388608},Do=[{kind:`private-key`,pattern:/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,strict:!0},{kind:`anthropic-key`,pattern:/\bsk-ant-[A-Za-z0-9_-]{20,}/g,strict:!0},{kind:`openai-key`,pattern:/\bsk-(?:proj-|svcacct-)?[A-Za-z0-9_-]{32,}/g,strict:!0},{kind:`github-token`,pattern:/\b(?:gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{40,})/g,strict:!0},{kind:`aws-key`,pattern:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,strict:!0},{kind:`slack-token`,pattern:/\bxox[abprs]-[A-Za-z0-9-]{10,}/g,strict:!0},{kind:`stripe-key`,pattern:/\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}/g,strict:!0},{kind:`google-key`,pattern:/\bAIza[0-9A-Za-z_-]{35}\b/g,strict:!0},{kind:`jwt`,pattern:/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,strict:!0},{kind:`url-credentials`,pattern:/\b([a-z][a-z0-9+.-]*:\/\/)[^\s:/@]+:[^\s@/]+@/gi,keep:(e,t)=>`${t}<secret>@`,strict:!1},{kind:`bearer`,pattern:/\b(Bearer\s+)[A-Za-z0-9._~+/-]{20,}=*/g,keep:(e,t)=>`${t}<secret>`,strict:!1},{kind:`assignment`,pattern:/\b([A-Za-z0-9_]*(?:secret|token|password|passwd|api_?key|private_?key|access_?key)[A-Za-z0-9_]*["']?\s*[=:]\s*)(["']?)(?!<secret)[^\s"'`,;]{8,}\2/gi,keep:(e,t,n)=>`${t}${n}<secret>${n}`,strict:!1}],Oo=/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}\b/g,ko=/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g,Ao=/* @__PURE__ */ new Set([`127.0.0.1`,`0.0.0.0`]),jo=/@(?:example\.(?:com|org|net)|anthropic\.com)$/i,Mo=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function No(e){let t={},n=(e,n=1)=>{t[e]=(t[e]??0)+n},r=e.paths.filter(e=>e.path.length>1).sort((e,t)=>t.path.length-e.path.length).map(e=>({...e,pattern:new RegExp(Mo(e.path),`g`)})),i=e.replacements.filter(e=>e.find.trim().length>1).sort((e,t)=>t.find.length-e.find.length).map(e=>({...e,pattern:new RegExp(e.find.length<4?`(?<![\\p{L}\\p{N}_])${Mo(e.find)}(?![\\p{L}\\p{N}_])`:Mo(e.find),`giu`)}));function a(e){let t=e;for(let e of Do)t=t.replace(e.pattern,(t,...r)=>(n(`secret:${e.kind}`),e.keep?e.keep(t,...r):`<secret>`));for(let e of r)t=t.replace(e.pattern,()=>(n(`path:${e.as}`),e.as));for(let e of i)t=t.replace(e.pattern,()=>(n(`term:${e.find}`),e.replace));return t=t.replace(Oo,e=>jo.test(e)?e:(n(`email`),`user@example.com`)),t=t.replace(ko,e=>Ao.has(e)?e:(n(`ip`),`192.0.2.1`)),t}function o(t){let r=e.maxToolText;return r===null||t.length<=r?t:(n(`cut`),`${t.slice(0,r)}\n… [${t.length-r} more characters left out by a-kit report]`)}function s(e){return typeof e==`string`?o(a(e)):Array.isArray(e)?e.map(s):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,s(t)])):e}function c(e){return e.type===`text`?{...e,text:a(e.text)}:e.type===`tool_use`?{...e,input:s(e.input)}:{...e,content:o(a(e.content))}}function l(e){return e.map(e=>e.type===`system`?e:{...e,message:{content:e.message.content.map(c)}})}return{text:a,events:l,counts:t}}const Po=e=>e.map(e=>JSON.stringify(e)).join(`
271
+ `});for(let e of s){let t=Ka.get(e.key);if(t)ro(t,e,i),t.scope===`claude-code`&&i(`warning`,`Only Claude Code reads \`${t.key}\`; claude.ai and the Skills API reject skills that have it.`,e.keyFrom,e.keyTo);else{let t=Ka.get(e.key.toLowerCase().replace(/_/g,`-`));i(`warning`,t?`Unknown field \`${e.key}\`. Did you mean \`${t.key}\`?`:`Unknown field \`${e.key}\`. Claude Code ignores it, and claude.ai and the Skills API reject the skill.`,e.keyFrom,e.keyTo,t?{label:`Rename to ${t.key}`,from:e.keyFrom,to:e.keyTo,insert:t.key}:void 0)}}let u=c.get(`name`);if(u&&typeof u.value==`string`)for(let e of to(u.value)){let t=no(u.value);i(`error`,e,u.valueFrom,u.valueTo,t&&t!==u.value?{label:`Change to ${t}`,from:u.valueFrom,to:u.valueTo,insert:t}:void 0)}let d=c.get(`description`);if(d&&typeof d.value==`string`){let e=d.value.trim(),t=[d.valueFrom,d.valueTo];if(e===``)i(`error`,$a,d.keyFrom,d.keyTo);else{let n=eo(e);for(let e of n.errors)i(`error`,e,...t);for(let e of n.warnings)i(`warning`,e,...t);let r=c.get(`when_to_use`)?.value,a=e.length+(typeof r==`string`?r.length:0);a>Ja&&i(`warning`,`description and when_to_use add up to ${a} characters; Claude Code cuts the listing at ${Ja}.`,...t)}}let f=c.get(`compatibility`);f&&typeof f.value==`string`&&f.value.length>500&&i(`error`,`compatibility can be at most 500 characters.`,f.valueFrom,f.valueTo);let p=c.get(`metadata`);if(p&&co(p.value))for(let[e,t]of Object.entries(p.value))typeof t!=`string`&&i(`warning`,`metadata.${e} should be a string; quote it.`,p.valueFrom,p.valueTo);let m=c.get(`allowed-tools`);return m&&Array.isArray(m.value)&&i(`warning`,`The spec expects allowed-tools as one space-separated string; only Claude Code accepts a list.`,m.valueFrom,m.valueTo),io(e,o.bodyFrom,t,n,i),r}const $a=`The description is empty. Say what the skill does and when to use it.`;function eo(e){let t=e.trim();if(t===``)return{errors:[$a],warnings:[]};let n=[],r=[];return t.length>qa&&n.push(`The description is ${t.length} characters; the most is ${qa}.`),Xa.test(t)&&n.push(`The description can't contain XML tags.`),t.length<40&&r.push(`The description is short. Say what the skill does and when to use it, with the words a user would say.`),{errors:n,warnings:r}}function to(e){if(e===``)return[`The name is empty.`];let t=[];e.length>64&&t.push(`The name is ${e.length} characters; the most is 64.`),/^[a-z0-9-]+$/.test(e)?((e.startsWith(`-`)||e.endsWith(`-`))&&t.push(`The name can't start or end with a hyphen.`),e.includes(`--`)&&t.push(`The name can't have two hyphens in a row.`)):t.push(`Use only lowercase letters, numbers and hyphens in the name.`);let n=Ya.find(t=>e.toLowerCase().includes(t));return n&&t.push(`The name can't contain the reserved word "${n}".`),t}function no(e){let t=e.normalize(`NFKD`).replace(/[̀-ͯ]/g,``).toLowerCase();for(let e of Ya)t=t.replaceAll(e,``);return t=t.replace(/[^a-z0-9]+/g,`-`).replace(/^-+|-+$/g,``).slice(0,64).replace(/-+$/,``),t===``?null:t}function ro(e,t,n){let{value:r}=t,i=[t.valueFrom,t.valueTo],a=e.kind;if(r===null)e.required&&n(`error`,`\`${e.key}\` is empty.`,t.keyFrom,t.keyTo);else if(a===`string`&&typeof r!=`string`)n(`error`,`\`${e.key}\` must be text.`,...i);else if(a===`boolean`&&typeof r!=`boolean`){let t=typeof r==`string`?so(r):null;n(`error`,`\`${e.key}\` must be true or false.`,...i,t===null?void 0:{label:`Change to ${t}`,from:i[0],to:i[1],insert:String(t)})}else a===`map`&&!co(r)?n(`error`,`\`${e.key}\` must be indented key: value lines.`,...i):a===`tools`&&typeof r!=`string`&&!(Array.isArray(r)&&r.every(e=>typeof e==`string`))?n(`error`,`\`${e.key}\` must be a space-separated list of names.`,...i):typeof a==`object`&&!a.oneOf.includes(String(r))&&n(`error`,`\`${e.key}\` must be one of: ${a.oneOf.join(`, `)}.`,...i)}function io(e,t,n,r,i){let a=e.slice(t);if(a.trim()===``){i(`warning`,`The skill has no instructions yet. Write them below the frontmatter.`,Math.max(0,t-4),t);return}let o=a.split(`
272
+ `).length;o>500&&i(`warning`,`${fn} has ${o} lines below the frontmatter. Keep it under 500 and move details to other files it links to.`,t,t+a.indexOf(`
273
+ `));for(let{path:a,from:o,to:s}of Vr(e,t)){if(a.startsWith(`/`)){i(`warning`,`Link to files with a path relative to SKILL.md, without a leading /.`,o,s);continue}let e=gn(fn,a);if(e===null){let e=Hr(a);if(e&&r?.has(e))continue;i(`warning`,e&&r?`There's no skill named \`${e}\` in this organization.`:`This link points outside the skill.`,o,s)}else!n.has(e)&&![...n].some(t=>t.startsWith(`${e}/`))&&i(`warning`,`There's no ${e} in this skill.`,o,s)}}function ao(e){return/nested mappings|implicit keys/i.test(e)&&!/map values/i.test(e)?`This value has a colon in it. Wrap the whole value in quotes.`:/implicit map keys need to be followed by map values/i.test(e)?"Each frontmatter line needs a key, a colon and a value, like `key: value`.":`YAML: ${e.replace(/\.$/,``)}.`}function oo(e){return{severity:`error`,path:null,message:e}}function so(e){let t=e.trim().toLowerCase();return[`true`,`yes`,`on`,`1`].includes(t)?!0:![`false`,`no`,`off`,`0`].includes(t)&&null}function co(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function lo(e){return e<1024?`${e} B`:e<1048576?`${Math.round(e/1024)} KB`:`${Math.round(e/1048576*10)/10} MB`}var uo=class extends Error{diagnostics;files;constructor(e,t){super(e[0]?.message??`The skill doesn't follow the format rules.`),this.diagnostics=e,this.files=t}textOf=e=>dn(this.files,e)},fo=class extends Error{name;local;remote;constructor(e,t,n){super(`${e} is at v${n} in agent kit, and your copy is from v${t}. Push with --force to save yours over it, or set your edits aside and get v${n} with \`a-kit pull ${e} --force\`.`),this.name=e,this.local=t,this.remote=n}};async function po(e,t,n){if(t.name===`report-session-issue`&&!t.entry)throw Error(`${Kr} is the CLI's own skill; it comes with every install.`);let{entry:r}=t,i=n.source?{folder:n.source,files:await an(n.source)}:await Ma(t,async()=>r?(await e.getVersion(r.id,r.version)).files:null),{files:a}=i,o=dn(a,`SKILL.md`)??null,s=o&&Wr(o).length>0?new Set((await e.listSkills()).map(e=>e.name)):void 0,c=Za({files:a.map(({path:e,size:t})=>({path:e,size:t})),skillMd:o,skills:s});if(c.filter(e=>e.severity===`error`).length>0)throw new uo(c,a);let l=c.filter(e=>e.severity===`warning`),u=await mo(e,t,n);if(u&&r&&u.version!==r.version&&!n.force)throw new fo(t.name,r.version,u.version);let d,f,p;try{if(!u)d=await e.createSkill(await n.organization(),{files:a.map(cn)}),f=`created`,p=a.map(e=>e.path);else{let t=on(a,u.files);p=t.paths,t.paths.length===0?(d=u,f=`unchanged`):(d=await e.saveSkill(u.id,{baseVersionId:u.versionId,upserts:t.upserts.map(cn),deletes:t.deletes}),f=`pushed`)}}catch(n){if(n instanceof Z&&n.status===422)throw new uo(n.diagnostics,a);if(n instanceof Z&&n.status===409&&u){let n=await e.getSkill(u.id);throw new fo(t.name,u.version,n.version)}throw n}let m=f===`unchanged`&&r?.id===d.id&&r.version===d.version?{folder:i.folder,renamed:!1}:await ho(t,i.folder,a,d);return{kind:f,skill:d,changed:p,folder:m.folder,renamedFrom:m.renamed?t.name:void 0,warnings:l,files:a}}async function mo(e,t,n){if(t.entry)try{return await e.getSkill(t.entry.id)}catch(e){throw e instanceof Z&&e.status===404?Error(`${t.name} isn't in your agent kit anymore. Remove it from ${d(t.lockFile)} to push it as a new skill.`):e}let r=n.org?.trim().toLowerCase(),i=(await e.listSkills()).filter(e=>e.name===t.name&&(!r||e.organizationId.toLowerCase()===r||e.organizationName.toLowerCase()===r));if(i.length===0)return null;if(i.length>1)throw Error(`More than one of your organizations has a skill named "${t.name}". Say which with --org: ${i.map(e=>e.organizationName).join(`, `)}.`);let a=i[0];if(!n.force)throw Error(`${a.organizationName} already has a skill named "${t.name}", and this folder didn't come from it. Push with --force to save your folder as its next version, or get it with \`a-kit pull ${t.name} --force\`.`);return e.getSkill(a.id)}async function ho(e,t,n,r){let i=await X(e.lockFile),a=r.name!==e.name&&/^[a-z0-9-]+$/.test(r.name)&&!e.folders.some(e=>l(p(f(e),r.name)))&&!i.skills[r.name],o=a?r.name:e.name,s=/* @__PURE__ */ new Set([...e.folders,t]),c=t;for(let e of s){let r=p(f(e),o);e===t&&(c=r),(e!==t||a)&&(await ln(r,n),a&&await k(e,{recursive:!0,force:!0}))}return a&&delete i.skills[e.name],i.skills[o]={id:r.id,version:r.version,agents:e.agents.map(e=>e.id)},await mi(e.lockFile,i),{folder:c,renamed:a}}function go(e,t){let n=e.lastIndexOf(`/`);return n===-1?{name:e,org:t}:{name:e.slice(n+1),org:t??e.slice(0,n)}}async function _o(e,t){let n=t.global?`global`:`project`,{api:r}=await $(),i=e.length===0,a=i?Object.keys((await X(Y(n))).skills):e,o=yo(r,t),s=0,c=0;for(let e of a){let{name:a,org:l}=go(e,t.org);try{let e=await ja(a,n,t.agent);if(i&&e.existing.length===0)continue;let c=await po(r,e,{force:t.force,org:l,organization:()=>o(l)});if(c.kind===`unchanged`){i||Ha(`${a} is up to date (v${c.skill.version}).`);continue}vo(c),s++}catch(e){if(c++,e instanceof uo)Wa(a,e);else if(i)Va(`${a}: ${e instanceof Error?e.message:e}`);else throw e}}i&&s===0&&c===0&&Ha(`Nothing to push.`),c>0&&(process.exitCode=1)}function vo(e){let{skill:t}=e;Ba(Ua(t.name,t.version,e.renamedFrom)+(e.kind===`created`?`, new in agent kit`:``)),Ga(e.warnings,t=>dn(e.files,t))}function yo(e,t){let n;return async r=>(n??=e.listOrganizations(),(await en(await n,r,!t.yes)).id)}async function bo(e,t){if(!e)throw Error("Name the skill to watch, like `a-kit dev release`.");let n=t.global?`global`:`project`,r=go(e,t.org),{api:i}=await $(),a=yo(i,t),o=r.name,s=await ja(o,n,t.agent),{folder:c}=await Ma(s,async()=>s.entry?(await i.getVersion(s.entry.id,s.entry.version)).files:null),l=``,d=!1,f,p,m=new Promise(e=>p=e),h=e=>{f?.close(),g.stop(),process.exitCode=e,p()},g=ka(async()=>{try{let e=await ja(o,n,t.agent),s=await po(i,e,{force:t.force,source:c,org:r.org,organization:()=>a(r.org)}),u=JSON.stringify(s.warnings.map(e=>e.message)),{version:f}=s.skill;if(s.kind===`unchanged`){d&&Ba(`fixed, and the same as v${f}; nothing to push`),d=!1;return}d=!1,Ba(s.kind===`created`?`${s.skill.name} is new in agent kit → v${f}`:`${un(s.changed)} changed → v${f}`+(s.renamedFrom?` (renamed to ${s.skill.name})`:``)),u!==l&&(Ga(s.warnings,e=>dn(s.files,e)),l=u),s.folder!==c&&(o=s.skill.name,c=s.folder,v())}catch(e){e instanceof uo?(Wa(o,e),l=``,d=!0):e instanceof fo?(Va(e.message),h(1)):xo(e)?(Va(`${V(c)} is gone; stopped watching.`),h(1)):e instanceof Z&&e.status===401?(Va(e.message),h(1)):(Va(e instanceof Error?e.message:String(e)),d=!0)}},300);function v(){f?.close(),f=u(c,{recursive:!0},(e,t)=>{let n=t?.toString().split(_).join(`/`);n&&nn(n)||g.trigger()}),f.on(`error`,()=>{Va(`Can't watch ${V(c)} anymore; stopped.`),h(1)}),console.log(`watching ${V(c)} …`)}v(),g.trigger();let y=()=>h(0);process.once(`SIGINT`,y),process.once(`SIGTERM`,y),await m,process.off(`SIGINT`,y),process.off(`SIGTERM`,y)}const xo=e=>typeof e==`object`&&!!e&&e.code===`ENOENT`;async function So(e){Et(`agent kit`);let t=await na();t?L.success(`Logged in as ${t.user.email}`):t=await ta();let n=Q(G(),t.token),r=await n.listSkills();if(r.length===0){R(`You don't have skills yet. Create one at ${t.webUrl}/app/skills, then run \`a-kit add\`.`);return}let i=!e.yes;if(i&&!z())throw Error("`a-kit init` asks questions. Pass --yes to install every skill, or use `a-kit add <skill>`.");let a=await Wt(e.global,i),o=await Ut(e.agent,i),s=i?B(await wt({message:`Which skills?`,options:r.map(e=>({value:e.id,label:$t(e)})),initialValues:r.map(e=>e.id),required:!0})):r.map(e=>e.id),{dirs:c}=await Ta(n,r.filter(e=>s.includes(e.id)),o,a,e.channel,{catalog:r,ask:i});R(`Installed in ${c.map(V).join(`, `)}`)}async function Co(e,t){switch(e){case`send`:t&&(process.env.AGENT_KIT_API_URL=t),await Qi();return;case`on`:{if(await ui({heartbeat:!0}),!await q()){L.warn("Heartbeats are on; they start once you run `a-kit login`.");return}if(!Di()){L.warn(`Run it from the published CLI to install the timer.`);return}await $i();let e=await Ki(G()),t=(await Zi())?.ok??!1;e?L.success(`Heartbeats are on${t?`; this machine is on your Machines page`:``}.`):L.warn(`Heartbeats are on, but this system has no timer agent kit can use (only Linux with systemd and macOS). It still reports when you install, update, or start Claude Code.`);return}case`off`:await ui({heartbeat:!1}),await Gi(G()),L.success("Heartbeats are off: this machine stops reporting. It stays on the Machines page until someone forgets it there. Turn them back on with `a-kit heartbeat on`.");return;case void 0:case`status`:{let e=(await J()).heartbeat!==!1,t=await Ki(G()),n=await Zi();console.log(`Heartbeats are ${e?`on`:`off`}.`),console.log(`Timer: ${t?Vi(G()).join(`, `):`not installed`}.`),n&&console.log(`Last heartbeat: ${new Date(n.sentAt).toLocaleString()}${n.ok?``:` (it didn't go through)`}.`),console.log(`
274
+ Every 5 minutes, a system timer tells agent kit this machine's name, the CLI's version, the agents on it and the skills installed everywhere (-g), so your organization's Machines page shows whether it's on and up to date. Logging in, installing and updating send it too.`);return}default:throw Error(`Unknown heartbeat action "${e}". Use on, off or status.`)}}const wo=()=>p(K(),`auto-update.json`);async function To(e=Date.now(),t=36e5,n=wo()){if(Eo(await Do(n),e,t))return!1;await D(f(n),{recursive:!0});let r=`${n}.claim`;try{await A(r,``,{flag:`wx`})}catch{let e=await re(r).then(e=>e.mtimeMs,()=>null);return e!==null&&Date.now()-e>6e4&&await ie(r).catch(()=>{}),!1}try{return!Eo(await Do(n),e,t)&&(await A(n,JSON.stringify({startedAt:e})+`
275
+ `),!0)}finally{await ie(r).catch(()=>{})}}const Eo=(e,t,n)=>e!==null&&t-e<n&&e<=t;async function Do(e){try{let{startedAt:t}=JSON.parse(await O(e,`utf8`));return typeof t==`number`?t:null}catch{return null}}const Oo=(e,t)=>{le(process.execPath,[e,...t],{cwd:y(),detached:!0,stdio:`ignore`,windowsHide:!0}).unref()};async function ko(e,t=Oo,n=Date.now()){if((await J()).autoUpdate===!1)return!1;let r=await X(Y(`global`));return Object.keys(r.skills).length===0&&Object.keys(r.kits).length===0||!await q()||!await To(n)?!1:(t(e,[`update`,`--global`]),!0)}async function Ao(e,t){try{if(t&&(process.env.AGENT_KIT_API_URL=t),e!==`claude-code`||process.stdin.isTTY)return;let n=JSON.parse(await jo());if(n.hook_event_name===`SessionStart`){await ko(Di()??Ei()),await Ki(G())||await Qi();return}if(di()||(await J()).telemetry===!1)return;let r=pa(n);if(!r)return;let i=await ki(r.name,e,typeof n.cwd==`string`?n.cwd:process.cwd());if(!i)return;let a=await q();if(!a)return;let o=Q(G(),a.token);await Pi(async e=>{await o.reportActivations(e,AbortSignal.timeout(5e3))},await Mi(i,e,r.trigger))}catch{}}async function jo(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}function Mo(e){return{always:e.description,max:e.description+e.body+e.files}}function No(e){let t=0,n=0,r=0,i=!1;for(let a of e){if(!a){r++;continue}let e=Mo(a);t+=e.always,n+=e.max,a.source===`estimate`&&(i=!0)}return{always:t,max:n,missing:r,estimated:i}}function Po(e){let t=Math.abs(e);return t<1e3?`${Math.round(e)}t`:t<9950?`${Io((e/1e3).toFixed(1))}k`:t<999500?`${Math.round(e/1e3)}k`:`${Io((e/1e6).toFixed(1))}M`}const Fo=(e,t)=>`${t===`estimate`?`~`:``}${Po(e)}`,Io=e=>e.replace(/\.0$/,``);function Lo(e,t,n){let r=e.map(e=>{let r=t.skills[e.name],i=n.skills[e.name],a=e.contextCost,o=e=>a?Fo(e,a.source):`—`;return{skill:e,installed:r!==void 0||i!==void 0,cells:[$t(e),Ro(e),o(a?.description??0),o(a?.body??0),o(a?.files??0),[zo(`project`,r,e),zo(`global`,i,e)].filter(Boolean).join(`, `)]}}),i=[`SKILL`,`VERSION`,`DESC`,`BODY`,`FILES`,`INSTALLED`],a=i.map((e,t)=>Math.max(e.length,...r.map(e=>e.cells[t].length))),o=e=>e.map((t,n)=>n===e.length-1?t:t.padEnd(a[n])).join(` `).trimEnd(),s=r.filter(e=>e.installed),c=No(s.map(e=>e.skill.contextCost)),l=c.estimated?`~`:``,u=[o(i),...r.map(e=>o(e.cells))];return u.push(s.length===0?`${`TOTAL`.padEnd(a[0])} nothing installed here`:`${`TOTAL`.padEnd(a[0])} ${l}${Po(c.always)} always · ${l}${Po(c.max)} max (${s.length} installed${c.missing?`, ${c.missing} not counted yet`:``})`),r.some(e=>e.skill.contextCost?.source===`estimate`)&&u.push(`~ estimated locally: add a Claude API key to the organization to count exactly.`),u}function Ro(e){return[`v${e.version}`,...Mt.filter(t=>e.channels[t]!==null).map(t=>`${t} v${e.channels[t]}`)].join(` · `)}function zo(e,t,n){if(!t)return null;let r=pi(t),{version:i}=It(n.channels,n.version,r),a=`in ${e}${r===`latest`?``:` on ${r}`}`;return t.version===i?a:`${a} at v${t.version}, run a-kit update${e===`global`?` -g`:``}`}async function Bo(){let{api:e,credentials:t}=await $(),[n,r]=await Promise.all([e.listSkills(),e.listKits()]);if(n.length===0){console.log(`You don't have skills yet. Create one at ${t.webUrl}/app/skills`);return}let i=await X(Y(`project`)),a=await X(Y(`global`));for(let e of Lo(n,i,a))console.log(e);if(r.length===0)return;console.log(``);let o=Math.max(...r.map(e=>Vo(e).length));for(let e of r){let t=[Ho(i,e)&&`in project`,Ho(a,e)&&`in global`].filter(Boolean);console.log(`${Vo(e).padEnd(o)} ${Uo(e)}`+(t.length?` (${t.join(`, `)})`:``))}}const Vo=e=>`${Gt}${$t(e)}`,Ho=(e,t)=>Object.values(e.kits).some(e=>e.id===t.id);function Uo(e){let t=e.skills.length;if(t===0)return`no skills`;let n=e.skills.slice(0,3).map(e=>e.name);return`${t} skill${t===1?``:`s`}: ${n.join(`, `)}${t>3?`, …`:``}`}async function Wo(){Et(`agent kit`);let e=await ta();R(`Logged in as ${e.user.email}`)}async function Go(){let e=await q();e?(await Q(G(),e.token).logout().catch(()=>{}),await ci(null),console.log(`Logged out ${e.user.email}.`)):console.log(`You're not logged in.`)}async function Ko(){let e=await na();e?console.log(e.user.email):(console.log("You're not logged in. Run `a-kit login`."),process.exitCode=1)}async function qo(e,t){if(e.length===0)throw Error("Name the skill to pull, like `a-kit pull release`. To refresh every installed skill, run `a-kit update`.");let n=t.global?`global`:`project`,r=!t.yes,{api:i}=await $(),a,o=/* @__PURE__ */ new Set;for(let s of e){let{name:e,org:c}=go(s,t.org),l=await ja(e,n,t.agent),u=l.entry?.id;if(!u){a??=await i.listSkills();let[o]=await qt(a,[c?`${c}/${e}`:e],r);u=o.id,l.existing.length===0&&t.agent.length===0&&(l=await ja(e,n,(await Ut([],r)).map(e=>e.id)))}let d=await bi(i,l,u,{force:t.force});for(let e of l.agents)o.add(e.id);await Ca([...new Set(l.folders.map(e=>f(e)))]),d.kind===`unchanged`?Ha(`${d.skill.name} is up to date (v${d.skill.version}).`):Ba(`${d.skill.name} v${d.skill.version}`+(d.from!==null&&d.from!==d.skill.version?` (was v${d.from})`:``))}await ya([...o])}const Jo={maxTitleLength:120,maxNoteLength:4e3,maxSkills:50,maxTranscriptBytes:8388608},Yo=[{kind:`private-key`,pattern:/-----BEGIN [A-Z ]*PRIVATE KEY-----[\s\S]*?(?:-----END [A-Z ]*PRIVATE KEY-----|$)/g,strict:!0},{kind:`anthropic-key`,pattern:/\bsk-ant-[A-Za-z0-9_-]{20,}/g,strict:!0},{kind:`openai-key`,pattern:/\bsk-(?:proj-|svcacct-)?[A-Za-z0-9_-]{32,}/g,strict:!0},{kind:`github-token`,pattern:/\b(?:gh[pousr]_[A-Za-z0-9]{36,}|github_pat_[A-Za-z0-9_]{40,})/g,strict:!0},{kind:`aws-key`,pattern:/\b(?:AKIA|ASIA)[0-9A-Z]{16}\b/g,strict:!0},{kind:`slack-token`,pattern:/\bxox[abprs]-[A-Za-z0-9-]{10,}/g,strict:!0},{kind:`stripe-key`,pattern:/\b[rs]k_(?:live|test)_[A-Za-z0-9]{16,}/g,strict:!0},{kind:`google-key`,pattern:/\bAIza[0-9A-Za-z_-]{35}\b/g,strict:!0},{kind:`jwt`,pattern:/\beyJ[A-Za-z0-9_-]{8,}\.eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}/g,strict:!0},{kind:`url-credentials`,pattern:/\b([a-z][a-z0-9+.-]*:\/\/)[^\s:/@]+:[^\s@/]+@/gi,keep:(e,t)=>`${t}<secret>@`,strict:!1},{kind:`bearer`,pattern:/\b(Bearer\s+)[A-Za-z0-9._~+/-]{20,}=*/g,keep:(e,t)=>`${t}<secret>`,strict:!1},{kind:`assignment`,pattern:/\b([A-Za-z0-9_]*(?:secret|token|password|passwd|api_?key|private_?key|access_?key)[A-Za-z0-9_]*["']?\s*[=:]\s*)(["']?)(?!<secret)[^\s"'`,;]{8,}\2/gi,keep:(e,t,n)=>`${t}${n}<secret>${n}`,strict:!1}],Xo=/[A-Za-z0-9._%+-]+@[A-Za-z0-9-]+(?:\.[A-Za-z0-9-]+)*\.[A-Za-z]{2,}\b/g,Zo=/\b(?:(?:25[0-5]|2[0-4]\d|1?\d?\d)\.){3}(?:25[0-5]|2[0-4]\d|1?\d?\d)\b/g,Qo=/* @__PURE__ */ new Set([`127.0.0.1`,`0.0.0.0`]),$o=/@(?:example\.(?:com|org|net)|anthropic\.com)$/i,es=e=>e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`);function ts(e){let t={},n=(e,n=1)=>{t[e]=(t[e]??0)+n},r=e.paths.filter(e=>e.path.length>1).sort((e,t)=>t.path.length-e.path.length).map(e=>({...e,pattern:new RegExp(es(e.path),`g`)})),i=e.replacements.filter(e=>e.find.trim().length>1).sort((e,t)=>t.find.length-e.find.length).map(e=>({...e,pattern:new RegExp(e.find.length<4?`(?<![\\p{L}\\p{N}_])${es(e.find)}(?![\\p{L}\\p{N}_])`:es(e.find),`giu`)}));function a(e){let t=e;for(let e of Yo)t=t.replace(e.pattern,(t,...r)=>(n(`secret:${e.kind}`),e.keep?e.keep(t,...r):`<secret>`));for(let e of r)t=t.replace(e.pattern,()=>(n(`path:${e.as}`),e.as));for(let e of i)t=t.replace(e.pattern,()=>(n(`term:${e.find}`),e.replace));return t=t.replace(Xo,e=>$o.test(e)?e:(n(`email`),`user@example.com`)),t=t.replace(Zo,e=>Qo.has(e)?e:(n(`ip`),`192.0.2.1`)),t}function o(t){let r=e.maxToolText;return r===null||t.length<=r?t:(n(`cut`),`${t.slice(0,r)}\n… [${t.length-r} more characters left out by a-kit report]`)}function s(e){return typeof e==`string`?o(a(e)):Array.isArray(e)?e.map(s):typeof e==`object`&&e?Object.fromEntries(Object.entries(e).map(([e,t])=>[e,s(t)])):e}function c(e){return e.type===`text`?{...e,text:a(e.text)}:e.type===`tool_use`?{...e,input:s(e.input)}:{...e,content:o(a(e.content))}}function l(e){return e.map(e=>e.type===`system`?e:{...e,message:{content:e.message.content.map(c)}})}return{text:a,events:l,counts:t}}const ns=e=>e.map(e=>JSON.stringify(e)).join(`
270
276
  `)+`
271
- `;function Fo(e){let t=[],n=null,r=null,i=null;for(let a of e.split(`
272
- `)){if(!a.trim())continue;let e;try{e=JSON.parse(a)}catch{continue}if(e.type!==`user`&&e.type!==`assistant`||e.isSidechain||e.isMeta)continue;r=e.version??r,i=e.cwd??i,e.type===`assistant`&&e.message?.model&&(e.message.model.startsWith(`<`)||(n=e.message.model));let o=Io(e.message?.content);o.length>0&&t.push({type:e.type,message:{content:o}})}return{agent:`claude-code`,agentVersion:r,model:n,cwd:i,events:[{type:`system`,subtype:`init`,agent:`Claude Code`,agent_version:r,model:n},...t],loaded:[...new Set(t.flatMap(qr))]}}function Io(e){if(typeof e==`string`)return e.trim()?[{type:`text`,text:e}]:[];if(!Array.isArray(e))return[];let t=[];for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text.trim()?t.push({type:`text`,text:n.text}):n.type===`tool_use`?t.push({type:`tool_use`,id:String(n.id??``),name:String(n.name??``),input:n.input??{}}):n.type===`tool_result`&&t.push({type:`tool_result`,tool_use_id:String(n.tool_use_id??``),content:Lo(n.content),...n.is_error===!0?{is_error:!0}:{}});return t}function Lo(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>e.type===`text`&&typeof e.text==`string`?e.text:e.type===`image`?`[image]`:``).filter(Boolean).join(`
273
- `):``}const Ro=[/^# AGENTS\.md instructions/,/^<(environment_context|user_instructions|permissions instructions|turn_aborted)>/];function zo(e){let t=[],n=null,r=null,i=null,a=(e,n)=>t.push({type:e,message:{content:[n]}});for(let t of e.split(`
274
- `)){if(!t.trim())continue;let e;try{e=JSON.parse(t)}catch{continue}let o=e.payload??{};if(e.type===`session_meta`)r=Vo(o.cli_version)??r,i=Vo(o.cwd)??i;else if(e.type===`turn_context`)n=Vo(o.model)??n,i=Vo(o.cwd)??i;else if(e.type===`response_item`){if(o.type===`message`){let e=o.role;if(e!==`user`&&e!==`assistant`)continue;let t=Ho(o.content);if(!t.trim()||e===`user`&&Ro.some(e=>e.test(t.trim())))continue;a(e,{type:`text`,text:t})}else o.type===`function_call`||o.type===`custom_tool_call`?a(`assistant`,{type:`tool_use`,id:String(o.call_id??o.id??``),name:String(o.name??``),input:o.type===`function_call`?Uo(o.arguments):{input:o.input??``}}):o.type===`function_call_output`||o.type===`custom_tool_call_output`?a(`user`,{type:`tool_result`,tool_use_id:String(o.call_id??``),content:Wo(o.output)}):o.type===`local_shell_call`&&a(`assistant`,{type:`tool_use`,id:String(o.call_id??o.id??``),name:`shell`,input:o.action??{}})}}return{agent:`codex`,agentVersion:r,model:n,cwd:i,events:[{type:`system`,subtype:`init`,agent:`Codex`,agent_version:r,model:n},...t],loaded:[...new Set(t.flatMap(qr))]}}function Bo(e){try{let t=JSON.parse(e);return t.type===`session_meta`?Vo(t.payload?.cwd):null}catch{return null}}const Vo=e=>typeof e==`string`&&e?e:null;function Ho(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e.text==`string`?e.text:``).filter(Boolean).join(`
275
- `):``}function Uo(e){if(typeof e!=`string`)return e??{};try{return JSON.parse(e)}catch{return{arguments:e}}}function Wo(e){if(typeof e==`string`){try{let t=JSON.parse(e);if(typeof t?.output==`string`)return t.output}catch{}return e}if(Array.isArray(e))return Ho(e);if(typeof e==`object`&&e){let{content:t,output:n}=e;if(typeof n==`string`)return n;if(t!==void 0)return Wo(t)}return JSON.stringify(e??``)}const Go=()=>process.env.CLAUDE_CONFIG_DIR??p(v(),`.claude`),Ko=()=>process.env.CODEX_HOME??p(v(),`.codex`),qo=(e,t=Go())=>p(t,`projects`,e.replace(/[^A-Za-z0-9]/g,`-`));async function Jo(e,t,n=process.cwd()){if(t&&l(t))return g(t);let r=e===`claude-code`?await Zo(t,n):await Qo(t,n);if(r)return r.file;throw Error(t?`No ${Xo(e)} session "${t}" on this machine.`:`No ${Xo(e)} session for ${n}. Run this from the folder the session runs in, or pass --session <id or path>.`)}async function Yo(e=process.cwd()){if(process.env.CLAUDECODE===`1`)return`claude-code`;if(Object.keys(process.env).some(e=>e.startsWith(`CODEX_`)))return`codex`;let[t,n]=await Promise.all([Zo(void 0,e),Qo(void 0,e)]);if(t&&(!n||t.mtime>=n.mtime))return`claude-code`;if(n)return`codex`;throw Error(`No Claude Code or Codex session for ${e}. Pass --agent and --session.`)}const Xo=e=>e===`claude-code`?`Claude Code`:`Codex`;async function Zo(e,t){if(e){let t=p(Go(),`projects`),n=await rs(t);for(let r of n){let n=p(t,r,`${e}.jsonl`);if(l(n))return{file:n,mtime:0}}return null}for(let e of is(t)){let t=qo(e),n=(await rs(t)).filter(e=>e.endsWith(`.jsonl`));if(n.length>0)return ns(n.map(e=>p(t,e)))}return null}async function Qo(e,t){let n=p(Ko(),`sessions`),r=[],i=0;outer:for(let e of $o(await rs(n)))for(let t of $o(await rs(p(n,e))))for(let a of $o(await rs(p(n,e,t)))){let o=p(n,e,t,a);for(let e of await rs(o))e.startsWith(`rollout-`)&&e.endsWith(`.jsonl`)&&r.push(p(o,e));if(r.length>=300||++i>=14)break outer}return es(r,e,t)}const $o=e=>e.sort().reverse();async function es(e,t,n){if(t){let n=e.find(e=>d(e).includes(t));return n?{file:n,mtime:0}:null}let r=is(n),i=/* @__PURE__ */ new Map;for(let t of e){let e=await ts(t);e&&r.includes(e)&&i.set(e,[...i.get(e)??[],t])}for(let e of r){let t=i.get(e);if(t)return ns(t)}return null}async function ts(e){let t=await E(e,`r`);try{let e=Buffer.alloc(262144),{bytesRead:n}=await t.read(e,0,e.length,0),r=e.subarray(0,n).toString(`utf8`),i=r.indexOf(`
276
- `);return Bo(i===-1?r:r.slice(0,i))??(JSON.parse(`"${r.match(/"cwd":"((?:[^"\\]|\\.)*)"/)?.[1]??``}"`)||null)}finally{await t.close()}}async function ns(e){let t=null;for(let n of e){let{mtimeMs:e}=await ne(n);(!t||e>t.mtime)&&(t={file:n,mtime:e})}return t}async function rs(e){try{return await ee(e)}catch{return[]}}function is(e){let t=[g(e)];for(;f(t.at(-1))!==t.at(-1);)t.push(f(t.at(-1)));return t}const as=2e3;function os(e){let t=[...e.map],n=ls(()=>x().username);n&&n.length>=3&&t.push({find:n,replace:`user`});let r=ls(()=>y());r&&r.length>=3&&r!==`localhost`&&t.push({find:r,replace:`host`});let i=ss();if(i){t.push({find:i,replace:`acme/app`});let e=i.split(`/`)[0];e.length>=3&&t.push({find:e,replace:`acme`})}let a=ls(()=>oe(`git`,[`rev-parse`,`--show-toplevel`],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim());return{replacements:t,paths:[...[...new Set([...e.cwds,a].filter(Boolean))].map(e=>({path:e,as:`<repo>`})),{path:v(),as:`~`}],maxToolText:e.fullOutputs?null:as}}function ss(){return ls(()=>oe(`git`,[`remote`,`get-url`,`origin`],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim())?.match(/[:/]([^/:]+\/[^/]+?)(?:\.git)?$/)?.[1]??null}function cs(e){let t;try{t=JSON.parse(e)}catch{throw Error(`--map isn't valid JSON.`)}let n=Array.isArray(t)?t.map(e=>[e?.find,e?.replace]):typeof t==`object`&&t?Object.entries(t):null;if(!n||!n.every(([e,t])=>typeof e==`string`&&typeof t==`string`))throw Error(`--map must be an object of words to replace, like {"Acme Corp": "Example Inc"}.`);return n.map(([e,t])=>({find:e,replace:t}))}function ls(e){try{return e()}catch{return null}}function us(e,t,n){let r=new Set(t),i=/* @__PURE__ */ new Map;for(let t of n)for(let[n,a]of Object.entries(t.skills))fs(a.agents,e)&&(i.has(n)||i.set(n,{name:n,skillId:a.id,version:a.version,triggered:r.has(n)}));for(let e of t)e===`report-session-issue`||i.has(e)||i.set(e,{name:e,skillId:null,version:null,triggered:!0});return i.delete(Vr),[...i.values()]}const ds=[`codex`,`cursor`,`gemini-cli`],fs=(e,t)=>e.length===0||e.includes(t)||ds.includes(t)&&e.some(e=>ds.includes(e));async function ps(e){wt(`agent kit report`);let t=await ms(e.agent[0]),n=await Jo(t,e.session||void 0),r=await D(n,`utf8`),i=Gr(t===`claude-code`?Fo(r):zo(r));if(i.events.length<2)throw Error(`${n} has no conversation to report.`);let a=No(os({map:e.map?cs(await hs(e.map)):[],cwds:i.cwd?[i.cwd]:[],fullOutputs:e.fullOutputs})),o=a.text(_s(e.title,`--title`,`a short title`)),s=a.text(_s(e.note,`--note`,`what went wrong`)),c=e.expected?a.text(e.expected):null,l=Po(a.events(i.events)),u=await Promise.all([X(Y(`project`)),X(Y(`global`))]),d=us(t,i.loaded,u),f={title:o,note:s,expected:c,agent:t,agentVersion:i.agentVersion,model:i.model,skills:d,transcript:l},m=p(b(),`a-kit-report-${Date.now()}.jsonl`);if(await k(m,l),I.info([`${Xo(t)} session: ${n}`,`Model: ${i.model??`unknown`}, ${i.events.length-1} messages`,`Skills: ${ys(d)}`,`Taken out: ${bs(a.counts)}`,`Scrubbed transcript: ${m}`].join(`
277
- `)),Buffer.byteLength(l)>Eo.maxTranscriptBytes)throw Error(`The transcript is over ${Eo.maxTranscriptBytes/1024/1024} MB.${e.fullOutputs?` Leave out --full-outputs.`:``}`);if(e.dryRun){L(`Nothing was sent. Check the file above, then run it again without --dry-run.`);return}if(!e.yes){if(!R())throw Error(`Check the scrubbed transcript, then pass --yes to send it.`);if(!z(await yt({message:`Send this report to agent kit?`}))){L(`Not sent.`);return}}let{api:h,credentials:g}=await Q(),[_,v]=await Promise.all([h.listOrganizations(),h.listSkills()]),y=vs(e.org,_,v,d),x=await h.createReport(y.id,f);L(`Reported: ${g.webUrl}/app/orgs/${y.id}/reports/${x.id}`)}async function ms(e){if(e===void 0)return Yo();if(e===`claude-code`||e===`codex`)return e;throw Error(`a-kit report reads Claude Code and Codex sessions; --agent must be claude-code or codex.`)}const hs=e=>e===`-`?gs():D(e,`utf8`);async function gs(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}function _s(e,t,n){if(!e?.trim())throw Error(`Pass ${t} with ${n}.`);return e}function vs(e,t,n,r){let i=()=>t.map(e=>`${e.name} (${e.id})`).join(`, `);if(e){let n=t.filter(t=>t.id===e||t.name===e);if(n.length===1)return n[0];throw Error(`--org: none of your organizations is "${e}". Yours: ${i()}`)}let a=new Set(r.map(e=>e.skillId).filter(Boolean)),o=new Set(n.filter(e=>a.has(e.id)).map(e=>e.organizationId));if(o.size===1){let e=t.find(e=>o.has(e.id));if(e)return e}if(t.length===1)return t[0];throw Error(`Which organization is it for? Pass --org with one of: ${i()}`)}function ys(e){return e.length===0?`none`:e.map(e=>`${e.name}${e.version?` v${e.version}`:``}${e.triggered?` (loaded)`:``}`).join(`, `)}function bs(e){let t=Object.entries(e);return t.length===0?`nothing`:t.map(([e,t])=>e===`cut`?`${t} tool outputs cut to ${as} characters`:`${e} ×${t}`).join(`, `)}function xs(e){return e&&e.total>0?e.passed/e.total:null}async function Ss(e){let{api:t,credentials:n}=await Q(),[r,i]=await Promise.all([t.search(e.join(` `)),t.listOrganizations()]);console.log(Cs(r,n.webUrl,i.length>1))}function Cs({skills:e,runs:t},n,r){if(e.length===0&&t.length===0)return`Nothing matches.`;let i=[];if(e.length>0){let t=e.map(e=>Zt({...e,showOrganization:r})),n=Math.max(...t.map(e=>e.length));i.push(`Skills`),e.forEach((e,r)=>{i.push(` ${t[r].padEnd(n)} v${e.version} a-kit add ${e.name}`)})}if(t.length>0){i.length>0&&i.push(``);let e=t.map(e=>`${e.skillName} v${e.version}`),r=Math.max(...e.map(e=>e.length));i.push(`Runs`),t.forEach((t,a)=>{let o=xs(t.withSkill),s=o===null?`—`:`${Math.round(o*100)}%`;i.push(` ${e[a].padEnd(r)} ${s.padStart(4)} ${t.status.padEnd(9)} ${n}/app/skills/${t.skillId}?tab=runs&run=${t.id}`)})}return i.join(`
278
- `)}async function ws(e){switch(e){case`on`:{await si({telemetry:!0});let e=await Hi();e.status===`skipped`?I.warn(`Couldn't add the Claude Code hook: ${e.reason}.`):I.success(`Telemetry is on: Claude Code reports the skills it loads.`);return}case`off`:await si({telemetry:!1}),await Hi(),I.success("Telemetry is off: Claude Code doesn't report the skills it loads. Turn it back on with `a-kit telemetry on`.");return;case void 0:case`status`:{let e=await oi(),t=(await Ui()).includes(`telemetry`),n=e.telemetry===!1?`off`:ci()?`off in this environment (DO_NOT_TRACK or AGENT_KIT_TELEMETRY)`:`on`;console.log(`Telemetry is ${n}.`),console.log(`Claude Code: ${t?`reports the skills it loads`:`no hook installed`}.`),console.log(`
277
+ `;function rs(e){let t=[],n=null,r=null,i=null;for(let a of e.split(`
278
+ `)){if(!a.trim())continue;let e;try{e=JSON.parse(a)}catch{continue}if(e.type!==`user`&&e.type!==`assistant`||e.isSidechain||e.isMeta)continue;r=e.version??r,i=e.cwd??i,e.type===`assistant`&&e.message?.model&&(e.message.model.startsWith(`<`)||(n=e.message.model));let o=is(e.message?.content);o.length>0&&t.push({type:e.type,message:{content:o}})}return{agent:`claude-code`,agentVersion:r,model:n,cwd:i,events:[{type:`system`,subtype:`init`,agent:`Claude Code`,agent_version:r,model:n},...t],loaded:[...new Set(t.flatMap(Qr))]}}function is(e){if(typeof e==`string`)return e.trim()?[{type:`text`,text:e}]:[];if(!Array.isArray(e))return[];let t=[];for(let n of e)n.type===`text`&&typeof n.text==`string`&&n.text.trim()?t.push({type:`text`,text:n.text}):n.type===`tool_use`?t.push({type:`tool_use`,id:String(n.id??``),name:String(n.name??``),input:n.input??{}}):n.type===`tool_result`&&t.push({type:`tool_result`,tool_use_id:String(n.tool_use_id??``),content:as(n.content),...n.is_error===!0?{is_error:!0}:{}});return t}function as(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>e.type===`text`&&typeof e.text==`string`?e.text:e.type===`image`?`[image]`:``).filter(Boolean).join(`
279
+ `):``}const os=[/^# AGENTS\.md instructions/,/^<(environment_context|user_instructions|permissions instructions|turn_aborted)>/];function ss(e){let t=[],n=null,r=null,i=null,a=(e,n)=>t.push({type:e,message:{content:[n]}});for(let t of e.split(`
280
+ `)){if(!t.trim())continue;let e;try{e=JSON.parse(t)}catch{continue}let o=e.payload??{};if(e.type===`session_meta`)r=ls(o.cli_version)??r,i=ls(o.cwd)??i;else if(e.type===`turn_context`)n=ls(o.model)??n,i=ls(o.cwd)??i;else if(e.type===`response_item`){if(o.type===`message`){let e=o.role;if(e!==`user`&&e!==`assistant`)continue;let t=us(o.content);if(!t.trim()||e===`user`&&os.some(e=>e.test(t.trim())))continue;a(e,{type:`text`,text:t})}else o.type===`function_call`||o.type===`custom_tool_call`?a(`assistant`,{type:`tool_use`,id:String(o.call_id??o.id??``),name:String(o.name??``),input:o.type===`function_call`?ds(o.arguments):{input:o.input??``}}):o.type===`function_call_output`||o.type===`custom_tool_call_output`?a(`user`,{type:`tool_result`,tool_use_id:String(o.call_id??``),content:fs(o.output)}):o.type===`local_shell_call`&&a(`assistant`,{type:`tool_use`,id:String(o.call_id??o.id??``),name:`shell`,input:o.action??{}})}}return{agent:`codex`,agentVersion:r,model:n,cwd:i,events:[{type:`system`,subtype:`init`,agent:`Codex`,agent_version:r,model:n},...t],loaded:[...new Set(t.flatMap(Qr))]}}function cs(e){try{let t=JSON.parse(e);return t.type===`session_meta`?ls(t.payload?.cwd):null}catch{return null}}const ls=e=>typeof e==`string`&&e?e:null;function us(e){return typeof e==`string`?e:Array.isArray(e)?e.map(e=>typeof e.text==`string`?e.text:``).filter(Boolean).join(`
281
+ `):``}function ds(e){if(typeof e!=`string`)return e??{};try{return JSON.parse(e)}catch{return{arguments:e}}}function fs(e){if(typeof e==`string`){try{let t=JSON.parse(e);if(typeof t?.output==`string`)return t.output}catch{}return e}if(Array.isArray(e))return us(e);if(typeof e==`object`&&e){let{content:t,output:n}=e;if(typeof n==`string`)return n;if(t!==void 0)return fs(t)}return JSON.stringify(e??``)}const ps=()=>process.env.CLAUDE_CONFIG_DIR??p(y(),`.claude`),ms=()=>process.env.CODEX_HOME??p(y(),`.codex`),hs=(e,t=ps())=>p(t,`projects`,e.replace(/[^A-Za-z0-9]/g,`-`));async function gs(e,t,n=process.cwd()){if(t&&l(t))return g(t);let r=e===`claude-code`?await ys(t,n):await bs(t,n);if(r)return r.file;throw Error(t?`No ${vs(e)} session "${t}" on this machine.`:`No ${vs(e)} session for ${n}. Run this from the folder the session runs in, or pass --session <id or path>.`)}async function _s(e=process.cwd()){if(process.env.CLAUDECODE===`1`)return`claude-code`;if(Object.keys(process.env).some(e=>e.startsWith(`CODEX_`)))return`codex`;let[t,n]=await Promise.all([ys(void 0,e),bs(void 0,e)]);if(t&&(!n||t.mtime>=n.mtime))return`claude-code`;if(n)return`codex`;throw Error(`No Claude Code or Codex session for ${e}. Pass --agent and --session.`)}const vs=e=>e===`claude-code`?`Claude Code`:`Codex`;async function ys(e,t){if(e){let t=p(ps(),`projects`),n=await Ts(t);for(let r of n){let n=p(t,r,`${e}.jsonl`);if(l(n))return{file:n,mtime:0}}return null}for(let e of Es(t)){let t=hs(e),n=(await Ts(t)).filter(e=>e.endsWith(`.jsonl`));if(n.length>0)return ws(n.map(e=>p(t,e)))}return null}async function bs(e,t){let n=p(ms(),`sessions`),r=[],i=0;outer:for(let e of xs(await Ts(n)))for(let t of xs(await Ts(p(n,e))))for(let a of xs(await Ts(p(n,e,t)))){let o=p(n,e,t,a);for(let e of await Ts(o))e.startsWith(`rollout-`)&&e.endsWith(`.jsonl`)&&r.push(p(o,e));if(r.length>=300||++i>=14)break outer}return Ss(r,e,t)}const xs=e=>e.sort().reverse();async function Ss(e,t,n){if(t){let n=e.find(e=>d(e).includes(t));return n?{file:n,mtime:0}:null}let r=Es(n),i=/* @__PURE__ */ new Map;for(let t of e){let e=await Cs(t);e&&r.includes(e)&&i.set(e,[...i.get(e)??[],t])}for(let e of r){let t=i.get(e);if(t)return ws(t)}return null}async function Cs(e){let t=await ee(e,`r`);try{let e=Buffer.alloc(262144),{bytesRead:n}=await t.read(e,0,e.length,0),r=e.subarray(0,n).toString(`utf8`),i=r.indexOf(`
282
+ `);return cs(i===-1?r:r.slice(0,i))??(JSON.parse(`"${r.match(/"cwd":"((?:[^"\\]|\\.)*)"/)?.[1]??``}"`)||null)}finally{await t.close()}}async function ws(e){let t=null;for(let n of e){let{mtimeMs:e}=await re(n);(!t||e>t.mtime)&&(t={file:n,mtime:e})}return t}async function Ts(e){try{return await te(e)}catch{return[]}}function Es(e){let t=[g(e)];for(;f(t.at(-1))!==t.at(-1);)t.push(f(t.at(-1)));return t}const Ds=2e3;function Os(e){let t=[...e.map],n=js(()=>C().username);n&&n.length>=3&&t.push({find:n,replace:`user`});let r=js(()=>b());r&&r.length>=3&&r!==`localhost`&&t.push({find:r,replace:`host`});let i=ks();if(i){t.push({find:i,replace:`acme/app`});let e=i.split(`/`)[0];e.length>=3&&t.push({find:e,replace:`acme`})}let a=js(()=>ce(`git`,[`rev-parse`,`--show-toplevel`],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim());return{replacements:t,paths:[...[...new Set([...e.cwds,a].filter(Boolean))].map(e=>({path:e,as:`<repo>`})),{path:y(),as:`~`}],maxToolText:e.fullOutputs?null:Ds}}function ks(){return js(()=>ce(`git`,[`remote`,`get-url`,`origin`],{encoding:`utf8`,stdio:[`ignore`,`pipe`,`ignore`]}).trim())?.match(/[:/]([^/:]+\/[^/]+?)(?:\.git)?$/)?.[1]??null}function As(e){let t;try{t=JSON.parse(e)}catch{throw Error(`--map isn't valid JSON.`)}let n=Array.isArray(t)?t.map(e=>[e?.find,e?.replace]):typeof t==`object`&&t?Object.entries(t):null;if(!n||!n.every(([e,t])=>typeof e==`string`&&typeof t==`string`))throw Error(`--map must be an object of words to replace, like {"Acme Corp": "Example Inc"}.`);return n.map(([e,t])=>({find:e,replace:t}))}function js(e){try{return e()}catch{return null}}function Ms(e,t,n){let r=new Set(t),i=/* @__PURE__ */ new Map;for(let t of n)for(let[n,a]of Object.entries(t.skills))Ps(a.agents,e)&&(i.has(n)||i.set(n,{name:n,skillId:a.id,version:a.version,triggered:r.has(n)}));for(let e of t)e===`report-session-issue`||i.has(e)||i.set(e,{name:e,skillId:null,version:null,triggered:!0});return i.delete(Kr),[...i.values()]}const Ns=[`codex`,`cursor`,`gemini-cli`],Ps=(e,t)=>e.length===0||e.includes(t)||Ns.includes(t)&&e.some(e=>Ns.includes(e));async function Fs(e){Et(`agent kit report`);let t=await Is(e.agent[0]),n=await gs(t,e.session||void 0),r=await O(n,`utf8`),i=Xr(t===`claude-code`?rs(r):ss(r));if(i.events.length<2)throw Error(`${n} has no conversation to report.`);let a=ts(Os({map:e.map?As(await Ls(e.map)):[],cwds:i.cwd?[i.cwd]:[],fullOutputs:e.fullOutputs})),o=a.text(zs(e.title,`--title`,`a short title`)),s=a.text(zs(e.note,`--note`,`what went wrong`)),c=e.expected?a.text(e.expected):null,l=ns(a.events(i.events)),u=await Promise.all([X(Y(`project`)),X(Y(`global`))]),d=Ms(t,i.loaded,u),f={title:o,note:s,expected:c,agent:t,agentVersion:i.agentVersion,model:i.model,skills:d,transcript:l},m=p(S(),`a-kit-report-${Date.now()}.jsonl`);if(await A(m,l),L.info([`${vs(t)} session: ${n}`,`Model: ${i.model??`unknown`}, ${i.events.length-1} messages`,`Skills: ${Vs(d)}`,`Taken out: ${Hs(a.counts)}`,`Scrubbed transcript: ${m}`].join(`
283
+ `)),Buffer.byteLength(l)>Jo.maxTranscriptBytes)throw Error(`The transcript is over ${Jo.maxTranscriptBytes/1024/1024} MB.${e.fullOutputs?` Leave out --full-outputs.`:``}`);if(e.dryRun){R(`Nothing was sent. Check the file above, then run it again without --dry-run.`);return}if(!e.yes){if(!z())throw Error(`Check the scrubbed transcript, then pass --yes to send it.`);if(!B(await xt({message:`Send this report to agent kit?`}))){R(`Not sent.`);return}}let{api:h,credentials:g}=await $(),[_,v]=await Promise.all([h.listOrganizations(),h.listSkills()]),y=Bs(e.org,_,v,d),b=await h.createReport(y.id,f);R(`Reported: ${g.webUrl}/app/orgs/${y.id}/reports/${b.id}`)}async function Is(e){if(e===void 0)return _s();if(e===`claude-code`||e===`codex`)return e;throw Error(`a-kit report reads Claude Code and Codex sessions; --agent must be claude-code or codex.`)}const Ls=e=>e===`-`?Rs():O(e,`utf8`);async function Rs(){let e=[];for await(let t of process.stdin)e.push(t);return Buffer.concat(e).toString(`utf8`)}function zs(e,t,n){if(!e?.trim())throw Error(`Pass ${t} with ${n}.`);return e}function Bs(e,t,n,r){let i=()=>t.map(e=>`${e.name} (${e.id})`).join(`, `);if(e){let n=t.filter(t=>t.id===e||t.name===e);if(n.length===1)return n[0];throw Error(`--org: none of your organizations is "${e}". Yours: ${i()}`)}let a=new Set(r.map(e=>e.skillId).filter(Boolean)),o=new Set(n.filter(e=>a.has(e.id)).map(e=>e.organizationId));if(o.size===1){let e=t.find(e=>o.has(e.id));if(e)return e}if(t.length===1)return t[0];throw Error(`Which organization is it for? Pass --org with one of: ${i()}`)}function Vs(e){return e.length===0?`none`:e.map(e=>`${e.name}${e.version?` v${e.version}`:``}${e.triggered?` (loaded)`:``}`).join(`, `)}function Hs(e){let t=Object.entries(e);return t.length===0?`nothing`:t.map(([e,t])=>e===`cut`?`${t} tool outputs cut to ${Ds} characters`:`${e} ×${t}`).join(`, `)}function Us(e){return e&&e.total>0?e.passed/e.total:null}async function Ws(e){let{api:t,credentials:n}=await $(),[r,i]=await Promise.all([t.search(e.join(` `)),t.listOrganizations()]);console.log(Gs(r,n.webUrl,i.length>1))}function Gs({skills:e,runs:t},n,r){if(e.length===0&&t.length===0)return`Nothing matches.`;let i=[];if(e.length>0){let t=e.map(e=>$t({...e,showOrganization:r})),n=Math.max(...t.map(e=>e.length));i.push(`Skills`),e.forEach((e,r)=>{i.push(` ${t[r].padEnd(n)} v${e.version} a-kit add ${e.name}`)})}if(t.length>0){i.length>0&&i.push(``);let e=t.map(e=>`${e.skillName} v${e.version}`),r=Math.max(...e.map(e=>e.length));i.push(`Runs`),t.forEach((t,a)=>{let o=Us(t.withSkill),s=o===null?`—`:`${Math.round(o*100)}%`;i.push(` ${e[a].padEnd(r)} ${s.padStart(4)} ${t.status.padEnd(9)} ${n}/app/skills/${t.skillId}?tab=runs&run=${t.id}`)})}return i.join(`
284
+ `)}async function Ks(e){switch(e){case`on`:{await ui({telemetry:!0});let e=await ga();e.status===`skipped`?L.warn(`Couldn't add the Claude Code hook: ${e.reason}.`):L.success(`Telemetry is on: Claude Code reports the skills it loads.`);return}case`off`:await ui({telemetry:!1}),await ga(),L.success("Telemetry is off: Claude Code doesn't report the skills it loads. Turn it back on with `a-kit telemetry on`.");return;case void 0:case`status`:{let e=await J(),t=(await _a()).includes(`telemetry`),n=e.telemetry===!1?`off`:di()?`off in this environment (DO_NOT_TRACK or AGENT_KIT_TELEMETRY)`:`on`;console.log(`Telemetry is ${n}.`),console.log(`Claude Code: ${t?`reports the skills it loads`:`no hook installed`}.`),console.log(`
279
285
  When an agent loads a skill installed from agent kit, it reports the skill, its version, the agent, this machine and when, so your organization sees which skills get used.
280
- Turn it off with \`a-kit telemetry off\`.`);return}default:throw Error(`Unknown telemetry action "${e}". Use on, off or status.`)}}async function Ts(e){wt(`agent kit`);let t=e.global?`global`:`project`,n=Y(t),r=await X(n);if(Object.keys(r.skills).length===0&&Object.keys(r.kits).length===0){L(e.global?"No skills installed everywhere yet. Add some with `a-kit add -g`.":"No skills installed in this project yet. Add some with `a-kit add`.");return}let{api:i}=await Q(),a=Xi(t),o=[...Object.values(r.skills).flatMap(e=>a(e.agents)),...Object.values(r.kits).flatMap(e=>a(e.agents))];await Yi([...new Set(o)]);let s=0,c=0,l=0;for(let[e,t]of Object.entries(r.kits)){let o;try{o=await i.getKit(t.id)}catch(t){if(t instanceof Z&&t.status===404){I.warn(`kit/${e} isn't in your agent kit anymore; left its skills as they are.`);continue}throw t}yi(r,e,o.name);try{let e=await bi(i,r,o,{agents:t.agents,dirsOf:a,reinstall:!1});for(let t of e.installed)I.success(`${t}: added to kit/${o.name}, installed`);for(let t of e.removed)I.success(`${t}: taken out of kit/${o.name}, removed`);s+=e.installed.length,c+=e.removed.length,l+=e.kept.length}finally{await di(n,r)}}let u=0;for(let[e,t]of Object.entries(r.skills)){let o=ui(t),s;try{s=await i.getSkill(t.id,o)}catch(t){if(t instanceof Z&&t.status===404){I.warn(`${e} isn't in your agent kit anymore; left it as it is.`);continue}throw t}if(s.version===t.version)continue;let c=a(t.agents),d=await hi(i,e,t,c);if(d)I.warn(`${e} has edits that aren't in agent kit (${cn(d.paths)}); left it at v${t.version}. Push them with \`a-kit push ${e}\`, or drop them with \`a-kit pull ${e} --force\`.`),l++;else{if(await ei(i,t.id,c,o),s.name!==e){for(let t of c)await O(p(t,e),{recursive:!0,force:!0});delete r.skills[e]}r.skills[s.name]={...t,version:s.version},await di(n,r),I.success(`${s.name}: v${t.version} → v${s.version}`+(o===`latest`?``:` (${o})`)+(s.name===e?``:` (was ${e})`)),u++}}await Gi([...new Set([...Object.values(r.skills),...Object.values(r.kits)].flatMap(e=>e.agents))]),L(Ds(u,s,c,l))}const Es=e=>`${e} skill${e===1?``:`s`}`;function Ds(e,t,n,r){let i=[e&&`updated ${Es(e)}`,t&&`installed ${Es(t)}`,n&&`removed ${Es(n)}`].filter(Boolean),a=r?`Left ${Es(r)} with local edits as they are.`:``;if(i.length===0)return a||`Everything is up to date.`;let o=i.join(`, `);return`${o[0].toUpperCase()}${o.slice(1)}.${a&&` ${a}`}`}const Os=`a-kit ${Ft}: your agent kit skills, in your agents.
286
+ Turn it off with \`a-kit telemetry off\`.`);return}default:throw Error(`Unknown telemetry action "${e}". Use on, off or status.`)}}async function qs(e){Et(`agent kit`);let t=e.global?`global`:`project`,n=Y(t),r=await X(n);if(Object.keys(r.skills).length===0&&Object.keys(r.kits).length===0){R(e.global?"No skills installed everywhere yet. Add some with `a-kit add -g`.":"No skills installed in this project yet. Add some with `a-kit add`.");return}let{api:i}=await $(),a=wa(t),o=[...Object.values(r.skills).flatMap(e=>a(e.agents)),...Object.values(r.kits).flatMap(e=>a(e.agents))];await Ca([...new Set(o)]);let s=0,c=0,l=0;for(let[e,t]of Object.entries(r.kits)){let o;try{o=await i.getKit(t.id)}catch(t){if(t instanceof Z&&t.status===404){L.warn(`kit/${e} isn't in your agent kit anymore; left its skills as they are.`);continue}throw t}Si(r,e,o.name);try{let e=await Ci(i,r,o,{agents:t.agents,dirsOf:a,reinstall:!1});for(let t of e.installed)L.success(`${t}: added to kit/${o.name}, installed`);for(let t of e.removed)L.success(`${t}: taken out of kit/${o.name}, removed`);s+=e.installed.length,c+=e.removed.length,l+=e.kept.length}finally{await mi(n,r)}}let u=0;for(let[e,t]of Object.entries(r.skills)){let o=pi(t),s;try{s=await i.getSkill(t.id,o)}catch(t){if(t instanceof Z&&t.status===404){L.warn(`${e} isn't in your agent kit anymore; left it as it is.`);continue}throw t}if(s.version===t.version)continue;let c=a(t.agents),d=await vi(i,e,t,c);if(d)L.warn(`${e} has edits that aren't in agent kit (${un(d.paths)}); left it at v${t.version}. Push them with \`a-kit push ${e}\`, or drop them with \`a-kit pull ${e} --force\`.`),l++;else{if(await ai(i,t.id,c,o),s.name!==e){for(let t of c)await k(p(t,e),{recursive:!0,force:!0});delete r.skills[e]}r.skills[s.name]={...t,version:s.version},await mi(n,r),L.success(`${s.name}: v${t.version} → v${s.version}`+(o===`latest`?``:` (${o})`)+(s.name===e?``:` (was ${e})`)),u++}}await ya([...new Set([...Object.values(r.skills),...Object.values(r.kits)].flatMap(e=>e.agents))]),R(Ys(u,s,c,l))}const Js=e=>`${e} skill${e===1?``:`s`}`;function Ys(e,t,n,r){let i=[e&&`updated ${Js(e)}`,t&&`installed ${Js(t)}`,n&&`removed ${Js(n)}`].filter(Boolean),a=r?`Left ${Js(r)} with local edits as they are.`:``;if(i.length===0)return a||`Everything is up to date.`;let o=i.join(`, `);return`${o[0].toUpperCase()}${o.slice(1)}.${a&&` ${a}`}`}const Xs=`a-kit ${Lt}: your agent kit skills, in your agents.
281
287
 
282
288
  Usage
283
289
  a-kit init Log in and pick skills to install
@@ -297,11 +303,13 @@ Usage
297
303
  a-kit telemetry [on|off] Whether your agents report the skills they load
298
304
  a-kit auto-update [on|off] Whether Claude Code updates your global skills
299
305
  when a session starts (at most once an hour)
306
+ a-kit heartbeat [on|off] Whether this machine reports to your Machines page
307
+ every 5 minutes (a systemd or launchd timer)
300
308
 
301
309
  Options
302
310
  -g, --global Install in your home folder instead of this project
303
- -a, --agent <id> Install for this agent (repeatable): ${It.map(e=>e.id).join(`, `)}
304
- --channel <channel> Install a release channel: ${jt.join(`, `)} (default latest);
311
+ -a, --agent <id> Install for this agent (repeatable): ${Rt.map(e=>e.id).join(`, `)}
312
+ --channel <channel> Install a release channel: ${Nt.join(`, `)} (default latest);
305
313
  \`a-kit update\` keeps following it
306
314
  -y, --yes Don't ask; use the defaults
307
315
  -h, --help Show this help
@@ -322,4 +330,4 @@ Report options (the report-session-issue skill passes them for you)
322
330
  --org <id|name> The organization, when it can't tell
323
331
  --full-outputs Keep tool outputs whole (they're cut to 2,000 characters)
324
332
  --dry-run Scrub and show what would be sent, without sending
325
- `;let ks;async function As(){let{values:e,positionals:n}=t({allowPositionals:!0,options:{global:{type:`boolean`,short:`g`,default:!1},agent:{type:`string`,short:`a`,multiple:!0,default:[]},yes:{type:`boolean`,short:`y`,default:!1},channel:{type:`string`,default:`latest`},help:{type:`boolean`,short:`h`,default:!1},version:{type:`boolean`,short:`v`,default:!1},session:{type:`string`},title:{type:`string`},note:{type:`string`},expected:{type:`string`},map:{type:`string`},org:{type:`string`},"full-outputs":{type:`boolean`,default:!1},"dry-run":{type:`boolean`,default:!1},force:{type:`boolean`,short:`f`,default:!1},api:{type:`string`}}});if(e.version)return console.log(Ft);let[r,...i]=n;if(ks=r,e.help||!r)return console.log(Os);if(!Nt(e.channel))throw Error(`Unknown channel "${e.channel}". Use one of: ${jt.join(`, `)}.`);let a={global:e.global,agent:e.agent.flatMap(e=>e.split(`,`)).filter(Boolean),yes:e.yes,channel:e.channel},o={...a,force:e.force,org:e.org};switch(r){case`init`:return Ka(a);case`add`:case`install`:return $i(i,a);case`update`:return Ts(a);case`list`:case`ls`:return vo();case`pull`:return To(i,o);case`push`:return Va(i,o);case`dev`:if(i.length>1)throw Error("`a-kit dev` watches one skill.");return Wa(i[0],o);case`search`:if(i.length===0)throw Error("What should it look for? Like `a-kit search pdf`.");return Ss(i);case`login`:return So();case`logout`:return Co();case`whoami`:return wo();case`report`:return ps({...a,session:e.session,title:e.title,note:e.note,expected:e.expected,map:e.map,org:e.org,fullOutputs:e[`full-outputs`],dryRun:e[`dry-run`]});case`telemetry`:return ws(i[0]);case`auto-update`:return ea(i[0]);case`hook`:return so(i[0],e.api);default:throw Error(`Unknown command "${r}". Run \`a-kit --help\`.`)}}const js=/* @__PURE__ */ new Set([`pull`,`push`,`dev`]);As().catch(e=>{let t=e instanceof Error?e.message:String(e);ks&&js.has(ks)?$(t):I.error(t),process.exitCode=1});export{};
333
+ `;let Zs;async function Qs(){let{values:e,positionals:n}=t({allowPositionals:!0,options:{global:{type:`boolean`,short:`g`,default:!1},agent:{type:`string`,short:`a`,multiple:!0,default:[]},yes:{type:`boolean`,short:`y`,default:!1},channel:{type:`string`,default:`latest`},help:{type:`boolean`,short:`h`,default:!1},version:{type:`boolean`,short:`v`,default:!1},session:{type:`string`},title:{type:`string`},note:{type:`string`},expected:{type:`string`},map:{type:`string`},org:{type:`string`},"full-outputs":{type:`boolean`,default:!1},"dry-run":{type:`boolean`,default:!1},force:{type:`boolean`,short:`f`,default:!1},api:{type:`string`}}});if(e.version)return console.log(Lt);let[r,...i]=n;if(Zs=r,e.help||!r)return console.log(Xs);if(!Ft(e.channel))throw Error(`Unknown channel "${e.channel}". Use one of: ${Nt.join(`, `)}.`);let a={global:e.global,agent:e.agent.flatMap(e=>e.split(`,`)).filter(Boolean),yes:e.yes,channel:e.channel},o={...a,force:e.force,org:e.org};switch(r){case`init`:return So(a);case`add`:case`install`:return Da(i,a);case`update`:return qs(a);case`list`:case`ls`:return Bo();case`pull`:return qo(i,o);case`push`:return _o(i,o);case`dev`:if(i.length>1)throw Error("`a-kit dev` watches one skill.");return bo(i[0],o);case`search`:if(i.length===0)throw Error("What should it look for? Like `a-kit search pdf`.");return Ws(i);case`login`:return Wo();case`logout`:return Go();case`whoami`:return Ko();case`report`:return Fs({...a,session:e.session,title:e.title,note:e.note,expected:e.expected,map:e.map,org:e.org,fullOutputs:e[`full-outputs`],dryRun:e[`dry-run`]});case`telemetry`:return Ks(i[0]);case`auto-update`:return Oa(i[0]);case`heartbeat`:return Co(i[0],e.api);case`hook`:return Ao(i[0],e.api);default:throw Error(`Unknown command "${r}". Run \`a-kit --help\`.`)}}const $s=/* @__PURE__ */ new Set([`pull`,`push`,`dev`]);Qs().catch(e=>{let t=e instanceof Error?e.message:String(e);Zs&&$s.has(Zs)?Va(t):L.error(t),process.exitCode=1});export{};