@visulima/cerebro 3.0.4 → 3.0.5

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 CHANGED
@@ -1,3 +1,18 @@
1
+ ## @visulima/cerebro [3.0.5](https://github.com/visulima/visulima/compare/%40visulima%2Fcerebro%403.0.4...%40visulima%2Fcerebro%403.0.5) (2026-08-02)
2
+
3
+
4
+ ### Dependencies
5
+
6
+ * **@visulima/colorize:** upgraded to 2.1.0
7
+ * **@visulima/tabular:** upgraded to 4.1.0
8
+ * **@visulima/boxen:** upgraded to 3.1.0
9
+ * **@visulima/command-line-args:** upgraded to 2.0.1
10
+ * **@visulima/error:** upgraded to 6.1.0
11
+ * **@visulima/find-cache-dir:** upgraded to 3.0.1
12
+ * **@visulima/pail:** upgraded to 4.1.0
13
+ * **@visulima/path:** upgraded to 3.1.0
14
+ * **@visulima/string:** upgraded to 3.1.0
15
+
1
16
  ## @visulima/cerebro [3.0.4](https://github.com/visulima/visulima/compare/%40visulima%2Fcerebro%403.0.3...%40visulima%2Fcerebro%403.0.4) (2026-07-27)
2
17
 
3
18
  ## @visulima/cerebro [3.0.3](https://github.com/visulima/visulima/compare/%40visulima%2Fcerebro%403.0.2...%40visulima%2Fcerebro%403.0.3) (2026-07-27)
package/LICENSE.md CHANGED
@@ -2575,6 +2575,352 @@ Repository: git+https://github.com/visulima/visulima.git
2575
2575
  > MIT, (MIT OR CC0-1.0)
2576
2576
  >
2577
2577
  > # Bundled types:
