@visulima/cerebro 3.0.0-alpha.2 → 3.0.0-alpha.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (89) hide show
  1. package/CHANGELOG.md +334 -0
  2. package/LICENSE.md +589 -4096
  3. package/README.md +26 -0
  4. package/dist/commands/completion-command.d.ts +6 -5
  5. package/dist/commands/completion-command.js +2 -2
  6. package/dist/commands/help-command.d.ts +9 -9
  7. package/dist/commands/help-command.js +1 -1
  8. package/dist/commands/readme-command.d.ts +6 -5
  9. package/dist/commands/readme-command.js +20 -20
  10. package/dist/commands/version-command.d.ts +4 -3
  11. package/dist/index.d.ts +422 -95
  12. package/dist/index.js +1 -1
  13. package/dist/logger/create-pail-logger.d.ts +779 -8
  14. package/dist/logger/create-pail-logger.js +1 -1
  15. package/dist/packem_chunks/has-new-version.js +1 -1
  16. package/dist/packem_shared/Cerebro-DVWKQlmP.js +4 -0
  17. package/dist/packem_shared/VisulimaError-Bh91XNXu.js +76 -0
  18. package/dist/packem_shared/index-B0BiusY7.js +6 -0
  19. package/dist/packem_shared/index.d-Br8HpP0A.d.ts +93 -0
  20. package/dist/packem_shared/lazyNamed-DOmefeJM.js +1 -0
  21. package/dist/packem_shared/plugin-manager.d-Dz-wu1tI.d.ts +544 -0
  22. package/dist/packem_shared/renderError-B_XyYPKJ-B65kP-Ou.js +24 -0
  23. package/dist/packem_shared/{runtime-process-G-n-wOub.js → runtime-process-DKHFvYkv.js} +1 -1
  24. package/dist/plugins/error-handler-plugin.d.ts +21 -19
  25. package/dist/plugins/error-handler-plugin.js +1 -1
  26. package/dist/plugins/runtime-version-check-plugin.d.ts +22 -20
  27. package/dist/plugins/runtime-version-check-plugin.js +1 -1
  28. package/dist/plugins/update-notifier/update-notifier-plugin.d.ts +21 -8
  29. package/dist/plugins/update-notifier/update-notifier-plugin.js +1 -1
  30. package/dist/util/general/compile-cache.d.ts +41 -0
  31. package/dist/util/general/compile-cache.js +1 -0
  32. package/dist/util/general/heap-tuning.d.ts +18 -0
  33. package/dist/util/general/heap-tuning.js +1 -0
  34. package/package.json +52 -44
  35. package/dist/cli.d.ts +0 -203
  36. package/dist/constants.d.ts +0 -29
  37. package/dist/default-env.d.ts +0 -7
  38. package/dist/default-options.d.ts +0 -3
  39. package/dist/empty-toolbox.d.ts +0 -15
  40. package/dist/errors/cerebro-error.d.ts +0 -10
  41. package/dist/errors/command-not-found-error.d.ts +0 -9
  42. package/dist/errors/command-validation-error.d.ts +0 -10
  43. package/dist/errors/completion-error.d.ts +0 -9
  44. package/dist/errors/conflicting-options-error.d.ts +0 -10
  45. package/dist/errors/plugin-error.d.ts +0 -9
  46. package/dist/errors/update-notifier-error.d.ts +0 -7
  47. package/dist/packem_shared/Cerebro-aPZjbfzf.js +0 -4
  48. package/dist/packem_shared/VisulimaError-BJideSBf.js +0 -76
  49. package/dist/packem_shared/help-command-CIRIXN03.js +0 -1
  50. package/dist/packem_shared/index-DQ3pvLQH.js +0 -6
  51. package/dist/packem_shared/renderError-ZMlMvw1N-eVUSdl6c.js +0 -24
  52. package/dist/plugin-manager.d.ts +0 -53
  53. package/dist/plugins/update-notifier/cache.d.ts +0 -11
  54. package/dist/plugins/update-notifier/get-distribution-version.d.ts +0 -2
  55. package/dist/plugins/update-notifier/has-new-version.d.ts +0 -14
  56. package/dist/types/cli.d.ts +0 -102
  57. package/dist/types/command-line-usage.d.ts +0 -37
  58. package/dist/types/command.d.ts +0 -136
  59. package/dist/types/option-types.d.ts +0 -83
  60. package/dist/types/options.d.ts +0 -4
  61. package/dist/types/plugin.d.ts +0 -53
  62. package/dist/types/toolbox.d.ts +0 -96
  63. package/dist/util/arg-processing/get-boolean-values.d.ts +0 -7
  64. package/dist/util/arg-processing/get-parameter-option.d.ts +0 -7
  65. package/dist/util/arg-processing/map-option-type-label.d.ts +0 -3
  66. package/dist/util/arg-processing/option-is-boolean.d.ts +0 -9
  67. package/dist/util/arg-processing/remove-boolean-values.d.ts +0 -9
  68. package/dist/util/command-line-commands.d.ts +0 -10
  69. package/dist/util/command-line-usage/get-terminal-width.d.ts +0 -7
  70. package/dist/util/command-line-usage/index.d.ts +0 -3
  71. package/dist/util/command-line-usage/section/base-section.d.ts +0 -8
  72. package/dist/util/command-line-usage/section/content-section.d.ts +0 -65
  73. package/dist/util/command-line-usage/section/option-list-section.d.ts +0 -44
  74. package/dist/util/command-processing/command-processor.d.ts +0 -37
  75. package/dist/util/command-processing/command-validation.d.ts +0 -17
  76. package/dist/util/command-processing/nested-command-parser.d.ts +0 -25
  77. package/dist/util/command-processing/option-processor.d.ts +0 -44
  78. package/dist/util/data-processing/list-missing-arguments.d.ts +0 -15
  79. package/dist/util/data-processing/merge-arguments.d.ts +0 -7
  80. package/dist/util/general/find-alternatives.d.ts +0 -8
  81. package/dist/util/general/hide-bin.d.ts +0 -2
  82. package/dist/util/general/parse-raw-command.d.ts +0 -7
  83. package/dist/util/general/register-exception-handler.d.ts +0 -9
  84. package/dist/util/general/runtime-process.d.ts +0 -65
  85. package/dist/util/general/semver-gt.d.ts +0 -2
  86. package/dist/util/general/validate-input.d.ts +0 -24
  87. package/dist/util/process-env-variables.d.ts +0 -9
  88. package/dist/util/security.d.ts +0 -58
  89. package/dist/util/text-processing/template-format.d.ts +0 -5
