@coryrylan/cradle 1.4.0 → 1.4.1
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/CHANGELOG.md +6 -0
- package/README.md +1 -1
- package/dist/commands/schedule.d.ts +8 -1
- package/dist/index.js +46 -46
- package/package.json +3 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
## [1.4.1](https://github.com/coryrylan/cradle/compare/cradle-v1.4.0...cradle-v1.4.1) (2026-09-23)
|
|
2
|
+
|
|
3
|
+
### Bug Fixes
|
|
4
|
+
|
|
5
|
+
* **cli:** update timer status reporting and improve schedule command documentation ([53a46cb](https://github.com/coryrylan/cradle/commit/53a46cba64ccef8a7439e1aee5b93ed045a3d4d6))
|
|
6
|
+
|
|
1
7
|
## [1.4.0](https://github.com/coryrylan/cradle/compare/cradle-v1.3.1...cradle-v1.4.0) (2026-08-31)
|
|
2
8
|
|
|
3
9
|
### Features
|
package/README.md
CHANGED
|
@@ -74,7 +74,7 @@ cradle run . --sandbox-backend sbx # run under the sbx Docker Sandboxes microVM
|
|
|
74
74
|
cradle run . --no-sandbox # run pi directly (debug)
|
|
75
75
|
cradle run . --dry-run -- --resume # print the write plan + command; forward `--resume` to pi
|
|
76
76
|
|
|
77
|
-
cradle schedule list ./my-agent # scheduled tasks, cron, next fire
|
|
77
|
+
cradle schedule list ./my-agent # scheduled tasks, cron, next fire, timer status
|
|
78
78
|
cradle schedule list my-agent # a name from ~/.cradle/settings.json works here too
|
|
79
79
|
cradle schedule install ./my-agent # write + load a native OS timer per task
|
|
80
80
|
cradle schedule run ./my-agent daily-report # fire one task now, in the foreground
|
|
@@ -24,6 +24,13 @@ interface ScheduleDeps {
|
|
|
24
24
|
readonly user?: string;
|
|
25
25
|
readonly now?: () => Date;
|
|
26
26
|
}
|
|
27
|
+
/**
|
|
28
|
+
* How the timer on disk relates to what this schedule file would compile to
|
|
29
|
+
* now. `stale` is the state that matters: the files exist, so the schedule
|
|
30
|
+
* looks live, but they were emitted from an older version of the `.md` and
|
|
31
|
+
* the OS is still firing the old cron.
|
|
32
|
+
*/
|
|
33
|
+
export type TimerStatus = 'installed' | 'stale' | 'not-installed';
|
|
27
34
|
/** One `cradle schedule list` row — a broken cron is reported inline rather than aborting the whole listing. */
|
|
28
35
|
export interface ScheduleRow {
|
|
29
36
|
readonly slug: string;
|
|
@@ -32,7 +39,7 @@ export interface ScheduleRow {
|
|
|
32
39
|
readonly cwd: string;
|
|
33
40
|
readonly cronError?: string;
|
|
34
41
|
readonly nextFire: Date | null;
|
|
35
|
-
readonly
|
|
42
|
+
readonly status: TimerStatus;
|
|
36
43
|
}
|
|
37
44
|
/** One resolved schedule's composed timer, for `install`/`remove`/`run`. */
|
|
38
45
|
interface ScheduleTarget {
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
2
|
// @bun
|
|
3
|
-
var
|
|
4
|
-
`).map((r)=>r.split("\t")),
|
|
5
|
-
`)}rowToString(e,
|
|
3
|
+
var Oo=Object.create;var{getPrototypeOf:$o,defineProperty:lr,getOwnPropertyNames:vo}=Object;var cr=Object.prototype.hasOwnProperty;function jo(e){return this[e]}var ko,Mo,No=(e,t,n)=>{var r=e!=null&&typeof e==="object";if(r){var i=t?ko??=new WeakMap:Mo??=new WeakMap,s=i.get(e);if(s)return s}n=e!=null?Oo($o(e)):{};let o=t||!e||!e.__esModule||!cr.call(e,"default")?lr(n,"default",{value:e,enumerable:!0}):n;if(e&&typeof e==="object"||typeof e==="function"){for(let u of vo(e))if(!cr.call(o,u))lr(o,u,{get:jo.bind(e,u),enumerable:!0})}if(r)i.set(e,o);return o};var Ro=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports);var ti=Ro(function(jh,ei){ei.exports=function(t){if(t===void 0)t=2;if(t>=Error.stackTraceLimit)throw TypeError("getCallerFile(position) requires position be less then Error.stackTraceLimit but position was: `"+t+"` and Error.stackTraceLimit was: `"+Error.stackTraceLimit+"`");var n=Error.prepareStackTrace;Error.prepareStackTrace=function(i,s){return s};var r=Error().stack;if(Error.prepareStackTrace=n,r!==null&&typeof r==="object")return r[t]?r[t].getFileName():void 0}});import{join as Po}from"path";import{notStrictEqual as Ma,strictEqual as Na}from"assert";var Io={right:Wo,center:Ho};class fr{constructor(e){var t;this.width=e.width,this.wrap=(t=e.wrap)!==null&&t!==void 0?t:!0,this.rows=[]}span(...e){let t=this.div(...e);t.span=!0}resetOutput(){this.rows=[]}div(...e){if(e.length===0)this.div("");if(this.wrap&&this.shouldApplyLayoutDSL(...e)&&typeof e[0]==="string")return this.applyLayoutDSL(e[0]);let t=e.map((n)=>{if(typeof n==="string")return this.colFromString(n);return n});return this.rows.push(t),t}shouldApplyLayoutDSL(...e){return e.length===1&&typeof e[0]==="string"&&/[\t\n]/.test(e[0])}applyLayoutDSL(e){let t=e.split(`
|
|
4
|
+
`).map((r)=>r.split("\t")),n=0;return t.forEach((r)=>{if(r.length>1&&ge.stringWidth(r[0])>n)n=Math.min(Math.floor(this.width*0.5),ge.stringWidth(r[0]))}),t.forEach((r)=>{this.div(...r.map((i,s)=>({text:i.trim(),padding:this.measurePadding(i),width:s===0&&r.length>1?n:void 0})))}),this.rows[this.rows.length-1]}colFromString(e){return{text:e,padding:this.measurePadding(e)}}measurePadding(e){let t=ge.stripAnsi(e);return[0,t.match(/\s*$/)[0].length,0,t.match(/^\s*/)[0].length]}toString(){let e=[];return this.rows.forEach((t)=>{this.rowToString(t,e)}),e.filter((t)=>!t.hidden).map((t)=>t.text).join(`
|
|
5
|
+
`)}rowToString(e,t){return this.rasterize(e).forEach((n,r)=>{let i="";n.forEach((s,o)=>{let{width:u}=e[o],c=this.negatePadding(e[o]),p=s;if(c>ge.stringWidth(s))p+=" ".repeat(c-ge.stringWidth(s));if(e[o].align&&e[o].align!=="left"&&this.wrap){let g=Io[e[o].align];if(p=g(p,c),ge.stringWidth(p)<c)p+=" ".repeat((u||0)-ge.stringWidth(p)-1)}let b=e[o].padding||[0,0,0,0];if(b[3])i+=" ".repeat(b[3]);if(i+=dr(e[o],p,"| "),i+=p,i+=dr(e[o],p," |"),b[1])i+=" ".repeat(b[1]);if(r===0&&t.length>0)i=this.renderInline(i,t[t.length-1])}),t.push({text:i.replace(/ +$/,""),span:e.span})}),t}renderInline(e,t){let n=e.match(/^ */),r=n?n[0].length:0,i=t.text,s=ge.stringWidth(i.trimRight());if(!t.span)return e;if(!this.wrap)return t.hidden=!0,i+e;if(r<s)return e;return t.hidden=!0,i.trimRight()+" ".repeat(r-s)+e.trimLeft()}rasterize(e){let t=[],n=this.columnWidths(e),r;return e.forEach((i,s)=>{if(i.width=n[s],this.wrap)r=ge.wrap(i.text,this.negatePadding(i),{hard:!0}).split(`
|
|
6
6
|
`);else r=i.text.split(`
|
|
7
|
-
`);if(i.border)r.unshift("."+"-".repeat(this.negatePadding(i)+2)+"."),r.push("'"+"-".repeat(this.negatePadding(i)+2)+"'");if(i.padding)r.unshift(...Array(i.padding[0]||0).fill("")),r.push(...Array(i.padding[2]||0).fill(""));r.forEach((o,u)=>{if(!n[u])n.push([]);let c=n[u];for(let p=0;p<s;p++)if(c[p]===void 0)c.push("");c.push(o)})}),n}negatePadding(e){let n=e.width||0;if(e.padding)n-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)n-=4;return n}columnWidths(e){if(!this.wrap)return e.map((s)=>s.width||ge.stringWidth(s.text));let n=e.length,t=this.width,r=e.map((s)=>{if(s.width)return n--,t-=s.width,s.width;return}),i=n?Math.floor(t/n):0;return r.map((s,o)=>{if(s===void 0)return Math.max(i,Io(e[o]));return s})}}function lr(e,n,t){if(e.border){if(/[.']-+[.']/.test(n))return"";if(n.trim().length!==0)return t;return" "}return""}function Io(e){let n=e.padding||[],t=1+(n[3]||0)+(n[1]||0);if(e.border)return t+4;return t}function To(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Lo(e,n){e=e.trim();let t=ge.stringWidth(e);if(t<n)return" ".repeat(n-t)+e;return e}function Wo(e,n){e=e.trim();let t=ge.stringWidth(e);if(t>=n)return e;return" ".repeat(n-t>>1)+e}var ge;function dr(e,n){return ge=n,new cr({width:(e===null||e===void 0?void 0:e.width)||To(),wrap:e===null||e===void 0?void 0:e.wrap})}function pt({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var Ho=pt();function je(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("\x9B"))return e;return e.replace(Ho,"")}var fr=161,hr=1114109,Dr=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],gr=12288,pr=65510,mr=[12288,12288,65281,65376,65504,65510];var Fr=4352,yr=262141,mt=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Nn=(e,n)=>{let t=0,r=Math.floor(e.length/2)-1;while(t<=r){let i=Math.floor((t+r)/2),s=i*2;if(n<e[s])r=i-1;else if(n>e[s+1])t=i+1;else return!0}return!1};var br=19968,[Vo,zo]=Go(mt);function Go(e){let n=e[0],t=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],s=e[r+1];if(br>=i&&br<=s)return[i,s];if(s-i>t-n)n=i,t=s}return[n,t]}var Er=(e)=>{if(e<fr||e>hr)return!1;return Nn(Dr,e)},Cr=(e)=>{if(e<gr||e>pr)return!1;return Nn(mr,e)};var wr=(e)=>{if(e>=Vo&&e<=zo)return!0;if(e<Fr||e>yr)return!1;return Nn(mt,e)};function Uo(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ye(e,{ambiguousAsWide:n=!1}={}){if(Uo(e),Cr(e)||wr(e)||n&&Er(e))return 2;return 1}var xr=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;var Yo=new Intl.Segmenter,Jo=/^\p{Default_Ignorable_Code_Point}$/u;function ke(e,n={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:r=!1}=n;if(!r)e=je(e);if(e.length===0)return 0;let i=0,s={ambiguousAsWide:!t};for(let{segment:o}of Yo.segment(e)){let u=o.codePointAt(0);if(u<=31||u>=127&&u<=159)continue;if(u>=8203&&u<=8207||u===65279)continue;if(u>=768&&u<=879||u>=6832&&u<=6911||u>=7616&&u<=7679||u>=8400&&u<=8447||u>=65056&&u<=65071)continue;if(u>=55296&&u<=57343)continue;if(u>=65024&&u<=65039)continue;if(Jo.test(o))continue;if(xr().test(o)){i+=2;continue}i+=Ye(u,s)}return i}var Sr=(e=0)=>(n)=>`\x1B[${n+e}m`,Ar=(e=0)=>(n)=>`\x1B[${38+e};5;${n}m`,Pr=(e=0)=>(n,t,r)=>`\x1B[${38+e};2;${n};${t};${r}m`,K={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Lf=Object.keys(K.modifier),Ko=Object.keys(K.color),qo=Object.keys(K.bgColor),Wf=[...Ko,...qo];function Xo(){let e=new Map;for(let[n,t]of Object.entries(K)){for(let[r,i]of Object.entries(t))K[r]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},t[r]=K[r],e.set(i[0],i[1]);Object.defineProperty(K,n,{value:t,enumerable:!1})}return Object.defineProperty(K,"codes",{value:e,enumerable:!1}),K.color.close="\x1B[39m",K.bgColor.close="\x1B[49m",K.color.ansi=Sr(),K.color.ansi256=Ar(),K.color.ansi16m=Pr(),K.bgColor.ansi=Sr(10),K.bgColor.ansi256=Ar(10),K.bgColor.ansi16m=Pr(10),Object.defineProperties(K,{rgbToAnsi256:{value(n,t,r){if(n===t&&t===r){if(n<8)return 16;if(n>248)return 231;return Math.round((n-8)/247*24)+232}return 16+36*Math.round(n/255*5)+6*Math.round(t/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(n){let t=/[a-f\d]{6}|[a-f\d]{3}/i.exec(n.toString(16));if(!t)return[0,0,0];let[r]=t;if(r.length===3)r=[...r].map((s)=>s+s).join("");let i=Number.parseInt(r,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:(n)=>K.rgbToAnsi256(...K.hexToRgb(n)),enumerable:!1},ansi256ToAnsi:{value(n){if(n<8)return 30+n;if(n<16)return 90+(n-8);let t,r,i;if(n>=232)t=((n-232)*10+8)/255,r=t,i=t;else{n-=16;let u=n%36;t=Math.floor(n/36)/5,r=Math.floor(u/6)/5,i=u%6/5}let s=Math.max(t,r,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(r)<<1|Math.round(t));if(s===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(n,t,r)=>K.ansi256ToAnsi(K.rgbToAnsi256(n,t,r)),enumerable:!1},hexToAnsi:{value:(n)=>K.ansi256ToAnsi(K.hexToAnsi256(n)),enumerable:!1}}),K}var Zo=Xo(),_r=Zo;var In=new Set(["\x1B","\x9B"]),Qo=39,yt="\x07",$r="[",ea="]",vr="m",Rn=`${ea}8;;`,Br=(e)=>`${In.values().next().value}${$r}${e}${vr}`,Or=(e)=>`${In.values().next().value}${Rn}${e}${yt}`,na=(e)=>e.split(" ").map((n)=>ke(n)),Ft=(e,n,t)=>{let r=[...n],i=!1,s=!1,o=ke(je(e.at(-1)));for(let[u,c]of r.entries()){let p=ke(c);if(o+p<=t)e[e.length-1]+=c;else e.push(c),o=0;if(In.has(c))i=!0,s=r.slice(u+1,u+1+Rn.length).join("")===Rn;if(i){if(s){if(c===yt)i=!1,s=!1}else if(c===vr)i=!1;continue}if(o+=p,o===t&&u<r.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},ta=(e)=>{let n=e.split(" "),t=n.length;while(t>0){if(ke(n[t-1])>0)break;t--}if(t===n.length)return e;return n.slice(0,t).join(" ")+n.slice(t).join("")},ra=(e,n,t={})=>{if(t.trim!==!1&&e.trim()==="")return"";let r="",i,s,o=na(e),u=[""];for(let[g,D]of e.split(" ").entries()){if(t.trim!==!1)u[u.length-1]=u.at(-1).trimStart();let F=ke(u.at(-1));if(g!==0){if(F>=n&&(t.wordWrap===!1||t.trim===!1))u.push(""),F=0;if(F>0||t.trim===!1)u[u.length-1]+=" ",F++}if(t.hard&&o[g]>n){let y=n-F,h=1+Math.floor((o[g]-y-1)/n);if(Math.floor((o[g]-1)/n)<h)u.push("");Ft(u,D,n);continue}if(F+o[g]>n&&F>0&&o[g]>0){if(t.wordWrap===!1&&F<n){Ft(u,D,n);continue}u.push("")}if(F+o[g]>n&&t.wordWrap===!1){Ft(u,D,n);continue}u[u.length-1]+=D}if(t.trim!==!1)u=u.map((g)=>ta(g));let c=u.join(`
|
|
8
|
-
`),p=[...c],b=0;for(let[g,D]of p.entries()){if(r+=D,
|
|
9
|
-
`){if(s)r+=
|
|
10
|
-
`){if(i&&F)r
|
|
7
|
+
`);if(i.border)r.unshift("."+"-".repeat(this.negatePadding(i)+2)+"."),r.push("'"+"-".repeat(this.negatePadding(i)+2)+"'");if(i.padding)r.unshift(...Array(i.padding[0]||0).fill("")),r.push(...Array(i.padding[2]||0).fill(""));r.forEach((o,u)=>{if(!t[u])t.push([]);let c=t[u];for(let p=0;p<s;p++)if(c[p]===void 0)c.push("");c.push(o)})}),t}negatePadding(e){let t=e.width||0;if(e.padding)t-=(e.padding[3]||0)+(e.padding[1]||0);if(e.border)t-=4;return t}columnWidths(e){if(!this.wrap)return e.map((s)=>s.width||ge.stringWidth(s.text));let t=e.length,n=this.width,r=e.map((s)=>{if(s.width)return t--,n-=s.width,s.width;return}),i=t?Math.floor(n/t):0;return r.map((s,o)=>{if(s===void 0)return Math.max(i,To(e[o]));return s})}}function dr(e,t,n){if(e.border){if(/[.']-+[.']/.test(t))return"";if(t.trim().length!==0)return n;return" "}return""}function To(e){let t=e.padding||[],n=1+(t[3]||0)+(t[1]||0);if(e.border)return n+4;return n}function Lo(){if(typeof process==="object"&&process.stdout&&process.stdout.columns)return process.stdout.columns;return 80}function Wo(e,t){e=e.trim();let n=ge.stringWidth(e);if(n<t)return" ".repeat(t-n)+e;return e}function Ho(e,t){e=e.trim();let n=ge.stringWidth(e);if(n>=t)return e;return" ".repeat(t-n>>1)+e}var ge;function hr(e,t){return ge=t,new fr({width:(e===null||e===void 0?void 0:e.width)||Lo(),wrap:e===null||e===void 0?void 0:e.wrap})}function mn({onlyFirst:e=!1}={}){return new RegExp("(?:\\u001B\\][\\s\\S]*?(?:\\u0007|\\u001B\\u005C|\\u009C))|[\\u001B\\u009B][[\\]()#;?]*(?:\\d{1,4}(?:[;:]\\d{0,4})*)?[\\dA-PR-TZcf-nq-uy=><~]",e?void 0:"g")}var Vo=mn();function je(e){if(typeof e!=="string")throw TypeError(`Expected a \`string\`, got \`${typeof e}\``);if(!e.includes("\x1B")&&!e.includes("\x9B"))return e;return e.replace(Vo,"")}var Dr=161,gr=1114109,pr=[161,161,164,164,167,168,170,170,173,174,176,180,182,186,188,191,198,198,208,208,215,216,222,225,230,230,232,234,236,237,240,240,242,243,247,250,252,252,254,254,257,257,273,273,275,275,283,283,294,295,299,299,305,307,312,312,319,322,324,324,328,331,333,333,338,339,358,359,363,363,462,462,464,464,466,466,468,468,470,470,472,472,474,474,476,476,593,593,609,609,708,708,711,711,713,715,717,717,720,720,728,731,733,733,735,735,768,879,913,929,931,937,945,961,963,969,1025,1025,1040,1103,1105,1105,8208,8208,8211,8214,8216,8217,8220,8221,8224,8226,8228,8231,8240,8240,8242,8243,8245,8245,8251,8251,8254,8254,8308,8308,8319,8319,8321,8324,8364,8364,8451,8451,8453,8453,8457,8457,8467,8467,8470,8470,8481,8482,8486,8486,8491,8491,8531,8532,8539,8542,8544,8555,8560,8569,8585,8585,8592,8601,8632,8633,8658,8658,8660,8660,8679,8679,8704,8704,8706,8707,8711,8712,8715,8715,8719,8719,8721,8721,8725,8725,8730,8730,8733,8736,8739,8739,8741,8741,8743,8748,8750,8750,8756,8759,8764,8765,8776,8776,8780,8780,8786,8786,8800,8801,8804,8807,8810,8811,8814,8815,8834,8835,8838,8839,8853,8853,8857,8857,8869,8869,8895,8895,8978,8978,9312,9449,9451,9547,9552,9587,9600,9615,9618,9621,9632,9633,9635,9641,9650,9651,9654,9655,9660,9661,9664,9665,9670,9672,9675,9675,9678,9681,9698,9701,9711,9711,9733,9734,9737,9737,9742,9743,9756,9756,9758,9758,9792,9792,9794,9794,9824,9825,9827,9829,9831,9834,9836,9837,9839,9839,9886,9887,9919,9919,9926,9933,9935,9939,9941,9953,9955,9955,9960,9961,9963,9969,9972,9972,9974,9977,9979,9980,9982,9983,10045,10045,10102,10111,11094,11097,12872,12879,57344,63743,65024,65039,65533,65533,127232,127242,127248,127277,127280,127337,127344,127373,127375,127376,127387,127404,917760,917999,983040,1048573,1048576,1114109],mr=12288,Fr=65510,yr=[12288,12288,65281,65376,65504,65510];var br=4352,Er=262141,Fn=[4352,4447,8986,8987,9001,9002,9193,9196,9200,9200,9203,9203,9725,9726,9748,9749,9776,9783,9800,9811,9855,9855,9866,9871,9875,9875,9889,9889,9898,9899,9917,9918,9924,9925,9934,9934,9940,9940,9962,9962,9970,9971,9973,9973,9978,9978,9981,9981,9989,9989,9994,9995,10024,10024,10060,10060,10062,10062,10067,10069,10071,10071,10133,10135,10160,10160,10175,10175,11035,11036,11088,11088,11093,11093,11904,11929,11931,12019,12032,12245,12272,12287,12289,12350,12353,12438,12441,12543,12549,12591,12593,12686,12688,12773,12783,12830,12832,12871,12880,42124,42128,42182,43360,43388,44032,55203,63744,64255,65040,65049,65072,65106,65108,65126,65128,65131,94176,94180,94192,94198,94208,101589,101631,101662,101760,101874,110576,110579,110581,110587,110589,110590,110592,110882,110898,110898,110928,110930,110933,110933,110948,110951,110960,111355,119552,119638,119648,119670,126980,126980,127183,127183,127374,127374,127377,127386,127488,127490,127504,127547,127552,127560,127568,127569,127584,127589,127744,127776,127789,127797,127799,127868,127870,127891,127904,127946,127951,127955,127968,127984,127988,127988,127992,128062,128064,128064,128066,128252,128255,128317,128331,128334,128336,128359,128378,128378,128405,128406,128420,128420,128507,128591,128640,128709,128716,128716,128720,128722,128725,128728,128732,128735,128747,128748,128756,128764,128992,129003,129008,129008,129292,129338,129340,129349,129351,129535,129648,129660,129664,129674,129678,129734,129736,129736,129741,129756,129759,129770,129775,129784,131072,196605,196608,262141];var Nt=(e,t)=>{let n=0,r=Math.floor(e.length/2)-1;while(n<=r){let i=Math.floor((n+r)/2),s=i*2;if(t<e[s])r=i-1;else if(t>e[s+1])n=i+1;else return!0}return!1};var Cr=19968,[zo,Go]=Uo(Fn);function Uo(e){let t=e[0],n=e[1];for(let r=0;r<e.length;r+=2){let i=e[r],s=e[r+1];if(Cr>=i&&Cr<=s)return[i,s];if(s-i>n-t)t=i,n=s}return[t,n]}var wr=(e)=>{if(e<Dr||e>gr)return!1;return Nt(pr,e)},xr=(e)=>{if(e<mr||e>Fr)return!1;return Nt(yr,e)};var Sr=(e)=>{if(e>=zo&&e<=Go)return!0;if(e<br||e>Er)return!1;return Nt(Fn,e)};function Yo(e){if(!Number.isSafeInteger(e))throw TypeError(`Expected a code point, got \`${typeof e}\`.`)}function Ye(e,{ambiguousAsWide:t=!1}={}){if(Yo(e),xr(e)||Sr(e)||t&&wr(e))return 2;return 1}var Ar=()=>/[#*0-9]\uFE0F?\u20E3|[\xA9\xAE\u203C\u2049\u2122\u2139\u2194-\u2199\u21A9\u21AA\u231A\u231B\u2328\u23CF\u23ED-\u23EF\u23F1\u23F2\u23F8-\u23FA\u24C2\u25AA\u25AB\u25B6\u25C0\u25FB\u25FC\u25FE\u2600-\u2604\u260E\u2611\u2614\u2615\u2618\u2620\u2622\u2623\u2626\u262A\u262E\u262F\u2638-\u263A\u2640\u2642\u2648-\u2653\u265F\u2660\u2663\u2665\u2666\u2668\u267B\u267E\u267F\u2692\u2694-\u2697\u2699\u269B\u269C\u26A0\u26A7\u26AA\u26B0\u26B1\u26BD\u26BE\u26C4\u26C8\u26CF\u26D1\u26E9\u26F0-\u26F5\u26F7\u26F8\u26FA\u2702\u2708\u2709\u270F\u2712\u2714\u2716\u271D\u2721\u2733\u2734\u2744\u2747\u2757\u2763\u27A1\u2934\u2935\u2B05-\u2B07\u2B1B\u2B1C\u2B55\u3030\u303D\u3297\u3299]\uFE0F?|[\u261D\u270C\u270D](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\u270A\u270B](?:\uD83C[\uDFFB-\uDFFF])?|[\u23E9-\u23EC\u23F0\u23F3\u25FD\u2693\u26A1\u26AB\u26C5\u26CE\u26D4\u26EA\u26FD\u2705\u2728\u274C\u274E\u2753-\u2755\u2795-\u2797\u27B0\u27BF\u2B50]|\u26D3\uFE0F?(?:\u200D\uD83D\uDCA5)?|\u26F9(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\u2764\uFE0F?(?:\u200D(?:\uD83D\uDD25|\uD83E\uDE79))?|\uD83C(?:[\uDC04\uDD70\uDD71\uDD7E\uDD7F\uDE02\uDE37\uDF21\uDF24-\uDF2C\uDF36\uDF7D\uDF96\uDF97\uDF99-\uDF9B\uDF9E\uDF9F\uDFCD\uDFCE\uDFD4-\uDFDF\uDFF5\uDFF7]\uFE0F?|[\uDF85\uDFC2\uDFC7](?:\uD83C[\uDFFB-\uDFFF])?|[\uDFC4\uDFCA](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDFCB\uDFCC](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDCCF\uDD8E\uDD91-\uDD9A\uDE01\uDE1A\uDE2F\uDE32-\uDE36\uDE38-\uDE3A\uDE50\uDE51\uDF00-\uDF20\uDF2D-\uDF35\uDF37-\uDF43\uDF45-\uDF4A\uDF4C-\uDF7C\uDF7E-\uDF84\uDF86-\uDF93\uDFA0-\uDFC1\uDFC5\uDFC6\uDFC8\uDFC9\uDFCF-\uDFD3\uDFE0-\uDFF0\uDFF8-\uDFFF]|\uDDE6\uD83C[\uDDE8-\uDDEC\uDDEE\uDDF1\uDDF2\uDDF4\uDDF6-\uDDFA\uDDFC\uDDFD\uDDFF]|\uDDE7\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEF\uDDF1-\uDDF4\uDDF6-\uDDF9\uDDFB\uDDFC\uDDFE\uDDFF]|\uDDE8\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDEE\uDDF0-\uDDF7\uDDFA-\uDDFF]|\uDDE9\uD83C[\uDDEA\uDDEC\uDDEF\uDDF0\uDDF2\uDDF4\uDDFF]|\uDDEA\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDED\uDDF7-\uDDFA]|\uDDEB\uD83C[\uDDEE-\uDDF0\uDDF2\uDDF4\uDDF7]|\uDDEC\uD83C[\uDDE6\uDDE7\uDDE9-\uDDEE\uDDF1-\uDDF3\uDDF5-\uDDFA\uDDFC\uDDFE]|\uDDED\uD83C[\uDDF0\uDDF2\uDDF3\uDDF7\uDDF9\uDDFA]|\uDDEE\uD83C[\uDDE8-\uDDEA\uDDF1-\uDDF4\uDDF6-\uDDF9]|\uDDEF\uD83C[\uDDEA\uDDF2\uDDF4\uDDF5]|\uDDF0\uD83C[\uDDEA\uDDEC-\uDDEE\uDDF2\uDDF3\uDDF5\uDDF7\uDDFC\uDDFE\uDDFF]|\uDDF1\uD83C[\uDDE6-\uDDE8\uDDEE\uDDF0\uDDF7-\uDDFB\uDDFE]|\uDDF2\uD83C[\uDDE6\uDDE8-\uDDED\uDDF0-\uDDFF]|\uDDF3\uD83C[\uDDE6\uDDE8\uDDEA-\uDDEC\uDDEE\uDDF1\uDDF4\uDDF5\uDDF7\uDDFA\uDDFF]|\uDDF4\uD83C\uDDF2|\uDDF5\uD83C[\uDDE6\uDDEA-\uDDED\uDDF0-\uDDF3\uDDF7-\uDDF9\uDDFC\uDDFE]|\uDDF6\uD83C\uDDE6|\uDDF7\uD83C[\uDDEA\uDDF4\uDDF8\uDDFA\uDDFC]|\uDDF8\uD83C[\uDDE6-\uDDEA\uDDEC-\uDDF4\uDDF7-\uDDF9\uDDFB\uDDFD-\uDDFF]|\uDDF9\uD83C[\uDDE6\uDDE8\uDDE9\uDDEB-\uDDED\uDDEF-\uDDF4\uDDF7\uDDF9\uDDFB\uDDFC\uDDFF]|\uDDFA\uD83C[\uDDE6\uDDEC\uDDF2\uDDF3\uDDF8\uDDFE\uDDFF]|\uDDFB\uD83C[\uDDE6\uDDE8\uDDEA\uDDEC\uDDEE\uDDF3\uDDFA]|\uDDFC\uD83C[\uDDEB\uDDF8]|\uDDFD\uD83C\uDDF0|\uDDFE\uD83C[\uDDEA\uDDF9]|\uDDFF\uD83C[\uDDE6\uDDF2\uDDFC]|\uDF44(?:\u200D\uD83D\uDFEB)?|\uDF4B(?:\u200D\uD83D\uDFE9)?|\uDFC3(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDFF3\uFE0F?(?:\u200D(?:\u26A7\uFE0F?|\uD83C\uDF08))?|\uDFF4(?:\u200D\u2620\uFE0F?|\uDB40\uDC67\uDB40\uDC62\uDB40(?:\uDC65\uDB40\uDC6E\uDB40\uDC67|\uDC73\uDB40\uDC63\uDB40\uDC74|\uDC77\uDB40\uDC6C\uDB40\uDC73)\uDB40\uDC7F)?)|\uD83D(?:[\uDC3F\uDCFD\uDD49\uDD4A\uDD6F\uDD70\uDD73\uDD76-\uDD79\uDD87\uDD8A-\uDD8D\uDDA5\uDDA8\uDDB1\uDDB2\uDDBC\uDDC2-\uDDC4\uDDD1-\uDDD3\uDDDC-\uDDDE\uDDE1\uDDE3\uDDE8\uDDEF\uDDF3\uDDFA\uDECB\uDECD-\uDECF\uDEE0-\uDEE5\uDEE9\uDEF0\uDEF3]\uFE0F?|[\uDC42\uDC43\uDC46-\uDC50\uDC66\uDC67\uDC6B-\uDC6D\uDC72\uDC74-\uDC76\uDC78\uDC7C\uDC83\uDC85\uDC8F\uDC91\uDCAA\uDD7A\uDD95\uDD96\uDE4C\uDE4F\uDEC0\uDECC](?:\uD83C[\uDFFB-\uDFFF])?|[\uDC6E-\uDC71\uDC73\uDC77\uDC81\uDC82\uDC86\uDC87\uDE45-\uDE47\uDE4B\uDE4D\uDE4E\uDEA3\uDEB4\uDEB5](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD74\uDD90](?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?|[\uDC00-\uDC07\uDC09-\uDC14\uDC16-\uDC25\uDC27-\uDC3A\uDC3C-\uDC3E\uDC40\uDC44\uDC45\uDC51-\uDC65\uDC6A\uDC79-\uDC7B\uDC7D-\uDC80\uDC84\uDC88-\uDC8E\uDC90\uDC92-\uDCA9\uDCAB-\uDCFC\uDCFF-\uDD3D\uDD4B-\uDD4E\uDD50-\uDD67\uDDA4\uDDFB-\uDE2D\uDE2F-\uDE34\uDE37-\uDE41\uDE43\uDE44\uDE48-\uDE4A\uDE80-\uDEA2\uDEA4-\uDEB3\uDEB7-\uDEBF\uDEC1-\uDEC5\uDED0-\uDED2\uDED5-\uDED8\uDEDC-\uDEDF\uDEEB\uDEEC\uDEF4-\uDEFC\uDFE0-\uDFEB\uDFF0]|\uDC08(?:\u200D\u2B1B)?|\uDC15(?:\u200D\uD83E\uDDBA)?|\uDC26(?:\u200D(?:\u2B1B|\uD83D\uDD25))?|\uDC3B(?:\u200D\u2744\uFE0F?)?|\uDC41\uFE0F?(?:\u200D\uD83D\uDDE8\uFE0F?)?|\uDC68(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDC68\uDC69]\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?)|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFC-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFD-\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFD\uDFFF]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?\uDC68\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDD1D\uDEEF]\u200D\uD83D\uDC68\uD83C[\uDFFB-\uDFFE]|[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3])))?))?|\uDC69(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:\uDC8B\u200D\uD83D)?[\uDC68\uDC69]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?|\uDC69\u200D\uD83D(?:\uDC66(?:\u200D\uD83D\uDC66)?|\uDC67(?:\u200D\uD83D[\uDC66\uDC67])?))|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFC-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFD-\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFD\uDFFF]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D\uD83D(?:[\uDC68\uDC69]|\uDC8B\u200D\uD83D[\uDC68\uDC69])\uD83C[\uDFFB-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3]|\uDD1D\u200D\uD83D[\uDC68\uDC69]\uD83C[\uDFFB-\uDFFE]|\uDEEF\u200D\uD83D\uDC69\uD83C[\uDFFB-\uDFFE])))?))?|\uDD75(?:\uD83C[\uDFFB-\uDFFF]|\uFE0F)?(?:\u200D[\u2640\u2642]\uFE0F?)?|\uDE2E(?:\u200D\uD83D\uDCA8)?|\uDE35(?:\u200D\uD83D\uDCAB)?|\uDE36(?:\u200D\uD83C\uDF2B\uFE0F?)?|\uDE42(?:\u200D[\u2194\u2195]\uFE0F?)?|\uDEB6(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?)|\uD83E(?:[\uDD0C\uDD0F\uDD18-\uDD1F\uDD30-\uDD34\uDD36\uDD77\uDDB5\uDDB6\uDDBB\uDDD2\uDDD3\uDDD5\uDEC3-\uDEC5\uDEF0\uDEF2-\uDEF8](?:\uD83C[\uDFFB-\uDFFF])?|[\uDD26\uDD35\uDD37-\uDD39\uDD3C-\uDD3E\uDDB8\uDDB9\uDDCD\uDDCF\uDDD4\uDDD6-\uDDDD](?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDDDE\uDDDF](?:\u200D[\u2640\u2642]\uFE0F?)?|[\uDD0D\uDD0E\uDD10-\uDD17\uDD20-\uDD25\uDD27-\uDD2F\uDD3A\uDD3F-\uDD45\uDD47-\uDD76\uDD78-\uDDB4\uDDB7\uDDBA\uDDBC-\uDDCC\uDDD0\uDDE0-\uDDFF\uDE70-\uDE7C\uDE80-\uDE8A\uDE8E-\uDEC2\uDEC6\uDEC8\uDECD-\uDEDC\uDEDF-\uDEEA\uDEEF]|\uDDCE(?:\uD83C[\uDFFB-\uDFFF])?(?:\u200D(?:[\u2640\u2642]\uFE0F?(?:\u200D\u27A1\uFE0F?)?|\u27A1\uFE0F?))?|\uDDD1(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1|\uDDD1\u200D\uD83E\uDDD2(?:\u200D\uD83E\uDDD2)?|\uDDD2(?:\u200D\uD83E\uDDD2)?))|\uD83C(?:\uDFFB(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFC-\uDFFF])))?|\uDFFC(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFD-\uDFFF])))?|\uDFFD(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])))?|\uDFFE(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFD\uDFFF])))?|\uDFFF(?:\u200D(?:[\u2695\u2696\u2708]\uFE0F?|\u2764\uFE0F?\u200D(?:\uD83D\uDC8B\u200D)?\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE]|\uD83C[\uDF3E\uDF73\uDF7C\uDF84\uDF93\uDFA4\uDFA8\uDFEB\uDFED]|\uD83D(?:[\uDCBB\uDCBC\uDD27\uDD2C\uDE80\uDE92]|\uDC30\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])|\uD83E(?:[\uDDAF\uDDBC\uDDBD](?:\u200D\u27A1\uFE0F?)?|[\uDDB0-\uDDB3\uDE70]|\uDD1D\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFF]|\uDEEF\u200D\uD83E\uDDD1\uD83C[\uDFFB-\uDFFE])))?))?|\uDEF1(?:\uD83C(?:\uDFFB(?:\u200D\uD83E\uDEF2\uD83C[\uDFFC-\uDFFF])?|\uDFFC(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFD-\uDFFF])?|\uDFFD(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB\uDFFC\uDFFE\uDFFF])?|\uDFFE(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFD\uDFFF])?|\uDFFF(?:\u200D\uD83E\uDEF2\uD83C[\uDFFB-\uDFFE])?))?)/g;var Jo=new Intl.Segmenter,Ko=/^\p{Default_Ignorable_Code_Point}$/u;function ke(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t;if(!r)e=je(e);if(e.length===0)return 0;let i=0,s={ambiguousAsWide:!n};for(let{segment:o}of Jo.segment(e)){let u=o.codePointAt(0);if(u<=31||u>=127&&u<=159)continue;if(u>=8203&&u<=8207||u===65279)continue;if(u>=768&&u<=879||u>=6832&&u<=6911||u>=7616&&u<=7679||u>=8400&&u<=8447||u>=65056&&u<=65071)continue;if(u>=55296&&u<=57343)continue;if(u>=65024&&u<=65039)continue;if(Ko.test(o))continue;if(Ar().test(o)){i+=2;continue}i+=Ye(u,s)}return i}var Pr=(e=0)=>(t)=>`\x1B[${t+e}m`,_r=(e=0)=>(t)=>`\x1B[${38+e};5;${t}m`,Br=(e=0)=>(t,n,r)=>`\x1B[${38+e};2;${t};${n};${r}m`,K={modifier:{reset:[0,0],bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],overline:[53,55],inverse:[7,27],hidden:[8,28],strikethrough:[9,29]},color:{black:[30,39],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],white:[37,39],blackBright:[90,39],gray:[90,39],grey:[90,39],redBright:[91,39],greenBright:[92,39],yellowBright:[93,39],blueBright:[94,39],magentaBright:[95,39],cyanBright:[96,39],whiteBright:[97,39]},bgColor:{bgBlack:[40,49],bgRed:[41,49],bgGreen:[42,49],bgYellow:[43,49],bgBlue:[44,49],bgMagenta:[45,49],bgCyan:[46,49],bgWhite:[47,49],bgBlackBright:[100,49],bgGray:[100,49],bgGrey:[100,49],bgRedBright:[101,49],bgGreenBright:[102,49],bgYellowBright:[103,49],bgBlueBright:[104,49],bgMagentaBright:[105,49],bgCyanBright:[106,49],bgWhiteBright:[107,49]}},Uf=Object.keys(K.modifier),qo=Object.keys(K.color),Xo=Object.keys(K.bgColor),Yf=[...qo,...Xo];function Zo(){let e=new Map;for(let[t,n]of Object.entries(K)){for(let[r,i]of Object.entries(n))K[r]={open:`\x1B[${i[0]}m`,close:`\x1B[${i[1]}m`},n[r]=K[r],e.set(i[0],i[1]);Object.defineProperty(K,t,{value:n,enumerable:!1})}return Object.defineProperty(K,"codes",{value:e,enumerable:!1}),K.color.close="\x1B[39m",K.bgColor.close="\x1B[49m",K.color.ansi=Pr(),K.color.ansi256=_r(),K.color.ansi16m=Br(),K.bgColor.ansi=Pr(10),K.bgColor.ansi256=_r(10),K.bgColor.ansi16m=Br(10),Object.defineProperties(K,{rgbToAnsi256:{value(t,n,r){if(t===n&&n===r){if(t<8)return 16;if(t>248)return 231;return Math.round((t-8)/247*24)+232}return 16+36*Math.round(t/255*5)+6*Math.round(n/255*5)+Math.round(r/255*5)},enumerable:!1},hexToRgb:{value(t){let n=/[a-f\d]{6}|[a-f\d]{3}/i.exec(t.toString(16));if(!n)return[0,0,0];let[r]=n;if(r.length===3)r=[...r].map((s)=>s+s).join("");let i=Number.parseInt(r,16);return[i>>16&255,i>>8&255,i&255]},enumerable:!1},hexToAnsi256:{value:(t)=>K.rgbToAnsi256(...K.hexToRgb(t)),enumerable:!1},ansi256ToAnsi:{value(t){if(t<8)return 30+t;if(t<16)return 90+(t-8);let n,r,i;if(t>=232)n=((t-232)*10+8)/255,r=n,i=n;else{t-=16;let u=t%36;n=Math.floor(t/36)/5,r=Math.floor(u/6)/5,i=u%6/5}let s=Math.max(n,r,i)*2;if(s===0)return 30;let o=30+(Math.round(i)<<2|Math.round(r)<<1|Math.round(n));if(s===2)o+=60;return o},enumerable:!1},rgbToAnsi:{value:(t,n,r)=>K.ansi256ToAnsi(K.rgbToAnsi256(t,n,r)),enumerable:!1},hexToAnsi:{value:(t)=>K.ansi256ToAnsi(K.hexToAnsi256(t)),enumerable:!1}}),K}var Qo=Zo(),Or=Qo;var It=new Set(["\x1B","\x9B"]),ea=39,bn="\x07",jr="[",ta="]",kr="m",Rt=`${ta}8;;`,$r=(e)=>`${It.values().next().value}${jr}${e}${kr}`,vr=(e)=>`${It.values().next().value}${Rt}${e}${bn}`,na=(e)=>e.split(" ").map((t)=>ke(t)),yn=(e,t,n)=>{let r=[...t],i=!1,s=!1,o=ke(je(e.at(-1)));for(let[u,c]of r.entries()){let p=ke(c);if(o+p<=n)e[e.length-1]+=c;else e.push(c),o=0;if(It.has(c))i=!0,s=r.slice(u+1,u+1+Rt.length).join("")===Rt;if(i){if(s){if(c===bn)i=!1,s=!1}else if(c===kr)i=!1;continue}if(o+=p,o===n&&u<r.length-1)e.push(""),o=0}if(!o&&e.at(-1).length>0&&e.length>1)e[e.length-2]+=e.pop()},ra=(e)=>{let t=e.split(" "),n=t.length;while(n>0){if(ke(t[n-1])>0)break;n--}if(n===t.length)return e;return t.slice(0,n).join(" ")+t.slice(n).join("")},ia=(e,t,n={})=>{if(n.trim!==!1&&e.trim()==="")return"";let r="",i,s,o=na(e),u=[""];for(let[g,D]of e.split(" ").entries()){if(n.trim!==!1)u[u.length-1]=u.at(-1).trimStart();let F=ke(u.at(-1));if(g!==0){if(F>=t&&(n.wordWrap===!1||n.trim===!1))u.push(""),F=0;if(F>0||n.trim===!1)u[u.length-1]+=" ",F++}if(n.hard&&o[g]>t){let y=t-F,h=1+Math.floor((o[g]-y-1)/t);if(Math.floor((o[g]-1)/t)<h)u.push("");yn(u,D,t);continue}if(F+o[g]>t&&F>0&&o[g]>0){if(n.wordWrap===!1&&F<t){yn(u,D,t);continue}u.push("")}if(F+o[g]>t&&n.wordWrap===!1){yn(u,D,t);continue}u[u.length-1]+=D}if(n.trim!==!1)u=u.map((g)=>ra(g));let c=u.join(`
|
|
8
|
+
`),p=[...c],b=0;for(let[g,D]of p.entries()){if(r+=D,It.has(D)){let{groups:y}=new RegExp(`(?:\\${jr}(?<code>\\d+)m|\\${Rt}(?<uri>.*)${bn})`).exec(c.slice(b))||{groups:{}};if(y.code!==void 0){let h=Number.parseFloat(y.code);i=h===ea?void 0:h}else if(y.uri!==void 0)s=y.uri.length===0?void 0:y.uri}let F=Or.codes.get(Number(i));if(p[g+1]===`
|
|
9
|
+
`){if(s)r+=vr("");if(i&&F)r+=$r(F)}else if(D===`
|
|
10
|
+
`){if(i&&F)r+=$r(i);if(s)r+=vr(s)}b+=D.length}return r};function En(e,t,n){return String(e).normalize().replaceAll(`\r
|
|
11
11
|
`,`
|
|
12
12
|
`).split(`
|
|
13
|
-
`).map((r)=>
|
|
14
|
-
`)}function Et(e){return dr(e,{stringWidth:ke,stripAnsi:je,wrap:bt})}import{dirname as jr,resolve as kr}from"path";import{readdirSync as ia,statSync as sa}from"fs";function Ct(e,n){let t=kr(".",e),r;if(!sa(t).isDirectory())t=jr(t);while(!0){if(r=n(t,ia(t)),r)return kr(t,r);if(t=jr(r=t),r===t)break}}import{inspect as Na}from"util";import{fileURLToPath as ni}from"url";import{format as ua}from"util";import{normalize as la,resolve as ca}from"path";function Je(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let t="",r=!1,i=e.match(/^-+/);for(let s=i?i[0].length:0;s<e.length;s++){let o=e.charAt(s);if(r)r=!1,o=o.toUpperCase();if(s!==0&&(o==="-"||o==="_"))r=!0;else if(o!=="-"&&o!=="_")t+=o}return t}}function Tn(e,n){let t=e.toLowerCase();n=n||"-";let r="";for(let i=0;i<e.length;i++){let s=t.charAt(i),o=e.charAt(i);if(s!==o&&i>0)r+=`${n}${t.charAt(i)}`;else r+=o}return r}function Ln(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function Mr(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let n=0,t=null,r=null,i=null,s=[];for(let o=0;o<e.length;o++){if(t=r,r=e.charAt(o),r===" "&&!i){if(t!==" ")n++;continue}if(r===i)i=null;else if((r==="'"||r==='"')&&!i)i=r;if(!s[n])s[n]="";s[n]+=r}return s}var ye;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(ye||(ye={}));var Me;class xt{constructor(e){Me=e}parse(e,n){let t=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},n),r=Mr(e),i=typeof e==="string",s=oa(Object.assign(Object.create(null),t.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},t.configuration),u=Object.assign(Object.create(null),t.default),c=t.configObjects||[],p=t.envPrefix,b=o["populate--"],g=b?"--":"_",D=Object.create(null),F=Object.create(null),y=t.__||Me.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},v=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,W=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(t.array||[]).filter(Boolean).forEach(function(l){let f=typeof l==="object"?l.key:l,E=Object.keys(l).map(function(m){return{boolean:"bools",string:"strings",number:"numbers"}[m]}).filter(Boolean).pop();if(E)h[E][f]=!0;h.arrays[f]=!0,h.keys.push(f)}),[].concat(t.boolean||[]).filter(Boolean).forEach(function(l){h.bools[l]=!0,h.keys.push(l)}),[].concat(t.string||[]).filter(Boolean).forEach(function(l){h.strings[l]=!0,h.keys.push(l)}),[].concat(t.number||[]).filter(Boolean).forEach(function(l){h.numbers[l]=!0,h.keys.push(l)}),[].concat(t.count||[]).filter(Boolean).forEach(function(l){h.counts[l]=!0,h.keys.push(l)}),[].concat(t.normalize||[]).filter(Boolean).forEach(function(l){h.normalize[l]=!0,h.keys.push(l)}),typeof t.narg==="object")Object.entries(t.narg).forEach(([l,f])=>{if(typeof f==="number")h.nargs[l]=f,h.keys.push(l)});if(typeof t.coerce==="object")Object.entries(t.coerce).forEach(([l,f])=>{if(typeof f==="function")h.coercions[l]=f,h.keys.push(l)});if(typeof t.config<"u"){if(Array.isArray(t.config)||typeof t.config==="string")[].concat(t.config).filter(Boolean).forEach(function(l){h.configs[l]=!0});else if(typeof t.config==="object")Object.entries(t.config).forEach(([l,f])=>{if(typeof f==="boolean"||typeof f==="function")h.configs[l]=f})}xn(t.key,s,t.default,h.arrays),Object.keys(u).forEach(function(l){(h.aliases[l]||[]).forEach(function(f){u[f]=u[l]})});let T=null;gt();let ce=[],I=Object.assign(Object.create(null),{_:[]}),Y={};for(let l=0;l<r.length;l++){let f=r[l],E=f.replace(/^-{3,}/,"---"),m,d,A,w,O,oe;if(f!=="--"&&/^-/.test(f)&&G(f))te(f);else if(E.match(/^---+(=|$)/)){te(f);continue}else if(f.match(/^--.+=/)||!o["short-option-groups"]&&f.match(/^-.+=/)){if(w=f.match(/^--?([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3)if(j(w[1],h.arrays))l=Pe(l,w[1],r,w[2]);else if(j(w[1],h.nargs)!==!1)l=X(l,w[1],r,w[2]);else z(w[1],w[2],!0)}else if(f.match(W)&&o["boolean-negation"]){if(w=f.match(W),w!==null&&Array.isArray(w)&&w.length>=2)d=w[1],z(d,j(d,h.arrays)?[!1]:!1)}else if(f.match(/^--.+/)||!o["short-option-groups"]&&f.match(/^-[^-]+/)){if(w=f.match(/^--?(.+)/),w!==null&&Array.isArray(w)&&w.length>=2)if(d=w[1],j(d,h.arrays))l=Pe(l,d,r);else if(j(d,h.nargs)!==!1)l=X(l,d,r);else if(O=r[l+1],O!==void 0&&(!O.match(/^-/)||O.match(v))&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else if(/^(true|false)$/.test(O))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-.\..+=/)){if(w=f.match(/^-([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3)z(w[1],w[2])}else if(f.match(/^-.\..+/)&&!f.match(v)){if(O=r[l+1],w=f.match(/^-(.\..+)/),w!==null&&Array.isArray(w)&&w.length>=2)if(d=w[1],O!==void 0&&!O.match(/^-/)&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-[^-]+/)&&!f.match(v)){A=f.slice(1,-1).split(""),m=!1;for(let fe=0;fe<A.length;fe++){if(O=f.slice(fe+2),A[fe+1]&&A[fe+1]==="="){if(oe=f.slice(fe+3),d=A[fe],j(d,h.arrays))l=Pe(l,d,r,oe);else if(j(d,h.nargs)!==!1)l=X(l,d,r,oe);else z(d,oe);m=!0;break}if(O==="-"){z(A[fe],O);continue}if(/[A-Za-z]/.test(A[fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)&&j(O,h.bools)===!1){z(A[fe],O),m=!0;break}if(A[fe+1]&&A[fe+1].match(/\W/)){z(A[fe],O),m=!0;break}else z(A[fe],L(A[fe]))}if(d=f.slice(-1)[0],!m&&d!=="-")if(j(d,h.arrays))l=Pe(l,d,r);else if(j(d,h.nargs)!==!1)l=X(l,d,r);else if(O=r[l+1],O!==void 0&&(!/^(-|--)[^-]/.test(O)||O.match(v))&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else if(/^(true|false)$/.test(O))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-[0-9]$/)&&f.match(v)&&j(f.slice(1),h.bools))d=f.slice(1),z(d,L(d));else if(f==="--"){ce=r.slice(l+1);break}else if(o["halt-at-non-option"]){ce=r.slice(l);break}else te(f)}if(ne(I,!0),ne(I,!1),_(I),V(),Ne(I,h.aliases,u,!0),H(I),o["set-placeholder-key"])re(I);if(Object.keys(h.counts).forEach(function(l){if(!U(I,l.split(".")))z(l,0)}),b&&ce.length)I[g]=[];if(ce.forEach(function(l){I[g].push(l)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(I).filter((l)=>l!=="--"&&l.includes("-")).forEach((l)=>{delete I[l]});if(o["strip-aliased"])[].concat(...Object.keys(s).map((l)=>s[l])).forEach((l)=>{if(o["camel-case-expansion"]&&l.includes("-"))delete I[l.split(".").map((f)=>Je(f)).join(".")];delete I[l]});function te(l){let f=C("_",l);if(typeof f==="string"||typeof f==="number")I._.push(f)}function X(l,f,E,m){let d,A=j(f,h.nargs);if(A=typeof A!=="number"||isNaN(A)?1:A,A===0){if(!se(m))T=Error(y("Argument unexpected for: %s",f));return z(f,L(f)),l}let w=se(m)?0:1;if(o["nargs-eats-options"]){if(E.length-(l+1)+w<A)T=Error(y("Not enough arguments following: %s",f));w=A}else{for(d=l+1;d<E.length;d++)if(!E[d].match(/^-[^0-9]/)||E[d].match(v)||G(E[d]))w++;else break;if(w<A)T=Error(y("Not enough arguments following: %s",f))}let O=Math.min(w,A);if(!se(m)&&O>0)z(f,m),O--;for(d=l+1;d<O+l+1;d++)z(f,E[d]);return l+O}function Pe(l,f,E,m){let d=[],A=m||E[l+1],w=j(f,h.nargs);if(j(f,h.bools)&&!/^(true|false)$/.test(A))d.push(!0);else if(se(A)||se(m)&&/^-/.test(A)&&!v.test(A)&&!G(A)){if(u[f]!==void 0){let O=u[f];d=Array.isArray(O)?O:[O]}}else{if(!se(m))d.push(P(f,m,!0));for(let O=l+1;O<E.length;O++){if(!o["greedy-arrays"]&&d.length>0||w&&typeof w==="number"&&d.length>=w)break;if(A=E[O],/^-/.test(A)&&!v.test(A)&&!G(A))break;l=O,d.push(P(f,A,i))}}if(typeof w==="number"&&(w&&d.length<w||isNaN(w)&&d.length===0))T=Error(y("Not enough arguments following: %s",f));return z(f,d),l}function z(l,f,E=i){if(/-/.test(l)&&o["camel-case-expansion"]){let A=l.split(".").map(function(w){return Je(w)}).join(".");wn(l,A)}let m=P(l,f,E),d=l.split(".");if(ve(I,d,m),h.aliases[l])h.aliases[l].forEach(function(A){let w=A.split(".");ve(I,w,m)});if(d.length>1&&o["dot-notation"])(h.aliases[d[0]]||[]).forEach(function(A){let w=A.split("."),O=[].concat(d);if(O.shift(),w=w.concat(O),!(h.aliases[l]||[]).includes(w.join(".")))ve(I,w,m)});if(j(l,h.normalize)&&!j(l,h.arrays))[l].concat(h.aliases[l]||[]).forEach(function(w){Object.defineProperty(Y,w,{enumerable:!0,get(){return f},set(O){f=typeof O==="string"?Me.normalize(O):O}})})}function wn(l,f){if(!(h.aliases[l]&&h.aliases[l].length))h.aliases[l]=[f],D[f]=!0;if(!(h.aliases[f]&&h.aliases[f].length))wn(f,l)}function P(l,f,E){if(E)f=aa(f);if(j(l,h.bools)||j(l,h.counts)){if(typeof f==="string")f=f==="true"}let m=Array.isArray(f)?f.map(function(d){return C(l,d)}):C(l,f);if(j(l,h.counts)&&(se(m)||typeof m==="boolean"))m=wt();if(j(l,h.normalize)&&j(l,h.arrays))if(Array.isArray(f))m=f.map((d)=>Me.normalize(d));else m=Me.normalize(f);return m}function C(l,f){if(!o["parse-positional-numbers"]&&l==="_")return f;if(!j(l,h.strings)&&!j(l,h.bools)&&!Array.isArray(f)){if(Ln(f)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${f}`)))||!se(f)&&j(l,h.numbers))f=Number(f)}return f}function _(l){let f=Object.create(null);Ne(f,h.aliases,u),Object.keys(h.configs).forEach(function(E){let m=l[E]||f[E];if(m)try{let d=null,A=Me.resolve(Me.cwd(),m),w=h.configs[E];if(typeof w==="function"){try{d=w(A)}catch(O){d=O}if(d instanceof Error){T=d;return}}else d=Me.require(A);N(d)}catch(d){if(d.name==="PermissionDenied")T=d;else if(l[E])T=Error(y("Invalid JSON config file: %s",m))}})}function N(l,f){Object.keys(l).forEach(function(E){let m=l[E],d=f?f+"."+E:E;if(typeof m==="object"&&m!==null&&!Array.isArray(m)&&o["dot-notation"])N(m,d);else if(!U(I,d.split("."))||j(d,h.arrays)&&o["combine-arrays"])z(d,m)})}function V(){if(typeof c<"u")c.forEach(function(l){N(l)})}function ne(l,f){if(typeof p>"u")return;let E=typeof p==="string"?p:"",m=Me.env();Object.keys(m).forEach(function(d){if(E===""||d.lastIndexOf(E,0)===0){let A=d.split("__").map(function(w,O){if(O===0)w=w.substring(E.length);return Je(w)});if((f&&h.configs[A.join(".")]||!f)&&!U(l,A))z(A.join("."),m[d])}})}function H(l){let f,E=new Set;Object.keys(l).forEach(function(m){if(!E.has(m)){if(f=j(m,h.coercions),typeof f==="function")try{let d=C(m,f(l[m]));[].concat(h.aliases[m]||[],m).forEach((A)=>{E.add(A),l[A]=d})}catch(d){T=d}}})}function re(l){return h.keys.forEach((f)=>{if(~f.indexOf("."))return;if(typeof l[f]>"u")l[f]=void 0}),l}function Ne(l,f,E,m=!1){Object.keys(E).forEach(function(d){if(!U(l,d.split("."))){if(ve(l,d.split("."),E[d]),m)F[d]=!0;(f[d]||[]).forEach(function(A){if(U(l,A.split(".")))return;ve(l,A.split("."),E[d])})}})}function U(l,f){let E=l;if(!o["dot-notation"])f=[f.join(".")];f.slice(0,-1).forEach(function(d){E=E[d]||{}});let m=f[f.length-1];if(typeof E!=="object")return!1;else return m in E}function ve(l,f,E){let m=l;if(!o["dot-notation"])f=[f.join(".")];f.slice(0,-1).forEach(function(oe){if(oe=Nr(oe),typeof m==="object"&&m[oe]===void 0)m[oe]={};if(typeof m[oe]!=="object"||Array.isArray(m[oe])){if(Array.isArray(m[oe]))m[oe].push({});else m[oe]=[m[oe],{}];m=m[oe][m[oe].length-1]}else m=m[oe]});let d=Nr(f[f.length-1]),A=j(f.join("."),h.arrays),w=Array.isArray(E),O=o["duplicate-arguments-array"];if(!O&&j(d,h.nargs)){if(O=!0,!se(m[d])&&h.nargs[d]===1||Array.isArray(m[d])&&m[d].length===h.nargs[d])m[d]=void 0}if(E===wt())m[d]=wt(m[d]);else if(Array.isArray(m[d]))if(O&&A&&w)m[d]=o["flatten-duplicate-arrays"]?m[d].concat(E):(Array.isArray(m[d][0])?m[d]:[m[d]]).concat([E]);else if(!O&&Boolean(A)===Boolean(w))m[d]=E;else m[d]=m[d].concat([E]);else if(m[d]===void 0&&A)m[d]=w?E:[E];else if(O&&!(m[d]===void 0||j(d,h.counts)||j(d,h.bools)))m[d]=[m[d],E];else m[d]=E}function xn(...l){l.forEach(function(f){Object.keys(f||{}).forEach(function(E){if(h.aliases[E])return;h.aliases[E]=[].concat(s[E]||[]),h.aliases[E].concat(E).forEach(function(m){if(/-/.test(m)&&o["camel-case-expansion"]){let d=Je(m);if(d!==E&&h.aliases[E].indexOf(d)===-1)h.aliases[E].push(d),D[d]=!0}}),h.aliases[E].concat(E).forEach(function(m){if(m.length>1&&/[A-Z]/.test(m)&&o["camel-case-expansion"]){let d=Tn(m,"-");if(d!==E&&h.aliases[E].indexOf(d)===-1)h.aliases[E].push(d),D[d]=!0}}),h.aliases[E].forEach(function(m){h.aliases[m]=[E].concat(h.aliases[E].filter(function(d){return m!==d}))})})})}function j(l,f){let E=[].concat(h.aliases[l]||[],l),m=Object.keys(f),d=E.find((A)=>m.includes(A));return d?f[d]:!1}function fn(l){let f=Object.keys(h);return[].concat(f.map((m)=>h[m])).some(function(m){return Array.isArray(m)?m.includes(l):m[l]})}function ar(l,...f){return[].concat(...f).some(function(m){let d=l.match(m);return d&&fn(d[1])})}function k(l){if(l.match(v)||!l.match(/^-[^-]+/))return!1;let f=!0,E,m=l.slice(1).split("");for(let d=0;d<m.length;d++){if(E=l.slice(d+2),!fn(m[d])){f=!1;break}if(m[d+1]&&m[d+1]==="="||E==="-"||/[A-Za-z]/.test(m[d])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(E)||m[d+1]&&m[d+1].match(/\W/))break}return f}function G(l){return o["unknown-options-as-args"]&&ie(l)}function ie(l){if(l=l.replace(/^-{3,}/,"--"),l.match(v))return!1;if(k(l))return!1;return!ar(l,/^-+([^=]+?)=[\s\S]*$/,W,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function L(l){if(!j(l,h.bools)&&!j(l,h.counts)&&`${l}`in u)return u[l];else return ue(Z(l))}function ue(l){return{[ye.BOOLEAN]:!0,[ye.STRING]:"",[ye.NUMBER]:void 0,[ye.ARRAY]:[]}[l]}function Z(l){let f=ye.BOOLEAN;if(j(l,h.strings))f=ye.STRING;else if(j(l,h.numbers))f=ye.NUMBER;else if(j(l,h.bools))f=ye.BOOLEAN;else if(j(l,h.arrays))f=ye.ARRAY;return f}function se(l){return l===void 0}function gt(){Object.keys(h.counts).find((l)=>{if(j(l,h.arrays))return T=Error(y("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0;else if(j(l,h.nargs))return T=Error(y("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0;return!1})}return{aliases:Object.assign({},h.aliases),argv:Object.assign(Y,I),configuration:o,defaulted:Object.assign({},F),error:T,newAliases:Object.assign({},D)}}}function oa(e){let n=[],t=Object.create(null),r=!0;Object.keys(e).forEach(function(i){n.push([].concat(e[i],i))});while(r){r=!1;for(let i=0;i<n.length;i++)for(let s=i+1;s<n.length;s++)if(n[i].filter(function(u){return n[s].indexOf(u)!==-1}).length){n[i]=n[i].concat(n[s]),n.splice(s,1),r=!0;break}}return n.forEach(function(i){i=i.filter(function(o,u,c){return c.indexOf(o)===u});let s=i.pop();if(s!==void 0&&typeof s==="string")t[s]=i}),t}function wt(e){return e!==void 0?e+1:1}function Nr(e){if(e==="__proto__")return"___proto___";return e}function aa(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as da}from"fs";import{createRequire as Rr}from"module";var St,At,Pt,Ir=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Tr=(At=(St=process===null||process===void 0?void 0:process.versions)===null||St===void 0?void 0:St.node)!==null&&At!==void 0?At:(Pt=process===null||process===void 0?void 0:process.version)===null||Pt===void 0?void 0:Pt.slice(1);if(Tr){if(Number(Tr.match(/^([^.]+)/)[1])<Ir)throw Error(`yargs parser supports a minimum Node.js version of ${Ir}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var fa=process?process.env:{},Lr=Rr?Rr(import.meta.url):void 0,Wr=new xt({cwd:process.cwd,env:()=>fa,format:ua,normalize:la,resolve:ca,require:(e)=>{if(typeof Lr<"u")return Lr(e);else if(e.match(/\.json$/))return JSON.parse(da(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),Sn=function(n,t){return Wr.parse(n.slice(),t).argv};Sn.detailed=function(e,n){return Wr.parse(e.slice(),n)};Sn.camelCase=Je;Sn.decamelize=Tn;Sn.looksLikeNumber=Ln;var Hr=Sn;import{basename as Ra,dirname as Ia,extname as Ta,relative as La,resolve as ei,join as Wa}from"path";function ha(){if(Da())return 0;return 1}function Da(){return ga()&&!process.defaultApp}function ga(){return!!process.versions.electron}function Vr(){return process.argv[ha()]}var pa=new Intl.Segmenter,zr=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,ma=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,Fa=/\p{Spacing_Mark}/v,ya=/^\p{RGI_Emoji}$/v,ba=/^[\d#*]\u20E3$/,Ea=/\p{Extended_Pictographic}/gu;function Ca(e){if(e.length>50)return!1;if(ba.test(e))return!0;if(e.includes("\u200D")){let n=e.match(Ea);return n!==null&&n.length>=2}return!1}function wa(e){return e.replace(ma,"")}function xa(e){return zr.test(e)}function Gr(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Ur(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Yr(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Sa(e){return Gr(e)||Ur(e)||Yr(e)}function Aa(e,n){let t=[];for(let i of e){if(zr.test(i))continue;t.push(i.codePointAt(0))}if(t.length===0)return;let r=0;for(let i=0;i<t.length;i++){let s=t[i];if(!Sa(s)){if(r===0)return;for(let o=i;o<t.length;o++)r+=Ye(t[o],n);return r}if(Gr(s)&&Ur(t[i+1])){r+=2,i+=Yr(t[i+2])?2:1;continue}r+=Ye(s,n)}return r}function Pa(e,n){let t=0,r=!0;for(let i of e){if(r){r=!1;continue}if(Fa.test(i)||i>="\uFF00"&&i<="\uFFEF")t+=Ye(i.codePointAt(0),n)}return t}function _t(e,n={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:t=!0,countAnsiEscapeCodes:r=!1}=n,i=e;if(!r&&(i.includes("\x1B")||i.includes("\x9B")))i=je(i);if(i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let s=0,o={ambiguousAsWide:!t};for(let{segment:u}of pa.segment(i)){if(xa(u))continue;if(ya.test(u)||Ca(u)){s+=2;continue}let c=wa(u),p=Aa(c,o);if(p!==void 0){s+=p;continue}let b=c.codePointAt(0);s+=Ye(b,o),s+=Pa(c,o)}return s}import{readFileSync as _a,statSync as Ba,writeFile as Oa}from"fs";import{format as $a}from"util";import{resolve as va}from"path";var Jr={fs:{readFileSync:_a,writeFile:Oa},format:$a,resolve:va,exists:(e)=>{try{return Ba(e).isFile()}catch(n){return!1}}};var xe;class Kr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let n=e.shift(),t=function(){};if(typeof e[e.length-1]==="function")t=e.pop();if(t=t||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][n]&&this.updateFiles)this.cache[this.locale][n]=n,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:t});else t();return xe.format.apply(xe.format,[this.cache[this.locale][n]||n].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),n=e.shift(),t=e.shift(),r=e.shift(),i=function(){};if(typeof e[e.length-1]==="function")i=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let s=r===1?n:t;if(this.cache[this.locale][n])s=this.cache[this.locale][n][r===1?"one":"other"];if(!this.cache[this.locale][n]&&this.updateFiles)this.cache[this.locale][n]={one:n,other:t},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i});else i();let o=[s];if(~s.indexOf("%d"))o.push(r);return xe.format.apply(xe.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let n in e)if(Object.prototype.hasOwnProperty.call(e,n))this.cache[this.locale][n]=e[n]}_taggedLiteral(e,...n){let t="";return e.forEach(function(r,i){let s=n[i+1];if(t+=r,typeof s<"u")t+="%s"}),this.__.apply(this,[t].concat([].slice.call(n,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,n=this.writeQueue[0],t=n.directory,r=n.locale,i=n.cb,s=this._resolveLocaleFile(t,r),o=JSON.stringify(this.cache[r],null,2);xe.fs.writeFile(s,o,"utf-8",function(u){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();i(u)})}_readLocaleFile(){let e={},n=this._resolveLocaleFile(this.directory,this.locale);try{if(xe.fs.readFileSync)e=JSON.parse(xe.fs.readFileSync(n,"utf-8"))}catch(t){if(t instanceof SyntaxError)t.message="syntax error in "+n;if(t.code==="ENOENT")e={};else throw t}this.cache[this.locale]=e}_resolveLocaleFile(e,n){let t=xe.resolve(e,"./",n+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(t)&&~n.lastIndexOf("_")){let r=xe.resolve(e,"./",n.split("_")[0]+".json");if(this._fileExistsSync(r))t=r}return t}_fileExistsSync(e){return xe.exists(e)}}function qr(e,n){xe=n;let t=new Kr(e);return{__:t.__.bind(t),__n:t.__n.bind(t),setLocale:t.setLocale.bind(t),getLocale:t.getLocale.bind(t),updateLocale:t.updateLocale.bind(t),locale:t.locale}}var ja=(e)=>qr(e,Jr),Xr=ja;var ti=Mo(Qr(),1);import{createRequire as Ha}from"module";import{readFileSync as Va,readdirSync as za}from"fs";var Bt=ni(import.meta.url),Ga=Bt.substring(0,Bt.lastIndexOf("node_modules")),Ua=Ha(import.meta.url),ri={assert:{notStrictEqual:ka,strictEqual:Ma},cliui:Et,findUp:Ct,getEnv:(e)=>process.env[e],inspect:Na,getProcessArgvBin:Vr,mainFilename:Ga||process.cwd(),Parser:Hr,path:{basename:Ra,dirname:Ia,extname:Ta,relative:La,resolve:ei,join:Wa},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,n)=>process.emitWarning(e,n),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:Va,readdirSync:za,require:Ua,getCallerFile:()=>{let e=ti.default(3);return e.match(/^file:\/\//)?ni(e):e},stringWidth:_t,y18n:Xr({directory:ei(Bt,"../../../locales"),updateFiles:!1})};function he(e,n,t,r){t.assert.notStrictEqual(e,n,r)}function Ot(e,n){n.assert.strictEqual(typeof e,"string")}function hn(e){return Object.keys(e)}function J(e){return!!e&&!!e.then&&typeof e.then==="function"}class Q extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,Q)}}function Re(e){let t=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),r=/\.*[\][<>]/g,i=t.shift();if(!i)throw Error(`No command found in: ${e}`);let s={cmd:i.replace(r,""),demanded:[],optional:[]};return t.forEach((o,u)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&u===t.length-1)c=!0;if(/^\[/.test(o))s.optional.push({cmd:o.replace(r,"").split("|"),variadic:c});else s.demanded.push({cmd:o.replace(r,"").split("|"),variadic:c})}),s}var Ya=["first","second","third","fourth","fifth","sixth"];function x(e,n,t){function r(){return typeof e==="object"?[{demanded:[],optional:[]},e,n]:[Re(`cmd ${e}`),n,t]}try{let i=0,[s,o,u]=r(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let p=u||c.length;if(p<s.demanded.length)throw new Q(`Not enough arguments provided. Expected ${s.demanded.length} but received ${c.length}.`);let b=s.demanded.length+s.optional.length;if(p>b)throw new Q(`Too many arguments provided. Expected max ${b} but received ${p}.`);s.demanded.forEach((g)=>{let D=c.shift(),F=ii(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)si(F,g.cmd,i);i+=1}),s.optional.forEach((g)=>{if(c.length===0)return;let D=c.shift(),F=ii(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)si(F,g.cmd,i);i+=1})}catch(i){console.warn(i.stack)}}function ii(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function si(e,n,t){throw new Q(`Invalid ${Ya[t]||"manyith"} argument. Expected ${n.join(" or ")} but received ${e}.`)}class $t{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,n,t=!0,r=!1){if(x("<array|function> [boolean] [boolean] [boolean]",[e,n,t],arguments.length),Array.isArray(e)){for(let i=0;i<e.length;i++){if(typeof e[i]!=="function")throw Error("middleware must be a function");let s=e[i];s.applyBeforeValidation=n,s.global=t}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let i=e;i.applyBeforeValidation=n,i.global=t,i.mutates=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,n){let t=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((r)=>{let i=[...t[n]||[],n];if(!r.option)return!0;else return!i.includes(r.option)}),e.option=n,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function oi(e){if(!e)return[];return e.map((n)=>(n.applyBeforeValidation=!1,n))}function Ke(e,n,t,r){return t.reduce((i,s)=>{if(s.applyBeforeValidation!==r)return i;if(s.mutates){if(s.applied)return i;s.applied=!0}if(J(i))return i.then((o)=>Promise.all([o,s(o,n)])).then(([o,u])=>Object.assign(o,u));else{let o=s(i,n);return J(o)?o.then((u)=>Object.assign(i,u)):Object.assign(i,o)}},e)}function qe(e,n,t=(r)=>{throw r}){try{let r=Ja(e)?e():e;return J(r)?r.then((i)=>n(i)):n(r)}catch(r){return t(r)}}function Ja(e){return typeof e==="function"}var Dn=/(^\*)|(^\$0)/;class ui{constructor(e,n,t,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=t,this.validation=n}addDirectory(e,n,t,r){r=r||{},this.requireCache.add(t);let i=this.shim.path.resolve(this.shim.path.dirname(t),e),s=this.shim.readdirSync(i,{recursive:r.recurse?!0:!1});if(!Array.isArray(r.extensions))r.extensions=["js"];let o=typeof r.visit==="function"?r.visit:(u)=>u;for(let u of s){let c=u.toString();if(r.exclude){let b=!1;if(typeof r.exclude==="function")b=r.exclude(c);else b=r.exclude.test(c);if(b)continue}if(r.include){let b=!1;if(typeof r.include==="function")b=r.include(c);else b=r.include.test(c);if(!b)continue}let p=!1;for(let b of r.extensions)if(c.endsWith(b))p=!0;if(p){let b=this.shim.path.join(i,c),g=n(b),D=Object.create(null,Object.getOwnPropertyDescriptors({...g}));if(o(D,b,c)){if(this.requireCache.has(b))continue;else this.requireCache.add(b);if(!D.command)D.command=this.shim.path.basename(b,this.shim.path.extname(b));this.addHandler(D)}}}}addHandler(e,n,t,r,i,s){let o=[],u=oi(i);if(r=r||(()=>{}),Array.isArray(e))if(Ka(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Xa(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(ai(t)){this.addHandler([e].concat(o),n,t.builder,t.handler,t.middlewares,t.deprecated);return}if(typeof e==="string"){let c=Re(e);o=o.map((g)=>Re(g).cmd);let p=!1,b=[c.cmd].concat(o).filter((g)=>{if(Dn.test(g))return p=!0,!1;return!0});if(b.length===0&&p)b.push("$0");if(p)c.cmd=b[0],o=b.slice(1),e=e.replace(Dn,c.cmd);if(o.forEach((g)=>{this.aliasMap[g]=c.cmd}),n!==!1)this.usage.command(e,n,p,o,s);if(this.handlers[c.cmd]={original:e,description:n,handler:r,builder:t||{},middlewares:u,deprecated:s,demanded:c.demanded,optional:c.optional},p)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,n,t,r,i,s){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,u=n.getInternalMethods().getContext(),c=u.commands.slice(),p=!e;if(e)u.commands.push(e),u.fullCommands.push(o.original);let b=this.applyBuilderUpdateUsageAndParse(p,o,n,t.aliases,c,r,i,s);return J(b)?b.then((g)=>this.applyMiddlewareAndGetResult(p,o,g.innerArgv,u,i,g.aliases,n)):this.applyMiddlewareAndGetResult(p,o,b.innerArgv,u,i,b.aliases,n)}applyBuilderUpdateUsageAndParse(e,n,t,r,i,s,o,u){let c=n.builder,p=t;if(Wn(c)){t.getInternalMethods().getUsageInstance().freeze();let b=c(t.getInternalMethods().reset(r),u);if(J(b))return b.then((g)=>(p=ci(g)?g:t,this.parseAndUpdateUsage(e,n,p,i,s,o)))}else if(qa(c))t.getInternalMethods().getUsageInstance().freeze(),p=t.getInternalMethods().reset(r),Object.keys(n.builder).forEach((b)=>{p.option(b,c[b])});return this.parseAndUpdateUsage(e,n,p,i,s,o)}parseAndUpdateUsage(e,n,t,r,i,s){if(e)t.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(t))t.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,n),n.description);let o=t.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,s);return J(o)?o.then((u)=>({aliases:t.parsed.aliases,innerArgv:u})):{aliases:t.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,n){let t=Dn.test(n.original)?n.original.replace(Dn,"").trim():n.original,r=e.filter((i)=>!Dn.test(i));return r.push(t),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,n,t,r,i,s,o,u){if(!s.getInternalMethods().getHasOutput()){let c=s.getInternalMethods().runValidation(i,u,s.parsed.error,e);t=qe(t,(p)=>(c(p),p))}if(n.handler&&!s.getInternalMethods().getHasOutput()){s.getInternalMethods().setHasOutput();let c=!!s.getOptions().configuration["populate--"];if(s.getInternalMethods().postProcess(t,c,!1,!1),t=Ke(t,s,o,!1),t=qe(t,(p)=>{let b=n.handler(p);return J(b)?b.then(()=>p):p}),!e)s.getInternalMethods().getUsageInstance().cacheHelpMessage();if(J(t)&&!s.getInternalMethods().hasParseCallback())t.catch((p)=>{try{s.getInternalMethods().getUsageInstance().fail(null,p)}catch(b){}})}if(!e)r.commands.pop(),r.fullCommands.pop();return t}applyMiddlewareAndGetResult(e,n,t,r,i,s,o){let u={};if(i)return t;if(!o.getInternalMethods().getHasOutput())u=this.populatePositionals(n,t,r,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(n.middlewares),p=Ke(t,o,c,!0);return J(p)?p.then((b)=>this.handleValidationAndGetResult(e,n,b,r,s,o,c,u)):this.handleValidationAndGetResult(e,n,p,r,s,o,c,u)}populatePositionals(e,n,t,r){n._=n._.slice(t.commands.length);let i=e.demanded.slice(0),s=e.optional.slice(0),o={};this.validation.positionalCount(i.length,n._.length);while(i.length){let u=i.shift();this.populatePositional(u,n,o)}while(s.length){let u=s.shift();this.populatePositional(u,n,o)}return n._=t.commands.concat(n._.map((u)=>""+u)),this.postProcessPositionals(n,o,this.cmdToParseOptions(e.original),r),o}populatePositional(e,n,t){let r=e.cmd[0];if(e.variadic)t[r]=n._.splice(0).map(String);else if(n._.length)t[r]=[String(n._.shift())]}cmdToParseOptions(e){let n={array:[],default:{},alias:{},demand:{}},t=Re(e);return t.demanded.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)n.array.push(i),n.default[i]=[];n.alias[i]=s,n.demand[i]=!0}),t.optional.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)n.array.push(i),n.default[i]=[];n.alias[i]=s}),n}postProcessPositionals(e,n,t,r){let i=Object.assign({},r.getOptions());i.default=Object.assign(t.default,i.default);for(let c of Object.keys(t.alias))i.alias[c]=(i.alias[c]||[]).concat(t.alias[c]);i.array=i.array.concat(t.array),i.config={};let s=[];if(Object.keys(n).forEach((c)=>{n[c].map((p)=>{if(i.configuration["unknown-options-as-args"])i.key[c]=!0;s.push(`--${c}`),s.push(p)})}),!s.length)return;let o=Object.assign({},i.configuration,{"populate--":!1}),u=this.shim.Parser.detailed(s,Object.assign({},i,{configuration:o}));if(u.error)r.getInternalMethods().getUsageInstance().fail(u.error.message,u.error);else{let c=Object.keys(n);Object.keys(n).forEach((p)=>{c.push(...u.aliases[p])}),Object.keys(u.argv).forEach((p)=>{if(c.includes(p)){if(!n[p])n[p]=u.argv[p];if(!this.isInConfigs(r,p)&&!this.isDefaulted(r,p)&&Object.prototype.hasOwnProperty.call(e,p)&&Object.prototype.hasOwnProperty.call(u.argv,p)&&(Array.isArray(e[p])||Array.isArray(u.argv[p])))e[p]=[].concat(e[p],u.argv[p]);else e[p]=u.argv[p]}})}}isDefaulted(e,n){let{default:t}=e.getOptions();return Object.prototype.hasOwnProperty.call(t,n)||Object.prototype.hasOwnProperty.call(t,this.shim.Parser.camelCase(n))}isInConfigs(e,n){let{configObjects:t}=e.getOptions();return t.some((r)=>Object.prototype.hasOwnProperty.call(r,n))||t.some((r)=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(n)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let t=Dn.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(t,this.defaultCommand.description)}let n=this.defaultCommand.builder;if(Wn(n))return n(e,!0);else if(!ai(n))Object.keys(n).forEach((t)=>{e.option(t,n[t])});return}extractDesc({describe:e,description:n,desc:t}){for(let r of[e,n,t]){if(typeof r==="string"||r===!1)return r;he(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();he(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function li(e,n,t,r){return new ui(e,n,t,r)}function ai(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function Ka(e){return e.every((n)=>typeof n==="string")}function Wn(e){return typeof e==="function"}function qa(e){return typeof e==="object"}function Xa(e){return typeof e==="object"&&!Array.isArray(e)}function Ie(e={},n=()=>!0){let t={};return hn(e).forEach((r)=>{if(n(r,e[r]))t[r]=e[r]}),t}function Te(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((n)=>{let t=n;if(t._handle&&t.isTTY&&typeof t._handle.setBlocking==="function")t._handle.setBlocking(e)})}function Za(e){return typeof e==="boolean"}function fi(e,n){let t=n.y18n.__,r={},i=[];r.failFn=function(C){i.push(C)};let s=null,o=null,u=!0;r.showHelpOnFail=function(C=!0,_){let[N,V]=typeof C==="string"?[!0,C]:[C,_];if(e.getInternalMethods().isGlobalContext())o=V;return s=V,u=N,r};let c=!1;r.fail=function(C,_){let N=e.getInternalMethods().getLoggerInstance();if(i.length)for(let V=i.length-1;V>=0;--V){let ne=i[V];if(Za(ne)){if(_)throw _;else if(C)throw Error(C)}else ne(C,_,r)}else{if(e.getExitProcess())Te(!0);if(!c){if(c=!0,u)e.showHelp("error"),N.error();if(C||_)N.error(C||_);let V=s||o;if(V){if(C||_)N.error("");N.error(V)}}if(_=_||new Q(C),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,_);else throw _}};let p=[],b=!1;r.usage=(P,C)=>{if(P===null)return b=!0,p=[],r;return b=!1,p.push([P,C||""]),r},r.getUsage=()=>p,r.getUsageDisabled=()=>b,r.getPositionalGroupName=()=>t("Positionals:");let g=[];r.example=(P,C)=>{g.push([P,C||""])};let D=[];r.command=function(C,_,N,V,ne=!1){if(N)D=D.map((H)=>(H[2]=!1,H));D.push([C,_||"",N,V,ne])},r.getCommands=()=>D;let F={};r.describe=function(C,_){if(Array.isArray(C))C.forEach((N)=>{r.describe(N,_)});else if(typeof C==="object")Object.keys(C).forEach((N)=>{r.describe(N,C[N])});else F[C]=_},r.getDescriptions=()=>F;let y=[];r.epilog=(P)=>{y.push(P)};let h=!1,v;r.wrap=(P)=>{h=!0,v=P},r.getWrap=()=>{if(n.getEnv("YARGS_DISABLE_WRAP"))return null;if(!h)v=Pe(),h=!0;return v};let W="__yargsString__:";r.deferY18nLookup=(P)=>W+P,r.help=function(){if(I)return I;ce();let C=e.customScriptName?e.$0:n.path.basename(e.$0),_=e.getDemandedOptions(),N=e.getDemandedCommands(),V=e.getDeprecatedOptions(),ne=e.getGroups(),H=e.getOptions(),re=[];re=re.concat(Object.keys(F)),re=re.concat(Object.keys(_)),re=re.concat(Object.keys(N)),re=re.concat(Object.keys(H.default)),re=re.filter(te),re=Object.keys(re.reduce((k,G)=>{if(G!=="_")k[G]=!0;return k},{}));let Ne=r.getWrap(),U=n.cliui({width:Ne,wrap:!!Ne});if(!b){if(p.length)p.forEach((k)=>{if(U.div({text:`${k[0].replace(/\$0/g,C)}`}),k[1])U.div({text:`${k[1]}`,padding:[1,0,0,0]})}),U.div();else if(D.length){let k=null;if(N._)k=`${C} <${t("command")}>
|
|
15
|
-
`;else k=`${C} [${
|
|
16
|
-
`;U.div(`${k}`)}}if(D.length>1||D.length===1&&!D[0][2]){U.div(
|
|
13
|
+
`).map((r)=>ia(r,t,n)).join(`
|
|
14
|
+
`)}function Cn(e){return hr(e,{stringWidth:ke,stripAnsi:je,wrap:En})}import{dirname as Mr,resolve as Nr}from"path";import{readdirSync as sa,statSync as oa}from"fs";function wn(e,t){let n=Nr(".",e),r;if(!oa(n).isDirectory())n=Mr(n);while(!0){if(r=t(n,sa(n)),r)return Nr(n,r);if(n=Mr(r=n),r===n)break}}import{inspect as Ra}from"util";import{fileURLToPath as ri}from"url";import{format as la}from"util";import{normalize as ca,resolve as da}from"path";function Je(e){if(!(e!==e.toLowerCase()&&e!==e.toUpperCase()))e=e.toLowerCase();if(e.indexOf("-")===-1&&e.indexOf("_")===-1)return e;else{let n="",r=!1,i=e.match(/^-+/);for(let s=i?i[0].length:0;s<e.length;s++){let o=e.charAt(s);if(r)r=!1,o=o.toUpperCase();if(s!==0&&(o==="-"||o==="_"))r=!0;else if(o!=="-"&&o!=="_")n+=o}return n}}function Tt(e,t){let n=e.toLowerCase();t=t||"-";let r="";for(let i=0;i<e.length;i++){let s=n.charAt(i),o=e.charAt(i);if(s!==o&&i>0)r+=`${t}${n.charAt(i)}`;else r+=o}return r}function Lt(e){if(e===null||e===void 0)return!1;if(typeof e==="number")return!0;if(/^0x[0-9a-f]+$/i.test(e))return!0;if(/^0[^.]/.test(e))return!1;return/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(e)}function Rr(e){if(Array.isArray(e))return e.map((o)=>typeof o!=="string"?o+"":o);e=e.trim();let t=0,n=null,r=null,i=null,s=[];for(let o=0;o<e.length;o++){if(n=r,r=e.charAt(o),r===" "&&!i){if(n!==" ")t++;continue}if(r===i)i=null;else if((r==="'"||r==='"')&&!i)i=r;if(!s[t])s[t]="";s[t]+=r}return s}var ye;(function(e){e.BOOLEAN="boolean",e.STRING="string",e.NUMBER="number",e.ARRAY="array"})(ye||(ye={}));var Me;class Sn{constructor(e){Me=e}parse(e,t){let n=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},t),r=Rr(e),i=typeof e==="string",s=aa(Object.assign(Object.create(null),n.alias)),o=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},n.configuration),u=Object.assign(Object.create(null),n.default),c=n.configObjects||[],p=n.envPrefix,b=o["populate--"],g=b?"--":"_",D=Object.create(null),F=Object.create(null),y=n.__||Me.format,h={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},v=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,W=new RegExp("^--"+o["negation-prefix"]+"(.+)");if([].concat(n.array||[]).filter(Boolean).forEach(function(l){let f=typeof l==="object"?l.key:l,E=Object.keys(l).map(function(m){return{boolean:"bools",string:"strings",number:"numbers"}[m]}).filter(Boolean).pop();if(E)h[E][f]=!0;h.arrays[f]=!0,h.keys.push(f)}),[].concat(n.boolean||[]).filter(Boolean).forEach(function(l){h.bools[l]=!0,h.keys.push(l)}),[].concat(n.string||[]).filter(Boolean).forEach(function(l){h.strings[l]=!0,h.keys.push(l)}),[].concat(n.number||[]).filter(Boolean).forEach(function(l){h.numbers[l]=!0,h.keys.push(l)}),[].concat(n.count||[]).filter(Boolean).forEach(function(l){h.counts[l]=!0,h.keys.push(l)}),[].concat(n.normalize||[]).filter(Boolean).forEach(function(l){h.normalize[l]=!0,h.keys.push(l)}),typeof n.narg==="object")Object.entries(n.narg).forEach(([l,f])=>{if(typeof f==="number")h.nargs[l]=f,h.keys.push(l)});if(typeof n.coerce==="object")Object.entries(n.coerce).forEach(([l,f])=>{if(typeof f==="function")h.coercions[l]=f,h.keys.push(l)});if(typeof n.config<"u"){if(Array.isArray(n.config)||typeof n.config==="string")[].concat(n.config).filter(Boolean).forEach(function(l){h.configs[l]=!0});else if(typeof n.config==="object")Object.entries(n.config).forEach(([l,f])=>{if(typeof f==="boolean"||typeof f==="function")h.configs[l]=f})}wt(n.key,s,n.default,h.arrays),Object.keys(u).forEach(function(l){(h.aliases[l]||[]).forEach(function(f){u[f]=u[l]})});let T=null;pn();let ce=[],I=Object.assign(Object.create(null),{_:[]}),Y={};for(let l=0;l<r.length;l++){let f=r[l],E=f.replace(/^-{3,}/,"---"),m,d,A,w,O,oe;if(f!=="--"&&/^-/.test(f)&&G(f))ne(f);else if(E.match(/^---+(=|$)/)){ne(f);continue}else if(f.match(/^--.+=/)||!o["short-option-groups"]&&f.match(/^-.+=/)){if(w=f.match(/^--?([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3)if(j(w[1],h.arrays))l=Pe(l,w[1],r,w[2]);else if(j(w[1],h.nargs)!==!1)l=X(l,w[1],r,w[2]);else z(w[1],w[2],!0)}else if(f.match(W)&&o["boolean-negation"]){if(w=f.match(W),w!==null&&Array.isArray(w)&&w.length>=2)d=w[1],z(d,j(d,h.arrays)?[!1]:!1)}else if(f.match(/^--.+/)||!o["short-option-groups"]&&f.match(/^-[^-]+/)){if(w=f.match(/^--?(.+)/),w!==null&&Array.isArray(w)&&w.length>=2)if(d=w[1],j(d,h.arrays))l=Pe(l,d,r);else if(j(d,h.nargs)!==!1)l=X(l,d,r);else if(O=r[l+1],O!==void 0&&(!O.match(/^-/)||O.match(v))&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else if(/^(true|false)$/.test(O))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-.\..+=/)){if(w=f.match(/^-([^=]+)=([\s\S]*)$/),w!==null&&Array.isArray(w)&&w.length>=3)z(w[1],w[2])}else if(f.match(/^-.\..+/)&&!f.match(v)){if(O=r[l+1],w=f.match(/^-(.\..+)/),w!==null&&Array.isArray(w)&&w.length>=2)if(d=w[1],O!==void 0&&!O.match(/^-/)&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-[^-]+/)&&!f.match(v)){A=f.slice(1,-1).split(""),m=!1;for(let fe=0;fe<A.length;fe++){if(O=f.slice(fe+2),A[fe+1]&&A[fe+1]==="="){if(oe=f.slice(fe+3),d=A[fe],j(d,h.arrays))l=Pe(l,d,r,oe);else if(j(d,h.nargs)!==!1)l=X(l,d,r,oe);else z(d,oe);m=!0;break}if(O==="-"){z(A[fe],O);continue}if(/[A-Za-z]/.test(A[fe])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(O)&&j(O,h.bools)===!1){z(A[fe],O),m=!0;break}if(A[fe+1]&&A[fe+1].match(/\W/)){z(A[fe],O),m=!0;break}else z(A[fe],L(A[fe]))}if(d=f.slice(-1)[0],!m&&d!=="-")if(j(d,h.arrays))l=Pe(l,d,r);else if(j(d,h.nargs)!==!1)l=X(l,d,r);else if(O=r[l+1],O!==void 0&&(!/^(-|--)[^-]/.test(O)||O.match(v))&&!j(d,h.bools)&&!j(d,h.counts))z(d,O),l++;else if(/^(true|false)$/.test(O))z(d,O),l++;else z(d,L(d))}else if(f.match(/^-[0-9]$/)&&f.match(v)&&j(f.slice(1),h.bools))d=f.slice(1),z(d,L(d));else if(f==="--"){ce=r.slice(l+1);break}else if(o["halt-at-non-option"]){ce=r.slice(l);break}else ne(f)}if(te(I,!0),te(I,!1),_(I),V(),Ne(I,h.aliases,u,!0),H(I),o["set-placeholder-key"])re(I);if(Object.keys(h.counts).forEach(function(l){if(!U(I,l.split(".")))z(l,0)}),b&&ce.length)I[g]=[];if(ce.forEach(function(l){I[g].push(l)}),o["camel-case-expansion"]&&o["strip-dashed"])Object.keys(I).filter((l)=>l!=="--"&&l.includes("-")).forEach((l)=>{delete I[l]});if(o["strip-aliased"])[].concat(...Object.keys(s).map((l)=>s[l])).forEach((l)=>{if(o["camel-case-expansion"]&&l.includes("-"))delete I[l.split(".").map((f)=>Je(f)).join(".")];delete I[l]});function ne(l){let f=C("_",l);if(typeof f==="string"||typeof f==="number")I._.push(f)}function X(l,f,E,m){let d,A=j(f,h.nargs);if(A=typeof A!=="number"||isNaN(A)?1:A,A===0){if(!se(m))T=Error(y("Argument unexpected for: %s",f));return z(f,L(f)),l}let w=se(m)?0:1;if(o["nargs-eats-options"]){if(E.length-(l+1)+w<A)T=Error(y("Not enough arguments following: %s",f));w=A}else{for(d=l+1;d<E.length;d++)if(!E[d].match(/^-[^0-9]/)||E[d].match(v)||G(E[d]))w++;else break;if(w<A)T=Error(y("Not enough arguments following: %s",f))}let O=Math.min(w,A);if(!se(m)&&O>0)z(f,m),O--;for(d=l+1;d<O+l+1;d++)z(f,E[d]);return l+O}function Pe(l,f,E,m){let d=[],A=m||E[l+1],w=j(f,h.nargs);if(j(f,h.bools)&&!/^(true|false)$/.test(A))d.push(!0);else if(se(A)||se(m)&&/^-/.test(A)&&!v.test(A)&&!G(A)){if(u[f]!==void 0){let O=u[f];d=Array.isArray(O)?O:[O]}}else{if(!se(m))d.push(P(f,m,!0));for(let O=l+1;O<E.length;O++){if(!o["greedy-arrays"]&&d.length>0||w&&typeof w==="number"&&d.length>=w)break;if(A=E[O],/^-/.test(A)&&!v.test(A)&&!G(A))break;l=O,d.push(P(f,A,i))}}if(typeof w==="number"&&(w&&d.length<w||isNaN(w)&&d.length===0))T=Error(y("Not enough arguments following: %s",f));return z(f,d),l}function z(l,f,E=i){if(/-/.test(l)&&o["camel-case-expansion"]){let A=l.split(".").map(function(w){return Je(w)}).join(".");Ct(l,A)}let m=P(l,f,E),d=l.split(".");if(ve(I,d,m),h.aliases[l])h.aliases[l].forEach(function(A){let w=A.split(".");ve(I,w,m)});if(d.length>1&&o["dot-notation"])(h.aliases[d[0]]||[]).forEach(function(A){let w=A.split("."),O=[].concat(d);if(O.shift(),w=w.concat(O),!(h.aliases[l]||[]).includes(w.join(".")))ve(I,w,m)});if(j(l,h.normalize)&&!j(l,h.arrays))[l].concat(h.aliases[l]||[]).forEach(function(w){Object.defineProperty(Y,w,{enumerable:!0,get(){return f},set(O){f=typeof O==="string"?Me.normalize(O):O}})})}function Ct(l,f){if(!(h.aliases[l]&&h.aliases[l].length))h.aliases[l]=[f],D[f]=!0;if(!(h.aliases[f]&&h.aliases[f].length))Ct(f,l)}function P(l,f,E){if(E)f=ua(f);if(j(l,h.bools)||j(l,h.counts)){if(typeof f==="string")f=f==="true"}let m=Array.isArray(f)?f.map(function(d){return C(l,d)}):C(l,f);if(j(l,h.counts)&&(se(m)||typeof m==="boolean"))m=xn();if(j(l,h.normalize)&&j(l,h.arrays))if(Array.isArray(f))m=f.map((d)=>Me.normalize(d));else m=Me.normalize(f);return m}function C(l,f){if(!o["parse-positional-numbers"]&&l==="_")return f;if(!j(l,h.strings)&&!j(l,h.bools)&&!Array.isArray(f)){if(Lt(f)&&o["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${f}`)))||!se(f)&&j(l,h.numbers))f=Number(f)}return f}function _(l){let f=Object.create(null);Ne(f,h.aliases,u),Object.keys(h.configs).forEach(function(E){let m=l[E]||f[E];if(m)try{let d=null,A=Me.resolve(Me.cwd(),m),w=h.configs[E];if(typeof w==="function"){try{d=w(A)}catch(O){d=O}if(d instanceof Error){T=d;return}}else d=Me.require(A);N(d)}catch(d){if(d.name==="PermissionDenied")T=d;else if(l[E])T=Error(y("Invalid JSON config file: %s",m))}})}function N(l,f){Object.keys(l).forEach(function(E){let m=l[E],d=f?f+"."+E:E;if(typeof m==="object"&&m!==null&&!Array.isArray(m)&&o["dot-notation"])N(m,d);else if(!U(I,d.split("."))||j(d,h.arrays)&&o["combine-arrays"])z(d,m)})}function V(){if(typeof c<"u")c.forEach(function(l){N(l)})}function te(l,f){if(typeof p>"u")return;let E=typeof p==="string"?p:"",m=Me.env();Object.keys(m).forEach(function(d){if(E===""||d.lastIndexOf(E,0)===0){let A=d.split("__").map(function(w,O){if(O===0)w=w.substring(E.length);return Je(w)});if((f&&h.configs[A.join(".")]||!f)&&!U(l,A))z(A.join("."),m[d])}})}function H(l){let f,E=new Set;Object.keys(l).forEach(function(m){if(!E.has(m)){if(f=j(m,h.coercions),typeof f==="function")try{let d=C(m,f(l[m]));[].concat(h.aliases[m]||[],m).forEach((A)=>{E.add(A),l[A]=d})}catch(d){T=d}}})}function re(l){return h.keys.forEach((f)=>{if(~f.indexOf("."))return;if(typeof l[f]>"u")l[f]=void 0}),l}function Ne(l,f,E,m=!1){Object.keys(E).forEach(function(d){if(!U(l,d.split("."))){if(ve(l,d.split("."),E[d]),m)F[d]=!0;(f[d]||[]).forEach(function(A){if(U(l,A.split(".")))return;ve(l,A.split("."),E[d])})}})}function U(l,f){let E=l;if(!o["dot-notation"])f=[f.join(".")];f.slice(0,-1).forEach(function(d){E=E[d]||{}});let m=f[f.length-1];if(typeof E!=="object")return!1;else return m in E}function ve(l,f,E){let m=l;if(!o["dot-notation"])f=[f.join(".")];f.slice(0,-1).forEach(function(oe){if(oe=Ir(oe),typeof m==="object"&&m[oe]===void 0)m[oe]={};if(typeof m[oe]!=="object"||Array.isArray(m[oe])){if(Array.isArray(m[oe]))m[oe].push({});else m[oe]=[m[oe],{}];m=m[oe][m[oe].length-1]}else m=m[oe]});let d=Ir(f[f.length-1]),A=j(f.join("."),h.arrays),w=Array.isArray(E),O=o["duplicate-arguments-array"];if(!O&&j(d,h.nargs)){if(O=!0,!se(m[d])&&h.nargs[d]===1||Array.isArray(m[d])&&m[d].length===h.nargs[d])m[d]=void 0}if(E===xn())m[d]=xn(m[d]);else if(Array.isArray(m[d]))if(O&&A&&w)m[d]=o["flatten-duplicate-arrays"]?m[d].concat(E):(Array.isArray(m[d][0])?m[d]:[m[d]]).concat([E]);else if(!O&&Boolean(A)===Boolean(w))m[d]=E;else m[d]=m[d].concat([E]);else if(m[d]===void 0&&A)m[d]=w?E:[E];else if(O&&!(m[d]===void 0||j(d,h.counts)||j(d,h.bools)))m[d]=[m[d],E];else m[d]=E}function wt(...l){l.forEach(function(f){Object.keys(f||{}).forEach(function(E){if(h.aliases[E])return;h.aliases[E]=[].concat(s[E]||[]),h.aliases[E].concat(E).forEach(function(m){if(/-/.test(m)&&o["camel-case-expansion"]){let d=Je(m);if(d!==E&&h.aliases[E].indexOf(d)===-1)h.aliases[E].push(d),D[d]=!0}}),h.aliases[E].concat(E).forEach(function(m){if(m.length>1&&/[A-Z]/.test(m)&&o["camel-case-expansion"]){let d=Tt(m,"-");if(d!==E&&h.aliases[E].indexOf(d)===-1)h.aliases[E].push(d),D[d]=!0}}),h.aliases[E].forEach(function(m){h.aliases[m]=[E].concat(h.aliases[E].filter(function(d){return m!==d}))})})})}function j(l,f){let E=[].concat(h.aliases[l]||[],l),m=Object.keys(f),d=E.find((A)=>m.includes(A));return d?f[d]:!1}function dt(l){let f=Object.keys(h);return[].concat(f.map((m)=>h[m])).some(function(m){return Array.isArray(m)?m.includes(l):m[l]})}function ur(l,...f){return[].concat(...f).some(function(m){let d=l.match(m);return d&&dt(d[1])})}function k(l){if(l.match(v)||!l.match(/^-[^-]+/))return!1;let f=!0,E,m=l.slice(1).split("");for(let d=0;d<m.length;d++){if(E=l.slice(d+2),!dt(m[d])){f=!1;break}if(m[d+1]&&m[d+1]==="="||E==="-"||/[A-Za-z]/.test(m[d])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(E)||m[d+1]&&m[d+1].match(/\W/))break}return f}function G(l){return o["unknown-options-as-args"]&&ie(l)}function ie(l){if(l=l.replace(/^-{3,}/,"--"),l.match(v))return!1;if(k(l))return!1;return!ur(l,/^-+([^=]+?)=[\s\S]*$/,W,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function L(l){if(!j(l,h.bools)&&!j(l,h.counts)&&`${l}`in u)return u[l];else return ue(Z(l))}function ue(l){return{[ye.BOOLEAN]:!0,[ye.STRING]:"",[ye.NUMBER]:void 0,[ye.ARRAY]:[]}[l]}function Z(l){let f=ye.BOOLEAN;if(j(l,h.strings))f=ye.STRING;else if(j(l,h.numbers))f=ye.NUMBER;else if(j(l,h.bools))f=ye.BOOLEAN;else if(j(l,h.arrays))f=ye.ARRAY;return f}function se(l){return l===void 0}function pn(){Object.keys(h.counts).find((l)=>{if(j(l,h.arrays))return T=Error(y("Invalid configuration: %s, opts.count excludes opts.array.",l)),!0;else if(j(l,h.nargs))return T=Error(y("Invalid configuration: %s, opts.count excludes opts.narg.",l)),!0;return!1})}return{aliases:Object.assign({},h.aliases),argv:Object.assign(Y,I),configuration:o,defaulted:Object.assign({},F),error:T,newAliases:Object.assign({},D)}}}function aa(e){let t=[],n=Object.create(null),r=!0;Object.keys(e).forEach(function(i){t.push([].concat(e[i],i))});while(r){r=!1;for(let i=0;i<t.length;i++)for(let s=i+1;s<t.length;s++)if(t[i].filter(function(u){return t[s].indexOf(u)!==-1}).length){t[i]=t[i].concat(t[s]),t.splice(s,1),r=!0;break}}return t.forEach(function(i){i=i.filter(function(o,u,c){return c.indexOf(o)===u});let s=i.pop();if(s!==void 0&&typeof s==="string")n[s]=i}),n}function xn(e){return e!==void 0?e+1:1}function Ir(e){if(e==="__proto__")return"___proto___";return e}function ua(e){return typeof e==="string"&&(e[0]==="'"||e[0]==='"')&&e[e.length-1]===e[0]?e.substring(1,e.length-1):e}import{readFileSync as fa}from"fs";import{createRequire as Tr}from"module";var An,Pn,_n,Lr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):20,Wr=(Pn=(An=process===null||process===void 0?void 0:process.versions)===null||An===void 0?void 0:An.node)!==null&&Pn!==void 0?Pn:(_n=process===null||process===void 0?void 0:process.version)===null||_n===void 0?void 0:_n.slice(1);if(Wr){if(Number(Wr.match(/^([^.]+)/)[1])<Lr)throw Error(`yargs parser supports a minimum Node.js version of ${Lr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`)}var ha=process?process.env:{},Hr=Tr?Tr(import.meta.url):void 0,Vr=new Sn({cwd:process.cwd,env:()=>ha,format:la,normalize:ca,resolve:da,require:(e)=>{if(typeof Hr<"u")return Hr(e);else if(e.match(/\.json$/))return JSON.parse(fa(e,"utf8"));else throw Error("only .json config files are supported in ESM")}}),xt=function(t,n){return Vr.parse(t.slice(),n).argv};xt.detailed=function(e,t){return Vr.parse(e.slice(),t)};xt.camelCase=Je;xt.decamelize=Tt;xt.looksLikeNumber=Lt;var zr=xt;import{basename as Ia,dirname as Ta,extname as La,relative as Wa,resolve as ni,join as Ha}from"path";function Da(){if(ga())return 0;return 1}function ga(){return pa()&&!process.defaultApp}function pa(){return!!process.versions.electron}function Gr(){return process.argv[Da()]}var ma=new Intl.Segmenter,Ur=/^(?:\p{Default_Ignorable_Code_Point}|\p{Control}|\p{Format}|\p{Nonspacing_Mark}|\p{Enclosing_Mark}|\p{Surrogate})+$/v,Fa=/^[\p{Default_Ignorable_Code_Point}\p{Control}\p{Format}\p{Nonspacing_Mark}\p{Enclosing_Mark}\p{Surrogate}]+/v,ya=/\p{Spacing_Mark}/v,ba=/^\p{RGI_Emoji}$/v,Ea=/^[\d#*]\u20E3$/,Ca=/\p{Extended_Pictographic}/gu;function wa(e){if(e.length>50)return!1;if(Ea.test(e))return!0;if(e.includes("\u200D")){let t=e.match(Ca);return t!==null&&t.length>=2}return!1}function xa(e){return e.replace(Fa,"")}function Sa(e){return Ur.test(e)}function Yr(e){return e>=4352&&e<=4447||e>=43360&&e<=43388}function Jr(e){return e>=4448&&e<=4519||e>=55216&&e<=55238}function Kr(e){return e>=4520&&e<=4607||e>=55243&&e<=55291}function Aa(e){return Yr(e)||Jr(e)||Kr(e)}function Pa(e,t){let n=[];for(let i of e){if(Ur.test(i))continue;n.push(i.codePointAt(0))}if(n.length===0)return;let r=0;for(let i=0;i<n.length;i++){let s=n[i];if(!Aa(s)){if(r===0)return;for(let o=i;o<n.length;o++)r+=Ye(n[o],t);return r}if(Yr(s)&&Jr(n[i+1])){r+=2,i+=Kr(n[i+2])?2:1;continue}r+=Ye(s,t)}return r}function _a(e,t){let n=0,r=!0;for(let i of e){if(r){r=!1;continue}if(ya.test(i)||i>="\uFF00"&&i<="\uFFEF")n+=Ye(i.codePointAt(0),t)}return n}function Bn(e,t={}){if(typeof e!=="string"||e.length===0)return 0;let{ambiguousIsNarrow:n=!0,countAnsiEscapeCodes:r=!1}=t,i=e;if(!r&&(i.includes("\x1B")||i.includes("\x9B")))i=je(i);if(i.length===0)return 0;if(/^[\u0020-\u007E]*$/.test(i))return i.length;let s=0,o={ambiguousAsWide:!n};for(let{segment:u}of ma.segment(i)){if(Sa(u))continue;if(ba.test(u)||wa(u)){s+=2;continue}let c=xa(u),p=Pa(c,o);if(p!==void 0){s+=p;continue}let b=c.codePointAt(0);s+=Ye(b,o),s+=_a(c,o)}return s}import{readFileSync as Ba,statSync as Oa,writeFile as $a}from"fs";import{format as va}from"util";import{resolve as ja}from"path";var qr={fs:{readFileSync:Ba,writeFile:$a},format:va,resolve:ja,exists:(e)=>{try{return Oa(e).isFile()}catch(t){return!1}}};var xe;class Xr{constructor(e){e=e||{},this.directory=e.directory||"./locales",this.updateFiles=typeof e.updateFiles==="boolean"?e.updateFiles:!0,this.locale=e.locale||"en",this.fallbackToLanguage=typeof e.fallbackToLanguage==="boolean"?e.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...e){if(typeof arguments[0]!=="string")return this._taggedLiteral(arguments[0],...arguments);let t=e.shift(),n=function(){};if(typeof e[e.length-1]==="function")n=e.pop();if(n=n||function(){},!this.cache[this.locale])this._readLocaleFile();if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]=t,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:n});else n();return xe.format.apply(xe.format,[this.cache[this.locale][t]||t].concat(e))}__n(){let e=Array.prototype.slice.call(arguments),t=e.shift(),n=e.shift(),r=e.shift(),i=function(){};if(typeof e[e.length-1]==="function")i=e.pop();if(!this.cache[this.locale])this._readLocaleFile();let s=r===1?t:n;if(this.cache[this.locale][t])s=this.cache[this.locale][t][r===1?"one":"other"];if(!this.cache[this.locale][t]&&this.updateFiles)this.cache[this.locale][t]={one:t,other:n},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:i});else i();let o=[s];if(~s.indexOf("%d"))o.push(r);return xe.format.apply(xe.format,o.concat(e))}setLocale(e){this.locale=e}getLocale(){return this.locale}updateLocale(e){if(!this.cache[this.locale])this._readLocaleFile();for(let t in e)if(Object.prototype.hasOwnProperty.call(e,t))this.cache[this.locale][t]=e[t]}_taggedLiteral(e,...t){let n="";return e.forEach(function(r,i){let s=t[i+1];if(n+=r,typeof s<"u")n+="%s"}),this.__.apply(this,[n].concat([].slice.call(t,1)))}_enqueueWrite(e){if(this.writeQueue.push(e),this.writeQueue.length===1)this._processWriteQueue()}_processWriteQueue(){let e=this,t=this.writeQueue[0],{directory:n,locale:r,cb:i}=t,s=this._resolveLocaleFile(n,r),o=JSON.stringify(this.cache[r],null,2);xe.fs.writeFile(s,o,"utf-8",function(u){if(e.writeQueue.shift(),e.writeQueue.length>0)e._processWriteQueue();i(u)})}_readLocaleFile(){let e={},t=this._resolveLocaleFile(this.directory,this.locale);try{if(xe.fs.readFileSync)e=JSON.parse(xe.fs.readFileSync(t,"utf-8"))}catch(n){if(n instanceof SyntaxError)n.message="syntax error in "+t;if(n.code==="ENOENT")e={};else throw n}this.cache[this.locale]=e}_resolveLocaleFile(e,t){let n=xe.resolve(e,"./",t+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(n)&&~t.lastIndexOf("_")){let r=xe.resolve(e,"./",t.split("_")[0]+".json");if(this._fileExistsSync(r))n=r}return n}_fileExistsSync(e){return xe.exists(e)}}function Zr(e,t){xe=t;let n=new Xr(e);return{__:n.__.bind(n),__n:n.__n.bind(n),setLocale:n.setLocale.bind(n),getLocale:n.getLocale.bind(n),updateLocale:n.updateLocale.bind(n),locale:n.locale}}var ka=(e)=>Zr(e,qr),Qr=ka;var ii=No(ti(),1);import{createRequire as Va}from"module";import{readFileSync as za,readdirSync as Ga}from"fs";var On=ri(import.meta.url),Ua=On.substring(0,On.lastIndexOf("node_modules")),Ya=Va(import.meta.url),si={assert:{notStrictEqual:Ma,strictEqual:Na},cliui:Cn,findUp:wn,getEnv:(e)=>process.env[e],inspect:Ra,getProcessArgvBin:Gr,mainFilename:Ua||process.cwd(),Parser:zr,path:{basename:Ia,dirname:Ta,extname:La,relative:Wa,resolve:ni,join:Ha},process:{argv:()=>process.argv,cwd:process.cwd,emitWarning:(e,t)=>process.emitWarning(e,t),execPath:()=>process.execPath,exit:(e)=>{process.exit(e)},nextTick:process.nextTick,stdColumns:typeof process.stdout.columns<"u"?process.stdout.columns:null},readFileSync:za,readdirSync:Ga,require:Ya,getCallerFile:()=>{let e=ii.default(3);return e.match(/^file:\/\//)?ri(e):e},stringWidth:Bn,y18n:Qr({directory:ni(On,"../../../locales"),updateFiles:!1})};function he(e,t,n,r){n.assert.notStrictEqual(e,t,r)}function $n(e,t){t.assert.strictEqual(typeof e,"string")}function ft(e){return Object.keys(e)}function J(e){return!!e&&!!e.then&&typeof e.then==="function"}class Q extends Error{constructor(e){super(e||"yargs error");if(this.name="YError",Error.captureStackTrace)Error.captureStackTrace(this,Q)}}function Re(e){let n=e.replace(/\s{2,}/g," ").split(/\s+(?![^[]*]|[^<]*>)/),r=/\.*[\][<>]/g,i=n.shift();if(!i)throw Error(`No command found in: ${e}`);let s={cmd:i.replace(r,""),demanded:[],optional:[]};return n.forEach((o,u)=>{let c=!1;if(o=o.replace(/\s/g,""),/\.+[\]>]/.test(o)&&u===n.length-1)c=!0;if(/^\[/.test(o))s.optional.push({cmd:o.replace(r,"").split("|"),variadic:c});else s.demanded.push({cmd:o.replace(r,"").split("|"),variadic:c})}),s}var Ja=["first","second","third","fourth","fifth","sixth"];function x(e,t,n){function r(){return typeof e==="object"?[{demanded:[],optional:[]},e,t]:[Re(`cmd ${e}`),t,n]}try{let i=0,[s,o,u]=r(),c=[].slice.call(o);while(c.length&&c[c.length-1]===void 0)c.pop();let p=u||c.length;if(p<s.demanded.length)throw new Q(`Not enough arguments provided. Expected ${s.demanded.length} but received ${c.length}.`);let b=s.demanded.length+s.optional.length;if(p>b)throw new Q(`Too many arguments provided. Expected max ${b} but received ${p}.`);s.demanded.forEach((g)=>{let D=c.shift(),F=oi(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)ai(F,g.cmd,i);i+=1}),s.optional.forEach((g)=>{if(c.length===0)return;let D=c.shift(),F=oi(D);if(g.cmd.filter((h)=>h===F||h==="*").length===0)ai(F,g.cmd,i);i+=1})}catch(i){console.warn(i.stack)}}function oi(e){if(Array.isArray(e))return"array";else if(e===null)return"null";return typeof e}function ai(e,t,n){throw new Q(`Invalid ${Ja[n]||"manyith"} argument. Expected ${t.join(" or ")} but received ${e}.`)}class vn{constructor(e){this.globalMiddleware=[],this.frozens=[],this.yargs=e}addMiddleware(e,t,n=!0,r=!1){if(x("<array|function> [boolean] [boolean] [boolean]",[e,t,n],arguments.length),Array.isArray(e)){for(let i=0;i<e.length;i++){if(typeof e[i]!=="function")throw Error("middleware must be a function");let s=e[i];s.applyBeforeValidation=t,s.global=n}Array.prototype.push.apply(this.globalMiddleware,e)}else if(typeof e==="function"){let i=e;i.applyBeforeValidation=t,i.global=n,i.mutates=r,this.globalMiddleware.push(e)}return this.yargs}addCoerceMiddleware(e,t){let n=this.yargs.getAliases();return this.globalMiddleware=this.globalMiddleware.filter((r)=>{let i=[...n[t]||[],t];if(!r.option)return!0;else return!i.includes(r.option)}),e.option=t,this.addMiddleware(e,!0,!0,!0)}getMiddleware(){return this.globalMiddleware}freeze(){this.frozens.push([...this.globalMiddleware])}unfreeze(){let e=this.frozens.pop();if(e!==void 0)this.globalMiddleware=e}reset(){this.globalMiddleware=this.globalMiddleware.filter((e)=>e.global)}}function ui(e){if(!e)return[];return e.map((t)=>(t.applyBeforeValidation=!1,t))}function Ke(e,t,n,r){return n.reduce((i,s)=>{if(s.applyBeforeValidation!==r)return i;if(s.mutates){if(s.applied)return i;s.applied=!0}if(J(i))return i.then((o)=>Promise.all([o,s(o,t)])).then(([o,u])=>Object.assign(o,u));else{let o=s(i,t);return J(o)?o.then((u)=>Object.assign(i,u)):Object.assign(i,o)}},e)}function qe(e,t,n=(r)=>{throw r}){try{let r=Ka(e)?e():e;return J(r)?r.then((i)=>t(i)):t(r)}catch(r){return n(r)}}function Ka(e){return typeof e==="function"}var ht=/(^\*)|(^\$0)/;class ci{constructor(e,t,n,r){this.requireCache=new Set,this.handlers={},this.aliasMap={},this.frozens=[],this.shim=r,this.usage=e,this.globalMiddleware=n,this.validation=t}addDirectory(e,t,n,r){r=r||{},this.requireCache.add(n);let i=this.shim.path.resolve(this.shim.path.dirname(n),e),s=this.shim.readdirSync(i,{recursive:r.recurse?!0:!1});if(!Array.isArray(r.extensions))r.extensions=["js"];let o=typeof r.visit==="function"?r.visit:(u)=>u;for(let u of s){let c=u.toString();if(r.exclude){let b=!1;if(typeof r.exclude==="function")b=r.exclude(c);else b=r.exclude.test(c);if(b)continue}if(r.include){let b=!1;if(typeof r.include==="function")b=r.include(c);else b=r.include.test(c);if(!b)continue}let p=!1;for(let b of r.extensions)if(c.endsWith(b))p=!0;if(p){let b=this.shim.path.join(i,c),g=t(b),D=Object.create(null,Object.getOwnPropertyDescriptors({...g}));if(o(D,b,c)){if(this.requireCache.has(b))continue;else this.requireCache.add(b);if(!D.command)D.command=this.shim.path.basename(b,this.shim.path.extname(b));this.addHandler(D)}}}}addHandler(e,t,n,r,i,s){let o=[],u=ui(i);if(r=r||(()=>{}),Array.isArray(e))if(qa(e))[e,...o]=e;else for(let c of e)this.addHandler(c);else if(Za(e)){let c=Array.isArray(e.command)||typeof e.command==="string"?e.command:null;if(c===null)throw Error(`No command name given for module: ${this.shim.inspect(e)}`);if(e.aliases)c=[].concat(c).concat(e.aliases);this.addHandler(c,this.extractDesc(e),e.builder,e.handler,e.middlewares,e.deprecated);return}else if(li(n)){this.addHandler([e].concat(o),t,n.builder,n.handler,n.middlewares,n.deprecated);return}if(typeof e==="string"){let c=Re(e);o=o.map((g)=>Re(g).cmd);let p=!1,b=[c.cmd].concat(o).filter((g)=>{if(ht.test(g))return p=!0,!1;return!0});if(b.length===0&&p)b.push("$0");if(p)c.cmd=b[0],o=b.slice(1),e=e.replace(ht,c.cmd);if(o.forEach((g)=>{this.aliasMap[g]=c.cmd}),t!==!1)this.usage.command(e,t,p,o,s);if(this.handlers[c.cmd]={original:e,description:t,handler:r,builder:n||{},middlewares:u,deprecated:s,demanded:c.demanded,optional:c.optional},p)this.defaultCommand=this.handlers[c.cmd]}}getCommandHandlers(){return this.handlers}getCommands(){return Object.keys(this.handlers).concat(Object.keys(this.aliasMap))}hasDefaultCommand(){return!!this.defaultCommand}runCommand(e,t,n,r,i,s){let o=this.handlers[e]||this.handlers[this.aliasMap[e]]||this.defaultCommand,u=t.getInternalMethods().getContext(),c=u.commands.slice(),p=!e;if(e)u.commands.push(e),u.fullCommands.push(o.original);let b=this.applyBuilderUpdateUsageAndParse(p,o,t,n.aliases,c,r,i,s);return J(b)?b.then((g)=>this.applyMiddlewareAndGetResult(p,o,g.innerArgv,u,i,g.aliases,t)):this.applyMiddlewareAndGetResult(p,o,b.innerArgv,u,i,b.aliases,t)}applyBuilderUpdateUsageAndParse(e,t,n,r,i,s,o,u){let c=t.builder,p=n;if(Wt(c)){n.getInternalMethods().getUsageInstance().freeze();let b=c(n.getInternalMethods().reset(r),u);if(J(b))return b.then((g)=>(p=fi(g)?g:n,this.parseAndUpdateUsage(e,t,p,i,s,o)))}else if(Xa(c))n.getInternalMethods().getUsageInstance().freeze(),p=n.getInternalMethods().reset(r),Object.keys(t.builder).forEach((b)=>{p.option(b,c[b])});return this.parseAndUpdateUsage(e,t,p,i,s,o)}parseAndUpdateUsage(e,t,n,r,i,s){if(e)n.getInternalMethods().getUsageInstance().unfreeze(!0);if(this.shouldUpdateUsage(n))n.getInternalMethods().getUsageInstance().usage(this.usageFromParentCommandsCommandHandler(r,t),t.description);let o=n.getInternalMethods().runYargsParserAndExecuteCommands(null,void 0,!0,i,s);return J(o)?o.then((u)=>({aliases:n.parsed.aliases,innerArgv:u})):{aliases:n.parsed.aliases,innerArgv:o}}shouldUpdateUsage(e){return!e.getInternalMethods().getUsageInstance().getUsageDisabled()&&e.getInternalMethods().getUsageInstance().getUsage().length===0}usageFromParentCommandsCommandHandler(e,t){let n=ht.test(t.original)?t.original.replace(ht,"").trim():t.original,r=e.filter((i)=>!ht.test(i));return r.push(n),`$0 ${r.join(" ")}`}handleValidationAndGetResult(e,t,n,r,i,s,o,u){if(!s.getInternalMethods().getHasOutput()){let c=s.getInternalMethods().runValidation(i,u,s.parsed.error,e);n=qe(n,(p)=>(c(p),p))}if(t.handler&&!s.getInternalMethods().getHasOutput()){s.getInternalMethods().setHasOutput();let c=!!s.getOptions().configuration["populate--"];if(s.getInternalMethods().postProcess(n,c,!1,!1),n=Ke(n,s,o,!1),n=qe(n,(p)=>{let b=t.handler(p);return J(b)?b.then(()=>p):p}),!e)s.getInternalMethods().getUsageInstance().cacheHelpMessage();if(J(n)&&!s.getInternalMethods().hasParseCallback())n.catch((p)=>{try{s.getInternalMethods().getUsageInstance().fail(null,p)}catch(b){}})}if(!e)r.commands.pop(),r.fullCommands.pop();return n}applyMiddlewareAndGetResult(e,t,n,r,i,s,o){let u={};if(i)return n;if(!o.getInternalMethods().getHasOutput())u=this.populatePositionals(t,n,r,o);let c=this.globalMiddleware.getMiddleware().slice(0).concat(t.middlewares),p=Ke(n,o,c,!0);return J(p)?p.then((b)=>this.handleValidationAndGetResult(e,t,b,r,s,o,c,u)):this.handleValidationAndGetResult(e,t,p,r,s,o,c,u)}populatePositionals(e,t,n,r){t._=t._.slice(n.commands.length);let i=e.demanded.slice(0),s=e.optional.slice(0),o={};this.validation.positionalCount(i.length,t._.length);while(i.length){let u=i.shift();this.populatePositional(u,t,o)}while(s.length){let u=s.shift();this.populatePositional(u,t,o)}return t._=n.commands.concat(t._.map((u)=>""+u)),this.postProcessPositionals(t,o,this.cmdToParseOptions(e.original),r),o}populatePositional(e,t,n){let r=e.cmd[0];if(e.variadic)n[r]=t._.splice(0).map(String);else if(t._.length)n[r]=[String(t._.shift())]}cmdToParseOptions(e){let t={array:[],default:{},alias:{},demand:{}},n=Re(e);return n.demanded.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)t.array.push(i),t.default[i]=[];t.alias[i]=s,t.demand[i]=!0}),n.optional.forEach((r)=>{let[i,...s]=r.cmd;if(r.variadic)t.array.push(i),t.default[i]=[];t.alias[i]=s}),t}postProcessPositionals(e,t,n,r){let i=Object.assign({},r.getOptions());i.default=Object.assign(n.default,i.default);for(let c of Object.keys(n.alias))i.alias[c]=(i.alias[c]||[]).concat(n.alias[c]);i.array=i.array.concat(n.array),i.config={};let s=[];if(Object.keys(t).forEach((c)=>{t[c].map((p)=>{if(i.configuration["unknown-options-as-args"])i.key[c]=!0;s.push(`--${c}`),s.push(p)})}),!s.length)return;let o=Object.assign({},i.configuration,{"populate--":!1}),u=this.shim.Parser.detailed(s,Object.assign({},i,{configuration:o}));if(u.error)r.getInternalMethods().getUsageInstance().fail(u.error.message,u.error);else{let c=Object.keys(t);Object.keys(t).forEach((p)=>{c.push(...u.aliases[p])}),Object.keys(u.argv).forEach((p)=>{if(c.includes(p)){if(!t[p])t[p]=u.argv[p];if(!this.isInConfigs(r,p)&&!this.isDefaulted(r,p)&&Object.prototype.hasOwnProperty.call(e,p)&&Object.prototype.hasOwnProperty.call(u.argv,p)&&(Array.isArray(e[p])||Array.isArray(u.argv[p])))e[p]=[].concat(e[p],u.argv[p]);else e[p]=u.argv[p]}})}}isDefaulted(e,t){let{default:n}=e.getOptions();return Object.prototype.hasOwnProperty.call(n,t)||Object.prototype.hasOwnProperty.call(n,this.shim.Parser.camelCase(t))}isInConfigs(e,t){let{configObjects:n}=e.getOptions();return n.some((r)=>Object.prototype.hasOwnProperty.call(r,t))||n.some((r)=>Object.prototype.hasOwnProperty.call(r,this.shim.Parser.camelCase(t)))}runDefaultBuilderOn(e){if(!this.defaultCommand)return;if(this.shouldUpdateUsage(e)){let n=ht.test(this.defaultCommand.original)?this.defaultCommand.original:this.defaultCommand.original.replace(/^[^[\]<>]*/,"$0 ");e.getInternalMethods().getUsageInstance().usage(n,this.defaultCommand.description)}let t=this.defaultCommand.builder;if(Wt(t))return t(e,!0);else if(!li(t))Object.keys(t).forEach((n)=>{e.option(n,t[n])});return}extractDesc({describe:e,description:t,desc:n}){for(let r of[e,t,n]){if(typeof r==="string"||r===!1)return r;he(r,!0,this.shim)}return!1}freeze(){this.frozens.push({handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand})}unfreeze(){let e=this.frozens.pop();he(e,void 0,this.shim),{handlers:this.handlers,aliasMap:this.aliasMap,defaultCommand:this.defaultCommand}=e}reset(){return this.handlers={},this.aliasMap={},this.defaultCommand=void 0,this.requireCache=new Set,this}}function di(e,t,n,r){return new ci(e,t,n,r)}function li(e){return typeof e==="object"&&!!e.builder&&typeof e.handler==="function"}function qa(e){return e.every((t)=>typeof t==="string")}function Wt(e){return typeof e==="function"}function Xa(e){return typeof e==="object"}function Za(e){return typeof e==="object"&&!Array.isArray(e)}function Ie(e={},t=()=>!0){let n={};return ft(e).forEach((r)=>{if(t(r,e[r]))n[r]=e[r]}),n}function Te(e){if(typeof process>"u")return;[process.stdout,process.stderr].forEach((t)=>{let n=t;if(n._handle&&n.isTTY&&typeof n._handle.setBlocking==="function")n._handle.setBlocking(e)})}function Qa(e){return typeof e==="boolean"}function Di(e,t){let n=t.y18n.__,r={},i=[];r.failFn=function(C){i.push(C)};let s=null,o=null,u=!0;r.showHelpOnFail=function(C=!0,_){let[N,V]=typeof C==="string"?[!0,C]:[C,_];if(e.getInternalMethods().isGlobalContext())o=V;return s=V,u=N,r};let c=!1;r.fail=function(C,_){let N=e.getInternalMethods().getLoggerInstance();if(i.length)for(let V=i.length-1;V>=0;--V){let te=i[V];if(Qa(te)){if(_)throw _;else if(C)throw Error(C)}else te(C,_,r)}else{if(e.getExitProcess())Te(!0);if(!c){if(c=!0,u)e.showHelp("error"),N.error();if(C||_)N.error(C||_);let V=s||o;if(V){if(C||_)N.error("");N.error(V)}}if(_=_||new Q(C),e.getExitProcess())return e.exit(1);else if(e.getInternalMethods().hasParseCallback())return e.exit(1,_);else throw _}};let p=[],b=!1;r.usage=(P,C)=>{if(P===null)return b=!0,p=[],r;return b=!1,p.push([P,C||""]),r},r.getUsage=()=>p,r.getUsageDisabled=()=>b,r.getPositionalGroupName=()=>n("Positionals:");let g=[];r.example=(P,C)=>{g.push([P,C||""])};let D=[];r.command=function(C,_,N,V,te=!1){if(N)D=D.map((H)=>(H[2]=!1,H));D.push([C,_||"",N,V,te])},r.getCommands=()=>D;let F={};r.describe=function(C,_){if(Array.isArray(C))C.forEach((N)=>{r.describe(N,_)});else if(typeof C==="object")Object.keys(C).forEach((N)=>{r.describe(N,C[N])});else F[C]=_},r.getDescriptions=()=>F;let y=[];r.epilog=(P)=>{y.push(P)};let h=!1,v;r.wrap=(P)=>{h=!0,v=P},r.getWrap=()=>{if(t.getEnv("YARGS_DISABLE_WRAP"))return null;if(!h)v=Pe(),h=!0;return v};let W="__yargsString__:";r.deferY18nLookup=(P)=>W+P,r.help=function(){if(I)return I;ce();let C=e.customScriptName?e.$0:t.path.basename(e.$0),_=e.getDemandedOptions(),N=e.getDemandedCommands(),V=e.getDeprecatedOptions(),te=e.getGroups(),H=e.getOptions(),re=[];re=re.concat(Object.keys(F)),re=re.concat(Object.keys(_)),re=re.concat(Object.keys(N)),re=re.concat(Object.keys(H.default)),re=re.filter(ne),re=Object.keys(re.reduce((k,G)=>{if(G!=="_")k[G]=!0;return k},{}));let Ne=r.getWrap(),U=t.cliui({width:Ne,wrap:!!Ne});if(!b){if(p.length)p.forEach((k)=>{if(U.div({text:`${k[0].replace(/\$0/g,C)}`}),k[1])U.div({text:`${k[1]}`,padding:[1,0,0,0]})}),U.div();else if(D.length){let k=null;if(N._)k=`${C} <${n("command")}>
|
|
15
|
+
`;else k=`${C} [${n("command")}]
|
|
16
|
+
`;U.div(`${k}`)}}if(D.length>1||D.length===1&&!D[0][2]){U.div(n("Commands:"));let k=e.getInternalMethods().getContext(),G=k.commands.length?`${k.commands.join(" ")} `:"";if(e.getInternalMethods().getParserConfiguration()["sort-commands"]===!0)D=D.sort((L,ue)=>L[0].localeCompare(ue[0]));let ie=C?`${C} `:"";D.forEach((L)=>{let ue=`${ie}${G}${L[0].replace(/^\$0 ?/,"")}`;U.span({text:ue,padding:[0,2,0,2],width:T(D,Ne,`${C}${G}`)+4},{text:L[1]});let Z=[];if(L[2])Z.push(`[${n("default")}]`);if(L[3]&&L[3].length)Z.push(`[${n("aliases:")} ${L[3].join(", ")}]`);if(L[4])if(typeof L[4]==="string")Z.push(`[${n("deprecated: %s",L[4])}]`);else Z.push(`[${n("deprecated")}]`);if(Z.length)U.div({text:Z.join(" "),padding:[0,0,0,2],align:"right"});else U.div()}),U.div()}let ve=(Object.keys(H.alias)||[]).concat(Object.keys(e.parsed.newAliases)||[]);re=re.filter((k)=>!e.parsed.newAliases[k]&&ve.every((G)=>(H.alias[G]||[]).indexOf(k)===-1));let wt=n("Options:");if(!te[wt])te[wt]=[];Y(re,H.alias,te,wt);let j=(k)=>/^--/.test(Ht(k)),dt=Object.keys(te).filter((k)=>te[k].length>0).map((k)=>{let G=te[k].filter(ne).map((ie)=>{if(ve.includes(ie))return ie;for(let L=0,ue;(ue=ve[L])!==void 0;L++)if((H.alias[ue]||[]).includes(ie))return ue;return ie});return{groupName:k,normalizedKeys:G}}).filter(({normalizedKeys:k})=>k.length>0).map(({groupName:k,normalizedKeys:G})=>{let ie=G.reduce((L,ue)=>(L[ue]=[ue].concat(H.alias[ue]||[]).map((Z)=>{if(k===r.getPositionalGroupName())return Z;else return(/^[0-9]$/.test(Z)?H.boolean.includes(ue)?"-":"--":Z.length>1?"--":"-")+Z}).sort((Z,se)=>j(Z)===j(se)?0:j(Z)?1:-1).join(", "),L),{});return{groupName:k,normalizedKeys:G,switches:ie}});if(dt.filter(({groupName:k})=>k!==r.getPositionalGroupName()).some(({normalizedKeys:k,switches:G})=>!k.every((ie)=>j(G[ie]))))dt.filter(({groupName:k})=>k!==r.getPositionalGroupName()).forEach(({normalizedKeys:k,switches:G})=>{k.forEach((ie)=>{if(j(G[ie]))G[ie]=eu(G[ie],4)})});if(dt.forEach(({groupName:k,normalizedKeys:G,switches:ie})=>{U.div(k),G.forEach((L)=>{let ue=ie[L],Z=F[L]||"",se=null;if(Z.includes(W))Z=n(Z.substring(W.length));if(H.boolean.includes(L))se=`[${n("boolean")}]`;if(H.count.includes(L))se=`[${n("count")}]`;if(H.string.includes(L))se=`[${n("string")}]`;if(H.normalize.includes(L))se=`[${n("string")}]`;if(H.array.includes(L))se=`[${n("array")}]`;if(H.number.includes(L))se=`[${n("number")}]`;let pn=(E)=>typeof E==="string"?`[${n("deprecated: %s",E)}]`:`[${n("deprecated")}]`,l=[L in V?pn(V[L]):null,se,L in _?`[${n("required")}]`:null,H.choices&&H.choices[L]?`[${n("choices:")} ${r.stringifiedValues(H.choices[L])}]`:null,X(H.default[L],H.defaultDescription[L])].filter(Boolean).join(" ");U.span({text:Ht(ue),padding:[0,2,0,2+hi(ue)],width:T(ie,Ne)+4},Z);let f=e.getInternalMethods().getUsageConfiguration()["hide-types"]===!0;if(l&&!f)U.div({text:l,padding:[0,0,0,2],align:"right"});else U.div()}),U.div()}),g.length)U.div(n("Examples:")),g.forEach((k)=>{k[0]=k[0].replace(/\$0/g,C)}),g.forEach((k)=>{if(k[1]==="")U.div({text:k[0],padding:[0,2,0,2]});else U.div({text:k[0],padding:[0,2,0,2],width:T(g,Ne)+4},{text:k[1]})}),U.div();if(y.length>0){let k=y.map((G)=>G.replace(/\$0/g,C)).join(`
|
|
17
17
|
`);U.div(`${k}
|
|
18
|
-
`)}return U.toString().replace(/\s*$/,"")};function T(P,C,_){let N=0;if(!Array.isArray(P))P=Object.values(P).map((V)=>[V]);if(P.forEach((V)=>{N=Math.max(
|
|
18
|
+
`)}return U.toString().replace(/\s*$/,"")};function T(P,C,_){let N=0;if(!Array.isArray(P))P=Object.values(P).map((V)=>[V]);if(P.forEach((V)=>{N=Math.max(t.stringWidth(_?`${_} ${Ht(V[0])}`:Ht(V[0]))+hi(V[0]),N)}),C)N=Math.min(N,parseInt((C*0.5).toString(),10));return N}function ce(){let P=e.getDemandedOptions(),C=e.getOptions();(Object.keys(C.alias)||[]).forEach((_)=>{C.alias[_].forEach((N)=>{if(F[N])r.describe(_,F[N]);if(N in P)e.demandOption(_,P[N]);if(C.boolean.includes(N))e.boolean(_);if(C.count.includes(N))e.count(_);if(C.string.includes(N))e.string(_);if(C.normalize.includes(N))e.normalize(_);if(C.array.includes(N))e.array(_);if(C.number.includes(N))e.number(_)})})}let I;r.cacheHelpMessage=function(){I=this.help()},r.clearCachedHelpMessage=function(){I=void 0},r.hasCachedHelpMessage=function(){return!!I};function Y(P,C,_,N){let V=[],te=null;return Object.keys(_).forEach((H)=>{V=V.concat(_[H])}),P.forEach((H)=>{if(te=[H].concat(C[H]),!te.some((re)=>V.indexOf(re)!==-1))_[N].push(H)}),V}function ne(P){return e.getOptions().hiddenOptions.indexOf(P)<0||e.parsed.argv[e.getOptions().showHiddenOpt]}r.showHelp=(P)=>{let C=e.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:C[P])(r.help())},r.functionDescription=(P)=>["(",P.name?t.Parser.decamelize(P.name,"-"):n("generated-value"),")"].join(""),r.stringifiedValues=function(C,_){let N="",V=_||", ",te=[].concat(C);if(!C||!te.length)return N;return te.forEach((H)=>{if(N.length)N+=V;N+=JSON.stringify(H)}),N};function X(P,C){let _=`[${n("default:")} `;if(P===void 0&&!C)return null;if(C)_+=C;else switch(typeof P){case"string":_+=`"${P}"`;break;case"object":_+=JSON.stringify(P);break;default:_+=P}return`${_}]`}function Pe(){if(t.process.stdColumns)return Math.min(80,t.process.stdColumns);else return 80}let z=null;r.version=(P)=>{z=P},r.showVersion=(P)=>{let C=e.getInternalMethods().getLoggerInstance();if(!P)P="error";(typeof P==="function"?P:C[P])(z)},r.reset=function(C){return s=null,c=!1,p=[],b=!1,y=[],g=[],D=[],F=Ie(F,(_)=>!C[_]),r};let Ct=[];return r.freeze=function(){Ct.push({failMessage:s,failureOutput:c,usages:p,usageDisabled:b,epilogs:y,examples:g,commands:D,descriptions:F})},r.unfreeze=function(C=!1){let _=Ct.pop();if(!_)return;if(C)F={..._.descriptions,...F},D=[..._.commands,...D],p=[..._.usages,...p],g=[..._.examples,...g],y=[..._.epilogs,...y];else({failMessage:s,failureOutput:c,usages:p,usageDisabled:b,epilogs:y,examples:g,commands:D,descriptions:F}=_)},r}function jn(e){return typeof e==="object"}function eu(e,t){return jn(e)?{text:e.text,indentation:e.indentation+t}:{text:e,indentation:t}}function hi(e){return jn(e)?e.indentation:0}function Ht(e){return jn(e)?e.text:e}var gi=`###-begin-{{app_name}}-completions-###
|
|
19
19
|
#
|
|
20
20
|
# yargs command completion script
|
|
21
21
|
#
|
|
@@ -44,7 +44,7 @@ _{{app_name}}_yargs_completions()
|
|
|
44
44
|
}
|
|
45
45
|
complete -o bashdefault -o default -F _{{app_name}}_yargs_completions {{app_name}}
|
|
46
46
|
###-end-{{app_name}}-completions-###
|
|
47
|
-
`,
|
|
47
|
+
`,pi=`#compdef {{app_name}}
|
|
48
48
|
###-begin-{{app_name}}-completions-###
|
|
49
49
|
#
|
|
50
50
|
# yargs command completion script
|
|
@@ -71,14 +71,14 @@ else
|
|
|
71
71
|
compdef _{{app_name}}_yargs_completions {{app_name}}
|
|
72
72
|
fi
|
|
73
73
|
###-end-{{app_name}}-completions-###
|
|
74
|
-
`;class
|
|
74
|
+
`;class mi{constructor(e,t,n,r){var i,s,o;this.yargs=e,this.usage=t,this.command=n,this.shim=r,this.completionKey="get-yargs-completions",this.aliases=null,this.customCompletionFunction=null,this.indexAfterLastReset=0,this.zshShell=(o=((i=this.shim.getEnv("SHELL"))===null||i===void 0?void 0:i.includes("zsh"))||((s=this.shim.getEnv("ZSH_NAME"))===null||s===void 0?void 0:s.includes("zsh")))!==null&&o!==void 0?o:!1}defaultCompletion(e,t,n,r){let i=this.command.getCommandHandlers();for(let o=0,u=e.length;o<u;++o)if(i[e[o]]&&i[e[o]].builder){let c=i[e[o]].builder;if(Wt(c)){this.indexAfterLastReset=o+1;let p=this.yargs.getInternalMethods().reset();return c(p,!0),p.argv}}let s=[];this.commandCompletions(s,e,n),this.optionCompletions(s,e,t,n),this.choicesFromOptionsCompletions(s,e,t,n),this.choicesFromPositionalsCompletions(s,e,t,n),r(null,s)}commandCompletions(e,t,n){let r=this.yargs.getInternalMethods().getContext().commands;if(!n.match(/^-/)&&r[r.length-1]!==n&&!this.previousArgHasChoices(t))this.usage.getCommands().forEach((i)=>{let s=Re(i[0]).cmd;if(t.indexOf(s)===-1)if(!this.zshShell)e.push(s);else{let o=i[1]||"";e.push(s.replace(/:/g,"\\:")+":"+o)}})}optionCompletions(e,t,n,r){if((r.match(/^-/)||r===""&&e.length===0)&&!this.previousArgHasChoices(t)){let i=this.yargs.getOptions(),s=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[];Object.keys(i.key).forEach((o)=>{let u=!!i.configuration["boolean-negation"]&&i.boolean.includes(o);if(!s.includes(o)&&!i.hiddenOptions.includes(o)&&!this.argsContainKey(t,o,u))this.completeOptionKey(o,e,r,u&&!!i.default[o])})}}choicesFromOptionsCompletions(e,t,n,r){if(this.previousArgHasChoices(t)){let i=this.getPreviousArgChoices(t);if(i&&i.length>0)e.push(...i.map((s)=>s.replace(/:/g,"\\:")))}}choicesFromPositionalsCompletions(e,t,n,r){if(r===""&&e.length>0&&this.previousArgHasChoices(t))return;let i=this.yargs.getGroups()[this.usage.getPositionalGroupName()]||[],s=Math.max(this.indexAfterLastReset,this.yargs.getInternalMethods().getContext().commands.length+1),o=i[n._.length-s-1];if(!o)return;let u=this.yargs.getOptions().choices[o]||[];for(let c of u)if(c.startsWith(r))e.push(c.replace(/:/g,"\\:"))}getPreviousArgChoices(e){if(e.length<1)return;let t=e[e.length-1],n="";if(!t.startsWith("-")&&e.length>1)n=t,t=e[e.length-2];if(!t.startsWith("-"))return;let r=t.replace(/^-+/,""),i=this.yargs.getOptions(),s=[r,...this.yargs.getAliases()[r]||[]],o;for(let u of s)if(Object.prototype.hasOwnProperty.call(i.key,u)&&Array.isArray(i.choices[u])){o=i.choices[u];break}if(o)return o.filter((u)=>!n||u.startsWith(n))}previousArgHasChoices(e){let t=this.getPreviousArgChoices(e);return t!==void 0&&t.length>0}argsContainKey(e,t,n){let r=(i)=>e.indexOf((/^[^0-9]$/.test(i)?"-":"--")+i)!==-1;if(r(t))return!0;if(n&&r(`no-${t}`))return!0;if(this.aliases){for(let i of this.aliases[t])if(r(i))return!0}return!1}completeOptionKey(e,t,n,r){var i,s,o,u;let c=e;if(this.zshShell){let D=this.usage.getDescriptions(),F=(s=(i=this===null||this===void 0?void 0:this.aliases)===null||i===void 0?void 0:i[e])===null||s===void 0?void 0:s.find((v)=>{let W=D[v];return typeof W==="string"&&W.length>0}),y=F?D[F]:void 0,h=(u=(o=D[e])!==null&&o!==void 0?o:y)!==null&&u!==void 0?u:"";c=`${e.replace(/:/g,"\\:")}:${h.replace("__yargsString__:","").replace(/(\r\n|\n|\r)/gm," ")}`}let p=(D)=>/^--/.test(D),b=(D)=>/^[^0-9]$/.test(D),g=!p(n)&&b(e)?"-":"--";if(t.push(g+c),r)t.push(g+"no-"+c)}customCompletion(e,t,n,r){if(he(this.customCompletionFunction,null,this.shim),nu(this.customCompletionFunction)){let i=this.customCompletionFunction(n,t);if(J(i))return i.then((s)=>{this.shim.process.nextTick(()=>{r(null,s)})}).catch((s)=>{this.shim.process.nextTick(()=>{r(s,void 0)})});return r(null,i)}else if(ru(this.customCompletionFunction))return this.customCompletionFunction(n,t,(i=r)=>this.defaultCompletion(e,t,n,i),(i)=>{r(null,i)});else return this.customCompletionFunction(n,t,(i)=>{r(null,i)})}getCompletion(e,t){let n=e.length?e[e.length-1]:"",r=this.yargs.parse(e,!0),i=this.customCompletionFunction?(s)=>this.customCompletion(e,s,n,t):(s)=>this.defaultCompletion(e,s,n,t);return J(r)?r.then(i):i(r)}generateCompletionScript(e,t){let n=this.zshShell?pi:gi,r=this.shim.path.basename(e);if(e.match(/\.js$/))e=`./${e}`;return n=n.replace(/{{app_name}}/g,r),n=n.replace(/{{completion_command}}/g,t),n.replace(/{{app_path}}/g,e)}registerFunction(e){this.customCompletionFunction=e}setParsed(e){this.aliases=e.aliases}}function Fi(e,t,n,r){return new mi(e,t,n,r)}function nu(e){return e.length<3}function ru(e){return e.length>3}function yi(e,t){if(e.length===0)return t.length;if(t.length===0)return e.length;let n=[],r;for(r=0;r<=t.length;r++)n[r]=[r];let i;for(i=0;i<=e.length;i++)n[0][i]=i;for(r=1;r<=t.length;r++)for(i=1;i<=e.length;i++)if(t.charAt(r-1)===e.charAt(i-1))n[r][i]=n[r-1][i-1];else if(r>1&&i>1&&t.charAt(r-2)===e.charAt(i-1)&&t.charAt(r-1)===e.charAt(i-2))n[r][i]=n[r-2][i-2]+1;else n[r][i]=Math.min(n[r-1][i-1]+1,Math.min(n[r][i-1]+1,n[r-1][i]+1));return n[t.length][e.length]}var bi=["$0","--","_"];function Ei(e,t,n){let r=n.y18n.__,i=n.y18n.__n,s={};s.nonOptionCount=function(g){let D=e.getDemandedCommands(),y=g._.length+(g["--"]?g["--"].length:0)-e.getInternalMethods().getContext().commands.length;if(D._&&(y<D._.min||y>D._.max)){if(y<D._.min)if(D._.minMsg!==void 0)t.fail(D._.minMsg?D._.minMsg.replace(/\$0/g,y.toString()).replace(/\$1/,D._.min.toString()):null);else t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",y,y.toString(),D._.min.toString()));else if(y>D._.max)if(D._.maxMsg!==void 0)t.fail(D._.maxMsg?D._.maxMsg.replace(/\$0/g,y.toString()).replace(/\$1/,D._.max.toString()):null);else t.fail(i("Too many non-option arguments: got %s, maximum of %s","Too many non-option arguments: got %s, maximum of %s",y,y.toString(),D._.max.toString()))}},s.positionalCount=function(g,D){if(D<g)t.fail(i("Not enough non-option arguments: got %s, need at least %s","Not enough non-option arguments: got %s, need at least %s",D,D+"",g+""))},s.requiredArguments=function(g,D){let F=null;for(let y of Object.keys(D))if(!Object.prototype.hasOwnProperty.call(g,y)||typeof g[y]>"u")F=F||{},F[y]=D[y];if(F){let y=[];for(let v of Object.keys(F)){let W=F[v];if(W&&y.indexOf(W)<0)y.push(W)}let h=y.length?`
|
|
75
75
|
${y.join(`
|
|
76
|
-
`)}`:"";
|
|
77
|
-
${r("Argument: %s, Given: %s, Choices: %s",v,
|
|
78
|
-
`;D.forEach((y)=>{F+=y}),n.fail(F)}};let c={};s.conflicts=function(g,D){if(x("<string|object> [array|string]",[g,D],arguments.length),typeof g==="object")Object.keys(g).forEach((F)=>{s.conflicts(F,g[F])});else{if(e.global(g),!c[g])c[g]=[];if(Array.isArray(D))D.forEach((F)=>s.conflicts(g,F));else c[g].push(D)}},s.getConflicting=()=>c,s.conflicting=function(g){if(Object.keys(g).forEach((D)=>{if(c[D])c[D].forEach((F)=>{if(F&&g[D]!==void 0&&g[F]!==void 0)n.fail(r("Arguments %s and %s are mutually exclusive",D,F))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((D)=>{c[D].forEach((F)=>{if(F&&g[t.Parser.camelCase(D)]!==void 0&&g[t.Parser.camelCase(F)]!==void 0)n.fail(r("Arguments %s and %s are mutually exclusive",D,F))})})},s.recommendCommands=function(g,D){D=D.sort((v,W)=>W.length-v.length);let y=null,h=1/0;for(let v=0,W;(W=D[v])!==void 0;v++){let T=mi(g,W);if(T<=3&&T<h)h=T,y=W}if(y)n.fail(r("Did you mean %s?",y))},s.reset=function(g){return o=Ie(o,(D)=>!g[D]),c=Ie(c,(D)=>!g[D]),s};let p=[];return s.freeze=function(){p.push({implied:o,conflicting:c})},s.unfreeze=function(){let g=p.pop();he(g,void 0,t),{implied:o,conflicting:c}=g},s}var jt=[],An;function Vn(e,n,t,r){An=r;let i={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return i;let s=/\.json|\..*rc$/.test(e.extends),o=null;if(!s)try{o=import.meta.resolve(e.extends)}catch(u){return e}else o=iu(n,e.extends);ru(o),jt.push(o),i=s?JSON.parse(An.readFileSync(o,"utf8")):r.require(e.extends),delete e.extends,i=Vn(i,An.path.dirname(o),t,An)}return jt=[],t?bi(i,e):Object.assign({},i,e)}function ru(e){if(jt.indexOf(e)>-1)throw new Q(`Circular extended configurations: '${e}'.`)}function iu(e,n){return An.path.resolve(e,n)}function bi(e,n){let t={};function r(i){return i&&typeof i==="object"&&!Array.isArray(i)}Object.assign(t,e);for(let i of Object.keys(n)){if(i==="__proto__")continue;if(r(n[i])&&r(t[i]))t[i]=bi(e[i],n[i]);else t[i]=n[i]}return t}var S=function(e,n,t,r,i){if(r==="m")throw TypeError("Private method is not writable");if(r==="a"&&!i)throw TypeError("Private accessor was defined without a setter");if(typeof n==="function"?e!==n||!i:!n.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(e,t):i?i.value=t:n.set(e,t),t},a=function(e,n,t,r){if(t==="a"&&!r)throw TypeError("Private accessor was defined without a getter");if(typeof n==="function"?e!==n||!r:!n.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return t==="m"?r:t==="a"?r.call(e):r?r.value:n.get(e)},ee,Xe,Pn,De,pe,zn,Le,Ze,Gn,be,Un,Ee,_e,me,Ce,Yn,Qe,ae,B,Jn,Kn,Fe,en,gn,nn,We,qn,M,tn,rn,sn,R,Xn,Be,q;function Li(e){return(n=[],t=e.process.cwd(),r)=>{let i=new Wi(n,t,r,e);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var Ei=Symbol("copyDoubleDash"),Ci=Symbol("copyDoubleDash"),kt=Symbol("deleteFromParserHintObject"),wi=Symbol("emitWarning"),xi=Symbol("freeze"),Si=Symbol("getDollarZero"),on=Symbol("getParserConfiguration"),Ai=Symbol("getUsageConfiguration"),Mt=Symbol("guessLocale"),Pi=Symbol("guessVersion"),_i=Symbol("parsePositionalNumbers"),Nt=Symbol("pkgUp"),He=Symbol("populateParserHintArray"),pn=Symbol("populateParserHintSingleValueDictionary"),Rt=Symbol("populateParserHintArrayDictionary"),It=Symbol("populateParserHintDictionary"),Tt=Symbol("sanitizeKey"),Lt=Symbol("setKey"),Wt=Symbol("unfreeze"),Bi=Symbol("validateAsync"),Oi=Symbol("getCommandInstance"),$i=Symbol("getContext"),vi=Symbol("getHasOutput"),ji=Symbol("getLoggerInstance"),ki=Symbol("getParseContext"),Mi=Symbol("getUsageInstance"),Ni=Symbol("getValidationInstance"),Zn=Symbol("hasParseCallback"),Ri=Symbol("isGlobalContext"),an=Symbol("postProcess"),Ii=Symbol("rebase"),Ht=Symbol("reset"),_n=Symbol("runYargsParserAndExecuteCommands"),Vt=Symbol("runValidation"),Ti=Symbol("setHasOutput"),un=Symbol("kTrackManuallySetKeys"),su="en_US";class Wi{constructor(e=[],n,t,r){this.customScriptName=!1,this.parsed=!1,ee.set(this,void 0),Xe.set(this,void 0),Pn.set(this,{commands:[],fullCommands:[]}),De.set(this,null),pe.set(this,null),zn.set(this,"show-hidden"),Le.set(this,null),Ze.set(this,!0),Gn.set(this,{}),be.set(this,!0),Un.set(this,[]),Ee.set(this,void 0),_e.set(this,{}),me.set(this,!1),Ce.set(this,null),Yn.set(this,!0),Qe.set(this,void 0),ae.set(this,""),B.set(this,void 0),Jn.set(this,void 0),Kn.set(this,{}),Fe.set(this,null),en.set(this,null),gn.set(this,{}),nn.set(this,{}),We.set(this,void 0),qn.set(this,!1),M.set(this,void 0),tn.set(this,!1),rn.set(this,!1),sn.set(this,!1),R.set(this,void 0),Xn.set(this,{}),Be.set(this,null),q.set(this,void 0),S(this,M,r,"f"),S(this,We,e,"f"),S(this,Xe,n,"f"),S(this,Jn,t,"f"),S(this,Ee,new $t(this),"f"),this.$0=this[Si](),this[Ht](),S(this,ee,a(this,ee,"f"),"f"),S(this,R,a(this,R,"f"),"f"),S(this,q,a(this,q,"f"),"f"),S(this,B,a(this,B,"f"),"f"),a(this,B,"f").showHiddenOpt=a(this,zn,"f"),S(this,Qe,this[Ci](),"f"),a(this,M,"f").y18n.setLocale(su)}addHelpOpt(e,n){if(x("[string|boolean] [string]",[e,n],arguments.length),a(this,Ce,"f"))this[kt](a(this,Ce,"f")),S(this,Ce,null,"f");if(e===!1&&n===void 0)return this;return S(this,Ce,typeof e==="string"?e:"help","f"),this.boolean(a(this,Ce,"f")),this.describe(a(this,Ce,"f"),n||a(this,R,"f").deferY18nLookup("Show help")),this}help(e,n){return this.addHelpOpt(e,n)}addShowHiddenOpt(e,n){if(x("[string|boolean] [string]",[e,n],arguments.length),e===!1&&n===void 0)return this;let t=typeof e==="string"?e:a(this,zn,"f");return this.boolean(t),this.describe(t,n||a(this,R,"f").deferY18nLookup("Show hidden options")),a(this,B,"f").showHiddenOpt=t,this}showHidden(e,n){return this.addShowHiddenOpt(e,n)}alias(e,n){return x("<object|string|array> [string|array]",[e,n],arguments.length),this[Rt](this.alias.bind(this),"alias",e,n),this}array(e){return x("<array|string>",[e],arguments.length),this[He]("array",e),this[un](e),this}boolean(e){return x("<array|string>",[e],arguments.length),this[He]("boolean",e),this[un](e),this}check(e,n){return x("<function> [boolean]",[e,n],arguments.length),this.middleware((t,r)=>qe(()=>e(t,r.getOptions()),(i)=>{if(!i)a(this,R,"f").fail(a(this,M,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof i==="string"||i instanceof Error)a(this,R,"f").fail(i.toString(),i);return t},(i)=>(a(this,R,"f").fail(i.message?i.message:i.toString(),i),t)),!1,n),this}choices(e,n){return x("<object|string|array> [string|array]",[e,n],arguments.length),this[Rt](this.choices.bind(this),"choices",e,n),this}coerce(e,n){if(x("<object|string|array> [function]",[e,n],arguments.length),Array.isArray(e)){if(!n)throw new Q("coerce callback must be provided");for(let r of e)this.coerce(r,n);return this}else if(typeof e==="object"){for(let r of Object.keys(e))this.coerce(r,e[r]);return this}if(!n)throw new Q("coerce callback must be provided");let t=e;return a(this,B,"f").key[t]=!0,a(this,Ee,"f").addCoerceMiddleware((r,i)=>{var s;let o=(s=i.getAliases()[t])!==null&&s!==void 0?s:[],u=[t,...o].filter((c)=>Object.prototype.hasOwnProperty.call(r,c));if(u.length===0)return r;return qe(()=>n(r[u[0]]),(c)=>(u.forEach((p)=>{r[p]=c}),r),(c)=>{throw new Q(c.message)})},t),this}conflicts(e,n){return x("<string|object> [string|array]",[e,n],arguments.length),a(this,q,"f").conflicts(e,n),this}config(e="config",n,t){if(x("[object|string] [string|function] [function]",[e,n,t],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=Vn(e,a(this,Xe,"f"),this[on]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(e),this;if(typeof n==="function")t=n,n=void 0;return this.describe(e,n||a(this,R,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((r)=>{a(this,B,"f").config[r]=t||!0}),this}completion(e,n,t){if(x("[string] [string|boolean|function] [function]",[e,n,t],arguments.length),typeof n==="function")t=n,n=void 0;if(S(this,pe,e||a(this,pe,"f")||"completion","f"),!n&&n!==!1)n="generate completion script";if(this.command(a(this,pe,"f"),n),t)a(this,De,"f").registerFunction(t);return this}command(e,n,t,r,i,s){return x("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,n,t,r,i,s],arguments.length),a(this,ee,"f").addHandler(e,n,t,r,i,s),this}commands(e,n,t,r,i,s){return this.command(e,n,t,r,i,s)}commandDir(e,n){x("<string> [object]",[e,n],arguments.length);let t=a(this,Jn,"f")||a(this,M,"f").require;return a(this,ee,"f").addDirectory(e,t,a(this,M,"f").getCallerFile(),n),this}count(e){return x("<array|string>",[e],arguments.length),this[He]("count",e),this[un](e),this}default(e,n,t){if(x("<object|string|array> [*] [string]",[e,n,t],arguments.length),t)Ot(e,a(this,M,"f")),a(this,B,"f").defaultDescription[e]=t;if(typeof n==="function"){if(Ot(e,a(this,M,"f")),!a(this,B,"f").defaultDescription[e])a(this,B,"f").defaultDescription[e]=a(this,R,"f").functionDescription(n);n=n.call()}return this[pn](this.default.bind(this),"default",e,n),this}defaults(e,n,t){return this.default(e,n,t)}demandCommand(e=1,n,t,r){if(x("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,n,t,r],arguments.length),typeof n!=="number")t=n,n=1/0;return this.global("_",!1),a(this,B,"f").demandedCommands._={min:e,max:n,minMsg:t,maxMsg:r},this}demand(e,n,t){if(Array.isArray(n))n.forEach((r)=>{he(t,!0,a(this,M,"f")),this.demandOption(r,t)}),n=1/0;else if(typeof n!=="number")t=n,n=1/0;if(typeof e==="number")he(t,!0,a(this,M,"f")),this.demandCommand(e,n,t,t);else if(Array.isArray(e))e.forEach((r)=>{he(t,!0,a(this,M,"f")),this.demandOption(r,t)});else if(typeof t==="string")this.demandOption(e,t);else if(t===!0||typeof t>"u")this.demandOption(e);return this}demandOption(e,n){return x("<object|string|array> [string]",[e,n],arguments.length),this[pn](this.demandOption.bind(this),"demandedOptions",e,n),this}deprecateOption(e,n){return x("<string> [string|boolean]",[e,n],arguments.length),a(this,B,"f").deprecatedOptions[e]=n,this}describe(e,n){return x("<object|string|array> [string]",[e,n],arguments.length),this[Lt](e,!0),a(this,R,"f").describe(e,n),this}detectLocale(e){return x("<boolean>",[e],arguments.length),S(this,Ze,e,"f"),this}env(e){if(x("[string|boolean]",[e],arguments.length),e===!1)delete a(this,B,"f").envPrefix;else a(this,B,"f").envPrefix=e||"";return this}epilogue(e){return x("<string>",[e],arguments.length),a(this,R,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,n){if(x("<string|array> [string]",[e,n],arguments.length),Array.isArray(e))e.forEach((t)=>this.example(...t));else a(this,R,"f").example(e,n);return this}exit(e,n){if(S(this,me,!0,"f"),S(this,Le,n,"f"),a(this,be,"f"))a(this,M,"f").process.exit(e)}exitProcess(e=!0){return x("[boolean]",[e],arguments.length),S(this,be,e,"f"),this}fail(e){if(x("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new Q("Invalid first argument. Expected function or boolean 'false'");return a(this,R,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,n){if(x("<array> [function]",[e,n],arguments.length),!n)return new Promise((t,r)=>{a(this,De,"f").getCompletion(e,(i,s)=>{if(i)r(i);else t(s)})});else return a(this,De,"f").getCompletion(e,n)}getDemandedOptions(){return x([],0),a(this,B,"f").demandedOptions}getDemandedCommands(){return x([],0),a(this,B,"f").demandedCommands}getDeprecatedOptions(){return x([],0),a(this,B,"f").deprecatedOptions}getDetectLocale(){return a(this,Ze,"f")}getExitProcess(){return a(this,be,"f")}getGroups(){return Object.assign({},a(this,_e,"f"),a(this,nn,"f"))}getHelp(){if(S(this,me,!0,"f"),!a(this,R,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[_n](a(this,We,"f"),void 0,void 0,0,!0);if(J(n))return n.then(()=>a(this,R,"f").help())}let e=a(this,ee,"f").runDefaultBuilderOn(this);if(J(e))return e.then(()=>a(this,R,"f").help())}return Promise.resolve(a(this,R,"f").help())}getOptions(){return a(this,B,"f")}getStrict(){return a(this,tn,"f")}getStrictCommands(){return a(this,rn,"f")}getStrictOptions(){return a(this,sn,"f")}global(e,n){if(x("<string|array> [boolean]",[e,n],arguments.length),e=[].concat(e),n!==!1)a(this,B,"f").local=a(this,B,"f").local.filter((t)=>e.indexOf(t)===-1);else e.forEach((t)=>{if(!a(this,B,"f").local.includes(t))a(this,B,"f").local.push(t)});return this}group(e,n){x("<string|array> <string>",[e,n],arguments.length);let t=a(this,nn,"f")[n]||a(this,_e,"f")[n];if(a(this,nn,"f")[n])delete a(this,nn,"f")[n];let r={};return a(this,_e,"f")[n]=(t||[]).concat(e).filter((i)=>{if(r[i])return!1;return r[i]=!0}),this}hide(e){return x("<string>",[e],arguments.length),a(this,B,"f").hiddenOptions.push(e),this}implies(e,n){return x("<string|object> [number|string|array]",[e,n],arguments.length),a(this,q,"f").implies(e,n),this}locale(e){if(x("[string]",[e],arguments.length),e===void 0)return this[Mt](),a(this,M,"f").y18n.getLocale();return S(this,Ze,!1,"f"),a(this,M,"f").y18n.setLocale(e),this}middleware(e,n,t){return a(this,Ee,"f").addMiddleware(e,!!n,t)}nargs(e,n){return x("<string|object|array> [number]",[e,n],arguments.length),this[pn](this.nargs.bind(this),"narg",e,n),this}normalize(e){return x("<array|string>",[e],arguments.length),this[He]("normalize",e),this}number(e){return x("<array|string>",[e],arguments.length),this[He]("number",e),this[un](e),this}option(e,n){if(x("<string|object> [object]",[e,n],arguments.length),typeof e==="object")Object.keys(e).forEach((t)=>{this.options(t,e[t])});else{if(typeof n!=="object")n={};if(this[un](e),a(this,Be,"f")&&(e==="version"||(n===null||n===void 0?void 0:n.alias)==="version"))this[wi](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
79
|
-
`),void 0,"versionWarning");if(a(this,B,"f").key[e]=!0,
|
|
80
|
-
`,"f");S(this,ae,a(this,ae,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[
|
|
81
|
-
`,"f");S(this,ae,a(this,ae,"f")+e.join(" "),"f")}}}[kt](e){hn(a(this,B,"f")).forEach((n)=>{if(((r)=>r==="configObjects")(n))return;let t=a(this,B,"f")[n];if(Array.isArray(t)){if(t.includes(e))t.splice(t.indexOf(e),1)}else if(typeof t==="object")delete t[e]}),delete a(this,R,"f").getDescriptions()[e]}[wi](e,n,t){if(!a(this,Gn,"f")[t])a(this,M,"f").process.emitWarning(e,n),a(this,Gn,"f")[t]=!0}[xi](){a(this,Un,"f").push({options:a(this,B,"f"),configObjects:a(this,B,"f").configObjects.slice(0),exitProcess:a(this,be,"f"),groups:a(this,_e,"f"),strict:a(this,tn,"f"),strictCommands:a(this,rn,"f"),strictOptions:a(this,sn,"f"),completionCommand:a(this,pe,"f"),output:a(this,ae,"f"),exitError:a(this,Le,"f"),hasOutput:a(this,me,"f"),parsed:this.parsed,parseFn:a(this,Fe,"f"),parseContext:a(this,en,"f")}),a(this,R,"f").freeze(),a(this,q,"f").freeze(),a(this,ee,"f").freeze(),a(this,Ee,"f").freeze()}[Si](){let e="",n;if(/\b(node|iojs|electron|bun)(\.exe)?$/.test(a(this,M,"f").process.argv()[0]))n=a(this,M,"f").process.argv().slice(1,2);else n=a(this,M,"f").process.argv().slice(0,1);if(e=n.map((t)=>{let r=this[Ii](a(this,Xe,"f"),t);return t.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<t.length?r:t}).join(" ").trim(),a(this,M,"f").getEnv("_")&&a(this,M,"f").getProcessArgvBin()===a(this,M,"f").getEnv("_"))e=a(this,M,"f").getEnv("_").replace(`${a(this,M,"f").path.dirname(a(this,M,"f").process.execPath())}/`,"");return e}[on](){return a(this,Kn,"f")}[Ai](){return a(this,Xn,"f")}[Mt](){if(!a(this,Ze,"f"))return;let e=a(this,M,"f").getEnv("LC_ALL")||a(this,M,"f").getEnv("LC_MESSAGES")||a(this,M,"f").getEnv("LANG")||a(this,M,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Pi](){return this[Nt]().version||"unknown"}[_i](e){let n=e["--"]?e["--"]:e._;for(let t=0,r;(r=n[t])!==void 0;t++)if(a(this,M,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`))))n[t]=Number(r);return e}[Nt](e){let n=e||"*";if(a(this,gn,"f")[n])return a(this,gn,"f")[n];let t={};try{let r=e||a(this,M,"f").mainFilename;if(a(this,M,"f").path.extname(r))r=a(this,M,"f").path.dirname(r);let i=a(this,M,"f").findUp(r,(s,o)=>{if(o.includes("package.json"))return"package.json";else return});he(i,void 0,a(this,M,"f")),t=JSON.parse(a(this,M,"f").readFileSync(i,"utf8"))}catch(r){}return a(this,gn,"f")[n]=t||{},a(this,gn,"f")[n]}[He](e,n){n=[].concat(n),n.forEach((t)=>{t=this[Tt](t),a(this,B,"f")[e].push(t)})}[pn](e,n,t,r){this[It](e,n,t,r,(i,s,o)=>{a(this,B,"f")[i][s]=o})}[Rt](e,n,t,r){this[It](e,n,t,r,(i,s,o)=>{a(this,B,"f")[i][s]=(a(this,B,"f")[i][s]||[]).concat(o)})}[It](e,n,t,r,i){if(Array.isArray(t))t.forEach((s)=>{e(s,r)});else if(((s)=>typeof s==="object")(t))for(let s of hn(t))e(s,t[s]);else i(n,this[Tt](t),r)}[Tt](e){if(e==="__proto__")return"___proto___";return e}[Lt](e,n){return this[pn](this[Lt].bind(this),"key",e,n),this}[Wt](){var e,n,t,r,i,s,o,u,c,p,b,g;let D=a(this,Un,"f").pop();he(D,void 0,a(this,M,"f"));let F;e=this,n=this,t=this,r=this,i=this,s=this,o=this,u=this,c=this,p=this,b=this,g=this,{options:{set value(y){S(e,B,y,"f")}}.value,configObjects:F,exitProcess:{set value(y){S(n,be,y,"f")}}.value,groups:{set value(y){S(t,_e,y,"f")}}.value,output:{set value(y){S(r,ae,y,"f")}}.value,exitError:{set value(y){S(i,Le,y,"f")}}.value,hasOutput:{set value(y){S(s,me,y,"f")}}.value,parsed:this.parsed,strict:{set value(y){S(o,tn,y,"f")}}.value,strictCommands:{set value(y){S(u,rn,y,"f")}}.value,strictOptions:{set value(y){S(c,sn,y,"f")}}.value,completionCommand:{set value(y){S(p,pe,y,"f")}}.value,parseFn:{set value(y){S(b,Fe,y,"f")}}.value,parseContext:{set value(y){S(g,en,y,"f")}}.value}=D,a(this,B,"f").configObjects=F,a(this,R,"f").unfreeze(),a(this,q,"f").unfreeze(),a(this,ee,"f").unfreeze(),a(this,Ee,"f").unfreeze()}[Bi](e,n){return qe(n,(t)=>(e(t),t))}getInternalMethods(){return{getCommandInstance:this[Oi].bind(this),getContext:this[$i].bind(this),getHasOutput:this[vi].bind(this),getLoggerInstance:this[ji].bind(this),getParseContext:this[ki].bind(this),getParserConfiguration:this[on].bind(this),getUsageConfiguration:this[Ai].bind(this),getUsageInstance:this[Mi].bind(this),getValidationInstance:this[Ni].bind(this),hasParseCallback:this[Zn].bind(this),isGlobalContext:this[Ri].bind(this),postProcess:this[an].bind(this),reset:this[Ht].bind(this),runValidation:this[Vt].bind(this),runYargsParserAndExecuteCommands:this[_n].bind(this),setHasOutput:this[Ti].bind(this)}}[Oi](){return a(this,ee,"f")}[$i](){return a(this,Pn,"f")}[vi](){return a(this,me,"f")}[ji](){return a(this,Qe,"f")}[ki](){return a(this,en,"f")||{}}[Mi](){return a(this,R,"f")}[Ni](){return a(this,q,"f")}[Zn](){return!!a(this,Fe,"f")}[Ri](){return a(this,Yn,"f")}[an](e,n,t,r){if(t)return e;if(J(e))return e;if(!n)e=this[Ei](e);if(this[on]()["parse-positional-numbers"]||this[on]()["parse-positional-numbers"]===void 0)e=this[_i](e);if(r)e=Ke(e,this,a(this,Ee,"f").getMiddleware(),!1);return e}[Ht](e={}){S(this,B,a(this,B,"f")||{},"f");let n={};n.local=a(this,B,"f").local||[],n.configObjects=a(this,B,"f").configObjects||[];let t={};n.local.forEach((s)=>{t[s]=!0,(e[s]||[]).forEach((o)=>{t[o]=!0})}),Object.assign(a(this,nn,"f"),Object.keys(a(this,_e,"f")).reduce((s,o)=>{let u=a(this,_e,"f")[o].filter((c)=>!(c in t));if(u.length>0)s[o]=u;return s},{})),S(this,_e,{},"f");let r=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],i=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(r.forEach((s)=>{n[s]=(a(this,B,"f")[s]||[]).filter((o)=>!t[o])}),i.forEach((s)=>{n[s]=Ie(a(this,B,"f")[s],(o)=>!t[o])}),n.envPrefix=a(this,B,"f").envPrefix,S(this,B,n,"f"),S(this,R,a(this,R,"f")?a(this,R,"f").reset(t):fi(this,a(this,M,"f")),"f"),S(this,q,a(this,q,"f")?a(this,q,"f").reset(t):yi(this,a(this,R,"f"),a(this,M,"f")),"f"),S(this,ee,a(this,ee,"f")?a(this,ee,"f").reset():li(a(this,R,"f"),a(this,q,"f"),a(this,Ee,"f"),a(this,M,"f")),"f"),!a(this,De,"f"))S(this,De,pi(this,a(this,R,"f"),a(this,ee,"f"),a(this,M,"f")),"f");return a(this,Ee,"f").reset(),S(this,pe,null,"f"),S(this,ae,"","f"),S(this,Le,null,"f"),S(this,me,!1,"f"),this.parsed=!1,this}[Ii](e,n){return a(this,M,"f").path.relative(e,n)}[_n](e,n,t,r=0,i=!1){var s,o,u,c;let p=!!t||i;e=e||a(this,We,"f"),a(this,B,"f").__=a(this,M,"f").y18n.__,a(this,B,"f").configuration=this[on]();let b=!!a(this,B,"f").configuration["populate--"],g=Object.assign({},a(this,B,"f").configuration,{"populate--":!0}),D=a(this,M,"f").Parser.detailed(e,Object.assign({},a(this,B,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),F=Object.assign(D.argv,a(this,en,"f")),y=void 0,h=D.aliases,v=!1,W=!1;if(Object.keys(F).forEach((T)=>{if(T===a(this,Ce,"f")&&F[T])v=!0;else if(T===a(this,Be,"f")&&F[T])W=!0}),F.$0=this.$0,this.parsed=D,r===0)a(this,R,"f").clearCachedHelpMessage();try{if(this[Mt](),n)return this[an](F,b,!!t,!1);if(a(this,Ce,"f")){if([a(this,Ce,"f")].concat(h[a(this,Ce,"f")]||[]).filter((te)=>te.length>1).includes(""+F._[F._.length-1]))F._.pop(),v=!0}S(this,Yn,!1,"f");let T=a(this,ee,"f").getCommands(),ce=((s=a(this,De,"f"))===null||s===void 0?void 0:s.completionKey)?[(o=a(this,De,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(u=a(this,De,"f"))===null||u===void 0?void 0:u.completionKey])!==null&&c!==void 0?c:[]].some((Y)=>Object.prototype.hasOwnProperty.call(F,Y)):!1,I=v||ce||i;if(F._.length){if(T.length){let Y;for(let te=r||0,X;F._[te]!==void 0;te++)if(X=String(F._[te]),T.includes(X)&&X!==a(this,pe,"f")){let Pe=a(this,ee,"f").runCommand(X,this,D,te+1,i,v||W||i);return this[an](Pe,b,!!t,!1)}else if(!Y&&X!==a(this,pe,"f")){Y=X;break}if(!a(this,ee,"f").hasDefaultCommand()&&a(this,qn,"f")&&Y&&!I)a(this,q,"f").recommendCommands(Y,T)}if(a(this,pe,"f")&&F._.includes(a(this,pe,"f"))&&!ce){if(a(this,be,"f"))Te(!0);this.showCompletionScript(),this.exit(0)}}if(a(this,ee,"f").hasDefaultCommand()&&!I){let Y=a(this,ee,"f").runCommand(null,this,D,0,i,v||W||i);return this[an](Y,b,!!t,!1)}if(ce){if(a(this,be,"f"))Te(!0);e=[].concat(e);let Y=e.slice(e.indexOf(`--${a(this,De,"f").completionKey}`)+1);return a(this,De,"f").getCompletion(Y,(te,X)=>{if(te)throw new Q(te.message);(X||[]).forEach((Pe)=>{a(this,Qe,"f").log(Pe)}),this.exit(0)}),this[an](F,!b,!!t,!1)}if(!a(this,me,"f")){if(v){if(a(this,be,"f"))Te(!0);p=!0,this.showHelp((Y)=>{a(this,Qe,"f").log(Y),this.exit(0)})}else if(W){if(a(this,be,"f"))Te(!0);p=!0,a(this,R,"f").showVersion("log"),this.exit(0)}}if(!p&&a(this,B,"f").skipValidation.length>0)p=Object.keys(F).some((Y)=>a(this,B,"f").skipValidation.indexOf(Y)>=0&&F[Y]===!0);if(!p){if(D.error)throw new Q(D.error.message);if(!ce){let Y=this[Vt](h,{},D.error);if(!t)y=Ke(F,this,a(this,Ee,"f").getMiddleware(),!0);if(y=this[Bi](Y,y!==null&&y!==void 0?y:F),J(y)&&!t)y=y.then(()=>Ke(F,this,a(this,Ee,"f").getMiddleware(),!1))}}}catch(T){if(T instanceof Q)a(this,R,"f").fail(T.message,T);else throw T}return this[an](y!==null&&y!==void 0?y:F,b,!!t,!0)}[Vt](e,n,t,r){let i={...this.getDemandedOptions()};return(s)=>{if(t)throw new Q(t.message);a(this,q,"f").nonOptionCount(s),a(this,q,"f").requiredArguments(s,i);let o=!1;if(a(this,rn,"f"))o=a(this,q,"f").unknownCommands(s);if(a(this,tn,"f")&&!o)a(this,q,"f").unknownArguments(s,e,n,!!r);else if(a(this,sn,"f"))a(this,q,"f").unknownArguments(s,e,{},!1,!1);a(this,q,"f").limitedChoices(s),a(this,q,"f").implications(s),a(this,q,"f").conflicting(s)}}[Ti](){S(this,me,!0,"f")}[un](e){if(typeof e==="string")a(this,B,"f").key[e]=!0;else for(let n of e)a(this,B,"f").key[n]=!0}}function ci(e){return!!e&&typeof e.getInternalMethods==="function"}var ou=Li(ri),Hi=ou;var Vi={name:"@coryrylan/cradle",version:"1.3.1",description:"A runtime for portable agents defined as folders \u2014 launches the pi coding agent configured from an agent folder, sandboxed with nono",main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:{cradle:"dist/index.js"},files:["README.md","CHANGELOG.md","LICENSE","package.json","dist/index.js","dist/**/*.d.ts","!dist/**/*.test.d.ts"],repository:{type:"git",url:"git+https://github.com/coryrylan/cradle.git",directory:"projects/cli"},keywords:["pi","agents","agent-folders","sandbox","nono","cli","bun"],author:"Cory Rylan (https://coryrylan.com)",license:"MIT",bugs:{url:"https://github.com/coryrylan/cradle/issues"},homepage:"https://github.com/coryrylan/cradle/tree/main/projects/cli#readme",engines:{bun:">=1.4.0"},publishConfig:{access:"public"},scripts:{start:"wireit",ci:"wireit","ci:nocache":"bun run clean && bun run ci",clean:"rm -rf dist",test:"wireit","test:coverage":"wireit",lint:"wireit",build:"wireit","install:local":"wireit","uninstall:local":"wireit",release:"wireit"},wireit:{start:{command:"bun src/index.ts",cache:!1},ci:{dependencies:["lint","build","test:coverage"]},test:{command:"bun test",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},"test:coverage":{command:"bun test --coverage",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},lint:{command:"eslint .",files:["src/**/*.ts","eslint.config.js","package.json"],output:[]},build:{dependencies:["build:js","build:tsc","build:darwin-arm64","build:darwin-x64","build:linux-x64","build:linux-arm64","build:windows-x64"]},"build:js":{command:"bun build ./src/index.ts --outdir=./dist --target=bun --format=esm --minify",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/index.js"]},"build:tsc":{command:"tsc --emitDeclarationOnly --project tsconfig.types.json",files:["src/**/*.ts","src/**/*.json","tsconfig.json","tsconfig.types.json"],output:["dist/**/*.d.ts"]},"build:darwin-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-arm64 --outfile dist/cradle-macos-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-arm64"]},"build:darwin-x64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-x64 --outfile dist/cradle-macos-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-x64"]},"build:linux-x64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-x64 --outfile dist/cradle-linux-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-x64"]},"build:linux-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-arm64 --outfile dist/cradle-linux-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-arm64"]},"build:windows-x64":{command:"bun build --compile --minify src/index.ts --target=bun-windows-x64 --outfile dist/cradle-windows-x64.exe",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-windows-x64.exe"]},"install:local":{dependencies:["build"],command:"bash install.sh",cache:!1},"uninstall:local":{command:'rm -f "$HOME/.local/bin/cradle"',cache:!1},release:{command:"HUSKY=0 bun x semantic-release",dependencies:["ci"]}},dependencies:{yargs:"^18.1.0"},devDependencies:{"@coryrylan/tools":"1.1.1","@eslint/js":"catalog:","@eslint/json":"2.0.1","@types/bun":"catalog:","@types/yargs":"17.0.35",eslint:"catalog:","eslint-plugin-jsdoc":"64.2.1",typescript:"catalog:","typescript-eslint":"catalog:"}};import{join as Gi}from"path";var Qn="agent-browser-nono-fallback.ts";function zi(){return`// generated by cradle for sandboxed agent-browser processes \u2014 do not edit
|
|
76
|
+
`)}`:"";t.fail(i("Missing required argument: %s","Missing required arguments: %s",Object.keys(F).length,Object.keys(F).join(", ")+h))}},s.unknownArguments=function(g,D,F,y,h=!0){var v;let W=e.getInternalMethods().getCommandInstance().getCommands(),T=[],ce=e.getInternalMethods().getContext();if(Object.keys(g).forEach((I)=>{if(!bi.includes(I)&&!Object.prototype.hasOwnProperty.call(F,I)&&!Object.prototype.hasOwnProperty.call(e.getInternalMethods().getParseContext(),I)&&!s.isValidAndSomeAliasIsNotNew(I,D))T.push(I)}),h&&(ce.commands.length>0||W.length>0||y))g._.slice(ce.commands.length).forEach((I)=>{if(!W.includes(""+I))T.push(""+I)});if(h){let Y=((v=e.getDemandedCommands()._)===null||v===void 0?void 0:v.max)||0,ne=ce.commands.length+Y;if(ne<g._.length)g._.slice(ne).forEach((X)=>{if(X=String(X),!ce.commands.includes(X)&&!T.includes(X))T.push(X)})}if(T.length)t.fail(i("Unknown argument: %s","Unknown arguments: %s",T.length,T.map((I)=>I.trim()?I:`"${I}"`).join(", ")))},s.unknownCommands=function(g){let D=e.getInternalMethods().getCommandInstance().getCommands(),F=[],y=e.getInternalMethods().getContext();if(y.commands.length>0||D.length>0)g._.slice(y.commands.length).forEach((h)=>{if(!D.includes(""+h))F.push(""+h)});if(F.length>0)return t.fail(i("Unknown command: %s","Unknown commands: %s",F.length,F.join(", "))),!0;else return!1},s.isValidAndSomeAliasIsNotNew=function(g,D){if(!Object.prototype.hasOwnProperty.call(D,g))return!1;let F=e.parsed.newAliases;return[g,...D[g]].some((y)=>!Object.prototype.hasOwnProperty.call(F,y)||!F[g])},s.limitedChoices=function(g){let D=e.getOptions(),F={};if(!Object.keys(D.choices).length)return;Object.keys(g).forEach((v)=>{if(bi.indexOf(v)===-1&&Object.prototype.hasOwnProperty.call(D.choices,v))[].concat(g[v]).forEach((W)=>{if(D.choices[v].indexOf(W)===-1&&W!==void 0)F[v]=(F[v]||[]).concat(W)})});let y=Object.keys(F);if(!y.length)return;let h=r("Invalid values:");y.forEach((v)=>{h+=`
|
|
77
|
+
${r("Argument: %s, Given: %s, Choices: %s",v,t.stringifiedValues(F[v]),t.stringifiedValues(D.choices[v]))}`}),t.fail(h)};let o={};s.implies=function(g,D){if(x("<string|object> [array|number|string]",[g,D],arguments.length),typeof g==="object")Object.keys(g).forEach((F)=>{s.implies(F,g[F])});else{if(e.global(g),!o[g])o[g]=[];if(Array.isArray(D))D.forEach((F)=>s.implies(g,F));else he(D,void 0,n),o[g].push(D)}},s.getImplied=function(){return o};function u(b,g){let D=Number(g);if(g=isNaN(D)?g:D,typeof g==="number")g=b._.length>=g;else if(g.match(/^--no-.+/))g=g.match(/^--no-(.+)/)[1],g=!Object.prototype.hasOwnProperty.call(b,g);else g=Object.prototype.hasOwnProperty.call(b,g);return g}s.implications=function(g){let D=[];if(Object.keys(o).forEach((F)=>{let y=F;(o[F]||[]).forEach((h)=>{let v=y,W=h;if(v=u(g,v),h=u(g,h),v&&!h)D.push(` ${y} -> ${W}`)})}),D.length){let F=`${r("Implications failed:")}
|
|
78
|
+
`;D.forEach((y)=>{F+=y}),t.fail(F)}};let c={};s.conflicts=function(g,D){if(x("<string|object> [array|string]",[g,D],arguments.length),typeof g==="object")Object.keys(g).forEach((F)=>{s.conflicts(F,g[F])});else{if(e.global(g),!c[g])c[g]=[];if(Array.isArray(D))D.forEach((F)=>s.conflicts(g,F));else c[g].push(D)}},s.getConflicting=()=>c,s.conflicting=function(g){if(Object.keys(g).forEach((D)=>{if(c[D])c[D].forEach((F)=>{if(F&&g[D]!==void 0&&g[F]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",D,F))})}),e.getInternalMethods().getParserConfiguration()["strip-dashed"])Object.keys(c).forEach((D)=>{c[D].forEach((F)=>{if(F&&g[n.Parser.camelCase(D)]!==void 0&&g[n.Parser.camelCase(F)]!==void 0)t.fail(r("Arguments %s and %s are mutually exclusive",D,F))})})},s.recommendCommands=function(g,D){D=D.sort((v,W)=>W.length-v.length);let y=null,h=1/0;for(let v=0,W;(W=D[v])!==void 0;v++){let T=yi(g,W);if(T<=3&&T<h)h=T,y=W}if(y)t.fail(r("Did you mean %s?",y))},s.reset=function(g){return o=Ie(o,(D)=>!g[D]),c=Ie(c,(D)=>!g[D]),s};let p=[];return s.freeze=function(){p.push({implied:o,conflicting:c})},s.unfreeze=function(){let g=p.pop();he(g,void 0,n),{implied:o,conflicting:c}=g},s}var kn=[],St;function Vt(e,t,n,r){St=r;let i={};if(Object.prototype.hasOwnProperty.call(e,"extends")){if(typeof e.extends!=="string")return i;let s=/\.json|\..*rc$/.test(e.extends),o=null;if(!s)try{o=import.meta.resolve(e.extends)}catch(u){return e}else o=su(t,e.extends);iu(o),kn.push(o),i=s?JSON.parse(St.readFileSync(o,"utf8")):r.require(e.extends),delete e.extends,i=Vt(i,St.path.dirname(o),n,St)}return kn=[],n?Ci(i,e):Object.assign({},i,e)}function iu(e){if(kn.indexOf(e)>-1)throw new Q(`Circular extended configurations: '${e}'.`)}function su(e,t){return St.path.resolve(e,t)}function Ci(e,t){let n={};function r(i){return i&&typeof i==="object"&&!Array.isArray(i)}Object.assign(n,e);for(let i of Object.keys(t)){if(i==="__proto__")continue;if(r(t[i])&&r(n[i]))n[i]=Ci(e[i],t[i]);else n[i]=t[i]}return n}var S=function(e,t,n,r,i){if(r==="m")throw TypeError("Private method is not writable");if(r==="a"&&!i)throw TypeError("Private accessor was defined without a setter");if(typeof t==="function"?e!==t||!i:!t.has(e))throw TypeError("Cannot write private member to an object whose class did not declare it");return r==="a"?i.call(e,n):i?i.value=n:t.set(e,n),n},a=function(e,t,n,r){if(n==="a"&&!r)throw TypeError("Private accessor was defined without a getter");if(typeof t==="function"?e!==t||!r:!t.has(e))throw TypeError("Cannot read private member from an object whose class did not declare it");return n==="m"?r:n==="a"?r.call(e):r?r.value:t.get(e)},ee,Xe,At,De,pe,zt,Le,Ze,Gt,be,Ut,Ee,_e,me,Ce,Yt,Qe,ae,B,Jt,Kt,Fe,et,Dt,tt,We,qt,M,nt,rt,it,R,Xt,Be,q;function Hi(e){return(t=[],n=e.process.cwd(),r)=>{let i=new Vi(t,n,r,e);return Object.defineProperty(i,"argv",{get:()=>i.parse(),enumerable:!0}),i.help(),i.version(),i}}var wi=Symbol("copyDoubleDash"),xi=Symbol("copyDoubleDash"),Mn=Symbol("deleteFromParserHintObject"),Si=Symbol("emitWarning"),Ai=Symbol("freeze"),Pi=Symbol("getDollarZero"),st=Symbol("getParserConfiguration"),_i=Symbol("getUsageConfiguration"),Nn=Symbol("guessLocale"),Bi=Symbol("guessVersion"),Oi=Symbol("parsePositionalNumbers"),Rn=Symbol("pkgUp"),He=Symbol("populateParserHintArray"),gt=Symbol("populateParserHintSingleValueDictionary"),In=Symbol("populateParserHintArrayDictionary"),Tn=Symbol("populateParserHintDictionary"),Ln=Symbol("sanitizeKey"),Wn=Symbol("setKey"),Hn=Symbol("unfreeze"),$i=Symbol("validateAsync"),vi=Symbol("getCommandInstance"),ji=Symbol("getContext"),ki=Symbol("getHasOutput"),Mi=Symbol("getLoggerInstance"),Ni=Symbol("getParseContext"),Ri=Symbol("getUsageInstance"),Ii=Symbol("getValidationInstance"),Zt=Symbol("hasParseCallback"),Ti=Symbol("isGlobalContext"),ot=Symbol("postProcess"),Li=Symbol("rebase"),Vn=Symbol("reset"),Pt=Symbol("runYargsParserAndExecuteCommands"),zn=Symbol("runValidation"),Wi=Symbol("setHasOutput"),at=Symbol("kTrackManuallySetKeys"),ou="en_US";class Vi{constructor(e=[],t,n,r){this.customScriptName=!1,this.parsed=!1,ee.set(this,void 0),Xe.set(this,void 0),At.set(this,{commands:[],fullCommands:[]}),De.set(this,null),pe.set(this,null),zt.set(this,"show-hidden"),Le.set(this,null),Ze.set(this,!0),Gt.set(this,{}),be.set(this,!0),Ut.set(this,[]),Ee.set(this,void 0),_e.set(this,{}),me.set(this,!1),Ce.set(this,null),Yt.set(this,!0),Qe.set(this,void 0),ae.set(this,""),B.set(this,void 0),Jt.set(this,void 0),Kt.set(this,{}),Fe.set(this,null),et.set(this,null),Dt.set(this,{}),tt.set(this,{}),We.set(this,void 0),qt.set(this,!1),M.set(this,void 0),nt.set(this,!1),rt.set(this,!1),it.set(this,!1),R.set(this,void 0),Xt.set(this,{}),Be.set(this,null),q.set(this,void 0),S(this,M,r,"f"),S(this,We,e,"f"),S(this,Xe,t,"f"),S(this,Jt,n,"f"),S(this,Ee,new vn(this),"f"),this.$0=this[Pi](),this[Vn](),S(this,ee,a(this,ee,"f"),"f"),S(this,R,a(this,R,"f"),"f"),S(this,q,a(this,q,"f"),"f"),S(this,B,a(this,B,"f"),"f"),a(this,B,"f").showHiddenOpt=a(this,zt,"f"),S(this,Qe,this[xi](),"f"),a(this,M,"f").y18n.setLocale(ou)}addHelpOpt(e,t){if(x("[string|boolean] [string]",[e,t],arguments.length),a(this,Ce,"f"))this[Mn](a(this,Ce,"f")),S(this,Ce,null,"f");if(e===!1&&t===void 0)return this;return S(this,Ce,typeof e==="string"?e:"help","f"),this.boolean(a(this,Ce,"f")),this.describe(a(this,Ce,"f"),t||a(this,R,"f").deferY18nLookup("Show help")),this}help(e,t){return this.addHelpOpt(e,t)}addShowHiddenOpt(e,t){if(x("[string|boolean] [string]",[e,t],arguments.length),e===!1&&t===void 0)return this;let n=typeof e==="string"?e:a(this,zt,"f");return this.boolean(n),this.describe(n,t||a(this,R,"f").deferY18nLookup("Show hidden options")),a(this,B,"f").showHiddenOpt=n,this}showHidden(e,t){return this.addShowHiddenOpt(e,t)}alias(e,t){return x("<object|string|array> [string|array]",[e,t],arguments.length),this[In](this.alias.bind(this),"alias",e,t),this}array(e){return x("<array|string>",[e],arguments.length),this[He]("array",e),this[at](e),this}boolean(e){return x("<array|string>",[e],arguments.length),this[He]("boolean",e),this[at](e),this}check(e,t){return x("<function> [boolean]",[e,t],arguments.length),this.middleware((n,r)=>qe(()=>e(n,r.getOptions()),(i)=>{if(!i)a(this,R,"f").fail(a(this,M,"f").y18n.__("Argument check failed: %s",e.toString()));else if(typeof i==="string"||i instanceof Error)a(this,R,"f").fail(i.toString(),i);return n},(i)=>(a(this,R,"f").fail(i.message?i.message:i.toString(),i),n)),!1,t),this}choices(e,t){return x("<object|string|array> [string|array]",[e,t],arguments.length),this[In](this.choices.bind(this),"choices",e,t),this}coerce(e,t){if(x("<object|string|array> [function]",[e,t],arguments.length),Array.isArray(e)){if(!t)throw new Q("coerce callback must be provided");for(let r of e)this.coerce(r,t);return this}else if(typeof e==="object"){for(let r of Object.keys(e))this.coerce(r,e[r]);return this}if(!t)throw new Q("coerce callback must be provided");let n=e;return a(this,B,"f").key[n]=!0,a(this,Ee,"f").addCoerceMiddleware((r,i)=>{var s;let o=(s=i.getAliases()[n])!==null&&s!==void 0?s:[],u=[n,...o].filter((c)=>Object.prototype.hasOwnProperty.call(r,c));if(u.length===0)return r;return qe(()=>t(r[u[0]]),(c)=>(u.forEach((p)=>{r[p]=c}),r),(c)=>{throw new Q(c.message)})},n),this}conflicts(e,t){return x("<string|object> [string|array]",[e,t],arguments.length),a(this,q,"f").conflicts(e,t),this}config(e="config",t,n){if(x("[object|string] [string|function] [function]",[e,t,n],arguments.length),typeof e==="object"&&!Array.isArray(e))return e=Vt(e,a(this,Xe,"f"),this[st]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(e),this;if(typeof t==="function")n=t,t=void 0;return this.describe(e,t||a(this,R,"f").deferY18nLookup("Path to JSON config file")),(Array.isArray(e)?e:[e]).forEach((r)=>{a(this,B,"f").config[r]=n||!0}),this}completion(e,t,n){if(x("[string] [string|boolean|function] [function]",[e,t,n],arguments.length),typeof t==="function")n=t,t=void 0;if(S(this,pe,e||a(this,pe,"f")||"completion","f"),!t&&t!==!1)t="generate completion script";if(this.command(a(this,pe,"f"),t),n)a(this,De,"f").registerFunction(n);return this}command(e,t,n,r,i,s){return x("<string|array|object> [string|boolean] [function|object] [function] [array] [boolean|string]",[e,t,n,r,i,s],arguments.length),a(this,ee,"f").addHandler(e,t,n,r,i,s),this}commands(e,t,n,r,i,s){return this.command(e,t,n,r,i,s)}commandDir(e,t){x("<string> [object]",[e,t],arguments.length);let n=a(this,Jt,"f")||a(this,M,"f").require;return a(this,ee,"f").addDirectory(e,n,a(this,M,"f").getCallerFile(),t),this}count(e){return x("<array|string>",[e],arguments.length),this[He]("count",e),this[at](e),this}default(e,t,n){if(x("<object|string|array> [*] [string]",[e,t,n],arguments.length),n)$n(e,a(this,M,"f")),a(this,B,"f").defaultDescription[e]=n;if(typeof t==="function"){if($n(e,a(this,M,"f")),!a(this,B,"f").defaultDescription[e])a(this,B,"f").defaultDescription[e]=a(this,R,"f").functionDescription(t);t=t.call()}return this[gt](this.default.bind(this),"default",e,t),this}defaults(e,t,n){return this.default(e,t,n)}demandCommand(e=1,t,n,r){if(x("[number] [number|string] [string|null|undefined] [string|null|undefined]",[e,t,n,r],arguments.length),typeof t!=="number")n=t,t=1/0;return this.global("_",!1),a(this,B,"f").demandedCommands._={min:e,max:t,minMsg:n,maxMsg:r},this}demand(e,t,n){if(Array.isArray(t))t.forEach((r)=>{he(n,!0,a(this,M,"f")),this.demandOption(r,n)}),t=1/0;else if(typeof t!=="number")n=t,t=1/0;if(typeof e==="number")he(n,!0,a(this,M,"f")),this.demandCommand(e,t,n,n);else if(Array.isArray(e))e.forEach((r)=>{he(n,!0,a(this,M,"f")),this.demandOption(r,n)});else if(typeof n==="string")this.demandOption(e,n);else if(n===!0||typeof n>"u")this.demandOption(e);return this}demandOption(e,t){return x("<object|string|array> [string]",[e,t],arguments.length),this[gt](this.demandOption.bind(this),"demandedOptions",e,t),this}deprecateOption(e,t){return x("<string> [string|boolean]",[e,t],arguments.length),a(this,B,"f").deprecatedOptions[e]=t,this}describe(e,t){return x("<object|string|array> [string]",[e,t],arguments.length),this[Wn](e,!0),a(this,R,"f").describe(e,t),this}detectLocale(e){return x("<boolean>",[e],arguments.length),S(this,Ze,e,"f"),this}env(e){if(x("[string|boolean]",[e],arguments.length),e===!1)delete a(this,B,"f").envPrefix;else a(this,B,"f").envPrefix=e||"";return this}epilogue(e){return x("<string>",[e],arguments.length),a(this,R,"f").epilog(e),this}epilog(e){return this.epilogue(e)}example(e,t){if(x("<string|array> [string]",[e,t],arguments.length),Array.isArray(e))e.forEach((n)=>this.example(...n));else a(this,R,"f").example(e,t);return this}exit(e,t){if(S(this,me,!0,"f"),S(this,Le,t,"f"),a(this,be,"f"))a(this,M,"f").process.exit(e)}exitProcess(e=!0){return x("[boolean]",[e],arguments.length),S(this,be,e,"f"),this}fail(e){if(x("<function|boolean>",[e],arguments.length),typeof e==="boolean"&&e!==!1)throw new Q("Invalid first argument. Expected function or boolean 'false'");return a(this,R,"f").failFn(e),this}getAliases(){return this.parsed?this.parsed.aliases:{}}async getCompletion(e,t){if(x("<array> [function]",[e,t],arguments.length),!t)return new Promise((n,r)=>{a(this,De,"f").getCompletion(e,(i,s)=>{if(i)r(i);else n(s)})});else return a(this,De,"f").getCompletion(e,t)}getDemandedOptions(){return x([],0),a(this,B,"f").demandedOptions}getDemandedCommands(){return x([],0),a(this,B,"f").demandedCommands}getDeprecatedOptions(){return x([],0),a(this,B,"f").deprecatedOptions}getDetectLocale(){return a(this,Ze,"f")}getExitProcess(){return a(this,be,"f")}getGroups(){return Object.assign({},a(this,_e,"f"),a(this,tt,"f"))}getHelp(){if(S(this,me,!0,"f"),!a(this,R,"f").hasCachedHelpMessage()){if(!this.parsed){let t=this[Pt](a(this,We,"f"),void 0,void 0,0,!0);if(J(t))return t.then(()=>a(this,R,"f").help())}let e=a(this,ee,"f").runDefaultBuilderOn(this);if(J(e))return e.then(()=>a(this,R,"f").help())}return Promise.resolve(a(this,R,"f").help())}getOptions(){return a(this,B,"f")}getStrict(){return a(this,nt,"f")}getStrictCommands(){return a(this,rt,"f")}getStrictOptions(){return a(this,it,"f")}global(e,t){if(x("<string|array> [boolean]",[e,t],arguments.length),e=[].concat(e),t!==!1)a(this,B,"f").local=a(this,B,"f").local.filter((n)=>e.indexOf(n)===-1);else e.forEach((n)=>{if(!a(this,B,"f").local.includes(n))a(this,B,"f").local.push(n)});return this}group(e,t){x("<string|array> <string>",[e,t],arguments.length);let n=a(this,tt,"f")[t]||a(this,_e,"f")[t];if(a(this,tt,"f")[t])delete a(this,tt,"f")[t];let r={};return a(this,_e,"f")[t]=(n||[]).concat(e).filter((i)=>{if(r[i])return!1;return r[i]=!0}),this}hide(e){return x("<string>",[e],arguments.length),a(this,B,"f").hiddenOptions.push(e),this}implies(e,t){return x("<string|object> [number|string|array]",[e,t],arguments.length),a(this,q,"f").implies(e,t),this}locale(e){if(x("[string]",[e],arguments.length),e===void 0)return this[Nn](),a(this,M,"f").y18n.getLocale();return S(this,Ze,!1,"f"),a(this,M,"f").y18n.setLocale(e),this}middleware(e,t,n){return a(this,Ee,"f").addMiddleware(e,!!t,n)}nargs(e,t){return x("<string|object|array> [number]",[e,t],arguments.length),this[gt](this.nargs.bind(this),"narg",e,t),this}normalize(e){return x("<array|string>",[e],arguments.length),this[He]("normalize",e),this}number(e){return x("<array|string>",[e],arguments.length),this[He]("number",e),this[at](e),this}option(e,t){if(x("<string|object> [object]",[e,t],arguments.length),typeof e==="object")Object.keys(e).forEach((n)=>{this.options(n,e[n])});else{if(typeof t!=="object")t={};if(this[at](e),a(this,Be,"f")&&(e==="version"||(t===null||t===void 0?void 0:t.alias)==="version"))this[Si](['"version" is a reserved word.',"Please do one of the following:",'- Disable version with `yargs.version(false)` if using "version" as an option',"- Use the built-in `yargs.version` method instead (if applicable)","- Use a different option key","https://yargs.js.org/docs/#api-reference-version"].join(`
|
|
79
|
+
`),void 0,"versionWarning");if(a(this,B,"f").key[e]=!0,t.alias)this.alias(e,t.alias);let n=t.deprecate||t.deprecated;if(n)this.deprecateOption(e,n);let r=t.demand||t.required||t.require;if(r)this.demand(e,r);if(t.demandOption)this.demandOption(e,typeof t.demandOption==="string"?t.demandOption:void 0);if(t.conflicts)this.conflicts(e,t.conflicts);if("default"in t)this.default(e,t.default);if(t.implies!==void 0)this.implies(e,t.implies);if(t.nargs!==void 0)this.nargs(e,t.nargs);if(t.config)this.config(e,t.configParser);if(t.normalize)this.normalize(e);if(t.choices)this.choices(e,t.choices);if(t.coerce)this.coerce(e,t.coerce);if(t.group)this.group(e,t.group);if(t.boolean||t.type==="boolean"){if(this.boolean(e),t.alias)this.boolean(t.alias)}if(t.array||t.type==="array"){if(this.array(e),t.alias)this.array(t.alias)}if(t.number||t.type==="number"){if(this.number(e),t.alias)this.number(t.alias)}if(t.string||t.type==="string"){if(this.string(e),t.alias)this.string(t.alias)}if(t.count||t.type==="count")this.count(e);if(typeof t.global==="boolean")this.global(e,t.global);if(t.defaultDescription)a(this,B,"f").defaultDescription[e]=t.defaultDescription;if(t.skipValidation)this.skipValidation(e);let i=t.describe||t.description||t.desc,s=a(this,R,"f").getDescriptions();if(!Object.prototype.hasOwnProperty.call(s,e)||typeof i==="string")this.describe(e,i);if(t.hidden)this.hide(e);if(t.requiresArg)this.requiresArg(e)}return this}options(e,t){return this.option(e,t)}parse(e,t,n){if(x("[string|array] [function|boolean|object] [function]",[e,t,n],arguments.length),this[Ai](),typeof e>"u")e=a(this,We,"f");if(typeof t==="object")S(this,et,t,"f"),t=n;if(typeof t==="function")S(this,Fe,t,"f"),t=!1;if(!t)S(this,We,e,"f");if(a(this,Fe,"f"))S(this,be,!1,"f");let r=this[Pt](e,!!t),i=this.parsed;if(a(this,De,"f").setParsed(this.parsed),J(r))return r.then((s)=>{if(a(this,Fe,"f"))a(this,Fe,"f").call(this,a(this,Le,"f"),s,a(this,ae,"f"));return s}).catch((s)=>{if(a(this,Fe,"f"))a(this,Fe,"f")(s,this.parsed.argv,a(this,ae,"f"));throw s}).finally(()=>{this[Hn](),this.parsed=i});else{if(a(this,Fe,"f"))a(this,Fe,"f").call(this,a(this,Le,"f"),r,a(this,ae,"f"));this[Hn](),this.parsed=i}return r}parseAsync(e,t,n){let r=this.parse(e,t,n);return!J(r)?Promise.resolve(r):r}parseSync(e,t,n){let r=this.parse(e,t,n);if(J(r))throw new Q(".parseSync() must not be used with asynchronous builders, handlers, or middleware");return r}parserConfiguration(e){return x("<object>",[e],arguments.length),S(this,Kt,e,"f"),this}pkgConf(e,t){x("<string> [string]",[e,t],arguments.length);let n=null,r=this[Rn](t||a(this,Xe,"f"));if(r[e]&&typeof r[e]==="object")n=Vt(r[e],t||a(this,Xe,"f"),this[st]()["deep-merge-config"]||!1,a(this,M,"f")),a(this,B,"f").configObjects=(a(this,B,"f").configObjects||[]).concat(n);return this}positional(e,t){x("<string> <object>",[e,t],arguments.length);let n=["default","defaultDescription","implies","normalize","choices","conflicts","coerce","type","describe","desc","description","alias"];t=Ie(t,(s,o)=>{if(s==="type"&&!["string","number","boolean"].includes(o))return!1;return n.includes(s)});let r=a(this,At,"f").fullCommands[a(this,At,"f").fullCommands.length-1],i=r?a(this,ee,"f").cmdToParseOptions(r):{array:[],alias:{},default:{},demand:{}};return ft(i).forEach((s)=>{let o=i[s];if(Array.isArray(o)){if(o.indexOf(e)!==-1)t[s]=!0}else if(o[e]&&!(s in t))t[s]=o[e]}),this.group(e,a(this,R,"f").getPositionalGroupName()),this.option(e,t)}recommendCommands(e=!0){return x("[boolean]",[e],arguments.length),S(this,qt,e,"f"),this}required(e,t,n){return this.demand(e,t,n)}require(e,t,n){return this.demand(e,t,n)}requiresArg(e){if(x("<array|string|object> [number]",[e],arguments.length),typeof e==="string"&&a(this,B,"f").narg[e])return this;else this[gt](this.requiresArg.bind(this),"narg",e,NaN);return this}showCompletionScript(e,t){return x("[string] [string]",[e,t],arguments.length),e=e||this.$0,a(this,Qe,"f").log(a(this,De,"f").generateCompletionScript(e,t||a(this,pe,"f")||"completion")),this}showHelp(e){if(x("[string|function]",[e],arguments.length),S(this,me,!0,"f"),!a(this,R,"f").hasCachedHelpMessage()){if(!this.parsed){let n=this[Pt](a(this,We,"f"),void 0,void 0,0,!0);if(J(n))return n.then(()=>{a(this,R,"f").showHelp(e)}),this}let t=a(this,ee,"f").runDefaultBuilderOn(this);if(J(t))return t.then(()=>{a(this,R,"f").showHelp(e)}),this}return a(this,R,"f").showHelp(e),this}scriptName(e){return this.customScriptName=!0,this.$0=e,this}showHelpOnFail(e,t){return x("[boolean|string] [string]",[e,t],arguments.length),a(this,R,"f").showHelpOnFail(e,t),this}showVersion(e){return x("[string|function]",[e],arguments.length),a(this,R,"f").showVersion(e),this}skipValidation(e){return x("<array|string>",[e],arguments.length),this[He]("skipValidation",e),this}strict(e){return x("[boolean]",[e],arguments.length),S(this,nt,e!==!1,"f"),this}strictCommands(e){return x("[boolean]",[e],arguments.length),S(this,rt,e!==!1,"f"),this}strictOptions(e){return x("[boolean]",[e],arguments.length),S(this,it,e!==!1,"f"),this}string(e){return x("<array|string>",[e],arguments.length),this[He]("string",e),this[at](e),this}terminalWidth(){return x([],0),a(this,M,"f").process.stdColumns}updateLocale(e){return this.updateStrings(e)}updateStrings(e){return x("<object>",[e],arguments.length),S(this,Ze,!1,"f"),a(this,M,"f").y18n.updateLocale(e),this}usage(e,t,n,r){if(x("<string|null|undefined> [string|boolean] [function|object] [function]",[e,t,n,r],arguments.length),t!==void 0)if(he(e,null,a(this,M,"f")),(e||"").match(/^\$0( |$)/))return this.command(e,t,n,r);else throw new Q(".usage() description must start with $0 if being used as alias for .command()");else return a(this,R,"f").usage(e),this}usageConfiguration(e){return x("<object>",[e],arguments.length),S(this,Xt,e,"f"),this}version(e,t,n){if(x("[boolean|string] [string] [string]",[e,t,n],arguments.length),a(this,Be,"f"))this[Mn](a(this,Be,"f")),a(this,R,"f").version(void 0),S(this,Be,null,"f");if(arguments.length===0)n=this[Bi](),e="version";else if(arguments.length===1){if(e===!1)return this;n=e,e="version"}else if(arguments.length===2)n=t,t=void 0;return S(this,Be,typeof e==="string"?e:"version","f"),t=t||a(this,R,"f").deferY18nLookup("Show version number"),a(this,R,"f").version(n||void 0),this.boolean(a(this,Be,"f")),this.describe(a(this,Be,"f"),t),this}wrap(e){return x("<number|null|undefined>",[e],arguments.length),a(this,R,"f").wrap(e),this}[(ee=new WeakMap,Xe=new WeakMap,At=new WeakMap,De=new WeakMap,pe=new WeakMap,zt=new WeakMap,Le=new WeakMap,Ze=new WeakMap,Gt=new WeakMap,be=new WeakMap,Ut=new WeakMap,Ee=new WeakMap,_e=new WeakMap,me=new WeakMap,Ce=new WeakMap,Yt=new WeakMap,Qe=new WeakMap,ae=new WeakMap,B=new WeakMap,Jt=new WeakMap,Kt=new WeakMap,Fe=new WeakMap,et=new WeakMap,Dt=new WeakMap,tt=new WeakMap,We=new WeakMap,qt=new WeakMap,M=new WeakMap,nt=new WeakMap,rt=new WeakMap,it=new WeakMap,R=new WeakMap,Xt=new WeakMap,Be=new WeakMap,q=new WeakMap,wi)](e){if(!e._||!e["--"])return e;e._.push.apply(e._,e["--"]);try{delete e["--"]}catch(t){}return e}[xi](){return{log:(...e)=>{if(!this[Zt]())console.log(...e);if(S(this,me,!0,"f"),a(this,ae,"f").length)S(this,ae,a(this,ae,"f")+`
|
|
80
|
+
`,"f");S(this,ae,a(this,ae,"f")+e.join(" "),"f")},error:(...e)=>{if(!this[Zt]())console.error(...e);if(S(this,me,!0,"f"),a(this,ae,"f").length)S(this,ae,a(this,ae,"f")+`
|
|
81
|
+
`,"f");S(this,ae,a(this,ae,"f")+e.join(" "),"f")}}}[Mn](e){ft(a(this,B,"f")).forEach((t)=>{if(((r)=>r==="configObjects")(t))return;let n=a(this,B,"f")[t];if(Array.isArray(n)){if(n.includes(e))n.splice(n.indexOf(e),1)}else if(typeof n==="object")delete n[e]}),delete a(this,R,"f").getDescriptions()[e]}[Si](e,t,n){if(!a(this,Gt,"f")[n])a(this,M,"f").process.emitWarning(e,t),a(this,Gt,"f")[n]=!0}[Ai](){a(this,Ut,"f").push({options:a(this,B,"f"),configObjects:a(this,B,"f").configObjects.slice(0),exitProcess:a(this,be,"f"),groups:a(this,_e,"f"),strict:a(this,nt,"f"),strictCommands:a(this,rt,"f"),strictOptions:a(this,it,"f"),completionCommand:a(this,pe,"f"),output:a(this,ae,"f"),exitError:a(this,Le,"f"),hasOutput:a(this,me,"f"),parsed:this.parsed,parseFn:a(this,Fe,"f"),parseContext:a(this,et,"f")}),a(this,R,"f").freeze(),a(this,q,"f").freeze(),a(this,ee,"f").freeze(),a(this,Ee,"f").freeze()}[Pi](){let e="",t;if(/\b(node|iojs|electron|bun)(\.exe)?$/.test(a(this,M,"f").process.argv()[0]))t=a(this,M,"f").process.argv().slice(1,2);else t=a(this,M,"f").process.argv().slice(0,1);if(e=t.map((n)=>{let r=this[Li](a(this,Xe,"f"),n);return n.match(/^(\/|([a-zA-Z]:)?\\)/)&&r.length<n.length?r:n}).join(" ").trim(),a(this,M,"f").getEnv("_")&&a(this,M,"f").getProcessArgvBin()===a(this,M,"f").getEnv("_"))e=a(this,M,"f").getEnv("_").replace(`${a(this,M,"f").path.dirname(a(this,M,"f").process.execPath())}/`,"");return e}[st](){return a(this,Kt,"f")}[_i](){return a(this,Xt,"f")}[Nn](){if(!a(this,Ze,"f"))return;let e=a(this,M,"f").getEnv("LC_ALL")||a(this,M,"f").getEnv("LC_MESSAGES")||a(this,M,"f").getEnv("LANG")||a(this,M,"f").getEnv("LANGUAGE")||"en_US";this.locale(e.replace(/[.:].*/,""))}[Bi](){return this[Rn]().version||"unknown"}[Oi](e){let t=e["--"]?e["--"]:e._;for(let n=0,r;(r=t[n])!==void 0;n++)if(a(this,M,"f").Parser.looksLikeNumber(r)&&Number.isSafeInteger(Math.floor(parseFloat(`${r}`))))t[n]=Number(r);return e}[Rn](e){let t=e||"*";if(a(this,Dt,"f")[t])return a(this,Dt,"f")[t];let n={};try{let r=e||a(this,M,"f").mainFilename;if(a(this,M,"f").path.extname(r))r=a(this,M,"f").path.dirname(r);let i=a(this,M,"f").findUp(r,(s,o)=>{if(o.includes("package.json"))return"package.json";else return});he(i,void 0,a(this,M,"f")),n=JSON.parse(a(this,M,"f").readFileSync(i,"utf8"))}catch(r){}return a(this,Dt,"f")[t]=n||{},a(this,Dt,"f")[t]}[He](e,t){t=[].concat(t),t.forEach((n)=>{n=this[Ln](n),a(this,B,"f")[e].push(n)})}[gt](e,t,n,r){this[Tn](e,t,n,r,(i,s,o)=>{a(this,B,"f")[i][s]=o})}[In](e,t,n,r){this[Tn](e,t,n,r,(i,s,o)=>{a(this,B,"f")[i][s]=(a(this,B,"f")[i][s]||[]).concat(o)})}[Tn](e,t,n,r,i){if(Array.isArray(n))n.forEach((s)=>{e(s,r)});else if(((s)=>typeof s==="object")(n))for(let s of ft(n))e(s,n[s]);else i(t,this[Ln](n),r)}[Ln](e){if(e==="__proto__")return"___proto___";return e}[Wn](e,t){return this[gt](this[Wn].bind(this),"key",e,t),this}[Hn](){var e,t,n,r,i,s,o,u,c,p,b,g;let D=a(this,Ut,"f").pop();he(D,void 0,a(this,M,"f"));let F;e=this,t=this,n=this,r=this,i=this,s=this,o=this,u=this,c=this,p=this,b=this,g=this,{options:{set value(y){S(e,B,y,"f")}}.value,configObjects:F,exitProcess:{set value(y){S(t,be,y,"f")}}.value,groups:{set value(y){S(n,_e,y,"f")}}.value,output:{set value(y){S(r,ae,y,"f")}}.value,exitError:{set value(y){S(i,Le,y,"f")}}.value,hasOutput:{set value(y){S(s,me,y,"f")}}.value,parsed:this.parsed,strict:{set value(y){S(o,nt,y,"f")}}.value,strictCommands:{set value(y){S(u,rt,y,"f")}}.value,strictOptions:{set value(y){S(c,it,y,"f")}}.value,completionCommand:{set value(y){S(p,pe,y,"f")}}.value,parseFn:{set value(y){S(b,Fe,y,"f")}}.value,parseContext:{set value(y){S(g,et,y,"f")}}.value}=D,a(this,B,"f").configObjects=F,a(this,R,"f").unfreeze(),a(this,q,"f").unfreeze(),a(this,ee,"f").unfreeze(),a(this,Ee,"f").unfreeze()}[$i](e,t){return qe(t,(n)=>(e(n),n))}getInternalMethods(){return{getCommandInstance:this[vi].bind(this),getContext:this[ji].bind(this),getHasOutput:this[ki].bind(this),getLoggerInstance:this[Mi].bind(this),getParseContext:this[Ni].bind(this),getParserConfiguration:this[st].bind(this),getUsageConfiguration:this[_i].bind(this),getUsageInstance:this[Ri].bind(this),getValidationInstance:this[Ii].bind(this),hasParseCallback:this[Zt].bind(this),isGlobalContext:this[Ti].bind(this),postProcess:this[ot].bind(this),reset:this[Vn].bind(this),runValidation:this[zn].bind(this),runYargsParserAndExecuteCommands:this[Pt].bind(this),setHasOutput:this[Wi].bind(this)}}[vi](){return a(this,ee,"f")}[ji](){return a(this,At,"f")}[ki](){return a(this,me,"f")}[Mi](){return a(this,Qe,"f")}[Ni](){return a(this,et,"f")||{}}[Ri](){return a(this,R,"f")}[Ii](){return a(this,q,"f")}[Zt](){return!!a(this,Fe,"f")}[Ti](){return a(this,Yt,"f")}[ot](e,t,n,r){if(n)return e;if(J(e))return e;if(!t)e=this[wi](e);if(this[st]()["parse-positional-numbers"]||this[st]()["parse-positional-numbers"]===void 0)e=this[Oi](e);if(r)e=Ke(e,this,a(this,Ee,"f").getMiddleware(),!1);return e}[Vn](e={}){S(this,B,a(this,B,"f")||{},"f");let t={};t.local=a(this,B,"f").local||[],t.configObjects=a(this,B,"f").configObjects||[];let n={};t.local.forEach((s)=>{n[s]=!0,(e[s]||[]).forEach((o)=>{n[o]=!0})}),Object.assign(a(this,tt,"f"),Object.keys(a(this,_e,"f")).reduce((s,o)=>{let u=a(this,_e,"f")[o].filter((c)=>!(c in n));if(u.length>0)s[o]=u;return s},{})),S(this,_e,{},"f");let r=["array","boolean","string","skipValidation","count","normalize","number","hiddenOptions"],i=["narg","key","alias","default","defaultDescription","config","choices","demandedOptions","demandedCommands","deprecatedOptions"];if(r.forEach((s)=>{t[s]=(a(this,B,"f")[s]||[]).filter((o)=>!n[o])}),i.forEach((s)=>{t[s]=Ie(a(this,B,"f")[s],(o)=>!n[o])}),t.envPrefix=a(this,B,"f").envPrefix,S(this,B,t,"f"),S(this,R,a(this,R,"f")?a(this,R,"f").reset(n):Di(this,a(this,M,"f")),"f"),S(this,q,a(this,q,"f")?a(this,q,"f").reset(n):Ei(this,a(this,R,"f"),a(this,M,"f")),"f"),S(this,ee,a(this,ee,"f")?a(this,ee,"f").reset():di(a(this,R,"f"),a(this,q,"f"),a(this,Ee,"f"),a(this,M,"f")),"f"),!a(this,De,"f"))S(this,De,Fi(this,a(this,R,"f"),a(this,ee,"f"),a(this,M,"f")),"f");return a(this,Ee,"f").reset(),S(this,pe,null,"f"),S(this,ae,"","f"),S(this,Le,null,"f"),S(this,me,!1,"f"),this.parsed=!1,this}[Li](e,t){return a(this,M,"f").path.relative(e,t)}[Pt](e,t,n,r=0,i=!1){var s,o,u,c;let p=!!n||i;e=e||a(this,We,"f"),a(this,B,"f").__=a(this,M,"f").y18n.__,a(this,B,"f").configuration=this[st]();let b=!!a(this,B,"f").configuration["populate--"],g=Object.assign({},a(this,B,"f").configuration,{"populate--":!0}),D=a(this,M,"f").Parser.detailed(e,Object.assign({},a(this,B,"f"),{configuration:{"parse-positional-numbers":!1,...g}})),F=Object.assign(D.argv,a(this,et,"f")),y=void 0,h=D.aliases,v=!1,W=!1;if(Object.keys(F).forEach((T)=>{if(T===a(this,Ce,"f")&&F[T])v=!0;else if(T===a(this,Be,"f")&&F[T])W=!0}),F.$0=this.$0,this.parsed=D,r===0)a(this,R,"f").clearCachedHelpMessage();try{if(this[Nn](),t)return this[ot](F,b,!!n,!1);if(a(this,Ce,"f")){if([a(this,Ce,"f")].concat(h[a(this,Ce,"f")]||[]).filter((ne)=>ne.length>1).includes(""+F._[F._.length-1]))F._.pop(),v=!0}S(this,Yt,!1,"f");let T=a(this,ee,"f").getCommands(),ce=((s=a(this,De,"f"))===null||s===void 0?void 0:s.completionKey)?[(o=a(this,De,"f"))===null||o===void 0?void 0:o.completionKey,...(c=this.getAliases()[(u=a(this,De,"f"))===null||u===void 0?void 0:u.completionKey])!==null&&c!==void 0?c:[]].some((Y)=>Object.prototype.hasOwnProperty.call(F,Y)):!1,I=v||ce||i;if(F._.length){if(T.length){let Y;for(let ne=r||0,X;F._[ne]!==void 0;ne++)if(X=String(F._[ne]),T.includes(X)&&X!==a(this,pe,"f")){let Pe=a(this,ee,"f").runCommand(X,this,D,ne+1,i,v||W||i);return this[ot](Pe,b,!!n,!1)}else if(!Y&&X!==a(this,pe,"f")){Y=X;break}if(!a(this,ee,"f").hasDefaultCommand()&&a(this,qt,"f")&&Y&&!I)a(this,q,"f").recommendCommands(Y,T)}if(a(this,pe,"f")&&F._.includes(a(this,pe,"f"))&&!ce){if(a(this,be,"f"))Te(!0);this.showCompletionScript(),this.exit(0)}}if(a(this,ee,"f").hasDefaultCommand()&&!I){let Y=a(this,ee,"f").runCommand(null,this,D,0,i,v||W||i);return this[ot](Y,b,!!n,!1)}if(ce){if(a(this,be,"f"))Te(!0);e=[].concat(e);let Y=e.slice(e.indexOf(`--${a(this,De,"f").completionKey}`)+1);return a(this,De,"f").getCompletion(Y,(ne,X)=>{if(ne)throw new Q(ne.message);(X||[]).forEach((Pe)=>{a(this,Qe,"f").log(Pe)}),this.exit(0)}),this[ot](F,!b,!!n,!1)}if(!a(this,me,"f")){if(v){if(a(this,be,"f"))Te(!0);p=!0,this.showHelp((Y)=>{a(this,Qe,"f").log(Y),this.exit(0)})}else if(W){if(a(this,be,"f"))Te(!0);p=!0,a(this,R,"f").showVersion("log"),this.exit(0)}}if(!p&&a(this,B,"f").skipValidation.length>0)p=Object.keys(F).some((Y)=>a(this,B,"f").skipValidation.indexOf(Y)>=0&&F[Y]===!0);if(!p){if(D.error)throw new Q(D.error.message);if(!ce){let Y=this[zn](h,{},D.error);if(!n)y=Ke(F,this,a(this,Ee,"f").getMiddleware(),!0);if(y=this[$i](Y,y!==null&&y!==void 0?y:F),J(y)&&!n)y=y.then(()=>Ke(F,this,a(this,Ee,"f").getMiddleware(),!1))}}}catch(T){if(T instanceof Q)a(this,R,"f").fail(T.message,T);else throw T}return this[ot](y!==null&&y!==void 0?y:F,b,!!n,!0)}[zn](e,t,n,r){let i={...this.getDemandedOptions()};return(s)=>{if(n)throw new Q(n.message);a(this,q,"f").nonOptionCount(s),a(this,q,"f").requiredArguments(s,i);let o=!1;if(a(this,rt,"f"))o=a(this,q,"f").unknownCommands(s);if(a(this,nt,"f")&&!o)a(this,q,"f").unknownArguments(s,e,t,!!r);else if(a(this,it,"f"))a(this,q,"f").unknownArguments(s,e,{},!1,!1);a(this,q,"f").limitedChoices(s),a(this,q,"f").implications(s),a(this,q,"f").conflicting(s)}}[Wi](){S(this,me,!0,"f")}[at](e){if(typeof e==="string")a(this,B,"f").key[e]=!0;else for(let t of e)a(this,B,"f").key[t]=!0}}function fi(e){return!!e&&typeof e.getInternalMethods==="function"}var au=Hi(si),zi=au;var Gi={name:"@coryrylan/cradle",version:"1.4.0",description:"A runtime for portable agents defined as folders \u2014 launches the pi coding agent configured from an agent folder, sandboxed with nono",main:"./dist/index.js",module:"./dist/index.js",types:"./dist/index.d.ts",type:"module",exports:{".":{types:"./dist/index.d.ts",default:"./dist/index.js"}},bin:{cradle:"dist/index.js"},files:["README.md","CHANGELOG.md","LICENSE","package.json","dist/index.js","dist/**/*.d.ts","!dist/**/*.test.d.ts"],repository:{type:"git",url:"git+https://github.com/coryrylan/cradle.git",directory:"projects/cli"},keywords:["pi","agents","agent-folders","sandbox","nono","cli","bun"],author:"Cory Rylan (https://coryrylan.com)",license:"MIT",bugs:{url:"https://github.com/coryrylan/cradle/issues"},homepage:"https://github.com/coryrylan/cradle/tree/main/projects/cli#readme",engines:{bun:">=1.4.2"},publishConfig:{access:"public"},scripts:{start:"wireit",ci:"wireit","ci:nocache":"bun run clean && bun run ci",clean:"rm -rf dist",test:"wireit","test:coverage":"wireit",lint:"wireit",build:"wireit","install:local":"wireit","uninstall:local":"wireit",release:"wireit"},wireit:{start:{command:"bun src/index.ts",cache:!1},ci:{dependencies:["lint","build","test:coverage"]},test:{command:"bun test",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},"test:coverage":{command:"bun test --coverage",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json","bunfig.toml"],output:[]},lint:{command:"eslint .",files:["src/**/*.ts","eslint.config.js","package.json"],output:[]},build:{dependencies:["build:js","build:tsc","build:darwin-arm64","build:darwin-x64","build:linux-x64","build:linux-arm64","build:windows-x64"]},"build:js":{command:"bun build ./src/index.ts --outdir=./dist --target=bun --format=esm --minify",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/index.js"]},"build:tsc":{command:"tsc --emitDeclarationOnly --project tsconfig.types.json",files:["src/**/*.ts","src/**/*.json","tsconfig.json","tsconfig.types.json"],output:["dist/**/*.d.ts"]},"build:darwin-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-arm64 --outfile dist/cradle-macos-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-arm64"]},"build:darwin-x64":{command:"bun build --compile --minify src/index.ts --target=bun-darwin-x64 --outfile dist/cradle-macos-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-macos-x64"]},"build:linux-x64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-x64 --outfile dist/cradle-linux-x64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-x64"]},"build:linux-arm64":{command:"bun build --compile --minify src/index.ts --target=bun-linux-arm64 --outfile dist/cradle-linux-arm64",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-linux-arm64"]},"build:windows-x64":{command:"bun build --compile --minify src/index.ts --target=bun-windows-x64 --outfile dist/cradle-windows-x64.exe",files:["src/**/*.ts","src/**/*.json","src/**/*.txt","tsconfig.json"],output:["dist/cradle-windows-x64.exe"]},"install:local":{dependencies:["build"],command:"bash install.sh",cache:!1},"uninstall:local":{command:'rm -f "$HOME/.local/bin/cradle"',cache:!1},release:{command:"HUSKY=0 bun x semantic-release",dependencies:["ci"]}},dependencies:{yargs:"^18.1.0"},devDependencies:{"@coryrylan/tools":"1.1.1","@eslint/js":"catalog:","@eslint/json":"2.0.1","@types/bun":"catalog:","@types/yargs":"17.0.35",eslint:"catalog:","eslint-plugin-jsdoc":"64.2.1",typescript:"catalog:","typescript-eslint":"catalog:"}};import{join as Yi}from"path";var Qt="agent-browser-nono-fallback.ts";function Ui(){return`// generated by cradle for sandboxed agent-browser processes \u2014 do not edit
|
|
82
82
|
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
83
83
|
|
|
84
84
|
export default function configureAgentBrowserNonoEnvironment(_pi: ExtensionAPI): void {
|
|
@@ -95,38 +95,38 @@ export default function configureAgentBrowserNonoEnvironment(_pi: ExtensionAPI):
|
|
|
95
95
|
process.env.AGENT_BROWSER_PROXY = nonoProxy;
|
|
96
96
|
}
|
|
97
97
|
}
|
|
98
|
-
`}function
|
|
99
|
-
\u26A0 ${e.note}`:i}function
|
|
100
|
-
`)}function
|
|
98
|
+
`}function lu(e){let t=[];if(e.systemFilePath!==null)t.push("--system-prompt",e.systemFilePath);if(e.appendSystemFilePath!==null)t.push("--append-system-prompt",e.appendSystemFilePath);return t}function cu(e){let{folder:t}=e,{settings:n}=t,r=[e.piBin,...lu(t),"--no-extensions","--no-skills","--no-prompt-templates"];if(t.providersJson!==null)r.push("-e",Yi(e.extensionsDir,"providers.ts"));if(e.backend==="nono")r.push("-e",Yi(e.extensionsDir,Qt));for(let i of e.packageEntries??[])r.push("-e",i);for(let i of t.extensionFiles)r.push("-e",i);if(t.skillsDir!==null)r.push("--skill",t.skillsDir);if(n.defaultProvider!==void 0)r.push("--provider",n.defaultProvider);if(n.defaultModel!==void 0)r.push("--model",n.defaultModel);if(n.defaultThinkingLevel!==void 0)r.push("--thinking",n.defaultThinkingLevel);return r.push("--session-dir",e.sessionsDir),r.push(...e.passthrough),r}function Gn(e){return e.backend==="nono"?{MISE_CACHE_DIR:e.miseCacheDir}:{}}function pt(e){let t=cu(e);if(e.backend!=="nono")return t;return[e.nonoBin,"run",...e.verbose===!0?[]:["--silent"],"--profile",e.profilePath,"--",...t]}import{existsSync as du}from"fs";import{homedir as fu}from"os";import{join as hu}from"path";function Du(e,t=fu()){let n=hu(t,".local","share","mise","shims",e);return du(n)?n:null}var Ji=(e)=>Bun.which(e)??Du(e);function _t(e,t=Ji){return t(e)}function mt(e,t=Ji){let n=_t(e,t);if(!n)throw Error(`Required executable "${e}" not found on PATH \u2014 install it, then run \`cradle doctor\` to verify`);return n}var gu="recommended: the supported way to install pi/nono \u2014 cradle resolves them from mise shims and the sandbox profile assumes a mise-managed install",pu="required for sandboxed runs (a folder declaring sandbox/nono.json, or --sandbox/--offline/--allow-host); not needed otherwise",mu="required for sbx-backend runs (a folder declaring sandbox/sbx.json, or --sandbox-backend sbx); not needed otherwise",Fu="recommended for `cradle schedule`: installs schedule/*.md tasks as launchd LaunchAgents; not needed otherwise",yu="recommended for `cradle schedule`: installs schedule/*.md tasks as systemd --user timers; not needed otherwise";function bu(e){if(e==="darwin")return"launchctl";if(e==="linux")return"systemctl";return null}function Eu(e){return e==="launchctl"?Fu:yu}function en(e,t,n,r){return{name:e,bin:e,required:!1,found:t,version:n,...t?{}:{note:r}}}function Cu(e){let t=(r)=>_t(r,e.which),n=bu(e.platform??process.platform);return{piPath:t("pi"),nonoPath:t("nono"),sbxPath:t("sbx"),misePath:t("mise"),scheduleBin:n,schedulePath:n!==null?t(n):null}}async function Ki(e={}){let t=async(c,p)=>c!==null&&e.readVersion?e.readVersion(c,p):null,n=Cu(e),[r,i,s,o,u]=await Promise.all([t(n.piPath),t(n.nonoPath),t(n.sbxPath,["version"]),t(n.misePath),t(n.schedulePath)]);return[{name:"pi",bin:"pi",required:!0,found:n.piPath,version:r},en("nono",n.nonoPath,i,pu),en("sbx",n.sbxPath,s,mu),en("mise",n.misePath,o,gu),...n.scheduleBin!==null?[en(n.scheduleBin,n.schedulePath,u,Eu(n.scheduleBin))]:[]]}var wu=8;function xu(e,t){let n=e.name.padEnd(t),r=e.version!==null?`${e.version} `:"",i=e.found?`\u2713 ${n} ${r}${e.found}`:e.required?`\u2717 ${n} MISSING (required)`:`\u25CB ${n} not found (recommended)`;return e.note?`${i}
|
|
99
|
+
\u26A0 ${e.note}`:i}function qi(e){let t=Math.max(wu,...e.map((n)=>n.name.length));return e.map((n)=>xu(n,t)).join(`
|
|
100
|
+
`)}function Xi(e){return e.some((t)=>t.required&&!t.found)?1:0}import{exists as Js,mkdir as tr,rm as Oc,writeFile as Ks}from"fs/promises";import{homedir as $c}from"os";import{basename as vc,dirname as jc,join as jt}from"path";import{stat as Wu}from"fs/promises";import{join as as,resolve as Hu}from"path";import{basename as Au,isAbsolute as Pu,join as _u,relative as Bu}from"path";var Bt={extends:"default",meta:{name:"cradle-pi"},groups:{include:["node_runtime","git_config","unlink_protection"]},filesystem:{read:["$HOME/.agents","$HOME/.local/share/mise","$HOME/.config/mise","$HOME/.local/state/mise","$HOME/.config/gh","/System/iOSSupport/System/Library/ExtensionKit/Extensions","/System/Library/AssetsV2/com_apple_MobileAsset_TTSAXResourceModelAssets","/System/Library/AssetsV2/com_apple_MobileAsset_UAF_Siri_TextToSpeech"],allow:["$HOME/.pi/agent"]},unsafe_macos_seatbelt_rules:['(allow user-preference-read (preference-domain "kCFPreferencesAnyApplication") (preference-domain "com.apple.speech.voice.prefs") (preference-domain "com.apple.speakselection") (preference-domain "com.apple.assistant.backedup") (preference-domain "com.apple.assistant.support") (preference-domain "com.apple.accessibility"))']};var Zi="nono-profile.json";function tn(e,t){let n=Bu(e,t);return n===""||!n.startsWith("..")&&!Pu(n)}function Qi(e,t){let n=_u(t,".local","state","nono");return tn(e,n)||tn(n,e)?e:void 0}function ut(e,t){if(e==="~"||e==="$HOME")return t;if(e.startsWith("~/"))return`${t}${e.slice(1)}`;if(e.startsWith("$HOME/"))return`${t}${e.slice(5)}`;return e}function es(e){let t=(o)=>ut(o,e.home),n=Bt.filesystem,r=e.network!==void 0?Ou(e.network):void 0,i=[...n.unix_socket_dir_bind??[],...e.grants.unixSocketDirBind.map(t)],s={...Bt,meta:{...Bt.meta,name:`cradle-${Au(e.stateDir)}`},filesystem:{...n,read:[...n.read??[],e.agentDir,...e.grants.read.map(t)],write:[...n.write??[],...e.grants.write.map(t)],allow:[...n.allow??[],e.cwd,e.stateDir,...e.linkedGitDir!==void 0?[e.linkedGitDir]:[],...e.grants.allow.map(t)],...i.length>0?{unix_socket_dir_bind:i}:{}},unsafe_macos_seatbelt_rules:[...Bt.unsafe_macos_seatbelt_rules,...e.rules],...r!==void 0?{network:r}:{}};return JSON.stringify(s,null,2)}function Ou(e){return{...e.block!==void 0?{block:e.block}:{},...e.networkProfile!==void 0?{network_profile:e.networkProfile}:{},...e.allowDomain!==void 0?{allow_domain:e.allowDomain}:{},...e.openPort!==void 0?{open_port:e.openPort}:{},...e.listenPort!==void 0?{listen_port:e.listenPort}:{}}}import{chmod as ts,lstat as $u,mkdir as vu,readdir as ns,readFile as ju,rm as ku,writeFile as Mu}from"fs/promises";import{dirname as Nu,join as rn,relative as Ru}from"path";function le(e){return typeof e==="object"&&e!==null&&!Array.isArray(e)}function Ft(e,t){try{return JSON.parse(e)}catch(n){throw Error(`${t} is not valid JSON: ${Se(n)}`,{cause:n})}}function Se(e){return e instanceof Error?e.message:String(e)}function de(e,t){return typeof e==="object"&&e!==null&&"code"in e&&e.code===t}function Ve(e){if(/^[A-Za-z0-9_./:@%+=,-]+$/u.test(e))return e;return`'${e.replaceAll("'","'\\''")}'`}function ze(e){return Array.isArray(e)&&e.every((t)=>typeof t==="string")}function lt(e){return/^(?:\/|~(?:\/|$)|\$HOME(?:\/|$)|[A-Za-z]:[\\/]|\\\\)/.test(e)}function Oe(e,t,n,r){let i=Object.keys(e).filter((s)=>!n.includes(s));if(i.length>0)r.push(`${t}: unsupported keys ignored: ${i.join(", ")}`)}function nn(e,t,n,r){e.results.push({name:t,detail:n,status:r})}function Iu(e,t,n){e.failures.push(`${t}: ${n}`),nn(e,t,n,"failed")}async function rs(e,t,n,r){try{if(await Lu(n,r)){nn(e,t,n,"unchanged");return}if(e.dryRun){nn(e,t,`would replace ${n}`,"changed");return}await ss(n),await ku(n,{force:!0,recursive:!0});for(let i of r)await Tu(n,i);nn(e,t,n,"changed")}catch(i){Iu(e,t,Se(i))}}async function Tu(e,t){let n=rn(e,t.rel);if(await vu(Nu(n),{recursive:!0}),await Mu(n,t.content,"utf8"),t.mode!==void 0)await ts(n,t.mode)}async function Lu(e,t){let n=await is(e);if(n.length!==t.length)return!1;let r=new Set(n);for(let i of t){if(!r.has(i.rel))return!1;if(await Ae(rn(e,i.rel))!==i.content)return!1}return!0}async function is(e,t=e){let n=await os(e);if(!n||!n.isDirectory())return[];let r=[];for(let i of await ns(e,{withFileTypes:!0})){let s=rn(e,i.name);if(i.isDirectory())r.push(...await is(s,t));else r.push(Ru(t,s))}return r}async function ss(e){let t=await os(e);if(!t||t.isSymbolicLink())return;if(await ts(e,t.isDirectory()?493:420),!t.isDirectory())return;let n=await ns(e);await Promise.all(n.map((r)=>ss(rn(e,r))))}async function Ae(e){try{return await ju(e,"utf8")}catch(t){if(de(t,"ENOENT"))return;throw t}}async function os(e){try{return await $u(e)}catch(t){if(de(t,"ENOENT"))return;throw t}}var Vu=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function sn(e,t){if(!zu(e))return{dir:e,warnings:[]};let n=as(t.home,".cradle","settings.json"),r=[],i=await Gu(n,r),s=as(t.cwd,e),o=i.get(e);if(o!==void 0){let u=Hu(ut(o,t.home));if(await us(s))r.push(Ju(e,u));return{dir:u,warnings:r}}if(await us(s))return{dir:s,warnings:r};throw Error(Ku(e,s,n,i))}function zu(e){return Vu.test(e)}async function us(e){try{return(await Wu(e)).isDirectory()}catch(t){if(de(t,"ENOENT")||de(t,"ENOTDIR"))return!1;throw t}}async function Gu(e,t){let n=await Ae(e);if(n===void 0)return new Map;let r=Ft(n,e);if(!le(r))return t.push(`${e}: settings must be a JSON object \u2014 ignored`),new Map;return Oe(r,e,["agents"],t),Uu(r,e,t)}function Uu(e,t,n){let r=e.agents;if(r===void 0)return new Map;if(!le(r))return n.push(`${t}: agents must be an object \u2014 ignored`),new Map;let i=Object.entries(r).map((s)=>{let[o,u]=s,c=Yu(u,o,t,n);return c===void 0?void 0:[o,c]}).filter((s)=>s!==void 0);return new Map(i)}function Yu(e,t,n,r){if(!le(e)){r.push(`${n}: agents.${t} must be an object with a "path" \u2014 ignored`);return}let i=e.path;if(typeof i!=="string"||i.trim()===""){r.push(`${n}: agents.${t}.path must be a non-empty string \u2014 ignored`);return}if(!lt(i)){r.push(`${n}: agents.${t}.path must be an absolute, ~/, or $HOME/ path \u2014 ignored: ${i}`);return}return i}function Ju(e,t){return`started alias "${e}" (${t}) \u2014 a directory named ${e} exists in the current directory; use ./${e} to run it instead`}function Ku(e,t,n,r){let i=r.size>0?` (known agents: ${[...r.keys()].join(", ")})`:"";return`Agent folder not found: ${t} \u2014 and no "agents.${e}" entry in ${n}${i}`}import{createHash as qu}from"crypto";import{join as Xu}from"path";var cs="host.docker.internal",ls="@earendil-works/pi-coding-agent",Zu=/^\d+\.\d+\.\d+\.\d+$/,Qu=new Set(["localhost","127.0.0.1"]);function ds(e){let t=(r)=>ut(r,e.home),n=[{path:e.cwd,readonly:!1},{path:e.agentDir,readonly:!0},{path:e.stateDir,readonly:!1},{path:Xu(e.home,".pi","agent"),readonly:!1},...e.linkedGitDir!==void 0?[{path:e.linkedGitDir,readonly:!1}]:[],...e.grants.read.map((r)=>({path:t(r),readonly:!0})),...e.grants.write.map((r)=>({path:t(r),readonly:!1})),...e.grants.allow.map((r)=>({path:t(r),readonly:!1}))];return el(n)}function el(e){let t=[],n=new Map;for(let r of e){if(!n.has(r.path))t.push(r.path);if(n.get(r.path)!==!1)n.set(r.path,r.readonly)}return t.map((r)=>({path:r,readonly:n.get(r)===!0}))}function fs(e,t){let n=t.map((i)=>`${i.path}:${i.readonly?"ro":"rw"}`).sort().join("|"),r=qu("sha256").update(n).digest("hex").slice(0,8);return`cradle-${e}-${r}`}function hs(e){let t=e.mounts.map((n)=>n.readonly?`${n.path}:ro`:n.path);return[e.sbxBin,"create","shell",...t,"--name",e.name,"-q"]}function tl(e){let t=[],n=!1;for(let r of e)if(Qu.has(r))n=!0;else if(Zu.test(r))t.push(r);else t.push(r,`*.${r}`);if(n)t.push(cs);return t}function Ds(e){let{network:t,sbxBin:n,name:r}=e;if(t===void 0)return[];if(t.block===!0)return[[n,"policy","deny","network","--sandbox",r,"**"]];let i=tl(t.allowDomain??[]);return i.length>0?[[n,"policy","allow","network","--sandbox",r,i.join(",")]]:[]}function nl(e){return e.networkProfile!==void 0?"network_profile is nono-only \u2014 ignored under the sbx backend":void 0}function rl(e){return(e.openPort?.length??0)>0||(e.listenPort?.length??0)>0?"open_port/listen_port are nono-only \u2014 guest-local ports are unrestricted and host services are reachable via host.docker.internal under sbx":void 0}function il(e){return e.block!==!0&&(e.allowDomain?.length??0)>0?"sbx allow rules add to your global sbx policy but cannot subtract from it \u2014 run `sbx policy init deny-all` for strict allowlist semantics (nono enforces the allowlist exactly)":void 0}function gs(e){if(e===void 0)return[];return[nl(e),rl(e),il(e)].filter((t)=>t!==void 0)}function ps(e){return e.unixSocketDirBind.length>0?["unix_socket_dir_bind is nono-only \u2014 Unix sockets cannot cross the sbx VM boundary; grant ignored"]:[]}function Un(e){let t=e.piVersion===null?`command -v pi >/dev/null 2>&1 || npm i -g ${ls}`:`command -v pi >/dev/null 2>&1 && [ "$(pi --version 2>/dev/null)" = "${e.piVersion}" ] || npm i -g ${ls}@${e.piVersion}`;return[e.sbxBin,"exec",e.name,"bash","-lc",t]}function on(e,t){return[e.sbxBin,"exec","-i",...e.tty?["-t"]:[],"-e",`HOME=${e.home}`,"-w",e.cwd,e.name,...t]}function ms(e){return e.toLowerCase().includes("already exists")}function Fs(e){let t;try{t=new URL(e)}catch{return e}if(t.hostname!=="localhost"&&t.hostname!=="127.0.0.1")return e;return t.hostname=cs,t.toString()}function ys(e,t={}){return`// generated by cradle from the agent folder's models.json \u2014 do not edit
|
|
101
101
|
import type { ExtensionAPI } from '@earendil-works/pi-coding-agent';
|
|
102
102
|
|
|
103
|
-
const providers = ${
|
|
103
|
+
const providers = ${t.rewriteLocalhostBaseUrls===!0?sl(e):e} as const;
|
|
104
104
|
|
|
105
105
|
export default function (pi: ExtensionAPI): void {
|
|
106
106
|
for (const [name, config] of Object.entries(providers)) {
|
|
107
107
|
pi.registerProvider(name, config as never);
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
-
`}function
|
|
111
|
-
`}async function As(e,n){let t=await Promise.all(n.map(async(r)=>{let i=[];return{entries:await El(e,r,i),warnings:i}}));return{entries:t.flatMap((r)=>r.entries),warnings:t.flatMap((r)=>r.warnings)}}async function El(e,n,t){let r=Ge(e,"node_modules",n.name),i=await Cl(n.name,r,t);if(i===null)return[];let s=await wl(r,i,n.name,t);return $l(s,n,r)}async function Cl(e,n,t){let r=Ge(n,"package.json"),i=await Ae(r);if(i===void 0)return t.push(`package ${e} is not installed \u2014 skipped`),null;try{let s=yn(i,r);if(!le(s))return t.push(`package ${e}: ${r} must be a JSON object \u2014 skipped`),null;return s}catch(s){return t.push(`package ${e}: ${Se(s)} \u2014 skipped`),null}}async function wl(e,n,t,r){let i=xl(n);if(i!==void 0)return Sl(e,i,t,r);let s=await Ps(Ge(e,"extensions"));if(s.length>0)return s;return Ol(t,e,r)}function xl(e){let n=e.pi;if(n===void 0||!le(n))return;let t=n.extensions;if(t===void 0||!ze(t)||t.length===0)return;return t}async function Sl(e,n,t,r){let i=n.filter((c)=>!On(c)),o=(await Promise.all(i.map((c)=>Al(e,c,t,r)))).flat(),u=n.filter(On);return u.length>0?qt(o,u,e):o}async function Al(e,n,t,r){let i=await Pl(e,n),s=i.filter((u)=>vl(e,u));if(s.length<i.length)r.push(`package ${t}: extension entry "${n}" escapes the package directory \u2014 skipped`);let o=await Promise.all(s.map(async(u)=>({files:await _l(u)})));if(o.some((u)=>u.files===null))r.push(`package ${t}: extension entry "${n}" not found \u2014 skipped`);return o.flatMap((u)=>u.files??[])}async function Pl(e,n){if(!fl.test(n))return[Es(e,n)];let t=new Bun.Glob(n).scan({cwd:e,absolute:!0,onlyFiles:!1});return(await Array.fromAsync(t)).map((r)=>Es(r)).sort()}async function _l(e){let n=await jl(e);if(n===void 0)return null;return n.isDirectory()?Ps(e):[e]}async function Ps(e){let t=[...await kl(e)].sort((i,s)=>i.name.localeCompare(s.name));return(await Promise.all(t.map((i)=>Bl(e,i)))).flat()}async function Bl(e,n){if(n.name.startsWith(".")||n.name==="node_modules")return[];if(n.isFile())return dl.test(n.name)?[Ge(e,n.name)]:[];if(!n.isDirectory())return[];let t=await _s([Ge(e,n.name,"index.ts"),Ge(e,n.name,"index.js")]);return t===null?[]:[t]}async function Ol(e,n,t){let r=await _s([Ge(n,"index.ts"),Ge(n,"index.js")]);if(r===null)return t.push(`package ${e} declares no pi extensions \u2014 skipped`),[];return[r]}function $l(e,n,t){if(n.autoloadDisabled===!0)return bs(e,n.extensions??[],t);if(n.extensions===void 0)return[...e];if(n.extensions.length===0)return[];return qt(e,n.extensions,t)}function vl(e,n){let t=e.endsWith(Cs)?e:`${e}${Cs}`;return n===e||n.startsWith(t)}async function _s(e){return(await Promise.all(e.map(async(t)=>await Bun.file(t).exists()?t:null))).find((t)=>t!==null)??null}async function jl(e){try{return await ul(e)}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))return;throw n}}async function kl(e){try{return await al(e,{withFileTypes:!0})}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))return[];throw n}}var Bs=["off","minimal","low","medium","high","xhigh","max"],Os=new Set(["subagents","channels","connections"]),Il=new Set(["SYSTEM.md","APPEND_SYSTEM.md","settings.json","models.json","skills","schedule","extensions","sandbox"]),Tl=new Set([".git",".gitignore",".DS_Store","README.md","LICENSE"]),$n={read:[],write:[],allow:[],unixSocketDirBind:[]},ot={posture:"unconfigured",filesystem:$n,unsafeMacosSeatbeltRules:[]};async function at(e){let n=Rl(e),t=await Ll(n),r=new Map(t.map((c)=>[c.name,c])),i=r.has("SYSTEM.md"),s=r.has("APPEND_SYSTEM.md");if(!i&&!s){let c=r.has("AGENTS.md")?" \u2014 found AGENTS.md, rename it to APPEND_SYSTEM.md":"";throw Error(`Not an agent folder: ${n} (needs SYSTEM.md or APPEND_SYSTEM.md${c} \u2014 see ARCHITECTURE.md)`)}let o=[];Wl(t,o);let u=await Zl(n,r.get("sandbox"),o);return{dir:n,systemFilePath:i?we(n,"SYSTEM.md"):null,appendSystemFilePath:s?we(n,"APPEND_SYSTEM.md"):null,settings:await Vl(n,r.has("settings.json"),o),providersJson:await Yl(n,r.has("models.json"),o),skillsDir:await Kl(n,r.get("skills"),o),scheduleDir:await ql(n,r.get("schedule"),o),extensionFiles:await Xl(n,r.get("extensions"),o),sandbox:u.nono,sbx:u.sbx,warnings:o}}async function Ll(e){try{return await ks(e,{withFileTypes:!0})}catch(n){if(de(n,"ENOENT")||de(n,"ENOTDIR"))throw Error(`Agent folder not found: ${e}`,{cause:n});throw n}}async function ut(e,n){if(n.isDirectory())return!0;if(!n.isSymbolicLink())return!1;try{return(await Nl(we(e,n.name))).isDirectory()}catch(t){if(de(t,"ENOENT"))return!1;throw t}}function Wl(e,n){let t=e.filter((i)=>Os.has(i.name)).map((i)=>i.name),r=e.map((i)=>i.name).filter((i)=>!Il.has(i)&&!Os.has(i)&&!Tl.has(i));if(t.length>0)n.push(`reserved for a future cradle release, ignored: ${t.join(", ")}`);if(r.length>0)n.push(`not part of the agent folder format, ignored: ${r.join(", ")}${Hl(r)}`)}function Hl(e){return e.includes("schedules")?" \u2014 did you mean schedule/ (singular)?":""}async function Vl(e,n,t){if(!n)return{};let r=we(e,"settings.json"),i=await Qt(r);Gl(i,r,t);let s=Xt(i,"defaultProvider",r,t),o=Xt(i,"defaultModel",r,t),u=lc(i,r,t),c=xs(i,r,t),p=Ul(i,r,t);return{...s!==void 0?{defaultProvider:s}:{},...o!==void 0?{defaultModel:o}:{},...u!==void 0?{defaultThinkingLevel:u}:{},...c.length>0?{packages:c}:{},...p!==void 0?{npmCommand:p}:{}}}var zl=new Set(["defaultProvider","defaultModel","defaultThinkingLevel","packages","npmCommand"]);function Gl(e,n,t){let r=Object.keys(e).filter((i)=>!zl.has(i));if(r.length>0)t.push(`${n}: keys cradle does not map are ignored \u2014 pi reads them from ~/.pi/agent/settings.json or `+`the project's .pi/settings.json, not the agent folder: ${r.join(", ")}`)}var $s=new Set(["npm","pnpm","yarn","bun"]);function Ul(e,n,t){let r=e.npmCommand;if(r===void 0)return;let[i,...s]=ze(r)?r:[];if(i===void 0||s.length>0||!$s.has(i)){let o=[...$s].join(", ");t.push(`${n}: npmCommand must be a single-element array naming one of ${o} \u2014 ignored`);return}return[i]}async function Yl(e,n,t){if(!n)return null;let r=we(e,"models.json"),i=await Qt(r),s=i.providers;if(s===void 0||!le(s))throw Error(`${r} must contain a "providers" object`);return Oe(i,r,["providers"],t),JSON.stringify(Jl(s),null,2)}function Jl(e){let n={input:0,output:0,cacheRead:0,cacheWrite:0};return Object.fromEntries(Object.entries(e).map(([t,r])=>{if(!le(r)||!Array.isArray(r.models))return[t,r];let i=r.models.map((s)=>le(s)&&s.cost===void 0?{cost:n,...s}:s);return[t,{...r,models:i}]}))}async function Kl(e,n,t){if(!n)return null;if(!await ut(e,n))return t.push("skills must be a directory \u2014 ignored"),null;return we(e,"skills")}async function ql(e,n,t){if(!n)return null;if(!await ut(e,n))return t.push("schedule must be a directory \u2014 ignored"),null;return we(e,"schedule")}async function Xl(e,n,t){if(!n)return[];if(!await ut(e,n))return t.push("extensions must be a directory \u2014 ignored"),[];let r=we(e,"extensions"),i=await ks(r,{withFileTypes:!0});return(await Promise.all(i.sort((o,u)=>o.name.localeCompare(u.name)).map(async(o)=>{if(o.isFile()&&o.name.endsWith(".ts")&&!o.name.startsWith("."))return we(r,o.name);if(o.isDirectory()){let u=we(r,o.name,"index.ts");return await Bun.file(u).exists()?u:null}return null}))).filter((o)=>o!==null)}async function Zl(e,n,t){let r={nono:ot,sbx:ot};if(!n)return r;if(!await ut(e,n))return t.push("sandbox must be a directory \u2014 ignored"),r;let i=we(e,"sandbox","nono.json"),s=we(e,"sandbox","sbx.json"),o=await vs(i),u=await vs(s);if(o===void 0&&u===void 0)return t.push("sandbox/ has no nono.json or sbx.json \u2014 sandboxing stays off unless --sandbox is passed"),r;return{nono:o===void 0?ot:Ql(o,i,t),sbx:u===void 0?ot:ec(u,s,t)}}function Ql(e,n,t){let r=lt(e,"sandbox",n,t),i=sc(e,n,t);return ic(e,n,t),Oe(e,n,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules","net"],t),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:ac(e.filesystem,n,t),unsafeMacosSeatbeltRules:oc(e.unsafe_macos_seatbelt_rules,n,t)}}function ec(e,n,t){let r=lt(e,"sandbox",n,t),i=nc(e,n,t);return Zt({record:e,key:"unsafe_macos_seatbelt_rules",path:n,explanation:"the sbx VM boundary replaces Seatbelt"},t),Oe(e,n,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules"],t),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:tc(e.filesystem,n,t),unsafeMacosSeatbeltRules:[]}}function nc(e,n,t){let r=e.network;if(r===void 0)return;if(!le(r)){t.push(`${n}: network must be an object \u2014 ignored`);return}for(let c of["network_profile","open_port","listen_port"])Zt({record:r,key:c,path:n},t);let i=`${n} network`;Oe(r,i,["block","allow_domain","network_profile","open_port","listen_port"],t);let s=lt(r,"block",i,t),o=Ms(r,"allow_domain",i,t),u={...s!==void 0?{block:s}:{},...o.length>0?{allowDomain:o}:{}};return Object.keys(u).length>0?u:void 0}function tc(e,n,t){if(e===void 0)return $n;if(!le(e))return t.push(`${n}: filesystem must be an object \u2014 ignored`),$n;return Zt({record:e,key:"unix_socket_dir_bind",path:n,explanation:"Unix sockets cannot cross the sbx VM boundary"},t),Oe(e,`${n} filesystem`,["read","write","allow","unix_socket_dir_bind"],t),{read:dn(e,"read",n,t),write:dn(e,"write",n,t),allow:dn(e,"allow",n,t),unixSocketDirBind:[]}}function Zt({record:e,key:n,path:t,explanation:r},i){if(e[n]===void 0)return;i.push(`${t}: ${n} is nono-only \u2014 ${r!==void 0?`${r}; `:""}ignored`)}async function vs(e){return await rc(e)?Qt(e):void 0}async function rc(e){try{return await Ml(e),!0}catch(n){if(de(n,"ENOENT"))return!1;throw n}}function ic(e,n,t){if(e.net!==void 0)t.push(`${n}: "net" was removed \u2014 use "network" instead (see ARCHITECTURE.md) \u2014 ignored`)}function sc(e,n,t){let r=e.network;if(r===void 0)return;if(!le(r)){t.push(`${n}: network must be an object \u2014 ignored`);return}let i=`${n} network`;Oe(r,i,["block","network_profile","allow_domain","open_port","listen_port"],t);let s=lt(r,"block",i,t),o=Xt(r,"network_profile",i,t),u=Ms(r,"allow_domain",i,t),c=js(r,"open_port",i,t),p=js(r,"listen_port",i,t),b={...s!==void 0?{block:s}:{},...o!==void 0?{networkProfile:o}:{},...u.length>0?{allowDomain:u}:{},...c.length>0?{openPort:c}:{},...p.length>0?{listenPort:p}:{}};return Object.keys(b).length>0?b:void 0}function Ms(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!ze(i))return r.push(`${t}: ${n} must be an array of strings \u2014 ignored`),[];let s=i.map((o)=>o.trim()).filter((o)=>o!=="");if(s.length!==i.length)r.push(`${t}: ${n} entries must be non-empty \u2014 blanks ignored`);return s}function js(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!Array.isArray(i))return r.push(`${t}: ${n} must be an array of port numbers \u2014 ignored`),[];let s=(u)=>typeof u==="number"&&Number.isInteger(u)&&u>=0&&u<=65535,o=i.filter((u)=>!s(u)).map((u)=>typeof u==="object"&&u!==null?JSON.stringify(u):String(u));if(o.length>0)r.push(`${t}: ${n} entries must be integers 0\u201365535 \u2014 ignored: ${o.join(", ")}`);return i.filter(s)}function oc(e,n,t){if(e===void 0)return[];if(!ze(e))return t.push(`${n}: unsafe_macos_seatbelt_rules must be an array of strings \u2014 ignored`),[];let r=(s)=>{let o=s.trim();return o.startsWith("(")&&o.endsWith(")")},i=e.filter((s)=>!r(s));if(i.length>0)t.push(`${n}: unsafe_macos_seatbelt_rules entries must be parenthesized s-expressions \u2014 ignored: ${i.join(", ")}`);return e.filter(r).map((s)=>s.trim())}function lt(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="boolean"){r.push(`${t}: ${n} must be true or false \u2014 ignored`);return}return i}function ac(e,n,t){if(e===void 0)return $n;if(!le(e))return t.push(`${n}: filesystem must be an object \u2014 ignored`),$n;return Oe(e,`${n} filesystem`,["read","write","allow","unix_socket_dir_bind"],t),{read:dn(e,"read",n,t),write:dn(e,"write",n,t),allow:dn(e,"allow",n,t),unixSocketDirBind:dn(e,"unix_socket_dir_bind",n,t)}}function dn(e,n,t,r){let i=e[n];if(i===void 0)return[];if(!ze(i))return r.push(`${t}: ${n} must be an array of strings \u2014 ignored`),[];let s=i.filter((o)=>!cn(o));if(s.length>0)r.push(`${t}: ${n} entries must be absolute, ~/, or $HOME/ paths \u2014 ignored: ${s.join(", ")}`);return i.filter(cn)}async function Qt(e){let n=yn(await uc(e),e);if(!le(n))throw Error(`${e} must be a JSON object`);return n}async function uc(e){let n;try{n=await Ae(e)}catch(t){throw Error(`${e} could not be read: ${Se(t)}`,{cause:t})}if(n===void 0)throw Error(`${e} could not be read \u2014 broken symlink?`);return n}function Xt(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="string"){r.push(`${t}: ${n} must be a string \u2014 ignored`);return}return i}function lc(e,n,t){let r=e.defaultThinkingLevel;if(r===void 0)return;if(typeof r!=="string"||!Bs.includes(r)){t.push(`${n}: defaultThinkingLevel must be one of ${Bs.join(", ")} \u2014 ignored`);return}return r}import{exists as cc,readdir as dc}from"fs/promises";import{basename as fc,extname as hc,join as Is,resolve as Dc}from"path";var gc=["name","description","cron","cwd"],Ns=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function ct(e){let n=await cc(Is(e,"schedules"))?" \u2014 found schedules/, rename it to schedule/ (singular)":"";return Error(`No schedule/ directory in ${e}${n}`)}async function dt(e,n){let t=await dc(e,{withFileTypes:!0}),r=[];return{schedules:[...(await Promise.all(t.map((o)=>pc(e,o,n,r)))).filter((o)=>o!==null)].sort((o,u)=>o.slug.localeCompare(u.slug)),warnings:r}}async function pc(e,n,t,r){let i=Is(e,n.name);if(n.isDirectory())return r.push(`${i}: subdirectories are not supported in schedule/ \u2014 ignored`),null;if(!n.isFile()&&!n.isSymbolicLink())return r.push(`${i}: only files are read from schedule/ \u2014 ignored`),null;if(hc(n.name)!==".md")return r.push(`${i}: only .md files are read from schedule/ \u2014 ignored`),null;return mc(i,t,r)}async function mc(e,n,t){let r=fc(e,".md");if(!Ns.test(r))return t.push(`${e}: filename must match ${Ns.source} \u2014 a schedule slug becomes a launchd label and a `+"systemd unit name \u2014 ignored"),null;let i=await Ae(e);if(i===void 0)return t.push(`${e}: could not be read \u2014 broken symlink? \u2014 ignored`),null;let s=Fc(i);if(s===null)return t.push(`${e}: missing YAML frontmatter block (a file starting with "---" and a closing "---") \u2014 ignored`),null;let o=yc(s.frontmatter,e,t);if(o===null)return null;return bc({slug:r,path:e,frontmatter:o,body:s.body,home:n,warnings:t})}function Fc(e){let n=e.split(`
|
|
112
|
-
`).map((r)=>r.replace(/\r$/,""));if(
|
|
113
|
-
`),body:
|
|
114
|
-
`)}}function yc(e,n,t){let r;try{r=Bun.YAML.parse(e)}catch(i){return t.push(`${n}: frontmatter is not valid YAML: ${Se(i)} \u2014 ignored`),null}if(typeof r!=="object"||r===null||Array.isArray(r))return t.push(`${n}: frontmatter must be a YAML mapping \u2014 ignored`),null;return r}function bc(e){let{slug:n,path:t,frontmatter:r,body:i,home:s,warnings:o}=e;Ec(r,t,o);let u=Cc(r,t,o),c=wc(r,t,s,o),p=Rs(r,"name",t,o),b=Rs(r,"description",t,o),g=i.trim();if(u===null||c===null)return null;if(g==="")return o.push(`${t}: body is empty \u2014 a schedule with no prompt does nothing \u2014 ignored`),null;return{slug:n,name:p??n,path:t,cron:u,cwd:c,...b!==void 0?{description:b}:{},prompt:g}}function Ec(e,n,t){let r=Object.keys(e).filter((i)=>!gc.includes(i));if(r.length>0)t.push(`${n}: unsupported keys ignored: ${r.join(", ")}`)}function Cc(e,n,t){let r=e.cron;if(typeof r!=="string"||r.trim()==="")return t.push(`${n}: cron must be a non-empty string \u2014 ignored`),null;return r}function wc(e,n,t,r){let i=e.cwd;if(typeof i!=="string"||!cn(i))return r.push(`${n}: cwd must be an absolute, ~/, or $HOME/ path${xc(i)} \u2014 ignored`),null;return Dc(ln(i,t))}function xc(e){return e===null?' (a bare "~" is YAML null \u2014 quote it as "~" or write ~/some/dir)':""}function Rs(e,n,t,r){let i=e[n];if(i===void 0)return;if(typeof i!=="string"){r.push(`${t}: ${n} must be a string \u2014 ignored`);return}return i}import{createHash as Sc}from"crypto";import{homedir as Ac}from"os";import{basename as Pc,join as vn}from"path";function er(e){let n=Pc(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),t=Sc("sha256").update(e).digest("hex").slice(0,8);return`${n===""?"agent":n}-${t}`}function ft(e,n=Ac(),t=process.env.CRADLE_STATE_DIR){let r=t||vn(n,".cradle");return vn(r,"agents",er(e))}function Ts(e){return{extensionsDir:vn(e,"extensions"),sessionsDir:vn(e,"sessions"),miseCacheDir:vn(e,"mise-cache")}}import{readFile as _c}from"fs/promises";import{join as Ls,resolve as Ws}from"path";var Hs="gitdir:";async function Vs(e){try{return await _c(e,"utf8")}catch{return}}async function zs(e){let n=await Vs(Ls(e,".git"));if(n===void 0||!n.startsWith(Hs))return;let t=Ws(e,n.slice(Hs.length).trim()),r=await Vs(Ls(t,"commondir")),i=r!==void 0?Ws(t,r.trim()):t;return nt(e,i)?void 0:i}async function Js(e,n={}){let t=n.home??Oc(),r=n.cwd??process.cwd(),{dir:i,warnings:s}=await it(e.dir,{home:t,cwd:r}),o=await at(i),u=await jc(e,o,t,r),c=ft(o.dir,t),{extensionsDir:p,sessionsDir:b,miseCacheDir:g}=Ts(c),D=Ic(e,o),F=e.dryRun??!1,y=Zc(D.backend,F,n.which),h=Nc({folder:o,flags:e,passthrough:u.passthrough,backend:D.backend,bins:y,stateDir:c,extensionsDir:p,sessionsDir:b,miseCacheDir:g}),v=await Qc(D,o,{home:t,cwd:u.cwd,stateDir:c,profilePath:h.profilePath,sbxBin:y.sbxBin,hostPiBin:y.piBin,tty:n.tty??!1}),W=Rc(o,c);return{files:td(o,D.backend),extensionsDir:p,sessionsDir:b,warnings:[...s,...u.warnings,...D.warnings,...v.warnings],profile:v.profile,sbx:v.sbx,packages:W,launch:h,cwd:u.cwd,dryRun:F}}async function jc(e,n,t,r){let i={cwd:r,passthrough:e.passthrough??[],warnings:[]};if(e.schedule===void 0)return i;if(n.scheduleDir===null)throw await ct(n.dir);let{schedules:s,warnings:o}=await dt(n.scheduleDir,t),u=s.find((c)=>c.slug===e.schedule);if(u===void 0)throw Error(Mc(e.schedule,s));return{cwd:u.cwd,passthrough:[...i.passthrough,"--print","--name",u.name,"--no-approve","--",u.prompt],warnings:[...o,...await kc(u)]}}async function kc(e){if(await Us(e.cwd))return[];return[`schedule "${e.slug}" cwd does not exist: ${e.cwd}`]}function Mc(e,n){let t=n.length>0?` (available: ${n.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${t}`}function Nc(e){let{folder:n,flags:t,passthrough:r,backend:i,bins:s,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p}=e;return{folder:n,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p,backend:i,passthrough:r,nonoBin:s.nonoBin,piBin:i==="sbx"?"pi":s.piBin,profilePath:jn(o,qi),...t.verbose?{verbose:!0}:{}}}function Rc(e,n){let t=e.settings.packages;if(t===void 0||t.length===0)return null;return{npmDir:jn(n,"npm"),manifest:Ss(t),specs:t,installCommand:[...e.settings.npmCommand??["npm"],"install","--ignore-scripts"]}}function Ic(e,n){let{backend:t,warnings:r}=zc(e,n),i=[],s=Tc(e,n,t,i);return{backend:t,network:s,warnings:Hc(t!==null,s,[...r,...i])}}function Tc(e,n,t,r){if(e.offline)return{block:!0};let i=Lc(e.allowHost??[],r);if(i.length>0)return{allowDomain:i};return t==="sbx"?n.sbx.network:n.sandbox.network}function Lc(e,n){let t=e.map((r)=>r.trim()).filter((r)=>r!=="");if(t.length!==e.length)n.push("--allow-host entries must be non-empty \u2014 blanks ignored");return t}function Wc(e){return e!==void 0&&(e.block===!0||(e.allowDomain?.length??0)>0)}function Hc(e,n,t){if(e||!Wc(n))return t;return[...t,"network policy has no effect without the sandbox \u2014 pi runs with no network isolation (--sandbox to enforce it)"]}function Vc(e){return e.offline===!0||(e.allowHost?.length??0)>0}function zc(e,n){if(e.noSandbox===!0)return{backend:null,warnings:n.warnings};if(e.sandboxBackend!==void 0)return{backend:e.sandboxBackend,warnings:n.warnings};let t=Gc(n);if(e.noSandbox===!1||t.backend!==null)return{...t,backend:t.backend??"nono"};return Uc(e,n,t.warnings)}function Gc(e){let n=e.sandbox.posture==="enabled",t=e.sbx.posture==="enabled";if(n&&t)return{backend:"nono",warnings:[...e.warnings,"both sandbox/nono.json and sandbox/sbx.json declare a sandbox \u2014 using nono (pass --sandbox-backend sbx to override)"]};return{backend:n?"nono":t?"sbx":null,warnings:e.warnings}}function Uc(e,n,t){let r=Yc(n);if(Vc(e))return{backend:"nono",warnings:[...t,`${r} \u2014 sandbox forced on to enforce the requested network policy (--no-sandbox to override)`]};return{backend:null,warnings:[...t,`${r} \u2014 agent is running without OS isolation (--sandbox to force enable)`]}}function Yc(e){if(e.sandbox.posture==="disabled")return"sandbox disabled by sandbox/nono.json";if(e.sbx.posture==="disabled")return"sandbox disabled by sandbox/sbx.json";return"sandbox/nono.json or sbx.json not found"}async function Ks(e,n={}){let t={dryRun:!1,results:[],failures:[]};if(await ns(t,"extensions",e.extensionsDir,e.files),t.failures.length>0)throw Error(`Failed to write agent extensions: ${t.failures.join("; ")}`);if(await nr(e.sessionsDir,{recursive:!0}),e.profile!==null)await nr(vc(e.profile.path),{recursive:!0}),await Ys(e.profile.path,e.profile.content,"utf8");if(e.sbx!==null)await Jc(e.sbx,n);let r={...e.launch,extensionsDir:e.extensionsDir,sessionsDir:e.sessionsDir},i=e.packages===null?{argv:mn(r),warnings:[]}:await Xc(e.packages,r,n);if(e.sbx===null)return i;return{argv:st(e.sbx.spec,i.argv),warnings:i.warnings}}async function Jc(e,n){let t=n.run;if(t===void 0)throw Error("An sbx-backend run needs a command runner but none was provided");let r=await t(e.createArgv);if(r.exitCode!==0&&!gs(r.stderr))throw Error(`Failed to create sbx sandbox ${e.spec.name}: ${r.stderr.trim()}`);for(let i of e.policyArgvs)await Gs(t,i,`apply sbx network policy (${e.spec.name})`);await Gs(t,await Kc(e,n),`provision pi in sbx sandbox ${e.spec.name}`)}async function Gs(e,n,t){let r=await e(n);if(r.exitCode!==0)throw Error(`Failed to ${t}: ${r.stderr.trim()}`)}async function Kc(e,n){if(n.readPiVersion===void 0)return e.provisionArgv;let t=await n.readPiVersion(e.hostPiBin);return Ut({...e.spec,piVersion:t})}async function qc(e,n){if(await Ae(jn(e,"package.json"))!==n)return!1;return Us(jn(e,"node_modules"))}async function Xc(e,n,t){if(await nr(e.npmDir,{recursive:!0}),!await qc(e.npmDir,e.manifest)){if(t.install===void 0)throw Error("Packages declared but no installer provided");let s=jn(e.npmDir,"package.json");await Ys(s,e.manifest,"utf8");try{await t.install(e.installCommand,e.npmDir)}catch(o){throw await Bc(s,{force:!0}),o}}let{entries:r,warnings:i}=await As(e.npmDir,e.specs);return{argv:mn({...n,packageEntries:r}),warnings:i}}function Zc(e,n,t){if(n)return{nonoBin:"nono",piBin:"pi",sbxBin:"sbx"};return{nonoBin:e==="nono"?Fn("nono",t):"nono",sbxBin:e==="sbx"?Fn("sbx",t):"sbx",piBin:Fn("pi",t)}}async function Qc(e,n,t){let r=e.backend!==null?await zs(t.cwd):void 0,i=nd(e.backend==="nono",n,e.network,{home:t.home,cwd:t.cwd,stateDir:t.stateDir,profilePath:t.profilePath,...r!==void 0?{linkedGitDir:r}:{}});if(e.backend!=="sbx")return{profile:i,sbx:null,warnings:[]};let s=ed(e.network,n,{...t,...r!==void 0?{linkedGitDir:r}:{}});return{profile:i,sbx:s,warnings:[...hs(e.network),...Ds(n.sbx.filesystem)]}}function ed(e,n,t){let r=ls({cwd:t.cwd,agentDir:n.dir,stateDir:t.stateDir,home:t.home,grants:n.sbx.filesystem,...t.linkedGitDir!==void 0?{linkedGitDir:t.linkedGitDir}:{}}),i={sbxBin:t.sbxBin,name:cs($c(t.stateDir),r),cwd:t.cwd,home:t.home,mounts:r,...e!==void 0?{network:e}:{},piVersion:null,tty:t.tty};return{spec:i,hostPiBin:t.hostPiBin,createArgv:ds(i),policyArgvs:fs(i),provisionArgv:Ut(i)}}function nd(e,n,t,r){if(!e)return null;let i=Xi(r.cwd,r.home);if(i!==void 0)throw Error(`cannot sandbox from ${i} \u2014 this directory is (or contains) nono's protected state root `+"(~/.local/state/nono) and nono refuses to start with an overlapping grant; run `cradle run` from a project directory instead");let s=Zi({home:r.home,cwd:r.cwd,agentDir:n.dir,stateDir:r.stateDir,grants:n.sandbox.filesystem,rules:n.sandbox.unsafeMacosSeatbeltRules,...t!==void 0?{network:t}:{},...r.linkedGitDir!==void 0?{linkedGitDir:r.linkedGitDir}:{}});return{path:r.profilePath,content:s}}function td(e,n){return[...e.providersJson!==null?[{rel:"providers.ts",content:ms(e.providersJson,{rewriteLocalhostBaseUrls:n==="sbx"})}]:[],...n==="nono"?[{rel:Qn,content:zi()}]:[]]}import{exists as Td,mkdir as co,rm as Ld,writeFile as Wd}from"fs/promises";import{homedir as Hd,userInfo as Vd}from"os";import{dirname as fo,join as zd}from"path";var rd={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},id={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6};function sd(e){return e===7?0:e}var Zs={name:"minute",min:0,max:59,canonicalMax:59},Qs={name:"hour",min:0,max:23,canonicalMax:23},eo={name:"day-of-month",min:1,max:31,canonicalMax:31},no={name:"month",min:1,max:12,canonicalMax:12,names:rd},to={name:"day-of-week",min:0,max:7,canonicalMax:6,names:id,normalize:sd},od={"@hourly":"0 * * * *","@daily":"0 0 * * *","@midnight":"0 0 * * *","@weekly":"0 0 * * 0","@monthly":"0 0 1 * *","@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *"};function $e(e,n){return Error(`Invalid cron expression "${e}": ${n}`)}function ad(e){let n=e.trim();if(!n.startsWith("@"))return n;let t=od[n.toLowerCase()];if(t===void 0)throw $e(e,`unknown macro "${n}"`);return t}var qs=[Zs,Qs,eo,no,to];function ud(e,n){let t=e.split(/\s+/).filter((r)=>r.length>0);if(t.length!==qs.length)throw $e(n,`expected ${String(qs.length)} space-separated fields, got ${String(t.length)}`);return t}function Xs(e,n){return Array.from({length:n-e+1},(t,r)=>e+r)}function tr(e,n,t){let i=n.names?.[e.toLowerCase()]??(/^\d+$/.test(e)?Number(e):Number.NaN);if(!Number.isInteger(i)||i<n.min||i>n.max)throw $e(t,`${n.name} field: token "${e}" is out of range (${String(n.min)}-${String(n.max)})`);return i}function ld(e,n,t){if(e==="*")return Xs(n.min,n.max);let r=e.split("-");if(r.length===1)return[tr(e,n,t)];if(r.length!==2)throw $e(t,`${n.name} field: could not parse token "${e}"`);let[i,s]=r,o=tr(i??"",n,t),u=tr(s??"",n,t);if(o>u)throw $e(t,`${n.name} field: reversed range "${e}" (start greater than end)`);return Xs(o,u)}function cd(e,n,t){if(e===void 0)return 1;let r=/^\d+$/.test(e)?Number(e):Number.NaN;if(!Number.isInteger(r)||r<1)throw $e(t,`${n.name} field: step must be a positive integer, got "${e}"`);return r}function dd(e,n,t){let r=e.split("/");if(r.length>2)throw $e(t,`${n.name} field: could not parse token "${e}"`);let[i,s]=r;if(s!==void 0&&i!=="*"&&!i?.includes("-"))throw $e(t,`${n.name} field: a step is only valid with "*" or a range, not "${e}"`);let o=ld(i??"",n,t),u=cd(s,n,t);return o.filter((c,p)=>p%u===0)}function fd(e,n){let t=n.normalize?e.map(n.normalize):e,r=Array.from(new Set(t)).sort((s,o)=>s-o),i=n.canonicalMax-n.min+1;return r.length===i?null:r}function hd(e,n,t){if(e.length===0)throw $e(t,`${n.name} field: empty token`);let r=e.split(",").flatMap((i)=>dd(i,n,t));return fd(r,n)}function rr(e){let n=ud(ad(e),e),t=(s,o)=>hd(n[s]??"",o,e),r=t(2,eo),i=t(4,to);if(r!==null&&i!==null)throw $e(e,"day-of-month and day-of-week cannot both be restricted (cron ORs them; launchd/systemd AND them, so there is no faithful encoding)");return{minute:t(0,Zs),hour:t(1,Qs),dayOfMonth:r,month:t(3,no),dayOfWeek:i}}function kn(e,n){return e===null||e.includes(n)}function Dd(e,n){return kn(e.month,n.getMonth()+1)&&kn(e.dayOfMonth,n.getDate())&&kn(e.dayOfWeek,n.getDay())}function gd(e,n){return kn(e.hour,n.getHours())}function pd(e,n){return kn(e.minute,n.getMinutes())}function md(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function Fd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+1)}function yd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()+1)}function bd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function ro(e,n){let t=new Date(n.getFullYear(),n.getMonth(),n.getDate()+366,n.getHours(),n.getMinutes()),r=md(n);while(r.getTime()<=t.getTime()){if(!Dd(e,r)){r=Fd(r);continue}if(!gd(e,r)){r=yd(r);continue}if(pd(e,r))return r;r=bd(r)}return null}import{join as ir}from"path";var io=500;class so extends Error{constructor(e){super(`cron expression expands to ${String(e)} StartCalendarInterval dicts, over the ${String(io)}-dict cap`);this.name="LaunchdIntervalOverflowError"}}function Ed(e){return[ir(e,".local","bin"),ir(e,".local","share","mise","shims"),"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].join(":")}function Cd(e){return[{key:"Minute",field:e.minute},{key:"Hour",field:e.hour},{key:"Day",field:e.dayOfMonth},{key:"Month",field:e.month},{key:"Weekday",field:e.dayOfWeek}].filter((t)=>t.field!==null).map((t)=>({key:t.key,values:t.field}))}function wd(e){let n=Cd(e);if(n.length===0)return Array.from({length:60},(r,i)=>({Minute:i}));let t=n.reduce((r,i)=>r.flatMap((s)=>i.values.map((o)=>({...s,[i.key]:o}))),[{}]);if(t.length>io)throw new so(t.length);return t}function xd(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function En(e){return`<string>${xd(e)}</string>`}function Sd(e,n){let t=e.map((r)=>`${n} ${En(r)}`).join(`
|
|
115
|
-
`);return`${
|
|
116
|
-
${
|
|
117
|
-
${
|
|
118
|
-
${
|
|
119
|
-
`);return`${
|
|
120
|
-
${
|
|
121
|
-
${
|
|
122
|
-
`);return`${
|
|
123
|
-
${
|
|
124
|
-
${
|
|
125
|
-
`)}function
|
|
126
|
-
`))throw new
|
|
127
|
-
`)}function
|
|
128
|
-
`)}function
|
|
110
|
+
`}function sl(e){let t=JSON.parse(e);for(let n of Object.values(t)){if(n===null||typeof n!=="object")continue;let r=n;if(typeof r.baseUrl==="string")r.baseUrl=Fs(r.baseUrl)}return JSON.stringify(t,null,2)}import{lstat as Nl,readdir as Ns,stat as Rl}from"fs/promises";import{join as we,resolve as Il}from"path";import{readdir as ul,stat as ll}from"fs/promises";import{join as Ge,resolve as ws,sep as xs}from"path";import{basename as ol,relative as Es,sep as bs}from"path";function Ot(e){return e.startsWith("!")||e.startsWith("+")||e.startsWith("-")}function qn(e,t,n){let r=t.filter((u)=>!Ot(u)),i=Yn(t,"!"),s=Yn(t,"+"),o=Yn(t,"-");return e.filter((u)=>{if(Kn(u,o,n))return!1;if(Kn(u,s,n))return!0;if(Jn(u,i,n))return!1;return r.length===0||Jn(u,r,n)})}function Cs(e,t,n){return e.filter((r)=>{let i=t.filter((s)=>al(r,s,n)).at(-1);return i!==void 0&&!i.startsWith("-")&&!i.startsWith("!")})}function al(e,t,n){let r=Ot(t)?t.slice(1):t;return t.startsWith("+")||t.startsWith("-")?Kn(e,[r],n):Jn(e,[r],n)}function Yn(e,t){return e.filter((n)=>n.startsWith(t)).map((n)=>n.slice(1))}function Jn(e,t,n){let r=[yt(Es(n,e)),ol(e),yt(e)];return t.some((i)=>{let s=new Bun.Glob(yt(i));return r.some((o)=>s.match(o))})}function Kn(e,t,n){let r=yt(Es(n,e)),i=yt(e);return t.some((s)=>{let o=yt(s.startsWith("./")?s.slice(2):s);return o===r||o===i})}function yt(e){return bs==="/"?e:e.split(bs).join("/")}var cl=/^(@[a-z0-9-~][a-z0-9-._~]*\/)?[a-z0-9-~][a-z0-9-._~]*$/,dl=/^[0-9A-Za-z.^~><=* +-]+$/,fl=/\.[tj]s$/,hl=/[*?]/;function As(e,t,n){let r=e.packages;if(r===void 0)return[];if(!Array.isArray(r))return n.push(`${t}: packages must be an array \u2014 ignored`),[];let i=Dl(r,t,n),s=yl(i,t,n);return bl(s,t,n)}function Dl(e,t,n){let r=[],i=[];for(let s of e){let o=typeof s==="string"?{source:s}:gl(s,t,n);if(o===null)i.push(JSON.stringify(s));else r.push(o)}if(i.length>0)n.push(`${t}: packages entries must be a source string or a { "source": \u2026 } object \u2014 ignored: ${i.join(", ")}`);return r}function gl(e,t,n){if(!le(e))return null;let r=e.source;if(typeof r!=="string")return null;Fl(e,r,t,n);let i=e.autoload;if(i!==void 0&&typeof i!=="boolean")n.push(`${t}: packages entry ${r}: autoload must be a boolean \u2014 ignored`);let s=pl(e,r,t,n);return{source:r,...s!==void 0?{extensions:s}:{},...i===!1?{autoloadDisabled:!0}:{}}}function pl(e,t,n,r){let i=e.extensions;if(i===void 0)return;if(!ze(i)){r.push(`${n}: packages entry ${t}: extensions must be an array of strings \u2014 ignored`);return}return i}var ml=new Set(["source","extensions","autoload"]),Ss=new Set(["skills","prompts","themes"]);function Fl(e,t,n,r){let i=Object.keys(e).filter((u)=>!ml.has(u)),s=i.filter((u)=>Ss.has(u)),o=i.filter((u)=>!Ss.has(u));if(s.length>0)r.push(`${n}: packages entry ${t}: cradle loads a package's extensions and nothing else \u2014 ignored: ${s.join(", ")}`);if(o.length>0)r.push(`${n}: packages entry ${t}: unknown filter keys \u2014 ignored: ${o.join(", ")}`)}function yl(e,t,n){let r=e.filter((s)=>s.source.startsWith("npm:")),i=e.filter((s)=>!s.source.startsWith("npm:"));if(i.length>0){let s=i.map((o)=>o.source).join(", ");n.push(`${t}: only npm: package sources are supported \u2014 ignored: ${s}`)}return r}function bl(e,t,n){let r=[],i=[];for(let{source:s,...o}of e){let u=El(s.slice(4));if(u===null)i.push(s);else r.push({...u,...o})}if(i.length>0)n.push(`${t}: packages entries must be npm:<name>[@<version>] \u2014 ignored: ${i.join(", ")}`);return r}function El(e){let t=e.lastIndexOf("@"),n=t>0,r=n?e.slice(0,t):e,i=n?e.slice(t+1):"latest";if(!cl.test(r)||!dl.test(i))return null;return{name:r,version:i}}function Ps(e){let t=Object.fromEntries([...e].sort((n,r)=>n.name.localeCompare(r.name)).map((n)=>[n.name,n.version]));return`${JSON.stringify({name:"cradle-agent-packages",private:!0,dependencies:t},null,2)}
|
|
111
|
+
`}async function _s(e,t){let n=await Promise.all(t.map(async(r)=>{let i=[];return{entries:await Cl(e,r,i),warnings:i}}));return{entries:n.flatMap((r)=>r.entries),warnings:n.flatMap((r)=>r.warnings)}}async function Cl(e,t,n){let r=Ge(e,"node_modules",t.name),i=await wl(t.name,r,n);if(i===null)return[];let s=await xl(r,i,t.name,n);return vl(s,t,r)}async function wl(e,t,n){let r=Ge(t,"package.json"),i=await Ae(r);if(i===void 0)return n.push(`package ${e} is not installed \u2014 skipped`),null;try{let s=Ft(i,r);if(!le(s))return n.push(`package ${e}: ${r} must be a JSON object \u2014 skipped`),null;return s}catch(s){return n.push(`package ${e}: ${Se(s)} \u2014 skipped`),null}}async function xl(e,t,n,r){let i=Sl(t);if(i!==void 0)return Al(e,i,n,r);let s=await Bs(Ge(e,"extensions"));if(s.length>0)return s;return $l(n,e,r)}function Sl(e){let t=e.pi;if(t===void 0||!le(t))return;let n=t.extensions;if(n===void 0||!ze(n)||n.length===0)return;return n}async function Al(e,t,n,r){let i=t.filter((c)=>!Ot(c)),o=(await Promise.all(i.map((c)=>Pl(e,c,n,r)))).flat(),u=t.filter(Ot);return u.length>0?qn(o,u,e):o}async function Pl(e,t,n,r){let i=await _l(e,t),s=i.filter((u)=>jl(e,u));if(s.length<i.length)r.push(`package ${n}: extension entry "${t}" escapes the package directory \u2014 skipped`);let o=await Promise.all(s.map(async(u)=>({files:await Bl(u)})));if(o.some((u)=>u.files===null))r.push(`package ${n}: extension entry "${t}" not found \u2014 skipped`);return o.flatMap((u)=>u.files??[])}async function _l(e,t){if(!hl.test(t))return[ws(e,t)];let n=new Bun.Glob(t).scan({cwd:e,absolute:!0,onlyFiles:!1});return(await Array.fromAsync(n)).map((r)=>ws(r)).sort()}async function Bl(e){let t=await kl(e);if(t===void 0)return null;return t.isDirectory()?Bs(e):[e]}async function Bs(e){let n=[...await Ml(e)].sort((i,s)=>i.name.localeCompare(s.name));return(await Promise.all(n.map((i)=>Ol(e,i)))).flat()}async function Ol(e,t){if(t.name.startsWith(".")||t.name==="node_modules")return[];if(t.isFile())return fl.test(t.name)?[Ge(e,t.name)]:[];if(!t.isDirectory())return[];let n=await Os([Ge(e,t.name,"index.ts"),Ge(e,t.name,"index.js")]);return n===null?[]:[n]}async function $l(e,t,n){let r=await Os([Ge(t,"index.ts"),Ge(t,"index.js")]);if(r===null)return n.push(`package ${e} declares no pi extensions \u2014 skipped`),[];return[r]}function vl(e,t,n){if(t.autoloadDisabled===!0)return Cs(e,t.extensions??[],n);if(t.extensions===void 0)return[...e];if(t.extensions.length===0)return[];return qn(e,t.extensions,n)}function jl(e,t){let n=e.endsWith(xs)?e:`${e}${xs}`;return t===e||t.startsWith(n)}async function Os(e){return(await Promise.all(e.map(async(n)=>await Bun.file(n).exists()?n:null))).find((n)=>n!==null)??null}async function kl(e){try{return await ll(e)}catch(t){if(de(t,"ENOENT")||de(t,"ENOTDIR"))return;throw t}}async function Ml(e){try{return await ul(e,{withFileTypes:!0})}catch(t){if(de(t,"ENOENT")||de(t,"ENOTDIR"))return[];throw t}}var $s=["off","minimal","low","medium","high","xhigh","max"],vs=new Set(["subagents","channels","connections"]),Tl=new Set(["SYSTEM.md","APPEND_SYSTEM.md","settings.json","models.json","skills","schedule","extensions","sandbox"]),Ll=new Set([".git",".gitignore",".DS_Store","README.md","LICENSE"]),$t={read:[],write:[],allow:[],unixSocketDirBind:[]},an={posture:"unconfigured",filesystem:$t,unsafeMacosSeatbeltRules:[]};async function un(e){let t=Il(e),n=await Wl(t),r=new Map(n.map((c)=>[c.name,c])),i=r.has("SYSTEM.md"),s=r.has("APPEND_SYSTEM.md");if(!i&&!s){let c=r.has("AGENTS.md")?" \u2014 found AGENTS.md, rename it to APPEND_SYSTEM.md":"";throw Error(`Not an agent folder: ${t} (needs SYSTEM.md or APPEND_SYSTEM.md${c} \u2014 see ARCHITECTURE.md)`)}let o=[];Hl(n,o);let u=await Ql(t,r.get("sandbox"),o);return{dir:t,systemFilePath:i?we(t,"SYSTEM.md"):null,appendSystemFilePath:s?we(t,"APPEND_SYSTEM.md"):null,settings:await zl(t,r.has("settings.json"),o),providersJson:await Jl(t,r.has("models.json"),o),skillsDir:await ql(t,r.get("skills"),o),scheduleDir:await Xl(t,r.get("schedule"),o),extensionFiles:await Zl(t,r.get("extensions"),o),sandbox:u.nono,sbx:u.sbx,warnings:o}}async function Wl(e){try{return await Ns(e,{withFileTypes:!0})}catch(t){if(de(t,"ENOENT")||de(t,"ENOTDIR"))throw Error(`Agent folder not found: ${e}`,{cause:t});throw t}}async function ln(e,t){if(t.isDirectory())return!0;if(!t.isSymbolicLink())return!1;try{return(await Rl(we(e,t.name))).isDirectory()}catch(n){if(de(n,"ENOENT"))return!1;throw n}}function Hl(e,t){let n=e.filter((i)=>vs.has(i.name)).map((i)=>i.name),r=e.map((i)=>i.name).filter((i)=>!Tl.has(i)&&!vs.has(i)&&!Ll.has(i));if(n.length>0)t.push(`reserved for a future cradle release, ignored: ${n.join(", ")}`);if(r.length>0)t.push(`not part of the agent folder format, ignored: ${r.join(", ")}${Vl(r)}`)}function Vl(e){return e.includes("schedules")?" \u2014 did you mean schedule/ (singular)?":""}async function zl(e,t,n){if(!t)return{};let r=we(e,"settings.json"),i=await Qn(r);Ul(i,r,n);let s=Xn(i,"defaultProvider",r,n),o=Xn(i,"defaultModel",r,n),u=cc(i,r,n),c=As(i,r,n),p=Yl(i,r,n);return{...s!==void 0?{defaultProvider:s}:{},...o!==void 0?{defaultModel:o}:{},...u!==void 0?{defaultThinkingLevel:u}:{},...c.length>0?{packages:c}:{},...p!==void 0?{npmCommand:p}:{}}}var Gl=new Set(["defaultProvider","defaultModel","defaultThinkingLevel","packages","npmCommand"]);function Ul(e,t,n){let r=Object.keys(e).filter((i)=>!Gl.has(i));if(r.length>0)n.push(`${t}: keys cradle does not map are ignored \u2014 pi reads them from ~/.pi/agent/settings.json or `+`the project's .pi/settings.json, not the agent folder: ${r.join(", ")}`)}var js=new Set(["npm","pnpm","yarn","bun"]);function Yl(e,t,n){let r=e.npmCommand;if(r===void 0)return;let[i,...s]=ze(r)?r:[];if(i===void 0||s.length>0||!js.has(i)){let o=[...js].join(", ");n.push(`${t}: npmCommand must be a single-element array naming one of ${o} \u2014 ignored`);return}return[i]}async function Jl(e,t,n){if(!t)return null;let r=we(e,"models.json"),i=await Qn(r),s=i.providers;if(s===void 0||!le(s))throw Error(`${r} must contain a "providers" object`);return Oe(i,r,["providers"],n),JSON.stringify(Kl(s),null,2)}function Kl(e){let t={input:0,output:0,cacheRead:0,cacheWrite:0};return Object.fromEntries(Object.entries(e).map(([n,r])=>{if(!le(r)||!Array.isArray(r.models))return[n,r];let i=r.models.map((s)=>le(s)&&s.cost===void 0?{cost:t,...s}:s);return[n,{...r,models:i}]}))}async function ql(e,t,n){if(!t)return null;if(!await ln(e,t))return n.push("skills must be a directory \u2014 ignored"),null;return we(e,"skills")}async function Xl(e,t,n){if(!t)return null;if(!await ln(e,t))return n.push("schedule must be a directory \u2014 ignored"),null;return we(e,"schedule")}async function Zl(e,t,n){if(!t)return[];if(!await ln(e,t))return n.push("extensions must be a directory \u2014 ignored"),[];let r=we(e,"extensions"),i=await Ns(r,{withFileTypes:!0});return(await Promise.all(i.sort((o,u)=>o.name.localeCompare(u.name)).map(async(o)=>{if(o.isFile()&&o.name.endsWith(".ts")&&!o.name.startsWith("."))return we(r,o.name);if(o.isDirectory()){let u=we(r,o.name,"index.ts");return await Bun.file(u).exists()?u:null}return null}))).filter((o)=>o!==null)}async function Ql(e,t,n){let r={nono:an,sbx:an};if(!t)return r;if(!await ln(e,t))return n.push("sandbox must be a directory \u2014 ignored"),r;let i=we(e,"sandbox","nono.json"),s=we(e,"sandbox","sbx.json"),o=await ks(i),u=await ks(s);if(o===void 0&&u===void 0)return n.push("sandbox/ has no nono.json or sbx.json \u2014 sandboxing stays off unless --sandbox is passed"),r;return{nono:o===void 0?an:ec(o,i,n),sbx:u===void 0?an:tc(u,s,n)}}function ec(e,t,n){let r=cn(e,"sandbox",t,n),i=oc(e,t,n);return sc(e,t,n),Oe(e,t,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules","net"],n),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:uc(e.filesystem,t,n),unsafeMacosSeatbeltRules:ac(e.unsafe_macos_seatbelt_rules,t,n)}}function tc(e,t,n){let r=cn(e,"sandbox",t,n),i=nc(e,t,n);return Zn({record:e,key:"unsafe_macos_seatbelt_rules",path:t,explanation:"the sbx VM boundary replaces Seatbelt"},n),Oe(e,t,["sandbox","network","filesystem","unsafe_macos_seatbelt_rules"],n),{posture:r===!1?"disabled":"enabled",...i!==void 0?{network:i}:{},filesystem:rc(e.filesystem,t,n),unsafeMacosSeatbeltRules:[]}}function nc(e,t,n){let r=e.network;if(r===void 0)return;if(!le(r)){n.push(`${t}: network must be an object \u2014 ignored`);return}for(let c of["network_profile","open_port","listen_port"])Zn({record:r,key:c,path:t},n);let i=`${t} network`;Oe(r,i,["block","allow_domain","network_profile","open_port","listen_port"],n);let s=cn(r,"block",i,n),o=Rs(r,"allow_domain",i,n),u={...s!==void 0?{block:s}:{},...o.length>0?{allowDomain:o}:{}};return Object.keys(u).length>0?u:void 0}function rc(e,t,n){if(e===void 0)return $t;if(!le(e))return n.push(`${t}: filesystem must be an object \u2014 ignored`),$t;return Zn({record:e,key:"unix_socket_dir_bind",path:t,explanation:"Unix sockets cannot cross the sbx VM boundary"},n),Oe(e,`${t} filesystem`,["read","write","allow","unix_socket_dir_bind"],n),{read:ct(e,"read",t,n),write:ct(e,"write",t,n),allow:ct(e,"allow",t,n),unixSocketDirBind:[]}}function Zn({record:e,key:t,path:n,explanation:r},i){if(e[t]===void 0)return;i.push(`${n}: ${t} is nono-only \u2014 ${r!==void 0?`${r}; `:""}ignored`)}async function ks(e){return await ic(e)?Qn(e):void 0}async function ic(e){try{return await Nl(e),!0}catch(t){if(de(t,"ENOENT"))return!1;throw t}}function sc(e,t,n){if(e.net!==void 0)n.push(`${t}: "net" was removed \u2014 use "network" instead (see ARCHITECTURE.md) \u2014 ignored`)}function oc(e,t,n){let r=e.network;if(r===void 0)return;if(!le(r)){n.push(`${t}: network must be an object \u2014 ignored`);return}let i=`${t} network`;Oe(r,i,["block","network_profile","allow_domain","open_port","listen_port"],n);let s=cn(r,"block",i,n),o=Xn(r,"network_profile",i,n),u=Rs(r,"allow_domain",i,n),c=Ms(r,"open_port",i,n),p=Ms(r,"listen_port",i,n),b={...s!==void 0?{block:s}:{},...o!==void 0?{networkProfile:o}:{},...u.length>0?{allowDomain:u}:{},...c.length>0?{openPort:c}:{},...p.length>0?{listenPort:p}:{}};return Object.keys(b).length>0?b:void 0}function Rs(e,t,n,r){let i=e[t];if(i===void 0)return[];if(!ze(i))return r.push(`${n}: ${t} must be an array of strings \u2014 ignored`),[];let s=i.map((o)=>o.trim()).filter((o)=>o!=="");if(s.length!==i.length)r.push(`${n}: ${t} entries must be non-empty \u2014 blanks ignored`);return s}function Ms(e,t,n,r){let i=e[t];if(i===void 0)return[];if(!Array.isArray(i))return r.push(`${n}: ${t} must be an array of port numbers \u2014 ignored`),[];let s=(u)=>typeof u==="number"&&Number.isInteger(u)&&u>=0&&u<=65535,o=i.filter((u)=>!s(u)).map((u)=>typeof u==="object"&&u!==null?JSON.stringify(u):String(u));if(o.length>0)r.push(`${n}: ${t} entries must be integers 0\u201365535 \u2014 ignored: ${o.join(", ")}`);return i.filter(s)}function ac(e,t,n){if(e===void 0)return[];if(!ze(e))return n.push(`${t}: unsafe_macos_seatbelt_rules must be an array of strings \u2014 ignored`),[];let r=(s)=>{let o=s.trim();return o.startsWith("(")&&o.endsWith(")")},i=e.filter((s)=>!r(s));if(i.length>0)n.push(`${t}: unsafe_macos_seatbelt_rules entries must be parenthesized s-expressions \u2014 ignored: ${i.join(", ")}`);return e.filter(r).map((s)=>s.trim())}function cn(e,t,n,r){let i=e[t];if(i===void 0)return;if(typeof i!=="boolean"){r.push(`${n}: ${t} must be true or false \u2014 ignored`);return}return i}function uc(e,t,n){if(e===void 0)return $t;if(!le(e))return n.push(`${t}: filesystem must be an object \u2014 ignored`),$t;return Oe(e,`${t} filesystem`,["read","write","allow","unix_socket_dir_bind"],n),{read:ct(e,"read",t,n),write:ct(e,"write",t,n),allow:ct(e,"allow",t,n),unixSocketDirBind:ct(e,"unix_socket_dir_bind",t,n)}}function ct(e,t,n,r){let i=e[t];if(i===void 0)return[];if(!ze(i))return r.push(`${n}: ${t} must be an array of strings \u2014 ignored`),[];let s=i.filter((o)=>!lt(o));if(s.length>0)r.push(`${n}: ${t} entries must be absolute, ~/, or $HOME/ paths \u2014 ignored: ${s.join(", ")}`);return i.filter(lt)}async function Qn(e){let t=Ft(await lc(e),e);if(!le(t))throw Error(`${e} must be a JSON object`);return t}async function lc(e){let t;try{t=await Ae(e)}catch(n){throw Error(`${e} could not be read: ${Se(n)}`,{cause:n})}if(t===void 0)throw Error(`${e} could not be read \u2014 broken symlink?`);return t}function Xn(e,t,n,r){let i=e[t];if(i===void 0)return;if(typeof i!=="string"){r.push(`${n}: ${t} must be a string \u2014 ignored`);return}return i}function cc(e,t,n){let r=e.defaultThinkingLevel;if(r===void 0)return;if(typeof r!=="string"||!$s.includes(r)){n.push(`${t}: defaultThinkingLevel must be one of ${$s.join(", ")} \u2014 ignored`);return}return r}import{exists as dc,readdir as fc}from"fs/promises";import{basename as hc,extname as Dc,join as Ls,resolve as gc}from"path";var pc=["name","description","cron","cwd"],Is=/^[A-Za-z0-9][A-Za-z0-9._-]*$/;async function dn(e){let t=await dc(Ls(e,"schedules"))?" \u2014 found schedules/, rename it to schedule/ (singular)":"";return Error(`No schedule/ directory in ${e}${t}`)}async function fn(e,t){let n=await fc(e,{withFileTypes:!0}),r=[];return{schedules:[...(await Promise.all(n.map((o)=>mc(e,o,t,r)))).filter((o)=>o!==null)].sort((o,u)=>o.slug.localeCompare(u.slug)),warnings:r}}async function mc(e,t,n,r){let i=Ls(e,t.name);if(t.isDirectory())return r.push(`${i}: subdirectories are not supported in schedule/ \u2014 ignored`),null;if(!t.isFile()&&!t.isSymbolicLink())return r.push(`${i}: only files are read from schedule/ \u2014 ignored`),null;if(Dc(t.name)!==".md")return r.push(`${i}: only .md files are read from schedule/ \u2014 ignored`),null;return Fc(i,n,r)}async function Fc(e,t,n){let r=hc(e,".md");if(!Is.test(r))return n.push(`${e}: filename must match ${Is.source} \u2014 a schedule slug becomes a launchd label and a `+"systemd unit name \u2014 ignored"),null;let i=await Ae(e);if(i===void 0)return n.push(`${e}: could not be read \u2014 broken symlink? \u2014 ignored`),null;let s=yc(i);if(s===null)return n.push(`${e}: missing YAML frontmatter block (a file starting with "---" and a closing "---") \u2014 ignored`),null;let o=bc(s.frontmatter,e,n);if(o===null)return null;return Ec({slug:r,path:e,frontmatter:o,body:s.body,home:t,warnings:n})}function yc(e){let t=e.split(`
|
|
112
|
+
`).map((r)=>r.replace(/\r$/,""));if(t[0]!=="---")return null;let n=t.indexOf("---",1);if(n===-1)return null;return{frontmatter:t.slice(1,n).join(`
|
|
113
|
+
`),body:t.slice(n+1).join(`
|
|
114
|
+
`)}}function bc(e,t,n){let r;try{r=Bun.YAML.parse(e)}catch(i){return n.push(`${t}: frontmatter is not valid YAML: ${Se(i)} \u2014 ignored`),null}if(typeof r!=="object"||r===null||Array.isArray(r))return n.push(`${t}: frontmatter must be a YAML mapping \u2014 ignored`),null;return r}function Ec(e){let{slug:t,path:n,frontmatter:r,body:i,home:s,warnings:o}=e;Cc(r,n,o);let u=wc(r,n,o),c=xc(r,n,s,o),p=Ts(r,"name",n,o),b=Ts(r,"description",n,o),g=i.trim();if(u===null||c===null)return null;if(g==="")return o.push(`${n}: body is empty \u2014 a schedule with no prompt does nothing \u2014 ignored`),null;return{slug:t,name:p??t,path:n,cron:u,cwd:c,...b!==void 0?{description:b}:{},prompt:g}}function Cc(e,t,n){let r=Object.keys(e).filter((i)=>!pc.includes(i));if(r.length>0)n.push(`${t}: unsupported keys ignored: ${r.join(", ")}`)}function wc(e,t,n){let r=e.cron;if(typeof r!=="string"||r.trim()==="")return n.push(`${t}: cron must be a non-empty string \u2014 ignored`),null;return r}function xc(e,t,n,r){let i=e.cwd;if(typeof i!=="string"||!lt(i))return r.push(`${t}: cwd must be an absolute, ~/, or $HOME/ path${Sc(i)} \u2014 ignored`),null;return gc(ut(i,n))}function Sc(e){return e===null?' (a bare "~" is YAML null \u2014 quote it as "~" or write ~/some/dir)':""}function Ts(e,t,n,r){let i=e[t];if(i===void 0)return;if(typeof i!=="string"){r.push(`${n}: ${t} must be a string \u2014 ignored`);return}return i}import{createHash as Ac}from"crypto";import{homedir as Pc}from"os";import{basename as _c,join as vt}from"path";function er(e){let t=_c(e).toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,""),n=Ac("sha256").update(e).digest("hex").slice(0,8);return`${t===""?"agent":t}-${n}`}function hn(e,t=Pc(),n=process.env.CRADLE_STATE_DIR){let r=n||vt(t,".cradle");return vt(r,"agents",er(e))}function Ws(e){return{extensionsDir:vt(e,"extensions"),sessionsDir:vt(e,"sessions"),miseCacheDir:vt(e,"mise-cache")}}import{readFile as Bc}from"fs/promises";import{join as Hs,resolve as Vs}from"path";var zs="gitdir:";async function Gs(e){try{return await Bc(e,"utf8")}catch{return}}async function Us(e){let t=await Gs(Hs(e,".git"));if(t===void 0||!t.startsWith(zs))return;let n=Vs(e,t.slice(zs.length).trim()),r=await Gs(Hs(n,"commondir")),i=r!==void 0?Vs(n,r.trim()):n;return tn(e,i)?void 0:i}async function qs(e,t={}){let n=t.home??$c(),r=t.cwd??process.cwd(),{dir:i,warnings:s}=await sn(e.dir,{home:n,cwd:r}),o=await un(i),u=await kc(e,o,n,r),c=hn(o.dir,n),{extensionsDir:p,sessionsDir:b,miseCacheDir:g}=Ws(c),D=Tc(e,o),F=e.dryRun??!1,y=Qc(D.backend,F,t.which),h=Rc({folder:o,flags:e,passthrough:u.passthrough,backend:D.backend,bins:y,stateDir:c,extensionsDir:p,sessionsDir:b,miseCacheDir:g}),v=await ed(D,o,{home:n,cwd:u.cwd,stateDir:c,profilePath:h.profilePath,sbxBin:y.sbxBin,hostPiBin:y.piBin,tty:t.tty??!1}),W=Ic(o,c);return{files:rd(o,D.backend),extensionsDir:p,sessionsDir:b,warnings:[...s,...u.warnings,...D.warnings,...v.warnings],profile:v.profile,sbx:v.sbx,packages:W,launch:h,cwd:u.cwd,dryRun:F}}async function kc(e,t,n,r){let i={cwd:r,passthrough:e.passthrough??[],warnings:[]};if(e.schedule===void 0)return i;if(t.scheduleDir===null)throw await dn(t.dir);let{schedules:s,warnings:o}=await fn(t.scheduleDir,n),u=s.find((c)=>c.slug===e.schedule);if(u===void 0)throw Error(Nc(e.schedule,s));return{cwd:u.cwd,passthrough:[...i.passthrough,"--print","--name",u.name,"--no-approve","--",u.prompt],warnings:[...o,...await Mc(u)]}}async function Mc(e){if(await Js(e.cwd))return[];return[`schedule "${e.slug}" cwd does not exist: ${e.cwd}`]}function Nc(e,t){let n=t.length>0?` (available: ${t.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${n}`}function Rc(e){let{folder:t,flags:n,passthrough:r,backend:i,bins:s,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p}=e;return{folder:t,stateDir:o,extensionsDir:u,sessionsDir:c,miseCacheDir:p,backend:i,passthrough:r,nonoBin:s.nonoBin,piBin:i==="sbx"?"pi":s.piBin,profilePath:jt(o,Zi),...n.verbose?{verbose:!0}:{}}}function Ic(e,t){let n=e.settings.packages;if(n===void 0||n.length===0)return null;return{npmDir:jt(t,"npm"),manifest:Ps(n),specs:n,installCommand:[...e.settings.npmCommand??["npm"],"install","--ignore-scripts"]}}function Tc(e,t){let{backend:n,warnings:r}=Gc(e,t),i=[],s=Lc(e,t,n,i);return{backend:n,network:s,warnings:Vc(n!==null,s,[...r,...i])}}function Lc(e,t,n,r){if(e.offline)return{block:!0};let i=Wc(e.allowHost??[],r);if(i.length>0)return{allowDomain:i};return n==="sbx"?t.sbx.network:t.sandbox.network}function Wc(e,t){let n=e.map((r)=>r.trim()).filter((r)=>r!=="");if(n.length!==e.length)t.push("--allow-host entries must be non-empty \u2014 blanks ignored");return n}function Hc(e){return e!==void 0&&(e.block===!0||(e.allowDomain?.length??0)>0)}function Vc(e,t,n){if(e||!Hc(t))return n;return[...n,"network policy has no effect without the sandbox \u2014 pi runs with no network isolation (--sandbox to enforce it)"]}function zc(e){return e.offline===!0||(e.allowHost?.length??0)>0}function Gc(e,t){if(e.noSandbox===!0)return{backend:null,warnings:t.warnings};if(e.sandboxBackend!==void 0)return{backend:e.sandboxBackend,warnings:t.warnings};let n=Uc(t);if(e.noSandbox===!1||n.backend!==null)return{...n,backend:n.backend??"nono"};return Yc(e,t,n.warnings)}function Uc(e){let t=e.sandbox.posture==="enabled",n=e.sbx.posture==="enabled";if(t&&n)return{backend:"nono",warnings:[...e.warnings,"both sandbox/nono.json and sandbox/sbx.json declare a sandbox \u2014 using nono (pass --sandbox-backend sbx to override)"]};return{backend:t?"nono":n?"sbx":null,warnings:e.warnings}}function Yc(e,t,n){let r=Jc(t);if(zc(e))return{backend:"nono",warnings:[...n,`${r} \u2014 sandbox forced on to enforce the requested network policy (--no-sandbox to override)`]};return{backend:null,warnings:[...n,`${r} \u2014 agent is running without OS isolation (--sandbox to force enable)`]}}function Jc(e){if(e.sandbox.posture==="disabled")return"sandbox disabled by sandbox/nono.json";if(e.sbx.posture==="disabled")return"sandbox disabled by sandbox/sbx.json";return"sandbox/nono.json or sbx.json not found"}async function Xs(e,t={}){let n={dryRun:!1,results:[],failures:[]};if(await rs(n,"extensions",e.extensionsDir,e.files),n.failures.length>0)throw Error(`Failed to write agent extensions: ${n.failures.join("; ")}`);if(await tr(e.sessionsDir,{recursive:!0}),e.profile!==null)await tr(jc(e.profile.path),{recursive:!0}),await Ks(e.profile.path,e.profile.content,"utf8");if(e.sbx!==null)await Kc(e.sbx,t);let r={...e.launch,extensionsDir:e.extensionsDir,sessionsDir:e.sessionsDir},i=e.packages===null?{argv:pt(r),warnings:[]}:await Zc(e.packages,r,t);if(e.sbx===null)return i;return{argv:on(e.sbx.spec,i.argv),warnings:i.warnings}}async function Kc(e,t){let n=t.run;if(n===void 0)throw Error("An sbx-backend run needs a command runner but none was provided");let r=await n(e.createArgv);if(r.exitCode!==0&&!ms(r.stderr))throw Error(`Failed to create sbx sandbox ${e.spec.name}: ${r.stderr.trim()}`);for(let i of e.policyArgvs)await Ys(n,i,`apply sbx network policy (${e.spec.name})`);await Ys(n,await qc(e,t),`provision pi in sbx sandbox ${e.spec.name}`)}async function Ys(e,t,n){let r=await e(t);if(r.exitCode!==0)throw Error(`Failed to ${n}: ${r.stderr.trim()}`)}async function qc(e,t){if(t.readPiVersion===void 0)return e.provisionArgv;let n=await t.readPiVersion(e.hostPiBin);return Un({...e.spec,piVersion:n})}async function Xc(e,t){if(await Ae(jt(e,"package.json"))!==t)return!1;return Js(jt(e,"node_modules"))}async function Zc(e,t,n){if(await tr(e.npmDir,{recursive:!0}),!await Xc(e.npmDir,e.manifest)){if(n.install===void 0)throw Error("Packages declared but no installer provided");let s=jt(e.npmDir,"package.json");await Ks(s,e.manifest,"utf8");try{await n.install(e.installCommand,e.npmDir)}catch(o){throw await Oc(s,{force:!0}),o}}let{entries:r,warnings:i}=await _s(e.npmDir,e.specs);return{argv:pt({...t,packageEntries:r}),warnings:i}}function Qc(e,t,n){if(t)return{nonoBin:"nono",piBin:"pi",sbxBin:"sbx"};return{nonoBin:e==="nono"?mt("nono",n):"nono",sbxBin:e==="sbx"?mt("sbx",n):"sbx",piBin:mt("pi",n)}}async function ed(e,t,n){let r=e.backend!==null?await Us(n.cwd):void 0,i=nd(e.backend==="nono",t,e.network,{home:n.home,cwd:n.cwd,stateDir:n.stateDir,profilePath:n.profilePath,...r!==void 0?{linkedGitDir:r}:{}});if(e.backend!=="sbx")return{profile:i,sbx:null,warnings:[]};let s=td(e.network,t,{...n,...r!==void 0?{linkedGitDir:r}:{}});return{profile:i,sbx:s,warnings:[...gs(e.network),...ps(t.sbx.filesystem)]}}function td(e,t,n){let r=ds({cwd:n.cwd,agentDir:t.dir,stateDir:n.stateDir,home:n.home,grants:t.sbx.filesystem,...n.linkedGitDir!==void 0?{linkedGitDir:n.linkedGitDir}:{}}),i={sbxBin:n.sbxBin,name:fs(vc(n.stateDir),r),cwd:n.cwd,home:n.home,mounts:r,...e!==void 0?{network:e}:{},piVersion:null,tty:n.tty};return{spec:i,hostPiBin:n.hostPiBin,createArgv:hs(i),policyArgvs:Ds(i),provisionArgv:Un(i)}}function nd(e,t,n,r){if(!e)return null;let i=Qi(r.cwd,r.home);if(i!==void 0)throw Error(`cannot sandbox from ${i} \u2014 this directory is (or contains) nono's protected state root `+"(~/.local/state/nono) and nono refuses to start with an overlapping grant; run `cradle run` from a project directory instead");let s=es({home:r.home,cwd:r.cwd,agentDir:t.dir,stateDir:r.stateDir,grants:t.sandbox.filesystem,rules:t.sandbox.unsafeMacosSeatbeltRules,...n!==void 0?{network:n}:{},...r.linkedGitDir!==void 0?{linkedGitDir:r.linkedGitDir}:{}});return{path:r.profilePath,content:s}}function rd(e,t){return[...e.providersJson!==null?[{rel:"providers.ts",content:ys(e.providersJson,{rewriteLocalhostBaseUrls:t==="sbx"})}]:[],...t==="nono"?[{rel:Qt,content:Ui()}]:[]]}import{exists as Ld,mkdir as ho,readFile as Wd,rm as Hd,writeFile as Vd}from"fs/promises";import{homedir as zd,userInfo as Gd}from"os";import{dirname as Do,join as Ud}from"path";var id={jan:1,feb:2,mar:3,apr:4,may:5,jun:6,jul:7,aug:8,sep:9,oct:10,nov:11,dec:12},sd={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6};function od(e){return e===7?0:e}var eo={name:"minute",min:0,max:59,canonicalMax:59},to={name:"hour",min:0,max:23,canonicalMax:23},no={name:"day-of-month",min:1,max:31,canonicalMax:31},ro={name:"month",min:1,max:12,canonicalMax:12,names:id},io={name:"day-of-week",min:0,max:7,canonicalMax:6,names:sd,normalize:od},ad={"@hourly":"0 * * * *","@daily":"0 0 * * *","@midnight":"0 0 * * *","@weekly":"0 0 * * 0","@monthly":"0 0 1 * *","@yearly":"0 0 1 1 *","@annually":"0 0 1 1 *"};function $e(e,t){return Error(`Invalid cron expression "${e}": ${t}`)}function ud(e){let t=e.trim();if(!t.startsWith("@"))return t;let n=ad[t.toLowerCase()];if(n===void 0)throw $e(e,`unknown macro "${t}"`);return n}var Zs=[eo,to,no,ro,io];function ld(e,t){let n=e.split(/\s+/).filter((r)=>r.length>0);if(n.length!==Zs.length)throw $e(t,`expected ${String(Zs.length)} space-separated fields, got ${String(n.length)}`);return n}function Qs(e,t){return Array.from({length:t-e+1},(n,r)=>e+r)}function nr(e,t,n){let i=t.names?.[e.toLowerCase()]??(/^\d+$/.test(e)?Number(e):Number.NaN);if(!Number.isInteger(i)||i<t.min||i>t.max)throw $e(n,`${t.name} field: token "${e}" is out of range (${String(t.min)}-${String(t.max)})`);return i}function cd(e,t,n){if(e==="*")return Qs(t.min,t.max);let r=e.split("-");if(r.length===1)return[nr(e,t,n)];if(r.length!==2)throw $e(n,`${t.name} field: could not parse token "${e}"`);let[i,s]=r,o=nr(i??"",t,n),u=nr(s??"",t,n);if(o>u)throw $e(n,`${t.name} field: reversed range "${e}" (start greater than end)`);return Qs(o,u)}function dd(e,t,n){if(e===void 0)return 1;let r=/^\d+$/.test(e)?Number(e):Number.NaN;if(!Number.isInteger(r)||r<1)throw $e(n,`${t.name} field: step must be a positive integer, got "${e}"`);return r}function fd(e,t,n){let r=e.split("/");if(r.length>2)throw $e(n,`${t.name} field: could not parse token "${e}"`);let[i,s]=r;if(s!==void 0&&i!=="*"&&!i?.includes("-"))throw $e(n,`${t.name} field: a step is only valid with "*" or a range, not "${e}"`);let o=cd(i??"",t,n),u=dd(s,t,n);return o.filter((c,p)=>p%u===0)}function hd(e,t){let n=t.normalize?e.map(t.normalize):e,r=Array.from(new Set(n)).sort((s,o)=>s-o),i=t.canonicalMax-t.min+1;return r.length===i?null:r}function Dd(e,t,n){if(e.length===0)throw $e(n,`${t.name} field: empty token`);let r=e.split(",").flatMap((i)=>fd(i,t,n));return hd(r,t)}function rr(e){let t=ld(ud(e),e),n=(s,o)=>Dd(t[s]??"",o,e),r=n(2,no),i=n(4,io);if(r!==null&&i!==null)throw $e(e,"day-of-month and day-of-week cannot both be restricted (cron ORs them; launchd/systemd AND them, so there is no faithful encoding)");return{minute:n(0,eo),hour:n(1,to),dayOfMonth:r,month:n(3,ro),dayOfWeek:i}}function kt(e,t){return e===null||e.includes(t)}function gd(e,t){return kt(e.month,t.getMonth()+1)&&kt(e.dayOfMonth,t.getDate())&&kt(e.dayOfWeek,t.getDay())}function pd(e,t){return kt(e.hour,t.getHours())}function md(e,t){return kt(e.minute,t.getMinutes())}function Fd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function yd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate()+1)}function bd(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours()+1)}function Ed(e){return new Date(e.getFullYear(),e.getMonth(),e.getDate(),e.getHours(),e.getMinutes()+1)}function so(e,t){let n=new Date(t.getFullYear(),t.getMonth(),t.getDate()+366,t.getHours(),t.getMinutes()),r=Fd(t);while(r.getTime()<=n.getTime()){if(!gd(e,r)){r=yd(r);continue}if(!pd(e,r)){r=bd(r);continue}if(md(e,r))return r;r=Ed(r)}return null}import{join as ir}from"path";var oo=500;class ao extends Error{constructor(e){super(`cron expression expands to ${String(e)} StartCalendarInterval dicts, over the ${String(oo)}-dict cap`);this.name="LaunchdIntervalOverflowError"}}function Cd(e){return[ir(e,".local","bin"),ir(e,".local","share","mise","shims"),"/opt/homebrew/bin","/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].join(":")}function wd(e){return[{key:"Minute",field:e.minute},{key:"Hour",field:e.hour},{key:"Day",field:e.dayOfMonth},{key:"Month",field:e.month},{key:"Weekday",field:e.dayOfWeek}].filter((n)=>n.field!==null).map((n)=>({key:n.key,values:n.field}))}function xd(e){let t=wd(e);if(t.length===0)return Array.from({length:60},(r,i)=>({Minute:i}));let n=t.reduce((r,i)=>r.flatMap((s)=>i.values.map((o)=>({...s,[i.key]:o}))),[{}]);if(n.length>oo)throw new ao(n.length);return n}function Sd(e){return e.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">")}function bt(e){return`<string>${Sd(e)}</string>`}function Ad(e,t){let n=e.map((r)=>`${t} ${bt(r)}`).join(`
|
|
115
|
+
`);return`${t}<array>
|
|
116
|
+
${n}
|
|
117
|
+
${t}</array>`}function Pd(e,t){let n=Object.entries(e).map(([r,i])=>`${t} <key>${r}</key>
|
|
118
|
+
${t} <integer>${String(i)}</integer>`).join(`
|
|
119
|
+
`);return`${t}<dict>
|
|
120
|
+
${n}
|
|
121
|
+
${t}</dict>`}function _d(e,t){let n=e.map((r)=>Pd(r,`${t} `)).join(`
|
|
122
|
+
`);return`${t}<array>
|
|
123
|
+
${n}
|
|
124
|
+
${t}</array>`}function Bd(e,t,n){let{schedule:r,cradleBin:i,agentDir:s,logPath:o,home:u}=e,c=[i,"schedule","run",s,r.slug];return['<?xml version="1.0" encoding="UTF-8"?>','<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">','<plist version="1.0">',"<dict>"," <key>ProgramArguments</key>",Ad(c," ")," <key>WorkingDirectory</key>",` ${bt(r.cwd)}`," <key>StartCalendarInterval</key>",_d(n," ")," <key>StandardOutPath</key>",` ${bt(o)}`," <key>StandardErrorPath</key>",` ${bt(o)}`," <key>EnvironmentVariables</key>"," <dict>"," <key>PATH</key>",` ${bt(Cd(u))}`," </dict>"," <key>RunAtLoad</key>"," <false/>"," <key>ProcessType</key>"," <string>Background</string>"," <key>Label</key>",` ${bt(t)}`,"</dict>","</plist>",""].join(`
|
|
125
|
+
`)}function Od(e){return`gui/${String(e)}`}function uo(e,t){let n=`com.cradle.${e.agentId}.${e.schedule.slug}`,r=ir(e.home,"Library","LaunchAgents",`${n}.plist`),i=xd(t),s=Bd(e,n,i),o=Od(e.uid),u=`${o}/${n}`;return{id:n,files:[{path:r,content:s}],installSteps:[{argv:["launchctl","bootout",u],ignoreFailure:!0},{argv:["launchctl","bootstrap",o,r]},{argv:["launchctl","enable",u]}],removeSteps:[{argv:["launchctl","bootout",u],ignoreFailure:!0}]}}import{join as Mt}from"path";class lo extends Error{constructor(e){super(`systemd unit values cannot contain a newline, got ${JSON.stringify(e)}`);this.name="SystemdUnitValueError"}}function Ue(e){if(e.includes(`
|
|
126
|
+
`))throw new lo(e);return e.replaceAll("%","%%")}function $d(e){return`"${e.replaceAll("\\","\\\\").replaceAll('"',"\\\"")}"`}function vd(e){return String(e).padStart(2,"0")}function Dn(e){return e===null?"*":e.map(vd).join(",")}var jd=["Sun","Mon","Tue","Wed","Thu","Fri","Sat"];function kd(e){let t=jd[e];if(t===void 0)throw Error(`Day-of-week value out of range: ${String(e)}`);return t}function Md(e){return e===null?void 0:e.map(kd).join(",")}function Nd(e){let t=Md(e.dayOfWeek),n=`*-${Dn(e.month)}-${Dn(e.dayOfMonth)}`,r=`${Dn(e.hour)}:${Dn(e.minute)}:00`;return t===void 0?`${n} ${r}`:`${t} ${n} ${r}`}function Rd(e){return[Mt(e,".local","bin"),Mt(e,".local","share","mise","shims"),"/usr/local/bin","/usr/bin","/bin","/usr/sbin","/sbin"].join(":")}function Id(e){let t=Ue(e.schedule.name),n=Ue(e.schedule.cwd),r=Ue(e.cradleBin),i=Ue(e.agentDir),s=Ue(e.schedule.slug),o=Ue(e.logPath);return["[Unit]",`Description=${t}`,"","[Service]","Type=oneshot",`WorkingDirectory=${n}`,`Environment=PATH=${Ue(Rd(e.home))}`,`ExecStart=${[r,"schedule","run",i,s].map($d).join(" ")}`,`StandardOutput=append:${o}`,`StandardError=append:${o}`,""].join(`
|
|
127
|
+
`)}function Td(e,t){let n=Ue(e.schedule.name),r=Nd(t);return["[Unit]",`Description=${n}`,"","[Timer]",`OnCalendar=${r}`,"Persistent=true","","[Install]","WantedBy=timers.target",""].join(`
|
|
128
|
+
`)}function co(e,t){let n=`cradle-${e.agentId}-${e.schedule.slug}`,r=Mt(e.home,".config","systemd","user"),i=Mt(r,`${n}.service`),s=Mt(r,`${n}.timer`),o=`${n}.timer`;return{id:n,files:[{path:i,content:Id(e)},{path:s,content:Td(e,t)}],installSteps:[{argv:["systemctl","--user","daemon-reload"]},{argv:["systemctl","--user","enable","--now",o]}],removeSteps:[{argv:["systemctl","--user","disable","--now",o],ignoreFailure:!0},{argv:["systemctl","--user","daemon-reload"]}]}}function fo(e){return["loginctl","show-user",e,"--property=Linger"]}var sr="systemd user timers stop firing once you log out unless lingering is enabled \u2014 run `loginctl enable-linger <user>` to keep them running";function Yd(e){if(e!=="darwin"&&e!=="linux")throw Error(`Scheduled tasks are not supported on ${e} \u2014 launchd (macOS) and systemd (Linux) are the supported timer backends`)}async function Jd(e,t,n){let{dir:r,warnings:i}=await sn(e.dir,{home:t,cwd:n}),s=await un(r);if(s.scheduleDir===null)throw await dn(s.dir);let{schedules:o,warnings:u}=await fn(s.scheduleDir,t);return{folder:s,schedules:o,warnings:[...i,...u],stateDir:hn(s.dir,t)}}function Kd(e,t){return(n)=>({schedule:n,agentId:er(e.folder.dir),agentDir:e.folder.dir,cradleBin:t.cradleBin,logPath:Ud(e.stateDir,"schedule",`${n.slug}.log`),home:t.home,uid:t.uid})}async function go(e,t={}){let n=qd(e,t),r=await Jd(e,n.home,n.cwd),i=Qd(e,n.dryRun,t.which),s=Kd(r,{cradleBin:i,home:n.home,uid:n.uid}),o={flags:e,base:r,contextFor:s,platform:n.platform,deps:t,dryRun:n.dryRun,cradleBinResolved:i!==or};return e.action==="list"?ef(o):tf(o)}function qd(e,t){let n=t.platform??process.platform;return Yd(n),{home:t.home??zd(),cwd:t.cwd??process.cwd(),platform:n,uid:t.uid??Xd(),dryRun:e.dryRun??!1}}function Xd(){return process.getuid?.()??0}function Zd(e,t){return e.action==="install"&&!t}var or="cradle";function Qd(e,t,n){if(Zd(e,t))return mt("cradle",n);if(e.action!=="list")return or;return _t("cradle",n)??or}async function ef(e){let t=e.deps.now??(()=>new Date),n=await Promise.all(e.base.schedules.map((r)=>of(r,{timer:e.contextFor(r),platform:e.platform,now:t,cradleBinResolved:e.cradleBinResolved})));return{action:"list",folder:e.base.folder,platform:e.platform,rows:n,targets:[],warnings:e.base.warnings,dryRun:e.dryRun,lingerCheckArgv:null}}function tf(e){let t=nf(e.base.schedules,e.flags).map((r)=>sf(r,e.contextFor(r),e.platform)),n=e.flags.action==="install"&&e.platform==="linux"?fo(e.deps.user??Gd().username):null;return{action:e.flags.action,folder:e.base.folder,platform:e.platform,rows:[],targets:t,warnings:e.base.warnings,dryRun:e.dryRun,lingerCheckArgv:n}}function nf(e,t){if(t.slug===void 0)return e;let n=e.find((r)=>r.slug===t.slug);if(n===void 0)throw Error(rf(t.slug,e));return[n]}function rf(e,t){let n=t.length>0?` (available: ${t.map((r)=>r.slug).join(", ")})`:" (schedule/ is empty)";return`Unknown schedule "${e}"${n}`}function sf(e,t,n){return{schedule:e,timerPlan:po(t,n,rr(e.cron)),logPath:t.logPath}}function po(e,t,n){return t==="darwin"?uo(e,n):co(e,n)}async function of(e,t){let n={slug:e.slug,name:e.name,cron:e.cron,cwd:e.cwd};try{let r=rr(e.cron),i=po(t.timer,t.platform,r);return{...n,nextFire:so(r,t.now()),status:await uf(i.files,t.cradleBinResolved)}}catch(r){return{...n,cronError:Se(r),nextFire:null,status:"not-installed"}}}async function af(e,t){if(!await Ld(e.path))return"missing";if(!t)return"matches";return await Wd(e.path,"utf8")===e.content?"matches":"differs"}async function uf(e,t){let n=await Promise.all(e.map((r)=>af(r,t)));if(n.every((r)=>r==="missing"))return"not-installed";return n.every((r)=>r==="matches")?"installed":"stale"}function mo(e){if(e.length===0)return"No schedules found.";return e.map(cf).join(`
|
|
129
129
|
|
|
130
|
-
`)}
|
|
131
|
-
`)}function
|
|
132
|
-
`)[0]?.match(/v?\d+\.\d+\S*/)?.[0]??null}catch{return null}}function
|
|
130
|
+
`)}var lf={installed:"installed",stale:"stale \u2014 the installed timer predates this file; run `cradle schedule install` to update it","not-installed":"not installed"};function cf(e){return[`${e.slug} \u2014 ${e.name}`,` cron: ${e.cron} (${df(e)})`,` cwd: ${e.cwd}`,` timer: ${lf[e.status]}`].join(`
|
|
131
|
+
`)}function df(e){if(e.cronError!==void 0)return`INVALID: ${e.cronError}`;return`${e.status==="stale"?"next after install":"next"}: ${ff(e.nextFire)}`}function ff(e){return e===null?"never (cannot fire within the next year)":e.toLocaleString()}async function Fo(e,t={}){if(e.dryRun)throw Error("Cannot materialize a --dry-run schedule plan; it is a preview only");if(e.action==="remove")return{warnings:await gf(e,t)};if(e.action==="install")return{warnings:await hf(e,t)};return{warnings:[]}}async function hf(e,t){let n=yo(t),r=await Df(e.lingerCheckArgv,n);for(let i of e.targets)await pf(i.timerPlan.files),await ho(Do(i.logPath),{recursive:!0}),await bo(n,i.timerPlan.installSteps,`install schedule "${i.schedule.slug}"`);return r}async function Df(e,t){if(e===null)return[];try{return(await t(e)).stdout.includes("Linger=yes")?[]:[sr]}catch{return[sr]}}async function gf(e,t){let n=yo(t);for(let r of e.targets)await bo(n,r.timerPlan.removeSteps,`remove schedule "${r.schedule.slug}"`),await Promise.all(r.timerPlan.files.map((i)=>Hd(i.path,{force:!0})));return[]}async function pf(e){for(let t of e)await ho(Do(t.path),{recursive:!0}),await Vd(t.path,t.content,"utf8")}function yo(e){if(e.run===void 0)throw Error("A schedule install/remove needs a command runner but none was provided");return e.run}async function bo(e,t,n){for(let r of t){let i=await e(r.argv);if(i.exitCode!==0&&r.ignoreFailure!==!0)throw Error(`Failed to ${n} (${r.argv.join(" ")}): ${i.stderr.trim()}`)}}function Eo(e,t){return t?`\x1B[33m${e}\x1B[0m`:e}function Co(e,t){return()=>{e.kill(t)}}async function wo(e,t={},n){let[r,...i]=e;if(!r)throw Error("Command requires at least one argument");let s=Bun.spawn([r,...i],{stdin:"inherit",stdout:"inherit",stderr:"inherit",env:{...process.env,...t},...n!==void 0?{cwd:n}:{}}),o=Co(s,"SIGINT"),u=Co(s,"SIGTERM");process.on("SIGINT",o),process.on("SIGTERM",u);try{return await s.exited}finally{process.off("SIGINT",o),process.off("SIGTERM",u)}}async function xo(e){let[t,...n]=e;if(!t)throw Error("Command requires at least one argument");let r=Bun.spawn([t,...n],{stdin:"ignore",stdout:"ignore",stderr:"pipe",env:process.env}),[i,s]=await Promise.all([new Response(r.stderr).text(),r.exited]);return{exitCode:s,stderr:i}}async function So(e){let[t,...n]=e;if(!t)throw Error("Command requires at least one argument");let r=Bun.spawn([t,...n],{stdin:"ignore",stdout:"pipe",stderr:"pipe",env:process.env}),[i,s,o]=await Promise.all([new Response(r.stdout).text(),new Response(r.stderr).text(),r.exited]);return{exitCode:o,stdout:i,stderr:s}}async function Ao(e,t){let[n,...r]=e;if(!n)throw Error("Command requires at least one argument");let s=await Bun.spawn([n,...r],{cwd:t,stdin:"ignore",stdout:"inherit",stderr:"inherit",env:process.env}).exited;if(s!==0)throw Error(`Package install failed (${e.join(" ")} exited ${String(s)})`)}var Et=zi(process.argv.slice(2)).scriptName("cradle").version(Gi.version).usage("$0 <cmd> [args]").parserConfiguration({"populate--":!0,"parse-numbers":!1,"parse-positional-numbers":!1}).strict();Et.command("$0","show help",()=>{},async()=>{console.log(await Et.getHelp())});Et.command("run [dir]","run an agent folder with pi, sandboxed when sandbox/nono.json or sandbox/sbx.json is present",(e)=>e.positional("dir",{type:"string",default:".",describe:"agent folder, or a name from ~/.cradle/settings.json (default: .)"}).option("offline",{type:"boolean",description:"block all outbound network (overrides the folder network policy; implies --sandbox)"}).option("allow-host",{type:"array",string:!0,description:"restrict network to these hosts (repeatable; overrides the folder allowlist; implies --sandbox)"}).option("sandbox",{type:"boolean",description:"run sandboxed (--sandbox forces it when no sandbox/ file enables one or the folder opts out; --no-sandbox disables)"}).option("sandbox-backend",{type:"string",choices:["nono","sbx"],description:"sandbox implementation (implies --sandbox): nono (host OS policy) or sbx (Docker Sandboxes microVM)"}).option("verbose",{type:"boolean",default:!1,description:"show nono's full sandbox capabilities banner instead of the one-line status"}).option("dry-run",{type:"boolean",default:!1,description:"print the write plan + command, do not spawn"}).epilogue("Everything after `--` is forwarded to pi."),async(e)=>{let t=(e["--"]??[]).map(String),n=(e.allowHost??[]).map(String),r={dir:e.dir,dryRun:e.dryRun,...e.sandbox!==void 0?{noSandbox:!e.sandbox}:{},...e.sandboxBackend!==void 0?{sandboxBackend:e.sandboxBackend}:{},...e.offline?{offline:!0}:{},...n.length?{allowHost:n}:{},...e.verbose?{verbose:!0}:{},...t.length?{passthrough:t}:{}};await _o(r)});Et.command("schedule <action> [dir] [task]","manage schedule/*.md tasks as launchd (macOS) / systemd --user (Linux) timers",(e)=>e.positional("action",{type:"string",choices:["list","install","remove","run"],demandOption:!0,describe:"list every schedule, install/remove their timers, or run one now"}).positional("dir",{type:"string",default:".",describe:"agent folder, or a name from ~/.cradle/settings.json (default: .)"}).positional("task",{type:"string",describe:"schedule slug \u2014 required for `run`; an optional filter for `install`/`remove` (default: every schedule)"}).option("dry-run",{type:"boolean",default:!1,description:"install/remove: print what would change, touch nothing"}),async(e)=>{if(e.action==="run"){if(e.task===void 0){ar(Error("A task slug is required: cradle schedule run <dir> <task>"));return}await _o({dir:e.dir,schedule:e.task});return}await mf({dir:e.dir,action:e.action,...e.task!==void 0?{slug:e.task}:{},...e.dryRun?{dryRun:!0}:{}})});Et.command("doctor","check pi / nono / mise on PATH",()=>{},async()=>{let e=await Ki({readVersion:Bo});console.log(qi(e)),process.exitCode=Xi(e)});async function _o(e){try{let t=await qs(e,{tty:process.stdout.isTTY});if(gn(t.warnings),t.dryRun){yf(t);return}let n=await Xs(t,{install:Ao,run:xo,readPiVersion:Bo});if(gn(n.warnings),t.profile!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active");if(t.sbx!==null&&!e.verbose)console.log("\uD83D\uDD12 Sandbox Active (sbx)");process.exit(await wo(n.argv,Gn(t.launch),t.cwd))}catch(t){ar(t)}}async function mf(e){try{let t=await go(e);if(gn(t.warnings),t.action==="list"){console.log(mo(t.rows));return}if(t.dryRun){Ff(t);return}let n=await Fo(t,{run:So});gn(n.warnings)}catch(t){ar(t)}}function Ff(e){for(let t of e.targets){if(e.action==="install"){for(let n of t.timerPlan.files)console.log(`write: ${n.path}`);for(let n of t.timerPlan.installSteps)console.log(`install: ${n.argv.map(Ve).join(" ")}`);continue}for(let n of t.timerPlan.removeSteps)console.log(`remove: ${n.argv.map(Ve).join(" ")}`);for(let n of t.timerPlan.files)console.log(`delete: ${n.path}`)}}function yf(e){for(let r of e.files)console.log(`write: ${Po(e.extensionsDir,r.rel)}`);if(e.profile!==null)console.log(`write: ${e.profile.path}`);if(e.sbx!==null)bf(e.sbx);if(e.packages!==null)Ef(e.packages);let t=Object.entries(Gn(e.launch)).map(([r,i])=>`${r}=${Ve(i)}`),n=e.sbx!==null?on(e.sbx.spec,pt(e.launch)):pt(e.launch);console.log([...t,...n.map(Ve)].join(" "))}function bf(e){console.log(`create: ${e.createArgv.map(Ve).join(" ")}`);for(let t of e.policyArgvs)console.log(`policy: ${t.map(Ve).join(" ")}`);console.log(`provision: ${e.provisionArgv.map(Ve).join(" ")}`)}function Ef(e){console.log(`write: ${Po(e.npmDir,"package.json")}`);let t=e.specs.map((n)=>`${n.name}@${n.version}`).join(", ");console.log(`install: ${e.installCommand.join(" ")} (${e.npmDir}): ${t}`)}function gn(e){let t=process.stderr.isTTY;for(let n of e)console.error(Eo(`warning: ${n}`,t))}async function Bo(e,t=["--version"]){try{let n=Bun.spawn([e,...t],{stdout:"pipe",stderr:"ignore"}),[r,i]=await Promise.all([new Response(n.stdout).text(),n.exited]);if(i!==0)return null;return r.split(`
|
|
132
|
+
`)[0]?.match(/v?\d+\.\d+\S*/)?.[0]??null}catch{return null}}function ar(e){console.error(e instanceof Error?e.message:String(e)),process.exitCode=1}Et.parse();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@coryrylan/cradle",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.1",
|
|
4
4
|
"description": "A runtime for portable agents defined as folders — launches the pi coding agent configured from an agent folder, sandboxed with nono",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
},
|
|
46
46
|
"homepage": "https://github.com/coryrylan/cradle/tree/main/projects/cli#readme",
|
|
47
47
|
"engines": {
|
|
48
|
-
"bun": ">=1.4.
|
|
48
|
+
"bun": ">=1.4.2"
|
|
49
49
|
},
|
|
50
50
|
"publishConfig": {
|
|
51
51
|
"access": "public"
|
|
@@ -226,7 +226,7 @@
|
|
|
226
226
|
"@coryrylan/tools": "1.1.1",
|
|
227
227
|
"@eslint/js": "10.0.1",
|
|
228
228
|
"@eslint/json": "2.0.1",
|
|
229
|
-
"@types/bun": "1.4.
|
|
229
|
+
"@types/bun": "1.4.2",
|
|
230
230
|
"@types/yargs": "17.0.35",
|
|
231
231
|
"eslint": "10.9.1",
|
|
232
232
|
"eslint-plugin-jsdoc": "64.2.1",
|