2578
+ > ## @visulima/error
2579
+ > License: MIT
2580
+ > By: Daniel Bannert
2581
+ > Repository: git+https://github.com/visulima/visulima.git
2582
+ >
2583
+ > > MIT License
2584
+ > >
2585
+ > > Copyright (c) 2026 visulima
2586
+ > >
2587
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy
2588
+ > > of this software and associated documentation files (the "Software"), to deal
2589
+ > > in the Software without restriction, including without limitation the rights
2590
+ > > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2591
+ > > copies of the Software, and to permit persons to whom the Software is
2592
+ > > furnished to do so, subject to the following conditions:
2593
+ > >
2594
+ > > The above copyright notice and this permission notice shall be included in all
2595
+ > > copies or substantial portions of the Software.
2596
+ > >
2597
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2598
+ > > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2599
+ > > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2600
+ > > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2601
+ > > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2602
+ > > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2603
+ > > SOFTWARE.
2604
+ > >
2605
+ > > <!-- DEPENDENCIES -->
2606
+ > >
2607
+ > > # Licenses of bundled dependencies
2608
+ > >
2609
+ > > The published @visulima/error artifact additionally contains code with the following licenses:
2610
+ > > MIT
2611
+ > >
2612
+ > > # Bundled dependencies:
2613
+ > >
2614
+ > > ## is-plain-obj
2615
+ > >
2616
+ > > License: MIT
2617
+ > > By: Sindre Sorhus
2618
+ > > Repository: sindresorhus/is-plain-obj
2619
+ > >
2620
+ > > > MIT License
2621
+ > > >
2622
+ > > > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
2623
+ > > >
2624
+ > > > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2625
+ > > >
2626
+ > > > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2627
+ > > >
2628
+ > > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2629
+ > >
2630
+ > > <!-- /DEPENDENCIES -->
2631
+ > >
2632
+ > >
2633
+ > >
2634
+ > > # Licenses of bundled types
2635
+ > > The published @visulima/error artifact additionally contains code with the following licenses:
2636
+ > > Apache-2.0
2637
+ > >
2638
+ > > # Bundled types:
2639
+ > > ## ai
2640
+ > > License: Apache-2.0
2641
+ > > Repository: https://github.com/vercel/ai
2642
+ > >
2643
+ > > > Copyright 2023 Vercel, Inc.
2644
+ > > >
2645
+ > > > Licensed under the Apache License, Version 2.0 (the "License");
2646
+ > > > you may not use this file except in compliance with the License.
2647
+ > > > You may obtain a copy of the License at
2648
+ > > >
2649
+ > > > http://www.apache.org/licenses/LICENSE-2.0
2650
+ > > >
2651
+ > > > Unless required by applicable law or agreed to in writing, software
2652
+ > > > distributed under the License is distributed on an "AS IS" BASIS,
2653
+ > > > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
2654
+ > > > See the License for the specific language governing permissions and
2655
+ > > > limitations under the License.
2656
+ >
2657
+ > ---------------------------------------
2658
+ >
2659
+ > ## @visulima/fmt
2660
+ > License: MIT
2661
+ > By: Daniel Bannert
2662
+ > Repository: git+https://github.com/visulima/visulima.git
2663
+ >
2664
+ > > MIT License
2665
+ > >
2666
+ > > Copyright (c) 2026 visulima
2667
+ > >
2668
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy
2669
+ > > of this software and associated documentation files (the "Software"), to deal
2670
+ > > in the Software without restriction, including without limitation the rights
2671
+ > > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2672
+ > > copies of the Software, and to permit persons to whom the Software is
2673
+ > > furnished to do so, subject to the following conditions:
2674
+ > >
2675
+ > > The above copyright notice and this permission notice shall be included in all
2676
+ > > copies or substantial portions of the Software.
2677
+ > >
2678
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2679
+ > > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2680
+ > > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2681
+ > > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2682
+ > > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2683
+ > > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2684
+ > > SOFTWARE.
2685
+ > >
2686
+ > > <!-- DEPENDENCIES -->
2687
+ > > <!-- /DEPENDENCIES -->
2688
+ >
2689
+ > ---------------------------------------
2690
+ >
2691
+ > ## @visulima/inspector
2692
+ > License: MIT
2693
+ > By: Daniel Bannert
2694
+ > Repository: git+https://github.com/visulima/visulima.git
2695
+ >
2696
+ > > MIT License
2697
+ > >
2698
+ > > Copyright (c) 2026 visulima
2699
+ > >
2700
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy
2701
+ > > of this software and associated documentation files (the "Software"), to deal
2702
+ > > in the Software without restriction, including without limitation the rights
2703
+ > > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2704
+ > > copies of the Software, and to permit persons to whom the Software is
2705
+ > > furnished to do so, subject to the following conditions:
2706
+ > >
2707
+ > > The above copyright notice and this permission notice shall be included in all
2708
+ > > copies or substantial portions of the Software.
2709
+ > >
2710
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2711
+ > > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2712
+ > > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2713
+ > > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2714
+ > > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2715
+ > > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2716
+ > > SOFTWARE.
2717
+ > >
2718
+ > > ---
2719
+ > >
2720
+ > > Modified code from the original [loupe](https://github.com/chaijs/loupe/tree/main) repository.
2721
+ > >
2722
+ > > (The MIT License)
2723
+ > >
2724
+ > > Copyright (c) 2011-2013 Jake Luer <jake@alogicalparadox.com> (http://alogicalparadox.com)
2725
+ > >
2726
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2727
+ > >
2728
+ > > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2729
+ > >
2730
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2731
+ > >
2732
+ > > <!-- DEPENDENCIES -->
2733
+ > > <!-- /DEPENDENCIES -->
2734
+ > >
2735
+ > >
2736
+ > >
2737
+ > > # Licenses of bundled types
2738
+ > > The published @visulima/inspector artifact additionally contains code with the following licenses:
2739
+ > > (MIT OR CC0-1.0)
2740
+ > >
2741
+ > > # Bundled types:
2742
+ > > ## type-fest
2743
+ > > License: (MIT OR CC0-1.0)
2744
+ > > By: Sindre Sorhus
2745
+ > > Repository: sindresorhus/type-fest
2746
+ > >
2747
+ > > > Creative Commons Legal Code
2748
+ > > >
2749
+ > > > CC0 1.0 Universal
2750
+ > > >
2751
+ > > > CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
2752
+ > > > LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
2753
+ > > > ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
2754
+ > > > INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
2755
+ > > > REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
2756
+ > > > PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
2757
+ > > > THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
2758
+ > > > HEREUNDER.
2759
+ > > >
2760
+ > > > Statement of Purpose
2761
+ > > >
2762
+ > > > The laws of most jurisdictions throughout the world automatically confer
2763
+ > > > exclusive Copyright and Related Rights (defined below) upon the creator
2764
+ > > > and subsequent owner(s) (each and all, an "owner") of an original work of
2765
+ > > > authorship and/or a database (each, a "Work").
2766
+ > > >
2767
+ > > > Certain owners wish to permanently relinquish those rights to a Work for
2768
+ > > > the purpose of contributing to a commons of creative, cultural and
2769
+ > > > scientific works ("Commons") that the public can reliably and without fear
2770
+ > > > of later claims of infringement build upon, modify, incorporate in other
2771
+ > > > works, reuse and redistribute as freely as possible in any form whatsoever
2772
+ > > > and for any purposes, including without limitation commercial purposes.
2773
+ > > > These owners may contribute to the Commons to promote the ideal of a free
2774
+ > > > culture and the further production of creative, cultural and scientific
2775
+ > > > works, or to gain reputation or greater distribution for their Work in
2776
+ > > > part through the use and efforts of others.
2777
+ > > >
2778
+ > > > For these and/or other purposes and motivations, and without any
2779
+ > > > expectation of additional consideration or compensation, the person
2780
+ > > > associating CC0 with a Work (the "Affirmer"), to the extent that he or she
2781
+ > > > is an owner of Copyright and Related Rights in the Work, voluntarily
2782
+ > > > elects to apply CC0 to the Work and publicly distribute the Work under its
2783
+ > > > terms, with knowledge of his or her Copyright and Related Rights in the
2784
+ > > > Work and the meaning and intended legal effect of CC0 on those rights.
2785
+ > > >
2786
+ > > > 1. Copyright and Related Rights. A Work made available under CC0 may be
2787
+ > > > protected by copyright and related or neighboring rights ("Copyright and
2788
+ > > > Related Rights"). Copyright and Related Rights include, but are not
2789
+ > > > limited to, the following:
2790
+ > > >
2791
+ > > > i. the right to reproduce, adapt, distribute, perform, display,
2792
+ > > > communicate, and translate a Work;
2793
+ > > > ii. moral rights retained by the original author(s) and/or performer(s);
2794
+ > > > iii. publicity and privacy rights pertaining to a person's image or
2795
+ > > > likeness depicted in a Work;
2796
+ > > > iv. rights protecting against unfair competition in regards to a Work,
2797
+ > > > subject to the limitations in paragraph 4(a), below;
2798
+ > > > v. rights protecting the extraction, dissemination, use and reuse of data
2799
+ > > > in a Work;
2800
+ > > > vi. database rights (such as those arising under Directive 96/9/EC of the
2801
+ > > > European Parliament and of the Council of 11 March 1996 on the legal
2802
+ > > > protection of databases, and under any national implementation
2803
+ > > > thereof, including any amended or successor version of such
2804
+ > > > directive); and
2805
+ > > > vii. other similar, equivalent or corresponding rights throughout the
2806
+ > > > world based on applicable law or treaty, and any national
2807
+ > > > implementations thereof.
2808
+ > > >
2809
+ > > > 2. Waiver. To the greatest extent permitted by, but not in contravention
2810
+ > > > of, applicable law, Affirmer hereby overtly, fully, permanently,
2811
+ > > > irrevocably and unconditionally waives, abandons, and surrenders all of
2812
+ > > > Affirmer's Copyright and Related Rights and associated claims and causes
2813
+ > > > of action, whether now known or unknown (including existing as well as
2814
+ > > > future claims and causes of action), in the Work (i) in all territories
2815
+ > > > worldwide, (ii) for the maximum duration provided by applicable law or
2816
+ > > > treaty (including future time extensions), (iii) in any current or future
2817
+ > > > medium and for any number of copies, and (iv) for any purpose whatsoever,
2818
+ > > > including without limitation commercial, advertising or promotional
2819
+ > > > purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
2820
+ > > > member of the public at large and to the detriment of Affirmer's heirs and
2821
+ > > > successors, fully intending that such Waiver shall not be subject to
2822
+ > > > revocation, rescission, cancellation, termination, or any other legal or
2823
+ > > > equitable action to disrupt the quiet enjoyment of the Work by the public
2824
+ > > > as contemplated by Affirmer's express Statement of Purpose.
2825
+ > > >
2826
+ > > > 3. Public License Fallback. Should any part of the Waiver for any reason
2827
+ > > > be judged legally invalid or ineffective under applicable law, then the
2828
+ > > > Waiver shall be preserved to the maximum extent permitted taking into
2829
+ > > > account Affirmer's express Statement of Purpose. In addition, to the
2830
+ > > > extent the Waiver is so judged Affirmer hereby grants to each affected
2831
+ > > > person a royalty-free, non transferable, non sublicensable, non exclusive,
2832
+ > > > irrevocable and unconditional license to exercise Affirmer's Copyright and
2833
+ > > > Related Rights in the Work (i) in all territories worldwide, (ii) for the
2834
+ > > > maximum duration provided by applicable law or treaty (including future
2835
+ > > > time extensions), (iii) in any current or future medium and for any number
2836
+ > > > of copies, and (iv) for any purpose whatsoever, including without
2837
+ > > > limitation commercial, advertising or promotional purposes (the
2838
+ > > > "License"). The License shall be deemed effective as of the date CC0 was
2839
+ > > > applied by Affirmer to the Work. Should any part of the License for any
2840
+ > > > reason be judged legally invalid or ineffective under applicable law, such
2841
+ > > > partial invalidity or ineffectiveness shall not invalidate the remainder
2842
+ > > > of the License, and in such case Affirmer hereby affirms that he or she
2843
+ > > > will not (i) exercise any of his or her remaining Copyright and Related
2844
+ > > > Rights in the Work or (ii) assert any associated claims and causes of
2845
+ > > > action with respect to the Work, in either case contrary to Affirmer's
2846
+ > > > express Statement of Purpose.
2847
+ > > >
2848
+ > > > 4. Limitations and Disclaimers.
2849
+ > > >
2850
+ > > > a. No trademark or patent rights held by Affirmer are waived, abandoned,
2851
+ > > > surrendered, licensed or otherwise affected by this document.
2852
+ > > > b. Affirmer offers the Work as-is and makes no representations or
2853
+ > > > warranties of any kind concerning the Work, express, implied,
2854
+ > > > statutory or otherwise, including without limitation warranties of
2855
+ > > > title, merchantability, fitness for a particular purpose, non
2856
+ > > > infringement, or the absence of latent or other defects, accuracy, or
2857
+ > > > the present or absence of errors, whether or not discoverable, all to
2858
+ > > > the greatest extent permissible under applicable law.
2859
+ > > > c. Affirmer disclaims responsibility for clearing rights of other persons
2860
+ > > > that may apply to the Work or any use thereof, including without
2861
+ > > > limitation any person's Copyright and Related Rights in the Work.
2862
+ > > > Further, Affirmer disclaims responsibility for obtaining any necessary
2863
+ > > > consents, permissions or other rights required for any use of the
2864
+ > > > Work.
2865
+ > > > d. Affirmer understands and acknowledges that Creative Commons is not a
2866
+ > > > party to this document and has no duty or obligation with respect to
2867
+ > > > this CC0 or use of the Work.
2868
+ >
2869
+ > ---------------------------------------
2870
+ >
2871
+ > ## @visulima/redact
2872
+ > License: MIT
2873
+ > By: Daniel Bannert
2874
+ > Repository: git+https://github.com/visulima/visulima.git
2875
+ >
2876
+ > > MIT License
2877
+ > >
2878
+ > > Copyright (c) 2026 visulima
2879
+ > >
2880
+ > > Permission is hereby granted, free of charge, to any person obtaining a copy
2881
+ > > of this software and associated documentation files (the "Software"), to deal
2882
+ > > in the Software without restriction, including without limitation the rights
2883
+ > > to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
2884
+ > > copies of the Software, and to permit persons to whom the Software is
2885
+ > > furnished to do so, subject to the following conditions:
2886
+ > >
2887
+ > > The above copyright notice and this permission notice shall be included in all
2888
+ > > copies or substantial portions of the Software.
2889
+ > >
2890
+ > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
2891
+ > > IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
2892
+ > > FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
2893
+ > > AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
2894
+ > > LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
2895
+ > > OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
2896
+ > > SOFTWARE.
2897
+ > >
2898
+ > > <!-- DEPENDENCIES -->
2899
+ > >
2900
+ > > # Licenses of bundled dependencies
2901
+ > > The published @visulima/redact artifact additionally contains code with the following licenses:
2902
+ > > MIT
2903
+ > >
2904
+ > > # Bundled dependencies:
2905
+ > > ## dot-prop
2906
+ > > License: MIT
2907
+ > > By: Sindre Sorhus
2908
+ > > Repository: sindresorhus/dot-prop
2909
+ > >
2910
+ > > > MIT License
2911
+ > > >
2912
+ > > > Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
2913
+ > > >
2914
+ > > > Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
2915
+ > > >
2916
+ > > > The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
2917
+ > > >
2918
+ > > > THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2919
+ > >
2920
+ > > <!-- /DEPENDENCIES -->
2921
+ >
2922
+ > ---------------------------------------
2923
+ >
2578
2924
  > ## safe-stable-stringify
2579
2925
  > License: MIT
2580
2926
  > By: Ruben Bridgewater
@@ -1,4 +1,4 @@
1
- import{t as u}from"../packem_shared/cerebro-error-DnA3fjrR.js";class h extends u{troubleshooting;constructor(o,t,i=[]){super(o,t,{troubleshooting:i}),this.name="CompletionError",this.troubleshooting=i,i.length>0&&(this.hint=i.join(`
1
+ import{t as u}from"../packem_shared/cerebro-error-DWpjBY_M.js";class h extends u{troubleshooting;constructor(o,t,i=[]){super(o,t,{troubleshooting:i}),this.name="CompletionError",this.troubleshooting=i,i.length>0&&(this.hint=i.join(`
2
2
  `))}}const a=["bash","zsh","fish","powershell"],c=["node","bun","deno"],f=e=>"Deno"in e,b=e=>"Bun"in e,d=()=>f(globalThis)?"deno":b(globalThis)?"bun":"node",p=e=>{const o=e?.starshipShell??e?.shell;if(o){const s=o.toLowerCase();if(s.includes("zsh"))return"zsh";if(s.includes("bash"))return"bash";if(s.includes("fish"))return"fish"}const t=e?.psModulePath,i=e?.prompt;if(t||i?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},g=async()=>(await import("@bomb.sh/tab")).default,S=(e,o)=>{for(const t of o)t.hidden||(t.name&&e.option(t.name,t.description??""),t.alias&&e.option(t.alias,t.description??""))},w=(e,o)=>{for(const[t,i]of o){if(i.name!==t||i.hidden)continue;const s=e.command(i.name,i.description??"");i.options&&S(s,i.options)}},$=e=>{if(!a.includes(e))throw new h(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${a.join(", ")}`,"Shell will be auto-detected if not specified"])},y=e=>{if(e&&!c.includes(e))throw new h(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${c.join(", ")}`,"Runtime will be auto-detected if not specified"])},L=(e,o)=>{e.error("Could not detect current shell");const t=[`Usage: ${o} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun|deno>]`,"","Examples:"," # Install completions for zsh:",` ${o} completion --shell=zsh > ~/.${o}-completion.zsh`,` echo 'source ~/.${o}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${o} completion --shell=bash --runtime=bun > ~/.${o}-completion.bash`,` echo 'source ~/.${o}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${o} completion --shell=fish > ~/.config/fish/completions/${o}.fish`].join(`
3
3
  `);e.info(t)},I={description:"Generate shell completion scripts",env:[{description:"Shell path (Unix-like systems). Used for shell detection.",name:"SHELL",type:String},{description:"Starship shell configuration. Takes precedence over SHELL for detection.",name:"STARSHIP_SHELL",type:String},{description:"PowerShell module path (Windows). Used for PowerShell detection.",name:"PSModulePath",type:String},{description:"Command prompt variable (Windows). Used for PowerShell detection.",name:"PROMPT",type:String},{description:"Command processor (Windows). Used for Windows Command Prompt detection.",name:"ComSpec",type:String}],execute:async({env:e,logger:o,options:t,runtime:i})=>{const s=i.getCliName(),l=t.shell??p(e);if(!l){L(o,s);return}try{$(l),y(t.runtime);const n=await g();w(n,i.getCommands());const r=`${t.runtime??d()} ${s}`;n.setup(s,r,l)}catch(n){if(n instanceof h){const r=[`Failed to generate completion script: ${n.message}`,`Error code: ${n.code}`];throw n.troubleshooting.length>0&&r.push("","Troubleshooting:",...n.troubleshooting.map(m=>` • ${m}`)),o.error(r.join(`
4
4
  `)),n}else{const r=["Failed to generate completion script",`Error: ${n instanceof Error?n.message:String(n)}`,"","Troubleshooting:"," • Ensure @bomb.sh/tab is installed: pnpm add @bomb.sh/tab",` • Verify shell is supported: ${a.join(", ")}`,` • Verify runtime is supported: ${c.join(", ")}`," • Check that your CLI name is correct"];o.error(r.join(`
@@ -1 +1 @@
1
- import{inverse as p,cyan as u,green as h,yellow as g}from"@visulima/colorize";import{o as y,r as f}from"../packem_shared/index-BAKCiGjO.js";const O=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],b="__Other",v=s=>s.charAt(0).toUpperCase()+s.slice(1),w=(s,r,l,o)=>{s.debug("no command given, printing general help...");let m=[...new Set(l.values())].filter(n=>!n.hidden);o&&(m=m.filter(n=>n.group===o));const e=m.reduce((n,i)=>{const d=i.group??b;return n[d]??=[],n[d].push(i),n},{}),a=n=>n.map(i=>{let d="";typeof i.alias=="string"?d=i.alias:Array.isArray(i.alias)&&(d=i.alias.join(", ")),d!==""&&(d=` [${d}]`);let t=i.name;return i.commandPath&&i.commandPath.length>0&&(t=`${i.commandPath.join(" ")} ${i.name}`),[`${h(t)}${d}`,i.description??""]});(s.raw??s.log)(f([{content:`${u(r.getCliName())} ${h("<command>")} [positional arguments] ${g("[options]")}`,header:p.cyan(" Usage ")},...Object.keys(e).map(n=>{const i=o?` ${v(o)}`:"";return{content:a(e[n]),header:n===b||o?p.green(` Available${i} Commands `):` ${p.green(` ${v(n)} `)}`}}),l.has("help")?{header:p.yellow(" Command Options "),optionList:l.get("help").options?.filter(n=>!n.hidden)}:void 0,{header:p.yellow(" Global Options "),optionList:r.getGlobalOptions()},{content:O.filter(n=>!n.hidden).map(n=>[n.name,n.description??""]),header:p.magenta(" Environment Variables ")},{content:`Run "${u(r.getCliName())} ${h("help <command>")}" or "${u(r.getCliName())} ${h("<command>")} ${g("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},$=(s,r)=>{const l=[];for(const o of s.values()){if(o.hidden)continue;const m=o.commandPath??[];if(m.length!==r.length)continue;let e=!0;for(const[a,n]of r.entries())if(m[a]!==n){e=!1;break}e&&l.push(o)}return l},E=(s,r,l,o)=>{const m=l.join(" "),e=[{content:`${u(r.getCliName())} ${h(m)} ${h("<subcommand>")} [positional arguments] ${g("[options]")}`,header:p.cyan(" Usage ")},{content:o.map(a=>{const n=[...a.commandPath??[],a.name].join(" ");return[h(n),a.description??""]}),header:p.green(" Subcommands ")},{header:p.yellow(" Global Options "),optionList:r.getGlobalOptions()},{content:`Run "${u(r.getCliName())} ${h(`${m} <subcommand>`)} ${g("--help")}" for help with a specific subcommand.`,raw:!0}];(s.raw??s.log)(f(e))},N=(s,r,l,o,m)=>{let e=m??l.get(o);if(!e)for(const t of l.values()){const c=t.commandPath?[...t.commandPath,t.name]:[t.name];if(c.at(-1)===o||c.join(" ")===o){e=t;break}}if(!e){const t=o.split(" ").filter(Boolean),c=t.length>0?$(l,t):[];if(c.length>0){E(s,r,t,c);return}s.error(`Command "${o}" not found`);return}const a=[],n=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(a.push({content:`${u(r.getCliName())} ${h(n)}${e.argument?" [positional arguments]":""}${e.options?" [options]":""}`,header:p.cyan(" Usage ")}),e.description&&a.push({content:e.description,header:p.green(" Description ")}),e.argument&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&a.push({header:p.yellow(" Command Options "),optionList:e.options.filter(t=>!t.hidden)}),a.push({header:p.yellow(" Global Options "),optionList:r.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const t=e.env.filter(c=>!c.hidden);t.length>0&&a.push({content:t.map(c=>[c.name,c.description??""]),header:p.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let t=e.alias;typeof e.alias=="string"&&(t=[e.alias]),a.splice(1,0,{content:t,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&a.push({content:e.examples,header:"Examples"});const i=[...e.commandPath??[],e.name],d=$(l,i);d.length>0&&a.push({content:d.map(t=>{const c=[...t.commandPath??[],t.name].join(" ");return[h(c),t.description??""]}),header:p.green(" Subcommands ")}),(s.raw??s.log)(f(a))};class P{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(r){this.commands=r}execute(r){const{argument:l,command:o,commandName:m,logger:e,options:a,runtime:n}=r,{footer:i,header:d}=n.getCommandSection();d&&(e.raw??e.log)(y(d));const t=m==="help"&&Array.isArray(l)&&l.length>0?l.join(" "):void 0;if(m==="help"&&t===void 0)w(e,n,this.commands,typeof a?.group=="string"?a.group:void 0);else{const c=t!==void 0||o===void 0||o.name==="help"?void 0:o;N(e,n,this.commands,t??m,c)}i&&(e.raw??e.log)(y(i))}}export{P as default};
1
+ import{inverse as p,cyan as u,green as h,yellow as g}from"@visulima/colorize";import{o as y,r as f}from"../packem_shared/index-Dpm7gUHe.js";const O=[{defaultValue:"32",description:"Controls the verbosity level of output. Valid values: '16' (quiet), '32' (normal), '64' (verbose), '128' (debug)",name:"CEREBRO_OUTPUT_LEVEL",type:String},{description:"Sets the minimum required Node.js version. Overrides the default minimum version check",name:"CEREBRO_MIN_NODE_VERSION",type:Number},{defaultValue:!1,description:"When set, disables the update notifier check",name:"NO_UPDATE_NOTIFIER",type:Boolean},{description:"Standard Node.js environment variable. When set to 'test', disables update notifier",name:"NODE_ENV",type:String},{defaultValue:!1,description:"When set, enables debug output (same as --debug flag)",name:"DEBUG",type:Boolean},{description:"Sets the terminal width for table rendering. Useful for testing and consistent output",name:"CEREBRO_TERMINAL_WIDTH",type:Number}],b="__Other",v=s=>s.charAt(0).toUpperCase()+s.slice(1),w=(s,r,l,o)=>{s.debug("no command given, printing general help...");let m=[...new Set(l.values())].filter(n=>!n.hidden);o&&(m=m.filter(n=>n.group===o));const e=m.reduce((n,i)=>{const d=i.group??b;return n[d]??=[],n[d].push(i),n},{}),a=n=>n.map(i=>{let d="";typeof i.alias=="string"?d=i.alias:Array.isArray(i.alias)&&(d=i.alias.join(", ")),d!==""&&(d=` [${d}]`);let t=i.name;return i.commandPath&&i.commandPath.length>0&&(t=`${i.commandPath.join(" ")} ${i.name}`),[`${h(t)}${d}`,i.description??""]});(s.raw??s.log)(f([{content:`${u(r.getCliName())} ${h("<command>")} [positional arguments] ${g("[options]")}`,header:p.cyan(" Usage ")},...Object.keys(e).map(n=>{const i=o?` ${v(o)}`:"";return{content:a(e[n]),header:n===b||o?p.green(` Available${i} Commands `):` ${p.green(` ${v(n)} `)}`}}),l.has("help")?{header:p.yellow(" Command Options "),optionList:l.get("help").options?.filter(n=>!n.hidden)}:void 0,{header:p.yellow(" Global Options "),optionList:r.getGlobalOptions()},{content:O.filter(n=>!n.hidden).map(n=>[n.name,n.description??""]),header:p.magenta(" Environment Variables ")},{content:`Run "${u(r.getCliName())} ${h("help <command>")}" or "${u(r.getCliName())} ${h("<command>")} ${g("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},$=(s,r)=>{const l=[];for(const o of s.values()){if(o.hidden)continue;const m=o.commandPath??[];if(m.length!==r.length)continue;let e=!0;for(const[a,n]of r.entries())if(m[a]!==n){e=!1;break}e&&l.push(o)}return l},E=(s,r,l,o)=>{const m=l.join(" "),e=[{content:`${u(r.getCliName())} ${h(m)} ${h("<subcommand>")} [positional arguments] ${g("[options]")}`,header:p.cyan(" Usage ")},{content:o.map(a=>{const n=[...a.commandPath??[],a.name].join(" ");return[h(n),a.description??""]}),header:p.green(" Subcommands ")},{header:p.yellow(" Global Options "),optionList:r.getGlobalOptions()},{content:`Run "${u(r.getCliName())} ${h(`${m} <subcommand>`)} ${g("--help")}" for help with a specific subcommand.`,raw:!0}];(s.raw??s.log)(f(e))},N=(s,r,l,o,m)=>{let e=m??l.get(o);if(!e)for(const t of l.values()){const c=t.commandPath?[...t.commandPath,t.name]:[t.name];if(c.at(-1)===o||c.join(" ")===o){e=t;break}}if(!e){const t=o.split(" ").filter(Boolean),c=t.length>0?$(l,t):[];if(c.length>0){E(s,r,t,c);return}s.error(`Command "${o}" not found`);return}const a=[],n=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(a.push({content:`${u(r.getCliName())} ${h(n)}${e.argument?" [positional arguments]":""}${e.options?" [options]":""}`,header:p.cyan(" Usage ")}),e.description&&a.push({content:e.description,header:p.green(" Description ")}),e.argument&&a.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&a.push({header:p.yellow(" Command Options "),optionList:e.options.filter(t=>!t.hidden)}),a.push({header:p.yellow(" Global Options "),optionList:r.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const t=e.env.filter(c=>!c.hidden);t.length>0&&a.push({content:t.map(c=>[c.name,c.description??""]),header:p.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let t=e.alias;typeof e.alias=="string"&&(t=[e.alias]),a.splice(1,0,{content:t,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&a.push({content:e.examples,header:"Examples"});const i=[...e.commandPath??[],e.name],d=$(l,i);d.length>0&&a.push({content:d.map(t=>{const c=[...t.commandPath??[],t.name].join(" ");return[h(c),t.description??""]}),header:p.green(" Subcommands ")}),(s.raw??s.log)(f(a))};class P{argument={description:"Command to show help for (subcommand path supported, e.g. `cli help docker build`)",name:"command",type:String};name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(r){this.commands=r}execute(r){const{argument:l,command:o,commandName:m,logger:e,options:a,runtime:n}=r,{footer:i,header:d}=n.getCommandSection();d&&(e.raw??e.log)(y(d));const t=m==="help"&&Array.isArray(l)&&l.length>0?l.join(" "):void 0;if(m==="help"&&t===void 0)w(e,n,this.commands,typeof a?.group=="string"?a.group:void 0);else{const c=t!==void 0||o===void 0||o.name==="help"?void 0:o;N(e,n,this.commands,t??m,c)}i&&(e.raw??e.log)(y(i))}}export{P as default};
@@ -1,4 +1,4 @@
1
- import{createRequire as x}from"node:module";import{r as N}from"../packem_shared/index-BAKCiGjO.js";import{g as q,a as V,b as G}from"../packem_shared/runtime-process-Dmz0vCJy.js";let S;const O=e=>(S??=x(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[n,t]=h.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return h.getBuiltinModule(e)}return O(e)},{resolve:P,join:B,dirname:L}=k("node:path"),v=async(e,n)=>{try{return await e.access(n),!0}catch{return!1}},T=async()=>{const{default:e}=await import("github-slugger"),n=new e;return t=>n.slug(t)},U=e=>e.filter(Boolean),F=(e,n)=>{const t=new Set,r=[];for(const a of e){const o=n(a);t.has(o)||(t.add(o),r.push(a))}return r},_=(e,n)=>{const t=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const r=e.argument.name.toUpperCase(),a=e.argument.required?r:`[${r}]`;return`${n} ${t} ${a}`}return`${n} ${t}`},I=(e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(r=>!r.hidden);t.length>0&&n.push({content:t.map(r=>[r.name,r.description??""]),header:" Environment Variables "})},W=(e,n)=>{const t=[],r=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),a=!!e.argument,o=!!e.options;if(t.push({content:`${n} ${r}${a?" [positional arguments]":""}${o?" [options]":""}`,header:" Usage "}),e.description&&t.push({content:e.description,header:" Description "}),e.argument&&t.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&t.push({header:" Command Options ",optionList:e.options.filter(i=>!i.hidden)}),I(e,t),e.alias!==void 0&&e.alias.length>0){const i=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:i,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),N(t)},z=(e,n)=>{const t=e.description?.trim().split(`
1
+ import{createRequire as x}from"node:module";import{r as N}from"../packem_shared/index-Dpm7gUHe.js";import{g as q,a as V,b as G}from"../packem_shared/runtime-process-BEw54Ar-.js";let S;const O=e=>(S??=x(import.meta.url))(e),h=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,k=e=>{if(typeof h<"u"&&h.versions&&h.versions.node){const[n,t]=h.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return h.getBuiltinModule(e)}return O(e)},{resolve:P,join:B,dirname:L}=k("node:path"),v=async(e,n)=>{try{return await e.access(n),!0}catch{return!1}},T=async()=>{const{default:e}=await import("github-slugger"),n=new e;return t=>n.slug(t)},U=e=>e.filter(Boolean),F=(e,n)=>{const t=new Set,r=[];for(const a of e){const o=n(a);t.has(o)||(t.add(o),r.push(a))}return r},_=(e,n)=>{const t=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const r=e.argument.name.toUpperCase(),a=e.argument.required?r:`[${r}]`;return`${n} ${t} ${a}`}return`${n} ${t}`},I=(e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(r=>!r.hidden);t.length>0&&n.push({content:t.map(r=>[r.name,r.description??""]),header:" Environment Variables "})},W=(e,n)=>{const t=[],r=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),a=!!e.argument,o=!!e.options;if(t.push({content:`${n} ${r}${a?" [positional arguments]":""}${o?" [options]":""}`,header:" Usage "}),e.description&&t.push({content:e.description,header:" Description "}),e.argument&&t.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&t.push({header:" Command Options ",optionList:e.options.filter(i=>!i.hidden)}),I(e,t),e.alias!==void 0&&e.alias.length>0){const i=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:i,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),N(t)},z=(e,n)=>{const t=e.description?.trim().split(`
2
2
  `)[0]??"",r=_(e,n),a=W(e,n);return U([`## \`${r}\``,t,`\`\`\`
3
3
  ${a.trim()}
4
4
  \`\`\``]).join(`
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Cli as e}from"./packem_shared/Cerebro-CHB2i5uf.js";import{VERBOSITY_DEBUG as B,VERBOSITY_NORMAL as O,VERBOSITY_QUIET as R,VERBOSITY_VERBOSE as V}from"./packem_shared/VERBOSITY_DEBUG-XPultrIA.js";import{lazyNamed as I}from"./packem_shared/lazyNamed-DMUm8mZe.js";import"./packem_shared/renderError-DjesnVYT-pHitCa3e.js";import{h as T}from"./packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js";const t=(r,o)=>new e(r,o);export{e as Cerebro,B as VERBOSITY_DEBUG,O as VERBOSITY_NORMAL,R as VERBOSITY_QUIET,V as VERBOSITY_VERBOSE,T as VisulimaError,t as createCerebro,I as lazyNamed};
1
+ import{Cli as e}from"./packem_shared/Cerebro-58LHN3_T.js";import{VERBOSITY_DEBUG as B,VERBOSITY_NORMAL as O,VERBOSITY_QUIET as R,VERBOSITY_VERBOSE as V}from"./packem_shared/VERBOSITY_DEBUG-XPultrIA.js";import{lazyNamed as I}from"./packem_shared/lazyNamed-DMUm8mZe.js";import{h as T}from"./packem_shared/VisulimaError-DTMgXonA-CzaryRgZ.js";const m=(r,o)=>new e(r,o);export{e as Cerebro,B as VERBOSITY_DEBUG,O as VERBOSITY_NORMAL,R as VERBOSITY_QUIET,V as VERBOSITY_VERBOSE,T as VisulimaError,m as createCerebro,I as lazyNamed};
@@ -1 +1 @@
1
- import a from"@visulima/pail/processor/caller";import m from"@visulima/pail/processor/message-formatter";import{createPail as l}from"@visulima/pail/server";import{VERBOSITY_DEBUG as p,VERBOSITY_QUIET as E}from"../packem_shared/VERBOSITY_DEBUG-XPultrIA.js";import{c}from"../packem_shared/runtime-process-Dmz0vCJy.js";const d=o=>{const i={16:"informational",32:"informational",64:"trace",128:"debug",256:"debug"},t=[new m],r=c().CEREBRO_OUTPUT_LEVEL;(r===String(128)||r===String(p))&&t.push(new a);const n=(r&&i[r])??"informational",s={...o,logLevel:o?.logLevel??n,processors:o?.processors?[...t,...o.processors]:t},e=l(s);return r===String(E)&&e.disable(),e};export{d as default};
1
+ import a from"@visulima/pail/processor/caller";import m from"@visulima/pail/processor/message-formatter";import{createPail as l}from"@visulima/pail/server";import{VERBOSITY_DEBUG as p,VERBOSITY_QUIET as E}from"../packem_shared/VERBOSITY_DEBUG-XPultrIA.js";import{c}from"../packem_shared/runtime-process-BEw54Ar-.js";const d=o=>{const i={16:"informational",32:"informational",64:"trace",128:"debug",256:"debug"},t=[new m],r=c().CEREBRO_OUTPUT_LEVEL;(r===String(128)||r===String(p))&&t.push(new a);const n=(r&&i[r])??"informational",s={...o,logLevel:o?.logLevel??n,processors:o?.processors?[...t,...o.processors]:t},e=l(s);return r===String(E)&&e.disable(),e};export{d as default};
@@ -1 +1 @@
1
- import{createRequire as k}from"node:module";import{findCacheDirSync as F}from"@visulima/find-cache-dir";import{t as U}from"../packem_shared/cerebro-error-DnA3fjrR.js";let T;const b=e=>(T??=k(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[r,t]=g.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return g.getBuiltinModule(e)}return b(e)},{writeFile:I,readFile:R,mkdir:S,access:$}=w("node:fs/promises"),{get:A}=w("node:https"),N=e=>{const[r,t]=e.split("-");return{nums:r.split(".").map(s=>Number.parseInt(s,10)||0),pre:t}},x=(e,r)=>{const t=N(e),s=N(r),o=Math.max(t.nums.length,s.nums.length);for(let i=0;i<o;i+=1){const n=t.nums[i]??0,l=s.nums[i]??0;if(n>l)return!0;if(n<l)return!1}if(t.pre===void 0&&s.pre!==void 0)return!0;if(t.pre!==void 0&&s.pre===void 0||t.pre===void 0&&s.pre===void 0)return!1;const c=t.pre.split("."),u=s.pre.split("."),a=Math.max(c.length,u.length);for(let i=0;i<a;i+=1){const n=c[i],l=u[i];if(n===void 0)return!1;if(l===void 0)return!0;if(n===l)continue;const f=Number.parseInt(n,10),d=Number.parseInt(l,10),h=!Number.isNaN(f)&&String(f)===n,_=!Number.isNaN(d)&&String(d)===l;return h&&_?f>d:h?!1:_?!0:n>l}return!1},j=/^[A-Z]:\//i,v=(e="")=>e&&e.replaceAll("\\","/").replace(j,r=>r.toUpperCase()),D=/^[/\\]{2}/,H=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,E=/^[A-Z]:$/i,M=/\/$/,q=(e,r)=>{let t="",s=0,o=-1,c=0,u;for(let a=0;a<=e.length;++a){if(a<e.length)u=e[a];else{if(u==="/")break;u="/"}if(u==="/"){if(!(o===a-1||c===1))if(c===2){if(t.length<2||s!==2||!t.endsWith(".")||t.at(-2)!=="."){if(t.length>2){const i=t.lastIndexOf("/");i===-1?(t="",s=0):(t=t.slice(0,i),s=t.length-1-t.lastIndexOf("/")),o=a,c=0;continue}else if(t.length>0){t="",s=0,o=a,c=0;continue}}r&&(t+=t.length>0?"/..":"..",s=2)}else t.length>0?t+=`/${e.slice(o+1,a)}`:t=e.slice(o+1,a),s=a-o-1;o=a,c=0}else u==="."&&c!==-1?++c:c=-1}return t},m=e=>H.test(e),P=function(e){if(e.length===0)return".";e=v(e);const r=D.exec(e),t=m(e),s=e.at(-1)==="/";return e=q(e,!t),e.length===0?t?"/":s?"./":".":(s&&(e+="/"),E.test(e)&&(e+="/"),r?t?`//${e}`:`//./${e}`:t&&!m(e)?`/${e}`:e)},V=(...e)=>{let r="";for(const t of e)if(t)if(r.length>0){const s=r.at(-1)==="/",o=t[0]==="/";s&&o?r+=t.slice(1):r+=s||o?t:`/${t}`}else r+=t;return P(r)},J=e=>{const r=v(e).replace(M,""),t=r.lastIndexOf("/");if(t===-1)return m(e)?"/":".";const s=r.slice(0,t);return E.test(s)?`${s}/`:s||(m(e)?"/":".")};class p extends U{constructor(r,t="UPDATE_NOTIFIER_ERROR",s){super(r,t,s),this.name="UpdateNotifierError"}}const L="last-update-check.json",y={access:(e,r)=>$(e,r),mkdir:(e,r)=>S(e,r),readFile:(async(e,r)=>r===void 0?R(e):R(e,r)),writeFile:(e,r,t)=>I(e,r,t)},O=async(e,r)=>{try{return await e.access(r),!0}catch{return!1}},C=e=>{const r=F(e);if(r===void 0)throw new p("Could not find cache directory","CACHE_DIRECTORY_NOT_FOUND",{packageName:e});return V(r,L)},Z=async(e,r=y)=>{const t=C(e);try{if(!await O(r,t))return;const{lastUpdateCheck:s}=JSON.parse(await r.readFile(t,"utf8"));return s}catch{return}},B=async(e,r=y)=>{const t=C(e),s=J(t);await O(r,s)||await r.mkdir(s,{recursive:!0}),await r.writeFile(t,JSON.stringify({lastUpdateCheck:Date.now()}),"utf8")},W=5e3,Y=async(e,r,t,s=W)=>{const o=t.replace("__NAME__",e),c=512*1024;return await new Promise((u,a)=>{const i=A(o,{timeout:s},n=>{if(n.statusCode!==void 0&&(n.statusCode<200||n.statusCode>=300)){a(new p(`Unexpected status code ${String(n.statusCode)}`,"VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),n.resume();return}let l="",f=!1;n.on("data",d=>{f||(l+=String(d),l.length>c&&(f=!0,a(new p("Response too large","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),n.destroy()))}),n.on("end",()=>{if(!f)try{const d=JSON.parse(l)[r];if(!d){a(new p("Error getting version","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}));return}u(d)}catch{a(new p("Could not parse version response","VERSION_PARSE_ERROR",{distributionTag:r,packageName:e}))}})});i.on("timeout",()=>{i.destroy(new p("Request timed out","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}))}),i.on("error",n=>{a(n)})})},K=async({alwaysRun:e,debug:r,distTag:t="latest",fs:s,pkg:o,registryUrl:c="https://registry.npmjs.org/-/package/__NAME__/dist-tags",timeout:u,updateCheckInterval:a=1e3*60*60*24})=>{const i=await Z(o.name,s);if(e||!i||i<Date.now()-a){const n=await Y(o.name,t,c,u);if(await B(o.name,s),x(n,o.version))return n;r&&console.error(`Latest version (${n}) not newer than current version (${o.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${String(a)}ms but only ${String(Date.now()-i)}ms since last check.`)};export{K as default};
1
+ import{createRequire as T}from"node:module";import{findCacheDirSync as F}from"@visulima/find-cache-dir";import{t as U}from"../packem_shared/cerebro-error-DWpjBY_M.js";let b;const k=e=>(b??=T(import.meta.url))(e),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[r,t]=g.versions.node.split(".").map(Number);if(r>22||r===22&&t>=3||r===20&&t>=16)return g.getBuiltinModule(e)}return k(e)},{writeFile:I,readFile:R,mkdir:S,access:$}=w("node:fs/promises"),{get:x}=w("node:https"),N=e=>{const[r,t]=e.split("-");return{nums:r.split(".").map(s=>Number.parseInt(s,10)||0),pre:t}},A=(e,r)=>{const t=N(e),s=N(r),o=Math.max(t.nums.length,s.nums.length);for(let i=0;i<o;i+=1){const n=t.nums[i]??0,l=s.nums[i]??0;if(n>l)return!0;if(n<l)return!1}if(t.pre===void 0&&s.pre!==void 0)return!0;if(t.pre!==void 0&&s.pre===void 0||t.pre===void 0&&s.pre===void 0)return!1;const c=t.pre.split("."),u=s.pre.split("."),a=Math.max(c.length,u.length);for(let i=0;i<a;i+=1){const n=c[i],l=u[i];if(n===void 0)return!1;if(l===void 0)return!0;if(n===l)continue;const f=Number.parseInt(n,10),d=Number.parseInt(l,10),h=!Number.isNaN(f)&&String(f)===n,_=!Number.isNaN(d)&&String(d)===l;return h&&_?f>d:h?!1:_?!0:n>l}return!1},j=/^[A-Z]:\//i,v=(e="")=>e&&e.replaceAll("\\","/").replace(j,r=>r.toUpperCase()),D=/^[/\\]{2}/,M=/^[/\\](?![/\\])|^[/\\]{2}(?!\.)|^[A-Z]:[/\\]/i,E=/^[A-Z]:$/i,q=/\/$/,H=(e,r)=>{let t="",s=0,o=-1,c=0,u;for(let a=0;a<=e.length;++a){if(a<e.length)u=e[a];else{if(u==="/")break;u="/"}if(u==="/"){if(!(o===a-1||c===1))if(c===2){if(t.length<2||s!==2||!t.endsWith(".")||t.at(-2)!=="."){if(t.length>2){const i=t.lastIndexOf("/");i===-1?(t="",s=0):(t=t.slice(0,i),s=t.length-1-t.lastIndexOf("/")),o=a,c=0;continue}else if(t.length>0){t="",s=0,o=a,c=0;continue}}r&&(t+=t.length>0?"/..":"..",s=2)}else t.length>0?t+=`/${e.slice(o+1,a)}`:t=e.slice(o+1,a),s=a-o-1;o=a,c=0}else u==="."&&c!==-1?++c:c=-1}return t},m=e=>M.test(e),V=function(e){if(e.length===0)return".";e=v(e);const r=D.exec(e),t=m(e),s=e.at(-1)==="/";return e=H(e,!t),e.length===0?t?"/":s?"./":".":(s&&(e+="/"),E.test(e)&&(e+="/"),r?t?`//${e}`:`//./${e}`:t&&!m(e)?`/${e}`:e)},J=(...e)=>{let r="";for(const t of e)if(t)if(r.length>0){const s=r.at(-1)==="/",o=t[0]==="/";s&&o?r+=t.slice(1):r+=s||o?t:`/${t}`}else r+=t;return V(r)},P=e=>{const r=v(e).replace(q,""),t=r.lastIndexOf("/");if(t===-1)return m(e)?"/":".";const s=r.slice(0,t);return E.test(s)?`${s}/`:s||(m(e)?"/":".")};class p extends U{constructor(r,t="UPDATE_NOTIFIER_ERROR",s){super(r,t,s),this.name="UpdateNotifierError"}}const B="last-update-check.json",y={access:(e,r)=>$(e,r),mkdir:(e,r)=>S(e,r),readFile:(async(e,r)=>r===void 0?R(e):R(e,r)),writeFile:(e,r,t)=>I(e,r,t)},O=async(e,r)=>{try{return await e.access(r),!0}catch{return!1}},C=e=>{const r=F(e);if(r===void 0)throw new p("Could not find cache directory","CACHE_DIRECTORY_NOT_FOUND",{packageName:e});return J(r,B)},L=async(e,r=y)=>{const t=C(e);try{if(!await O(r,t))return;const{lastUpdateCheck:s}=JSON.parse(await r.readFile(t,"utf8"));return s}catch{return}},Z=async(e,r=y)=>{const t=C(e),s=P(t);await O(r,s)||await r.mkdir(s,{recursive:!0}),await r.writeFile(t,JSON.stringify({lastUpdateCheck:Date.now()}),"utf8")},W=5e3,Y=async(e,r,t,s=W)=>{const o=t.replace("__NAME__",e),c=512*1024;return await new Promise((u,a)=>{const i=x(o,{timeout:s},n=>{if(n.statusCode!==void 0&&(n.statusCode<200||n.statusCode>=300)){a(new p(`Unexpected status code ${String(n.statusCode)}`,"VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),n.resume();return}let l="",f=!1;n.on("data",d=>{f||(l+=String(d),l.length>c&&(f=!0,a(new p("Response too large","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e})),n.destroy()))}),n.on("end",()=>{if(!f)try{const d=JSON.parse(l)[r];if(!d){a(new p("Error getting version","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}));return}u(d)}catch{a(new p("Could not parse version response","VERSION_PARSE_ERROR",{distributionTag:r,packageName:e}))}})});i.on("timeout",()=>{i.destroy(new p("Request timed out","VERSION_FETCH_ERROR",{distributionTag:r,packageName:e}))}),i.on("error",n=>{a(n)})})},Q=async({alwaysRun:e,debug:r,distTag:t="latest",fs:s,pkg:o,registryUrl:c="https://registry.npmjs.org/-/package/__NAME__/dist-tags",timeout:u,updateCheckInterval:a=1e3*60*60*24})=>{const i=await L(o.name,s);if(e||!i||i<Date.now()-a){const n=await Y(o.name,t,c,u);if(await Z(o.name,s),A(n,o.version))return n;r&&console.error(`Latest version (${n}) not newer than current version (${o.version})`)}else r&&console.error(`Too recent to check for a new update. simpleUpdateNotifier() interval set to ${String(a)}ms but only ${String(Date.now()-i)}ms since last check.`)};export{Q as default};
@@ -0,0 +1,4 @@
1
+ import{createRequire as je}from"node:module";import{VERBOSITY_DEBUG as M,POSITIONALS_KEY as Z,VERBOSITY_NORMAL as ee,VERBOSITY_QUIET as Ge,VERBOSITY_VERBOSE as Ye}from"./VERBOSITY_DEBUG-XPultrIA.js";import{t as w}from"./cerebro-error-DWpjBY_M.js";import{c as Q,d as ae,o as ue,e as U,a as He,b as Ke,f as Je,h as Ze,i as Qe}from"./runtime-process-BEw54Ar-.js";import{h as Y}from"./VisulimaError-DTMgXonA-CzaryRgZ.js";import{k as Xe,W as et}from"./split-by-case-BZ6XOTIf.js";import{distance as tt}from"fastest-levenshtein";let Se;const Te=t=>(Se??=je(import.meta.url))(t),W=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,Ue=t=>{if(typeof W<"u"&&W.versions&&W.versions.node){const[e,n]=W.versions.node.split(".").map(Number);if(e>22||e===22&&n>=3||e===20&&n>=16)return W.getBuiltinModule(t)}return Te(t)},{writeFile:Be,stat:Re,rm:ze,readFile:de,readdir:Fe,mkdir:qe,access:We}=Ue("node:fs/promises"),K=[{alias:"v",description:"Turn on verbose output",group:"global",name:"verbose",type:Boolean},{description:"Turn on debugging output",group:"global",name:"debug",type:Boolean},{alias:"h",description:"Print out helpful usage information",group:"global",name:"help",type:Boolean},{alias:"q",description:"Silence output",group:"global",name:"quiet",type:Boolean},{alias:"V",description:"Print version info",group:"global",name:"version",type:Boolean},{description:"Turn off colored output",group:"global",name:"no-color",type:Boolean},{description:"Force colored output",group:"global",name:"color",type:Boolean}];let S=class extends w{commandName;constructor(e,n=[]){const o=`Command "${e}" not found${n.length>0?`. Did you mean: ${n.join(", ")}?`:""}`;super(o,"COMMAND_NOT_FOUND",{commandName:e,suggestions:n}),this.name="CommandNotFoundError",this.commandName=e,n.length>0&&(this.hint=`Try one of these commands: ${n.join(", ")}`)}},Ce=class extends w{option1;option2;constructor(e,n){super(`Options "${e}" and "${n}" cannot be used together`,"CONFLICTING_OPTIONS",{option1:e,option2:n}),this.name="ConflictingOptionsError",this.option1=e,this.option2=n,this.hint=`Remove either --${e} or --${n}`}},nt=class extends w{unknownOptions;constructor(e,n){const o=e.join(", "),s=`Found unknown ${e.length===1?"option":"options"}: ${o}`;super(s,"UNKNOWN_OPTION",{suggestions:n,unknownOptions:e}),this.name="UnknownOptionError",this.unknownOptions=e,n&&n.length>0&&(this.hint=`Did you mean: ${n.join(", ")}?`)}},ot=class extends w{pluginName;constructor(e,n,o){super(`Plugin "${e}" error: ${n}`,"PLUGIN_ERROR",{originalError:o,pluginName:e}),this.name="PluginError",this.pluginName=e,o&&(this.cause=o)}},it=class{logger;plugins=new Map;initialized=!1;cachedDependencyOrder=void 0;constructor(e){this.logger=e}hasPlugins(){return this.plugins.size>0}register(e){if(this.initialized)throw new Error(`Cannot register plugin "${e.name}" after initialization`);if(this.plugins.has(e.name))throw new Error(`Plugin "${e.name}" is already registered`);Q().CEREBRO_OUTPUT_LEVEL===String(M)&&this.logger.debug(`registering plugin: ${e.name}`),this.plugins.set(e.name,e),this.cachedDependencyOrder=void 0}async init(e){if(this.initialized)throw new Error("PluginManager already initialized");if(this.plugins.size===0){this.logger.debug("no plugins registered, skipping initialization"),this.initialized=!0;return}this.validateDependencies();const n=this.getDependencyOrder();this.logger.debug(`initializing ${String(n.length)} plugin(s)...`);for(const o of n)if(typeof o.init=="function"){this.logger.debug(`initializing plugin: ${o.name}`);try{await o.init(e)}catch(s){const i=new ot(o.name,`Failed to initialize: ${s instanceof Error?s.message:String(s)}`,s instanceof Error?s:void 0);throw this.logger.error(i.message),i}}this.initialized=!0}async executeLifecycle(e,n,o){if(!this.initialized)throw new Error("PluginManager not initialized");if(this.plugins.size===0)return;const s=this.getDependencyOrder();for(const i of s){const l=i[e];if(typeof l=="function"){this.logger.debug(`executing ${e} hook for plugin: ${i.name}`);try{await(e==="afterCommand"?l(n,o):l(n))}catch(a){throw this.logger.error(`Error in ${e} hook for plugin "${i.name}":`,a),a}}}}async executeErrorHandlers(e,n){if(!this.initialized||this.plugins.size===0)return;const o=this.getDependencyOrder();for(const s of o)if(typeof s.onError=="function"){this.logger.debug(`executing error handler for plugin: ${s.name}`);try{await s.onError(e,n)}catch(i){this.logger.error(`Error in error handler for plugin "${s.name}":`,i)}}}getDependencyOrder(){if(this.cachedDependencyOrder!==void 0)return this.cachedDependencyOrder;const e=[],n=new Set,o=new Set,s=i=>{if(n.has(i))return;if(o.has(i))throw new Error(`Circular dependency detected involving plugin "${i}"`);const l=this.plugins.get(i);if(!l)throw new Error(`Plugin "${i}" not found`);if(o.add(i),l.dependencies)for(const a of l.dependencies)s(a);o.delete(i),n.add(i),e.push(l)};for(const i of this.plugins.keys())s(i);return this.cachedDependencyOrder=e,e}validateDependencies(){for(const e of this.plugins.values())if(e.dependencies){for(const n of e.dependencies)if(!this.plugins.has(n))throw new Error(`Plugin "${e.name}" depends on "${n}" which is not registered`)}}};const G=t=>t.type?.name==="Boolean",st=t=>{let e=t.type?t.type.name.toLowerCase():"string";const n=t.multiple??t.lazyMultiple?"[]":"";return e&&(e=e==="boolean"?"":`{underline ${e}${n}}`),e},me=t=>(G(t)||(t.typeLabel=t.typeLabel??st(t),t.defaultOption&&(t.typeLabel=`${t.typeLabel} (D)`),t.required&&(t.typeLabel=`${t.typeLabel} (R)`)),t),at=new RegExp(/^-([^\d-])$/),rt=new RegExp(/^--(\S+)/),lt=new RegExp(/^-([^\d-]{2,})$/),ct=t=>at.test(t)||rt.test(t)||lt.test(t),dt=(t,e)=>{const n=e[0]&&ct(e[0])||e.length===0?null:e.shift()??null;if(!t.includes(n)){const o=new Error(`Command not recognised: ${String(n)}`);throw o.command=n,o.name="INVALID_COMMAND",o}return{argv:e,command:n}};let ut=class xe extends Y{optionName;value;constructor(e,n,o){super({hint:`Pass a valid ${o} value for '${e}'.`,message:`Invalid ${o} value '${n}' for option '${e}'`,name:"INVALID_VALUE",title:"Invalid Value"}),this.optionName=e,this.value=n,Object.setPrototypeOf(this,xe.prototype)}},mt=class Ie extends Y{optionName;constructor(e){super({cause:void 0,hint:`Remove the duplicate option '${e}' from your command line arguments.`,location:void 0,message:`Option '${e}' is already set`,name:"ALREADY_SET",stack:void 0,title:"Option Already Set"}),this.optionName=e,Object.setPrototypeOf(this,Ie.prototype)}},he=class ke extends Y{optionName;constructor(e){super({cause:void 0,hint:`Check your option definitions or remove the unknown option '${e}' from your command line arguments.`,location:void 0,message:`Unknown option: --${e}`,name:"UNKNOWN_OPTION",stack:void 0,title:"Unknown Option"}),this.optionName=`--${e}`,Object.setPrototypeOf(this,ke.prototype)}},ht=class Ee extends Y{value;constructor(e){super({hint:"Use a defined option or add a defaultOption to capture this value.",message:`Unknown value: ${e}`,name:"UNKNOWN_VALUE",title:"Unknown Value"}),this.value=e,Object.setPrototypeOf(this,Ee.prototype)}};class O extends Y{constructor(e,n){super({cause:void 0,hint:n,location:void 0,message:e,name:"INVALID_DEFINITIONS",stack:void 0,title:"Invalid Option Definition"}),Object.setPrototypeOf(this,O.prototype)}}const B=t=>t===Boolean||typeof t=="function"&&t.name==="Boolean",re=t=>t===Number||typeof t=="function"&&t.name==="Number",pe=t=>t===String||typeof t=="function"&&t.name==="String",fe=(t,e,n)=>{const o=Number(t);if(e&&Number.isNaN(o)&&String(t).trim().toLowerCase()!=="nan")throw new ut(n??"",String(t),"Number");return o},pt=(t,e,n={})=>{const{optionName:o,strictTypes:s}=n;return Array.isArray(t)?B(e)?t.map(Boolean):re(e)?t.map(i=>fe(i,s,o)):pe(e)?t.map(String):t.map(i=>e(String(i))):t===null?null:B(e)?!!t:re(e)?fe(t,s,o):pe(e)?typeof t=="string"?t:String(t):e(typeof t=="string"?t:String(t))},b=(t,e,n,...o)=>{t&&console.debug(`[command-line-args:${n}] ${e}`,...o)},ft=/-([a-z])/g,gt=/^\d+$/,wt=t=>t.codePointAt(0)===95,ge=(t,e)=>Array.isArray(t)?[...t,...e]:[t,...e],we=t=>t==="__proto__"||t==="constructor"||t==="prototype",te=(t,e,n,o=!1)=>{t[e]===void 0?t[e]=o?[n]:n:o&&Array.isArray(t[e])?t[e].push(n):t[e]=[t[e],n]},ye=(t,e,n,o,s)=>{let i=e.get(t)??n.get(t);if(!i&&o){const l=t.toLowerCase();i=o.get(l)??s?.get(l)}return i},yt=(t,e,n,o)=>{const s=n.debug??!1;b(s,"resolveArgs called with options:","resolver",{partial:n.partial,stopAtFirstUnknown:n.stopAtFirstUnknown}),b(s,"Starting argument resolution","resolver"),b(s,"Tokens:","resolver",t),b(s,"Definitions:","resolver",e),b(s,"Processing tokens...","resolver");const i=new Map,l=new Map,a=n.caseInsensitive?new Map:void 0,d=n.caseInsensitive?new Map:void 0,r=n.camelCase?new Map:void 0,m=n.camelCase?new Map:void 0;for(const c of e)if(i.set(c.name,c),c.alias&&l.set(c.alias,c),n.caseInsensitive&&a&&(a.set(c.name.toLowerCase(),c),c.alias&&d&&d.set(c.alias.toLowerCase(),c)),n.camelCase&&r&&m){const u=c.name.replaceAll(ft,(p,_)=>_.toUpperCase());r.set(c.name,u),m.set(u,c.name)}const h=Object.create(null),f=Object.create(null),N=[],P=[],A=new Set;let V=!1;const y=e.find(c=>c.defaultOption),$=e.some(c=>c.group),E=e.find(c=>re(c.type));for(let c=0;c<t.length;c++){const u=t[c];if(u.kind==="option-terminator"){h._unknown=o.slice(u.index),V=!0;break}if(u.kind==="option"&&u.name){let p=ye(u.name,i,l,a,d);!p&&u.value===void 0&&E&&gt.test(u.name)&&(p=E,u.value=u.name,u.name=E.name);let _=!1;if(!p&&n.negation&&u.value===void 0&&u.name.startsWith("no-")){const v=u.name.slice(3),k=ye(v,i,l,a,d);k?.type&&B(k.type)&&(p=k,_=!0)}const g=p?p.name:u.name,x=p?.multiple,I=p?.lazyMultiple;if(Object.hasOwn(f,g)&&f[g]!==void 0&&!x&&!I&&!n.partial)throw new mt(g);if(!p&&n.partial){const v=u.rawName??`--${u.name}${u.value!==void 0&&u.inlineValue?`=${u.value}`:""}`;N.push({index:u.index,value:v});continue}if(!p&&n.stopAtFirstUnknown){h._unknown=o.slice(u.index);break}if(!p&&!n.partial)throw new he(u.name);if(u.value===void 0){const v=t[c+1],k=v?.kind==="option"&&!("name"in v)&&v.value!==void 0,L=v&&p&&!(p.type&&B(p.type))&&(v.kind==="positional"||k),Ve=p&&p.defaultOption&&!p.multiple&&!p.lazyMultiple;if(L&&(!p?.defaultOption||Ve))if(x){let D=c+1;const X=[];for(;D<t.length&&(t[D].kind==="positional"||t[D].kind==="option"&&!("name"in t[D])&&t[D].value!==void 0);)X.push(t[D].value),A.add(t[D].index),D++;f[g]=f[g]===void 0?X:ge(f[g],X),c=D-1}else I?(te(f,g,v.value,!0),A.add(v.index),c++):(f[g]=v.value,A.add(v.index),c++);else p?.type&&B(p.type)?te(f,g,!_,x):(x||I)&&f[g]!==void 0?te(f,g,null,!0):f[g]=x?[]:null}else{let{value:v}=u;if(p?.type&&B(p.type))switch(v){case"":{if(n.partial){const L=`${u.rawName??`--${u.name}`}${u.value?`=${u.value}`:""}`;P.push({index:u.index,value:L}),v=!0}else throw new he(u.name);break}case"false":{v=!1;break}case"true":{v=!0;break}default:v=!0}const k=[v];if(x){let L=c+1;for(;L<t.length&&t[L].kind==="positional";)k.push(t[L].value),A.add(t[L].index),L++;c=L-1}f[g]===void 0?f[g]=x||I?k:v:x||I?f[g]=ge(f[g],k):f[g]=v}}else if(u.kind==="positional"&&n.stopAtFirstUnknown&&!A.has(u.index)&&!y){b(s,`Found unconsumed positional token at index ${String(u.index)}, stopping processing`,"resolver"),h._unknown=o.slice(u.index);break}}for(const[c,u]of Object.entries(f)){const p=i.get(c);p&&(p.multiple||p.lazyMultiple)&&!Array.isArray(u)&&(f[c]=[u])}const z=c=>c.kind==="option"&&!i.has(c.name??"")&&!l.has(c.name??"")&&(!n.caseInsensitive||!a?.has(c.name?.toLowerCase()??"")&&!d?.has(c.name?.toLowerCase()??""));let C=-1,H=Number.POSITIVE_INFINITY;if(n.stopAtFirstUnknown&&!V&&(C=t.findIndex(c=>z(c)),C!==-1&&(H=t[C].index)),y){const c=[],u=[];for(const p of t)p.kind==="positional"&&!A.has(p.index)&&p.index<H&&(c.push(p.value),u.push(p));if(c.length>0){const p=f[y.name],_=y.multiple??y.lazyMultiple;p===void 0?_?(u.forEach(g=>A.add(g.index)),f[y.name]=c):(A.add(u[0].index),f[y.name]=c[0]):_&&(u.forEach(g=>A.add(g.index)),f[y.name]=Array.isArray(p)?[...c,...p]:[...c,p])}}if(!n.partial){for(const c of t)if(c.kind==="positional"&&!A.has(c.index))throw new ht(o[c.index])}if(n.partial&&!n.stopAtFirstUnknown){const c=[...N];for(const u of P)c.push({index:u.index,value:u.value});for(const u of t)u.kind==="positional"&&!A.has(u.index)&&c.push({index:u.index,value:o[u.index]});c.length>0&&(c.sort((u,p)=>u.index-p.index),h._unknown=c.map(u=>u.value))}if(n.stopAtFirstUnknown&&!V){const c=t.findIndex(p=>p.kind==="positional"&&!A.has(p.index));let u=-1;if(C!==-1&&c!==-1?u=Math.min(C,c):C!==-1?u=C:c!==-1&&(u=c),u>=0){const p=t[u].index;h._unknown=o.slice(p)}}for(const[c,u]of Object.entries(f)){const p=n.camelCase?r?.get(c)??c:c,_=i.get(c);_?.type?h[p]=pt(u,_.type,{optionName:_.name,strictTypes:n.strictTypes}):h[p]=u===void 0?null:u}for(const c of e){const u=n.camelCase?r?.get(c.name)??c.name:c.name;!(u in h)&&c.defaultValue!==void 0&&(c.multiple??c.lazyMultiple?h[u]=Array.isArray(c.defaultValue)?[...c.defaultValue]:[c.defaultValue]:h[u]=c.defaultValue)}if($){const c={},u={},p={};for(const g of e)if(g.group){const x=Array.isArray(g.group)?g.group:[g.group];for(const I of x)we(I)||(c[I]??={})}for(const g of Object.keys(h))if(!wt(g)){u[g]=h[g];let x=g;n.camelCase&&(x=m?.get(g)??g);const I=i.get(x);if(I?.group){const v=Array.isArray(I.group)?I.group:[I.group];for(const k of v)we(k)||c[k]&&(c[k][g]=h[g])}else p[g]=h[g]}const _={_all:u};for(const[g,x]of Object.entries(c))_[g]=x;Object.keys(p).length>0&&(_._none=p),h._unknown&&(_._unknown=h._unknown),Object.keys(h).forEach(g=>delete h[g]),Object.assign(h,_)}const ce=Object.defineProperties({},Object.getOwnPropertyDescriptors(h));return b(s,"Final parsed result:","resolver",ce),ce},q="-".codePointAt(0),R="=",vt=R.codePointAt(0),Nt="--",$t="-",bt="--",Pe=t=>t.length>2&&t.startsWith(bt),At=t=>Pe(t)&&!t.includes(R,3),_t=t=>Pe(t)&&t.includes(R,3),Ot=t=>{if(t.length!==2||t.codePointAt(0)!==q||t.codePointAt(1)===q)return!1;const e=t.codePointAt(1);return e!==void 0&&(e<48||e>57)},Ct=t=>{if(t.length<=2||t.codePointAt(0)!==q||t.codePointAt(1)===q)return!1;const e=t.codePointAt(1);return!(e!==void 0&&e>=48&&e<=57)},xt=t=>{const e=[];let n=0,o=[],s=0,i=-1,l=0;for(;s<o.length||n<t.length;){let a;if(s<o.length?(a=o[s],s++):(a=t[n],n++),l>0?l--:i++,a===Nt){e.push({index:i,kind:"option-terminator"});const d=[...o.slice(s),...t.slice(n)],r=d.map((m,h)=>({index:i+h+1,kind:"positional",value:m}));e.push(...r),i+=d.length;break}if(Ot(a)){const d=a.charAt(1);e.push({index:i,kind:"option",name:d,rawName:a});continue}if(Ct(a)&&!a.includes(R)){const d=[];let r="",m=!1;for(let h=1;h<a.length;h++){const f=a.charAt(h);m?r+=f:f.codePointAt(0)===vt?m=!0:d.push(`${$t}${f}`)}if(m)if(d.length>0){const h=d.pop();d.push(`${h}=${r}`)}else d.push(r);o=s<o.length?[...d,...o.slice(s)]:d,s=0,l=d.length;continue}if(At(a)){const d=a.slice(2);e.push({index:i,kind:"option",name:d,rawName:a});continue}if(_t(a)){const d=a.indexOf(R),r=a.slice(2,d),m=a.slice(d+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:a,value:m});continue}if(a.length>2&&a.codePointAt(0)===q&&a.codePointAt(1)!==q&&a.includes(R)){const d=a.indexOf(R),r=a.charAt(1),m=a.slice(d+1);e.push({index:i,inlineValue:!0,kind:"option",name:r,rawName:a,value:m});continue}e.push({index:i,kind:"positional",value:a})}return e},It=/\d/,kt=t=>typeof t=="function",Et=(t,e,n)=>{const o=n?.debug??!1;b(o,"Validating definitions:","validation",t,"caseInsensitive:",e);const s=new Set,i=new Set,l=new Set,a=new Set;let d=0;for(const r of t){if(b(o,"Checking definition:","validation",r),!r.name)throw b(o,"Validation failed: name is required","validation"),new O("Invalid option definition: name is required");if(typeof r.name!="string")throw new O("Invalid option definition: name must be a string");if(r.name.trim()==="")throw new O("Invalid option definition: name cannot be empty");const m=e?r.name.toLowerCase():"";if(s.has(r.name)||e&&l.has(m))throw new O(`Invalid option definition: duplicate name '${r.name}'`);if(i.has(r.name)||e&&a.has(m))throw new O(`Invalid option definition: name '${r.name}' conflicts with an existing alias`);if(s.add(r.name),e&&l.add(m),r.alias!==void 0){if(typeof r.alias!="string")throw new O("Invalid option definition: alias must be a string");if(r.alias.length!==1)throw new O("Invalid option definition: alias must be a single character");if(It.test(r.alias))throw new O("Invalid option definition: alias cannot be numeric");if(r.alias==="-")throw new O('Invalid option definition: alias cannot be "-"');const h=e?r.alias.toLowerCase():"";if(i.has(r.alias)||e&&a.has(h))throw new O(`Invalid option definition: duplicate alias '${r.alias}'`);if(s.has(r.alias)||e&&l.has(h))throw new O(`Invalid option definition: alias '${r.alias}' conflicts with an existing option name`);i.add(r.alias),e&&a.add(h)}if(r.defaultOption&&(d++,r.type!==void 0&&B(r.type)))throw new O("Invalid option definition: defaultOption cannot be Boolean type");if(r.type!==void 0&&!(r.type===Boolean||r.type===Number||r.type===String||typeof r.type=="function"&&kt(r.type)))throw new O("Invalid option definition: invalid type")}if(d>1)throw b(o,"Validation failed: multiple defaultOptions not allowed","validation"),new O("Invalid option definition: multiple defaultOptions not allowed");b(o,"Validation completed successfully","validation")};function Pt(t,e={}){const n=e.debug??!1;b(n,"Starting command-line-args parsing","index"),b(n,"Options:","index",e);const o={...e};o.stopAtFirstUnknown&&(o.partial=!0);const s=Array.isArray(t)?t:[t];b(n,"Normalized definitions:","index",s),Et(s,o.caseInsensitive,n?o:void 0);let{argv:i}=o;i??=process.argv.slice(2),b(n,"Using argv:","index",i);let l=i;o.caseInsensitive&&(l=i.map(r=>{if(r.startsWith("--")){const m=r.indexOf("="),h=(m===-1?r.slice(2):r.slice(2,m)).toLowerCase();return m===-1?`--${h}`:`--${h}${r.slice(m)}`}if(r.startsWith("-")&&!r.startsWith("--")&&r.length>1){const m=r.indexOf("="),h=m===-1?r.slice(1):r.slice(1,m);if(!h)return r;const f=h.toLowerCase();return m===-1?`-${f}`:`-${f}${r.slice(m)}`}return r}));const a=xt(l.map(String));b(n,"Tokenized arguments:","index",a);const d=yt(a,s,o,i);return b(n,"Command-line-args parsing completed","index"),d}class Lt{result;argv;options;argument;command;commandName;env;logger;console;fs;process;runtime;rawUnknown;constructor(e,n){this.commandName=e,this.command=n}}let ne=class extends w{commandName;constructor(e,n,o){super(`Failed to load command "${e}": ${n}`,"COMMAND_LOADER_ERROR",{commandName:e,reason:n}),this.name="CommandLoaderError",this.commandName=e,this.hint="Ensure the loader resolves to a module with a default export that is the command handler function.",o!==void 0&&(this.cause=o)}};const Dt=/^-{1,2}(\w+)(=(.+))?$/,Le=(t,e,n,o)=>{const s=Dt.exec(t);if(s===null)return{};const i=s[1];if(!i)return{};const l=n&&o?n.get(i)??o.get(i):e.find(a=>a.name===i||a.alias===i);return l!==void 0?{argName:l.name,argValue:s[3],option:l}:{}},ve=(t,e)=>{if(e.type===void 0)return t;if(e.type.name==="Boolean"){if(t==="true"||t==="1")return e.type(!0);if(t==="false"||t==="0")return e.type(!1)}return e.type(t)},Mt=new Set(["0","1","false","true"]),Vt=(t,e,n,o)=>{if(e.length===0||t.length===0)return{};const s=(i,l)=>{const{argName:a,argValue:d,option:r}=Le(l,e,n,o),{lastOption:m}=i;return r&&G(r)&&d&&a?i.partial[a]=ve(d,r):i.lastName&&m&&G(m)&&Mt.has(l)&&(i.partial[i.lastName]=ve(l,m)),{lastName:a,lastOption:r,partial:i.partial}};return t.reduce(s,{partial:{}}).partial},jt=new Set(["0","1","false","true"]),St=(t,e,n,o)=>{if(e.length===0||t.length===0)return t;const s=(i,l)=>{const{argValue:a,option:d}=Le(l,e,n,o),{lastOption:r}=i;if(r&&G(r)&&jt.has(l)){const{args:m}=i;return{args:m.slice(0,-1)}}return d&&G(d)&&a?{args:i.args}:{args:[...i.args,l],lastOption:d}};return t.reduce(s,{args:[]}).args},Ne=t=>{const e=new Map;for(const n of t){const o=e.get(n.name);o?e.set(n.name,{...o,...n}):e.set(n.name,n)}return[...e.values()]},Tt=t=>{if(t===void 0)return;const e=t.toLowerCase().trim();return e==="true"||e==="1"||e==="yes"||e==="on"},Ut=(t,e)=>{if(!t.type)return e;if(e!==void 0){if(t.type===Boolean||typeof t.type=="function"&&t.type.name==="Boolean")return Tt(e);if(t.type===Number||typeof t.type=="function"&&t.type.name==="Number"){const n=Number.parseFloat(e);return Number.isNaN(n)?void 0:n}return t.type===String||typeof t.type=="function"&&t.type.name==="String"?e:t.type(e)}},Bt=/_./g,Rt=/^[A-Z]/,zt=t=>t.toLowerCase().replaceAll(Bt,e=>e[1]?.toUpperCase()??e).replace(Rt,e=>e.toLowerCase()),Ft=(t,e=Q())=>{if(!t||t.length===0)return{};const n={};for(const o of t){const s=e[o.name],i=Ut(o,s),l=i===void 0?o.defaultValue:i,a=zt(o.name);n[a]=l}return n},qt=t=>{const e=new Map,n=new Map;for(const o of t)if(e.set(o.name,o),o.alias){const s=Array.isArray(o.alias)?o.alias:[o.alias];for(const i of s)n.set(i,o)}return{optionMapByAlias:n,optionMapByName:e}},De=async t=>{if(typeof t.__resolvedExecute__=="function")return t.__resolvedExecute__;if(typeof t.loader!="function")throw new ne(t.name,"no execute or loader defined");let e;try{e=await t.loader()}catch(o){throw new ne(t.name,o instanceof Error?o.message:String(o),o)}const n=e.default;if(typeof n!="function")throw new ne(t.name,"loader did not return a module with a default-exported handler function");return t.__resolvedExecute__=n,n},Wt=(t,e,n,o,s)=>{const i=new Lt(t.name,t),{_all:l,_unknown:a,positionals:d}=e,r=Object.keys(n).length>0?{...l,...n}:l;Z in r&&delete r[Z],i.argument=d?.[Z]??[],i.rawUnknown=[...a??[]];const m=Object.keys(o).length>0;return i.options=m?{...r,...o}:r,i.env=Ft(t.env,s),i},Gt=(t,e,n)=>{const o=t.options??[],s=o.length>0;let i=Ne(s?[...o,...n]:n);if(i.length>0){for(const r of i)if(r.multiple&&r.lazyMultiple)throw new Error(`Argument "${r.name}" cannot have both multiple and lazyMultiple options, please choose one.`)}t.argument&&(i=[{defaultOption:!0,description:t.argument.description,group:"positionals",multiple:!0,name:Z,type:t.argument.type,typeLabel:t.argument.typeLabel},...i]);let l,a;if(s){const{optionMapByAlias:r,optionMapByName:m}=qt(o);l=St(e,o,m,r),a=Vt(e,o,m,r)}else l=e,a={};const d=Pt(i,{argv:l,camelCase:!0,partial:!0,stopAtFirstUnknown:!0});return{arguments_:i,booleanValues:a,parsedArgs:d}},oe=async(t,e,n)=>typeof t.execute=="function"?t.execute(e):(await De(t))(e),Yt=(t,e)=>typeof t!="string"||t===""?"":t[0].toLowerCase()+t.slice(1),Ht=(t,e)=>typeof t!="string"||t===""?"":t[0].toUpperCase()+t.slice(1),Kt=(t,e)=>{const{length:n}=t;if(n===0)return"";if(n===1)return t[0];const o=[];let s="",i="";for(let l=0;l<n;l++){const a=t[l];if(Xe.test(a)){s?(o.push(s+i+a),s="",i=""):(o.length>0&&o.push(e),s=a);continue}s?(i&&(i+=e),i+=a):(o.length>0&&o.push(e),o.push(a))}return o.join("")},F=(t,e)=>{if(typeof t!="string"||!t)return"";let n=!0;return Kt(et(t,{handleAnsi:e?.handleAnsi,handleEmoji:e?.handleEmoji,knownAcronyms:e?.knownAcronyms,locale:e?.locale,normalize:e?.normalize,separators:void 0,stripAnsi:e?.stripAnsi,stripEmoji:e?.stripEmoji}).map(s=>{const i=s,l=i.toLowerCase();return n?(n=!1,Yt(l)):Ht(l)}),"")};let Jt=class extends w{commandName;missingOptions;constructor(e,n){super(`Command "${e}" is missing required options: ${n.join(", ")}`,"COMMAND_VALIDATION_ERROR",{commandName:e,missingOptions:n}),this.name="CommandValidationError",this.commandName=e,this.missingOptions=n,this.hint=`Provide the following required options: ${n.join(", ")}`}},Zt=class extends w{choices;option;value;constructor(e,n,o){super(`Invalid value "${n}" for option "${e}". Allowed values: ${o.join(", ")}`,"INVALID_CHOICE",{choices:o,option:e,value:n}),this.name="InvalidChoiceError",this.option=e,this.value=n,this.choices=o,this.hint=`Use one of: ${o.map(s=>`--${e} ${s}`).join(", ")}`}};const $e=(t,e,n=!1)=>{const o=[],s=e._all??e;for(const i of t){if(!n&&!i.required)continue;const l=i.__camelCaseName__??i.name;if(s[l]===void 0){if(i.type?.name==="Boolean"){e[l]=!1;continue}o.push(i)}}return o},Qt=(t,e)=>e.includes(t)?!0:Math.abs(t.length-e.length)>t.length/2?!1:tt(t,e)<=t.length/3,j=(t,e)=>{const n=t.toLowerCase();return e.filter(o=>Qt(o.toLowerCase(),n))},Xt=(t,e)=>{const n=[];if(t._unknown&&t._unknown.forEach(o=>{const s=o.startsWith("--");let i=`Found unknown ${s?"option":"argument"} "${o}"`;if(s){const l=j(o.replace("--",""),(e.options??[]).map(a=>a.name));if(l.length>0){const[a,...d]=l.map(r=>`--${r}`);i+=d.length>0?`, did you mean ${a??""} or ${d.join(", ")}?`:`, did you mean ${a??""}?`}}n.push(i)}),n.length>0)throw new Error(n.join(`
2
+ `))},en=(t,e,n)=>{const o=n.__requiredOptions__,s=o?$e(o,e,!0):$e(t,e,!1);if(s.length>0)throw new Jt(n.name,s.map(i=>i.name));e._unknown&&e._unknown.length>0&&!n.argument&&Xt(e,n)},tn=(t,e,n)=>{const o=n.__conflictingOptions__??t.filter(s=>s.conflicts!==void 0);if(o.length>0){const s=o.find(i=>{const l=i.__camelCaseName__??F(i.name);return Array.isArray(i.conflicts)?i.conflicts.some(a=>e[F(a)]!==void 0)&&e[l]!==void 0:e[F(i.conflicts)]!==void 0&&e[l]!==void 0});if(s)throw new Ce(s.name,typeof s.conflicts=="string"?s.conflicts:s.conflicts?.[0]??"unknown")}},nn=(t,e)=>{const n=e.options;if(n)for(const o of n){if(!o.choices||o.choices.length===0)continue;const s=o.__camelCaseName__??F(o.name),i=t[s];if(i==null)continue;const l=Array.isArray(i)?i:[i];for(const a of l){const d=String(a);if(!o.choices.includes(d))throw new Zt(o.name,d,o.choices)}}},on=t=>{if(!Array.isArray(t.options))return;const e=new Map,n=new Map;for(const s of t.options){if(s.name){const i=e.get(s.name)??[];i.push(s),e.set(s.name,i)}if(typeof s.alias=="string"&&s.alias.length>0){const i=n.get(s.alias)??[];i.push(s),n.set(s.alias,i)}else if(Array.isArray(s.alias)){for(const i of s.alias)if(i.length>0){const l=n.get(i)??[];l.push(s),n.set(i,l)}}}const o=[];for(const[s,i]of e)i.length>1&&o.push(`Duplicate option name "${s}" in command "${t.name}": ${JSON.stringify(i)}`);for(const[s,i]of n)i.length>1&&o.push(`Duplicate option alias "-${s}" used by options ${i.map(l=>`"${l.name}"`).join(", ")} in command "${t.name}"`);if(o.length>0)throw new Error(o.join(`
3
+ `))},sn=(t,e)=>{if(e.length===0)return{argv:[],commandPath:void 0};const n=[];let o;for(let s=1;s<=e.length;s+=1){const i=e[s-1];if(i===void 0||i.startsWith("-"))break;n.push(i);const l=n.join(" ");t.has(l)&&(o={commandPath:[...n],depth:s})}return o?{argv:e.slice(o.depth),commandPath:o.commandPath}:{argv:e,commandPath:void 0}},T=t=>t.join(" "),be=(t,e)=>e&&e.length>0?[...e,t]:[t],an=/^no-/,rn=t=>{t.options?.forEach(e=>{e.__camelCaseName__=F(e.name)})},ln=t=>{if(!Array.isArray(t.options)||t.options.length===0)return;const e=new Set;for(const o of t.options)e.add(o.name);const n=[];for(const o of t.options)if(o.name.startsWith("no-")){const s=o.name.replace(an,"");if(!e.has(s)){if(o.type!==Boolean)throw new Error(`Cannot add negated option "${o.name}" to command "${t.name}" because it is not a boolean.`);const i={...o,defaultValue:o.defaultValue===void 0?!0:!o.defaultValue,name:s};n.push(i),e.add(s)}}n.length>0&&t.options.push(...n)},cn=(t,e)=>{if(!e.options||e.options.length===0)return;const{options:n}=t,o=new Map;for(const i of e.options)if(i.name.startsWith("no-")){const l=F(i.name);o.set(l,i)}const s=Object.keys(n).filter(i=>o.has(i));if(s.length!==0)for(const i of s){const l=i.charAt(2);if(!l)continue;const a=l.toLowerCase()+i.slice(3),d=o.get(i);d&&(d.__negated__=!0),n[a]=!n[i],Reflect.deleteProperty(n,i)}},dn=(t,e)=>{if(!e.options||e.options.length===0)return;const n=new Map;for(const s of e.options)s.__camelCaseName__&&s.__negated__===void 0&&s.implies!==void 0&&n.set(s.__camelCaseName__,s);if(n.size===0)return;const{options:o}=t;for(const s of Object.keys(o)){const i=n.get(s);if(i?.implies){const{implies:l}=i;for(const[a,d]of Object.entries(l))o[a]===void 0&&(o[a]=d)}}},un=()=>!!process.versions.electron,mn=()=>un()&&!process.defaultApp,hn=()=>mn()?0:1,pn=t=>t.slice(hn()+1),fn=" ",gn=(t,e)=>t===e?!0:t.length!==e.length?!1:t.every((n,o)=>n===e[o]),wn=t=>{if(typeof t=="string")return t.split(fn);const e=ae();return gn(t,e)?pn(t):t},yn=t=>{const e=i=>{t.error(`Uncaught exception: ${i.message||i}`),i.stack&&t.error(i.stack),U(1)},n=(i,l)=>{if(i instanceof Error)t.error(`Promise rejection: ${i.message||i}`),i.stack&&t.error(i.stack);else{let a;if(typeof i=="string")a=i;else try{a=JSON.stringify(i)}catch{a=String(i)}t.error(`Promise rejection: ${a}`)}U(1)},o=ue("uncaughtException",e),s=ue("unhandledRejection",n);return()=>{o(),s()}},Ae=100,vn=/^[a-z][\w-]*$/i,le=(t,e)=>{if(typeof t!="string"||t.trim().length===0)throw new w(`${e} must be a non-empty string`,"INVALID_INPUT",{fieldName:e,value:t});return t.trim()},_e=(t,e)=>{if(!Array.isArray(t)||!t.every(n=>typeof n=="string"))throw new w(`${e} must be an array of strings`,"INVALID_INPUT",{fieldName:e,value:t});return t},ie=(t,e)=>{if(typeof t!="object"||t===null)throw new w(`${e} must be an object`,"INVALID_INPUT",{fieldName:e,value:t});return t},J=t=>{const e=le(t,"Command name");if(e.length>Ae)throw new w(`Command name is too long (maximum ${String(Ae)} characters)`,"INVALID_COMMAND_NAME",{commandName:e,length:e.length});if(e.includes("..")||e.includes("/")||e.includes("\\")||e.includes(";")||e.includes("|")||e.includes("&"))throw new w(`Command name "${e}" contains invalid characters`,"INVALID_COMMAND_NAME",{commandName:e});if(!vn.test(e))throw new w(`Command name "${e}" must start with a letter and contain only letters, numbers, hyphens, and underscores`,"INVALID_COMMAND_NAME",{commandName:e});return e},Nn=new Set([`
4
+ `,"\r"," ","\0",'"',"$","&","'","(",")",";","<",">","[","\\","]","`","{","|","}"]),$n=(t,e={})=>{if(typeof t!="string")throw new TypeError("Argument must be a string");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArgumentLength??1e6;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Argument is too long (maximum ${String(o)} characters)`);if(n.checkDangerousChars){for(const s of t)if(Nn.has(s))throw new Error(`Argument contains dangerous character: ${s}`)}return n.trim?t.trim():t},Oe=(t,e={})=>{if(!Array.isArray(t))throw new TypeError("Arguments must be an array");const n=typeof e=="boolean"?{checkDangerousChars:e}:e,o=n.maxArguments??1e5;if(Number.isFinite(o)&&o>0&&t.length>o)throw new Error(`Too many arguments (maximum ${String(o)})`);return t.map(s=>$n(s,n))},bn=/^-([^\d-])$/,An=/^--(\S+)/,_n=/^-([^\d-]{2,})$/,se=t=>bn.test(t)||An.test(t)||_n.test(t),On={access:(t,e)=>We(t,e),mkdir:(t,e)=>qe(t,e),readdir:t=>Fe(t),readFile:(async(t,e)=>e===void 0?de(t):de(t,e)),rm:(t,e)=>ze(t,e),stat:t=>Re(t),writeFile:(t,e,n)=>Be(t,e,n)},Cn=(t,e,n)=>{const o=e.indexOf("--"),s=o===-1?new Set:new Set(e.slice(o+1)),i=n.filter(d=>d.startsWith("--")&&d!=="--"&&!s.has(d));if(i.length===0)return;const l=(t.options??[]).map(d=>d.name),a=i.flatMap(d=>j(d.slice(2),l).map(r=>`--${r}`));throw new nt(i,a)};class Me{#t;#e;#d;#m;#h;#p;#_;#O;#C;#N;#x;#$;#I;#b=ee;#u;#n;#o;#i;#s;#a;#k=!1;#E;#P=!1;#f;#g;#w;#l=[];#S(){return this.#f===void 0&&(this.#f=[...this.#o.keys()]),this.#f}#L(){return this.#g===void 0&&(this.#g=[...this.#n.keys()]),this.#g}#r(){return this.#w===void 0&&(this.#w=[...this.#S(),...this.#L()]),this.#w}#D(){return this.#l.length===0?K:[...K,...this.#l]}#M(){this.#f=void 0,this.#g=void 0,this.#w=void 0}#A(){if(this.#d===void 0){const e=wn(this.#e.argv);this.#d=Oe(e,{maxArguments:this.#$}),this.#T()}return this.#d}#y(){return this.#N??Q()}#v(e){this.#b=e,this.#y().CEREBRO_OUTPUT_LEVEL=String(e)}#c(){return this.#b}#T(){if(!this.#d)return;let e=!1;for(const n of this.#d){if(n==="--quiet"||n==="-q"){this.#v(Ge),e=!0;break}if(n==="--verbose"||n==="-v"){this.#v(Ye),e=!0;break}if(n==="--debug"){this.#v(M),e=!0;break}}e||this.#v(Object.hasOwn(this.#y(),"DEBUG")?M:ee)}#U(){this.#P||(this.#E=yn(this.#t),this.#P=!0)}#B(){return{arch:Ke(),argv:this.#A(),cwd:this.#m,env:this.#N??Q(),exit:this.#C??(e=>U(e??0)),platform:He(),stdin:this.#x}}#V(e,n,o,s){this.#c()===M&&this.#t.debug(`command '${s}' found, parsing command args: ${n.join(", ")}`);const{arguments_:i,booleanValues:l,parsedArgs:a}=Gt(e,n,this.#D()),d=Object.keys(l).length>0;let r=a;d&&(r={...a,_all:{...a._all,...l}}),en(i,r,e);const m=Wt(e,a,l,o,this.#y());m.runtime=this,m.argv=this.#A(),m.fs=this.#O??On,m.process=this.#B(),m.console=this.#t;const h=e.options&&e.options.length>0;if(h&&e.options){const f=e.options.filter(N=>N.name.startsWith("no-"));for(const N of f){const P=N.name.slice(3),A=`--${N.name}`,V=`--${P}`,y=n.includes(A),$=n.includes(V);if(y&&$)throw new Ce(P,N.name)}}return h&&(cn(m,e),dn(m,e)),tn(i,m.options,e),nn(m.options,e),this.#I&&Cn(e,n,m.rawUnknown),this.#c()===M&&(this.#t.debug("command options parsed from options:"),this.#t.debug(JSON.stringify(m.options,null,2)),this.#t.debug("command argument parsed from argument:"),this.#t.debug(JSON.stringify(m.argument,null,2))),{arguments_:i,booleanValues:l,commandArgs:r,parsedArgs:a,toolbox:m}}async#j(e,n,o){const s=this.getPluginManager();try{!this.#k&&s.hasPlugins()&&(await s.init({cli:this,cwd:this.#m,logger:this.#t}),this.#k=!0),await s.executeLifecycle("execute",n),await s.executeLifecycle("beforeCommand",n);let i;const l=o.global;if(l?.help){const a=this.#n.get("help");if(!a)throw new w("Help command not found","COMMAND_NOT_FOUND");i=await oe(a,n)}else if(l?.version??l?.V){const a=this.#n.get("version");if(!a)throw new w("Version command not found","COMMAND_NOT_FOUND");i=await oe(a,n)}else i=await oe(e,n);return await s.executeLifecycle("afterCommand",n,i),i}catch(i){throw await s.executeErrorHandlers(i,n),i}}constructor(e,n={}){if(typeof e!="string"||e.trim().length===0)throw new w("CLI name must be a non-empty string","INVALID_INPUT",{cliName:e});this.#h=e.trim();const o=n.argv??ae(),s=n.cwd??Je();if(this.#e={...n,argv:o,cwd:s},this.#e.argv&&!Array.isArray(this.#e.argv))throw new w("CLI argv option must be an array of strings","INVALID_INPUT",{argv:this.#e.argv});if(this.#e.cwd&&typeof this.#e.cwd!="string")throw new w("CLI cwd option must be a string","INVALID_INPUT",{cwd:this.#e.cwd});if(this.#e.packageName&&typeof this.#e.packageName!="string")throw new w("CLI packageName option must be a string","INVALID_INPUT",{packageName:this.#e.packageName});if(this.#e.packageVersion&&typeof this.#e.packageVersion!="string")throw new w("CLI packageVersion option must be a string","INVALID_INPUT",{packageVersion:this.#e.packageVersion});if(typeof this.#e.logger=="object"){const h=["debug","error","info","log","warn"],f=[],N=this.#e.logger;for(const P of h)typeof N[P]!="function"&&f.push(P);if(f.length>0)throw new w(`Logger object is missing required methods: ${f.join(", ")}`,"INVALID_INPUT",{logger:this.#e.logger,missingMethods:f});this.#t=this.#e.logger}else this.#t={...console,debug:(...h)=>{this.#c()===M&&console.debug(...h)}};this.#p=this.#e.packageVersion,this.#_=this.#e.packageName,this.#m=this.#e.cwd,this.#s="help",this.#a={};const i=n.fs;if(i!==void 0&&(typeof i!="object"||i===null))throw new w("CLI fs option must be an object implementing the CerebroFs interface","INVALID_INPUT",{fs:n.fs});const l=n.exit;if(l!==void 0&&typeof l!="function")throw new w("CLI exit option must be a function","INVALID_INPUT",{exit:n.exit});const a=n.env;if(a!==void 0&&(typeof a!="object"||a===null))throw new w("CLI env option must be a record of string keys","INVALID_INPUT",{env:n.env});const d=n.stdin;if(d!==void 0&&typeof d!="string")throw new w("CLI stdin option must be a string","INVALID_INPUT",{stdin:n.stdin});this.#O=n.fs,this.#C=n.exit,this.#N=n.env,this.#x=n.stdin??"",this.#$=n.maxArguments,this.#I=n.strictOptions??!1;const r=this.#y().CEREBRO_OUTPUT_LEVEL,m=r===void 0?Number.NaN:Number(r);this.#b=Number.isNaN(m)?ee:m,this.#n=new Map,this.#o=new Map,this.#i=new Map}setCommandSection(e){return this.#a=e,this}getCommandSection(){return this.#a.header||(this.#a.header=`${this.#h}${this.#p?` v${this.#p}`:""}`),this.#a}setDefaultCommand(e){return this.#s=e,this}get defaultCommand(){return this.#s}addCommand(e){ie(e,"Command"),J(e.name);const n=typeof e.execute=="function",o=typeof e.loader=="function";if(n&&o)throw new w(`Command "${e.name}" cannot define both "execute" and "loader" — choose one`,"INVALID_COMMAND",{commandName:e.name});if(!n&&!o)throw new w(`Command "${e.name}" must define either "execute" or "loader"`,"INVALID_COMMAND",{commandName:e.name});e.alias&&(typeof e.alias=="string"?J(e.alias):_e(e.alias,"Command alias").forEach(r=>J(r))),e.argument&&ie(e.argument,"Command argument"),e.options&&ie(e.options,"Command options"),e.commandPath&&(_e(e.commandPath,"Command commandPath"),e.commandPath.forEach(r=>{J(r)}));const s=be(e.name,e.commandPath),i=T(s);if(this.#o.has(i))throw new w(`Command with path "${i}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name,commandPath:e.commandPath});const l=Array.isArray(e.commandPath)&&e.commandPath.length>0,a=this.#n.get(e.name),d=a!==void 0&&(a.commandPath===void 0||a.commandPath.length===0);if(!l&&d)throw new w(`Command with name "${e.name}" already exists`,"DUPLICATE_COMMAND",{commandName:e.name});if(e.options)for(const r of e.options)me(r);if(on(e),ln(e),rn(e),e.options&&(e.__conflictingOptions__=e.options.filter(r=>r.conflicts!==void 0),e.__requiredOptions__=e.options.filter(r=>r.required===!0)),l&&a!==void 0)this.#n.set(i,e);else{if(!l&&a!==void 0&&!d){const r=be(a.name,a.commandPath);this.#n.set(T(r),a)}this.#n.set(e.name,e)}if(this.#o.set(i,s),this.#i.set(i,e),this.#M(),e.alias!==void 0){const r=typeof e.alias=="string"?[e.alias]:e.alias;for(const m of r){if(this.#c()===M&&this.#t.debug("adding alias",m),this.#n.has(m))throw new w(`Command alias "${m}" conflicts with existing command`,"DUPLICATE_COMMAND",{alias:m,commandName:e.name});this.#n.set(m,e)}}return this}addGlobalOption(e){const n=e,o=new Set(K.map(i=>i.name)),s=new Set(K.map(i=>i.alias).filter(Boolean));if(o.has(n.name))throw new w(`Cannot add global option "--${n.name}": it conflicts with a built-in global option`,"DUPLICATE_OPTION",{optionName:n.name});if(n.alias&&s.has(n.alias))throw new w(`Cannot add global option with alias "-${n.alias}": it conflicts with a built-in global option alias`,"DUPLICATE_OPTION",{alias:n.alias,optionName:n.name});if(new Set(this.#l.map(i=>i.name)).has(n.name))throw new w(`Global option "--${n.name}" has already been added`,"DUPLICATE_OPTION",{optionName:n.name});return n.group="global",me(n),this.#l.push(n),this}getGlobalOptions(){return this.#D()}addPlugin(e){return this.getPluginManager().register(e),this}getPluginManager(){return this.#u?this.#u:(this.#u=new it(this.#t),this.#u.register({description:"Attaches the logger to the toolbox",execute:e=>{e.logger=this.#t,e.console=e.logger},name:"logger"}),this.#u)}getCliName(){return this.#h}getPackageVersion(){return this.#p}getPackageName(){return this.#_}getCommands(){return this.#n}getCwd(){return this.#m}dispose(){this.#E?.()}async run(e={}){const{autoDispose:n=!0,shouldExitProcess:o=!0,...s}=e;if(!this.#n.has("help")){const{default:y}=await import("../commands/help-command.js");this.addCommand(new y(this.#n))}const i=this.#L(),l=this.#o;this.#U();const a=this.#A();let d,r=[...a];this.#c()===M&&(this.#t.debug(`process.execPath: ${Ze()}`),this.#t.debug(`process.execArgv: ${Qe().join(" ")}`),this.#t.debug(`process.argv: ${ae().join(" ")}`));const m=sn(l,[...a]);if(m.commandPath)d=m.commandPath,r=m.argv;else{if(a.length>1&&a[0]&&a[1]&&!se(a[0])&&!se(a[1])){const $=[];let E=0;for(;E<a.length;){const C=a[E];if(!C||se(C))break;$.push(C),E+=1}const z=T($);if($[0]&&!i.includes($[0])){const C=this.#r(),H=j(z,C);throw new S(z,H)}}let y;try{y=dt([null,...i],[...a])}catch($){if($ instanceof Error&&$.name==="INVALID_COMMAND"&&"command"in $){const E=$.command,z=this.#r(),C=j(E,z);throw new S(E,C)}throw $}y.command&&(d=[y.command],r=y.argv)}if(!d)if(this.#s)d=[this.#s];else{const y=this.#r();throw new S("",y)}const h=T(d),f=this.#o.get(h);let N;if(f){if(N=this.#i.get(h),!N||T(f)!==h){const y=this.#r(),$=j(h,y);throw new S(h,$)}}else{const y=d.at(-1);if(N=y?this.#n.get(y):void 0,!N){const $=this.#r(),E=j(h,$);throw new S(h,E)}}if(typeof N.execute!="function"&&typeof N.loader!="function")return this.#t.error(`Command "${N.name}" has no function to execute.`),o?U(1):void 0;const P=r;let A,V;try{({commandArgs:A,toolbox:V}=this.#V(N,P,s,h))}catch(y){if(this.#t.error(y),o)return U(1);throw y}try{return await this.#j(N,V,A),o?U(0):void 0}catch(y){if(o)return this.#t.error(y),U(1);throw y}finally{n&&this.dispose()}}async runCommand(e,n={}){const{argv:o=[],...s}=n;le(e,"Command name");const i=e.split(" ").filter(Boolean),l=T(i),a=this.#o.get(l)?this.#i.get(l):this.#n.get(e);if(!a){const h=this.#r(),f=j(l||e,h);throw new S(e,f)}if(typeof a.execute!="function"&&typeof a.loader!="function")throw new w(`Command "${a.name}" has no function to execute`,"INVALID_COMMAND",{commandName:a.name});const d=[...Oe(o,{maxArguments:this.#$})];this.#c()===M&&this.#t.debug(`running command '${e}' programmatically with args: ${d.join(", ")}`);const{commandArgs:r,toolbox:m}=this.#V(a,d,s,l||e);return this.#j(a,m,r)}clone(e){const n={...this.#e,...e},o=new Me(this.#h,n);for(const[s,i]of this.#n)o.#n.set(s,i);for(const[s,i]of this.#o)o.#o.set(s,[...i]);for(const[s,i]of this.#i)o.#i.set(s,i);for(const s of this.#l)o.#l.push(s);return o.#s=this.#s,o.#a={...this.#a},o.#M(),o}async getAction(e){le(e,"Command name");const n=e.split(" ").filter(Boolean),o=T(n),s=this.#o.get(o)?this.#i.get(o):this.#n.get(e);if(!s){const i=this.#r(),l=j(o||e,i);throw new S(e,l)}if(typeof s.execute=="function")return s.execute;if(typeof s.loader=="function")return De(s);throw new w(`Command "${s.name}" has no execute or loader defined`,"INVALID_COMMAND",{commandName:s.name})}}export{Me as Cli};