package/README.md CHANGED
@@ -158,6 +158,32 @@ You should see help output and command execution based on the options provided:
158
158
 
159
159
  ![Cli Output](./__assets__/cli_output.png)
160
160
 
161
+ ## Lazy commands
162
+
163
+ For CLIs with many subcommands or heavy per-command dependencies, you can defer importing each handler until the command is actually invoked. Declare the metadata inline and point `loader` at a dynamic `import()`:
164
+
165
+ ```ts
166
+ // commands/build.ts
167
+ export default ({ logger, options }) => {
168
+ logger.info(`Building to ${options.output ?? "dist"}`);
169
+ };
170
+ ```
171
+
172
+ ```ts
173
+ // index.ts
174
+ cli.addCommand({
175
+ name: "build",
176
+ description: "Build the project",
177
+ options: [{ name: "output", alias: "o", type: String, description: "Output directory" }],
178
+ argument: { name: "target", type: String },
179
+ loader: () => import("./commands/build"),
180
+ });
181
+ ```
182
+
183
+ `loader` is a zero-argument function that returns a promise resolving to a module — typically `() => import("./path")`. The handler module's **default export** is the toolbox-receiving function. Help, completion, and option validation work entirely from the metadata you declared on `addCommand` and never trigger the loader. The first invocation of the command imports the module; subsequent calls reuse the cached handler.
184
+
185
+ A command may declare either `execute` or `loader`, but not both. If a loader rejects or returns a module without a default-exported function, a `CommandLoaderError` is thrown.
186
+
161
187
  ## Toolbox API
162
188
 
163
189
  When your command's `execute` function is called, it receives a toolbox object with various utilities and context. Here's what you can access:
