cyber-agentkit 1.0.0 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/plugin.json +1 -1
- package/.codex-plugin/plugin.json +1 -1
- package/.cursor-plugin/plugin.json +1 -1
- package/dist/cli.js +1389 -72
- package/dist/commands.d.ts +7 -1
- package/dist/commands.js +469 -48
- package/dist/index.d.ts +116 -12
- package/dist/index.js +608 -13
- package/dist/{reference-where-BhymfNgA.js → reference-where-C84J6MsR.js} +3839 -3649
- package/dist/{resolve-reference-Cis-Ye6T.d.ts → resolve-reference-D62VJZc0.d.ts} +17 -3
- package/package.json +1 -1
- package/plugin.json +4 -2
- package/skills/asset/README.md +14 -0
- package/skills/asset/SKILL.md +52 -0
- package/skills/asset/scripts/asset.mjs +220 -0
- package/skills/prose-update/README.md +24 -0
- package/skills/prose-update/SKILL.md +58 -0
- package/skills/prose-update/scripts/prose-update.mjs +220 -0
- package/skills/reference/README.md +1 -1
- package/skills/reference/SKILL.md +3 -3
- package/skills/reference/scripts/reference.mjs +77 -56
|
@@ -0,0 +1,220 @@
|
|
|
1
|
+
// Compiled by `universal-plugin plugin build` from src/prose-update/prose-update.skill-script.ts. Edit the source, not this file.
|
|
2
|
+
globalThis.__SKILL_SCRIPT__ = {"package":"cyber-agentkit","bin":"cyber-agentkit","version":"1.2.0","entry":"skills/prose-update/scripts/prose-update.mjs","commands":{}};
|
|
3
|
+
import{createRequire as e}from"node:module";import{fileURLToPath as t}from"node:url";import{copyFileSync as n,existsSync as r,lstatSync as i,mkdirSync as a,readFileSync as o,readdirSync as s,realpathSync as c,rmSync as l,rmdirSync as u,statSync as d,writeFileSync as f}from"node:fs";import{basename as p,dirname as m,extname as h,join as g,posix as _,relative as v,resolve as y,sep as b,win32 as x}from"node:path";import{inspect as S,styleText as C}from"node:util";import{homedir as w}from"node:os";import{readFile as T,readdir as E}from"node:fs/promises";var D=(e,t)=>()=>(t||(e((t={exports:{}}).exports,t),e=null),t.exports),O=/* @__PURE__ */ e(import.meta.url),ee=`1.2.0`,k=`cyber-agentkit`,te;const A={success:0,error:1,usage:2},ne=Symbol.for(`clibuilder.CliError`),re=Symbol.for(`clibuilder.CliError.reported`),ie=[`error`,`code`,`help`];var j=class e extends Error{static reported(t=A.error,n=`the error was already reported`){let r=new e(n,{exitCode:t});return r[re]=!0,r}constructor(e,t){let n=typeof e==`string`?{...t,message:e}:e;super(n.message),this.name=`CliError`,this[te]=!0,this.exitCode=se(n.exitCode??A.error),this.code=ce(n.code??`error`),this.details=le(n.details??{}),this.help=n.help===void 0?[]:typeof n.help==`string`?[n.help]:[...n.help],this.cause=n.cause}};te=ne;function ae(e){return!!e&&typeof e==`object`&&e[ne]===!0}function oe(e){return e[re]===!0}function se(e){if(Number.isInteger(e)&&e>=1&&e<=255)return e;throw RangeError(`CliError exitCode must be an integer from 1 to 255, received ${e}`)}function ce(e){if(/^[a-z0-9]+(?:-[a-z0-9]+)*$/.test(e))return e;throw RangeError(`CliError code must be a kebab-case string such as "not-found", received "${e}"`)}function le(e){for(let t of ie)if(t in e)throw RangeError(`CliError details may not have the key "${t}"`);return{...e}}function M(e){return e}function ue(e){let t=e.kind===`array`?e.element:e;return!(t.kind===`boolean`||t.kind===`literal`&&typeof t.value==`boolean`)}function de(e){switch(e.kind){case`string`:return e.pattern?`string ${e.pattern}`:`string`;case`number`:case`int`:return`${e.kind}${fe(e.min,e.max)}`;case`boolean`:case`json`:return e.kind;case`literal`:return String(e.value);case`enum`:return e.values.join(`|`);case`custom`:return`value`;case`array`:return de(e.element)}}function fe(e,t){return e!==void 0&&t!==void 0?` ${e}..${t}`:e===void 0?t===void 0?``:` <=${t}`:` >=${e}`}const pe={optional(){return me({...this,isOptional:!0})},check(e){let t=typeof e==`function`?{type:`fn`,fn:e}:{type:`schema`,schema:e};if(typeof e!=`function`&&!he(e))throw TypeError(`check() takes a function or a Standard Schema`);return me({...this,checks:[...this.checks,t]})}};function me(e){return Object.freeze(Object.assign(Object.create(pe),e))}function N(e){return me({...e,isOptional:!1,checks:Object.freeze([])})}function he(e){let t=e?.[`~standard`];return typeof t==`object`&&!!t&&typeof t.validate==`function`}function ge(e,t,n){let{min:r,max:i}=t??{};for(let[t,a]of[[`min`,r],[`max`,i]])if(a!==void 0){if(typeof a!=`number`||Number.isNaN(a))throw TypeError(`${e}: ${t} must be a number`);if(n&&Number.isFinite(a)&&!Number.isInteger(a))throw RangeError(`${e}: ${t} must be an integer, got ${a}`)}if(r!==void 0&&i!==void 0&&r>i)throw RangeError(`${e}: min (${r}) is greater than max (${i})`);return{...r===void 0?{}:{min:r},...i===void 0?{}:{max:i}}}function _e(e){let t=e?.pattern;if(t!==void 0&&!(t instanceof RegExp))throw TypeError(`t.string: pattern must be a RegExp`);return N(t===void 0?{kind:`string`}:{kind:`string`,pattern:t})}function ve(e){if(e===void 0)return N({kind:`json`});if(!he(e))throw TypeError(`t.json: schema must be a Standard Schema`);return N({kind:`json`,schema:e})}const P={string:_e,number(e){return N({kind:`number`,...ge(`t.number`,e,!1)})},int(e){return N({kind:`int`,...ge(`t.int`,e,!0)})},boolean(){return N({kind:`boolean`})},literal(e){let t=typeof e;if(!(t===`string`||t===`boolean`||t===`number`&&Number.isFinite(e)))throw TypeError(`t.literal: value must be a string, a finite number or a boolean, got ${String(e)}`);return N({kind:`literal`,value:e})},enum(e){if(!Array.isArray(e)||e.length===0)throw TypeError(`t.enum: values must be a non-empty array`);for(let t of e)if(typeof t!=`string`)throw TypeError(`t.enum: values must be strings, got ${String(t)}`);return N({kind:`enum`,values:Object.freeze([...e])})},array(e){let t=e;if(typeof t?.kind!=`string`||!Object.prototype.isPrototypeOf.call(pe,t))throw TypeError(`t.array: element must be a descriptor`);if(t.kind===`array`)throw TypeError(`t.array: element cannot be an array`);if(t.isOptional)throw TypeError(`t.array: element cannot be optional`);return N({kind:`array`,element:e})},custom(e){if(typeof e!=`function`)throw TypeError(`t.custom: convert must be a function`);return N({kind:`custom`,convert:e})},json:ve};function ye(e){return typeof e==`object`&&!!e&&Object.prototype.isPrototypeOf.call(pe,e)}String.prototype.charCodeAt;const be=String.prototype.slice;Array.prototype.forEach,Array.prototype.map,Array.prototype.reduce;const xe=Array.prototype.slice,Se=Array.prototype.push,Ce={modifiers:`-`,terminator:`--`};function we(e){let t=/* @__PURE__ */ new Set,n=e?.modifiers??Ce.modifiers;for(let e of typeof n==`string`?Array.from(n):n){if(e.length!==1||e===`=`)throw Error(`Invalid modifier '${e}': a modifier must be a single character other than '='`);t.add(e)}if(t.size===0)throw Error(`At least one modifier is required`);let r=e?.terminator??Ce.terminator;if(r===``)throw Error(`The terminator must not be empty`);return{modifiers:t,terminator:r}}function Te(e,t){let n=0;for(;n<e.length&&t.has(e[n]);)n++;return[be.call(e,n),n]}function Ee(e,t){let{modifiers:n,terminator:r}=we(t),i=[],a=0,o=xe.call(e);for(;o.length>0;){let e=o.shift();if(e===r){Se.call(i,{kind:`option-terminator`,index:a}),a++,Se.apply(i,o.map((e,t)=>({kind:`positional`,index:a+t,value:e})));break}let[t,s]=Te(e,n);if(s===0||!t)Se.call(i,{kind:`positional`,index:a,value:t||e});else{let n=t.indexOf(`=`),[r,o]=n===-1?[t,void 0]:[be.call(t,0,n),be.call(t,n+1)];Se.call(i,{kind:`option`,index:a,name:r,dashes:s,raw:e,value:o})}a++}return i}var De=class extends Error{constructor(e,t,n,r={}){super(e),Object.defineProperty(this,"option",{enumerable:!0,configurable:!0,writable:!0,value:t}),Object.defineProperty(this,"input",{enumerable:!0,configurable:!0,writable:!0,value:n}),Object.defineProperty(this,"kind",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"index",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"issues",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"value",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"detail",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.name=`ParseArgsError`,this.kind=r.kind??`invalid-value`,this.index=r.index,this.issues=r.issues,this.value=r.value,this.detail=r.detail??e}};function Oe(e){let t=je(e),n=t.next();for(;!n.done;){let{value:e,option:r}=n.value;if(Ae(e))throw e.then(void 0,()=>{}),t.return(void 0),Error(`Option '${r}' has an asynchronous converter or check: use parseArgsAsync() to parse it`);n=t.next(e)}return n.value}async function ke(e){let t=je(e),n=t.next();for(;!n.done;)n=await Promise.resolve(n.value.value).then(e=>t.next(e),e=>t.throw(e));return n.value}function Ae(e){return(typeof e==`object`||typeof e==`function`)&&e!==null&&typeof e.then==`function`}function*je(e){let t=Ee(e.args,e.grammar),n=e.options;Me(n);let r=Pe(n),i=Object.create(null),a=Object.create(null),o=[],s=[],c=t.slice();for(;c.length>0;){let t=c.shift();switch(t.kind){case`positional`:Ne(e,t.value),o.push(t.value);break;case`option`:{let o=t.dashes===1?Array.from(t.name):[t.name];for(let s=0;s<o.length;s++){let l=o[s],u=s===o.length-1,d=r.get(l)??l,f=n?.[d];if(e.strict&&!f)throw new De(`Unknown option '${l}' (from '${t.raw}')`,l,t.raw,{kind:`unknown-option`});if(!u&&f&&Ie(f))throw new De(`Invalid option group '${t.raw}': '${l}' takes a value, so it can only be the last option in a group`,d,t.raw,{kind:`invalid-group`,detail:`takes a value, so it can only be the last option in a group`});let p=u?t.value??Re(f,c):void 0;if(f&&ye(f.type)){let e=f.type;if(e.kind===`array`){let n=i[d]??(i[d]=[]);(a[d]??(a[d]=[])).push(t.raw);let r={name:d,label:`${d}[${n.length}]`,index:n.length,token:t};n.push(yield*Ge(e.element,p,r))}else i[d]=yield*Ge(e,p,{name:d,label:d,index:void 0,token:t});continue}let m=ze(f,d,p,t);f?.multiple?(i[d]??(i[d]=[])).push(m):i[d]=m}break}case`option-terminator`:for(let t of c)Ne(e,t.value);s.push(...c.map(e=>e.value)),c.length=0}}for(let[e,t]of Object.entries(n??{})){let n=ye(t.type)?t.type:void 0;if(i[e]!==void 0){if(n?.kind===`array`){let t=a[e].join(` `);yield*Xe(n,i[e],e,(n,r)=>We(e,e,t,n,{issues:r}))}continue}if(t.default!==void 0)n&&(yield*Qe(t,e)),i[e]=Array.isArray(t.default)?[...t.default]:t.default;else if(n&&!n.isOptional)throw new De(`Missing required option '${e}'`,e,``,{kind:`missing-option`,detail:`a value is required`})}let l={_:o,__:s,options:i};return e.tokens&&(l.tokens=t),l}function Me(e){for(let[t,n]of Object.entries(e??{})){let e=n.type;if(typeof e==`object`&&e&&!ye(e))throw TypeError(`Option '${t}' has a type that is neither a type name nor a descriptor from t`);if(ye(e)&&n.multiple!==void 0)throw TypeError(`Option '${t}' cannot set 'multiple' with a descriptor: use t.array(element)`)}}function Ne(e,t){if(e.allowPositionals===!1)throw new De(`Unexpected positional argument '${t}'`,void 0,t,{kind:`unexpected-positional`})}function Pe(e){let t=/* @__PURE__ */ new Map;if(!e)return t;for(let n of Object.keys(e))t.set(n,n);for(let[n,r]of Object.entries(e)){let e=r.alias;for(let r of e===void 0?[]:Array.isArray(e)?e:[e]){let e=t.get(r);if(e!==void 0&&e!==n)throw Error(`Alias '${r}' of option '${n}' is already used by option '${e}'`);t.set(r,n)}}return t}function Fe(e){return e.kind===`array`?e.element:e}function Ie(e){if(!ye(e.type))return e.type!==`boolean`;let t=Fe(e.type);return!(t.kind===`boolean`||t.kind===`literal`&&typeof t.value==`boolean`)}function Le(e){if(!ye(e.type))return e.type===`number`;let t=Fe(e.type);return t.kind===`number`||t.kind===`int`||t.kind===`literal`&&typeof t.value==`number`}function Re(e,t){if(!e||!Ie(e))return;let n=t[0];if(n){if(n.kind===`positional`)return t.shift(),n.value;if(n.kind===`option`&&Le(e)&&Number.isFinite(Ve(n.raw)))return t.shift(),n.raw}}function ze(e,t,n,r){if(!e)return n??!0;switch(e.type){case`boolean`:return Ue(t,n,r);case`number`:return He(t,n,r);default:if(n===void 0)throw Be(t,`a value is required`,r,`missing-value`);return n}}function Be(e,t,n,r,i){return new De(`Invalid value for option '${e}': ${t} (from '${n.raw}')`,e,n.raw,{kind:r,value:i,detail:t})}function Ve(e){return e.trim()===``?NaN:Number(e)}function He(e,t,n){if(t===void 0)throw Be(e,`a number is required`,n,`missing-value`);let r=Ve(t);if(!Number.isFinite(r))throw Be(e,t,n,`invalid-value`,t);return r}function Ue(e,t,n){if(t===void 0)return!0;if(t===`false`||t===`f`||t===`0`)return!1;if(t===`true`||t===`t`)return!0;let r=Ve(t);if(!Number.isNaN(r))return r>0;throw Be(e,t,n,`invalid-value`,t)}function We(e,t,n,r,i,a=r){return new De(`Invalid value for option '${t}': ${a} (from '${n}')`,e,n,{...i,detail:r})}function*Ge(e,t,n){let r=(e,r,i)=>We(n.name,n.label,n.token.raw,e,{index:n.index,issues:r,value:t},i),i=yield*Je(e,t,n,r);return yield*Xe(e,i,n.label,r),i}function Ke(e){return`'${e}'`}function qe(e){switch(e.kind){case`string`:return`a string matching ${e.pattern}`;case`number`:case`int`:{let t=e.kind===`int`?`an integer`:`a number`;return e.min!==void 0&&e.max!==void 0?`${t} from ${e.min} to ${e.max}`:e.min===void 0?e.max===void 0?t:`${t} of at most ${e.max}`:`${t} of at least ${e.min}`}case`boolean`:return`no value, true or false`;case`literal`:return typeof e.value==`string`?Ke(e.value):String(e.value);case`enum`:return`one of ${e.values.map(Ke).join(`, `)}`}}function*Je(e,t,n,r){let i=e=>r(`expected ${qe(e)}`,void 0,`expected ${qe(e)}, got ${Ke(t)}`);if(e.kind===`boolean`||e.kind===`literal`&&typeof e.value==`boolean`){let n=t===void 0||t===`true`||t!==`false`&&void 0;if(n===void 0||e.kind===`literal`&&n!==e.value)throw t===void 0?r(`expected ${qe(e)}`,void 0,`expected ${qe(e)}, got no value`):i(e);return n}if(t===void 0)throw We(n.name,n.label,n.token.raw,`a value is required`,{kind:`missing-value`,index:n.index});switch(e.kind){case`string`:if(e.pattern&&(e.pattern.lastIndex=0,!e.pattern.test(t)))throw i(e);return t;case`number`:case`int`:{let n=Ve(t);if(!Number.isFinite(n)||e.kind===`int`&&!Number.isInteger(n)||e.min!==void 0&&n<e.min||e.max!==void 0&&n>e.max)throw i(e);return n}case`literal`:{let n=typeof e.value==`number`?Ve(t):t;if(n!==e.value)throw i(e);return n}case`enum`:if(!e.values.includes(t))throw i(e);return t;case`custom`:try{return yield{value:e.convert(t),option:n.label}}catch(e){throw Ye(e,r)}case`json`:{let i;try{i=JSON.parse(t)}catch{throw r(`not valid JSON`,void 0,`${Ke(t)} is not valid JSON`)}if(!e.schema)return i;let a=yield{value:e.schema[`~standard`].validate(i),option:n.label};if(a.issues)throw r(`does not match the expected shape`,a.issues);return a.value}}}function Ye(e,t){return e instanceof Error&&e.constructor===Error?t(e.message):e}function*Xe(e,t,n,r){for(let i of e.checks)if(i.type===`fn`){let e=yield{value:i.fn(t),option:n};if(e===!1)throw r(`failed a check`);if(typeof e==`string`)throw r(e)}else{let e=yield{value:i.schema[`~standard`].validate(t),option:n};if(e.issues)throw r(`failed a check`,e.issues)}}const Ze=/* @__PURE__ */ new WeakMap;function*Qe(e,t){if(Ze.has(e))return;let n=e.type,r=e=>t=>/* @__PURE__ */ Error(`The default of option '${e}' failed a check${t===`failed a check`?``:`: ${t}`}`);if(n.kind===`array`){let i=e.default;for(let e=0;e<i.length;e++){let a=`${t}[${e}]`;yield*Xe(n.element,i[e],a,r(a))}}yield*Xe(n,e.default,t,r(t)),Ze.set(e,!0)}const $e=/* @__PURE__ */ new WeakMap;function et(e,t,n){let r=tt(e,nt(t,n)),[i,a]=rt(t,r,n);return ct(r,i,a)}function tt(e,t){if(e.commands){let n=e.commands,r=t.peek(e);for(let e=n.length-1;e>=0;e--){let i=n[e];if(!i.name)return i;if(r===i.name||i.alias?.includes(r))return t.consume(),i.commands?tt(i,t):i}}return e}function nt(e,t){let n=$e.get(e)??[],r,i=-1,a=0;return{peek(o){if(r=void 0,i<0){if(a<e._.length)return(r=[e._,a])[0][a];i=0,a=-1}for(;t&&i<n.length;){let e=n[i];if(a<0){let n=F(t,e.key)[1];if(!n)return;a=it(F(o,e.key)[1]??n,e)}if(a<e.following.length)return(r=[e.following,a])[0][a];i++,a=-1}},consume(){r[0].splice(r[1],1)}}}function rt(e,t,n){let r=$e.get(e);if(!r)return[e,void 0];let i={},a=[],o=[];for(let e of r){let r=F(t,e.key)[1],s=it(r??(n&&F(n,e.key)[1]),e),c=e.following.slice(0,s);r&&o.push({key:e.key,tokens:[e.raw,...c]}),a.push(...e.following.slice(s));let l=e.inline.length+c.length>0?[...e.inline,...c]:[`true`];i[e.key]=[...i[e.key]??[],...l]}let s={...e,_:[...e._,...a]};for(let t of Object.keys(i))e[t]&&(s[t]=i[t]);return[s,o]}function it(e,t){return e?t.inline.length===0&&ue(st(e))?1:0:t.following.length}const at=P.boolean().optional(),ot=P.string();function st(e){return e.type??at}function ct(e,t,n){return ft(dt(ut(lt({command:e,rawArgs:t,args:{_:[]},errors:[],descriptors:[]}))),n)}function lt(e){let t=e.command,n=[...e.rawArgs._],r=t.arguments||[];for(let t of r){let r=t.type??ot;if(n.length===0){r.isOptional||e.errors.push({type:`missing-argument`,name:t.name});continue}let i=r.kind===`array`?n.splice(0):[n.shift()];e.descriptors.push({type:`argument`,name:t.name,descriptor:r,values:i})}return n.length>0&&e.errors.push({type:`extra-arguments`,name:t.name,values:n}),e}function ut(e){for(let t of Object.keys(e.rawArgs)){if(t===`_`)continue;if(/^-/.test(t)){e.errors.push({type:`invalid-key`,key:t});continue}let[n,r]=F(e.command,t);if(!n){e.errors.push({type:`invalid-key`,key:t});continue}let i=st(r),a=e.rawArgs[t];i.kind!==`array`&&a.length>1&&e.errors.push({type:`expect-single`,key:t,keyKind:i.kind,value:a})}return e}function dt(e){let t=e.command.options;if(!t)return e;let n=/* @__PURE__ */ new Map;for(let t of Object.keys(e.rawArgs)){let[r]=F(e.command,t);r&&!n.has(r)&&n.set(r,t)}let r=[...n.keys()];for(let i=0;i<r.length;i++)for(let a=i+1;a<r.length;a++){let[o,s]=[r[i],r[a]];if(!t[o].conflicts?.includes(s)&&!t[s].conflicts?.includes(o))continue;let[c,l]=t[o].conflicts?.includes(s)?[o,s]:[s,o];e.errors.push({type:`conflicting-options`,key:n.get(c),conflictsWith:n.get(l)})}return e}function ft(e,t){let n=e.command.options??{};for(let r of Object.keys(n)){let i=n[r],a=Object.keys(e.rawArgs).filter(t=>t!==`_`&&F(e.command,t)[0]===r);e.errors.some(e=>e.type===`expect-single`&&a.includes(e.key))||e.descriptors.push({type:`option`,name:r,entry:{...i,type:st(i)},occurrences:t?t.filter(e=>a.includes(e.key)):a.flatMap(t=>e.rawArgs[t].map(e=>({key:t,tokens:[`--${r}=${e}`]})))})}return e}function F(e,t){let n=e.options;if(!n)return[];let r=n[t];if(r)return[t,r];let i=Object.keys(n).find(e=>{let r=n[e];return r.alias?r.alias.some(e=>e===t||e.alias===t):!1});return i?[i,n[i]]:[]}const pt={comma:`,`,tab:` `,pipe:`|`},mt=pt.comma;function ht(e){return e.replace(/\\/g,`\\\\`).replace(/"/g,`\\"`).replace(/\n/g,`\\n`).replace(/\r/g,`\\r`).replace(/\t/g,`\\t`).replace(/[\u0000-\u001F]/g,e=>`\\u${e.charCodeAt(0).toString(16).padStart(4,`0`)}`)}function gt(e){return e===`true`||e===`false`||e===`null`}function _t(e,t,n){if(t===`__proto__`){Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0});return}e[t]=n}const vt=/* @__PURE__ */ RegExp(`(?:^?|\\n) *#`);var yt=class{constructor(e){if(vt.test(e))throw TypeError(`Raw string must not contain a line starting with "#": ${JSON.stringify(e)}`);this.value=e}};function bt(e){return e instanceof yt}const xt=/[\uD800-\uDFFF]/;function St(e){if(e===null)return null;if(bt(e))return e;if(typeof e==`object`&&e&&`toJSON`in e&&typeof e.toJSON==`function`){let t=e.toJSON();if(t!==e)return St(t)}if(typeof e==`string`)return Ct(e,`string value`),e;if(typeof e==`boolean`)return e;if(typeof e==`number`)return Object.is(e,-0)?0:Number.isFinite(e)?e:null;if(typeof e==`bigint`)return e>=-(2**53-1)&&e<=2**53-1?Number(e):e.toString();if(e instanceof Date)return e.toISOString();if(Array.isArray(e))return e.map(St);if(e instanceof Set)return Array.from(e).map(St);if(e instanceof Map)return Object.fromEntries(Array.from(e,([e,t])=>[String(e),St(t)]));if(kt(e)){let t={};for(let n in e)Object.hasOwn(e,n)&&(Ct(n,`object key`),_t(t,n,St(e[n])));return t}return null}function Ct(e,t){if(xt.test(e))for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r<55296||r>57343)continue;let i=r<=56319,a=e.charCodeAt(n+1);if(i&&a>=56320&&a<=57343){n++;continue}throw TypeError(`Cannot encode ${t} containing an unpaired surrogate U+${r.toString(16).toUpperCase()} at index ${n}`)}}function wt(e){return e===null||typeof e==`string`||typeof e==`number`||typeof e==`boolean`}function Tt(e){return wt(e)||bt(e)}function Et(e){return Array.isArray(e)}function Dt(e){return typeof e==`object`&&!!e&&!Array.isArray(e)&&!bt(e)}function Ot(e){return Object.keys(e).length===0}function kt(e){if(typeof e!=`object`||!e)return!1;let t=Object.getPrototypeOf(e);return t===null||t===Object.prototype}function At(e){return e.length===0||e.every(e=>Tt(e))}function jt(e){return e.length===0||e.every(e=>Et(e))}function Mt(e){return e.length===0||e.every(e=>Dt(e))}const Nt=/^[+-]?\d+(?:\.\d+)?(?:e[+-]?\d+)?$/i;function Pt(e){if(!Object.values(pt).includes(e))throw TypeError(`Invalid delimiter ${JSON.stringify(e)}. Valid delimiters are: comma (,), tab (\\t), pipe (|)`)}function Ft(e){return/^[A-Z_][\w.]*$/i.test(e)}function It(e,t=mt){return!(!e||/^[ \t]|[ \t]$/.test(e)||gt(e)||Lt(e)||e.includes(`:`)||e.includes(`"`)||e.includes(`\\`)||/[[\]{}]/.test(e)||/[\u0000-\u001F]/.test(e)||e.includes(t)||e.startsWith(`-`)||e.startsWith(`#`))}function Lt(e){return Nt.test(e)}function Rt(e,t){return bt(e)?e.value:e===null?`null`:typeof e==`boolean`||typeof e==`number`?String(e):zt(e,t)}function zt(e,t=mt){return It(e,t)?e:`"${ht(e)}"`}function Bt(e){return Ft(e)?e:`"${ht(e)}"`}function Vt(e,t=mt){return e.map(e=>Rt(e,t)).join(t)}function Ht(e,t){let n=t?.key,r=t?.fields,i=t?.delimiter??`,`,a=``;return n!=null&&(a+=Bt(n)),a+=`[${e}${t?.keyed?`:`:``}${i===mt?``:i}]`,r&&(a+=`{${Ut(r,i)}}`),a+=`:`,a}function Ut(e,t){return e.map(e=>Bt(e.name)+(e.children?`{${Ut(e.children,t)}}`:``)).join(t)}function Wt(e){if(e.length===0)return;let t=Object.keys(e[0]);if(t.length===0)return;for(let n of e){if(Object.keys(n).length!==t.length)return;for(let e of t)if(!Object.hasOwn(n,e))return}let n=[];for(let r of t){let t=qt(r,e.map(e=>e[r]));if(!t)return;n.push(t)}return n}function Gt(e){let t=Object.values(e);if(!(t.length<2)&&t.every(e=>Dt(e)&&!Ot(e)))return Wt(t)}function Kt(e,t){let n=[];return Jt(e,t,n),n}function qt(e,t){if(t.every(e=>Tt(e)))return{name:e};if(!t.every(e=>Dt(e)&&!Ot(e)))return;let n=Wt(t);if(n)return{name:e,children:n}}function Jt(e,t,n){for(let r of t){let t=e[r.name];r.children?Jt(t,r.children,n):n.push(t)}}function*Yt(e,t,n){if(Tt(e)){let n=Rt(e,t.delimiter);n!==``&&(yield n);return}if(Et(e))yield*en(void 0,e,n,t);else if(Dt(e)){let r=Gt(e);if(r){yield*Qt(void 0,e,r,n,t);return}yield*Xt(e,n,t)}}function*Xt(e,t,n){for(let[r,i]of Object.entries(e))yield*Zt(r,i,t,n)}function*Zt(e,t,n,r){let i=Bt(e);if(Tt(t))yield I(n,`${i}: ${Rt(t,r.delimiter)}`,r.indentSize);else if(Et(t))yield*en(e,t,n,r);else if(Dt(t)){let a=Gt(t);if(a){yield*Qt(e,t,a,n,r);return}yield I(n,`${i}:`,r.indentSize),Ot(t)||(yield*Xt(t,n+1,r))}}function*Qt(e,t,n,r,i){let a=Object.entries(t);yield I(r,Ht(a.length,{key:e,fields:n,delimiter:i.delimiter,keyed:!0}),i.indentSize),yield*$t(a,n,r+1,i)}function*$t(e,t,n,r){for(let[i,a]of e){let e=Kt(a,t);yield I(n,`${Bt(i)}: ${Vt(e,r.delimiter)}`,r.indentSize)}}function*en(e,t,n,r){if(t.length===0){yield I(n,e==null?`[]`:`${Bt(e)}: []`,r.indentSize);return}if(At(t)){yield I(n,nn(t,r.delimiter,e),r.indentSize);return}if(jt(t)&&t.every(e=>At(e))){yield*tn(e,t,n,r);return}if(Mt(t)){let i=Wt(t);i?yield*rn(e,t,i,n,r):yield*on(e,t,n,r);return}yield*on(e,t,n,r)}function*tn(e,t,n,r){yield I(n,Ht(t.length,{key:e,delimiter:r.delimiter}),r.indentSize);for(let e of t)if(At(e)){let t=nn(e,r.delimiter);yield L(n+1,t,r.indentSize)}}function nn(e,t,n){let r=Ht(e.length,{key:n,delimiter:t}),i=Vt(e,t);return e.length===0?r:`${r} ${i}`}function*rn(e,t,n,r,i){yield I(r,Ht(t.length,{key:e,fields:n,delimiter:i.delimiter}),i.indentSize),yield*an(t,n,r+1,i)}function*an(e,t,n,r){for(let i of e)yield I(n,Vt(Kt(i,t),r.delimiter),r.indentSize)}function*on(e,t,n,r){yield I(n,Ht(t.length,{key:e,delimiter:r.delimiter}),r.indentSize);for(let e of t)yield*cn(e,n+1,r)}function*sn(e,t,n){if(Ot(e)){yield I(t,`-`,n.indentSize);return}let r=Object.entries(e),[i,a]=r[0],o=r.slice(1);if(Et(a)&&Mt(a)){let e=Wt(a);if(e){yield L(t,Ht(a.length,{key:i,fields:e,delimiter:n.delimiter}),n.indentSize),yield*an(a,e,t+2,n),o.length>0&&(yield*Xt(Object.fromEntries(o),t+1,n));return}}if(Dt(a)){let e=Gt(a);if(e){let r=Object.entries(a);yield L(t,Ht(r.length,{key:i,fields:e,delimiter:n.delimiter,keyed:!0}),n.indentSize),yield*$t(r,e,t+2,n),o.length>0&&(yield*Xt(Object.fromEntries(o),t+1,n));return}}let s=Bt(i);if(Tt(a))yield L(t,`${s}: ${Rt(a,n.delimiter)}`,n.indentSize);else if(Et(a)){if(a.length===0)yield L(t,`${s}: []`,n.indentSize);else if(At(a))yield L(t,`${s}${nn(a,n.delimiter)}`,n.indentSize);else{yield L(t,`${s}${Ht(a.length,{delimiter:n.delimiter})}`,n.indentSize);for(let e of a)yield*cn(e,t+2,n)}}else Dt(a)&&(yield L(t,`${s}:`,n.indentSize),Ot(a)||(yield*Xt(a,t+2,n)));o.length>0&&(yield*Xt(Object.fromEntries(o),t+1,n))}function*cn(e,t,n){if(Tt(e))yield L(t,Rt(e,n.delimiter),n.indentSize);else if(Et(e)){if(At(e))yield L(t,nn(e,n.delimiter),n.indentSize);else{yield L(t,Ht(e.length,{delimiter:n.delimiter}),n.indentSize);for(let r of e)yield*cn(r,t+1,n)}}else Dt(e)&&(yield*sn(e,t,n))}function I(e,t,n){return` `.repeat(n*e)+t}function L(e,t,n){return I(e,`- `+t,n)}function ln(e,t){let n=t(``,e,[]);return n===void 0?dn(e,t,[]):un(e,n,t,[])}function un(e,t,n,r){return bt(t)&&!Tt(e)?dn(e,n,r):dn(St(t),n,r)}function dn(e,t,n){return Dt(e)?fn(e,t,n):Et(e)?pn(e,t,n):e}function fn(e,t,n){let r={};for(let[i,a]of Object.entries(e)){let e=[...n,i],o=t(i,a,e);o!==void 0&&_t(r,i,un(a,o,t,e))}return r}function pn(e,t,n){let r=[];for(let i=0;i<e.length;i++){let a=e[i],o=[...n,i],s=t(String(i),a,o);s!==void 0&&r.push(un(a,s,t,o))}return r}function mn(e,t){return Array.from(hn(e,t)).join(`
|
|
4
|
+
`)}function hn(e,t){let n=St(e),r=gn(t);return Yt(r.replacer?ln(n,r.replacer):n,r,0)}function gn(e){let t=e?.delimiter??mt;return Pt(t),{indentSize:e?.indentSize??e?.indent??2,delimiter:t,replacer:e?.replacer}}function _n(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}function vn(e){return e===void 0?``:String(e)}function yn(e){let t=[...new Set(e.flatMap(e=>Object.keys(e)))],n=t.map(t=>Math.max(t.length,...e.map(e=>vn(e[t]).length))),r=e=>` ${e.map((e,t)=>e.padEnd(n[t])).join(` `)}`.trimEnd();return[r(t),...e.map(e=>r(t.map(t=>vn(e[t]))))]}function bn(e){let t=Object.entries(e).filter(([,e])=>e!==void 0).map(([e,t])=>{if(!Array.isArray(t))return[`${e}: ${_n(t)?JSON.stringify(t):String(t)}`];if(!t.length)return[`${e}: (none)`];let n=t.every(_n)?yn(t):t.map(e=>` - ${String(e)}`);return[`${e}:`,...n]});return t.flatMap((e,n)=>{let r=t[n-1];return r&&(r.length>1||e.length>1)?[``,...e]:e}).join(`
|
|
5
|
+
`)}const xn=[`toon`,`json`,`text`];function Sn(e,t){return t===`json`?JSON.stringify(e):t===`text`?bn(e):mn(e)}function Cn({message:e,code:t,details:n,help:r}){let i={error:e,code:t,...n};return r&&r.length>0&&(i.help=[...r]),i}const wn=Symbol.for(`clibuilder.global-format`),Tn=Symbol.for(`clibuilder.defers-to-global-format`);function En(e,t){return M({name:``,description:e,options:{help:{type:P.boolean().optional(),description:`Print help message`,alias:[`h`]},version:{type:P.boolean().optional(),description:`Print the CLI version`,alias:[`v`]},verbose:{type:P.boolean().optional(),description:`Turn on verbose logging`,alias:[`V`]},silent:{type:P.boolean().optional(),description:`Turn off logging`},"debug-cli":{type:P.boolean().optional(),description:`Display clibuilder debug messages`},...t?.options,format:Dn(t?.format??`toon`)},commands:[]})}function Dn(e){return Object.defineProperty({type:P.enum(xn),description:`Output format: 'toon' for agents, 'json' to pipe, 'text' for humans`,default:e},wn,{value:!0})}function On(e){return!!e&&e[wn]===!0}function kn(e){let[t,n]=F(e,`format`);if(!t||On(n))return e;if(!n[Tn]){let n=e.name?`command '${e.name}'`:`the default command`;throw Error(`${n} declares its own option '${t}', which conflicts with the global --format option. Delete the local declaration and read this.format in run() instead. See docs/rfcs/axi-native.md section 3.4: https://github.com/clibuilder/clibuilder/blob/main/docs/rfcs/axi-native.md#34---format-is-not-first-class-6394`)}let{[t]:r,...i}=e.options;return{...e,options:i}}function An(e){return{id:e,kind:`value`}}function jn(){let e=/* @__PURE__ */ new Map,t=/* @__PURE__ */ new Map;function n(n){return n.kind===`collection`?t.get(n.id)??[]:e.get(n.id)?.value}return{register(n,r,i){if(r.kind===`collection`){let e=t.get(r.id)??[];return e.push({source:n,value:i}),t.set(r.id,e),{accepted:!0}}let a=e.get(r.id);return a?{accepted:!1,source:a.source}:(e.set(r.id,{source:n,value:i}),{accepted:!0})},get:n,has(n){return n.kind===`collection`?t.has(n.id):e.has(n.id)},describe(n){if(n.kind===`collection`)return(t.get(n.id)??[]).map(({source:e})=>e);let r=e.get(n.id)?.source;return r?[r]:[]}}}const Mn=An(`clibuilder.config`);function Nn(e){let t=[],n=e.slice(2).reduce((e,n)=>(e.args.__?e.args.__.push(n):Fn(n)?(Pn(e)&&(e=Bn(e)),e=In(e,n,t)):Pn(e)?(e.values.push(n),t[t.length-1].following.push(n)):n===`--`?e.args.__=[]:e.args._.push(n),e),{args:{_:[]},key:``,values:[]}),r=(Pn(n)?Bn(n):n).args;return $e.set(r,t),r}function Pn(e){return!!e.key}function Fn(e){return e.startsWith(`-`)&&/\w+/.test(e)}function In(e,t,n){return e=/^-\w+/.test(t)?Ln(e,t,n):zn(e,t),n.push({key:e.key,raw:t,inline:[...e.values],following:[]}),e}function Ln(e,t,n){let r=t.indexOf(`=`),[i,a]=r>0?[t.slice(1,r),[t.slice(r+1)]]:[t.slice(1),[]],o=i.split(``),s=o.pop();for(let e of o)n.push({key:e,raw:t,inline:[`true`],following:[]});return e=Rn(e,o),e.key=s,e.values=a,e}function Rn(e,t){return t.length<=0?e:(e.key=t.pop(),e.values=[`true`],Rn(Bn(e),t))}function zn(e,t){let n=t.indexOf(`=`);return n>0?(e.key=t.slice(2,n),e.values=[t.slice(n+1)]):(e.key=t.slice(2),e.values=[]),e}function Bn(e){let{key:t,values:n}=e,r={...e.args};return r[t]||(r[t]=[]),n.length===0?r[t].push(`true`):r[t].push(...n),{args:r,key:``,values:[]}}const Vn=/* @__PURE__ */ new WeakMap;async function Hn(e){for(let t of e.descriptors)try{Kn(e,t,await ke(Gn(t)))}catch(n){qn(e,t,n)}}function Un(e){for(let t of e.descriptors)try{Kn(e,t,Oe(Gn(t)))}catch(n){qn(e,t,n)}}function Wn(e,t){let n={...e,args:{...e.args},errors:[],descriptors:e.descriptors.filter(e=>e.type===`option`&&t.includes(e.name)&&e.entry.type.kind===`boolean`&&e.entry.type.checks.length===0)};return Un(n),n.args}function Gn(e){return e.type===`option`?{args:e.occurrences.flatMap(e=>e.tokens),options:{[e.name]:Jn(e.entry)}}:{args:e.values.map(t=>`--${e.name}=${t}`),options:{[e.name]:{type:e.descriptor}}}}function Kn(e,t,{options:n}){n[t.name]!==void 0&&(e.args[t.name]=n[t.name])}function qn(e,t,n){if(!(n instanceof De))throw n;e.errors.push(Yn(n,t))}function Jn(e){let t=Vn.get(e);if(!t){let n=e.alias?.map(e=>typeof e==`string`?e:e.alias);t={type:e.type,...n?{alias:n}:{},...e.default===void 0?{}:{default:e.default}},Vn.set(e,t)}return t}function Yn(e,t){if(e.kind===`missing-option`)return{type:`missing-argument`,name:t.name};let n=t.type===`option`?t.entry.type:t.descriptor,r=n.kind===`array`?n.element:n;return{type:`invalid-value`,key:Xn(e,t),message:e.detail,value:e.value??(e.kind===`invalid-value`?Zn(t):void 0),keyKind:n.kind,constraint:de(r),...r.kind===`enum`?{allowed:r.values}:{},...e.index===void 0?{}:{index:e.index}}}function Xn(e,t){if(t.type===`argument`)return t.name;let n=t.occurrences;return(e.index===void 0?n[n.length-1]:n[e.index])?.key??t.name}function Zn(e){return e.type===`argument`?e.values:e.occurrences.map(e=>e.tokens.join(` `))}const Qn=Symbol.for(`clibuilder.answer`);function R(e,t={}){return{[Qn]:`result`,value:e,help:or(t.help),render:t.render}}function z(e){return{[Qn]:`document`,value:String(e)}}function $n(e){return typeof e==`object`&&!!e&&typeof e[Qn]==`string`}function er(e){return $n(e)?e.value:e}function tr(e,t){if(e!==void 0){if(!$n(e))return nr(e,[],t);switch(e[Qn]){case`written`:return;case`document`:return sr(e.value);case`empty`:return sr(Sn(ar({empty:e.value},e.help),t));case`result`:{let n=e.render?.[t];return n?rr(n(e.value),e.help,t):nr(e.value,e.help,t)}}}}function nr(e,t,n){return typeof e==`string`?rr(e,t,n):sr(Sn(ar(ir(e),t),n))}function rr(e,t,n){return t.length===0?sr(e):sr(`${e}${e.endsWith(`
|
|
6
|
+
`)?`
|
|
7
|
+
`:`
|
|
8
|
+
|
|
9
|
+
`}${Sn({help:[...t]},n)}`)}function ir(e){return typeof e==`object`&&e&&!Array.isArray(e)?e:{result:e}}function ar(e,t){if(t.length===0)return e;let{help:n,...r}=e;return{...r,help:[...t]}}function or(e){return e===void 0?[]:typeof e==`string`?[e]:[...e]}function sr(e){return e.endsWith(`
|
|
10
|
+
`)?e:`${e}\n`}function cr(e,t){switch(e.type){case`invalid-key`:return`unknown option ${ur(e.key)}`;case`missing-argument`:return`missing required ${lr(e.name,t,`argument`)}`;case`extra-arguments`:return`unexpected argument${e.values.length>1?`s`:``}: ${e.values.join(`, `)}`;case`invalid-value`:{let n=e.index===void 0?``:`[${e.index}]`,r=e.value===void 0?``:`, received "${e.value}"`;return`invalid value for ${lr(e.key,t)}${n}: ${e.message}${r}`}case`conflicting-options`:return`option ${ur(e.key)} cannot be used with option ${ur(e.conflictsWith)}`;case`expect-single`:return`${lr(e.key,t)} expects a single value, received: ${dr(e.value).join(`, `)}`}}function lr(e,t,n=`option`){return t.arguments?.some(t=>t.name===e)||n===`argument`&&!t.options?.[e]?`argument <${e}>`:`option ${ur(e)}`}function ur(e){return e.length===1?`-${e}`:`--${e}`}function dr(e){return Array.isArray(e)?e:[e]}function fr(e,t){let n=[``];for(let r of e.split(/(\S+\s+)/)){if(r===``)continue;let e=r.replace(/\t/g,` `),i=n.length-1;if(n[i].length+e.length>t){n[i]=n[i].replace(/\s+$/,``);for(let t of e.split(`
|
|
11
|
+
`))n.push(t.replace(/^\s+/,``))}else if(e.includes(`
|
|
12
|
+
`)){let[t,...r]=e.split(`
|
|
13
|
+
`);n[i]+=t;for(let e of r)n.push(e.replace(/^\s+/,``))}else n[i]+=e}return n.join(`
|
|
14
|
+
`)}function pr(e,t){return`
|
|
15
|
+
${[mr(e,t),gr(t),vr(t),br(t),xr(t),Dr(t),Or(t),Ar(t)].filter(e=>!!e).join(`
|
|
16
|
+
|
|
17
|
+
`)}
|
|
18
|
+
`}function mr(e,t){let n=_r(e,t),r=t.commands&&t.commands.length>0,i=`Usage: ${n.join(` `)}${r?` <command>`:``}`;if(t.arguments&&(i+=t.arguments.some(e=>hr(e,!0))?` <arguments>`:` [arguments]`),t.options){let e=t.options;i+=Object.keys(e).some(t=>hr(e[t],!1))?` <options>`:` [options]`}return i}function hr({type:e,default:t},n){return e?!e.isOptional&&t===void 0:n}function gr(e){return e.description?` ${e.description}`:``}function _r(e,t){let n=[t];for(;t.parent;)n.unshift(t.parent),t=t.parent;return[e,...n.map(e=>e.name).filter(e=>e)]}function vr(e){let t=yr(e.commands);return t.length===0?``:`Commands:
|
|
19
|
+
${fr(t.join(`, `),80)}
|
|
20
|
+
|
|
21
|
+
${(e.name?`${e.name} <command> -h`:` <command> -h`).padEnd(25)}Get help for <command>`}function yr(e){let t=[];return e&&e.forEach(e=>{e.alias?t.push(`${e.name} (${e.alias.join(`|`)})`):t.push(e.name)}),t}function br(e){if(!e.arguments)return``;let t=`Arguments:
|
|
22
|
+
`,n=[],r=0;e.arguments.forEach(e=>{let t=e.type?wr(e.name,e.type):`<${e.name}>`;r=Math.max(r,t.length),n.push([t,e.description||``])});let i=Math.max(23,r+2);return t+=n.map(e=>` ${e[0].padEnd(i)}${e[1]}`.trimEnd()).join(`
|
|
23
|
+
`),t}function xr(e){if(!e.options)return``;let t=`Options:
|
|
24
|
+
`,n=[],r=0;for(let t in e.options){let i=e.options[t],a=Sr(t,i),o=Tr(i,Er(t,e.options));n.push([a,o]),r=Math.max(r,a.length)}let i=Math.max(23,r+2);return t+=n.map(e=>` ${e[0].padEnd(i)}${e[1]}`).join(`
|
|
25
|
+
`),t}function Sr(e,t){let n=[...t.alias?t.alias.map(e=>typeof e==`string`?e:e.hidden?void 0:e.alias).filter(e=>e):[],e].sort((e,t)=>e.length-t.length).map(e=>e.length===1?`-${e}`:`--${e}`).join(`|`);return t.type?Cr(n,t.type,hr(t,!1)):`[${n}]`}function Cr(e,t,n){let r=`${e}${ue(t)?` <${de(t)}>`:``}${t.kind===`array`?`...`:``}`;return n?r:`[${r}]`}function wr(e,t){let n=`${e}: ${de(t)}${t.kind===`array`?`...`:``}`;return t.isOptional?`[${n}]`:`<${n}>`}function Tr(e,t){let n=typeof e.default==`string`?`'${e.default}'`:e.default,r=e.default?`${e.description} (default ${n})`:e.description;return t.length===0?r:`${r} (conflicts with ${t.map(e=>e.length===1?`-${e}`:`--${e}`).join(`, `)})`}function Er(e,t){return Object.keys(t).filter(n=>n!==e&&(t[e].conflicts?.includes(n)||t[n].conflicts?.includes(e)))}function Dr(e){return e.alias?`Alias:
|
|
26
|
+
${fr(e.alias.join(`, `),80)}`:``}function Or(e){let t=kr(e);return t===void 0?``:`Config:
|
|
27
|
+
${t}`}function kr(e){if(e.config)return jr(e.config)}function Ar(e){return!e.examples||e.examples.length===0?``:`Examples:
|
|
28
|
+
${e.examples.map(e=>` ${e.description}\n ${e.command}`).join(`
|
|
29
|
+
`)}`}function jr(e){let t=e[`~standard`]?.jsonSchema;if(t)try{return Mr(t.input({target:`draft-2020-12`}))}catch{return}}function Mr(e){if(Array.isArray(e.enum))return e.enum.map(e=>JSON.stringify(e)).join(` | `);if(`const`in e)return JSON.stringify(e.const);let t=e.anyOf??e.oneOf;if(Array.isArray(t))return t.map(Mr).join(` | `);switch(e.type){case`object`:{let t=e.properties??{},n=e.required??[],r=Object.keys(t).map(e=>`${e}${n.includes(e)?``:`?`}: ${Mr(t[e])}`);return r.length===0?`{}`:`{ ${r.join(`, `)} }`}case`array`:{let t=e.items&&typeof e.items==`object`?e.items:{};return t.type===`object`?`Array<${Mr(t)}>`:`${Mr(t)}[]`}case`string`:case`boolean`:case`number`:case`null`:return e.type;case`integer`:return`number`;default:return`unknown`}}function Nr(e,t,n){let r={name:_r(e,t).join(` `),usage:mr(e,t).slice(7)};t.description&&(r.description=t.description),t.alias&&t.alias.length>0&&(r.aliases=[...t.alias]),t.commands&&t.commands.length>0&&(r.commands=t.commands.map(e=>{let t={name:e.name};e.alias&&e.alias.length>0&&(t.aliases=[...e.alias]);let n=e.description?.split(`
|
|
30
|
+
`)[0];return n&&(t.description=n),t})),t.arguments&&t.arguments.length>0&&(r.arguments=t.arguments.map(e=>{let t={name:e.name,required:hr(e,!0),...Fr(e.type)};return e.description&&(t.description=e.description),t}));let i=!t.parent&&!t.name,a=Pr(t.options,i?Object.keys(n):[]);a.length>0&&(r.options=a);let o=kr(t);return o!==void 0&&(r.config=o),t.examples&&t.examples.length>0&&(r.examples=t.examples.map(({command:e,description:t})=>({command:e,description:t}))),r.globalOptions=Pr(n,[]),r}function Pr(e,t){return e?Object.keys(e).filter(e=>!t.includes(e)).map(t=>{let n=e[t],r={name:t},i=(n.alias??[]).map(e=>typeof e==`string`?e:e.hidden?void 0:e.alias).filter(e=>!!e);i.length>0&&(r.aliases=i),Object.assign(r,Fr(n.type)),r.required=hr(n,!1),n.default!==void 0&&(r.default=n.default),n.description&&(r.description=n.description);let a=Er(t,e);return a.length>0&&(r.conflicts=a),r}):[]}function Fr(e){return e?Ir(e):{}}function Ir(e){switch(e.kind){case`string`:return e.pattern?{type:`string`,pattern:String(e.pattern)}:{type:`string`};case`number`:case`int`:{let t={type:e.kind};return e.min!==void 0&&(t.min=e.min),e.max!==void 0&&(t.max=e.max),t}case`literal`:return{type:`literal`,values:[e.value]};case`enum`:return{type:`enum`,values:[...e.values]};case`array`:return{...Ir(e.element),array:!0};default:return{type:e.kind}}}const Lr={"invalid-key":0,"conflicting-options":1,"invalid-value":2,"expect-single":3,"missing-argument":4,"extra-arguments":5};function Rr(e){return e.reduce((e,t)=>!e||Lr[t.type]<Lr[e.type]?t:e,void 0)}const zr={"invalid-key":`unknown-option`,"conflicting-options":`conflicting-options`,"invalid-value":`invalid-value`,"expect-single":`expect-single`,"missing-argument":`missing-argument`,"extra-arguments":`extra-arguments`};function Br(e){return zr[e.type]}function Vr(e,t,n){let r=mr(n,t),i=cr(e,t),a=Br(e);switch(e.type){case`invalid-key`:return{message:i,code:a,details:{option:Ur(e.key)},help:[r,Jr(t,n)]};case`conflicting-options`:return{message:i,code:a,details:{option:Ur(e.key),conflictsWith:Ur(e.conflictsWith)},help:[r]};case`invalid-value`:{let n=Wr(e.key,t);return{message:i,code:a,details:{...n.details,...e.value===void 0?{}:{value:Xr(e.value)}},help:[r,...Yr(e,n.label)]}}case`expect-single`:return{message:i,code:a,details:{...Wr(e.key,t).details,value:Qr(e.value).map(String)},help:[r]};case`missing-argument`:return!t.arguments?.some(t=>t.name===e.name)&&t.options?.[e.name]?{message:i,code:a,details:{option:Ur(e.name)},help:[r,Jr(t,n)]}:{message:i,code:a,details:{argument:e.name},help:[r,qr(t,n)]};case`extra-arguments`:return{message:i,code:a,details:{arguments:e.values},help:[r,qr(t,n)]}}}function Hr(e,t){let n=Gr(e,t),r=(e.commands??[]).map(e=>e.name);return{message:`missing command for \`${n}\``,code:`missing-command`,details:{command:n},help:[mr(t,e),r.length>0?`valid commands for \`${n}\`: ${r.join(`, `)}`:`\`${n}\` has no commands (--help always allowed)`]}}function Ur(e){return e.length===1?`-${e}`:`--${e}`}function Wr(e,t){return t.arguments?.some(t=>t.name===e)?{label:`<${e}>`,details:{argument:e}}:{label:Ur(e),details:{option:Ur(e)}}}function Gr(e,t){let n=[];for(let t=e;t;t=t.parent)t.name&&n.unshift(t.name);return[t,...n].join(` `)}function Kr(e){return!!e?.isOptional}function qr(e,t){let n=e.name||t,r=(e.commands??[]).map(e=>e.name);if(!e.arguments?.length&&r.length>0)return`valid commands for \`${n}\`: ${r.join(`, `)}`;let i=(e.arguments??[]).map(e=>Kr(e.type)?`[${e.name}]`:`<${e.name}>`);return i.length>0?`\`${n}\` takes: ${i.join(` `)}`:`\`${n}\` takes no arguments`}function Jr(e,t){let n=e.name||t,r=Object.keys(e.options??{}).map(Ur);return r.length>0?`valid options for \`${n}\`: ${r.join(`, `)} (--help always allowed)`:`\`${n}\` takes no options (--help always allowed)`}function Yr(e,t){let n=e.index===void 0?``:`[${e.index}]`,r=e.value===void 0?``:` (received ${Qr(e.value).map(Zr).join(`, `)})`;return e.allowed?.length?[`allowed for ${t}${n}: ${e.allowed.join(`, `)}${r}`]:e.constraint?[`expected for ${t}${n}: ${e.constraint}${r}`]:[]}function Xr(e){return Array.isArray(e)?e.map(String):String(e)}function Zr(e){return`"${String(e)}"`}function Qr(e){return Array.isArray(e)?e:[e]}function $r(e){let{name:t,description:n=``,version:r}=e;return{name:t,description:n,version:r,displayLevel:`info`,command:En(n,{format:e.format})}}function ei(e,t,n){let r=et(e,t);Un(r);let{args:i,errors:a}=r,o=a.filter(t=>`key`in t&&ri(e,t.key)).map(oi(e)),s=!o.some(t=>`key`in t&&ai(e,t.key));return{help:i.help,version:i.version,verbose:i.verbose,silent:i.silent,"debug-cli":i[`debug-cli`],values:i,format:s&&i.format||n,errors:o}}function ti(e,t,n,r){return e.flatMap(e=>!(`key`in e)||!ri(n,e.key)||ii(t,e.key)?[e]:r.errors.filter(t=>`key`in t&&t.key===e.key)).map(ni)}function ni(e){return Object.defineProperty(e,"code",{value:Br(e),enumerable:!1,configurable:!0})}function ri(e,t){return F(e,t).length>0}function ii(e,t){let[n,r]=F(e,t);return!!n&&!On(r)}function ai(e,t){return On(F(e,t)[1])}function oi(e){return t=>t.type===`invalid-value`&&ai(e,t.key)?{...t,allowed:xn}:t}function si(e,t){let n=$r(t),r=t.format??`toon`,i=t.output??`axi`;if(!xn.includes(r))throw TypeError(`cli({ format }) must be one of ${xn.join(`, `)}, received ${String(r)}`);let a=n.description,o=jn(),s=/* @__PURE__ */ new Map,c=[],l={},u={},d=[],f=n.command.options,p,m=!1;return{name:n.name,version:n.version||``,description:a,default(e){return n.command=T(n.command,{...n.command,...e}),delete this.default,{...this,parse:v}},command(e){return n.command.commands.push(T(n.command,e)),{...this,parse:v}},use(e){return c.push(e),{...this,parse:v}}};function h(){return p??=(async()=>{let t={host:{name:n.name,version:n.version||``},cwd:e.cwd,ui:li(e,n),registry:o,shared:{get:e=>s.get(e.id),set(e,t){s.set(e.id,t)},has:e=>s.has(e.id)},addCommand(e){n.command.commands.push(T(n.command,e))},addGlobalOption(e,t,n){l[e]=t,u[e]=n},beforeRun(e){d.push(e)},async resolveConfig(){return m=!0,s.get(Mn.id)??{config:void 0,source:{type:`none`},candidates:[]}}};for(let e of c)await e(t);g(),_()})()}function g(){if(Object.keys(l).length===0)return;let{format:e,...t}=f;for(let e of Object.keys(f))delete f[e];Object.assign(f,t,l,{format:e})}function _(){let t=s.get(Mn.id)?.config?.plugins;!m&&Array.isArray(t)&&t.length!==0&&e.ui.warn(`the config lists plugins, but this cli loads none. Plugin loading moved out of clibuilder 12 into @clibuilder/plugins: add .use(plugins()) to the cli.`)}async function v(a){if(ci(a)){e.writeStdout(`${n.version||`not versioned`}\n`);return}e.ui.debug(`argv:`,a.join(` `));let c=Nn(a);await h();let f=En(n.description,{format:r,options:l}),p=ei(f,c,r);p.silent&&(delete c.silent,n.displayLevel=`none`),p.verbose&&(delete c.verbose,n.displayLevel=`debug`),p[`debug-cli`]&&(delete c[`debug-cli`],n.displayLevel=`trace`),e.ui.displayLevel=n.displayLevel,e.ui.dump();for(let t of Object.keys(u)){let r=p.values[t];if(r===void 0)continue;let a=fi(e,n,n.command);return x(await u[t]({value:r,format:p.format,output:i,ui:a}),p.format)}let m=et(n.command,c,f),{args:g,command:_}=m,v=Wn(m,[`help`,`version`]);if(p.version||v.version)return i===`axi`?C():di(e,n,m.command,o).ui.showVersion();if(p.help||v.help)return i===`axi`?S(m.command,f,p.format):di(e,n,m.command,o).ui.showHelp();await Hn(m);let T=ti(m.errors,_,f,p);if(T.length>0){let r=di(e,n,m.command,o).ui,a=ui(_)??t.onUsageError;if(a){let e=await a(T,{command:_,ui:r,format:p.format,exitCode:A.usage});return w(typeof e==`number`?e:A.usage)}if(i===`axi`)return b(Vr(Rr(T),_,n.name),p.format),w(A.usage);for(let e of T)r.error(cr(e,_));return r.showHelp(),w(A.usage)}if(_.config&&!s.has(Mn.id)){let e=_.name?`command '${_.name}'`:`the default command`;throw Error(`${e} declares config, but the cli does not load config. Add .use(config()) from 'clibuilder/config' to the cli.`)}if(d.length>0){let t=di(e,n,m.command,o).ui,r={command:_,config:n.config,format:p.format,output:i,ui:t};try{for(let e of d)await e(r)}catch(e){if(!ae(e))throw e;return y(e,p.format,t),w(e.exitCode)}n.config=r.config}let E=di(e,n,_,o,p.format,i);if(!E.run)return i===`axi`?b(Hr(_,n.name),p.format):E.ui.showHelp(),w(A.usage);i===`axi`&&(E.ui.showHelp=()=>S(_,f,p.format),E.ui.showVersion=()=>C());try{return x(await E.run(g),p.format)}catch(e){if(!ae(e))throw e;return y(e,p.format,E.ui),w(e.exitCode)}}function y(t,n,r){if(!oe(t)){if(i===`axi`){let i=Cn({message:t.message,code:t.code??`error`,details:t.details,help:t.help});e.writeStdout(`${Sn(i,n)}\n`),r.debug(t);return}r.error(t.message);for(let e of t.help)r.error(e)}}function b(t,n){e.writeStdout(`${Sn(Cn(t),n)}\n`)}function x(t,n){if(i===`axi`){let r=tr(t,n);r!==void 0&&e.writeStdout(r)}return er(t)}function S(t,r,i){e.writeStdout(i===`text`?`${pr(n.name,t)}\n`:`${Sn(Nr(n.name,t,r.options),i)}\n`)}function C(){e.writeStdout(`${n.version||`not versioned`}\n`)}function w(t){return e.exit(t),t}function T(e,t){return pi(e,t)}}function ci(e){let t=e.slice(2);return t.length===1&&(t[0]===`--version`||t[0]===`-v`)}function li(e,t){let n=e.ui;return{get displayLevel(){return n.displayLevel},set displayLevel(e){n.displayLevel=e},info:(...e)=>n.info(...e),warn:(...e)=>n.warn(...e),error:(...e)=>n.error(...e),debug:(...e)=>n.debug(...e),showHelp:()=>n.showHelp(t.name,t.command),showVersion:()=>n.showVersion(t.version)}}function ui(e){for(let t=e;t;t=t.parent)if(t.onUsageError)return t.onUsageError}function di(e,t,n,r,i=`toon`,a=`axi`){return{...n,run:n.run,ui:fi(e,t,n),format:i,output:a,config:t.config,cwd:e.cwd,registry:r}}function fi(e,t,n){let r=e.createCommandUI(n.name||t.name);
|
|
31
|
+
// istanbul ignore next
|
|
32
|
+
return r.displayLevel=t.displayLevel,{...r,showVersion:()=>r.showVersion(t.version),showHelp:()=>r.showHelp(t.name,n)}}function pi(e,t){return t=kn(t),t.name&&(t.parent=e),t.commands&&(t.commands=t.commands.map(e=>pi(t,e))),t}function mi(e){let t=!0,n=[];
|
|
33
|
+
// istanbul ignore next
|
|
34
|
+
return{...e,get displayLevel(){return e.displayLevel},set displayLevel(t){e.displayLevel=t},debug:(...r)=>t?n.push([`debug`,r]):e.debug(...r),info:(...r)=>t?n.push([`info`,r]):e.info(...r),warn:(...r)=>t?n.push([`warn`,r]):e.warn(...r),error:(...r)=>t?n.push([`error`,r]):e.error(...r),dump:()=>{t=!1;for(let[t,r]of n.splice(0))e[t](...r)}}}const hi={console:{debug:`stdout`,info:`stdout`,warn:`stderr`,error:`stderr`,answer:`stdout`},axi:{debug:`stderr`,info:`stderr`,warn:`stderr`,error:`stderr`,answer:`stdout`}},gi={none:0,info:1,debug:2,trace:3},_i={error:1,warn:1,info:1,answer:1,debug:2},vi={error:`red`,warn:`yellow`};function yi(e,t){let n=`info`,r=hi[t];function i(t,i){if(_i[t]>gi[n])return;let a=e[r[t]],o=bi(i,a.colour),s=vi[t];a.write(`${s&&a.colour?C(s,o,{validateStream:!1}):o}\n`)}return{get displayLevel(){return n},set displayLevel(e){n=e},debug:(...e)=>i(`debug`,e),info:(...e)=>i(`info`,e),warn:(...e)=>i(`warn`,e),error:(...e)=>i(`error`,e),showHelp(e,t){i(`answer`,[pr(e,t)])},showVersion(e){i(`answer`,[e||`not versioned`])}}}function bi(e,t){return e.map(e=>typeof e==`object`&&e?S(e,{colors:t}):e).join(` `)}function xi(e,t=process.env){if(!e.isTTY)return!1;let n=t.FORCE_COLOR;return n===void 0?t.NO_COLOR?!1:typeof e.hasColors!=`function`||e.hasColors(t):n!==`0`&&n!==`false`}function Si(e,t=process.env){return e.stdout===process.stdout&&Ei(process.stdout),{stdout:Ci(e.stdout,t),stderr:Ci(e.stderr,t)}}function Ci(e,t){return{colour:xi(e,t),write(t){Ti.has(e)||e.write(t)}}}const wi=/* @__PURE__ */ new WeakSet,Ti=/* @__PURE__ */ new WeakSet;function Ei(e){wi.has(e)||(wi.add(e),e.on(`error`,t=>{if(t?.code!==`EPIPE`)throw t;Ti.add(e),process.exitCode=0}))}function Di(e={}){let t=process.cwd(),n=Si(e.streams??{stdout:process.stdout,stderr:process.stderr}),r=e.output??`axi`;return{cwd:t,exit(e){process.exitCode=e},writeStdout(e){n.stdout.write(e)},createCommandUI(){return yi(n,r)},ui:mi(yi(n,r))}}function Oi(e){return si(Di({streams:e.streams,output:e.output}),e)}function B(e,t){return e&&t.startsWith(e+b)?`~${t.slice(e.length)}`:t}async function ki(e){try{return await T(e,`utf8`)}catch(e){if(e.code===`ENOENT`)return;throw e}}function Ai(e){let t=``,n=0;for(;n<e.length;){let r=e[n];if(r===`"`){let r=n+1;for(;r<e.length&&e[r]!==`"`;)r+=e[r]===`\\`?2:1;t+=e.slice(n,r+1),n=r+1}else if(r===`/`&&e[n+1]===`/`)for(;n<e.length&&e[n]!==`
|
|
35
|
+
`;)n++;else if(r===`/`&&e[n+1]===`*`){let t=e.indexOf(`*/`,n+2);n=t===-1?e.length:t+2}else t+=r,n++}return t.replace(/,(\s*[}\]])/g,`$1`)}function V(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var H=/* @__PURE__ */ D((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})),ji=/* @__PURE__ */ D((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})),Mi=/* @__PURE__ */ D((e=>{var t=H(),n=ji();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(`
|
|
36
|
+
`)}};a.defaultYaml={explicit:!1,version:`1.2`},a.defaultTags={"!!":`tag:yaml.org,2002:`},e.Directives=a})),Ni=/* @__PURE__ */ D((e=>{var t=H(),n=ji();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})),Pi=/* @__PURE__ */ D((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})),Fi=/* @__PURE__ */ D((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})),Ii=/* @__PURE__ */ D((e=>{var t=Pi(),n=H(),r=Fi();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}}})),Li=/* @__PURE__ */ D((e=>{var t=Ni(),n=ji(),r=H(),i=Ii(),a=Fi(),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);
|
|
37
|
+
/* istanbul ignore if */
|
|
38
|
+
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__ */ D((e=>{var t=H(),n=Ii(),r=Fi();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})),Ri=/* @__PURE__ */ D((e=>{var t=Li(),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})),zi=/* @__PURE__ */ D((e=>{var t=Ri(),n=H(),r=Ii();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})),Bi=/* @__PURE__ */ D((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(`
|
|
39
|
+
`)?n(r,t):r.includes(`
|
|
40
|
+
`)?`
|
|
41
|
+
`+n(r,t):(e.endsWith(` `)?``:` `)+r,e.stringifyComment=t})),Vi=/* @__PURE__ */ D((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===`
|
|
42
|
+
`)a===t&&(v=i(e,v,r.length)),m=v+r.length+d,h=void 0;else{if(o===` `&&g&&g!==` `&&g!==`
|
|
43
|
+
`&&g!==` `){let t=e[v+1];t&&t!==` `&&t!==`
|
|
44
|
+
`&&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!==`
|
|
45
|
+
`);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})),Hi=/* @__PURE__ */ D((e=>{var t=U(),n=Vi();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]===`
|
|
46
|
+
`){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)+`
|
|
47
|
+
|
|
48
|
+
`;a[e+2]===`\\`&&a[e+3]===`n`&&a[e+4]!==`"`;)l+=`
|
|
49
|
+
`,e+=2;l+=c,a[e+2]===` `&&(l+=`\\`),e+=1,u=e+1}break;default:e+=1}return l=u?l+a.slice(u):a,o?l:n.foldFlowLines(l,c,n.FOLD_QUOTED,r(t,!1))}function s(e,t){if(t.options.singleQuote===!1||t.implicitKey&&e.includes(`
|
|
50
|
+
`)||/[ \t]\n|\n[ \t]/.test(e))return o(e,t);let a=t.indent||(i(e)?` `:``),s=`'`+e.replace(/'/g,`''`).replace(/\n+/g,`$&\n${a}`)+`'`;return t.implicitKey?s:n.foldFlowLines(s,a,n.FOLD_FLOW,r(t,!1))}function c(e,t){let{singleQuote:n}=t.options,r;if(n===!1)r=o;else{let t=e.includes(`"`),i=e.includes(`'`);r=t&&!i?s:i&&!t?o:n?s:o}return r(e,t)}let l;try{l=RegExp(`(^|(?<!
|
|
51
|
+
))
|
|
52
|
+
+(?!
|
|
53
|
+
|$)`,`g`)}catch{l=/\n+(?!\n|$)/g}function u({comment:e,type:o,value:s},u,d,f){let{blockQuote:p,commentString:m,lineWidth:h}=u.options;if(!p||/\n[\t ]+$/.test(s))return c(s,u);let g=u.indent||(u.forceBlockIndent||i(s)?` `:``),_=p===`literal`?!0:p===`folded`||o===t.Scalar.BLOCK_FOLDED?!1:o===t.Scalar.BLOCK_LITERAL||!a(s,h,g.length);if(!s)return _?`|
|
|
54
|
+
`:`>
|
|
55
|
+
`;let v,y;for(y=s.length;y>0;--y){let e=s[y-1];if(e!==`
|
|
56
|
+
`&&e!==` `&&e!==` `)break}let b=s.substring(y),x=b.indexOf(`
|
|
57
|
+
`);x===-1?v=`-`:s===b||x!==b.length-1?(v=`+`,f&&f()):v=``,b&&=(s=s.slice(0,-b.length),b[b.length-1]===`
|
|
58
|
+
`&&(b=b.slice(0,-1)),b.replace(l,`$&${g}`));let S=!1,C,w=-1;for(C=0;C<s.length;++C){let e=s[C];if(e===` `)S=!0;else if(e===`
|
|
59
|
+
`)w=C;else break}let T=s.substring(0,w<C?w+1:C);T&&=(s=s.substring(T.length),T.replace(/\n+/g,`$&${g}`));let E=(S?g?`2`:`1`:``)+v;if(e&&(E+=` `+m(e.replace(/ ?[\r\n]+/g,` `)),d&&d()),!_){let e=s.replace(/\n+/g,`
|
|
60
|
+
$&`).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(`
|
|
61
|
+
`)||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(`
|
|
62
|
+
`)?c(d,a):u(e,a,o,s);if(!p&&!g&&l!==t.Scalar.PLAIN&&d.includes(`
|
|
63
|
+
`))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})),Ui=/* @__PURE__ */ D((e=>{var t=Ni(),n=H(),r=Bi(),i=Hi();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})),Wi=/* @__PURE__ */ D((e=>{var t=H(),n=U(),r=Ui(),i=Bi();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?`
|
|
64
|
+
`:``,S){let e=p(S);E+=`\n${i.indentComment(e,o.indent)}`}T===``&&!o.inFlow?E===`
|
|
65
|
+
`&&C&&(E=`
|
|
66
|
+
|
|
67
|
+
`):E+=`\n${o.indent}`}else if(!_&&t.isCollection(a)){let e=T[0],t=T.indexOf(`
|
|
68
|
+
`),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]===`
|
|
69
|
+
`)&&(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})),Gi=/* @__PURE__ */ D((e=>{var t=O(`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})),Ki=/* @__PURE__ */ D((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})),qi=/* @__PURE__ */ D((e=>{var t=Gi(),n=Ki(),r=Ui(),i=H(),a=Fi();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})),Ji=/* @__PURE__ */ D((e=>{var t=Ri(),n=Wi(),r=qi(),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})),Yi=/* @__PURE__ */ D((e=>{var t=H(),n=Ui(),r=Bi();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}`:`
|
|
70
|
+
`}}return e?(_+=`
|
|
71
|
+
`+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(`
|
|
72
|
+
`),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}`:`
|
|
73
|
+
`;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})),Xi=/* @__PURE__ */ D((e=>{var t=Yi(),n=qi(),r=zi(),i=H(),a=Ji(),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})),Zi=/* @__PURE__ */ D((e=>{var t=H(),n=Xi();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)}})),Qi=/* @__PURE__ */ D((e=>{var t=Ri(),n=Yi(),r=zi(),i=H(),a=U(),o=Fi(),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})),$i=/* @__PURE__ */ D((e=>{var t=H(),n=Qi();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)}})),ea=/* @__PURE__ */ D((e=>{var t=Hi();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)}}})),ta=/* @__PURE__ */ D((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})),na=/* @__PURE__ */ D((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})),ra=/* @__PURE__ */ D((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})),ia=/* @__PURE__ */ D((e=>{var t=U(),n=ra();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})),aa=/* @__PURE__ */ D((e=>{var t=ra();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`)}})),oa=/* @__PURE__ */ D((e=>{var t=Zi(),n=ta(),r=$i(),i=ea(),a=na(),o=ia(),s=aa();e.schema=[t.map,r.seq,i.string,n.nullTag,a.boolTag,s.intOct,s.int,s.intHex,o.floatNaN,o.floatExp,o.float]})),sa=/* @__PURE__ */ D((e=>{var t=U(),n=Zi(),r=$i();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}})})),ca=/* @__PURE__ */ D((e=>{var t=O(`buffer`),n=U(),r=Hi();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?`
|
|
74
|
+
`:` `)}return r.stringifyString({comment:e,type:i,value:u},o,s,c)}}})),la=/* @__PURE__ */ D((e=>{var t=H(),n=Ji(),r=U(),i=Qi();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})),ua=/* @__PURE__ */ D((e=>{var t=H(),n=Fi(),r=Xi(),i=Qi(),a=la(),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})),da=/* @__PURE__ */ D((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})),fa=/* @__PURE__ */ D((e=>{var t=U(),n=ra();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})),pa=/* @__PURE__ */ D((e=>{var t=ra();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})),ma=/* @__PURE__ */ D((e=>{var t=H(),n=Ji(),r=Xi(),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})),ha=/* @__PURE__ */ D((e=>{var t=ra();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})),ga=/* @__PURE__ */ D((e=>{var t=Zi(),n=ta(),r=$i(),i=ea(),a=ca(),o=da(),s=fa(),c=pa(),l=Ki(),u=ua(),d=la(),f=ma(),p=ha();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]})),_a=/* @__PURE__ */ D((e=>{var t=Zi(),n=ta(),r=$i(),i=ea(),a=na(),o=ia(),s=aa(),c=oa(),l=sa(),u=ca(),d=Ki(),f=ua(),p=la(),m=ga(),h=ma(),g=ha();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})),va=/* @__PURE__ */ D((e=>{var t=H(),n=Zi(),r=$i(),i=ea(),a=_a();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}}})),ya=/* @__PURE__ */ D((e=>{var t=H(),n=Ui(),r=Bi();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(`
|
|
75
|
+
`)?(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(`
|
|
76
|
+
`)+`
|
|
77
|
+
`}e.stringifyDocument=i})),ba=/* @__PURE__ */ D((e=>{var t=Li(),n=zi(),r=H(),i=Ji(),a=Fi(),o=va(),s=ya(),c=Ni(),l=Pi(),u=Ri(),d=Mi(),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})),xa=/* @__PURE__ */ D((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)+`…
|
|
78
|
+
`),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`}}})),Sa=/* @__PURE__ */ D((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})),Ca=/* @__PURE__ */ D((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(`
|
|
79
|
+
`))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})),wa=/* @__PURE__ */ D((e=>{var t=Ca();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})),Ta=/* @__PURE__ */ D((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})),Ea=/* @__PURE__ */ D((e=>{var t=Ji(),n=Xi(),r=Sa(),i=Ca(),a=wa(),o=Ta();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+=`
|
|
80
|
+
`+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+=`
|
|
81
|
+
`+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})),Da=/* @__PURE__ */ D((e=>{var t=Qi(),n=Sa(),r=wa();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})),Oa=/* @__PURE__ */ D((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})),ka=/* @__PURE__ */ D((e=>{var t=H(),n=Ji(),r=Xi(),i=Qi(),a=Oa(),o=Sa(),s=Ca(),c=Ta();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+=`
|
|
82
|
+
`+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+=`
|
|
83
|
+
`+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+=`
|
|
84
|
+
`+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+=`
|
|
85
|
+
`+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})),Aa=/* @__PURE__ */ D((e=>{var t=H(),n=U(),r=Xi(),i=Qi(),a=Ea(),o=Da(),s=ka();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})),ja=/* @__PURE__ */ D((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?`
|
|
86
|
+
`.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)+`
|
|
87
|
+
`;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`;
|
|
88
|
+
/* istanbul ignore if already caught in lexer */
|
|
89
|
+
if(i&&(r=r.slice(0,-1)),r&&n.length<d){let e=`Block scalar lines must not be less indented than their ${s.indent?`explicit indentation indicator`:`first line`}`;a(f-r.length-(i?2:1),`BAD_INDENT`,e),n=``}c===t.Scalar.BLOCK_LITERAL?(m+=h+n.slice(d)+r,h=`
|
|
90
|
+
`):n.length>d||r[0]===` `?(h===` `?h=`
|
|
91
|
+
`:!g&&h===`
|
|
92
|
+
`&&(h=`
|
|
93
|
+
|
|
94
|
+
`),m+=h+n.slice(d)+r,h=`
|
|
95
|
+
`,g=!0):r===``?h===`
|
|
96
|
+
`?m+=`
|
|
97
|
+
`:h=`
|
|
98
|
+
`:(m+=h+r,h=` `,g=!1)}switch(s.chomp){case`-`:break;case`+`:for(let e=u;e<l.length;++e)m+=`
|
|
99
|
+
`+l[e][0].slice(d);m[m.length-1]!==`
|
|
100
|
+
`&&(m+=`
|
|
101
|
+
`);break;default:m+=`
|
|
102
|
+
`}let _=o+s.length+n.source.length;return{value:m,type:c,comment:s.comment,range:[o,_,_]}}function r({offset:e,props:t},n,r){
|
|
103
|
+
/* istanbul ignore if should not happen */
|
|
104
|
+
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;
|
|
105
|
+
/* istanbul ignore next should not happen */
|
|
106
|
+
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})),Ma=/* @__PURE__ */ D((e=>{var t=U(),n=Oa();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;
|
|
107
|
+
/* istanbul ignore next should not happen */
|
|
108
|
+
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]){
|
|
109
|
+
/* istanbul ignore next should not happen */
|
|
110
|
+
case` `:n=`a tab character`;break;case`,`:n=`flow indicator character ,`;break;case`%`:n=`directive indicator character %`;break;case`|`:case`>`:n=`block scalar indicator ${e[0]}`;break;case`@`:case"`":n=`reserved character ${e[0]}`}return n&&t(0,`BAD_SCALAR_START`,`Plain value cannot start with ${n}`),o(e)}function a(e,t){return(e[e.length-1]!==`'`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing 'quote`),o(e.slice(1,-1)).replace(/''/g,`'`)}function o(e){let t=/(.*?)\r?\n/sy,n=t.exec(e);if(!n)return e;let r,i;try{r=RegExp(`(?<![ ])[ ]+$`),i=RegExp(`^[ ]+|(?<![ ])[ ]+$`,`g`)}catch{r=/[ \t]+$/,i=/^[ \t]+|[ \t]+$/g}let a=n[1].replace(r,``),o=` `,s=t.lastIndex;for(;n=t.exec(e);){let e=n[1].replace(i,``);e===``?o===`
|
|
111
|
+
`?a+=o:o=`
|
|
112
|
+
`:(a+=o+e,o=` `),s=t.lastIndex}let c=/[ \t]*(.*)/sy;return c.lastIndex=s,n=c.exec(e),a+o+(n?.[1]??``)}function s(e,t){let n=``;for(let r=1;r<e.length-1;++r){let i=e[r];if(i!==`\r`||e[r+1]!==`
|
|
113
|
+
`){if(i===`
|
|
114
|
+
`){let{fold:t,offset:i}=c(e,r);n+=t,r=i}else if(i===`\\`){let i=e[++r],a=l[i];if(a)n+=a;else if(i===`
|
|
115
|
+
`)for(i=e[r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`\r`&&e[r+1]===`
|
|
116
|
+
`)for(i=e[++r+1];i===` `||i===` `;)i=e[++r+1];else if(i===`x`||i===`u`||i===`U`){let a=i===`x`?2:i===`u`?4:8;n+=u(e,r+1,a,t),r+=a}else{let i=e.substr(r-1,2);t(r-1,`BAD_DQ_ESCAPE`,`Invalid escape sequence ${i}`),n+=i}}else if(i===` `||i===` `){let t=r,a=e[r+1];for(;a===` `||a===` `;)a=e[++r+1];a!==`
|
|
117
|
+
`&&(a!==`\r`||e[r+2]!==`
|
|
118
|
+
`)&&(n+=r>t?e.slice(t,r+1):i)}else n+=i}}return(e[e.length-1]!==`"`||e.length===1)&&t(e.length,`MISSING_CHAR`,`Missing closing "quote`),n}function c(e,t){let n=``,r=e[t+1];for(;(r===` `||r===` `||r===`
|
|
119
|
+
`||r===`\r`)&&(r!==`\r`||e[t+2]===`
|
|
120
|
+
`);)r===`
|
|
121
|
+
`&&(n+=`
|
|
122
|
+
`),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:`
|
|
123
|
+
`,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})),Na=/* @__PURE__ */ D((e=>{var t=H(),n=U(),r=ja(),i=Ma();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})),Pa=/* @__PURE__ */ D((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})),Fa=/* @__PURE__ */ D((e=>{var t=Li(),n=H(),r=Aa(),i=Na(),a=Oa(),o=Pa();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})),Ia=/* @__PURE__ */ D((e=>{var t=ba(),n=Fa(),r=Oa(),i=Sa();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})),La=/* @__PURE__ */ D((e=>{var t=O(`process`),n=Mi(),r=ba(),i=xa(),a=H(),o=Ia(),s=Oa();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?`
|
|
124
|
+
|
|
125
|
+
`:`
|
|
126
|
+
`)+(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}}}})),Ra=/* @__PURE__ */ D((e=>{var t=ja(),n=Ma(),r=xa(),i=Hi();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:`
|
|
127
|
+
`}];switch(c[0]){case`|`:case`>`:{let e=c.indexOf(`
|
|
128
|
+
`),t=c.substring(0,e),n=c.substring(e+1)+`
|
|
129
|
+
`,i=[{type:`block-scalar-header`,offset:o,indent:r,source:t}];return l(i,u)||i.push({type:`newline`,offset:-1,indent:r,source:`
|
|
130
|
+
`}),{type:`block-scalar`,offset:o,indent:r,props:i,source:n}}case`"`:return{type:`double-quoted-scalar`,offset:o,indent:r,source:c,end:u};case`'`:return{type:`single-quoted-scalar`,offset:o,indent:r,source:c,end:u};default:return{type:`scalar`,offset:o,indent:r,source:c,end:u}}}function s(e,t,n={}){let{afterKey:r=!1,implicitKey:a=!1,inFlow:o=!1,type:s}=n,l=`indent`in e?e.indent:null;if(r&&typeof l==`number`&&(l+=2),!s)switch(e.type){case`single-quoted-scalar`:s=`QUOTE_SINGLE`;break;case`double-quoted-scalar`:s=`QUOTE_DOUBLE`;break;case`block-scalar`:{let t=e.props[0];if(t.type!==`block-scalar-header`)throw Error(`Invalid block scalar header`);s=t.source[0]===`>`?`BLOCK_FOLDED`:`BLOCK_LITERAL`;break}default:s=`PLAIN`}let d=i.stringifyString({type:s,value:t},{implicitKey:a||l===null,indent:l!==null&&l>0?` `.repeat(l):``,inFlow:o,options:{blockQuote:!0,lineWidth:-1}});switch(d[0]){case`|`:case`>`:c(e,d);break;case`"`:u(e,d,`double-quoted-scalar`);break;case`'`:u(e,d,`single-quoted-scalar`);break;default:u(e,d,`scalar`)}}function c(e,t){let n=t.indexOf(`
|
|
131
|
+
`),r=t.substring(0,n),i=t.substring(n+1)+`
|
|
132
|
+
`;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:`
|
|
133
|
+
`});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:`
|
|
134
|
+
`};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})),za=/* @__PURE__ */ D((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})),Ba=/* @__PURE__ */ D((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})),Va=/* @__PURE__ */ D((e=>{var t=Ra(),n=za(),r=Ba();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`);
|
|
135
|
+
/* istanbul ignore next */
|
|
136
|
+
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`
|
|
137
|
+
`:case`\r
|
|
138
|
+
`: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})),Ha=/* @__PURE__ */ D((e=>{var t=Va();function n(e){switch(e){case void 0:case` `:case`
|
|
139
|
+
`: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(` ,[]{}
|
|
140
|
+
\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===`
|
|
141
|
+
`||t===`\r`&&this.buffer[e+1]===`
|
|
142
|
+
`}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let n=0;for(;t===` `;)t=this.buffer[++n+e];if(t===`\r`){let t=this.buffer[n+e+1];if(t===`
|
|
143
|
+
`||!t&&!this.atEnd)return e+n+1}return t===`
|
|
144
|
+
`||n>=this.indentNext||!t&&!this.atEnd?e+n:-1}if(t===`-`||t===`.`){let t=this.buffer.substr(e,3);if((t===`---`||t===`...`)&&n(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!=`number`||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
145
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]===`\r`&&--e,this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case`stream`:return yield*this.parseStream();case`line-start`:return yield*this.parseLineStart();case`block-start`:return yield*this.parseBlockStart();case`doc`:return yield*this.parseDocument();case`flow`:return yield*this.parseFlowCollection();case`quoted-scalar`:return yield*this.parseQuotedScalar();case`block-scalar`:return yield*this.parseBlockScalar();case`plain-scalar`:return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext(`stream`);if(e[0]===t.BOM&&(yield*this.pushCount(1),e=e.substring(1)),e[0]===`%`){let t=e.length,n=e.indexOf(`#`);for(;n!==-1;){let r=e[n-1];if(r===` `||r===` `){t=n-1;break}n=e.indexOf(`#`,n+1)}for(;;){let n=e[t-1];if(n===` `||n===` `)--t;else break}let r=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-r),this.pushNewline(),`stream`}if(this.atLineEnd()){let t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),`stream`}return yield t.DOCUMENT,yield*this.parseLineStart()}*parseLineStart(){let e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext(`line-start`);if(e===`-`||e===`.`){if(!this.atEnd&&!this.hasChars(4))return this.setNext(`line-start`);let e=this.peek(3);if((e===`---`||e===`...`)&&n(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,e===`---`?`doc`:`stream`}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!n(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){let[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext(`block-start`);if((e===`-`||e===`?`||e===`:`)&&n(t)){let e=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=e,`block-start`}return`doc`}*parseDocument(){yield*this.pushSpaces(!0);let e=this.getLine();if(e===null)return this.setNext(`doc`);let t=yield*this.pushIndicators();switch(e[t]){case`#`:yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),`doc`;case`*`:return yield*this.pushUntil(s),`doc`;case`"`:case`'`:return yield*this.parseQuotedScalar();case`|`:case`>`:return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,r,i=-1;do e=yield*this.pushNewline(),e>0?(r=yield*this.pushSpaces(!1),this.indentValue=i=r):r=0,r+=yield*this.pushSpaces(!0);while(e+r>0);let a=this.getLine();if(a===null)return this.setNext(`flow`);if((i!==-1&&i<this.indentNext&&a[0]!==`#`||i===0&&(a.startsWith(`---`)||a.startsWith(`...`))&&n(a[3]))&&(i!==this.indentNext-1||this.flowLevel!==1||a[0]!==`]`&&a[0]!==`}`))return this.flowLevel=0,yield t.FLOW_END,yield*this.parseLineStart();let o=0;for(;a[o]===`,`;)o+=yield*this.pushCount(1),o+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(o+=yield*this.pushIndicators(),a[o]){case void 0:return`flow`;case`#`:return yield*this.pushCount(a.length-o),`flow`;case`{`:case`[`:return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,`flow`;case`}`:case`]`:return yield*this.pushCount(1),this.flowKey=!0,--this.flowLevel,this.flowLevel?`flow`:`doc`;case`*`:return yield*this.pushUntil(s),`flow`;case`"`:case`'`:return this.flowKey=!0,yield*this.parseQuotedScalar();case`:`:{let e=this.charAt(1);if(this.flowKey||n(e)||e===`,`)return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),`flow`}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){let e=this.charAt(0),t=this.buffer.indexOf(e,this.pos+1);if(e===`'`)for(;t!==-1&&this.buffer[t+1]===`'`;)t=this.buffer.indexOf(`'`,t+2);else for(;t!==-1;){let e=0;for(;this.buffer[t-1-e]===`\\`;)e+=1;if(e%2==0)break;t=this.buffer.indexOf(`"`,t+1)}let n=this.buffer.substring(0,t),r=n.indexOf(`
|
|
146
|
+
`,this.pos);if(r!==-1){for(;r!==-1;){let e=this.continueScalar(r+1);if(e===-1)break;r=n.indexOf(`
|
|
147
|
+
`,e)}r!==-1&&(t=r-(n[r-1]===`\r`?2:1))}if(t===-1){if(!this.atEnd)return this.setNext(`quoted-scalar`);t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?`flow`:`doc`}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){let t=this.buffer[++e];if(t===`+`)this.blockScalarKeep=!0;else if(t>`0`&&t<=`9`)this.blockScalarIndent=Number(t)-1;else if(t!==`-`)break}return yield*this.pushUntil(e=>n(e)||e===`#`)}*parseBlockScalar(){let e=this.pos-1,n=0,r;loop:for(let t=this.pos;r=this.buffer[t];++t)switch(r){case` `:n+=1;break;case`
|
|
148
|
+
`:e=t,n=0;break;case`\r`:{let e=this.buffer[t+1];if(!e&&!this.atEnd)return this.setNext(`block-scalar`);if(e===`
|
|
149
|
+
`)break}default:break loop}if(!r&&!this.atEnd)return this.setNext(`block-scalar`);if(n>=this.indentNext){this.indentNext=this.blockScalarIndent===-1?n:this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{let t=this.continueScalar(e+1);if(t===-1)break;e=this.buffer.indexOf(`
|
|
150
|
+
`,t)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext(`block-scalar`);e=this.buffer.length}}let i=e+1;for(r=this.buffer[i];r===` `;)r=this.buffer[++i];if(r===` `){for(;r===` `||r===` `||r===`\r`||r===`
|
|
151
|
+
`;)r=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let t=e-1,r=this.buffer[t];r===`\r`&&(r=this.buffer[--t]);let i=t;for(;r===` `;)r=this.buffer[--t];if(r===`
|
|
152
|
+
`&&t>=this.pos&&t+1+n>i)e=t;else break}while(1);return yield t.SCALAR,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){let e=this.flowLevel>0,r=this.pos-1,i=this.pos-1,o;for(;o=this.buffer[++i];)if(o===`:`){let t=this.buffer[i+1];if(n(t)||e&&a.has(t))break;r=i}else if(n(o)){let t=this.buffer[i+1];if(o===`\r`&&(t===`
|
|
153
|
+
`?(i+=1,o=`
|
|
154
|
+
`,t=this.buffer[i+1]):r=i),t===`#`||e&&a.has(t))break;if(o===`
|
|
155
|
+
`){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===`
|
|
156
|
+
`?yield*this.pushCount(1):e===`\r`&&this.charAt(1)===`
|
|
157
|
+
`?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)}}})),Ua=/* @__PURE__ */ D((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}}}}})),Wa=/* @__PURE__ */ D((e=>{var t=O(`process`),n=Va(),r=Ha();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;
|
|
158
|
+
/* istanbul ignore next should not happen */
|
|
159
|
+
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});return}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)}
|
|
160
|
+
/* istanbul ignore next should not happen */
|
|
161
|
+
yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){let t=e??this.stack.pop();
|
|
162
|
+
/* istanbul ignore if should not happen */
|
|
163
|
+
if(!t)yield{type:`error`,offset:this.offset,source:``,message:`Tried to pop an empty stack`};else if(this.stack.length===0)yield t;else{let e=this.peek(1);switch(t.type===`block-scalar`?t.indent=`indent`in e?e.indent:0:t.type===`flow-collection`&&e.type===`document`&&(t.indent=0),t.type===`flow-collection`&&u(t),e.type){case`document`:e.value=t;break;case`block-scalar`:e.props.push(t);break;case`block-map`:{let n=e.items[e.items.length-1];if(n.value){e.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}if(n.sep)n.value=t;else{Object.assign(n,{key:t,sep:[]}),this.onKeyLine=!n.explicitKey;return}break}case`block-seq`:{let n=e.items[e.items.length-1];n.value?e.items.push({start:[],value:t}):n.value=t;break}case`flow-collection`:{let n=e.items[e.items.length-1];!n||n.value?e.items.push({start:[],key:t,sep:[]}):n.sep?n.value=t:Object.assign(n,{key:t,sep:[]});return}
|
|
164
|
+
/* istanbul ignore next should not happen */
|
|
165
|
+
default:yield*this.pop(),yield*this.pop(t)}if((e.type===`document`||e.type===`block-map`||e.type===`block-seq`)&&(t.type===`block-map`||t.type===`block-seq`)){let n=t.items[t.items.length-1];n&&!n.sep&&!n.value&&n.start.length>0&&a(n.start)===-1&&(t.indent===0||n.start.every(e=>e.type!==`comment`||e.indent<t.indent))&&(e.type===`document`?e.end=n.start:e.items.push({start:n.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case`directive-line`:yield{type:`directive`,offset:this.offset,source:this.source};return;case`byte-order-mark`:case`space`:case`comment`:case`newline`:yield this.sourceToken;return;case`doc-mode`:case`doc-start`:{let e={type:`document`,offset:this.offset,start:[]};this.type===`doc-start`&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case`doc-start`:a(e.start)===-1?e.start.push(this.sourceToken):(yield*this.pop(),yield*this.step());return;case`anchor`:case`tag`:case`space`:case`comment`:case`newline`:e.start.push(this.sourceToken);return}let t=this.startBlockValue(e);t?this.stack.push(t):yield{type:`error`,offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type===`map-value-ind`){let t=c(s(this.peek(2))),n;e.end?(n=e.end,n.push(this.sourceToken),delete e.end):n=[this.sourceToken];let r={type:`block-map`,offset:e.offset,indent:e.indent,items:[{start:t,key:e,sep:n}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case`space`:case`comment`:case`newline`:e.props.push(this.sourceToken);return;case`scalar`:if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let e=this.source.indexOf(`
|
|
166
|
+
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
167
|
+
`,e)+1}yield*this.pop();break;
|
|
168
|
+
/* istanbul ignore next should not happen */
|
|
169
|
+
default:yield*this.pop(),yield*this.step()}}*blockMap(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(this.onKeyLine=!1,t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){l(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){let n=!this.onKeyLine&&this.indent===e.indent,r=n&&(t.sep||t.explicitKey)&&this.type!==`seq-item-ind`,a=[];if(r&&t.sep&&!t.value){let n=[];for(let r=0;r<t.sep.length;++r){let i=t.sep[r];switch(i.type){case`newline`:n.push(r);break;case`space`:break;case`comment`:i.indent>e.indent&&(n.length=0);break;default:n.length=0}}n.length>=2&&(a=t.sep.splice(n[1]))}switch(this.type){case`anchor`:case`tag`:r||t.value?(a.push(this.sourceToken),e.items.push({start:a}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`explicit-key-ind`:!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):r||t.value?(a.push(this.sourceToken),e.items.push({start:a,explicitKey:!0})):this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case`map-value-ind`:if(t.explicitKey){if(!t.sep){if(i(t.start,`newline`))Object.assign(t,{key:null,sep:[this.sourceToken]});else{let e=c(t.start);this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:null,sep:[this.sourceToken]}]})}}else if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(i(t.sep,`map-value-ind`))this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:a,key:null,sep:[this.sourceToken]}]});else if(o(t.key)&&!i(t.sep,`newline`)){let e=c(t.start),n=t.key,r=t.sep;r.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:e,key:n,sep:r}]})}else a.length>0?t.sep=t.sep.concat(a,this.sourceToken):t.sep.push(this.sourceToken)}else t.sep?t.value||r?e.items.push({start:a,key:null,sep:[this.sourceToken]}):i(t.sep,`map-value-ind`)?this.stack.push({type:`block-map`,offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);r||t.value?(e.items.push({start:a,key:n,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(n):(Object.assign(t,{key:n,sep:[]}),this.onKeyLine=!0);return}default:{let r=this.startBlockValue(e);if(r){if(r.type===`block-seq`){if(!t.explicitKey&&t.sep&&!i(t.sep,`newline`)){yield*this.pop({type:`error`,offset:this.offset,message:`Unexpected block-seq-ind on same line with key`,source:this.source});return}}else n&&e.items.push({start:a});this.stack.push(r);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){let t=e.items[e.items.length-1];switch(this.type){case`newline`:if(t.value){let n=`end`in t.value?t.value.end:void 0;(Array.isArray(n)?n[n.length-1]:void 0)?.type===`comment`?n?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case`space`:case`comment`:if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){let n=e.items[e.items.length-2]?.value?.end;if(Array.isArray(n)){l(n,t.start),n.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case`anchor`:case`tag`:if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case`seq-item-ind`:if(this.indent!==e.indent)break;t.value||i(t.start,`seq-item-ind`)?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){let t=this.startBlockValue(e);if(t){this.stack.push(t);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){let t=e.items[e.items.length-1];if(this.type===`flow-error-end`){let e;do yield*this.pop(),e=this.peek(1);while(e?.type===`flow-collection`)}else if(e.end.length===0){switch(this.type){case`comma`:case`explicit-key-ind`:!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case`map-value-ind`:!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case`space`:case`comment`:case`newline`:case`anchor`:case`tag`:!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case`alias`:case`scalar`:case`single-quoted-scalar`:case`double-quoted-scalar`:{let n=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:n,sep:[]}):t.sep?this.stack.push(n):Object.assign(t,{key:n,sep:[]});return}case`flow-map-end`:case`flow-seq-end`:e.end.push(this.sourceToken);return}let n=this.startBlockValue(e);
|
|
170
|
+
/* istanbul ignore else should not happen */
|
|
171
|
+
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(`
|
|
172
|
+
`)+1;for(;e!==0;)this.onNewLine(this.offset+e),e=this.source.indexOf(`
|
|
173
|
+
`,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())}}}})),Ga=/* @__PURE__ */ D((e=>{var t=La(),n=ba(),r=xa(),i=Gi(),a=H(),o=Ua(),s=Wa();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})),Ka=(/* @__PURE__ */ D((e=>{var t=La(),n=ba(),r=va(),i=xa(),a=Li(),o=H(),s=Ji(),c=U(),l=Xi(),u=Qi();Va();var d=Ha(),f=Ua(),p=Wa(),m=Ga(),h=ji();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 qa=[`replace`,`patch`,`combine`,`remove`];function Ja(e){return qa.includes(e)}const Ya=/^---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/;function Xa(e,t){let n=Ya.exec(e);if(!n)return{metadata:{},body:e};let r=e.slice(n[0].length);try{let e=(0,Ka.parse)(n[1]);if(e==null)return{metadata:{},body:r};if(V(e))return{metadata:e,body:r}}catch{}return t(`frontmatter-invalid`,`frontmatter is not a YAML mapping; it is ignored`),{metadata:{},body:r}}function Za(e,t){let n=e.merge;if(n!==void 0)return Ja(n)?n:(t(`merge-unknown`,`unknown merge "${String(n)}"; read as patch`),`patch`)}function Qa(e){return ro(e).trim().length>0}const $a=/^\s*<!--\s*merge:\s*([\w-]*)\s*-->\s*$/,eo=/^ {0,3}(#{1,6})(?:[ \t]+(.*?))?(?:[ \t]+#+)?[ \t]*$/,to=/^ {0,3}(`{3,}|~{3,})/;function no(){let e;return t=>{if(e)return RegExp(`^ {0,3}${e[0]==="`"?"`":`~`}{${e.length},}\\s*$`).test(t)&&(e=void 0),!0;let n=to.exec(t);return n?(e=n[1],!0):!1}}function ro(e){let t=no();return e.split(`
|
|
174
|
+
`).filter(e=>t(e)||!$a.test(e)).join(`
|
|
175
|
+
`)}function io(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}function ao(e){let t=no(),n;for(let r of e.split(`
|
|
176
|
+
`)){if(t(r))continue;let e=eo.exec(r);e&&(n=Math.min(n??6,e[1].length))}return n}function oo(e,t){let n=ao(e),r={top:n,preamble:[],children:[]},i=[],a=no(),o;for(let s of e.split(`
|
|
177
|
+
`)){let e=a(s),c=e?null:eo.exec(s);if(c){let e=c[1].length,t={depth:e-(n??e),level:e,title:(c[2]??``).trim(),heading:s.trimEnd(),marker:void 0,text:[],children:[]};for(;(i.at(-1)?.level??0)>=e;)i.pop();(i.at(-1)?.children??r.children).push(t),i.push(t),o=t;continue}if(o&&!e){if(!s.trim())continue;let e=$a.exec(s);if(e){let n=e[1];Ja(n)?o.marker=n:(t(`marker-unknown`,`unknown merge "${n}" on "${o.title}"; read as patch`),o.marker=`patch`),o=void 0;continue}}o=void 0,(i.at(-1)?.text??r.preamble).push(s)}return r}function so(e){let t=0,n=e.length;for(;t<n&&!e[t].trim();)t++;for(;n>t&&!e[n-1].trim();)n--;return e.slice(t,n)}function co(){return{top:void 0,preamble:[],preambleSources:[],children:[],removed:[],joined:!1}}function lo(e,t){return e?`${e} > ${t}`:t}function uo(e,t,{warn:n}){let r=/* @__PURE__ */ new Set;for(let i of e){let e=io(i.title);r.has(e)&&n(`heading-repeated`,`heading path "${lo(t,i.title)}" appears more than once; the first is matched`),r.add(e),uo(i.children,lo(t,i.title),{warn:n})}}function fo(e,t,{warn:n}){n(`marker-unmatched`,`"<!-- merge: ${e.marker} -->" on "${lo(t,e.title)}" matches no section below`)}function po(e,t,n,r){let i=lo(n,e.title),a=e.children.flatMap(e=>(e.marker&&fo(e,i,r),e.marker===`remove`?[]:[po(e,e.marker??t,i,r)])),o=so(e.text);return{depth:e.depth,title:e.title,heading:e.heading,level:e.level,text:o,sources:o.length?[{contribution:r.label,operation:t}]:[],children:a}}function mo(e,t){return e.length&&t.length?[...e,``,...t]:[...e,...t]}function ho(e,t,n,r,i){let a=[...e],o=[],s=/* @__PURE__ */ new Set;for(let c of t){let t=c.marker??n,l=io(c.title),u=s.has(l)?-1:e.findIndex(e=>io(e.title)===l);if(s.add(l),u===-1){c.marker&&fo(c,r,i),t!==`remove`&&o.push(po(c,t,r,i));continue}let d=e[u],f=lo(r,d.title);if(t===`remove`){a[u]=void 0,i.composed.removed.push({path:f,by:i.label});continue}if(t===`replace`){a[u]={...po(c,`replace`,r,i),depth:d.depth};continue}let p=so(c.text),m=p.length?[{contribution:i.label,operation:t}]:[];if(t===`combine`){p.length&&d.text.length&&(i.composed.joined=!0),a[u]={...d,text:mo(d.text,p),sources:[...d.sources,...m],children:ho(d.children,c.children,`combine`,f,i)};continue}a[u]={...d,text:p.length?p:d.text,sources:p.length?m:d.sources,children:ho(d.children,c.children,`replace`,f,i)}}return[...a.filter(e=>e!==void 0),...o]}function go(e,t,n,r,i){let a=oo(t,i),o=n===`replace`?co():e,s={...o,removed:[...o.removed]},c={label:r,warn:i,composed:s};uo(a.children,``,c);let l=so(a.preamble);return n===`combine`?(l.length&&o.preamble.length&&(s.joined=!0),s.preamble=mo(o.preamble,l),l.length&&(s.preambleSources=[...o.preambleSources,{contribution:r,operation:n}])):l.length&&(s.preamble=l,s.preambleSources=[{contribution:r,operation:n}]),s.top=o.top??a.top,s.children=ho(o.children,a.children,n,``,c),s}function _o(e){let t=[];e.joined&&t.push(`> Where combined text conflicts, the later text wins.`),e.preamble.length&&t.push(e.preamble.join(`
|
|
178
|
+
`));let n=e.top??1,r=e=>{let i=Math.min(6,n+e.depth),a=i===e.level?e.heading:`${`#`.repeat(i)} ${e.title}`.trimEnd();t.push(e.text.length?`${a}\n\n${e.text.join(`
|
|
179
|
+
`)}`:a);for(let t of e.children)r(t)};for(let t of e.children)r(t);return t.length?`${t.join(`
|
|
180
|
+
|
|
181
|
+
`)}\n`:``}function vo(e){let t=[];e.preambleSources.length&&t.push({path:`(before the first heading)`,sources:e.preambleSources});let n=(e,r)=>{let i=lo(r,e.title);t.push({path:i,sources:e.sources});for(let t of e.children)n(t,i)};for(let t of e.children)n(t,``);return t}function yo(e){let t=[],n=(e,r)=>{let i=lo(r,e.title);t.push(i);for(let t of e.children)n(t,i)};for(let t of oo(e,()=>{}).children)n(t,``);return t}const W=[{extension:`.json`,format:`json`},{extension:`.yaml`,format:`yaml`},{extension:`.yml`,format:`yaml`},{extension:`.toml`,format:`toml`},{extension:`.txt`,format:`txt`}];function bo(e){return W.find(({extension:t})=>e.endsWith(t))?.format??`markdown`}const xo=`.interface`,So=/^([a-z0-9]+(?:[-.][a-z0-9]+)*)@(\d+)$/i;function Co(e){return e.endsWith(`.interface`)&&e.length>10?e.slice(0,-10):void 0}function wo(e){return typeof e==`number`&&Number.isInteger(e)&&e>0}function To(e){if(typeof e==`string`&&e.trim())return e.trim();if(V(e)){let t=Object.keys(e),[n]=t;if(t.length===1&&n?.trim())return n.trim()}return{problem:`section ${JSON.stringify(e)} is not a heading name`}}function Eo(e){return e.trim().replace(/\s+/g,` `).toLowerCase()}function Do(e,t){let n=t.interface;if(!V(n))return{problems:[n===void 0?"has no `interface:` block in its frontmatter":"`interface:` is not a mapping"]};let r=[],i=n.cardinality;i!==`one`&&i!==`many`&&r.push(`cardinality is ${JSON.stringify(i)}; it is one or many`);let a=n.version;wo(a)||r.push(`version is ${JSON.stringify(a)}; it is a positive integer`);let o=n.versions,s=wo(a)?[a]:[];o!==void 0&&(Array.isArray(o)&&o.length&&o.every(wo)?s=o:r.push(`versions is not a list of positive integers`));let c=n.sections,l=[];if(!Array.isArray(c)||!c.length)r.push(`sections is not a list of headings`);else{let e=/* @__PURE__ */ new Set;for(let t of c){let n=To(t);if(typeof n!=`string`){r.push(n.problem);continue}let i=Eo(n);e.has(i)&&r.push(`section "${n}" is listed more than once`),e.add(i),l.push(n)}}return r.length?{problems:r}:{value:{id:e,cardinality:i,version:a,versions:s,sections:l},problems:r}}function Oo(e){let t=e.implements;if(t===void 0)return{problems:[]};let n=Array.isArray(t)?t:[t];if(n.length!==1)return{problems:[n.length?`implements lists ${n.length} interfaces; an implementation implements one`:`implements is an empty list`]};let[r]=n,i=typeof r==`string`?So.exec(r.trim()):null;return i?{entry:{id:i[1],version:Number(i[2])},problems:[]}:{problems:[`implements ${JSON.stringify(r)} is not <id>@<version>`]}}function ko(e,t){return e.cardinality===`one`?t===e.id:t.startsWith(`${e.id}.`)&&t.length>e.id.length+1&&!t.endsWith(`.interface`)}function Ao(e){let t=[],n=e=>{if(e.depth===0){let n=e.text.find(e=>e.trim());t.push({title:e.title,unsupported:n?.trim().startsWith(`**Unsupported.**`)??!1})}for(let t of e.children)n(t)};for(let t of oo(e,()=>{}).children)n(t);return t}function jo(e,{name:t,version:n,content:r,accept:i=e.versions}){let a=[],o=(t,n)=>a.push({check:t,interface:e.id,message:n});i.includes(n)||o(`version`,`unknown version ${n}`),ko(e,t)||o(`name`,`name ${t} is not ${e.cardinality===`one`?e.id:`${e.id}.<key>`}`);let s=Ao(r),c=e.sections.map(Eo),l=e.sections.filter(e=>{let t=s.find(t=>Eo(t.title)===Eo(e));return!t||t.unsupported}),u=-1,d=``,f=/* @__PURE__ */ new Set;for(let e of s){let t=Eo(e.title),n=c.indexOf(t);n!==-1&&(f.has(t)?o(`order`,`section ${e.title} appears more than once`):n<u&&o(`order`,`section ${e.title} comes after ${d}`),f.add(t),n>u&&(u=n,d=e.title))}return{failures:a,unsupported:l}}const Mo=/^[a-z0-9]+(?:[-.][a-z0-9]+)*$/i,No=`.default`;function G(e){let t=t=>({raw:e,name:e,invalid:t});if(e.endsWith(`.md`))return t(`"${e}" names a file. Ask for the reference by name, without the .md extension.`);let n=W.find(t=>e.endsWith(t.extension));if(n)return t(`"${e}" names a file. Ask for the reference by name, without the ${n.extension} extension.`);let r=e.split(`/`);if(r.length>2||e.includes(`\\`))return t(`"${e}" is a path. A name is letters, digits, hyphens, and dots, optionally after "<plugin>/".`);let[i,a]=r,o=a??i,s=a===void 0?void 0:i;return o.endsWith(`.default`)?t(`"${e}" names a skill's default file. Ask for "${o.slice(0,-8)}"; the default joins when its skill loads it.`):!Mo.test(o)||s!==void 0&&!Mo.test(s)?t(`"${e}" is not a reference name. A name is letters, digits, hyphens, and dots, optionally after "<plugin>/", where <plugin> is a plugin's manifest name.`):s===void 0?{raw:e,name:o}:{raw:e,name:o,plugin:s}}function Po(e){return Array.isArray(e)?{layers:[...e],harnesses:[]}:e}function Fo(e){try{return o(e,`utf8`)}catch{return}}function Io(e,t){return e.whole?[`${t}.md`,...W.map(({extension:e})=>`${t}${e}`)]:e.tier==="default"?[`${t}${No}.md`,...W.map(({extension:e})=>`${t}${No}${e}`)]:[`${t}.md`,`${t}/README.md`,...W.map(({extension:e})=>`${t}${e}`)]}function Lo(e,t,n){return e.tier===`plugin`?`plugin ${e.plugin}`:e.tier==="default"?`default of ${e.skill}`:`${e.tier} ${n(t)}`}function Ro(e,t){if(e===void 0)return;let n=e=>{t(`extends-invalid`,`\`extends\` ${e}; it is read as not written`)},r=typeof e==`string`?[e]:Array.isArray(e)?e:void 0;if(!r)return n(`is not a list of plugins`);let i=[];for(let e of r){let r=zo(e,t);if(typeof r==`string`)return n(r);i.push(r)}return i}function zo(e,t){if(typeof e==`string`)return Mo.test(e)?{target:e}:`names "${e}", which is not a plugin name or default`;if(!V(e)||Object.keys(e).length!==1)return`holds ${JSON.stringify(e)}, which is not a step`;let[n,r]=Object.entries(e)[0];if(!Mo.test(n))return`names "${n}", which is not a plugin name or default`;if(r==null)return{target:n};let i={target:n};if(typeof r==`string`)return i.merge=Bo(r,n,t),i;if(!V(r)||Object.keys(r).some(e=>e!==`merge`&&e!==`extends`))return`gives "${n}" keys other than merge and extends`;if(r.merge!==void 0&&(i.merge=Bo(r.merge,n,t)),r.extends!==void 0){let e=Ro(r.extends,t);if(!e)return`gives "${n}" a malformed extends`;i.extends=e}return i}function Bo(e,t,n){return Ja(e)?e:(n(`merge-unknown`,`unknown merge "${String(e)}" on the step ${t}; read as patch`),`patch`)}function Vo(e,t,n,r,i){let a={entries:[],missing:[],allMissing:!1,replaced:[]},o=/* @__PURE__ */ new Set,s=/* @__PURE__ */ new Set,c=(e,t,n)=>{let r=[];for(let o of e){if(o.target===n){i(`extends-self`,`${t} lists itself in its extends; that entry is ignored`);continue}r.at(-1)?.target!==o.target&&(r.some(({target:e})=>e===o.target)&&!a.ambiguous&&(a.ambiguous={cause:`repeat`,message:`${t}'s extends lists ${o.target} at two places`}),r.push(o))}return r},l=c(e,t),u=new Set(l.map(({target:e})=>e)),d=(e,l,f)=>{if(a.ambiguous||o.has(e.target))return;if(s.has(e.target)){n===`plugins`&&(a.ambiguous={cause:`cycle`,message:`the plugins' own extends form a cycle: ${[...f,e.target].join(` → `)}`});return}if(!l&&u.has(e.target))return;let p=r(e.target);if(`reason`in p){a.missing.push({target:e.target,reason:p.reason}),e.target!=="default"&&i(`extends-step-missing`,`the step ${e.target} in ${f.at(-1)??t}'s extends ${p.reason}; it is skipped`);return}s.add(e.target);let m=p.steps??[];if(e.extends){let t=new Set(e.extends.map(({target:e})=>e));for(let{target:n}of m)t.has(n)||a.replaced.push({target:n,step:e.target})}for(let t of c(e.extends??m,`plugin ${e.target}`,e.target))d(t,!1,[...f,e.target]);s.delete(e.target);let h=e.merge??p.merge??`patch`,g=e.merge?`step`:p.merge?`contribution`:`default`;a.entries.push({target:e.target,contribution:p,operation:h,from:g}),o.add(e.target)};for(let e of l)d(e,!0,[]);return a.allMissing=l.length>0&&l.every(({target:e})=>!o.has(e))&&l.some(({target:e})=>e!=="default"),a}const Ho=()=>{};function Uo(e,t,n,r,i,a){let o;for(let n of t){if(!n.steps)continue;if(e.plugin!==void 0){n.entry.extendsOutcome=`not used (qualified name)`;continue}if(o){Vo(n.steps,n.label,`written`,r,Ho).entries.map(({target:e})=>e).join(` `)!==o.targets&&(n.entry.extendsOutcome=`not used (${o.builder.label}'s extends builds the stack)`,a(`extends-not-used`,`${n.label} builds a different stack from ${o.builder.label}, whose extends is used`));continue}let t=Vo(n.steps,n.label,`written`,r,a);if(t.ambiguous)return{status:`ambiguous`,...t.ambiguous};if(t.allMissing){n.entry.extendsOutcome=`not used (every step is missing)`,a(`extends-all-missing`,`every step in ${n.label}'s extends is missing; it is read as not written`);continue}o={entries:t.entries,builtBy:n.label,replaced:t.replaced,replacedBy:n.label,builder:n,targets:t.entries.map(({target:e})=>e).join(` `)}}if(o)return o;if(e.plugin!==void 0){let t=r(e.plugin);if(`reason`in t)return{status:`missing`,message:`the plugin ${e.plugin} ${t.reason}`};let n=Vo([{target:e.plugin}],`plugin ${e.plugin}`,`plugins`,r,a);return n.ambiguous?{status:`ambiguous`,...n.ambiguous}:{entries:n.entries,builtBy:`qualified name`,replaced:[],replacedBy:``}}return Ko(n,r,i,e.name,a)}function Wo(e,t,n,r,i,a,o){let s=(e,t)=>({target:e,contribution:t,operation:`replace`,from:`default`}),c=a?[s(`default`,a)]:[];if(e.plugin!==void 0){let t=i(e.plugin);return`reason`in t?{status:`missing`,message:`the plugin ${e.plugin} ${t.reason}`}:{entries:[s(e.plugin,t)],builtBy:`qualified name`,replaced:[],replacedBy:``}}if(n.some(({hasBody:e})=>e))return{entries:c,builtBy:`none`,replaced:[],replacedBy:``};let l=Go(t,e.name,o);if(l!==void 0){if(l==="default"&&a)return{entries:c,builtBy:`selection`,replaced:[],replacedBy:``};let t=r.get(l);if(t)return{entries:[...c,s(l,t)],builtBy:`selection`,replaced:[],replacedBy:``};o(`selection-invalid`,`the selection of "${e.name}" names ${l}, which holds no such asset; it is ignored`)}let u=[...r.entries()];if(u.length>1){let t=u.map(([e])=>e);return{status:`ambiguous`,cause:`unordered`,message:`the plugins ${t.join(`, `)} hold it; run "asset select ${e.name} <option>" (options: ${t.join(`, `)}${a?`, default`:``}), ask for ${t[0]}/${e.name}, or put the file in a project or user assets folder`}}let[d]=u;return{entries:[...c,...d?[s(d[0],d[1])]:[]],builtBy:`none`,replaced:[],replacedBy:``}}function Go(e,t,n){for(let r of e){if(r.skipped||![`managed`,`project`,`user`].includes(r.tier))continue;let e=Fo(g(r.dir,`${t}.select`));if(e===void 0)continue;let i=e.trim();if(!Mo.test(i)){n(`selection-invalid`,`${r.tier} ${t}.select holds "${i}", which is not a plugin name or default; it is ignored`);continue}return i}}function Ko(e,t,n,r,i){let a=()=>n?[{target:`default`,contribution:n,operation:n.merge??`patch`,from:n.merge?`contribution`:`default`}]:[],o=[...e.keys()];if(!o.length)return{entries:a(),builtBy:`none`,replaced:[],replacedBy:``};let s=/* @__PURE__ */ new Map;for(let e of o){let n=Vo([{target:e}],`plugin ${e}`,`plugins`,t,Ho);if(n.ambiguous)return{status:`ambiguous`,...n.ambiguous};s.set(e,new Set(n.entries.map(({target:e})=>e).filter(t=>t!==e)))}let c=o.filter(e=>!o.some(t=>t!==e&&s.get(t)?.has(e))),l=()=>({status:`ambiguous`,cause:`unordered`,message:`the plugins ${o.join(`, `)} hold it, and no extends orders them`});if(c.length!==1)return l();let u=c[0],d=Vo([{target:u}],`plugin ${u}`,`plugins`,t,i);if(d.ambiguous)return{status:`ambiguous`,...d.ambiguous};let f=new Set(d.entries.map(({target:e})=>e));if(o.some(e=>!f.has(e)))return l();let p=d.entries;if(n&&!f.has(`default`)){p.unshift(...a());let e=o.join(`, `);i(`default-not-selected`,`${o.length>1?`the plugins`:`the plugin`} ${e} ${o.length>1?`answer`:`answers`} over the default of ${n.layer.skill}, and no extends names either; run "reference select ${r} <option>..." to choose (options: ${[...o,`default`].join(`, `)})`)}return{entries:p,builtBy:u&&(e.get(u)?.steps?.length??0)>0?`plugin ${u}'s extends`:`none`,replaced:[],replacedBy:``}}function qo(e){return(e??[]).some(e=>e.target==="default"||qo(e.extends))}function Jo(e){return{stack:[],builtBy:`none`,contributions:[],sections:[],layers:[],harnesses:[...e]}}function Yo(e){return e.endsWith(`
|
|
182
|
+
`)?e:`${e}\n`}function Xo(e){return e.replace(/^(?:[ \t]*\r?\n)+/,``)}function K(e,t,{display:n=e=>e,without:r,below:i}={}){let a=typeof e==`string`?G(e):e,{layers:o,harnesses:s}=Po(t),c=Jo(s),l=[],u={name:a.raw,status:`missing`,warnings:l,trace:c};if(a.invalid)return{...u,status:`invalid`,code:`reference-invalid`,message:a.invalid};let d=/* @__PURE__ */ new Set,f=e=>(t,n)=>{let r=e?`${e}: ${n}`:n;d.has(`${t} ${r}`)||(d.add(`${t} ${r}`),l.push({code:t,message:r}))},p=f(``),m=i===void 0?-1:o.findIndex(e=>e.dir===i),h=m===-1?o:o.slice(m+1),g=[];for(let e of h){e.warning&&p(e.warning.code,e.warning.message);let t={tier:e.tier,path:e.dir,outcome:`missing`};if(e.plugin!==void 0&&(t.plugin=e.plugin),e.skill!==void 0&&(t.skill=e.skill),c.layers.push(t),e.skipped){t.outcome=`not read (${e.skipped})`;continue}let i=Qo(e,a.name,t,{display:n,without:r,warnAt:f});i?g.push(i):e.tier==="default"&&(t.outcome=`not read (no default)`)}let _=/* @__PURE__ */ new Map;for(let e of g.filter(({layer:e})=>e.tier===`plugin`)){let t=e.layer.plugin,r=_.get(t);r?e.entry.outcome=`not read (plugin ${t} answers from ${n(r.path)})`:_.set(t,e)}let v=g.find(({layer:e})=>e.tier==="default"),y=g.filter(({layer:e})=>e.tier!==`plugin`&&e.tier!=="default"),b=new Set(h.flatMap(({plugin:e,skipped:t})=>e&&!t?[e]:[])),x=e=>e==="default"?v??{reason:`has no default`}:_.get(e)??{reason:b.has(e)?`holds no ${a.name}`:`is not installed`},S=()=>[...[..._.keys()].map(e=>`${e}/${a.name}`),...v?[`default`]:[]];if(Co(a.name)!==void 0)return $o(a,g,_,v,u,p,S);let C=h.some(({whole:e})=>e)?Wo(a,h,y,_,x,v,p):Uo(a,y,_,x,v,p);if(`status`in C){if(C.status===`ambiguous`){for(let{entry:e}of g)e.outcome===``&&(e.outcome=`ambiguous`);return{...u,status:`ambiguous`,code:`reference-ambiguous`,message:C.message,cause:C.cause,options:S()}}for(let{entry:e}of g)e.outcome===``&&(e.outcome=`not used (qualified name)`);return{...u,status:`missing`,code:`reference-missing`,message:C.message}}!h.some(({tier:e})=>e==="default")&&g.some(({steps:e})=>qo(e))&&c.layers.push({tier:`default`,path:`(no skill folder given)`,outcome:`not read (no default)`}),c.stack=C.entries.map(({target:e})=>e),c.builtBy=C.builtBy;let w=new Set(c.stack);for(let[e,t]of[..._.entries(),...v?[[`default`,v]]:[]]){if(w.has(e))continue;let n=C.replaced.find(t=>t.target===e);t.entry.outcome=a.plugin===void 0?n?`not used (${n.step}'s extends replaced by ${C.replacedBy})`:`not used (not in extends)`:`not used (qualified name)`}let T=[...C.entries,...[...y].reverse().map(e=>({contribution:e,operation:e.merge??`patch`,from:e.merge?`contribution`:`default`}))],E=co(),D=[],O,ee=[],k;for(let{contribution:e,operation:t,from:n}of T){let{entry:r}=e;if(e.whole&&e.hasBody){r.operation=`replace`,r.operationFrom=`default`;for(let t of D)t.entry.outcome=`shadowed by ${e.label} (replace)`;D=[e],E={...co(),removed:E.removed},k=e,O=void 0,r.outcome=`used`,ee.push(e);continue}if(k&&t!==`remove`&&e.hasBody){r.operation=t,r.operationFrom=n,r.outcome=`not used (format differs from ${k.format})`,f(e.label)(`format-mismatch`,`it is ignored: ${k.label} is ${k.format}, which a Markdown contribution cannot compose with`);continue}t===`remove`&&(k=void 0),r.operation=t,r.operationFrom=n;let i=f(e.label);if(t===`remove`){e.hasBody&&i(`remove-body-ignored`,`a merge: remove contribution has a body; it is ignored`);for(let t of D)t.entry.outcome=`shadowed by ${e.label} (remove)`;for(let t of vo(E))t.path!==`(before the first heading)`&&E.removed.push({path:t.path,by:e.label});let t=E.removed;D=[],E={...co(),removed:t},O=e,r.outcome=`used`,ee.push(e);continue}if(!e.hasBody){r.outcome=r.extendsOutcome??`used`,r.extendsOutcome||ee.push(e);continue}if(t===`replace`){for(let t of D)t.entry.outcome=`shadowed by ${e.label} (replace)`;D=[]}E=go(E,e.body,t,e.label,i),D.push(e),O=void 0,r.outcome=`used`,ee.push(e)}if(c.sections=E.removed.map(({path:e,by:t})=>({path:e,contributions:[],removedBy:t})),!D.length){if(O)return{...u,status:`missing`,code:`reference-missing`,message:`"${a.name}" is turned off by ${O.label} (remove)`,removedBy:O.label};let e=a.plugin===void 0?`no tier holds a document for "${a.name}"`:`the plugin ${a.plugin} holds no document for "${a.name}"`;return{...u,status:`missing`,code:`reference-missing`,message:e}}let te=ee.filter(({entry:e})=>e.outcome===`used`);if(c.contributions=D.map(({layer:e,entry:t})=>{let n={tier:e.tier,path:t.path,operation:t.operation};return t.plugin!==void 0&&(n.plugin=t.plugin),t.skill!==void 0&&(n.skill=t.skill),n}),c.sections=[...vo(E).map(({path:e,sources:t})=>({path:e,contributions:t})),...c.sections],k)return{...u,status:`found`,content:k.body,format:k.format,metadata:{}};let A=D.length===1&&!E.removed.length?D[0].body:void 0,ne=A!==void 0&&ro(A)===A?Yo(Xo(A)):_o(E);return{...u,status:`found`,content:ne,format:`markdown`,metadata:Zo(te)}}function Zo(e){let t=Object.assign({},...e.map(({metadata:e})=>e));return delete t.merge,delete t.extends,t}function Qo(e,t,n,{display:r,without:i,warnAt:a}){if(e.tier!=="default"){let n=g(e.dir,`${t}${No}.md`);n!==i&&Fo(n)!==void 0&&a(r(n))(`default-in-tier`,`it is ignored: a default goes in a skill's references/ folder`)}let[o,...s]=Io(e,t).flatMap(t=>{let n=g(e.dir,t),r=n===i?void 0:Fo(n);return r===void 0?[]:[{file:t,path:n,raw:r}]});if(!o)return;for(let e of s)a(r(e.path))(`file-ignored`,`it is ignored: ${o.file} answers first in that folder`);let c=Lo(e,o.path,r),l=a(c),u=bo(o.file);if(u!==`markdown`||e.whole){Object.assign(n,{path:o.path,file:o.file,outcome:``});let t=o.raw.trim().length>0;return t||(n.empty=!0),{layer:e,entry:n,label:c,path:o.path,metadata:{},body:o.raw,hasBody:t,whole:!0,format:u,merge:`replace`,steps:void 0}}let{metadata:d,body:f}=Xa(o.raw,l),p=Za(d,l),m=Ro(d.extends,l);Object.assign(n,{path:o.path,file:o.file,frontmatter:d,outcome:``}),typeof d.description==`string`&&(n.description=d.description);let h=Qa(f);return h||(n.empty=!0),m&&!h&&p!==`remove`&&(n.selection=!0),{layer:e,entry:n,label:c,path:o.path,metadata:d,body:f,hasBody:h,format:u,whole:!1,merge:p,steps:m}}function $o(e,t,n,r,i,a,o){for(let e of t)(e.merge!==void 0||e.steps!==void 0)&&a(`interface-not-composed`,`${e.label}: merge and extends on an interface document are ignored; an interface is never composed`);if(e.plugin===void 0&&n.size>1){for(let{entry:e}of t)e.outcome===``&&(e.outcome=`ambiguous`);return{...i,status:`ambiguous`,code:`reference-ambiguous`,message:`the plugins ${[...n.keys()].join(`, `)} each hold the interface document`,cause:`unordered`,options:o()}}let s=e.plugin===void 0?[...n.values()]:n.has(e.plugin)?[n.get(e.plugin)]:[];if(e.plugin!==void 0){for(let[t,r]of n)t!==e.plugin&&(r.entry.outcome=`not used (qualified name)`);if(!s.length)return{...i,status:`missing`,code:`reference-missing`,message:`the plugin ${e.plugin} holds no "${e.name}"`}}let c=t.filter(({layer:e})=>e.tier!==`plugin`&&e.tier!=="default"),[l,...u]=[...e.plugin===void 0&&r?[r]:[],...s,...[...c].reverse()];if(!l)return{...i,status:`missing`,code:`reference-missing`,message:`no tier holds a document for "${e.name}"`};for(let e of u)e.entry.outcome=`not used (an interface document is never composed)`,a(`interface-not-composed`,`${e.label} is ignored: an interface document is never composed; define a new interface id instead`);r&&r!==l&&(r.entry.outcome=`not used (qualified name)`),l.entry.outcome=`used`,l.entry.operation=`replace`,l.entry.operationFrom=`default`;let{trace:d}=i;return l.layer.tier===`plugin`&&(d.stack=[l.layer.plugin]),l.layer.tier==="default"&&(d.stack=[`default`]),d.contributions=[{tier:l.layer.tier,...l.entry.plugin?{plugin:l.entry.plugin}:{},...l.entry.skill?{skill:l.entry.skill}:{},path:l.path,operation:`replace`}],{...i,status:`found`,content:Yo(Xo(ro(l.body))),metadata:Zo([l])}}function es(e){if(e.skipped)return[];let t;try{t=s(e.dir,{withFileTypes:!0})}catch{return[]}let n=/* @__PURE__ */ new Set,r=e.tier==="default"&&!e.whole;for(let i of t){let t;if(r){let e=[`${No}.md`,...W.map(e=>`${No}${e.extension}`)].find(e=>i.name.endsWith(e));e&&(t=i.name.slice(0,-e.length))}else!i.isDirectory()&&[`.md`,...W.map(e=>e.extension)].some(e=>i.name.endsWith(e))?t=i.name.slice(0,i.name.lastIndexOf(`.`)):!e.whole&&!i.isFile()&&Fo(g(e.dir,i.name,`README.md`))!==void 0&&(t=i.name);t===void 0||G(t).invalid||n.add(t)}return[...n]}function ts(e){return[...new Set(Po(e).layers.flatMap(es))].sort((e,t)=>e.localeCompare(t))}function ns(e){if(!e||typeof e!=`object`)return[];let t=e,n=/* @__PURE__ */ new Set;for(let e of[`dependencies`,`devDependencies`]){let r=t[e];if(r&&typeof r==`object`)for(let e of Object.keys(r))n.add(e)}return[...n].sort()}function rs(e,t){let n=t.split(`/`),r=[],i=e;for(;;){r.push(g(i,`node_modules`,...n));let e=m(i);if(e===i)break;i=e}return r}function is(t,n){try{let r=e(n);return m(r.resolve(`${t}/package.json`))}catch{}for(let e of rs(m(n),t))if(r(g(e,`package.json`)))return e}const as=[`plugin.json`,`.claude-plugin/plugin.json`,`.cursor-plugin/plugin.json`,`.codex-plugin/plugin.json`,`.github/plugin.json`,`.github/plugin/plugin.json`];function os(e){for(let t of as){let n;try{n=JSON.parse(o(g(e,t),`utf8`))}catch{continue}if(V(n)&&typeof n.name==`string`&&n.name)return n.name}}function ss(e){switch(e){case`claude-code`:return{project:[`.claude/skills`],user:[`.claude/skills`],research:[`E-CC-L1`]};case`cursor`:return{project:[`.cursor/skills`,`.claude/skills`,`.codex/skills`,`.grok/skills`,`.agents/skills`],user:[`.cursor/skills`,`.claude/skills`,`.codex/skills`,`.grok/skills`,`.agents/skills`],research:[`E-CUR-L1`,`E-SR-CUR-10`]};case`codex`:return{project:[`.agents/skills`],user:[`.agents/skills`],research:[`E-CODEX-L1`]};case`copilot-cli`:return{project:[`.github/skills`,`.agents/skills`,`.claude/skills`],user:[`.copilot/skills`,`.agents/skills`],research:[`E-COPILOT-S5`,`E-SR-COPILOT-9`],relocatedBy:{variable:`COPILOT_HOME`,skills:`skills`}};case`vscode-copilot`:return{project:[`.github/skills`,`.claude/skills`,`.agents/skills`],user:[`.copilot/skills`,`.claude/skills`,`.agents/skills`],research:[`E-VSC-P1`]};case`opencode`:return{project:[`.opencode/skills`,`.claude/skills`,`.agents/skills`],user:[`.config/opencode/skills`,`.claude/skills`,`.agents/skills`],research:[`E-OC-S1`]};case`gemini-cli`:return{project:[`.agents/skills`,`.gemini/skills`],user:[`.agents/skills`,`.gemini/skills`],research:[`E-GEM-L1`]};case`cline`:return{project:[`.cline/skills`,`.clinerules/skills`,`.claude/skills`,`.agents/skills`],user:[`.cline/skills`,`.agents/skills`],research:[`E-CLINE-S1`,`E-CLINE-S3`]};case`augment`:return{project:[`.augment/skills`,`.claude/skills`,`.agents/skills`],user:[`.augment/skills`,`.claude/skills`,`.agents/skills`],research:[`E-AUG-S4`]};case`kilo`:return{project:[`.kilo/skills`,`.agents/skills`,`.claude/skills`],user:[`.kilo/skills`,`.agents/skills`,`.claude/skills`],research:[`E-KILO-L2`]};case`qwen-code`:case`crush`:case`openhands`:return}}const cs=[`claude-code`,`cursor`,`codex`,`copilot-cli`,`opencode`,`gemini-cli`];function ls(e,t,n={}){let r=n.ProgramData||`C:\\ProgramData`;switch(e){case`claude-code`:return t===`darwin`?[`/Library/Application Support/ClaudeCode/.claude/skills`]:t===`win32`?[x.join(`C:\\Program Files\\ClaudeCode`,`.claude`,`skills`)]:[`/etc/claude-code/.claude/skills`];case`codex`:return t===`win32`?[]:[`/etc/codex/skills`];case`opencode`:{let e=t===`darwin`?`/Library/Application Support/opencode`:t===`win32`?x.join(r,`opencode`):`/etc/opencode`,n=t===`win32`?x:{join:g};return[n.join(e,`skill`),n.join(e,`skills`)]}default:return[]}}function us(e,{chain:t,home:n,platform:r,env:i={}}){if(!cs.includes(e))return;let a=ss(e);if(!a)return;let o=t.flatMap(e=>a.project.map(t=>g(e,t))),s=a.relocatedBy&&i[a.relocatedBy.variable],c=s&&y(s)!==g(n,`.copilot`)?[g(s,a.relocatedBy.skills)]:a.user.map(e=>g(n,e));return[...o,...c,...ls(e,r,i)]}function ds(e){for(let t of as){let n;try{n=JSON.parse(o(g(e,t),`utf8`))}catch{continue}if(!V(n))return;let r=n.skills;return typeof r==`string`?[r]:Array.isArray(r)&&r.every(e=>typeof e==`string`)?r:void 0}}function fs(e,t){if(e===`opencode`)return[];let n=e===`gemini-cli`?void 0:ds(t),r=g(t,`skills`);if(!n)return[r];let i=n.map(e=>g(t,e));return e===`claude-code`?[r,...i]:i}const ps=/^---[ \t]*\r?\n([\s\S]*?)\r?\n(?:---|\.\.\.)[ \t]*(?:\r?\n|$)/;function ms(e){let t;try{t=o(g(e,`SKILL.md`),`utf8`)}catch{return}let n=ps.exec(t);if(n)try{let e=(0,Ka.parse)(n[1]);if(V(e)&&typeof e.name==`string`&&e.name.trim())return e.name.trim()}catch{}return p(e)}function hs(e){try{return d(e).isDirectory()}catch{return!1}}function gs(e){let t=[],n=/* @__PURE__ */ new Set,r=(e,r)=>{let i=e;try{i=c(e)}catch{}n.has(i)||(n.add(i),t.push({name:r,folder:i}))};for(let t of e){let e=ms(t);if(e!==void 0){r(t,e);continue}let n;try{n=s(t)}catch{continue}for(let e of n.sort()){let n=g(t,e);if(!hs(n))continue;let i=ms(n);i!==void 0&&r(n,i)}}return t}const q=e=>e===`1`,J=e=>e!==``,_s={name:`CLAUDECODE`,matches:q,description:`Claude Code sets CLAUDECODE=1 in subprocesses it spawns; IDE extensions also set it in integrated terminals`,research:`E-CC-D1`},vs=[{harness:`claude-code`,all:[_s,{name:`CLAUDE_CODE_CHILD_SESSION`,matches:q,description:`Claude Code sets CLAUDE_CODE_CHILD_SESSION=1 for tool, hook, and status line subprocesses`,research:`E-CC-D3`}]},{harness:`claude-code`,all:[_s,{name:`CLAUDE_CODE_SESSION_ID`,matches:J,description:`Claude Code sets CLAUDE_CODE_SESSION_ID in tool, hook, and stdio MCP server subprocesses`,research:`E-CC-D6`}]},{harness:`cursor`,all:[{name:`CURSOR_AGENT`,matches:q,description:`Cursor sets CURSOR_AGENT=1 on terminal commands its agent runs`,research:`E-CUR-D1`}]},{harness:`cursor`,all:[{name:`CURSOR_VERSION`,matches:J,description:`Cursor sets CURSOR_VERSION for hook commands`,research:`E-CUR-D10`},{name:`CURSOR_PROJECT_DIR`,matches:J,description:`Cursor sets CURSOR_PROJECT_DIR for hook commands`,research:`E-CUR-D10`}]},{harness:`codex`,all:[{name:`CODEX_THREAD_ID`,matches:J,description:`Codex injects CODEX_THREAD_ID into shell tool commands, even under a restrictive shell env policy`,research:`E-CODEX-D2`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_CLI`,matches:q,description:`Copilot CLI sets COPILOT_CLI=1 in its subprocesses`,research:`E-COPILOT-D1`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_AGENT_SESSION_ID`,matches:J,description:`Copilot CLI passes COPILOT_AGENT_SESSION_ID to shell commands and MCP servers`,research:`E-COPILOT-D2`}]},{harness:`copilot-cli`,all:[{name:`COPILOT_PLUGIN_ROOT`,matches:J,description:`Copilot CLI passes COPILOT_PLUGIN_ROOT to plugin hooks`,research:`E-COPILOT-D6`}]},{harness:`opencode`,all:[{name:`OPENCODE`,matches:q,description:`OpenCode sets OPENCODE=1 for shell tool commands and MCP servers; Kilo Code, its fork, sets it too`,research:`E-OC-D1`},{name:`OPENCODE_PID`,matches:J,description:`OpenCode sets OPENCODE_PID for shell tool commands and MCP servers; Kilo Code sets KILO_PID instead`,research:`E-OC-D2`}]},{harness:`kilo`,all:[{name:`KILO`,matches:q,description:`Kilo Code sets KILO=1 for shell tool commands and MCP servers`,research:`E-KILO-D2`},{name:`KILO_PID`,matches:J,description:`Kilo Code sets KILO_PID for shell tool commands and MCP servers`,research:`E-KILO-D1`}]},{harness:`gemini-cli`,all:[{name:`GEMINI_CLI`,matches:q,description:`Gemini CLI sets GEMINI_CLI=1 for shell tool commands and MCP stdio servers`,research:`E-GEM-D1`}]},{harness:`qwen-code`,all:[{name:`QWEN_CODE`,matches:q,description:`Qwen Code sets QWEN_CODE=1 for shell tool commands, not for MCP servers or hooks`,research:`E-QWEN-D1`}]},{harness:`vscode-copilot`,all:[{name:`COPILOT_AGENT`,matches:q,description:`VS Code 1.121+ sets COPILOT_AGENT=1 on terminals its Copilot agent runs commands in`,research:`E-VSC-D1`}]},{harness:`cline`,all:[{name:`CLINE_ACTIVE`,matches:e=>e===`true`,description:`Cline's VS Code extension sets CLINE_ACTIVE=true on the terminals it creates; the Cline CLI does not`,research:`E-CLINE-D1`}]},{harness:`crush`,all:[{name:`CRUSH`,matches:q,description:`Crush sets CRUSH=1 for bash tool and hook commands, not for MCP servers`,research:`E-CRUSH-D1`}]},{harness:`openhands`,all:[{name:`AI_AGENT`,matches:e=>e===`openhands`,description:`OpenHands (SDK 1.40.1 and later) sets AI_AGENT=openhands for terminal tool and hook commands when AI_AGENT is unset; other vendors use the name with other values`,research:`E-OH-D1`}]},{harness:`openhands`,all:[{name:`OPENHANDS_EVENT_TYPE`,matches:J,description:`OpenHands sets OPENHANDS_EVENT_TYPE for hook commands`,research:`E-OH-D4`},{name:`OPENHANDS_PROJECT_DIR`,matches:J,description:`OpenHands sets OPENHANDS_PROJECT_DIR for hook commands`,research:`E-OH-D4`}]},{harness:`augment`,all:[{name:`AUGMENT_HOOK_EVENT`,matches:J,description:`The Auggie CLI sets AUGMENT_HOOK_EVENT for hook commands; its shell commands carry no marker`,research:`E-AUG-D3`},{name:`AUGMENT_PROJECT_DIR`,matches:J,description:`The Auggie CLI sets AUGMENT_PROJECT_DIR for hook commands`,research:`E-AUG-D3`}]}];function ys(e={}){let t=e.env??process.env,n=[],r=[];for(let e of vs){let i=e.all.filter(e=>{let n=t[e.name];return n!==void 0&&e.matches(n)});for(let t of i)n.some(n=>n.harness===e.harness&&n.signal===t.name)||n.push({harness:e.harness,signal:t.name,description:t.description,research:t.research});i.length===e.all.length&&!r.includes(e.harness)&&r.push(e.harness)}return{harness:r.length===1?r[0]:`unknown`,evidence:n,candidates:r}}function bs(e,t={}){let n=t.platform??process.platform,r=t.env??process.env;return Ts[e](n,r)}const xs=e=>e===`win32`?x.join:_.join,Ss=e=>e===`win32`?x.dirname:_.dirname;function Cs(e,t,n,r){let i={darwin:`/Library/Application Support/${n}`,linux:`/etc/${n}`,win32:x.join(t.ProgramData??`C:\\ProgramData`,n)}[e];return[...Y(e===`darwin`,{kind:`macos-managed-preferences`,location:`ai.opencode.managed`,description:`MDM configuration profile; outranks the managed config folder`,research:r.preferences}),...Y(i!==void 0,{kind:`directory`,location:i??``,description:`Managed config files; outrank user and project config`,research:r.directory})]}function ws(e,t,n){let r=e===`darwin`||e===`win32`?n.dirs[e]:n.dirs.linux,i=t[n.settingsVariable]||xs(e)(r,`settings.json`),a=t[n.defaultsVariable]||xs(e)(Ss(e)(i),`system-defaults.json`);return[{kind:`file`,location:i,description:`System settings; outrank user and workspace settings. ${n.settingsVariable} overrides the path`,research:n.research},{kind:`file`,location:a,description:`System defaults; user and workspace settings override them. ${n.defaultsVariable} overrides the path`,research:n.research}]}const Y=(e,...t)=>e?t:[],Ts={"claude-code":e=>{let t={darwin:`/Library/Application Support/ClaudeCode`,linux:`/etc/claude-code`,win32:`C:\\Program Files\\ClaudeCode`}[e],n=xs(e);return[{kind:`server`,location:`claude.ai admin console or a self-hosted Claude apps gateway`,description:`Server-managed settings; the highest-ranked managed source`,research:`E-CC-M6`},...Y(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.anthropic.claudecode`,description:`MDM configuration profile with the same top-level keys as managed-settings.json`,research:`E-CC-M6`}),...Y(e===`win32`,{kind:`windows-registry`,location:`HKLM\\SOFTWARE\\Policies\\ClaudeCode`,description:`MDM or Group Policy; the Settings value holds managed-settings JSON`,research:`E-CC-M6`}),...Y(t!==void 0,{kind:`file`,location:n(t??``,`managed-settings.json`),description:`Managed settings, same shape as settings.json`,research:`E-CC-M1`},{kind:`directory`,location:n(t??``,`managed-settings.d`),description:`Drop-in managed settings files, merged with managed-settings.json`,research:`E-CC-M1`},{kind:`file`,location:n(t??``,`managed-mcp.json`),description:`Managed MCP servers`,research:`E-CC-M1`}),...Y(e===`win32`,{kind:`windows-registry`,location:`HKCU\\SOFTWARE\\Policies\\ClaudeCode`,description:`User-writable; used only when no other managed source delivers a policy key`,research:`E-CC-M6`})]},cursor:e=>{let t={darwin:`/Library/Application Support/Cursor/hooks.json`,linux:`/etc/cursor/hooks.json`,win32:`C:\\ProgramData\\Cursor\\hooks.json`}[e];return[...Y(t!==void 0,{kind:`file`,location:t??``,description:`Enterprise hooks deployed by MDM; hooks only, not other enterprise settings`,research:`E-CUR-M1`}),{kind:`server`,location:`Cursor dashboard`,description:`Team hooks and other enterprise settings, synced from the dashboard`,research:`E-CUR-M1`}]},codex:(e,t)=>{let n={kind:`server`,location:`ChatGPT workspace admin settings`,description:`Cloud-managed requirements; outrank every local source`,research:`E-CODEX-M8`};return e===`win32`?[n,{kind:`file`,location:x.join(t.ProgramData??`C:\\ProgramData`,`OpenAI`,`Codex`,`requirements.toml`),description:`Admin-enforced requirements users cannot override`,research:`E-CODEX-M4`}]:[n,...Y(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.openai.codex`,description:`MDM keys requirements_toml_base64 (enforced) and config_toml_base64 (managed defaults)`,research:`E-CODEX-M6`}),{kind:`file`,location:`/etc/codex/requirements.toml`,description:`Admin-enforced requirements users cannot override`,research:`E-CODEX-M3`},{kind:`file`,location:`/etc/codex/managed_config.toml`,description:`Managed defaults; a user can override them within a session`,research:`E-CODEX-M2`},{kind:`file`,location:`/etc/codex/config.toml`,description:`System-wide config`,research:`E-CODEX-M1`}]},"copilot-cli":(e,t)=>{let n={darwin:`/Library/Application Support/GitHubCopilot/managed-settings.json`,linux:`/etc/github-copilot/managed-settings.json`,win32:x.join(t.ProgramFiles??`C:\\Program Files`,`GitHubCopilot`,`managed-settings.json`)}[e];return[...Y(e===`darwin`,{kind:`macos-managed-preferences`,location:`com.github.copilot`,description:`MDM-managed settings; the highest-ranked source`,research:`E-COPILOT-M2`}),...Y(e===`win32`,{kind:`windows-registry`,location:`HKLM\\SOFTWARE\\Policies\\GitHubCopilot`,description:`MDM-managed settings as REG_SZ values; the highest-ranked source`,research:`E-COPILOT-M2`}),{kind:`server`,location:`copilot/managed-settings.json in the enterprise's .github-private repository`,description:`Server-managed settings, fetched for the signed-in account`,research:`E-COPILOT-M3`},...Y(n!==void 0,{kind:`file`,location:n??``,description:`File-based managed settings; on macOS and Linux it must be a root-owned regular file`,research:`E-COPILOT-M1`})]},opencode:(e,t)=>[...Cs(e,t,`opencode`,{directory:`E-OC-M1`,preferences:`E-OC-M1`}),{kind:`server`,location:`Remote config at the organization domain /.well-known/opencode`,description:`Organization defaults; the lowest-ranked config source, so user config overrides them`,research:`E-OC-M2`}],kilo:(e,t)=>Cs(e,t,`kilo`,{directory:`E-KILO-M1`,preferences:`E-KILO-M2`}),"gemini-cli":(e,t)=>ws(e,t,{settingsVariable:`GEMINI_CLI_SYSTEM_SETTINGS_PATH`,defaultsVariable:`GEMINI_CLI_SYSTEM_DEFAULTS_PATH`,dirs:{darwin:`/Library/Application Support/GeminiCli`,linux:`/etc/gemini-cli`,win32:`C:\\ProgramData\\gemini-cli`},research:`E-GEM-M1`}),"qwen-code":(e,t)=>ws(e,t,{settingsVariable:`QWEN_CODE_SYSTEM_SETTINGS_PATH`,defaultsVariable:`QWEN_CODE_SYSTEM_DEFAULTS_PATH`,dirs:{darwin:`/Library/Application Support/QwenCode`,linux:`/etc/qwen-code`,win32:`C:\\ProgramData\\qwen-code`},research:`E-QWEN-M1`}),"vscode-copilot":e=>[...Y(e===`win32`,{kind:`windows-registry`,location:`Software\\Policies\\Microsoft\\VSCode`,description:`VS Code policies set by Group Policy (ADMX templates ship with VS Code)`,research:`E-VSC-M1`}),...Y(e===`linux`,{kind:`file`,location:`/etc/vscode/policy.json`,description:`VS Code policies as JSON, read by VS Code 1.106 and later`,research:`E-VSC-M3`})],cline:()=>[{kind:`server`,location:`Cline Enterprise admin console`,description:`Provider, model, and tool policy pushed to clients; no local policy file is documented`,research:`E-CLINE-M1`}],crush:e=>Y(e!==`win32`,{kind:`file`,location:`/etc/crush/crush.json`,description:`System config; the lowest-ranked source, so user and project config override it`,research:`E-CRUSH-M1`}),openhands:()=>[{kind:`server`,location:`OpenHands Cloud or Enterprise deployment`,description:`Organization controls held server-side; no local policy file is known`,research:`E-OH-D8`}],augment:(e,t)=>[{kind:`file`,location:e===`win32`?x.join(t.ProgramData||`C:\\ProgramData`,`augment`,`settings.json`):`/etc/augment/settings.json`,description:`System settings, read from the Auggie CLI bundle; its rank against user settings is not documented`,research:`E-AUG-M1`}]};function Es(e={}){return{env:e.env??process.env,homedir:e.homedir??w(),cwd:e.cwd??process.cwd(),platform:e.platform??process.platform}}function Ds(e,t={}){return As[e](Es(t))}const Os=({env:e,homedir:t})=>e.XDG_CONFIG_HOME||g(t,`.config`);function ks({env:e,homedir:t,platform:n}){if(n===`win32`){let n=x.join(e.APPDATA||x.join(t,`AppData`,`Roaming`),`Code`);return{configDir:n,path:x.join(n,`agentPlugins`)}}let r=n===`darwin`?g(t,`Library`,`Application Support`,`Code`):g(t,`.config`,`Code`);return{configDir:r,path:g(r,`agentPlugins`)}}const As={"claude-code":({env:e,homedir:t})=>{let n=e.CLAUDE_CONFIG_DIR||g(t,`.claude`),r=g(n,`plugins`);return{harness:`claude-code`,configDir:n,locations:[{kind:`plugin-cache`,path:g(r,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CC-P1`},{kind:`marketplaces`,path:g(r,`marketplaces`),description:`Marketplace checkouts`,research:`E-CC-P1`},{kind:`install-record`,path:g(r,`installed_plugins.json`),description:`Installs keyed by plugin@marketplace, each with scope, installPath, and version`,research:`E-CC-P2`},{kind:`enabled-record`,path:g(n,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-CC-P3`}]}},cursor:({homedir:e})=>{let t=g(e,`.cursor`);return{harness:`cursor`,configDir:t,locations:[{kind:`local-plugins`,path:g(t,`plugins`,`local`),description:`Plugins under development, one folder each`,research:`E-CUR-P2`},{kind:`marketplaces`,path:g(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-CUR-P3`}]}},codex:({env:e,homedir:t})=>{let n=e.CODEX_HOME||g(t,`.codex`);return{harness:`codex`,configDir:n,locations:[{kind:`plugin-cache`,path:g(n,`plugins`,`cache`),description:`Installed plugins as <marketplace>/<plugin>/<version>/`,research:`E-CODEX-P3`},{kind:`enabled-record`,path:g(n,`config.toml`),description:`User config; [plugins."<plugin>@<marketplace>"] tables carry enabled = <bool>`,research:`E-CODEX-P2`}]}},"copilot-cli":({env:e,homedir:t})=>{let n=e.COPILOT_HOME||g(t,`.copilot`);return{harness:`copilot-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:g(n,`installed-plugins`),description:`Installed plugins as <marketplace>/<plugin>/, or _direct/<source-id>/ for direct installs`,research:`E-COPILOT-P9`},{kind:`install-record`,path:g(n,`config.json`),description:`Application state, including installedPlugins`,research:`E-COPILOT-P9`},{kind:`enabled-record`,path:g(n,`settings.json`),description:`User settings (JSON with comments); enabledPlugins maps plugin specs to a boolean`,research:`E-COPILOT-P4`}]}},opencode:e=>{let t=g(Os(e),`opencode`);return{harness:`opencode`,configDir:t,locations:[{kind:`local-plugins`,path:g(t,`plugins`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-OC-P2`}]}},kilo:e=>{let t=g(Os(e),`kilo`);return{harness:`kilo`,configDir:t,locations:[{kind:`local-plugins`,path:g(t,`plugin`),description:`JS/TS plugin modules loaded at startup; npm plugins are named in the plugin config array`,research:`E-KILO-P2`}]}},"gemini-cli":({env:e,homedir:t})=>{let n=g(e.GEMINI_CLI_HOME||t,`.gemini`),r=g(n,`extensions`);return{harness:`gemini-cli`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a gemini-extension.json manifest`,research:`E-GEM-P1`},{kind:`enabled-record`,path:g(r,`extension-enablement.json`),description:`Per-extension path-glob overrides that enable or disable it by folder, not a boolean`,research:`E-GEM-P3`}]}},"qwen-code":({env:e,homedir:t})=>{let n=e.QWEN_HOME||g(t,`.qwen`),r=g(n,`extensions`);return{harness:`qwen-code`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed extensions, one folder each with a qwen-extension.json manifest`,research:`E-QWEN-P1`},{kind:`enabled-record`,path:g(r,`extension-enablement.json`),description:`Extension enable/disable state, inherited from Gemini CLI's format`,research:`E-QWEN-P2`}]}},"vscode-copilot":e=>{let{configDir:t,path:n}=ks(e);return{harness:`vscode-copilot`,configDir:t,locations:[{kind:`installed-plugins`,path:n,description:`Installed agent plugins as <host>/<org>/<repo>/`,research:`E-VSC-P3`}]}},cline:({homedir:e})=>{let t=g(e,`.cline`);return{harness:`cline`,configDir:t,locations:[{kind:`installed-plugins`,path:g(t,`plugins`,`_installed`),description:`Installed plugins, grouped by source: npm, git, remote, or local`,research:`E-CLINE-P3`}]}},crush:({env:e,homedir:t})=>({harness:`crush`,configDir:e.CRUSH_GLOBAL_CONFIG||g(e.XDG_CONFIG_HOME||g(t,`.config`),`crush`),locations:[]}),openhands:({env:e,homedir:t})=>{let n=e.OH_PERSISTENCE_DIR||e.OPENHANDS_PERSISTENCE_DIR||g(t,`.openhands`),r=g(n,`plugins`,`installed`);return{harness:`openhands`,configDir:n,locations:[{kind:`installed-plugins`,path:r,description:`Installed plugins, one folder each`,research:`E-OH-P3`},{kind:`enabled-record`,path:g(r,`.installed.json`),description:`Install metadata keyed by plugin name, each with enabled: <bool>`,research:`E-OH-P4`}]}},augment:({homedir:e})=>{let t=g(e,`.augment`);return{harness:`augment`,configDir:t,locations:[{kind:`marketplaces`,path:g(t,`plugins`,`marketplaces`),description:`Marketplace checkouts`,research:`E-AUG-P2`},{kind:`enabled-record`,path:g(t,`settings.json`),description:`User settings; enabledPlugins maps plugin@marketplace to a boolean`,research:`E-AUG-P4`}]}}};async function js(e,t={}){let n=Bs[e](Es(t),t.managedSettingsPath),r=/* @__PURE__ */ new Map,i=[];for(let e of n.sources){let t;try{let n=await ki(e.path);if(n===void 0){i.push({scope:e.scope,path:e.path,found:!1});continue}t=e.parse(n)}catch(t){i.push({scope:e.scope,path:e.path,found:!0,error:String(t)});continue}i.push({scope:e.scope,path:e.path,found:!0});for(let[n,i]of Object.entries(t))r.has(n)||r.set(n,{id:n,enabled:i,scope:e.scope,source:e.path})}return{harness:e,supported:n.supported,plugins:[...r.values()],sources:i,unread:n.unread,research:n.research}}function Ms(e){let t=JSON.parse(e),n=V(t)?t.enabledPlugins:void 0;return V(n)?Object.fromEntries(Object.entries(n).filter(e=>typeof e[1]==`boolean`)):{}}const Ns=/^\[\s*plugins\s*\.\s*(?:"([^"]*)"|'([^']*)'|([A-Za-z0-9_-]+))\s*\]\s*(?:#.*)?$/,Ps=/^enabled\s*=\s*(true|false)\s*(?:#.*)?$/;function Fs(e){let t={},n;for(let r of e.split(/\r?\n/)){let e=r.trim();if(e.startsWith(`[`)){let t=Ns.exec(e);n=t?t[1]??t[2]??t[3]:void 0;continue}let i=n===void 0?null:Ps.exec(e);n!==void 0&&i&&(t[n]=i[1]===`true`)}return t}const Is={server:`server-managed settings`,"macos-managed-preferences":`MDM managed preferences`,"windows-registry":`Windows registry policy`,directory:`drop-in managed settings`,file:`managed file`};function Ls(e,t,n=[]){return e.filter(e=>e.location!==t&&!n.some(t=>e.location.endsWith(t))).map(e=>`${Is[e.kind]} (${e.location})`)}function Rs(e,t){return e.find(e=>e.kind===`file`&&e.location.endsWith(t))?.location}function zs(e){return Ms(Ai(e))}const X=(...e)=>({supported:!1,sources:[],unread:[],research:e}),Bs={"claude-code":(e,t)=>{let{configDir:n}=Ds(`claude-code`,e),r=bs(`claude-code`,e),i=Rs(r,`managed-settings.json`),a=t??i,o=g(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:Ms}],{scope:`local`,path:g(o,`settings.local.json`),parse:Ms},{scope:`project`,path:g(o,`settings.json`),parse:Ms},{scope:`user`,path:g(n,`settings.json`),parse:Ms}],unread:Ls(r,i,[`managed-mcp.json`]),research:[`E-CC-P3`,`E-CC-P7`,`E-CC-M1`,`E-CC-M6`]}},cursor:()=>X(),opencode:()=>X(`E-OC-P3`),kilo:()=>X(`E-KILO-P3`),"gemini-cli":()=>X(`E-GEM-P3`),"qwen-code":()=>X(`E-QWEN-P2`),"vscode-copilot":()=>X(`E-VSC-P4`),cline:()=>X(`E-CLINE-P4`),crush:()=>X(`E-CRUSH-P2`),openhands:()=>X(`E-OH-P4`),augment:()=>X(`E-AUG-P4`),codex:e=>{let t=Ds(`codex`,e);return{supported:!0,sources:[{scope:`user`,path:g(t.configDir,`config.toml`),parse:Fs}],unread:Ls(bs(`codex`,e),void 0),research:[`E-CODEX-P2`,`E-CODEX-M7`]}},"copilot-cli":(e,t)=>{let n=Ds(`copilot-cli`,e),r=bs(`copilot-cli`,e),i=Rs(r,`managed-settings.json`),a=t??i,o=g(e.cwd,`.github`,`copilot`),s=g(e.cwd,`.claude`);return{supported:!0,sources:[...a===void 0?[]:[{scope:`managed`,path:a,parse:zs}],{scope:`local`,path:g(o,`settings.local.json`),parse:zs},{scope:`project`,path:g(o,`settings.json`),parse:zs},{scope:`user`,path:g(n.configDir,`settings.json`),parse:zs}],unread:[...Ls(r,i),`Claude Code project settings (${g(s,`settings.json`)})`,`Claude Code local settings (${g(s,`settings.local.json`)})`],research:[`E-COPILOT-P4`,`E-COPILOT-M1`,`E-COPILOT-M2`,`E-COPILOT-M4`]}}};async function Vs(e,t={}){let n=sc[e](Es(t)),r={harness:e,supported:n.supported,unread:n.unread,research:n.research};if(n.source===void 0)return{...r,plugins:[],unresolved:[],sources:[]};let i=n.source;try{let e=await n.read(i);return e===void 0?{...r,plugins:[],unresolved:[],sources:[{path:i,found:!1}]}:{...r,plugins:e.plugins,unresolved:e.unresolved??[],sources:[{path:i,found:!0}]}}catch(e){return{...r,plugins:[],unresolved:[],sources:[{path:i,found:!0,error:String(e)}]}}}const Hs=[`managed`,`local`,`project`,`user`],Us=e=>typeof e==`string`&&e!==``?e:void 0;async function Ws(e){let t=await ki(e);if(t===void 0)return;let n=JSON.parse(t),r=V(n)?n.plugins:void 0;if(!V(r))return{plugins:[]};let i=[];for(let[e,t]of Object.entries(r))if(Array.isArray(t))for(let n of t){let t=V(n)?Us(n.installPath):void 0;if(!V(n)||t===void 0)continue;let r=Us(n.version),a=typeof n.scope==`string`&&Hs.includes(n.scope)?n.scope:void 0,o=Us(n.projectPath);i.push({id:e,path:t,...r===void 0?{}:{version:r},...a===void 0?{}:{scope:a},...o===void 0?{}:{projectPath:o},research:[`E-CC-P2`]})}return{plugins:i}}async function Gs(e){let t=await ki(e);if(t===void 0)return;let n=JSON.parse(Ai(t)),r=V(n)?n.installedPlugins:void 0;if(!Array.isArray(r))return{plugins:[]};let i=[];for(let e of r){if(!V(e))continue;let t=Us(e.name),n=Us(e.cache_path);if(t===void 0||n===void 0)continue;let r=Us(e.marketplace),a=Us(e.version);i.push({id:r===void 0?t:`${t}@${r}`,path:n,...a===void 0?{}:{version:a},research:r===void 0?[`E-COPILOT-P10`,`E-COPILOT-P11`]:[`E-COPILOT-P10`]})}return{plugins:i}}const Ks=`local`,qs=/^[A-Za-z0-9_-]+$/,Js=/^[A-Za-z0-9_-]+(?:\.[A-Za-z0-9_-]+)*$/,Ys=/^[A-Za-z0-9._+-]+$/;async function Xs(e){let t=await Qs(e);if(t===void 0)return;let n=[],r=[];for(let i of t.filter(e=>qs.test(e)))for(let t of await Qs(g(e,i))??[]){if(!Js.test(t))continue;let a=`${t}@${i}`,o=(await Qs(g(e,i,t))??[]).filter(e=>Ys.test(e)&&e!==`.`&&e!==`..`);if(o.length===0)continue;let s=Zs(o);if(s===void 0){r.push(a);continue}n.push({id:a,path:g(e,i,t,s),version:s,research:[`E-CODEX-P3`,`E-CODEX-P8`]})}return{plugins:n,unresolved:r}}function Zs(e){if(e.includes(Ks))return Ks;let t=e.filter(e=>ec(e)!==void 0).length;if(!(e.length>2&&t!==0&&t!==e.length))return[...e].sort(tc).at(-1)}async function Qs(e){try{return(await E(e,{withFileTypes:!0})).filter(e=>e.isDirectory()).map(e=>e.name)}catch(e){if(e.code===`ENOENT`)return;throw e}}const $s=/^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*)(?:\.(?:0|[1-9]\d*|\d*[A-Za-z-][0-9A-Za-z-]*))*))?(?:\+([0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*))?$/;function ec(e){let t=$s.exec(e);if(t)return{core:[t[1],t[2],t[3]],pre:t[4]===void 0?[]:t[4].split(`.`),build:t[5]===void 0?[]:t[5].split(`.`)}}function tc(e,t){let n=ec(e),r=ec(t);if(n===void 0||r===void 0)return ac(e,t);for(let e=0;e<3;e++){let t=ic(n.core[e],r.core[e]);if(t!==0)return t}let i=n.pre.length===0||r.pre.length===0?r.pre.length-n.pre.length:rc(n.pre,r.pre);return i===0?rc(n.build,r.build):Math.sign(i)}const nc=/^\d+$/;function rc(e,t){for(let n=0;n<Math.min(e.length,t.length);n++){let r=e[n],i=t[n],a=nc.test(r),o=nc.test(i),s=a&&o?ic(r,i):a===o?ac(r,i):a?-1:1;if(s!==0)return s}return e.length-t.length}function ic(e,t){let n=e.replace(/^0+(?=\d)/,``),r=t.replace(/^0+(?=\d)/,``);return n.length-r.length||ac(n,r)||e.length-t.length}const ac=(e,t)=>e<t?-1:+(e>t),oc={supported:!1,read:async()=>void 0,unread:[],research:[]},sc={"claude-code":e=>({supported:!0,source:g(Ds(`claude-code`,e).configDir,`plugins`,`installed_plugins.json`),read:Ws,unread:[],research:[`E-CC-P2`]}),codex:e=>({supported:!0,source:g(Ds(`codex`,e).configDir,`plugins`,`cache`),read:Xs,unread:[],research:[`E-CODEX-P3`,`E-CODEX-P8`]}),"copilot-cli":e=>{let{configDir:t}=Ds(`copilot-cli`,e);return{supported:!0,source:g(t,`config.json`),read:Gs,unread:[`plugins from marketplaces added by local path (extraKnownMarketplaces in ${g(t,`settings.json`)})`],research:[`E-COPILOT-P10`,`E-COPILOT-P11`,`E-COPILOT-P12`,`E-COPILOT-P13`]}},cursor:()=>oc,opencode:()=>oc,kilo:()=>oc,"gemini-cli":()=>oc,"qwen-code":()=>oc,"vscode-copilot":()=>oc,cline:()=>oc,crush:()=>oc,openhands:()=>oc,augment:()=>oc};function cc(e){return ys({env:e}).candidates}const lc={"macos-managed-preferences":`a macOS managed-preferences domain delivered by MDM`,"windows-registry":`a Windows registry key delivered by MDM or Group Policy`,server:`server-side settings`};function uc(e,t,n,r){return r===void 0?{tier:e,dir:t,skipped:n}:{tier:e,dir:t,plugin:r,skipped:n}}function dc(e,t,n){let r=t===`win32`?x:_,i=bs(e,{platform:t,env:n}),a=[...new Set(i.flatMap(({kind:e,location:t})=>e===`file`?[r.dirname(t)]:e===`directory`?[t]:[]))];return{read:a.filter(e=>!a.some(t=>e.startsWith(t+r.sep))).map(e=>r.join(e,`references`)),unread:i.flatMap(({kind:t,location:n})=>{let r=lc[t];return r?[{location:n,reason:`${e} keeps this policy in ${r}, which cannot be read locally`}]:[]})}}function fc(e,t,n){return e.length?e.flatMap(e=>{let{read:r,unread:i}=dc(e,t,n);return[...r.map(e=>({tier:`managed`,dir:e})),...i.map(({location:e,reason:t})=>uc(`managed`,e,t))]}):[uc(`managed`,`(no harness detected)`,`no harness detected, so no managed folder`)]}function pc(e,t){for(let n of t){let t=e.find(({projectPath:e})=>e===n);if(t)return t}return e.find(({projectPath:e})=>e===void 0)}async function mc(e,t,n){let r=[];for(let i of e){let[e,a]=await Promise.all([js(i,n),Vs(i,n)]);if(!e.supported){r.push(uc(`plugin`,`(${i} enabled plugins)`,`${i} keeps no readable record of enabled plugins`));continue}e.unread.length&&r.push(uc(`plugin`,`(${i} plugin policy)`,`${e.unread.join(`; `)} may also enable or disable ${i} plugins`));for(let{id:n,enabled:o}of e.plugins){if(!o)continue;let e=n.split(`@`)[0],s=pc(a.plugins.filter(e=>e.id===n),t);if(s){let t=os(s.path)??e;r.push({tier:`plugin`,dir:g(s.path,`references`),plugin:t});continue}r.push(uc(`plugin`,`(${n})`,`enabled in ${i}, but no install folder for this project is recorded`,e))}}return r}function hc(e){return g(e,`.agents`,`references`)}function gc(e){return g(e,`.agents`,`references`)}function _c(e){try{return JSON.parse(o(e,`utf8`))}catch{return}}function vc(e){if(r(g(e,`.git`))||r(g(e,`pnpm-workspace.yaml`)))return!0;let t=_c(g(e,`package.json`));return V(t)&&t.workspaces!==void 0}function yc(e){let t=y(e),n=[],r=t;for(;;){if(n.push(r),vc(r))return n;let e=m(r);if(e===r)return[t];r=e}}function bc(e){let t=yc(e).at(-1);return vc(t)?t:void 0}function xc(e){try{return d(e).isDirectory()}catch{return!1}}function Sc(e){let t=e;for(;;){let e=g(t,`package.json`);if(r(e))return e;let n=m(t);if(n===t)return;t=n}}function Cc(e){try{return c(e)}catch{return e}}function wc(e,t,n){let r=Sc(e);if(!r)return[];let i=[];for(let e of ns(_c(r))){let a=is(e,r);if(!a||t.has(Cc(a)))continue;let o=g(a,n);if(!xc(o))continue;let s=os(a);i.push(s?{tier:`plugin`,dir:o,plugin:s}:{tier:`plugin`,dir:o,skipped:`not a plugin`})}return i}function Tc(e){let t=Sc(e);return t?ns(_c(t)).flatMap(e=>{let n=is(e,t);return n&&os(n)?[n]:[]}):[]}function Ec(e){try{return s(g(e,`references`)).some(e=>e.endsWith(`.default.md`))}catch{return!1}}function Dc(e,t,n){if(!e.length)return{skills:[],unverified:`no harness detected, so no skill folder is read and no skill's default is listed`};let r=[],i=[];for(let a of e){let e=us(a,t);if(!e){i.push(a);continue}r.push(...e,...n.flatMap(e=>fs(a,e)))}let a=n.filter(e=>ms(e)!==void 0),o=r.length?gs([...r,...a]).filter(({folder:e})=>Ec(e)):[];return i.length?{skills:o,unverified:`the skill folders ${i.join(`, `)} ${i.length===1?`reads are`:`read are`} not verified, so ${i.length===1?`its`:`their`} skills' defaults are not listed`}:{skills:o}}function Oc(e,t){if(t===`references`||p(e.dir)!==`references`)return e;let n=g(m(e.dir),t);return{...e,dir:n,whole:!0}}function kc(e){let t=g(e,`references`);return xc(e)?{tier:`default`,dir:t,skill:ms(e)??p(e)}:{tier:`default`,dir:t,skill:p(e),skipped:`no skill folder`,warning:{code:`default-folder-missing`,message:`the skill folder ${e} does not exist; the name resolves without its default`}}}async function Ac({root:e,home:t,platform:n,plugin:r,defaultSkill:i,folder:a=`references`,env:o=process.env}){let s=cc(o),c=yc(e),l=r&&Cc(r.root),u=await mc(s,c,{env:o,homedir:t,cwd:y(e),platform:n}),d=[...r?[r.root]:[],...u.flatMap(({dir:e,skipped:t})=>t?[]:[m(e)]),...Tc(e)],f=a===`assets`?void 0:Dc(s,{chain:c,home:t,platform:n,env:o},d),p=[...fc(s,n,o),...c.map(e=>({tier:`project`,dir:hc(e)})),{tier:`user`,dir:gc(t)},...r?[{tier:`plugin`,dir:g(r.root,`references`),plugin:r.name}]:[],...u.filter(e=>e.skipped||xc(Oc(e,a).dir)&&Cc(m(e.dir))!==l),...wc(e,new Set(l?[l]:[]),a),...i===void 0?[]:[kc(y(i))]],h=/* @__PURE__ */ new Set;return{layers:p.map(e=>Oc(e,a)).filter(({dir:e})=>!h.has(e)&&h.add(e)),harnesses:s,skills:f}}function jc(e){return(Array.isArray(e)?[]:e.skills?.skills??[]).flatMap(e=>es(kc(e.folder)).map(t=>({name:t,skill:e}))).sort((e,t)=>e.name.localeCompare(t.name)||e.skill.name.localeCompare(t.skill.name))}function Mc(e){return Array.isArray(e)?void 0:e.skills?.unverified}function Nc(e,t){let{layers:n,harnesses:r,skills:i}=Array.isArray(e)?{layers:e,harnesses:[],skills:void 0}:e;return{layers:[...n.filter(({tier:e})=>e!=="default"),kc(t)],harnesses:r,skills:i}}function Pc(e){let t=e.split(`*`).map(e=>e.replace(/[.+?^${}()|[\]\\]/g,`\\$&`));return RegExp(`^${t.join(`.*`)}$`,`s`)}function Fc(e){return typeof e==`string`&&e.split(`
|
|
183
|
+
`)[0]?.trim()||``}function Ic(e,t,n){for(let r of n){let n=`${r.code} ${r.message}`;t.has(n)||e.push(r),t.add(n)}}function Lc(e,t){let n={name:e,tier:t.tier,path:t.path,description:Fc(t.description),outcome:t.outcome};return t.plugin!==void 0&&(n.plugin=t.plugin),t.skill!==void 0&&(n.skill=t.skill),t.selection&&(n.selection=!0),n}function Rc(e,t={}){let{pattern:n,...r}=t,i=n===void 0?void 0:Pc(n),a={references:[],layers:[],warnings:[]},o=Mc(e);o&&(a.defaults=o);let s=/* @__PURE__ */ new Set,c=jc(e),l=[.../* @__PURE__ */ new Set([...ts(e),...c.map(({name:e})=>e)])].sort((e,t)=>e.localeCompare(t));for(let t of l){if(i&&!i.test(t))continue;let n=c.filter(e=>e.name===t),o=K(t,e,r);!o.trace.layers.some(({file:e,tier:t})=>e&&t!=="default")&&n[0]&&(o=K(t,Nc(e,n[0].skill.folder),r)),Ic(a.warnings,s,o.warnings);let l={name:t,description:o.status===`found`?Fc(o.metadata?.description):``,status:o.status};if(o.format&&o.format!==`markdown`&&(l.format=o.format),o.options){let e=n.map(({skill:e})=>`default of ${e.name}`);l.options=[.../* @__PURE__ */ new Set([...o.options.filter(e=>e!=="default"),...e])]}a.references.push(l);for(let e of o.trace.layers)e.file!==void 0&&e.tier!=="default"&&a.layers.push(Lc(t,e));for(let{skill:i}of n)a.layers.push(zc(t,i.name,i.folder,e,r))}return a}function zc(e,t,n,r,i){return{...Lc(e,K(e,Nc(r,n),i).trace.layers.find(({tier:e,file:t})=>e==="default"&&t)),reachedBy:`the default step, when ${t} loads ${e}`}}const Bc=[`name`,`prefix`,`close name`,`description`,`heading`,`body`];function Vc(e,t){let n=Array.from({length:t.length+1},(e,t)=>t);for(let r=1;r<=e.length;r++){let i=[r];for(let a=1;a<=t.length;a++){let o=n[a-1]+(e[r-1]===t[a-1]?0:1);i.push(Math.min(n[a]+1,i[a-1]+1,o))}n=i}return n[t.length]}function Hc(e){let t=!1,n=[];for(let r of e.split(`
|
|
184
|
+
`))/^ {0,3}(`{3,}|~{3,})/.test(r)?t=!t:!t&&/^ {0,3}#{1,6}\s/.test(r)&&n.push(r);return n.join(`
|
|
185
|
+
`)}function Uc(e){return Array.isArray(e)?e.map(String).join(` `):typeof e==`string`?e:``}function Wc(e,t,n){let r=e.slice(e.lastIndexOf(`/`)+1).toLowerCase();if(r===n||e.toLowerCase()===n)return`name`;if(r.startsWith(n))return`prefix`;if(r.includes(n)||Vc(r,n)<=Math.max(1,Math.floor(n.length/4)))return`close name`;let i=n.split(/\s+/),a=e=>{let t=e.toLowerCase();return i.every(e=>t.includes(e))},o=t.metadata??{};if(a(`${typeof o.description==`string`?o.description:``} ${Uc(o.tags)}`))return`description`;let s=t.content??``;if(a(Hc(s)))return`heading`;if(a(s))return`body`}function Gc(e,t,n={}){let r=e.trim().toLowerCase(),i=[],a=(e,t)=>{if(e.status!==`found`)return;let n=Wc(e.name,e,r);if(!n)return;let a=e.trace.contributions.at(-1),o={name:e.name,description:Fc(e.metadata?.description),match:n,tier:a?.tier??`plugin`};a?.plugin!==void 0&&(o.plugin=a.plugin),a?.skill!==void 0&&(o.skill=a.skill),t!==void 0&&(o.loadedBy=t),i.push(o)},o=/* @__PURE__ */ new Map;for(let e of ts(t)){let r=K(e,t,n);if(o.set(e,r.content),r.status!==`ambiguous`)a(r);else for(let e of r.options??[])e!=="default"&&a(K(e,t,n))}for(let{name:e,skill:r}of jc(t)){let i=K(e,Nc(t,r.folder),n);i.trace.layers.some(({tier:e,outcome:t})=>e==="default"&&t===`used`)&&i.content!==o.get(e)&&a(i,r.name)}i.sort((e,t)=>Bc.indexOf(e.match)-Bc.indexOf(t.match)||e.name.localeCompare(t.name));let s=Mc(t);return s?{matches:i,defaults:s}:{matches:i}}function Kc(e,t={}){let n=/* @__PURE__ */ new Map;return r=>{let i=n.get(r);if(i)return i;let a=qc(r,e,t);return n.set(r,a),a}}function qc(e,t,n){let r=`${e}${xo}`,i=K(r,t,n),a=t=>({failure:{check:`interface found`,interface:e,message:t}});if(i.status===`invalid`)return a(`${e} is not an interface id`);if(i.status===`missing`)return a(`no interface document ${r}`);if(i.status===`ambiguous`)return a(`${r} is ambiguous between ${(i.options??[]).join(` and `)}`);let{value:o,problems:s}=Do(e,i.metadata??{});return o?{value:o}:a(`${r} is malformed: ${s.join(`; `)}`)}function Jc(e){return e.slice(e.lastIndexOf(`/`)+1)}function Yc(e){let t=e.metadata??{};return Co(Jc(e.name))!==void 0||t.interface!==void 0?`interface`:t.implements===void 0?`none`:`implementation`}function Xc(e,t,n){if(e.status!==`found`)return{failures:[],unsupported:[]};let r=Jc(e.name),i=e.metadata??{},a=[],o=[];if(Yc(e)===`interface`){let e=Co(r);if(e===void 0)a.push({check:`interface`,message:`${r} has an \`interface:\` block; an interface document is named <id>${xo}`});else for(let t of Do(e,i).problems)a.push({check:`interface`,interface:e,message:t})}else{let{entry:s,problems:c}=Oo(i);for(let e of c)a.push({check:`interface found`,message:e});if(s){let i=t(s.id);if(i.value){let t=jo(i.value,{name:r,version:s.version,content:e.content??``,accept:n?.id===s.id?n.versions:void 0});a.push(...t.failures),o=t.unsupported}else a.push(i.failure)}}return e.warnings.length&&a.push({check:`compose`,message:`composing it raised ${e.warnings.length===1?`a warning`:`${e.warnings.length} warnings`}: ${e.warnings.map(({code:e,message:t})=>`${e}: ${t}`).join(`; `)}`}),{failures:a,unsupported:o}}function Zc(e,t){if(e.status!==`found`)return{name:e.name,kind:`none`,status:e.status,failures:[{check:e.code,message:e.message??e.status}],unsupported:[]};let n=Yc(e),{failures:r,unsupported:i}=n===`none`?{failures:[{check:`interface found`,message:`${e.name} declares no \`implements\` and is not an interface document`}],unsupported:[]}:Xc(e,t);return{name:e.name,kind:n,status:r.length?`failed`:`passed`,failures:r,unsupported:i}}function Qc(e,t){let n=[...new Set(t.trace.layers.flatMap(({plugin:e,file:t})=>e!==void 0&&t?[e]:[]))];return n.length>1?n.map(t=>`${t}/${e}`):[]}function $c(e,t={}){let{names:n,...r}=t,i=Kc(e,r),a=t=>K(G(t),e,r);if(n?.length)return n.map(e=>Zc(a(e),i));let o=[],s=/* @__PURE__ */ new Map;for(let t of ts(e)){let e=a(t);s.set(t,e.content);let n=[...e.status===`found`?[e]:[],...Qc(t,e).map(a)];for(let e of n)e.status===`found`&&Yc(e)!==`none`&&o.push(Zc(e,i))}for(let{name:t,skill:n}of jc(e)){let a=K(t,Nc(e,n.folder),r),c=a.trace.layers.some(({tier:e,outcome:t})=>e==="default"&&t===`used`);a.status===`found`&&c&&Yc(a)!==`none`&&a.content!==s.get(t)&&o.push({...Zc(a,i),loadedBy:n.name})}return o}function el(e){return typeof e==`string`&&e.split(`
|
|
186
|
+
`)[0]?.trim()||``}function tl(e,t,n){return t!==void 0&&t!==n&&(e===t||e.startsWith(`${t}.`))}function nl(e,t,n={}){let{accept:r,...i}=n,a=G(`${e}${xo}`);if(a.invalid||a.plugin!==void 0)throw Error(`"${e}" is not an interface id.`);let o=Kc(t,i),s=o(e),c=s.value;if(!c)throw Error(s.failure?.message??`no interface ${e}`);let l=[...r?.length?r:c.versions],u={interface:e,cardinality:c.cardinality,accept:l,implementations:[],excluded:[],warnings:[]},d=/* @__PURE__ */ new Set,f=(t,n)=>{if(n.status!==`found`)return;let r=Oo(n.metadata??{}).entry,i=t===e||t.startsWith(`${e}.`),a=r?.id===e;if(!a&&(!i||t.endsWith(`.interface`)||tl(t,r?.id,e)))return;for(let e of n.warnings){let t=`${e.code} ${e.message}`;d.has(t)||u.warnings.push(e),d.add(t)}if(!a){let r=ko(c,t)?``:` and is not named ${c.cardinality===`one`?e:`${e}.<key>`}`;u.excluded.push({name:n.name,reasons:[`declares no implements ${e}@<version>${r}`]});return}let{failures:s,unsupported:f}=Xc(n,o,{id:e,versions:l});if(s.length){u.excluded.push({name:n.name,reasons:s.map(({check:e,message:t})=>`${e}: ${t}`)});return}let p=n.trace.contributions.at(-1);u.implementations.push({pin:n.name,description:el(n.metadata?.description),unsupported:f,name:t,tier:p?.tier??`plugin`,version:r.version})};for(let n of ts(t)){if(n===`${e}.interface`)continue;let r=K(n,t,i);if(r.status!==`ambiguous`){f(n,r);continue}for(let e of r.options??[])e!=="default"&&f(n,K(e,t,i))}return u}const rl={project:`everyone working in this repository`,user:`only you, in every repository`};function il(e,t,{root:n,display:r=e=>e,assets:i}){let a=typeof e==`string`?G(e):e,o=K(a,t,{display:r}),s={name:a.raw,status:o.status,places:[],layers:o.trace.layers,warnings:o.warnings};if(o.options&&(s.options=o.options),a.invalid)return s;let c=Array.isArray(t)?t:t.layers,l=i?g(m(hc(n)),`assets`):hc(n),u=c.find(({tier:e})=>e===`user`)?.dir,d=[{scope:`project`,dir:l},...u?[{scope:`user`,dir:u}]:[]];for(let{scope:e,dir:c}of d){let l=g(c,`${a.name}.md`),u=[l,...W.map(({extension:e})=>g(c,`${a.name}${e}`))],d=o.trace.layers.find(e=>u.includes(e.path)),f=K(a,t,{display:r,below:c});s.places.push({scope:e,path:i?`${e===`project`?v(n,c):r(c)}/${a.name}.<ext>`:e===`project`?v(n,l):r(l),reaches:rl[e],status:d?.file?d.outcome:`empty`,sections:!i&&f.status===`found`&&f.format===`markdown`?yo(f.content??``):[]})}return s}function al(e){let t=e.sections.map(e=>`## ${e}\n\n**Unsupported.** Replace this line with the section, or say in one sentence why it is not supported.\n`);return sl(`---\ndescription: What this ${e.id} implementation covers, and when an agent should read it.\nimplements: ${e.id}@${e.version}\n---\n\n${t.join(`
|
|
187
|
+
`)}`,`the ${e.id} interface`)}function ol(e){if(e===void 0)return sl(`---
|
|
188
|
+
description: What this reference covers, and when an agent should read it.
|
|
189
|
+
tags: [topic]
|
|
190
|
+
---
|
|
191
|
+
|
|
192
|
+
## Overview
|
|
193
|
+
|
|
194
|
+
Write the guidance here. Give each topic its own top-level \`##\` section.
|
|
195
|
+
`,`the default template`);let t;try{t=o(e,`utf8`)}catch(t){throw Error(`cannot read the template ${e}: ${t.message}`)}return sl(t,`the template ${e}`)}function sl(e,t){let n=!0,{metadata:r,body:i}=Xa(e,()=>{n=!1});if(!n)throw Error(`${t} has frontmatter that is not a YAML mapping.`);return{content:e,metadata:r,body:i}}function cl({body:e}){let t=oo(e,()=>{}),[n]=t.children;return t.children.length===1&&n?.children.length?n.heading.trim():void 0}function ll({metadata:e}){return typeof e.description==`string`&&e.description.trim().length>0}function ul(e,t){let n=Ya.exec(e),r=n?e.slice(n[0].length):e,i=(0,Ka.parseDocument)(n?n[1]:``);for(let[e,n]of Object.entries(t))if(n===void 0)i.delete(e);else{let t=i.createNode(n,{flow:Array.isArray(n)});i.set(e,t)}if(!i.contents?.items?.length)return r.replace(/^(?:[ \t]*\r?\n)+/,``);let a=!n&&r.trim()?`
|
|
196
|
+
`:``;return`---\n${i.toString({lineWidth:0,flowCollectionPadding:!1})}---\n${a}${r}`}var Z=class extends Error{code;usage;constructor(e,t,n=!1){super(t),this.code=e,this.usage=n}};function dl(e){let t=G(e);if(t.invalid)throw new Z(`reference-invalid`,t.invalid);if(t.plugin!==void 0)throw new Z(`reference-qualified`,`a contribution is written under the bare name, which every tier resolves; ask for "${t.name}".`);return t}function fl(e,t){let n=Cc(bc(t)??y(t)),r=Cc(e);return r!==n&&!r.startsWith(n+b)?!1:!r.slice(n.length).split(b).includes(`node_modules`)}function pl(e,{root:t,home:n,scope:r,plugin:i,default:a}){if([r,i,a].filter(e=>e!==void 0).length>1)throw new Z(`options-conflict`,`pass one of --scope, --plugin, and --default.`,!0);if(i!==void 0){let n=y(i);if(!os(n))throw new Z(`folder-invalid`,`${n} holds no plugin manifest, so it is not a plugin folder.`);if(!fl(n,t))throw new Z(`folder-invalid`,`${n} is outside the repository, such as an installed copy; write to the plugin's source instead.`);let r=g(n,`references`);return{scope:`plugin`,dir:r,path:g(r,`${e.name}.md`)}}if(a!==void 0){let n=y(a);if(ms(n)===void 0)throw new Z(`folder-invalid`,`${n} holds no SKILL.md, so it is not a skill folder.`);if(!fl(n,t))throw new Z(`folder-invalid`,`${n} is outside the repository, such as an installed copy; write to the skill's source instead.`);let r=g(n,`references`);return{scope:`default`,dir:r,path:g(r,`${e.name}.default.md`)}}if(r!==void 0&&r!==`project`&&r!==`user`)throw new Z(`options-invalid`,`--scope is project or user.`,!0);let o=r===`user`?gc(n):hc(y(t));return{scope:r===`user`?`user`:`project`,dir:o,path:g(o,`${e.name}.md`)}}function ml(e){try{return o(e,`utf8`)}catch{return}}function hl(e,t=e=>e){if(e.status===`found`){let n=e.trace.contributions.at(-1),r=n?n.tier===`plugin`?`plugin ${n.plugin}`:n.tier==="default"?`the default of ${n.skill}`:`the ${n.tier} file ${t(n.path)}`:`nothing`,i=e.trace.stack.length?`, on the stack ${e.trace.stack.join(` → `)}`:``;return`"${e.name}" is answered by ${r}${i}.`}return e.status===`ambiguous`?`"${e.name}" is ambiguous: ${e.message}; the options are ${(e.options??[]).join(`, `)}.`:`"${e.name}" is ${e.status}: ${e.message}.`}function gl(e,t,n,r){let i=G(e);if(i.invalid||i.plugin!==void 0)throw new Z(`interface-invalid`,`"${e}" is not an interface id.`);let a=Kc(n,r)(e);if(!a.value)throw new Z(`interface-invalid`,a.failure?.message??`no interface ${e}`);if(!ko(a.value,t))throw new Z(`interface-invalid`,`an implementation of ${e} is named ${a.value.cardinality===`one`?e:`${e}.<key>`}, not "${t}".`);return a.value}function _l(e,t,n){let r=e.trace.layers,i=r.findIndex(e=>e.path===t||e.path===n);if(i===-1)return;let a=r[i],o=e=>e===`managed`||e===`project`||e===`user`,s=a&&!o(a.tier)?e.trace.stack.indexOf(a.tier==="default"?`default`:a.plugin??``):-1,c=r.filter((t,n)=>{if(!t.file||t.outcome!==`used`)return!1;if(a&&o(a.tier))return n<i&&o(t.tier);if(o(t.tier))return!0;let r=e.trace.stack.indexOf(t.tier==="default"?`default`:t.plugin??``);return s!==-1&&r>s}).find(e=>e.operation===`remove`||e.operation===`replace`&&!e.empty);return c?`${c.tier}${c.plugin?` ${c.plugin}`:``} ${c.path} (${c.operation})`:void 0}function vl(e,t,n){let r=Xa(e,()=>{}).metadata,i={};for(let[e,n]of Object.entries(t.metadata))e!==`merge`&&!(e in r)&&(i[e]=n);return i.merge=n,i}function yl(e,t){let n=t.replace(/^(?:[ \t]*\r?\n)+/,``);return n?`${e.replace(/\s*$/,``)}\n\n${n}`:e}function bl(e,t,n={}){let r=dl(t.name),i=pl(r,t);if(t.merge!==void 0&&!Ja(t.merge))throw new Z(`options-invalid`,`--merge is replace, patch, combine, or remove; got "${t.merge}".`,!0);let o=t.merge;if(t.template!==void 0&&t.implements!==void 0)throw new Z(`options-conflict`,`pass --template or --implements, not both.`);if(o===`remove`&&t.template!==void 0)throw new Z(`options-conflict`,`--merge remove writes no body, so it takes no --template.`);if(o!==void 0&&i.scope==="default")throw new Z(`options-conflict`,`a default is written with no merge; drop --merge.`);let s=ml(i.path);if(s!==void 0&&Qa(Xa(s,()=>{}).body))throw new Z(`file-exists`,`${(n.display??(e=>e))(i.path)} already holds "${r.name}"; change it with the reference skill's Update mode.`);let c=t.implements===void 0?o===`remove`?{content:``,metadata:{},body:``}:ol(t.template===void 0?void 0:y(t.template)):al(gl(t.implements,r.name,e,n)),l=cl(c);if(l)throw new Z(`template-title`,`the template's top level is the single heading "${l}" holding the others; patch matches by heading path, so make its sections top-level.`);let u=K(r,e,n),d=_l(u,i.dir,i.path);if(d)throw new Z(`hidden`,`${d} applies above it, so nothing would read the new file; change that contribution instead.`);let p=i.scope==="default"?void 0:t.implements===void 0?o??(Ja(c.metadata.merge)?c.metadata.merge:void 0)??(i.scope===`plugin`?void 0:`patch`):`replace`,m=s===void 0?ul(c.content,{merge:p}):yl(ul(s,vl(s,c,p)),c.body),h=ll(Xa(m,()=>{}))?[]:["it has no `description` in its frontmatter, so `list` and `search` show it blank"],g={name:r.name,scope:i.scope,path:i.path,content:m,dryRun:!!t.dryRun,hints:h};return g.dryRun?g:(a(i.dir,{recursive:!0}),f(i.path,m,s===void 0?{flag:`wx`}:{}),u.trace.layers.some(e=>e.path===i.dir||e.path===i.path)&&(g.after=K(r,e,n)),g)}function xl(e,t,n={}){let r=dl(t.name),i=pl(r,{root:t.root,home:t.home,scope:t.scope}),o=i.scope,s=ml(i.path);if(t.clear){if(t.options.length)throw new Z(`options-conflict`,`--clear takes no option.`,!0);if(!(s!==void 0&&Ro(Xa(s,()=>{}).metadata.extends,()=>{})))throw new Z(`no-selection`,`the ${o} tier holds no selection of "${r.name}". ${hl(K(r,e,n),n.display)}`);let a=ul(s,{extends:void 0}),c=!a.trim();return c?l(i.path):f(i.path,a),{name:r.name,scope:o,path:i.path,extends:[],deleted:c,after:K(r,e,n)}}if(!t.options.length)throw new Z(`options-missing`,`name at least one option: a plugin or default.`,!0);let c=K(r,e,n),u=new Set(c.trace.layers.flatMap(({plugin:e,file:t})=>e!==void 0&&t?[e]:[])),d=t.options.map(e=>e.endsWith(`/${r.name}`)?e.slice(0,-r.name.length-1):e),p=d.filter(e=>e!=="default"&&!u.has(e));if(p.length)throw new Z(`option-invalid`,`${p.join(`, `)} ${p.length===1?`is`:`are`} neither default nor a plugin holding "${r.name}"${u.size?`; the plugins holding it are ${[...u].join(`, `)}`:``}.`);let m=ul(s??``,{extends:d});return a(i.dir,{recursive:!0}),f(i.path,m),{name:r.name,scope:o,path:i.path,extends:d,deleted:!1,after:K(r,e,n)}}function Sl(e,t){return W.map(({extension:n})=>g(e,`${t}${n}`))}function Cl(e,t,n={}){let i=dl(t.name),a=pl(i,t),o=n.display??(e=>e),s=K(i,e,n),c=(a.scope===`project`||a.scope===`user`?[a.path,g(a.dir,i.name,`README.md`),...Sl(a.dir,i.name)]:[a.path]).find(e=>e!==n.without&&r(e));if(!c)throw new Z(`no-file`,`${o(a.path)} does not exist, so there is no ${a.scope} contribution of "${i.name}" to delete. ${hl(s,n.display)} An installed plugin's, a managed, or an installed skill's contribution is never deleted.`);let d=Ro(Xa(ml(c)??``,()=>{}).metadata.extends,()=>{}),f=!!t.dryRun;if(!f&&(l(c),m(c)!==a.dir))try{u(m(c))}catch{}let p={name:i.name,scope:a.scope,path:c,dryRun:f,after:K(i,e,{...n,without:f?c:void 0})};return d&&(p.selection=d.map(({target:e})=>e)),p}const wl={description:"Directory the project tier is read from, and each folder above it up to the repository root; a project write goes to its `.agents/references/`. Defaults to the current directory.",type:P.string().optional()},Tl={description:`Add the trace: every layer checked, with its outcome, and how the result was built.`,type:P.boolean().optional()},El={description:"The calling skill's folder: its `references/<name>.default.md` joins as the `default` tier.",type:P.string().optional()};function Dl(e,t=`references`){return(n,r)=>Ac({root:n.root??process.cwd(),home:r,platform:process.platform,env:process.env,plugin:e,defaultSkill:n.default,folder:t})}function Q(e){return Object.fromEntries(Object.entries(e).filter(([,e])=>e!==void 0&&e!==``&&!(Array.isArray(e)&&!e.length)))}function Ol(e,t){throw ae(e)?e:e instanceof Z?(process.stderr.write(`error: ${e.code}: ${e.message}\n`),j.reported(e.usage?A.usage:A.error)):(process.stderr.write(`error: ${e instanceof Error?e.message:t}\n`),j.reported(A.error))}function kl(e){throw process.stderr.write(`error: usage: ${e}\n`),j.reported(A.usage)}function Al(e,t){let n=tr(e,t);throw n!==void 0&&process.stdout.write(n),j.reported(A.error)}function jl(e){for(let{code:t,message:n}of e)process.stderr.write(`warning: ${t}: ${n}\n`)}function Ml(e,t){let n=e=>B(t,e);return{...e,contributions:e.contributions.map(e=>({...e,path:n(e.path)})),layers:e.layers.map(e=>({...e,path:n(e.path)}))}}function Nl(e,t){let n=Ml(e.trace,t),r=[`${e.name}: ${e.status}; stack: ${n.stack.join(` → `)||`none`}; built by ${n.builtBy}; harnesses: ${n.harnesses.join(`, `)||`none detected`}`];if(e.message&&r.push(` ${e.message}`),n.sections.length){r.push(`sections:`);for(let e of n.sections){let t=e.removedBy?`removed by ${e.removedBy}`:e.contributions.map(({contribution:e,operation:t})=>`${e} (${t})`).join(`, `)||`no text`;r.push(` ${e.path}: ${t}`)}}r.push(`layers:`);for(let e of n.layers){let t=e.plugin?` ${e.plugin}`:e.skill?` ${e.skill}`:``,n=e.operation?`; ${e.operation} from ${e.operationFrom}`:``,i=e.extendsOutcome?`; extends ${e.extendsOutcome}`:``,a=e.selection?`; selection`:``,o=e.frontmatter&&Object.keys(e.frontmatter).length?` ${JSON.stringify(e.frontmatter)}`:``;r.push(` ${e.tier}${t} ${e.path}: ${e.outcome}${n}${i}${a}${o}`)}return`${r.join(`
|
|
197
|
+
`)}\n`}function Pl(e){let t=e.options?.length?`; options: ${e.options.join(`, `)}`:``;return`${e.name}: ${e.message}${t}`}function Fl(e,t,{metadata:n,trace:r}){return e.status===`found`&&!e.warnings.length&&!n&&!r&&e.format===`markdown`?e.content:Q({name:e.name,status:e.status,content:e.content,format:e.format===`markdown`?void 0:e.format,code:e.code,options:e.options,metadata:n?e.metadata:void 0,warnings:e.warnings,trace:r?Ml(e.trace,t):void 0})}const Il={toon:e=>Sn(e,`toon`),json:e=>Sn(e,`json`)};function Ll(e){if(e.length===1){let[t]=e;return t.content===void 0?void 0:z(t.content)}return z(e.map(e=>e.content===void 0?`<reference name="${e.name}" status="${e.status}" />`:`<reference name="${e.name}">\n${e.content}</reference>`).join(`
|
|
198
|
+
|
|
199
|
+
`))}function Rl(e,t=`show`){return M({name:t,description:`Print one or more references, each composed from its contributions as their extends and merge declare.`,arguments:[{name:`names`,description:"Reference names, without the `.md` extension; `<plugin>/<name>` builds that plugin’s own stack.",type:P.array(P.string())}],options:{root:wl,default:El,metadata:{description:`Make every entry a record with its status and composed frontmatter.`,type:P.boolean().optional()},trace:Tl},async run(t){let n=this.format;t.names.length||kl(`name at least one reference.`);try{let r=w(),i=await e(t,r),a=e=>B(r,e),o=Kc(i,{display:a}),s=t.names.map(e=>{let t=K(G(e),i,{display:a});for(let e of Xc(t,o).failures)e.check!==`compose`&&t.warnings.push({code:`interface-check`,message:`it fails its interface check (${e.check}): ${e.message}`});return t}),c=s.every(e=>e.status===`found`);if(n===`text`){for(let e of s)jl(e.warnings),e.status!==`found`&&process.stderr.write(`error: ${e.code}: ${Pl(e)}\n`),t.trace&&process.stderr.write(Nl(e,r));let e=Ll(s);if(e===void 0)throw j.reported(A.error);return c?e:Al(e,n)}let l={metadata:!!t.metadata,trace:!!t.trace},u=R(s.map(e=>Fl(e,r,l)),{render:Il});return c?u:Al(u,n)}catch(e){return Ol(e,`Reference lookup failed.`)}}})}function zl(e,t=`list`){return M({name:t,description:`List every reference name, one row each, with its description, and its status when not found. A pattern keeps only the names it matches exactly.`,arguments:[{name:`pattern`,description:"Exact name pattern, where `*` stands for any run of characters, such as `project-tracker.capabilities.*`.",type:P.string().optional()}],options:{root:wl,trace:{...Tl,description:`Add one row per name per layer holding it, with its outcome.`}},async run(t){try{let n=w(),r=e=>B(n,e),i=Rc(await e(t,n),{display:r,pattern:t.pattern}),a=Q({references:i.references.length?i.references.map(e=>Q({name:e.name,description:e.description,format:e.format,status:e.status===`found`?void 0:e.status,options:e.options})):t.pattern?`0 references match "${t.pattern}"`:`0 references — no layer holds one`,defaults:i.defaults});return t.trace&&(a.layers=i.layers.map(e=>Q({...e,path:r(e.path)}))),i.warnings.length&&(a.warnings=i.warnings),R(a)}catch(e){return Ol(e,`Reference listing failed.`)}}})}function Bl(e){return M({name:`search`,description:`Find references by name, description, tags, headings, or body, best match first.`,arguments:[{name:`query`,description:`What the reference is about.`,type:P.string()}],options:{root:wl,trace:{...Tl,description:`Add the tier and plugin or skill of each match.`}},async run(t){let n=t.query.trim();n||kl(`search needs a query.`);try{let r=w(),{matches:i,defaults:a}=Gc(n,await e(t,r),{display:e=>B(r,e)});return R(Q({references:i.length?i.map(({name:e,description:n,match:r,tier:i,plugin:a,skill:o,loadedBy:s})=>Q(t.trace?{name:e,description:n,match:r,loadedBy:s,tier:i,plugin:a,skill:o}:{name:e,description:n,match:r,loadedBy:s})):`0 references match "${n}"`,defaults:a}))}catch(e){return Ol(e,`Reference search failed.`)}}})}function Vl(e,t=!1,n=`where`){return M({name:n,description:`Give the project and user files a customization or a selection of a reference is written to, who each reaches, and the heading paths of the document below each.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:P.string()}],options:{root:wl,default:El,trace:{...Tl,description:`Add every layer checked, with its outcome.`}},async run(n){let r=this.format;try{let i=w(),a=e=>B(i,e),o=il(n.name,await e(n,i),{root:y(n.root??process.cwd()),display:a,assets:t}),s=Q({name:o.name,status:o.status,places:o.places.map(e=>Q(e)),options:o.options,layers:n.trace?o.layers.map(e=>({...e,path:a(e.path)})):void 0,warnings:o.warnings});r===`text`&&jl(o.warnings);let c=R(s);return o.status===`invalid`?(process.stderr.write(`error: reference-invalid: ${G(n.name).invalid}\n`),Al(c,r)):c}catch(e){return Ol(e,`Reference placement lookup failed.`)}}})}function Hl(e){if(e===void 0)return;let t=e.split(`,`).map(e=>e.trim());return(!t.length||t.some(e=>!/^[1-9]\d*$/.test(e)))&&kl(`--accept is a comma-separated list of versions, such as 1,2; got "${e}".`),t.map(Number)}function Ul(e){return M({name:`implementations`,description:`List the implementations of an interface a consumer can load, each with its pin, description, and unsupported sections.`,arguments:[{name:`id`,description:"Interface id, the name of its `<id>.interface` document without the suffix.",type:P.string()}],options:{root:wl,accept:{description:"Versions the consumer knows, comma-separated, such as 1,2. Defaults to the interface's `versions`.",type:P.string().optional()},trace:{...Tl,description:`Add each one's name, tier, and version, the interface's cardinality and accepted versions, and the ones left out with why.`}},async run(t){let n=Hl(t.accept);try{let r=w(),i=nl(t.id,await e(t,r),{accept:n,display:e=>B(r,e)}),a=i.implementations.map(({pin:e,description:n,unsupported:r,name:i,tier:a,version:o})=>Q(t.trace?{pin:e,description:n,unsupported:r,name:i,tier:a,version:o}:{pin:e,description:n,unsupported:r})),o={implementations:a.length?a:`0 implementations of ${t.id}`};return t.trace&&Object.assign(o,Q({interface:i.interface,cardinality:i.cardinality,accept:i.accept,excluded:i.excluded,warnings:i.warnings})),R(o)}catch(e){return Ol(e,`Implementation lookup failed.`)}}})}function Wl(e){return M({name:`check`,description:"Check interface documents and their implementations, each composed as `show` composes it. With no names, checks every one found. Exits 1 on any failure.",arguments:[{name:`names`,description:"Reference names, without the `.md` extension; `<plugin>/<name>` builds that plugin’s own stack.",type:P.array(P.string()).optional()}],options:{root:wl,trace:{...Tl,description:`Add every entry checked, with its kind and unsupported sections.`}},async run(t){let n=this.format;try{let r=w(),i=$c(await e(t,r),{names:t.names??[],display:e=>B(r,e)}),a=i.filter(e=>e.status!==`passed`),o=e=>e.map(({check:e,message:t})=>({check:e,message:t})),s=R(Q({failed:a.map(({name:e,loadedBy:t,failures:n})=>Q({name:e,loadedBy:t,failures:o(n)})),passed:i.length-a.length,references:t.trace?i.map(({name:e,loadedBy:t,kind:n,status:r,failures:i,unsupported:a})=>Q({name:e,loadedBy:t,kind:n,status:r,failures:o(i),unsupported:a})):void 0}));return a.length?(n===`text`&&process.stderr.write(`error: interface-check: ${a.length} of ${i.length} references fail their check.\n`),Al(s,n)):s}catch(e){return Ol(e,`Reference check failed.`)}}})}const Gl={description:"Tier to write: project (default), `.agents/references/` at the root, or user, `~/.agents/references/`.",type:P.string().optional()},Kl={description:"A plugin's source folder in this repository: acts on its `references/<name>.md`.",type:P.string().optional()},ql={description:"A skill's source folder in this repository: acts on its `references/<name>.default.md`.",type:P.string().optional()};function Jl(e){return M({name:`create`,description:`Start a contribution in the project or user tier, or in a plugin's or a skill's source folder, from a template or an interface. Never overwrites a file with a body.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:P.string()}],options:{root:wl,scope:Gl,plugin:Kl,default:ql,merge:{description:`How it applies over what is below: replace, patch (default), combine, or remove. remove writes no body.`,type:P.string().optional()},template:{description:"File whose text is written as it is, frontmatter included. Defaults to a built-in template of top-level `##` sections.",type:P.string().optional()},implements:{description:"Interface id to implement: the interface's sections become `##` headings, each stubbed `**Unsupported.**`, with `merge: replace`. Not with --template.",type:P.string().optional()},"dry-run":{description:`Print the target path and the exact content, and write nothing.`,type:P.boolean().optional()},trace:{...Tl,description:`After the write, add the trace, in which the new file applies.`}},async run(t){let n=this.format;try{let r=w(),i=y(t.root??process.cwd()),a=e=>B(r,e),o=bl(await e({root:i,default:t.default},r),{root:i,home:r,name:t.name,scope:t.scope,plugin:t.plugin,default:t.default,merge:t.merge,template:t.template,implements:t.implements,dryRun:t[`dry-run`]},{display:a}),s=Q({path:a(o.path),hint:o.dryRun?`Nothing was written. Run again without --dry-run to write it.`:`Run \`show ${o.name}\` for the composed document.`,content:o.dryRun?o.content:void 0,hints:o.hints,trace:t.trace&&o.after?Ml(o.after.trace,r):void 0});if(n!==`text`)return R(s);for(let e of o.hints)process.stderr.write(`hint: ${e}\n`);return t.trace&&o.after&&process.stderr.write(Nl(o.after,r)),z(o.dryRun?`${s.path}\n\n${o.content}`:`${s.path}\n\n${s.hint}\n`)}catch(e){return Ol(e,`Reference creation failed.`)}}})}function Yl(e){return M({name:`select`,description:"Choose what a name builds on: write an `extends` listing the options, bottom first, in the project or user file. Its body and other keys are kept.",arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:P.string()},{name:`options`,description:"Bottom first: each a plugin holding the name (or `<plugin>/<name>`), or `default`.",type:P.array(P.string()).optional()}],options:{root:wl,scope:Gl,clear:{description:`Remove the selection; a file left with nothing in it is deleted.`,type:P.boolean().optional()}},async run(t){let n=this.format;try{let r=w(),i=y(t.root??process.cwd()),a=e=>B(r,e),o=xl(await e({root:i},r),{root:i,home:r,name:t.name,options:t.options??[],scope:t.scope,clear:t.clear},{display:a}),s=Q({path:a(o.path),extends:o.extends,deleted:o.deleted||void 0,status:o.after.status,stack:o.after.trace.stack,answer:hl(o.after,a)});if(n!==`text`)return R(s);jl(o.after.warnings);let c=t.clear?o.deleted?`selection cleared; the file was left empty and deleted`:`selection cleared`:`extends: [${o.extends.join(`, `)}]`;return z(`${s.path}\n\n${c}. ${s.answer}\n`)}catch(e){return Ol(e,`Reference selection failed.`)}}})}function Xl(e,t){let n=e.selection?`the selection extends: [${e.selection.join(`, `)}] went with it; run \`reference select ${e.name} <option>...\` to restore it`:void 0;return Q({path:B(t,e.path),dryRun:e.dryRun||void 0,status:e.after.status,stack:e.after.trace.stack,answer:hl(e.after,e=>B(t,e)),selection:n,options:e.after.options})}function Zl(e){return M({name:`delete`,description:`Delete a project or user contribution, or one in a plugin's or a skill's source folder, and report what answers the name afterwards. Never deletes an installed or managed one.`,arguments:[{name:`name`,description:"Reference name, without the `.md` extension.",type:P.string()}],options:{root:wl,scope:{...Gl,description:`Tier to delete from: project (default) or user.`},plugin:Kl,default:ql,"dry-run":{description:`Print the file that would be deleted and what would answer the name then, and delete nothing.`,type:P.boolean().optional()}},async run(t){let n=this.format;try{let r=w(),i=y(t.root??process.cwd()),a=Cl(await e({root:i,default:t.default},r),{root:i,home:r,name:t.name,scope:t.scope,plugin:t.plugin,default:t.default,dryRun:t[`dry-run`]},{display:e=>B(r,e)}),o=Xl(a,r);if(n!==`text`)return R(o);let s=o.selection?` Also, ${o.selection}.`:``;return z(`${o.path}\n\n${a.dryRun?`would delete`:`deleted`}. ${o.answer}${s}\n`)}catch(e){return Ol(e,`Reference deletion failed.`)}}})}function Ql({plugin:e}={}){let t=Dl(e);return{show:Rl(t),list:zl(t),search:Bl(t),where:Vl(t),create:Jl(t),select:Yl(t),delete:Zl(t),check:Wl(t),implementations:Ul(t)}}function $l(e={}){let{show:t,list:n,search:r,where:i,create:a,select:o,delete:s,check:c,implementations:l}=Ql(e);return M({name:`reference`,description:`Read reference documents by name, composed from the managed, project, user, plugin, and default tiers, and write, select, or delete a contribution.`,commands:[t,n,r,i,a,o,s,l,c]})}function eu({plugin:e}={}){let t=Dl(e,`assets`);return{load:Rl(t,`load`),names:zl(t,`names`),where:Vl(t,!0)}}var $=class extends Error{code;usage;constructor(e,t,n=!1){super(t),this.code=e,this.usage=n}};function tu(e,t,n){let r=y(e);if(ms(r)===void 0)throw new $(`folder-invalid`,`${r} holds no SKILL.md, so it is not a skill folder.`);if(n&&!fl(r,t))throw new $(`folder-invalid`,`${r} is outside the repository, such as an installed copy; write to the skill's source instead.`);return g(r,`assets`)}function nu(e,t){let n=t.split(`/`);if(!t||t.includes(`\\`)||t.startsWith(`/`)||n.some(e=>e===``||e===`.`||e===`..`))throw new $(`path-invalid`,`"${t}" is not an asset path. Use a relative path inside assets/, with "/" separators and no "..".`,!0);return g(e,...n)}function ru(e,t){if(!r(e))return!0;let n=c(e),i=t;for(;!r(i);)i=m(i);let a=c(i);return a===n||a.startsWith(n+b)}function iu(e,t,n){if(!ru(e,t))throw new $(`path-invalid`,`"${n}" leaves the assets/ folder through a link.`,!0)}function au(e,t){let n=tu(e,t,!1),r=[],a=(e,t)=>{let n;try{n=s(e,{withFileTypes:!0})}catch{return}for(let o of n){let n=g(e,o.name),s=i(n);s.isSymbolicLink()||(s.isDirectory()?a(n,`${t}${o.name}/`):s.isFile()&&r.push({path:`${t}${o.name}`,bytes:s.size}))}};return a(n,``),r.sort((e,t)=>e.path.localeCompare(t.path))}function ou(e,t,n){let a=tu(e,t,!1),s=nu(a,n);if(iu(a,s,n),!r(s)||!i(s).isFile())throw new $(`no-file`,`${n} does not exist in assets/.`);let c=o(s);if(c.includes(0))throw new $(`binary`,`${n} is binary (${c.length} bytes); point to it by path instead of showing it.`);return c.toString(`utf8`)}function su(e,t,n,i,o){let s=tu(t,n,!0),c=nu(s,i);iu(s,c,i);let l=r(c);if(e===`create`&&l)throw new $(`exists`,`${i} already exists in assets/; use update to replace it.`);if(e===`update`&&!l)throw new $(`no-file`,`${i} does not exist in assets/; use create to add it.`);return a(m(c),{recursive:!0}),f(c,o),c}function cu(e,t,n){let a=tu(e,t,!0),o=nu(a,n);if(iu(a,o,n),!r(o)||!i(o).isFile())throw new $(`no-file`,`${n} does not exist in assets/.`);l(o);for(let e=m(o);e!==a&&e.startsWith(a+b);e=m(e))try{u(e)}catch{break}return o}function lu(e,t){let i=G(t.name);if(i.invalid||i.plugin!==void 0)throw new $(`name-invalid`,i.invalid??`create takes a bare name.`,!0);if(t.scope!==`project`&&t.scope!==`user`)throw new $(`options-invalid`,`--scope is project or user.`,!0);if(t.copy===`managed`)throw new $(`managed-copy-refused`,`the managed tier is policy and is never copied into a project or user folder. Ask the administrator, or read it with "asset load".`);let o=K(i.name,e).trace.layers.filter(({file:e})=>e),s=o.find(e=>t.copy==="default"||t.copy===`project`||t.copy===`user`?e.tier===t.copy:e.tier===`plugin`&&e.plugin===t.copy);if(!s){let e=o.map(e=>e.tier===`plugin`?e.plugin:e.tier);throw new $(`no-source`,`"${t.copy}" holds no asset "${i.name}". Held by: ${e.filter(e=>e!==`managed`).join(`, `)||`nothing`}.`)}let c=h(s.path);if(s.file&&![...W.map(e=>e.extension),`.md`].includes(c))throw new $(`no-source`,`${p(s.path)} is not a file an asset name resolves to.`);let l=t.scope===`user`?gc(t.home):hc(y(t.root)),u=g(m(l),`assets`),d=[`.md`,...W.map(e=>e.extension)].map(e=>g(u,`${i.name}${e}`)).find(e=>r(e));if(d)throw new $(`exists`,`${d} already exists; edit it, or delete it first.`);let f=g(u,`${i.name}${c}`);return a(u,{recursive:!0}),n(s.path,f),{path:f,source:s.path,from:t.copy}}function uu(e,t){let n=K(t,e).trace.layers;return[...n.filter(({tier:e,file:t})=>e===`plugin`&&t).map(({plugin:e})=>e),...n.some(({tier:e,file:t})=>e==="default"&&t)?[`default`]:[]]}function du(e,t){let n=G(t.name);if(n.invalid||n.plugin!==void 0)throw new $(`name-invalid`,n.invalid??`select takes a bare name.`,!0);if(t.scope!==void 0&&t.scope!==`project`&&t.scope!==`user`)throw new $(`options-invalid`,`--scope is project or user.`,!0);let i=t.scope===`user`?gc(t.home):hc(y(t.root)),o=g(m(i),`assets`,`${n.name}.select`);if(t.clear){if(!r(o))throw new $(`no-file`,`${o} does not exist, so there is no selection to clear.`);l(o)}else{let r=uu(e,n.name);if(!t.option||!r.includes(t.option))throw new $(`option-invalid`,`"${t.option??``}" cannot be selected for "${n.name}". Options: ${r.join(`, `)||`none, no plugin or default holds it`}.`,!t.option);a(m(o),{recursive:!0}),f(o,`${t.option}\n`)}let s={path:o,cleared:!!t.clear,after:K(n.name,e,{without:t.clear?o:void 0})};return t.clear?s:{...s,selected:t.option}}const fu={description:"A skill's source folder in this repository: its `assets/` folder is acted on.",type:P.string()},pu={description:`The directory the repository is found from. Defaults to the current directory.`,type:P.string().optional()};function mu(e,t){throw ae(e)?e:e instanceof $?(process.stderr.write(`error: ${e.code}: ${e.message}\n`),j.reported(e.usage?A.usage:A.error)):(process.stderr.write(`error: ${e instanceof Error?e.message:t}\n`),j.reported(A.error))}function hu(e){throw process.stderr.write(`error: usage: ${e}\n`),j.reported(A.usage)}const gu="Asset path inside `assets/`, such as `data/rules.json`.";function _u(e){return y(e.root??process.cwd())}function vu(){return M({name:`list`,description:`List every file in a skill's assets/ folder with its size.`,options:{skill:fu,root:pu},async run(e){try{let t=au(e.skill,_u(e));return R({assets:t.length?t:`0 assets — the skill holds none`})}catch(e){return mu(e,`Asset listing failed.`)}}})}function yu(){return M({name:`show`,description:`Print a text asset as written.`,arguments:[{name:`path`,description:gu,type:P.string()}],options:{skill:fu,root:pu},async run(e){try{return z(ou(e.skill,_u(e),e.path))}catch(e){return mu(e,`Asset read failed.`)}}})}function bu(e,t){let n=e===`create`;return M({name:e,description:n?`Add a new asset: by path in a skill from --content or --from, or, with --copy, by name in the project or user assets folder as a copy of what a plugin, the default, or another tier holds (never the managed tier). Never overwrites a file.`:`Replace an existing asset from --content or --from.`,arguments:[{name:`path`,description:`${gu} With --copy, the asset name.`,type:P.string()}],options:{skill:{...fu,type:P.string().optional()},root:pu,content:{description:`The text to write.`,type:P.string().optional()},from:{description:`A local file whose bytes to write.`,type:P.string().optional()},...n?{default:{description:"With --copy, the calling skill's folder: its `assets/<name>.<ext>` is the `default` source.",type:P.string().optional()},copy:{description:"Copy the asset of this source: a plugin's name, `default` (the skill's own file), `project`, or `user`. `managed` is refused.",type:P.string().optional()},scope:{description:"With --copy, where the copy goes: project (default), `.agents/assets/`, or user, `~/.agents/assets/`.",type:P.string().optional()}}:{}},async run(r){try{if(r.copy!==void 0){(r.content!==void 0||r.from!==void 0)&&hu(`--copy takes neither --content nor --from.`);let e=w(),n=_u(r),i=lu(await Ac({root:n,home:e,platform:process.platform,env:process.env,plugin:t.plugin,defaultSkill:r.default??r.skill,folder:`assets`}),{root:n,home:e,name:r.path,scope:r.scope??`project`,copy:r.copy});return z(`${i.path}\n\ncopied from ${i.from}. Edit it; it now answers over the plugin tier.\n`)}r.skill||hu(`pass --skill, or --copy to create an override by name.`),r.content===void 0==(r.from===void 0)&&hu(`pass exactly one of --content and --from.`);let i=r.content??o(y(r.from),`utf8`);return z(`${su(e,r.skill,_u(r),r.path,i)}\n\n${n?`created`:`updated`}.\n`)}catch(t){return mu(t,`Asset ${e} failed.`)}}})}function xu(){return M({name:`delete`,description:`Delete an asset from a skill's source folder, and any folder it leaves empty.`,arguments:[{name:`path`,description:gu,type:P.string()}],options:{skill:fu,root:pu},async run(e){try{return z(`${cu(e.skill,_u(e),e.path)}\n\ndeleted.\n`)}catch(e){return mu(e,`Asset deletion failed.`)}}})}function Su(e){return M({name:`select`,description:"Choose which plugin, or the skill itself, answers an asset name that several hold, by writing `<name>.select` in the project or user assets folder.",arguments:[{name:`name`,description:`Asset name, without its extension.`,type:P.string()},{name:`option`,description:"A plugin name, or `default` for the skill's own file. Not used with --clear.",type:P.string().optional()}],options:{root:pu,default:{description:"The calling skill's folder: its `assets/<name>.<ext>` is the `default` option.",type:P.string().optional()},scope:{description:"Where to write: project (default), `.agents/assets/`, or user, `~/.agents/assets/`.",type:P.string().optional()},clear:{description:`Remove the selection.`,type:P.boolean().optional()}},async run(t){try{let n=w(),r=y(t.root??process.cwd()),i=du(await Ac({root:r,home:n,platform:process.platform,env:process.env,plugin:e.plugin,defaultSkill:t.default,folder:`assets`}),{...t,root:r,home:n}),a=i.after.status===`found`?`${t.name} now answers from ${i.after.trace.stack.join(`, `)||`a tier`}.`:`${t.name} is ${i.after.status}: ${i.after.message??``}`;return z(`${i.path}\n\n${i.cleared?`selection cleared`:`selected ${i.selected}`}. ${a}\n`)}catch(e){return mu(e,`Asset selection failed.`)}}})}function Cu(e={}){let{load:t,names:n,where:r}=eu(e);return M({name:`asset`,description:`Manage a skill's assets/ files by path (list, show, create, update, delete), and load one by name through the tiers (load, names, where, select).`,commands:[vu(),yu(),bu(`create`,e),bu(`update`,e),xu(),t,n,r,Su(e)]})}const wu=[`e.g.`,`i.e.`,`etc.`,`vs.`],Tu=/^\s*(`{3,}|~{3,})/,Eu=/^#{1,6}\s/,Du=/^\s*(?:[-*+]|\d+[.)])\s/,Ou=/^\s*\|/,ku=/^\s*>/;function Au(e){return wu.some(t=>{if(!e.endsWith(t))return!1;let n=e.length-t.length;return n===0||/\s/.test(e[n-1])})}function ju(e){let t=[],n=0;for(let r=0;r<e.length;r++){if(!`.;?!`.includes(e[r]))continue;let i=e[r+1];(i===void 0||/\s/.test(i))&&(e[r]===`.`&&Au(e.slice(n,r+1))||(t.push(e.slice(n,r+1)),n=r+1))}return t.push(e.slice(n)),t.map(e=>e.trim()).filter(Boolean)}function Mu(e){let t=e.split(/\r?\n/),n=[],r=[],i=!1,a=()=>n.length===0?``:i?`
|
|
200
|
+
|
|
201
|
+
`:`
|
|
202
|
+
`,o=(e,t)=>{n.push({text:e,kind:t,gap:a()}),i=!1},s=()=>{r.length&&(ju(r.join(` `)).forEach((e,t)=>{t===0?o(e,`text`):n.push({text:e,kind:`text`,gap:` `})}),r=[])};for(let e=0;e<t.length;e++){let n=t[e],a=Tu.exec(n);if(a){s();let r=a[1][0],i=[n.trimEnd()];for(;++e<t.length;){i.push(t[e].trimEnd());let n=Tu.exec(t[e]);if(n&&n[1][0]===r&&t[e].trim()===n[1])break}o(i.join(`
|
|
203
|
+
`),`fence`)}else if(!n.trim())s(),i=!0;else if(Eu.test(n))s(),o(n.trim(),`heading`);else if(ku.test(n)){s();let r=[n.trim()];for(;e+1<t.length&&ku.test(t[e+1]);)r.push(t[++e].trim());o(r.join(`
|
|
204
|
+
`),`quote`)}else Ou.test(n)?(s(),o(n.trim(),`row`)):Du.test(n)?(s(),o(n.trim(),`item`)):r.push(n.trim())}return s(),n}function Nu(e,t){return e.replace(/\s+/g,` `).trim()===t.replace(/\s+/g,` `).trim()}function Pu(e,t){let n=Array.from({length:e.length+1},()=>Array(t.length+1).fill(0)),r=(e,t)=>n[e][t];for(let i=e.length-1;i>=0;i--)for(let a=t.length-1;a>=0;a--)n[i][a]=Nu(e[i].text,t[a].text)?r(i+1,a+1)+1:Math.max(r(i+1,a),r(i,a+1));let i=[],a=0,o=0;for(;a<e.length&&o<t.length;)Nu(e[a].text,t[o].text)&&r(a,o)===r(a+1,o+1)+1?i.push([a++,o++]):r(a+1,o)>=r(a,o+1)?a++:o++;return i}function Fu(e,t){return Pu(e,t).length}const Iu=/^## Superseded(?:\s+(.*))?$/,Lu=/^(`{3,}|~{3,})(.*)$/;function Ru(e){let t=[],n=0;for(;n<=e.length;){let r=e.indexOf(`
|
|
205
|
+
`,n),i=r===-1?e.length:r;if(t.push({text:e.slice(n,i),start:n,end:i}),r===-1)break;n=r+1}return t}function zu(e){let t=[],n;return e.forEach((e,r)=>{let i=Lu.exec(e.text);n?i&&i[1]===n&&!i[2]?.trim()&&(n=void 0):i?n=i[1]:Iu.test(e.text)&&t.push(r)}),t}function Bu(e){let t=Ru(e),n=zu(t),r=[],i=[];return n.forEach((a,o)=>{let s=t[a],c=n[o+1]??t.length,l=()=>{i.push({position:o,line:a+1,heading:s.text})},u=t.findIndex((e,t)=>t>a&&t<c&&Lu.test(e.text));if(u===-1){l();return}let d=t[u],f=Lu.exec(d.text)[1],p=t.findIndex((e,t)=>t>u&&t<c&&e.text.trimEnd()===f),m=t[p];if(!m){l();return}let h=Iu.exec(s.text)[1]??``,g=h.indexOf(` — `),_=e.slice(d.end+1,Math.max(d.end+1,m.start-1));r.push({wording:_,date:g===-1?h.trim():h.slice(0,g).trim(),reason:g===-1?``:h.slice(g+3).trim()})}),{entries:r,invalid:i}}function Vu(e){let t=Math.max(0,...(e.match(/^\s*`{3,}/gm)??[]).map(e=>e.trim().length));return"`".repeat(Math.max(3,t+1))}function Hu(e,t,n,r){if(Bu(e).entries[0]?.wording===t)return e;let i=Vu(t),a=`## Superseded ${n} — ${r}\n\n${i}markdown\n${t}\n${i}\n`,o=Ru(e),s=zu(o)[0];if(s!==void 0){let t=o[s].start;return`${e.slice(0,t)}${a}\n${e.slice(t)}`}let c=e.endsWith(`
|
|
206
|
+
`)||e===``?e:`${e}\n`;return`${c}${c?`
|
|
207
|
+
`:``}${a}`}function Uu(e,t){return e.length===t.length&&e.every((e,n)=>Nu(e.text,t[n].text))}function Wu(e,t){return t.length>=e.length&&Uu(e,t.slice(0,e.length))?`append`:`rewrite`}function Gu(e,t,n){let r=Pu(e,t).find(([t])=>t===e.length-1),i=[...t],a=r?r[1]+1:i.length;for(let e of n){let t=i.findIndex((t,n)=>n>=a&&Nu(t.text,e.text));t===-1?i.splice(a++,0,e):a=t+1}return i}function Ku(e,t,n){let r=Wu(e,n);if(r===`append`)return{revision:r,merged:Gu(e,t,n.slice(e.length)),collisions:[]};let i=new Map(Pu(e,t)),a=new Map(Pu(e,n)),o=[...i.keys()].filter(e=>a.has(e)).sort((e,t)=>e-t),s=[],c=[],l=0,u=0,d=0;for(let r of[...o,e.length]){let o=r,f=r===e.length?t.length:i.get(r),p=r===e.length?n.length:a.get(r),m={base:e.slice(l,o),found:t.slice(u,f),offered:n.slice(d,p)};Uu(m.found,m.base)?s.push(...m.offered):Uu(m.offered,m.base)||Uu(m.found,m.offered)?s.push(...m.found):(s.push(...m.found),c.push(m)),r<e.length&&s.push(t[f]),l=o+1,u=f+1,d=p+1}return{revision:r,merged:s,collisions:c}}const qu=/^(#{1,6})[ \t](.*)$/,Ju=/^\s*(`{3,}|~{3,})/;function Yu(e){let t=e.trimEnd().length;for(;t>0&&e[t-1]===`#`;)t--;return e.slice(0,t).trim()}function Xu(e){let t=e.split(/\r?\n/),n=[{level:0,title:``,body:[]}],r;for(let e of t){let t=Ju.exec(e);if(r)t&&t[1][0]===r[0]&&e.trim()===t[1]&&(r=void 0);else if(t)r=t[1];else{let t=qu.exec(e);if(t){n.push({heading:e.trim(),level:t[1].length,title:Yu(t[2]),body:[]});continue}}n[n.length-1]?.body.push(e)}let i=[],a=/* @__PURE__ */ new Map,o=[];for(let e of n){let t=Mu(e.body.join(`
|
|
208
|
+
`)),n=t[0];if(e.heading!==void 0&&n&&(n.gap=e.body[0]?.trim()===``?`
|
|
209
|
+
|
|
210
|
+
`:`
|
|
211
|
+
`),e.heading===void 0){if(!t.length)continue}else{for(;i.length&&i[i.length-1].level>=e.level;)i.pop();i.push({level:e.level,title:e.title})}let r=i.map(e=>e.title),s=r.join(` > `),c=(a.get(s)??0)+1;a.set(s,c),o.push({path:r,key:c===1?s:`${s} #${c}`,heading:e.heading,sentences:t,raw:[e.heading,...e.body].filter(e=>e!==void 0).join(`
|
|
212
|
+
`).trimEnd().replace(/^\n+/,``)})}return o}function Zu(e,t){let n=e??``;return t.forEach((t,r)=>{r>0?n+=t.gap||` `:e!==void 0&&(n+=t.gap===`
|
|
213
|
+
`?`
|
|
214
|
+
`:`
|
|
215
|
+
|
|
216
|
+
`),n+=t.text}),n}function Qu(e){let t=/* @__PURE__ */ new Map;return e.forEach((n,r)=>{for(let i of n){let n=t.get(i.key)??{key:i.key,parts:e.map(()=>void 0)};n.parts[r]=i,t.set(i.key,n)}}),[...t.values()]}var $u=class extends Error{code;constructor(e,t){super(t),this.code=e,this.name=`ProseUpdateError`}};const ed=[`conflict`,`undetermined`,`update`,`owners`,`up-to-date`],td=e=>e.replace(/\s+/g,` `).trim(),nd=(e,t)=>e.length===t.length&&e.every((e,n)=>Nu(e.text,t[n].text));function rd(e){let t=typeof e==`string`?Bu(e).entries.map(({wording:e,date:t})=>({wording:e,date:t})):e.map(e=>({wording:e,date:void 0})),n=/* @__PURE__ */ new Set;return t.map(({wording:e,date:t},n)=>({text:e,date:t,sentences:Mu(e),index:n})).filter(e=>{let t=e.sentences.map(e=>td(e.text)).join(`\0`);return!n.has(t)&&(n.add(t),!0)})}function id(e,t){let n=t.map(t=>({r:t,count:Fu(e,t.sentences)})),r=Math.max(0,...n.map(e=>e.count));if(r<1)return{};let i=n.filter(e=>e.count===r).map(e=>e.r);return i.length>1?{tied:i}:{base:i[0]}}function ad(e,t,n){return Zu(t??e?.heading,n)}function od(e){if(!Mu(e.offered).length)throw new $u(`empty-offered`,`The offered wording is empty.`);let t=Mu(e.found),n=Xu(e.found),r=Xu(e.offered),i=rd(e.history),a=(t,i={})=>{let a=Qu([n,r]);return{outcome:`undetermined`,reason:t,parts:(a.length?a:[{key:``,parts:[]}]).map(e=>({path:(e.parts[0]??e.parts[1])?.path??[],key:e.key,outcome:`undetermined`,reason:t,...i})),text:e.found}};if(!t.length)return a(`empty-section`);if(!i.length)return a(`no-history`);let{base:o,tied:s}=id(t,i);if(s)return a(`tied-base`,{tied:s.map(e=>e.index)});let c=o?Xu(o.text):[],l=new Set(i.flatMap(e=>e.sentences.map(e=>td(e.text)))),u=o&&{index:o.index,date:o.date},d=Qu([c,n,r]),f=/* @__PURE__ */ new Map,p=/* @__PURE__ */ new Map;for(let e of d){let[t,n,r]=e.parts,i={path:(n??r??t)?.path??[],key:e.key,outcome:`owners`};f.set(e.key,i);let a=(e,t,n,r)=>{i.outcome=e,u&&(i.base=u),i.shared=Fu(n,t),i.baseSentences=t.length,i.revision=Wu(t,r)};if(!n&&r)t?nd(t.sentences,r.sentences)?(i.outcome=`up-to-date`,i.text=``):(a(`conflict`,t.sentences,[],r.sentences),i.collisions=[{base:t.sentences,found:[],offered:r.sentences}]):(i.outcome=`update`,i.text=r.raw,p.set(e.key,r.raw));else if(n&&!r)t?nd(t.sentences,n.sentences)?(i.outcome=`update`,i.text=``,p.set(e.key,``)):(a(`conflict`,t.sentences,n.sentences,[]),i.collisions=[{base:t.sentences,found:n.sentences,offered:[]}]):i.text=n.raw;else if(n&&r){let s=n.sentences.some(e=>l.has(td(e.text))&&!r.sentences.some(t=>Nu(t.text,e.text))),c=Fu(n.sentences,r.sentences);if(!n.sentences.length)i.outcome=`undetermined`,i.reason=`empty-section`;else if(c===r.sentences.length&&!s)i.outcome=`up-to-date`,i.text=n.raw;else if(!o||!t?.sentences.length)c>0?(i.outcome=`undetermined`,i.reason=`no-base`):i.text=n.raw;else if(!Fu(n.sentences,t.sentences)&&c===0)i.text=n.raw;else{let o=Ku(t.sentences,n.sentences,r.sentences);a(o.collisions.length?`conflict`:`update`,t.sentences,n.sentences,r.sentences),i.text=ad(n,n.heading??r.heading,o.merged),p.set(e.key,i.text),o.collisions.length&&(i.collisions=o.collisions)}}}let m=ed.find(e=>[...f.values()].some(t=>t.outcome===e)),h=[...f.values()].some(e=>e.outcome===`update`||e.outcome===`conflict`),g=sd(n,r,f).map(e=>f.get(e)),_=h?cd(e.found,n,r,p,f):e.found,v=m===`undetermined`?g.find(e=>e.outcome===`undetermined`)?.reason:void 0;return{outcome:m,...v?{reason:v}:{},...u?{base:u}:{},parts:g,text:_}}function sd(e,t,n){let r=new Set(e.map(e=>e.key)),i=/* @__PURE__ */ new Map;t.forEach((e,n)=>{if(r.has(e.key))return;let a=t.slice(0,n).reverse().find(e=>r.has(e.key))?.key;i.set(a,[...i.get(a)??[],e.key])});let a=[...i.get(void 0)??[]];for(let t of e)a.push(t.key,...i.get(t.key)??[]);let o=[...n.keys()].filter(e=>!a.includes(e));return[...a,...o]}function cd(e,t,n,r,i){let a=new Map([...n,...t].map(e=>[e.key,e.raw]));return sd(t,n,i).filter(e=>i.get(e).outcome!==`up-to-date`||t.some(t=>t.key===e)).map(e=>r.get(e)??(t.some(t=>t.key===e)?a.get(e):void 0)).filter(e=>e!==void 0&&e!==``).join(`
|
|
217
|
+
|
|
218
|
+
`)+(e.endsWith(`
|
|
219
|
+
`)?`
|
|
220
|
+
`:``)}const ld=e=>({description:`${e}, as text.`,type:P.string().optional()}),ud=e=>({description:`${e}, read from this file.`,type:P.string().optional()});function dd(e){throw process.stderr.write(`error: usage: ${e}\n`),j.reported(A.usage)}function fd(e,t,n){return t===void 0==(n===void 0)&&dd(`pass exactly one of --${e} and --${e}-from.`),t??o(y(n),`utf8`)}function pd(){return M({name:`classify`,description:`Compare found prose with an offered wording and the retired wordings: the outcome for each part and the merged text, with no judgment involved.`,options:{offered:ld(`The wording offered now`),"offered-from":ud(`The wording offered now`),found:ld(`The text found in the file being updated`),"found-from":ud(`The text found in the file being updated`),history:ld(`A history text of retired wordings, newest first`),"history-from":ud(`A history text of retired wordings, newest first`),retired:{description:`A retired wording, as text. Repeat for several, newest first. Used when no history text is given.`,type:P.array(P.string()).optional()},"retired-from":{description:`A file holding a retired wording. Repeat for several, newest first.`,type:P.array(P.string()).optional()}},async run(e){let t=fd(`offered`,e.offered,e[`offered-from`]),n=fd(`found`,e.found,e[`found-from`]),r=[...e.retired??[],...(e[`retired-from`]??[]).map(e=>o(y(e),`utf8`))],i=e.history!==void 0||e[`history-from`]!==void 0;i&&r.length&&dd(`pass a history text or retired wordings, not both.`);let a=i?fd(`history`,e.history,e[`history-from`]):r;if(typeof a==`string`){let{invalid:e}=Bu(a);for(let t of e)process.stderr.write(`warning: history entry ${t.position+1} (line ${t.line}) did not parse: ${t.heading}\n`)}try{let e=od({found:n,offered:t,history:a});return R({outcome:e.outcome,...e.reason?{reason:e.reason}:{},...e.base?{base:e.base}:{},parts:e.parts.map(e=>({path:e.path.join(` > `),outcome:e.outcome,...e.reason?{reason:e.reason}:{},...e.tied?{tied:e.tied}:{},...e.base?{base:e.base}:{},...e.shared===void 0?{}:{shared:e.shared,baseSentences:e.baseSentences},...e.revision?{revision:e.revision}:{},...e.text===void 0?{}:{text:e.text},...e.collisions?{collisions:e.collisions.map(e=>({base:e.base.map(e=>e.text),found:e.found.map(e=>e.text),offered:e.offered.map(e=>e.text)}))}:{}})),text:e.text})}catch(e){throw e instanceof $u?(process.stderr.write(`error: ${e.code}: ${e.message}\n`),j.reported(A.error)):e}}})}function md(){return M({name:`retire`,description:`Print the history text with the outgoing wording added as its newest entry. Writes no file: the caller saves the answer.`,options:{history:ld(`The history text`),"history-from":ud(`The history text`),wording:ld(`The outgoing wording`),"wording-from":ud(`The outgoing wording`),date:{description:`The date of the entry, written as given.`,type:P.string()},reason:{description:`Why the wording was replaced.`,type:P.string()}},async run(e){return z(Hu(fd(`history`,e.history,e[`history-from`]),fd(`wording`,e.wording,e[`wording-from`]),e.date,e.reason))}})}function hd(){return M({name:`prose-update`,description:`Bring prose a tool wrote earlier to its offered wording without losing the owner’s edits: classify found prose, and extend the history of retired wordings.`,commands:[pd(),md()]})}function gd(e){return JSON.parse(o(e,`utf8`))}function _d(){let e=new URL(`../package.json`,import.meta.url),{name:n}=gd(new URL(`../plugin.json`,import.meta.url)),{version:r}=gd(e);return{name:n,version:r,root:m(t(e))}}function vd({name:e,version:t,root:n},r){return Oi({format:r,name:`cyber-agentkit`,version:t,description:`Work with the AI agent harness running here: read its layered reference documents, and update prose a tool wrote earlier.`}).command($l({plugin:{name:e,root:n}})).command(Cu({plugin:{name:e,root:n}})).command(hd())}function yd(e){let t=e.slice(2);if(t.some(e=>e===`--format`||e.startsWith(`--format=`)))return`toon`;let n=t[0]===`reference`||t[0]===`asset`||t[0]===`prose-update`?t[1]:void 0;return[`show`,`load`,`create`,`update`,`select`,`delete`,`retire`].includes(n??``)?`text`:`toon`}async function bd(e,t=_d()){try{let n=await vd(t,yd(e)).parse(e);return typeof n==`number`?n:A.success}catch(e){return process.stderr.write(`error: ${e instanceof Error?e.message:`Invalid command.`}\n`),A.usage}}process.exitCode=await bd([...process.argv.slice(0,2),`prose-update`,...process.argv.slice(2)],{name:k,version:ee,root:t(new URL(`../../..`,import.meta.url))});export{};
|