@@ -1,6 +1,7 @@
1
- import type { Command as ICommand } from "../types/command.d.ts";
1
+ import { C as Command } from "../packem_shared/plugin-manager.d-Dz-wu1tI.js";
2
+ import '@visulima/tabular';
2
3
  /**
3
- * Generates shell completion scripts for the CLI application.
4
- */
5
- declare const completionCommand: ICommand;
6
- export default completionCommand;
4
+ * Generates shell completion scripts for the CLI application.
5
+ */
6
+ declare const completionCommand: Command;
7
+ export { completionCommand as default };
@@ -1,5 +1,5 @@
1
1
  var g=Object.defineProperty;var a=(e,t)=>g(e,"name",{value:t,configurable:!0});import S from"@bomb.sh/tab";import{c as $}from"../packem_shared/cerebro-error-BnJTixb2.js";var w=Object.defineProperty,y=a((e,t)=>w(e,"name",{value:t,configurable:!0}),"n");class p extends ${static{a(this,"l")}static{y(this,"CompletionError")}troubleshooting;constructor(t,o,n=[]){super(t,o,{troubleshooting:n}),this.name="CompletionError",this.troubleshooting=n,n.length>0&&(this.hint=n.join(`
2
- `))}}var C=Object.defineProperty,s=a((e,t)=>C(e,"name",{value:t,configurable:!0}),"s");const h=["bash","zsh","fish","powershell"],d=["node","bun","deno"],v=s(e=>"Deno"in e,"hasDeno"),L=s(e=>"Bun"in e,"hasBun"),u=s(()=>v(globalThis)?"deno":L(globalThis)?"bun":"node","detectRuntime"),m=s(e=>{const t=e?.starshipShell??e?.shell;if(t){const r=t.toLowerCase();if(r.includes("zsh"))return"zsh";if(r.includes("bash"))return"bash";if(r.includes("fish"))return"fish"}const o=e?.psModulePath,n=e?.prompt;if(o||n?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},"detectShell"),f=S,I=s((e,t)=>{for(const o of t)o.hidden||(o.name&&e.option(o.name,o.description||""),o.alias&&e.option(o.alias,o.description||""))},"registerCommandOptions"),P=s((e,t)=>{for(const[o,n]of t){if(n.name!==o||n.hidden)continue;const r=e.command(n.name,n.description||"");n.options&&I(r,n.options)}},"registerCommands"),E=s(e=>{if(!h.includes(e))throw new p(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${h.join(", ")}`,"Shell will be auto-detected if not specified"])},"validateShell"),j=s(e=>{if(e&&!d.includes(e))throw new p(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${d.join(", ")}`,"Runtime will be auto-detected if not specified"])},"validateRuntime"),z=s((e,t)=>{e.error("Could not detect current shell");const o=[`Usage: ${t} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun|deno>]`,"","Examples:"," # Install completions for zsh:",` ${t} completion --shell=zsh > ~/.${t}-completion.zsh`,` echo 'source ~/.${t}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${t} completion --shell=bash --runtime=bun > ~/.${t}-completion.bash`,` echo 'source ~/.${t}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${t} completion --shell=fish > ~/.config/fish/completions/${t}.fish`].join(`
3
- `);e.info(o)},"printUsageInstructions"),x={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:s(async({env:e,logger:t,options:o,runtime:n})=>{const r=n.getCliName(),c=o?.shell||m(e);if(!c){z(t,r);return}try{E(c),j(o?.runtime),P(f,n.getCommands());const i=`${o?.runtime||u()} ${r}`;f.setup(r,i,c)}catch(i){if(i instanceof p){const l=[`Failed to generate completion script: ${i.message}`,`Error code: ${i.code}`];throw i.troubleshooting.length>0&&l.push("","Troubleshooting:",...i.troubleshooting.map(b=>` • ${b}`)),t.error(l.join(`
2
+ `))}}var C=Object.defineProperty,s=a((e,t)=>C(e,"name",{value:t,configurable:!0}),"s");const h=["bash","zsh","fish","powershell"],d=["node","bun","deno"],v=s(e=>"Deno"in e,"hasDeno"),L=s(e=>"Bun"in e,"hasBun"),u=s(()=>v(globalThis)?"deno":L(globalThis)?"bun":"node","detectRuntime"),m=s(e=>{const t=e?.starshipShell??e?.shell;if(t){const r=t.toLowerCase();if(r.includes("zsh"))return"zsh";if(r.includes("bash"))return"bash";if(r.includes("fish"))return"fish"}const o=e?.psModulePath,n=e?.prompt;if(o||n?.includes("PS"))return"powershell";if(e?.comSpec?.toLowerCase().includes("cmd.exe"))return"bash"},"detectShell"),f=S,I=s((e,t)=>{for(const o of t)o.hidden||(o.name&&e.option(o.name,o.description??""),o.alias&&e.option(o.alias,o.description??""))},"registerCommandOptions"),P=s((e,t)=>{for(const[o,n]of t){if(n.name!==o||n.hidden)continue;const r=e.command(n.name,n.description??"");n.options&&I(r,n.options)}},"registerCommands"),E=s(e=>{if(!h.includes(e))throw new p(`Invalid shell type: ${e}`,"INVALID_SHELL",[`Valid shells are: ${h.join(", ")}`,"Shell will be auto-detected if not specified"])},"validateShell"),j=s(e=>{if(e&&!d.includes(e))throw new p(`Invalid runtime: ${e}`,"INVALID_RUNTIME",[`Valid runtimes are: ${d.join(", ")}`,"Runtime will be auto-detected if not specified"])},"validateRuntime"),z=s((e,t)=>{e.error("Could not detect current shell");const o=[`Usage: ${t} completion --shell=<bash|zsh|fish|powershell> [--runtime=<node|bun|deno>]`,"","Examples:"," # Install completions for zsh:",` ${t} completion --shell=zsh > ~/.${t}-completion.zsh`,` echo 'source ~/.${t}-completion.zsh' >> ~/.zshrc`,""," # Install completions for bash with custom runtime:",` ${t} completion --shell=bash --runtime=bun > ~/.${t}-completion.bash`,` echo 'source ~/.${t}-completion.bash' >> ~/.bashrc`,""," # Install completions for fish:",` ${t} completion --shell=fish > ~/.config/fish/completions/${t}.fish`].join(`
3
+ `);e.info(o)},"printUsageInstructions"),x={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:s(async({env:e,logger:t,options:o,runtime:n})=>{const r=n.getCliName(),c=o.shell??m(e);if(!c){z(t,r);return}try{E(c),j(o.runtime),P(f,n.getCommands());const i=`${o.runtime??u()} ${r}`;f.setup(r,i,c)}catch(i){if(i instanceof p){const l=[`Failed to generate completion script: ${i.message}`,`Error code: ${i.code}`];throw i.troubleshooting.length>0&&l.push("","Troubleshooting:",...i.troubleshooting.map(b=>` • ${b}`)),t.error(l.join(`
4
4
  `)),i}else{const l=["Failed to generate completion script",`Error: ${i instanceof Error?i.message:String(i)}`,"","Troubleshooting:"," • Ensure @bomb.sh/tab is installed: pnpm add @bomb.sh/tab",` • Verify shell is supported: ${h.join(", ")}`,` • Verify runtime is supported: ${d.join(", ")}`," • Check that your CLI name is correct"];t.error(l.join(`
5
5
  `))}}},"execute"),name:"completion",options:[{defaultOption:!0,defaultValue:m(),description:"Shell type (bash, zsh, fish, powershell). Defaults to current shell if detected.",name:"shell",type:String,typeLabel:"{underline shell}"},{defaultOption:!0,defaultValue:u(),description:"JavaScript runtime (node, bun, deno). Defaults to current runtime if detected.",name:"runtime",type:String,typeLabel:"{underline runtime}"}]};export{x as default};
@@ -1,10 +1,10 @@
1
- import type { Command as ICommand, OptionDefinition } from "../types/command.d.ts";
2
- import type { Toolbox as IToolbox } from "../types/toolbox.d.ts";
3
- declare class HelpCommand<TLogger extends Console = Console> implements ICommand<OptionDefinition<string>, TLogger> {
4
- name: string;
5
- options: OptionDefinition<string>[];
6
- private readonly commands;
7
- constructor(commands: Map<string, ICommand<OptionDefinition<unknown>, TLogger>>);
8
- execute(toolbox: IToolbox<TLogger>): void;
1
+ import { O as OptionDefinition, C as Command, T as Toolbox } from "../packem_shared/plugin-manager.d-Dz-wu1tI.js";
2
+ import '@visulima/tabular';
3
+ declare class HelpCommand<TLogger extends Console = Console> implements Command<OptionDefinition<string>, TLogger> {
4
+ name: string;
5
+ options: OptionDefinition<string>[];
6
+ private readonly commands;
7
+ constructor(commands: Map<string, Command<OptionDefinition<unknown>, TLogger>>);
8
+ execute(toolbox: Toolbox<TLogger>): void;
9
9
  }
10
- export default HelpCommand;
10
+ export { HelpCommand as default };
@@ -1 +1 @@
1
- import"@visulima/colorize";import{D as p}from"../packem_shared/help-command-CIRIXN03.js";import"../packem_shared/index-DQ3pvLQH.js";export{p as default};
1
+ var O=Object.defineProperty;var f=(r,a)=>O(r,"name",{value:a,configurable:!0});import{green as c,inverse as p,cyan as u,yellow as g}from"@visulima/colorize";import{f as y,p as b}from"../packem_shared/index-B0BiusY7.js";const E=[{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}];var N=Object.defineProperty,h=f((r,a)=>N(r,"name",{value:a,configurable:!0}),"h");const $="__Other",v=h(r=>r.charAt(0).toUpperCase()+r.slice(1),"upperFirstChar"),w=h((r,a,l,o)=>{r.debug("no command given, printing general help...");let e=[...new Set(l.values())].filter(t=>!t.hidden);o&&(e=e.filter(t=>t.group===o));const i=e.reduce((t,s)=>{const n=s.group??$;return t[n]??=[],t[n].push(s),t},{}),d=h(t=>t.map(s=>{let n="";typeof s.alias=="string"?n=s.alias:Array.isArray(s.alias)&&(n=s.alias.join(", ")),n!==""&&(n=` [${n}]`);let m=s.name;return s.commandPath&&s.commandPath.length>0&&(m=`${s.commandPath.join(" ")} ${s.name}`),[`${c(m)}${n}`,s.description??""]}),"buildCommandList");(r.raw??r.log)(b([{content:`${u(a.getCliName())} ${c("<command>")} [positional arguments] ${g("[options]")}`,header:p.cyan(" Usage ")},...Object.keys(i).map(t=>{const s=o?` ${v(o)}`:"";return{content:d(i[t]),header:t===$||o?p.green(` Available${s} Commands `):` ${p.green(` ${v(t)} `)}`}}),l.has("help")?{header:p.yellow(" Command Options "),optionList:l.get("help").options?.filter(t=>!t.hidden)}:void 0,{header:p.yellow(" Global Options "),optionList:a.getGlobalOptions()},{content:E.filter(t=>!t.hidden).map(t=>[t.name,t.description??""]),header:p.magenta(" Environment Variables ")},{content:`Run "${u(a.getCliName())} ${c("help <command>")}" or "${u(a.getCliName())} ${c("<command>")} ${g("--help")}" for help with a specific command.`,raw:!0}].filter(Boolean)))},"printGeneralHelp"),C=h((r,a)=>{const l=[];for(const o of r.values()){if(o.hidden)continue;const e=o.commandPath??[];if(e.length!==a.length)continue;let i=!0;for(const[d,t]of a.entries())if(e[d]!==t){i=!1;break}i&&l.push(o)}return l},"findChildren"),P=h((r,a,l,o)=>{const e=l.join(" "),i=[{content:`${u(a.getCliName())} ${c(e)} ${c("<subcommand>")} [positional arguments] ${g("[options]")}`,header:p.cyan(" Usage ")},{content:o.map(d=>{const t=[...d.commandPath??[],d.name].join(" ");return[c(t),d.description??""]}),header:p.green(" Subcommands ")},{header:p.yellow(" Global Options "),optionList:a.getGlobalOptions()},{content:`Run "${u(a.getCliName())} ${c(`${e} <subcommand>`)} ${g("--help")}" for help with a specific subcommand.`,raw:!0}];(r.raw??r.log)(b(i))},"printParentHelp"),A=h((r,a,l,o)=>{let e=l.get(o);if(!e)for(const n of l.values()){const m=n.commandPath?[...n.commandPath,n.name]:[n.name];if(m.at(-1)===o||m.join(" ")===o){e=n;break}}if(!e){const n=o.split(" ").filter(Boolean),m=n.length>0?C(l,n):[];if(m.length>0){P(r,a,n,m);return}r.error(`Command "${o}" not found`);return}const i=[],d=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(i.push({content:`${u(a.getCliName())} ${c(d)}${e.argument?" [positional arguments]":""}${e.options?" [options]":""}`,header:p.cyan(" Usage ")}),e.description&&i.push({content:e.description,header:p.green(" Description ")}),e.argument&&i.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&i.push({header:p.yellow(" Command Options "),optionList:e.options.filter(n=>!n.hidden)}),i.push({header:p.yellow(" Global Options "),optionList:a.getGlobalOptions()}),Array.isArray(e.env)&&e.env.length>0){const n=e.env.filter(m=>!m.hidden);n.length>0&&i.push({content:n.map(m=>[m.name,m.description??""]),header:p.magenta(" Environment Variables ")})}if(e.alias!==void 0&&e.alias.length>0){let n=e.alias;typeof e.alias=="string"&&(n=[e.alias]),i.splice(1,0,{content:n,header:"Alias(es)"})}Array.isArray(e.examples)&&e.examples.length>0&&i.push({content:e.examples,header:"Examples"});const t=[...e.commandPath??[],e.name],s=C(l,t);s.length>0&&i.push({content:s.map(n=>{const m=[...n.commandPath??[],n.name].join(" ");return[c(m),n.description??""]}),header:p.green(" Subcommands ")}),(r.raw??r.log)(b(i))},"printCommandHelp");class S{static{f(this,"x")}static{h(this,"HelpCommand")}name="help";options=[{description:"Display only the specified group",name:"group",type:String}];commands;constructor(a){this.commands=a}execute(a){const{commandName:l,logger:o,options:e,runtime:i}=a,{footer:d,header:t}=i.getCommandSection();t&&(o.raw??o.log)(y(t)),l==="help"?w(o,i,this.commands,typeof e?.group=="string"?e.group:void 0):A(o,i,this.commands,l),d&&(o.raw??o.log)(y(d))}}export{S as default};
@@ -1,6 +1,7 @@
1
- import type { Command as ICommand } from "../types/command.d.ts";
1
+ import { C as Command } from "../packem_shared/plugin-manager.d-Dz-wu1tI.js";
2
+ import '@visulima/tabular';
2
3
  /**
3
- * Generates README documentation for cerebro CLI commands.
4
- */
5
- declare const readmeCommand: ICommand;
6
- export default readmeCommand;
4
+ * Generates README documentation for cerebro CLI commands.
5
+ */
6
+ declare const readmeCommand: Command;
7
+ export { readmeCommand as default };
@@ -1,36 +1,36 @@
1
- var O=Object.defineProperty;var f=(e,n)=>O(e,"name",{value:n,configurable:!0});import{createRequire as L}from"node:module";import G from"github-slugger";import{p as U}from"../packem_shared/index-DQ3pvLQH.js";import{g as F,a as M,b as W,c as z}from"../packem_shared/runtime-process-G-n-wOub.js";const N=L(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,w=f(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[n,t]=g.versions.node.split(".").map(Number);if(n>22||n===22&&t>=3||n===20&&t>=16)return g.getBuiltinModule(e)}return N(e)},"__cjs_getBuiltinModule"),{existsSync:E}=w("node:fs"),{readFile:T,mkdir:k,writeFile:B}=w("node:fs/promises"),{resolve:v,join:V,dirname:q}=w("node:path");var H=Object.defineProperty,d=f((e,n)=>H(e,"name",{value:n,configurable:!0}),"d");const I=new G,b=I.slug,J=d(e=>e.filter(Boolean),"compact"),K=d((e,n)=>{const t=new Set,a=[];for(const r of e){const i=n(r);t.has(i)||(t.add(i),a.push(r))}return a},"uniqBy"),D=d((e,n)=>{const t=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const a=e.argument.name?.toUpperCase()??"ARG",r=e.argument.required?a:`[${a}]`;return`${n} ${t} ${r}`}return`${n} ${t}`},"formatCommandUsage"),Q=d((e,n)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const t=e.env.filter(a=>!a.hidden);t.length>0&&n.push({content:t.map(a=>[a.name,a.description??""]),header:" Environment Variables "})},"addEnvironmentVariables"),X=d((e,n)=>{const t=[],a=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.argument,i=!!e.options;if(t.push({content:`${n} ${a}${r?" [positional arguments]":""}${i?" [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(o=>typeof o=="object"&&o!==null&&(!("hidden"in o)||!o.hidden))}),Q(e,t),e.alias!==void 0&&e.alias.length>0){const o=Array.isArray(e.alias)?e.alias:[e.alias];t.splice(1,0,{content:o,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&t.push({content:e.examples,header:"Examples"}),U(t)},"formatCommandHelp"),Y=d((e,n)=>{const t=e.description?.trim().split(`
2
- `)[0]??"",a=D(e,n),r=X(e,n);return J([`## \`${a}\``,t,`\`\`\`
1
+ var O=Object.defineProperty;var f=(e,t)=>O(e,"name",{value:t,configurable:!0});import{createRequire as L}from"node:module";import U from"github-slugger";import{p as G}from"../packem_shared/index-B0BiusY7.js";import{g as F,a as M,b as W,c as z}from"../packem_shared/runtime-process-DKHFvYkv.js";const N=L(import.meta.url),g=typeof globalThis<"u"&&typeof globalThis.process<"u"?globalThis.process:process,A=f(e=>{if(typeof g<"u"&&g.versions&&g.versions.node){const[t,n]=g.versions.node.split(".").map(Number);if(t>22||t===22&&n>=3||t===20&&n>=16)return g.getBuiltinModule(e)}return N(e)},"__cjs_getBuiltinModule"),{existsSync:v}=A("node:fs"),{readFile:T,mkdir:k,writeFile:B}=A("node:fs/promises"),{resolve:P,join:V,dirname:q}=A("node:path");var H=Object.defineProperty,c=f((e,t)=>H(e,"name",{value:t,configurable:!0}),"m");const I=new U,C=c(e=>I.slug(e),"slugify"),J=c(e=>e.filter(Boolean),"compact"),K=c((e,t)=>{const n=new Set,o=[];for(const r of e){const i=t(r);n.has(i)||(n.add(i),o.push(r))}return o},"uniqBy"),D=c((e,t)=>{const n=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" ");if(e.argument){const o=e.argument.name.toUpperCase(),r=e.argument.required?o:`[${o}]`;return`${t} ${n} ${r}`}return`${t} ${n}`},"formatCommandUsage"),Q=c((e,t)=>{if(!Array.isArray(e.env)||e.env.length===0)return;const n=e.env.filter(o=>!o.hidden);n.length>0&&t.push({content:n.map(o=>[o.name,o.description??""]),header:" Environment Variables "})},"addEnvironmentVariables"),X=c((e,t)=>{const n=[],o=(e.commandPath?[...e.commandPath,e.name]:[e.name]).join(" "),r=!!e.argument,i=!!e.options;if(n.push({content:`${t} ${o}${r?" [positional arguments]":""}${i?" [options]":""}`,header:" Usage "}),e.description&&n.push({content:e.description,header:" Description "}),e.argument&&n.push({header:"Command Positional Arguments",isArgument:!0,optionList:[e.argument]}),Array.isArray(e.options)&&e.options.length>0&&n.push({header:" Command Options ",optionList:e.options.filter(a=>!a.hidden)}),Q(e,n),e.alias!==void 0&&e.alias.length>0){const a=Array.isArray(e.alias)?e.alias:[e.alias];n.splice(1,0,{content:a,header:"Alias(es)"})}return Array.isArray(e.examples)&&e.examples.length>0&&n.push({content:e.examples,header:"Examples"}),G(n)},"formatCommandHelp"),Y=c((e,t)=>{const n=e.description?.trim().split(`
2
+ `)[0]??"",o=D(e,t),r=X(e,t);return J([`## \`${o}\``,n,`\`\`\`
3
3
  ${r.trim()}
4
4
  \`\`\``]).join(`
5
5
 
6
- `)},"renderCommand"),Z=d((e,n,t,a)=>{const r=`(${["--version","-V"].join("|")})`,i=W(),o=z();return`\`\`\`sh-session
7
- $ npm install -g ${n}
6
+ `)},"renderCommand"),Z=c((e,t,n,o)=>{const r=`(${["--version","-V"].join("|")})`,i=W(),a=z();return`\`\`\`sh-session
7
+ $ npm install -g ${t}
8
8
  $ ${e} COMMAND
9
9
  running command...
10
10
  $ ${e} ${r}
11
- ${n}/${t??"unknown"} ${i}-${o} node-v${a}
11
+ ${t}/${n??"unknown"} ${i}-${a} node-v${o}
12
12
  $ ${e} --help [COMMAND]
13
13
  USAGE
14
14
  $ ${e} COMMAND
15
15
  ...
16
16
  \`\`\`
17
- `},"generateUsage"),R=d(async(e,n,t)=>{const a=await Promise.all(e.map(async i=>{const o=D(i,n);return`* [\`${o}\`](#${await b(o)})`})),r=e.map(i=>Y(i,n)).map(i=>`${i.trim()}
18
- `);return[...a,"",...r].join(`
19
- `).trim()},"generateCommands"),j=d(async(e,n)=>{const t=q(e);E(t)||await k(t,{recursive:!0}),await B(e,n,"utf8")},"writeFileWithDirectory"),ee=d(async(e,n,t,a)=>{const r=new Map;for(const o of e){const s=o.group??"__Other",l=r.get(s)??[];l.push(o),r.set(s,l)}const i=[...r.entries()].map(([o,s])=>o==="__Other"?["Other",s]:[o,s]);return await Promise.all(i.map(async([o,s])=>{const l=o.replaceAll(":","/"),$=V(".",n,`${l}.md`),p=`\`${t} ${o}\``,c=`${[p,"=".repeat(p.length),"",`Commands in the ${o} group.`,"",await R(s,t,a)].join(`
17
+ `},"generateUsage"),b=c((e,t,n)=>{const o=e.map(i=>{const a=D(i,t);return`* [\`${a}\`](#${C(a)})`}),r=e.map(i=>Y(i,t)).map(i=>`${i.trim()}
18
+ `);return[...o,"",...r].join(`
19
+ `).trim()},"generateCommands"),R=c(async(e,t)=>{const n=q(e);v(n)||await k(n,{recursive:!0}),await B(e,t,"utf8")},"writeFileWithDirectory"),ee=c(async(e,t,n,o)=>{const r=new Map;for(const a of e){const s=a.group??"__Other",l=r.get(s)??[];l.push(a),r.set(s,l)}const i=Array.from(r.entries(),([a,s])=>a==="__Other"?["Other",s]:[a,s]);return await Promise.all(i.map(async([a,s])=>{const l=a.replaceAll(":","/"),$=V(".",t,`${l}.md`),d=`\`${n} ${a}\``,p=`${[d,"=".repeat(d.length),"",`Commands in the ${a} group.`,"",b(s,n,o)].join(`
20
20
  `).trim()}
21
- `;a.dryRun||await j(v(M(),$),c)})),`${[`# Command Topics
22
- `,...i.map(([o])=>{const s=o.replaceAll(":","/");return`* [\`${t} ${o}\`](${n}/${s}.md)`})].join(`
21
+ `;o.dryRun||await R(P(M(),$),p)})),`${[`# Command Topics
22
+ `,...i.map(([a])=>{const s=a.replaceAll(":","/");return`* [\`${n} ${a}\`](${t}/${s}.md)`})].join(`
23
23
  `).trim()}
24
- `},"generateMultiCommands"),A=d(e=>e.replaceAll(`\r
24
+ `},"generateMultiCommands"),w=c(e=>e.replaceAll(`\r
25
25
  `,`
26
26
  `).replaceAll("\r",`
27
- `),"normalizeLineEndings"),te=d(async e=>{const n=A(e);return(await Promise.all(n.split(`
28
- `).filter(t=>t.startsWith("# ")).map(t=>t.trim().slice(2)).map(async t=>`* [${t}](#${await b(t)})`))).join(`
29
- `)},"generateTableOfContents"),P=d(e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeRegex"),y=d((e,n,t)=>{const a=A(e),r=`<!-- ${n} -->`,i=`<!-- ${n}stop -->`;if(a.includes(r)&&a.includes(i)){const o=P(r),s=P(i),l=new RegExp(String.raw`${o}(.|\n)*${s}`,"m");return a.replace(l,`${r}
30
- ${t}
31
- ${i}`)}return a.replace(r,`${r}
32
- ${t}
33
- ${i}`)},"replaceTag"),se={description:"Generate README documentation for CLI commands",execute:d(async({logger:e,options:n,runtime:t})=>{const a=t.getCliName(),r=t.getPackageName()??a,i=t.getPackageVersion(),o=F().node??"unknown",s={aliases:n?.aliases,dryRun:n?.dryRun,multi:n?.multi,nestedTopicsDepth:n?.nestedTopicsDepth,outputDir:n?.outputDir??"docs",readmePath:n?.readmePath??"README.md",repositoryPrefix:n?.repositoryPrefix,version:n?.version??i??void 0},l=t.getCommands(),$=[...l.values()].filter(m=>!m.hidden).filter(m=>s.aliases?!0:m.name===l.get(m.name)?.name).toSorted((m,h)=>{const _=m.commandPath?[...m.commandPath,m.name].join(" "):m.name,S=h.commandPath?[...h.commandPath,h.name].join(" "):h.name;return _.localeCompare(S)}),p=K($,m=>m.commandPath?[...m.commandPath,m.name].join(" "):m.name);e.debug(`Processing ${p.length} commands for README generation`);let c;const u=v(M(),s.readmePath??"README.md");if(E(u)){const m=await T(u,"utf8");c=A(m)}else e.warn(`README file not found at ${u}, creating template`),c=`# ${r}
27
+ `),"normalizeLineEndings"),te=c(e=>w(e).split(`
28
+ `).filter(t=>t.startsWith("# ")).map(t=>t.trim().slice(2)).map(t=>`* [${t}](#${C(t)})`).join(`
29
+ `),"generateTableOfContents"),E=c(e=>e.replaceAll(/[.*+?^${}()|[\]\\]/g,String.raw`\$&`),"escapeRegex"),y=c((e,t,n)=>{const o=w(e),r=`<!-- ${t} -->`,i=`<!-- ${t}stop -->`;if(o.includes(r)&&o.includes(i)){const a=E(r),s=E(i),l=new RegExp(String.raw`${a}(.|\n)*${s}`,"m");return o.replace(l,`${r}
30
+ ${n}
31
+ ${i}`)}return o.replace(r,`${r}
32
+ ${n}
33
+ ${i}`)},"replaceTag"),se={description:"Generate README documentation for CLI commands",execute:c(async({logger:e,options:t,runtime:n})=>{const o=n.getCliName(),r=n.getPackageName()??o,i=n.getPackageVersion(),a=F().node??"unknown",s={aliases:t.aliases,dryRun:t.dryRun,multi:t.multi,nestedTopicsDepth:t.nestedTopicsDepth,outputDir:t.outputDir??"docs",readmePath:t.readmePath??"README.md",repositoryPrefix:t.repositoryPrefix,version:t.version??i??void 0},l=n.getCommands(),$=[...l.values()].filter(m=>!m.hidden).filter(m=>s.aliases?!0:m.name===l.get(m.name)?.name).toSorted((m,h)=>{const _=m.commandPath?[...m.commandPath,m.name].join(" "):m.name,S=h.commandPath?[...h.commandPath,h.name].join(" "):h.name;return _.localeCompare(S)}),d=K($,m=>m.commandPath?[...m.commandPath,m.name].join(" "):m.name);e.debug(`Processing ${String(d.length)} commands for README generation`);let p;const u=P(M(),s.readmePath??"README.md");if(v(u)){const m=await T(u,"utf8");p=w(m)}else e.warn(`README file not found at ${u}, creating template`),p=`# ${r}
34
34
 
35
35
  <!-- usage -->
36
36
  <!-- usagestop -->
@@ -40,6 +40,6 @@ ${i}`)},"replaceTag"),se={description:"Generate README documentation for CLI com
40
40
 
41
41
  <!-- toc -->
42
42
  <!-- tocstop -->
43
- `;const C=s.outputDir??"docs",x=s.version??i??"unknown";c=y(c,"usage",Z(a,r,x,o)),c=y(c,"commands",s.multi?await ee(p,C,a,s):await R(p,a,s)),c=y(c,"toc",await te(c)),c=`${c.trimEnd()}
43
+ `;const j=s.outputDir??"docs",x=s.version??i??"unknown";p=y(p,"usage",Z(o,r,x,a)),p=y(p,"commands",s.multi?await ee(d,j,o,s):b(d,o,s)),p=y(p,"toc",te(p)),p=`${p.trimEnd()}
44
44
  `,s.dryRun?(e.info("Dry run mode - README not written"),e.info(`Generated README content:
45
- ${c}`)):(await j(u,c),e.info(`README generated successfully at ${u}`))},"execute"),name:"readme",options:[{description:"Include aliases in command list",name:"aliases",type:Boolean},{description:"Show what would be generated without writing files",name:"dry-run",type:Boolean},{description:"Generate multi-file documentation by command groups",name:"multi",type:Boolean},{description:"Maximum depth for nested topics when using multi-file mode",name:"nested-topics-depth",type:Number},{description:"Output directory for multi-file documentation",name:"output-dir",type:String,typeLabel:"{underline directory}"},{description:"Path to README file to generate",name:"readme-path",type:String,typeLabel:"{underline path}"},{description:"Repository prefix for code links",name:"repository-prefix",type:String,typeLabel:"{underline prefix}"},{description:"Version to use in generated documentation",name:"version",type:String,typeLabel:"{underline version}"}]};export{se as default};
45
+ ${p}`)):(await R(u,p),e.info(`README generated successfully at ${u}`))},"execute"),name:"readme",options:[{description:"Include aliases in command list",name:"aliases",type:Boolean},{description:"Show what would be generated without writing files",name:"dry-run",type:Boolean},{description:"Generate multi-file documentation by command groups",name:"multi",type:Boolean},{description:"Maximum depth for nested topics when using multi-file mode",name:"nested-topics-depth",type:Number},{description:"Output directory for multi-file documentation",name:"output-dir",type:String,typeLabel:"{underline directory}"},{description:"Path to README file to generate",name:"readme-path",type:String,typeLabel:"{underline path}"},{description:"Repository prefix for code links",name:"repository-prefix",type:String,typeLabel:"{underline prefix}"},{description:"Version to use in generated documentation",name:"version",type:String,typeLabel:"{underline version}"}]};export{se as default};
@@ -1,3 +1,4 @@
1
- import type { Command as ICommand } from "../types/command.d.ts";
2
- declare const _default: ICommand;
3
- export default _default;
1
+ import { C as Command } from "../packem_shared/plugin-manager.d-Dz-wu1tI.js";
2
+ import '@visulima/tabular';
3
+ declare const _default: Command;
4
+ export { _default as default };