padrone 1.6.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # padrone
2
2
 
3
+ ## 1.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`3eecb40`](https://github.com/KurtGokhan/padrone/commit/3eecb40ad4f678bf745b70fb1f791ceff4dfb541) Thanks [@KurtGokhan](https://github.com/KurtGokhan)! - Add format-aware output primitives (table, tree, list, key-value) to auto-output. Actions can use `ctx.context.output.table()`, `.tree()`, `.list()`, `.kv()` for styled output that adapts to the runtime format (ANSI, text, JSON, markdown, HTML). Declarative formatting via `padroneAutoOutput({ output: 'table' })` per-command. Extract shared Styler/Layout infrastructure from help formatter into reusable `styling.ts` module.
8
+
9
+ - [`0a27a69`](https://github.com/KurtGokhan/padrone/commit/0a27a6960622be5f053a9a49731de8d6adf65646) Thanks [@KurtGokhan](https://github.com/KurtGokhan)! - Add printf-style format specifiers (`%s`, `%d`, `%i`, `%f`, `%j`, `%o`, `%O`, `%%`) to the logger extension, following WHATWG Console Standard conventions.
10
+
3
11
  ## 1.6.0
4
12
 
5
13
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  import { s as getCommand } from "../commands-B_gufyR9.mjs";
2
- import { n as getHelpInfo } from "../help-B5Kk83of.mjs";
2
+ import { n as getHelpInfo } from "../help-BtxLgrF_.mjs";
3
3
  import { existsSync, mkdirSync, writeFileSync } from "node:fs";
4
4
  import { dirname, join, resolve } from "node:path";
5
5
  //#region src/docs/index.ts
@@ -134,4 +134,4 @@ function signalExitCode(signal) {
134
134
  //#endregion
135
135
  export { SignalError as a, RoutingError as i, ConfigError as n, ValidationError as o, PadroneError as r, signalExitCode as s, ActionError as t };
136
136
 
137
- //# sourceMappingURL=errors-CL63UOzt.mjs.map
137
+ //# sourceMappingURL=errors-DA4KzK1M.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"errors-CL63UOzt.mjs","names":[],"sources":["../src/core/errors.ts"],"sourcesContent":["/**\n * Structured error hierarchy for Padrone CLI framework.\n *\n * All Padrone errors extend `PadroneError`, which carries an exit code,\n * optional suggestions, and context about which command/phase produced the error.\n * This allows callers to distinguish user errors (bad input) from bugs (unexpected throws)\n * and to present formatted, actionable error messages.\n */\n\nimport type { PadroneSignal } from './runtime.ts';\n\nexport type PadroneErrorOptions = {\n /** Process exit code. Defaults to 1. */\n exitCode?: number;\n /** Actionable suggestions shown to the user (e.g. \"Use --env production\"). */\n suggestions?: string[];\n /** The command path that produced the error (e.g. \"deploy staging\"). */\n command?: string;\n /** The phase where the error occurred. */\n phase?: 'parse' | 'validate' | 'execute' | 'config';\n /** Original cause for error chaining. */\n cause?: unknown;\n};\n\n/**\n * Base error class for all Padrone errors.\n * Carries structured metadata for user-friendly formatting and programmatic handling.\n *\n * @example\n * ```ts\n * throw new PadroneError('Something went wrong', {\n * exitCode: 1,\n * suggestions: ['Try --help for usage information'],\n * });\n * ```\n */\nexport class PadroneError extends Error {\n readonly exitCode: number;\n readonly suggestions: string[];\n readonly command?: string;\n readonly phase?: 'parse' | 'validate' | 'execute' | 'config';\n\n constructor(message: string, options?: PadroneErrorOptions) {\n super(message, options?.cause ? { cause: options.cause } : undefined);\n this.name = 'PadroneError';\n this.exitCode = options?.exitCode ?? 1;\n this.suggestions = options?.suggestions ?? [];\n this.command = options?.command;\n this.phase = options?.phase;\n }\n\n /**\n * Returns a serializable representation of the error,\n * suitable for non-terminal runtimes (web UIs, APIs, etc.).\n */\n toJSON(): {\n name: string;\n message: string;\n exitCode: number;\n suggestions: string[];\n command?: string;\n phase?: string;\n } {\n return {\n name: this.name,\n message: this.message,\n exitCode: this.exitCode,\n suggestions: this.suggestions,\n command: this.command,\n phase: this.phase,\n };\n }\n}\n\n/**\n * Thrown when command routing fails — unknown command, unexpected arguments, etc.\n */\nexport class RoutingError extends PadroneError {\n constructor(message: string, options?: PadroneErrorOptions) {\n super(message, { phase: 'parse', ...options });\n this.name = 'RoutingError';\n }\n}\n\n/**\n * Thrown when argument or schema validation fails.\n * Carries the structured issues from the schema validator.\n */\nexport class ValidationError extends PadroneError {\n readonly issues: readonly { path?: PropertyKey[]; message: string }[];\n\n constructor(message: string, issues: readonly { path?: PropertyKey[]; message: string }[], options?: PadroneErrorOptions) {\n super(message, { phase: 'validate', ...options });\n this.name = 'ValidationError';\n this.issues = issues;\n }\n\n override toJSON() {\n return {\n ...super.toJSON(),\n issues: this.issues.map((i) => ({ path: i.path?.map(String), message: i.message })),\n };\n }\n}\n\n/**\n * Thrown when config file loading or validation fails.\n */\nexport class ConfigError extends PadroneError {\n constructor(message: string, options?: PadroneErrorOptions) {\n super(message, { phase: 'config', ...options });\n this.name = 'ConfigError';\n }\n}\n\n/**\n * Thrown from user action handlers to surface structured errors with exit codes and suggestions.\n * This is the primary error class users should throw from their command actions.\n *\n * @example\n * ```ts\n * throw new ActionError('Missing environment', {\n * exitCode: 1,\n * suggestions: ['Use --env production or --env staging'],\n * });\n * ```\n */\nexport class ActionError extends PadroneError {\n constructor(message: string, options?: PadroneErrorOptions) {\n super(message, { phase: 'execute', ...options });\n this.name = 'ActionError';\n }\n}\n\n/**\n * Thrown when command execution is interrupted by a process signal (SIGINT, SIGTERM, SIGHUP).\n * Carries the signal name and the conventional exit code (128 + signal number).\n */\nexport class SignalError extends PadroneError {\n readonly signal: PadroneSignal;\n\n constructor(signal: PadroneSignal, options?: { cause?: unknown }) {\n super(`Process interrupted by ${signal}`, { exitCode: signalExitCode(signal), cause: options?.cause });\n this.name = 'SignalError';\n this.signal = signal;\n }\n}\n\n/** Maps a signal name to its conventional exit code (128 + signal number). */\nexport function signalExitCode(signal: PadroneSignal): number {\n const codes: Record<string, number> = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };\n return codes[signal] ?? 1;\n}\n"],"mappings":";;;;;;;;;;;;;AAoCA,IAAa,eAAb,cAAkC,MAAM;CACtC;CACA;CACA;CACA;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AAU;GAAE,UAAU,eAAe,OAAO;GAAE,OAAO,SAAS;GAAO,CAAC;AACtG,OAAK,OAAO;AACZ,OAAK,SAAS;;;;AAKlB,SAAgB,eAAe,QAA+B;AAE5D,QADsC;EAAE,QAAQ;EAAK,SAAS;EAAK,QAAQ;EAAK,CACnE,WAAW"}
1
+ {"version":3,"file":"errors-DA4KzK1M.mjs","names":[],"sources":["../src/core/errors.ts"],"sourcesContent":["/**\n * Structured error hierarchy for Padrone CLI framework.\n *\n * All Padrone errors extend `PadroneError`, which carries an exit code,\n * optional suggestions, and context about which command/phase produced the error.\n * This allows callers to distinguish user errors (bad input) from bugs (unexpected throws)\n * and to present formatted, actionable error messages.\n */\n\nimport type { PadroneSignal } from './runtime.ts';\n\nexport type PadroneErrorOptions = {\n /** Process exit code. Defaults to 1. */\n exitCode?: number;\n /** Actionable suggestions shown to the user (e.g. \"Use --env production\"). */\n suggestions?: string[];\n /** The command path that produced the error (e.g. \"deploy staging\"). */\n command?: string;\n /** The phase where the error occurred. */\n phase?: 'parse' | 'validate' | 'execute' | 'config';\n /** Original cause for error chaining. */\n cause?: unknown;\n};\n\n/**\n * Base error class for all Padrone errors.\n * Carries structured metadata for user-friendly formatting and programmatic handling.\n *\n * @example\n * ```ts\n * throw new PadroneError('Something went wrong', {\n * exitCode: 1,\n * suggestions: ['Try --help for usage information'],\n * });\n * ```\n */\nexport class PadroneError extends Error {\n readonly exitCode: number;\n readonly suggestions: string[];\n readonly command?: string;\n readonly phase?: 'parse' | 'validate' | 'execute' | 'config';\n\n constructor(message: string, options?: PadroneErrorOptions) {\n super(message, options?.cause ? { cause: options.cause } : undefined);\n this.name = 'PadroneError';\n this.exitCode = options?.exitCode ?? 1;\n this.suggestions = options?.suggestions ?? [];\n this.command = options?.command;\n this.phase = options?.phase;\n }\n\n /**\n * Returns a serializable representation of the error,\n * suitable for non-terminal runtimes (web UIs, APIs, etc.).\n */\n toJSON(): {\n name: string;\n message: string;\n exitCode: number;\n suggestions: string[];\n command?: string;\n phase?: string;\n } {\n return {\n name: this.name,\n message: this.message,\n exitCode: this.exitCode,\n suggestions: this.suggestions,\n command: this.command,\n phase: this.phase,\n };\n }\n}\n\n/**\n * Thrown when command routing fails — unknown command, unexpected arguments, etc.\n */\nexport class RoutingError extends PadroneError {\n constructor(message: string, options?: PadroneErrorOptions) {\n super(message, { phase: 'parse', ...options });\n this.name = 'RoutingError';\n }\n}\n\n/**\n * Thrown when argument or schema validation fails.\n * Carries the structured issues from the schema validator.\n */\nexport class ValidationError extends PadroneError {\n readonly issues: readonly { path?: PropertyKey[]; message: string }[];\n\n constructor(message: string, issues: readonly { path?: PropertyKey[]; message: string }[], options?: PadroneErrorOptions) {\n super(message, { phase: 'validate', ...options });\n this.name = 'ValidationError';\n this.issues = issues;\n }\n\n override toJSON() {\n return {\n ...super.toJSON(),\n issues: this.issues.map((i) => ({ path: i.path?.map(String), message: i.message })),\n };\n }\n}\n\n/**\n * Thrown when config file loading or validation fails.\n */\nexport class ConfigError extends PadroneError {\n constructor(message: string, options?: PadroneErrorOptions) {\n super(message, { phase: 'config', ...options });\n this.name = 'ConfigError';\n }\n}\n\n/**\n * Thrown from user action handlers to surface structured errors with exit codes and suggestions.\n * This is the primary error class users should throw from their command actions.\n *\n * @example\n * ```ts\n * throw new ActionError('Missing environment', {\n * exitCode: 1,\n * suggestions: ['Use --env production or --env staging'],\n * });\n * ```\n */\nexport class ActionError extends PadroneError {\n constructor(message: string, options?: PadroneErrorOptions) {\n super(message, { phase: 'execute', ...options });\n this.name = 'ActionError';\n }\n}\n\n/**\n * Thrown when command execution is interrupted by a process signal (SIGINT, SIGTERM, SIGHUP).\n * Carries the signal name and the conventional exit code (128 + signal number).\n */\nexport class SignalError extends PadroneError {\n readonly signal: PadroneSignal;\n\n constructor(signal: PadroneSignal, options?: { cause?: unknown }) {\n super(`Process interrupted by ${signal}`, { exitCode: signalExitCode(signal), cause: options?.cause });\n this.name = 'SignalError';\n this.signal = signal;\n }\n}\n\n/** Maps a signal name to its conventional exit code (128 + signal number). */\nexport function signalExitCode(signal: PadroneSignal): number {\n const codes: Record<string, number> = { SIGINT: 130, SIGTERM: 143, SIGHUP: 129 };\n return codes[signal] ?? 1;\n}\n"],"mappings":";;;;;;;;;;;;;AAoCA,IAAa,eAAb,cAAkC,MAAM;CACtC;CACA;CACA;CACA;CAEA,YAAY,SAAiB,SAA+B;AAC1D,QAAM,SAAS,SAAS,QAAQ,EAAE,OAAO,QAAQ,OAAO,GAAG,KAAA,EAAU;AACrE,OAAK,OAAO;AACZ,OAAK,WAAW,SAAS,YAAY;AACrC,OAAK,cAAc,SAAS,eAAe,EAAE;AAC7C,OAAK,UAAU,SAAS;AACxB,OAAK,QAAQ,SAAS;;;;;;CAOxB,SAOE;AACA,SAAO;GACL,MAAM,KAAK;GACX,SAAS,KAAK;GACd,UAAU,KAAK;GACf,aAAa,KAAK;GAClB,SAAS,KAAK;GACd,OAAO,KAAK;GACb;;;;;;AAOL,IAAa,eAAb,cAAkC,aAAa;CAC7C,YAAY,SAAiB,SAA+B;AAC1D,QAAM,SAAS;GAAE,OAAO;GAAS,GAAG;GAAS,CAAC;AAC9C,OAAK,OAAO;;;;;;;AAQhB,IAAa,kBAAb,cAAqC,aAAa;CAChD;CAEA,YAAY,SAAiB,QAA8D,SAA+B;AACxH,QAAM,SAAS;GAAE,OAAO;GAAY,GAAG;GAAS,CAAC;AACjD,OAAK,OAAO;AACZ,OAAK,SAAS;;CAGhB,SAAkB;AAChB,SAAO;GACL,GAAG,MAAM,QAAQ;GACjB,QAAQ,KAAK,OAAO,KAAK,OAAO;IAAE,MAAM,EAAE,MAAM,IAAI,OAAO;IAAE,SAAS,EAAE;IAAS,EAAE;GACpF;;;;;;AAOL,IAAa,cAAb,cAAiC,aAAa;CAC5C,YAAY,SAAiB,SAA+B;AAC1D,QAAM,SAAS;GAAE,OAAO;GAAU,GAAG;GAAS,CAAC;AAC/C,OAAK,OAAO;;;;;;;;;;;;;;;AAgBhB,IAAa,cAAb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kBAAA;EACV,IAAA;EACA,KAAA;EACA,WAAA;EACA,OAAA;EACA,UAAA;EACA,MAAA;EACA,cAAA,YD0C8B;ECxC9B,KAAA;AAAA;;;;KAMU,eAAA;EACV,IAAA;EACA,WAAA;EACA,GAAA;IAAQ,IAAA;IAAc,WAAA;EAAA;AAAA;;AApExB;;;KA2EY,QAAA;EA3EU,4DA6EpB,IAAA,UApE4B;EAsE5B,KAAA,WAtE4B;EAwE5B,WAAA,WAtEA;EAwEA,OAAA,aAtEA;EAwEA,UAAA,qBAtEA;EAwEA,MAAA,YAxEI;EA0EJ,KAAA;IACE,OAAA;IACA,cAAA;IACA,cAAA;IACA,YAAA,WAtEF;IAwEE,UAAA;EAAA,GArEF;EAwEA,WAAA,GAAc,kBAAA,IArEd;EAuEA,WAAA,GAAc,kBAAA,IApEd;EAsEA,SAAA,GAAY,gBAAA,IApEZ;EAsEA,QAAA,GAAW,eAAA,IAlEX;EAoEA,QAAA,aAhEA;EAkEA,cAAA,GAAiB,QAAA;AAAA"}
1
+ {"version":3,"file":"formatter-DrvhDMrq.d.mts","names":[],"sources":["../src/output/colorizer.ts","../src/output/formatter.ts"],"mappings":";;AAqBA;;KAAY,SAAA;;;AAoBZ;;KAAY,WAAA;EACV,OAAA,GAAU,SAAA;EACV,GAAA,GAAM,SAAA;EACN,IAAA,GAAO,SAAA;EACP,WAAA,GAAc,SAAA;EACd,KAAA,GAAQ,SAAA;EACR,IAAA,GAAO,SAAA;EACP,OAAA,GAAU,SAAA;EACV,YAAA,GAAe,SAAA;EACf,UAAA,GAAa,SAAA;AAAA;;;;KAsEH,UAAA;AAAA,cAEC,WAAA,EAAa,MAAA,CAAO,UAAA,EAAY,QAAA,CAAS,WAAA;;;KCxG1C,UAAA;AAAA,KACA,UAAA;;;;KASA,kBAAA;EACV,IAAA;EACA,WAAA;EACA,QAAA;EACA,OAAA;EACA,IAAA;EACA,IAAA;AAAA;;;;KAMU,gBAAA;EACV,IAAA;EACA,WAAA;EACA,QAAA;EACA,OAAA;EACA,IAAA;EACA,IAAA,aDFA;ECIA,KAAA,aDHA;ECKA,OAAA;EACA,UAAA;EACA,MAAA;EACA,QAAA,cDNO;ECQP,GAAA,sBDPU;ECSV,QAAA,YDRe;ECUf,SAAA,YDTa;ECWb,SAAA,WDXsB;ECatB,KAAA;AAAA;;;;KAMU,kBAAA;EACV,IAAA;EACA,KAAA;EACA,WAAA;EACA,OAAA;EACA,UAAA;EACA,MAAA;EACA,cAAA,YD8C8B;EC5C9B,KAAA;AAAA;;;;KAMU,eAAA;EACV,IAAA;EACA,WAAA;EACA,GAAA;IAAQ,IAAA;IAAc,WAAA;EAAA;AAAA;;AApExB;;;KA2EY,QAAA;EA3EU,4DA6EpB,IAAA,UApE4B;EAsE5B,KAAA,WAtE4B;EAwE5B,WAAA,WAtEA;EAwEA,OAAA,aAtEA;EAwEA,UAAA,qBAtEA;EAwEA,MAAA,YAxEI;EA0EJ,KAAA;IACE,OAAA;IACA,cAAA;IACA,cAAA;IACA,YAAA,WAtEF;IAwEE,UAAA;EAAA,GArEF;EAwEA,WAAA,GAAc,kBAAA,IArEd;EAuEA,WAAA,GAAc,kBAAA,IApEd;EAsEA,SAAA,GAAY,gBAAA,IApEZ;EAsEA,QAAA,GAAW,eAAA,IAlEX;EAoEA,QAAA,aAhEA;EAkEA,cAAA,GAAiB,QAAA;AAAA"}
@@ -1,45 +1,5 @@
1
1
  import { o as findCommandByName } from "./commands-B_gufyR9.mjs";
2
2
  import { a as getJsonSchema, c as parsePositionalConfig, i as extractSchemaMetadata, u as camelToKebab } from "./args-Cnq0nwSM.mjs";
3
- //#region src/util/utils.ts
4
- function getRootCommand(cmd) {
5
- let current = cmd;
6
- while (current.parent) current = current.parent;
7
- return current;
8
- }
9
- async function readVersionFromPackageJson() {
10
- try {
11
- const fs = await import("node:fs");
12
- const path = await import("node:path");
13
- let dir = process.cwd();
14
- for (let i = 0; i < 10; i++) {
15
- const pkgPath = path.join(dir, "package.json");
16
- if (fs.existsSync(pkgPath)) {
17
- const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
18
- if (pkg.version) return pkg.version;
19
- }
20
- const parentDir = path.dirname(dir);
21
- if (parentDir === dir) break;
22
- dir = parentDir;
23
- }
24
- } catch {}
25
- return "0.0.0";
26
- }
27
- /**
28
- * Attempts to get the version from various sources:
29
- * 1. Explicit version set on the command
30
- * 2. npm_package_version environment variable (set by npm/yarn/pnpm when running scripts)
31
- * 3. package.json in current or parent directories
32
- *
33
- * Returns synchronously when an explicit version or env var is available.
34
- * Falls back to async package.json discovery otherwise.
35
- */
36
- function getVersion(explicitVersion) {
37
- if (explicitVersion) return explicitVersion;
38
- if (typeof process !== "undefined" && process.env?.npm_package_version) return process.env.npm_package_version;
39
- if (typeof process !== "undefined") return readVersionFromPackageJson();
40
- return "0.0.0";
41
- }
42
- //#endregion
43
3
  //#region src/output/colorizer.ts
44
4
  const ansiCodes = {
45
5
  reset: "\x1B[0m",
@@ -130,9 +90,6 @@ function createColorizer(config) {
130
90
  deprecated: makeStyleFn(resolved.deprecated)
131
91
  };
132
92
  }
133
- //#endregion
134
- //#region src/output/formatter.ts
135
- const DEFAULT_TERMINAL_WIDTH = 80;
136
93
  function wrapText(text, maxWidth) {
137
94
  if (maxWidth <= 0 || text.length <= maxWidth) return [text];
138
95
  const words = text.split(" ");
@@ -145,6 +102,9 @@ function wrapText(text, maxWidth) {
145
102
  if (current) lines.push(current);
146
103
  return lines.length > 0 ? lines : [text];
147
104
  }
105
+ function escapeHtml(text) {
106
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
107
+ }
148
108
  function createTextStyler() {
149
109
  return {
150
110
  command: (text) => text,
@@ -191,9 +151,6 @@ function createMarkdownStyler() {
191
151
  deprecated: (text) => `~~${text}~~`
192
152
  };
193
153
  }
194
- function escapeHtml(text) {
195
- return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;").replace(/'/g, "&#039;");
196
- }
197
154
  function createHtmlStyler() {
198
155
  return {
199
156
  command: (text) => `<strong style="color: #00bcd4;">${escapeHtml(text)}</strong>`,
@@ -234,6 +191,88 @@ function createHtmlLayout() {
234
191
  wrapDocument: (content) => `<div style="font-family: monospace; line-height: 1.6;">${content}</div>`
235
192
  };
236
193
  }
194
+ function shouldUseAnsi(env, isTTY) {
195
+ if (env?.NO_COLOR) return false;
196
+ if (env?.CI) return false;
197
+ if (typeof isTTY === "boolean") return isTTY;
198
+ return false;
199
+ }
200
+ /** Resolve the output format from the runtime and caller context. */
201
+ function resolveOutputFormat(runtime, caller) {
202
+ let format;
203
+ if (caller === "serve" || caller === "mcp" || caller === "tool") format = "json";
204
+ else if (runtime.format && runtime.format !== "auto" && runtime.format !== "console") format = runtime.format;
205
+ else format = shouldUseAnsi(runtime.env(), runtime.terminal?.isTTY) ? "ansi" : "text";
206
+ const terminalWidth = format === "markdown" || format === "html" ? void 0 : runtime.terminal?.columns ?? 80;
207
+ let styler;
208
+ let layout;
209
+ switch (format) {
210
+ case "ansi":
211
+ styler = createAnsiStyler(runtime.theme);
212
+ layout = createTextLayout();
213
+ break;
214
+ case "markdown":
215
+ styler = createMarkdownStyler();
216
+ layout = createMarkdownLayout();
217
+ break;
218
+ case "html":
219
+ styler = createHtmlStyler();
220
+ layout = createHtmlLayout();
221
+ break;
222
+ default:
223
+ styler = createTextStyler();
224
+ layout = createTextLayout();
225
+ break;
226
+ }
227
+ return {
228
+ format,
229
+ styler,
230
+ layout,
231
+ terminalWidth
232
+ };
233
+ }
234
+ //#endregion
235
+ //#region src/util/utils.ts
236
+ function getRootCommand(cmd) {
237
+ let current = cmd;
238
+ while (current.parent) current = current.parent;
239
+ return current;
240
+ }
241
+ async function readVersionFromPackageJson() {
242
+ try {
243
+ const fs = await import("node:fs");
244
+ const path = await import("node:path");
245
+ let dir = process.cwd();
246
+ for (let i = 0; i < 10; i++) {
247
+ const pkgPath = path.join(dir, "package.json");
248
+ if (fs.existsSync(pkgPath)) {
249
+ const pkg = JSON.parse(fs.readFileSync(pkgPath, "utf-8"));
250
+ if (pkg.version) return pkg.version;
251
+ }
252
+ const parentDir = path.dirname(dir);
253
+ if (parentDir === dir) break;
254
+ dir = parentDir;
255
+ }
256
+ } catch {}
257
+ return "0.0.0";
258
+ }
259
+ /**
260
+ * Attempts to get the version from various sources:
261
+ * 1. Explicit version set on the command
262
+ * 2. npm_package_version environment variable (set by npm/yarn/pnpm when running scripts)
263
+ * 3. package.json in current or parent directories
264
+ *
265
+ * Returns synchronously when an explicit version or env var is available.
266
+ * Falls back to async package.json discovery otherwise.
267
+ */
268
+ function getVersion(explicitVersion) {
269
+ if (explicitVersion) return explicitVersion;
270
+ if (typeof process !== "undefined" && process.env?.npm_package_version) return process.env.npm_package_version;
271
+ if (typeof process !== "undefined") return readVersionFromPackageJson();
272
+ return "0.0.0";
273
+ }
274
+ //#endregion
275
+ //#region src/output/formatter.ts
237
276
  /**
238
277
  * Creates a formatter that uses the given styler and layout configuration.
239
278
  */
@@ -556,12 +595,6 @@ function createJsonFormatter() {
556
595
  return JSON.stringify(info, null, 2);
557
596
  } };
558
597
  }
559
- function shouldUseAnsi(env, isTTY) {
560
- if (env?.NO_COLOR) return false;
561
- if (env?.CI) return false;
562
- if (typeof isTTY === "boolean") return isTTY;
563
- return false;
564
- }
565
598
  /**
566
599
  * Creates a minimal formatter that outputs just a single-line usage string.
567
600
  */
@@ -580,7 +613,7 @@ function createMinimalFormatter() {
580
613
  function createFormatter(format, detail = "standard", theme, all, width, terminal, env) {
581
614
  if (detail === "minimal") return createMinimalFormatter();
582
615
  if (format === "json") return createJsonFormatter();
583
- const tw = format === "markdown" || format === "html" ? void 0 : width ?? terminal?.columns ?? DEFAULT_TERMINAL_WIDTH;
616
+ const tw = format === "markdown" || format === "html" ? void 0 : width ?? terminal?.columns ?? 80;
584
617
  if (format === "ansi" || format === "auto" && shouldUseAnsi(env, terminal?.isTTY)) return createGenericFormatter(createAnsiStyler(theme), createTextLayout(), all, tw);
585
618
  if (format === "console") return createGenericFormatter(createConsoleStyler(theme), createTextLayout(), all, tw);
586
619
  if (format === "markdown") return createGenericFormatter(createMarkdownStyler(), createMarkdownLayout(), all);
@@ -844,6 +877,6 @@ function generateHelp(rootCommand, commandObj = rootCommand, prefs) {
844
877
  return createFormatter(prefs?.format ?? "auto", prefs?.detail, prefs?.theme, prefs?.all, prefs?.width, prefs?.terminal, prefs?.env).format(helpInfo);
845
878
  }
846
879
  //#endregion
847
- export { getVersion as a, getRootCommand as i, getHelpInfo as n, colorThemes as r, generateHelp as t };
880
+ export { escapeHtml as a, getVersion as i, getHelpInfo as n, resolveOutputFormat as o, getRootCommand as r, colorThemes as s, generateHelp as t };
848
881
 
849
- //# sourceMappingURL=help-B5Kk83of.mjs.map
882
+ //# sourceMappingURL=help-BtxLgrF_.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"help-BtxLgrF_.mjs","names":[],"sources":["../src/output/colorizer.ts","../src/output/styling.ts","../src/util/utils.ts","../src/output/formatter.ts","../src/output/help.ts"],"sourcesContent":["// ANSI color/style codes\nconst ansiCodes: Record<AnsiStyle, string> = {\n reset: '\\x1b[0m',\n bold: '\\x1b[1m',\n dim: '\\x1b[2m',\n italic: '\\x1b[3m',\n underline: '\\x1b[4m',\n strikethrough: '\\x1b[9m',\n red: '\\x1b[31m',\n green: '\\x1b[32m',\n yellow: '\\x1b[33m',\n blue: '\\x1b[34m',\n magenta: '\\x1b[35m',\n cyan: '\\x1b[36m',\n white: '\\x1b[37m',\n gray: '\\x1b[90m',\n};\n\n/**\n * Available ANSI styles that can be combined for each color role.\n */\nexport type AnsiStyle =\n | 'reset'\n | 'bold'\n | 'dim'\n | 'italic'\n | 'underline'\n | 'strikethrough'\n | 'red'\n | 'green'\n | 'yellow'\n | 'blue'\n | 'magenta'\n | 'cyan'\n | 'white'\n | 'gray';\n\n/**\n * Maps each semantic color role to an array of ANSI styles.\n * Partial configs are merged with the default theme.\n */\nexport type ColorConfig = {\n command?: AnsiStyle[];\n arg?: AnsiStyle[];\n type?: AnsiStyle[];\n description?: AnsiStyle[];\n label?: AnsiStyle[];\n meta?: AnsiStyle[];\n example?: AnsiStyle[];\n exampleValue?: AnsiStyle[];\n deprecated?: AnsiStyle[];\n};\n\nexport type Colorizer = {\n command: (text: string) => string;\n arg: (text: string) => string;\n type: (text: string) => string;\n description: (text: string) => string;\n label: (text: string) => string;\n meta: (text: string) => string;\n example: (text: string) => string;\n exampleValue: (text: string) => string;\n deprecated: (text: string) => string;\n};\n\n// ============================================================================\n// Predefined Themes\n// ============================================================================\n\nconst defaultTheme: Required<ColorConfig> = {\n command: ['cyan', 'bold'],\n arg: ['green'],\n type: ['yellow'],\n description: ['dim'],\n label: ['bold'],\n meta: ['gray'],\n example: ['underline'],\n exampleValue: ['italic'],\n deprecated: ['strikethrough', 'gray'],\n};\n\nconst oceanTheme: Required<ColorConfig> = {\n command: ['blue', 'bold'],\n arg: ['cyan'],\n type: ['green'],\n description: ['dim'],\n label: ['bold'],\n meta: ['gray'],\n example: ['underline', 'cyan'],\n exampleValue: ['italic'],\n deprecated: ['strikethrough', 'gray'],\n};\n\nconst warmTheme: Required<ColorConfig> = {\n command: ['yellow', 'bold'],\n arg: ['red'],\n type: ['magenta'],\n description: ['dim'],\n label: ['bold'],\n meta: ['gray'],\n example: ['underline', 'yellow'],\n exampleValue: ['italic'],\n deprecated: ['strikethrough', 'gray'],\n};\n\nconst monochromeTheme: Required<ColorConfig> = {\n command: ['bold'],\n arg: ['underline'],\n type: ['dim'],\n description: ['dim'],\n label: ['bold'],\n meta: ['dim'],\n example: ['underline'],\n exampleValue: ['italic'],\n deprecated: ['strikethrough', 'dim'],\n};\n\n/**\n * Available predefined color themes.\n */\nexport type ColorTheme = 'default' | 'ocean' | 'warm' | 'monochrome';\n\nexport const colorThemes: Record<ColorTheme, Required<ColorConfig>> = {\n default: defaultTheme,\n ocean: oceanTheme,\n warm: warmTheme,\n monochrome: monochromeTheme,\n};\n\nfunction makeStyleFn(styles: AnsiStyle[]): (text: string) => string {\n const prefix = styles.map((s) => ansiCodes[s]).join('');\n return (text: string) => `${prefix}${text}${ansiCodes.reset}`;\n}\n\nfunction resolveConfig(config?: ColorTheme | ColorConfig): Required<ColorConfig> {\n if (!config) return defaultTheme;\n if (typeof config === 'string') return colorThemes[config] ?? defaultTheme;\n return { ...defaultTheme, ...config };\n}\n\nexport function createColorizer(config?: ColorTheme | ColorConfig): Colorizer {\n const resolved = resolveConfig(config);\n return {\n command: makeStyleFn(resolved.command),\n arg: makeStyleFn(resolved.arg),\n type: makeStyleFn(resolved.type),\n description: makeStyleFn(resolved.description),\n label: makeStyleFn(resolved.label),\n meta: makeStyleFn(resolved.meta),\n example: makeStyleFn(resolved.example),\n exampleValue: makeStyleFn(resolved.exampleValue),\n deprecated: makeStyleFn(resolved.deprecated),\n };\n}\n","import type { PadroneActionContext } from '../types/index.ts';\nimport { type ColorConfig, type ColorTheme, createColorizer } from './colorizer.ts';\n\nexport const DEFAULT_TERMINAL_WIDTH = 80;\n\nexport function wrapText(text: string, maxWidth: number): string[] {\n if (maxWidth <= 0 || text.length <= maxWidth) return [text];\n const words = text.split(' ');\n const lines: string[] = [];\n let current = '';\n for (const word of words) {\n if (current && current.length + 1 + word.length > maxWidth) {\n lines.push(current);\n current = word;\n } else {\n current = current ? `${current} ${word}` : word;\n }\n }\n if (current) lines.push(current);\n return lines.length > 0 ? lines : [text];\n}\n\nexport function escapeHtml(text: string): string {\n return text.replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;').replace(/\"/g, '&quot;').replace(/'/g, '&#039;');\n}\n\n// ── Styler ──────────────────────────────────────────────────────────────\n\n/**\n * Styling functions for semantic text roles.\n * Used by formatters to apply visual styles (ANSI, HTML, Markdown, etc.)\n * to different types of content.\n */\nexport type Styler = {\n command: (text: string) => string;\n arg: (text: string) => string;\n type: (text: string) => string;\n description: (text: string) => string;\n label: (text: string) => string;\n section: (text: string) => string;\n meta: (text: string) => string;\n example: (text: string) => string;\n exampleValue: (text: string) => string;\n deprecated: (text: string) => string;\n};\n\n/**\n * Layout configuration for formatters.\n */\nexport type LayoutConfig = {\n newline: string;\n indent: (level: number) => string;\n join: (parts: string[]) => string;\n wrapDocument?: (content: string) => string;\n};\n\n// ── Styler Factories ────────────────────────────────────────────────────\n\nexport function createTextStyler(): Styler {\n return {\n command: (text) => text,\n arg: (text) => text,\n type: (text) => text,\n description: (text) => text,\n label: (text) => text,\n section: (text) => text,\n meta: (text) => text,\n example: (text) => text,\n exampleValue: (text) => text,\n deprecated: (text) => text,\n };\n}\n\nexport function createAnsiStyler(theme?: ColorTheme | ColorConfig): Styler {\n const colorizer = createColorizer(theme);\n return {\n command: colorizer.command,\n arg: colorizer.arg,\n type: colorizer.type,\n description: colorizer.description,\n label: colorizer.label,\n section: colorizer.label,\n meta: colorizer.meta,\n example: colorizer.example,\n exampleValue: colorizer.exampleValue,\n deprecated: colorizer.deprecated,\n };\n}\n\nexport function createConsoleStyler(theme?: ColorTheme | ColorConfig): Styler {\n return createAnsiStyler(theme);\n}\n\nexport function createMarkdownStyler(): Styler {\n return {\n command: (text) => `**${text}**`,\n arg: (text) => `\\`${text}\\``,\n type: (text) => `\\`${text}\\``,\n description: (text) => text,\n label: (text) => `**${text}**`,\n section: (text) => `### ${text}`,\n meta: (text) => `*${text}*`,\n example: (text) => `**${text}**`,\n exampleValue: (text) => `\\`${text}\\``,\n deprecated: (text) => `~~${text}~~`,\n };\n}\n\nexport function createHtmlStyler(): Styler {\n return {\n command: (text) => `<strong style=\"color: #00bcd4;\">${escapeHtml(text)}</strong>`,\n arg: (text) => `<code style=\"color: #4caf50;\">${escapeHtml(text)}</code>`,\n type: (text) => `<code style=\"color: #ff9800;\">${escapeHtml(text)}</code>`,\n description: (text) => `<span style=\"color: #666;\">${escapeHtml(text)}</span>`,\n label: (text) => `<strong>${escapeHtml(text)}</strong>`,\n section: (text) => `<h3>${escapeHtml(text)}</h3>`,\n meta: (text) => `<span style=\"color: #999;\">${escapeHtml(text)}</span>`,\n example: (text) => `<strong style=\"text-decoration: underline;\">${escapeHtml(text)}</strong>`,\n exampleValue: (text) => `<em>${escapeHtml(text)}</em>`,\n deprecated: (text) => `<del style=\"color: #999;\">${escapeHtml(text)}</del>`,\n };\n}\n\n// ── Layout Factories ────────────────────────────────────────────────────\n\nexport function createTextLayout(): LayoutConfig {\n return {\n newline: '\\n',\n indent: (level) => ' '.repeat(level),\n join: (parts) => parts.filter(Boolean).join(' '),\n };\n}\n\nexport function createMarkdownLayout(): LayoutConfig {\n return {\n newline: '\\n\\n',\n indent: (level) => {\n if (level === 0) return '';\n if (level === 1) return ' ';\n return ' ';\n },\n join: (parts) => parts.filter(Boolean).join(' '),\n };\n}\n\nexport function createHtmlLayout(): LayoutConfig {\n return {\n newline: '<br>',\n indent: (level) => '&nbsp;&nbsp;'.repeat(level),\n join: (parts) => parts.filter(Boolean).join(' '),\n wrapDocument: (content) => `<div style=\"font-family: monospace; line-height: 1.6;\">${content}</div>`,\n };\n}\n\n// ── Format Detection ────────────────────────────────────────────────────\n\nexport function shouldUseAnsi(env?: Record<string, string | undefined>, isTTY?: boolean): boolean {\n if (env?.NO_COLOR) return false;\n if (env?.CI) return false;\n if (typeof isTTY === 'boolean') return isTTY;\n return false;\n}\n\n// ── Output Context ──────────────────────────────────────────────────────\n\n/** Resolved formatting context used by output primitives. */\nexport type OutputFormat = 'text' | 'ansi' | 'json' | 'markdown' | 'html';\n\nexport type OutputContext = {\n format: OutputFormat;\n styler: Styler;\n layout: LayoutConfig;\n terminalWidth?: number;\n};\n\n/** Resolve the output format from the runtime and caller context. */\nexport function resolveOutputFormat(\n runtime: {\n format?: string;\n theme?: ColorTheme | ColorConfig;\n terminal?: { columns?: number; isTTY?: boolean };\n env: () => Record<string, string | undefined>;\n },\n caller?: PadroneActionContext['caller'],\n): OutputContext {\n let format: OutputFormat;\n\n if (caller === 'serve' || caller === 'mcp' || caller === 'tool') {\n format = 'json';\n } else if (runtime.format && runtime.format !== 'auto' && runtime.format !== 'console') {\n format = runtime.format as OutputFormat;\n } else {\n format = shouldUseAnsi(runtime.env(), runtime.terminal?.isTTY) ? 'ansi' : 'text';\n }\n\n const terminalWidth = format === 'markdown' || format === 'html' ? undefined : (runtime.terminal?.columns ?? DEFAULT_TERMINAL_WIDTH);\n\n let styler: Styler;\n let layout: LayoutConfig;\n\n switch (format) {\n case 'ansi':\n styler = createAnsiStyler(runtime.theme);\n layout = createTextLayout();\n break;\n case 'markdown':\n styler = createMarkdownStyler();\n layout = createMarkdownLayout();\n break;\n case 'html':\n styler = createHtmlStyler();\n layout = createHtmlLayout();\n break;\n default:\n styler = createTextStyler();\n layout = createTextLayout();\n break;\n }\n\n return { format, styler, layout, terminalWidth };\n}\n","import type { AnyPadroneCommand } from '../types/index.ts';\n\nexport function getRootCommand(cmd: AnyPadroneCommand): AnyPadroneCommand {\n let current = cmd;\n while (current.parent) current = current.parent;\n return current;\n}\n\nasync function readVersionFromPackageJson(): Promise<string> {\n try {\n const fs = await import('node:fs');\n const path = await import('node:path');\n let dir = process.cwd();\n\n // Walk up the directory tree looking for package.json\n for (let i = 0; i < 10; i++) {\n const pkgPath = path.join(dir, 'package.json');\n if (fs.existsSync(pkgPath)) {\n const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf-8'));\n if (pkg.version) return pkg.version;\n }\n const parentDir = path.dirname(dir);\n if (parentDir === dir) break; // Reached root\n dir = parentDir;\n }\n } catch {\n // Ignore errors (e.g., fs not available in browser)\n }\n return '0.0.0';\n}\n\n/**\n * Attempts to get the version from various sources:\n * 1. Explicit version set on the command\n * 2. npm_package_version environment variable (set by npm/yarn/pnpm when running scripts)\n * 3. package.json in current or parent directories\n *\n * Returns synchronously when an explicit version or env var is available.\n * Falls back to async package.json discovery otherwise.\n */\nexport function getVersion(explicitVersion?: string): string | Promise<string> {\n if (explicitVersion) return explicitVersion;\n\n if (typeof process !== 'undefined' && process.env?.npm_package_version) {\n return process.env.npm_package_version;\n }\n\n if (typeof process !== 'undefined') return readVersionFromPackageJson();\n\n return '0.0.0';\n}\n","import { camelToKebab } from '../util/shell-utils.ts';\nimport type { ColorConfig, ColorTheme } from './colorizer.ts';\nimport {\n createAnsiStyler,\n createConsoleStyler,\n createHtmlLayout,\n createHtmlStyler,\n createMarkdownLayout,\n createMarkdownStyler,\n createTextLayout,\n createTextStyler,\n DEFAULT_TERMINAL_WIDTH,\n type LayoutConfig,\n type Styler,\n shouldUseAnsi,\n wrapText,\n} from './styling.ts';\n\nexport type HelpFormat = 'text' | 'ansi' | 'console' | 'markdown' | 'html' | 'json';\nexport type HelpDetail = 'minimal' | 'standard' | 'full';\n\n// ============================================================================\n// Help Info Types (shared with help.ts)\n// ============================================================================\n\n/**\n * Information about a single positional argument.\n */\nexport type HelpPositionalInfo = {\n name: string;\n description?: string;\n optional: boolean;\n default?: unknown;\n type?: string;\n enum?: string[];\n};\n\n/**\n * Information about a single argument/flag.\n */\nexport type HelpArgumentInfo = {\n name: string;\n description?: string;\n optional: boolean;\n default?: unknown;\n type?: string;\n enum?: string[];\n /** Single-character short flags (shown as `-v`) */\n flags?: string[];\n /** Multi-character alternative long names (shown as `--dry-run`) */\n aliases?: string[];\n deprecated?: boolean | string;\n hidden?: boolean;\n examples?: unknown[];\n /** Environment variable(s) this arg can be set from */\n env?: string | string[];\n /** Whether this arg is an array type (shown as <type...>) */\n variadic?: boolean;\n /** Whether this arg is a boolean (shown as --[no-]arg) */\n negatable?: boolean;\n /** Config file key that maps to this arg */\n configKey?: string;\n /** Group name for organizing this option under a labeled section in help output */\n group?: string;\n};\n\n/**\n * Information about a subcommand (minimal info for listing).\n */\nexport type HelpSubcommandInfo = {\n name: string;\n title?: string;\n description?: string;\n aliases?: string[];\n deprecated?: boolean | string;\n hidden?: boolean;\n hasSubcommands?: boolean;\n /** Group name for organizing this command under a labeled section in help output */\n group?: string;\n};\n\n/**\n * Information about a built-in command/flag entry.\n */\nexport type HelpBuiltinInfo = {\n name: string;\n description?: string;\n sub?: { name: string; description?: string }[];\n};\n\n/**\n * Comprehensive JSON structure for help information.\n * This is the single source of truth that all formatters use.\n */\nexport type HelpInfo = {\n /** The full command name (e.g., \"cli serve\" or \"<root>\") */\n name: string;\n /** Short title for the command */\n title?: string;\n /** Command description */\n description?: string;\n /** Alternative names/aliases for this command */\n aliases?: string[];\n /** Whether the command is deprecated */\n deprecated?: boolean | string;\n /** Whether the command is hidden */\n hidden?: boolean;\n /** Usage string parts for flexible formatting */\n usage: {\n command: string;\n hasSubcommands: boolean;\n hasPositionals: boolean;\n hasArguments: boolean;\n /** The name of the field that reads from stdin, if any. Shown as `[stdin > field]` in usage. */\n stdinField?: string;\n };\n /** List of subcommands */\n subcommands?: HelpSubcommandInfo[];\n /** Positional arguments */\n positionals?: HelpPositionalInfo[];\n /** Arguments/flags (only visible ones, hidden filtered out) */\n arguments?: HelpArgumentInfo[];\n /** Built-in commands and flags (shown only for root command) */\n builtins?: HelpBuiltinInfo[];\n /** Command-level usage examples (shown in help output) */\n examples?: string[];\n /** Full help info for nested commands (used in 'full' detail mode) */\n nestedCommands?: HelpInfo[];\n};\n\n// ============================================================================\n// Formatter Interface\n// ============================================================================\n\n/**\n * A formatter that takes the entire HelpInfo structure and produces formatted output.\n */\nexport type Formatter = {\n /** Format the entire help info structure into a string */\n format: (info: HelpInfo) => string;\n};\n\n// ============================================================================\n// Generic Formatter Implementation\n// ============================================================================\n\n/**\n * Creates a formatter that uses the given styler and layout configuration.\n */\nfunction createGenericFormatter(styler: Styler, layout: LayoutConfig, showAllBuiltins?: boolean, terminalWidth?: number): Formatter {\n const { newline, indent, join, wrapDocument } = layout;\n\n function formatUsageSection(info: HelpInfo): string[] {\n const usageParts: string[] = [styler.command(info.usage.command), info.usage.hasSubcommands ? styler.meta('[command]') : ''];\n // Show actual positional argument names in usage line\n if (info.positionals && info.positionals.length > 0) {\n for (const arg of info.positionals) {\n const name = arg.name.startsWith('...') ? `${arg.name}` : arg.name;\n usageParts.push(styler.meta(arg.optional ? `[${name}]` : `<${name}>`));\n }\n }\n if (info.usage.hasArguments) usageParts.push(styler.meta('[options]'));\n return [`${styler.label('Usage:')} ${join(usageParts)}`];\n }\n\n function formatSubcommandsSection(info: HelpInfo): string[] {\n const lines: string[] = [];\n const subcommands = info.subcommands!;\n\n const subcommandSuffix = (c: HelpSubcommandInfo) => (c.hasSubcommands ? ' <subcommand>' : '');\n const formatAliasParts = (c: HelpSubcommandInfo) => {\n if (!c.aliases?.length) return { plain: '', styled: '' };\n const realAliases = c.aliases.filter((a) => a !== '[default]');\n const hasDefault = c.aliases.some((a) => a === '[default]');\n const parts: string[] = [];\n const styledParts: string[] = [];\n if (realAliases.length) {\n parts.push(`(${realAliases.join(', ')})`);\n styledParts.push(`(${realAliases.join(', ')})`);\n }\n if (hasDefault) {\n parts.push('[default]');\n styledParts.push(styler.meta('[default]'));\n }\n return { plain: parts.length ? ` ${parts.join(' ')}` : '', styled: styledParts.length ? ` ${styledParts.join(' ')}` : '' };\n };\n // Column width is computed across all subcommands for consistent alignment\n const maxNameLength = Math.max(\n ...subcommands.map((c) => {\n return (c.name + subcommandSuffix(c) + formatAliasParts(c).plain).length;\n }),\n );\n\n const grouped = Object.groupBy(subcommands, (c) => c.group ?? '');\n\n const renderSubcommands = (cmds: HelpSubcommandInfo[]) => {\n for (const subCmd of cmds) {\n const aliasParts = formatAliasParts(subCmd);\n const suffix = subcommandSuffix(subCmd);\n const commandDisplay = subCmd.name + suffix + aliasParts.plain;\n const padding = ' '.repeat(Math.max(0, maxNameLength - commandDisplay.length + 2));\n const isDeprecated = !!subCmd.deprecated;\n const isDefaultEntry = subCmd.name === '[default]';\n const commandName = isDeprecated\n ? styler.deprecated(commandDisplay)\n : (isDefaultEntry ? styler.meta(subCmd.name) : styler.command(subCmd.name)) +\n (suffix ? styler.meta(suffix) : '') +\n aliasParts.styled;\n const lineParts: string[] = [commandName, padding];\n\n // Use title if available, otherwise use description\n const displayText = subCmd.title ?? subCmd.description;\n if (displayText) {\n lineParts.push(isDeprecated ? styler.deprecated(displayText) : styler.description(displayText));\n }\n if (isDeprecated) {\n const deprecatedMeta =\n typeof subCmd.deprecated === 'string' ? styler.meta(` (deprecated: ${subCmd.deprecated})`) : styler.meta(' (deprecated)');\n lineParts.push(deprecatedMeta);\n }\n lines.push(indent(1) + lineParts.join(''));\n }\n };\n\n for (const [key, items] of Object.entries(grouped)) {\n if (lines.length > 0) lines.push('');\n lines.push(styler.section(key ? `${key}:` : 'Commands:'));\n renderSubcommands(items!);\n }\n\n // Skip hint when builtins are present — the builtins section shows a combined hint\n if (!info.builtins?.length) {\n lines.push('');\n lines.push(styler.meta(`Run \"${info.name} [command] --help\" for more information on a command.`));\n }\n\n return lines;\n }\n\n function formatPositionalsSection(info: HelpInfo): string[] {\n const lines: string[] = [];\n const args = info.positionals!;\n\n lines.push(styler.section('Arguments:'));\n\n const maxNameLength = Math.min(32, Math.max(...args.map((a) => a.name.length)));\n const descCol = 2 + maxNameLength + 2;\n const posAvailWidth = terminalWidth ? terminalWidth - descCol : undefined;\n const descColPad = ' '.repeat(descCol);\n\n for (const arg of args) {\n const padding = ' '.repeat(Math.max(2, maxNameLength - arg.name.length + 2));\n const prefix = indent(1) + styler.arg(arg.name) + padding;\n\n const descPlain = arg.description ?? '';\n const styledDesc = descPlain ? styler.description(descPlain) : '';\n\n const metaParts: string[] = [];\n const styledMetaParts: string[] = [];\n if (info.usage.stdinField === arg.name) {\n metaParts.push('(stdin)');\n styledMetaParts.push(styler.meta('(stdin)'));\n }\n if (arg.enum) {\n const text = `(choices: ${arg.enum.join(', ')})`;\n metaParts.push(text);\n styledMetaParts.push(styler.meta(text));\n }\n if (arg.default !== undefined) {\n const text = `(default: ${String(arg.default)})`;\n metaParts.push(text);\n styledMetaParts.push(styler.meta(text));\n }\n\n const metaStyled = join(styledMetaParts);\n\n if (posAvailWidth && posAvailWidth > 0) {\n const metaPlain = metaParts.join(' ');\n const fullPlain = [descPlain, metaPlain].filter(Boolean).join(' ');\n if (fullPlain.length <= posAvailWidth) {\n lines.push(prefix + [styledDesc, metaStyled].filter(Boolean).join(' '));\n } else if (!descPlain || descPlain.length <= posAvailWidth) {\n lines.push(prefix + styledDesc);\n if (metaStyled) lines.push(descColPad + metaStyled);\n } else {\n const wrapped = wrapText(descPlain, posAvailWidth);\n lines.push(prefix + styler.description(wrapped[0]!));\n for (const wline of wrapped.slice(1)) lines.push(descColPad + styler.description(wline));\n if (metaStyled) lines.push(descColPad + metaStyled);\n }\n } else {\n lines.push(prefix + join([styledDesc, metaStyled]));\n }\n }\n\n return lines;\n }\n\n function formatArgumentsSection(info: HelpInfo): string[] {\n const lines: string[] = [];\n const argList = info.arguments || [];\n\n // Helper to check if a default value is meaningful (not empty string/array)\n const hasDefault = (value: unknown): boolean => {\n if (value === undefined) return false;\n if (value === '') return false;\n if (Array.isArray(value) && value.length === 0) return false;\n return true;\n };\n\n // Build columns: flags | names | type | description\n const argColumns = argList.map((arg) => {\n // Promote kebab-case alias to primary display name if it exists\n const kebab = camelToKebab(arg.name);\n const primaryName = kebab && arg.aliases?.includes(kebab) ? kebab : arg.name;\n const remainingAliases = arg.aliases?.filter((a) => a !== primaryName);\n\n const flagsPlain = arg.flags?.length ? arg.flags.map((f) => `-${f}`).join(', ') : '';\n const namesPlain = [`--${primaryName}`, ...(remainingAliases?.map((a) => `--${a}`) || [])].join(', ');\n const typePlain = arg.type && arg.type !== 'boolean' ? (arg.optional ? `[${arg.type}]` : `<${arg.type}>`) : '';\n\n const isDeprecated = !!arg.deprecated;\n\n return { flagsPlain, namesPlain, typePlain, isDeprecated, arg };\n });\n\n // Column widths are computed across all args (regardless of group) for consistent alignment\n const maxFlagsWidth = Math.min(12, Math.max(0, ...argColumns.map((c) => c.flagsPlain.length)));\n const maxNamesWidth = Math.min(32, Math.max(0, ...argColumns.map((c) => c.namesPlain.length)));\n const maxTypeWidth = Math.min(16, Math.max(0, ...argColumns.map((c) => c.typePlain.length)));\n const hasAnyFlags = maxFlagsWidth > 0;\n const descCol = 2 + (hasAnyFlags ? maxFlagsWidth + 2 : 0) + maxNamesWidth + 2 + (maxTypeWidth > 0 ? maxTypeWidth + 2 : 0);\n const argAvailWidth = terminalWidth ? terminalWidth - descCol : undefined;\n const descColPad = ' '.repeat(descCol);\n\n // Split into ordered groups: ungrouped first as \"Options:\", then each group in first-seen order\n const grouped = Object.groupBy(argColumns, (c) => c.arg.group ?? '');\n\n const renderArgColumns = (columns: typeof argColumns) => {\n for (const { flagsPlain, namesPlain, typePlain, isDeprecated, arg } of columns) {\n const parts: string[] = [];\n\n // Flags column\n if (hasAnyFlags) {\n const styledFlags = isDeprecated ? (flagsPlain ? styler.deprecated(flagsPlain) : '') : flagsPlain ? styler.arg(flagsPlain) : '';\n const flagsPadding = ' '.repeat(Math.max(0, maxFlagsWidth - flagsPlain.length));\n const separator = flagsPlain ? ', ' : ' ';\n parts.push(styledFlags + flagsPadding + separator);\n }\n\n // Names column\n const styledNames = isDeprecated ? styler.deprecated(namesPlain) : styler.arg(namesPlain);\n const namesPadding = ' '.repeat(Math.max(2, maxNamesWidth - namesPlain.length + 2));\n parts.push(styledNames + namesPadding);\n\n // Type column\n if (maxTypeWidth > 0) {\n const styledType = typePlain ? styler.type(typePlain) : '';\n const typePadding = ' '.repeat(Math.max(2, maxTypeWidth - typePlain.length + 2));\n parts.push(styledType + typePadding);\n }\n\n const prefix = indent(1) + parts.join('');\n const contPad = argAvailWidth ? descColPad : indent(3);\n\n // Build inline meta (deprecated no-reason, default, choices)\n const inlineMeta: string[] = [];\n const styledInlineMeta: string[] = [];\n if (isDeprecated && typeof arg.deprecated !== 'string') {\n inlineMeta.push('(deprecated)');\n styledInlineMeta.push(styler.meta('(deprecated)'));\n }\n if (hasDefault(arg.default)) {\n const text = `(default: ${String(arg.default)})`;\n inlineMeta.push(text);\n styledInlineMeta.push(styler.meta(text));\n }\n if (arg.enum) {\n const text = `(choices: ${arg.enum.join(', ')})`;\n inlineMeta.push(text);\n styledInlineMeta.push(styler.meta(text));\n }\n\n const descPlain = arg.description ?? '';\n const styledDesc = descPlain ? (isDeprecated ? styler.deprecated(descPlain) : styler.description(descPlain)) : '';\n const metaStyled = join(styledInlineMeta);\n\n if (argAvailWidth && argAvailWidth > 0) {\n // Terminal-width-aware: try to fit description + meta on one line\n const metaPlain = inlineMeta.join(' ');\n const fullPlain = [descPlain, metaPlain].filter(Boolean).join(' ');\n if (fullPlain.length <= argAvailWidth) {\n lines.push(prefix + [styledDesc, metaStyled].filter(Boolean).join(' '));\n } else if (!descPlain || descPlain.length <= argAvailWidth) {\n lines.push(prefix + styledDesc);\n if (metaStyled) lines.push(descColPad + metaStyled);\n } else {\n const wrapped = wrapText(descPlain, argAvailWidth);\n const styleFn = isDeprecated ? styler.deprecated : styler.description;\n lines.push(prefix + styleFn(wrapped[0]!));\n for (const wline of wrapped.slice(1)) lines.push(descColPad + styleFn(wline));\n if (metaStyled) lines.push(descColPad + metaStyled);\n }\n } else {\n // No terminal width (markdown/html): description on line 1, meta on line 2\n const descParts: string[] = [];\n if (styledDesc) descParts.push(styledDesc);\n lines.push(prefix + join(descParts));\n if (styledInlineMeta.length > 0) lines.push(indent(3) + metaStyled);\n }\n\n // Deprecated (with reason), examples — always on separate line\n const line3Parts: string[] = [];\n if (isDeprecated && typeof arg.deprecated === 'string') line3Parts.push(styler.meta(`(deprecated: ${arg.deprecated})`));\n if (arg.examples && arg.examples.length > 0) {\n const exampleValues = arg.examples.map((example) => (typeof example === 'string' ? example : JSON.stringify(example))).join(', ');\n line3Parts.push(styler.example('Example:'), styler.exampleValue(exampleValues));\n }\n if (line3Parts.length > 0) lines.push(contPad + join(line3Parts));\n\n // stdin, env, config — always on separate line\n const line4Parts: string[] = [];\n if (info.usage.stdinField === arg.name) line4Parts.push(styler.meta('(stdin)'));\n if (arg.env) {\n const envVars = typeof arg.env === 'string' ? [arg.env] : arg.env;\n line4Parts.push(styler.example('Env:'), styler.exampleValue(envVars.join(', ')));\n }\n if (arg.configKey) {\n line4Parts.push(styler.example('Config:'), styler.exampleValue(arg.configKey));\n }\n if (line4Parts.length > 0) lines.push(contPad + join(line4Parts));\n }\n };\n\n for (const [key, items] of Object.entries(grouped)) {\n if (lines.length > 0) lines.push('');\n lines.push(styler.section(key ? `${key}:` : 'Options:'));\n renderArgColumns(items!);\n }\n\n return lines;\n }\n\n function formatBuiltinsSection(info: HelpInfo): string[] {\n const lines: string[] = [];\n const builtins = info.builtins!;\n\n if (!showAllBuiltins) {\n // Collapsed summary: show selected builtins on a single line with a combined hint\n const highlights = ['help [command]', 'version', '[command] --repl'];\n lines.push(`${styler.label('Global:')} ${styler.meta(highlights.join(', '))}`);\n const hint = info.usage.hasSubcommands\n ? `Run \"${info.name} [command] --help\" for more information. Use \"--all\" for all global commands.`\n : `Use \"${info.name} help --all\" for more information on global commands.`;\n lines.push(styler.meta(hint));\n return lines;\n }\n\n lines.push(styler.section('Global:'));\n\n // Compute max effective name length for alignment across main and sub entries\n const allLengths: number[] = [];\n for (const entry of builtins) {\n allLengths.push(entry.name.length);\n if (entry.sub) {\n for (const sub of entry.sub) {\n // Sub entries get extra indent(2) - indent(1) = 2 chars\n allLengths.push(sub.name.length + 2);\n }\n }\n }\n const maxLen = Math.max(...allLengths);\n\n for (const entry of builtins) {\n const padding = ' '.repeat(Math.max(2, maxLen - entry.name.length + 2));\n const parts: string[] = [styler.command(entry.name)];\n if (entry.description) parts.push(padding + styler.description(entry.description));\n lines.push(indent(1) + parts.join(''));\n\n if (entry.sub) {\n for (const sub of entry.sub) {\n const subPadding = ' '.repeat(Math.max(2, maxLen - sub.name.length));\n const subParts: string[] = [styler.arg(sub.name)];\n if (sub.description) subParts.push(subPadding + styler.description(sub.description));\n lines.push(indent(2) + subParts.join(''));\n }\n }\n }\n\n return lines;\n }\n\n return {\n format(info: HelpInfo): string {\n const lines: string[] = [];\n\n // Show deprecation warning at the top if command is deprecated\n if (info.deprecated) {\n const deprecationMessage =\n typeof info.deprecated === 'string' ? `⚠️ This command is deprecated: ${info.deprecated}` : '⚠️ This command is deprecated';\n lines.push(styler.deprecated(deprecationMessage));\n lines.push('');\n }\n\n // Usage section\n lines.push(...formatUsageSection(info));\n lines.push('');\n\n // Title section (if present, shows a short summary line)\n if (info.title) {\n lines.push(styler.label(info.title));\n lines.push('');\n }\n\n // Aliases section (if present)\n if (info.aliases && info.aliases.length > 0) {\n lines.push(styler.meta(`Aliases: ${info.aliases.join(', ')}`));\n lines.push('');\n }\n\n // Description section (if present)\n if (info.description) {\n lines.push(styler.description(info.description));\n lines.push('');\n }\n\n // Examples section (if present)\n if (info.examples && info.examples.length > 0) {\n lines.push(styler.section('Examples:'));\n for (const ex of info.examples) {\n lines.push(indent(1) + styler.meta('$ ') + styler.exampleValue(ex));\n }\n lines.push('');\n }\n\n // Subcommands section\n if (info.subcommands && info.subcommands.length > 0) {\n lines.push(...formatSubcommandsSection(info));\n lines.push('');\n }\n\n if (info.positionals && info.positionals.length > 0) {\n lines.push(...formatPositionalsSection(info));\n lines.push('');\n }\n\n if (info.arguments && info.arguments.length > 0) {\n lines.push(...formatArgumentsSection(info));\n lines.push('');\n }\n\n if (info.builtins && info.builtins.length > 0) {\n lines.push(...formatBuiltinsSection(info));\n lines.push('');\n }\n\n // Show --no- hint when there are negatable boolean options defaulting to true\n if (info.arguments?.some((arg) => arg.negatable && arg.default === true)) {\n lines.push(styler.meta('Boolean options can be negated with --no-<option>.'));\n lines.push('');\n }\n\n // Nested commands section (full detail mode)\n if (info.nestedCommands?.length) {\n lines.push(styler.section('Subcommand Details:'));\n lines.push('');\n for (const nestedCmd of info.nestedCommands) {\n lines.push(styler.meta('─'.repeat(60)));\n lines.push(this.format(nestedCmd));\n }\n }\n\n const result = lines.join(newline);\n return wrapDocument ? wrapDocument(result) : result;\n },\n };\n}\n\n// ============================================================================\n// JSON Formatter\n// ============================================================================\n\nfunction createJsonFormatter(): Formatter {\n return {\n format(info: HelpInfo): string {\n return JSON.stringify(info, null, 2);\n },\n };\n}\n\n// ============================================================================\n// Minimal Formatter\n// ============================================================================\n\n/**\n * Creates a minimal formatter that outputs just a single-line usage string.\n */\nfunction createMinimalFormatter(): Formatter {\n return {\n format(info: HelpInfo): string {\n const parts: string[] = [info.usage.command];\n if (info.usage.hasSubcommands) parts.push('[command]');\n if (info.positionals && info.positionals.length > 0) {\n for (const arg of info.positionals) {\n const name = arg.name.startsWith('...') ? `${arg.name}` : arg.name;\n parts.push(arg.optional ? `[${name}]` : `<${name}>`);\n }\n }\n if (info.usage.hasArguments) parts.push('[options]');\n return parts.join(' ');\n },\n };\n}\n\nexport function createFormatter(\n format: HelpFormat | 'auto',\n detail: HelpDetail = 'standard',\n theme?: ColorTheme | ColorConfig,\n all?: boolean,\n width?: number,\n terminal?: { columns?: number; isTTY?: boolean },\n env?: Record<string, string | undefined>,\n): Formatter {\n if (detail === 'minimal') return createMinimalFormatter();\n if (format === 'json') return createJsonFormatter();\n const tw = format === 'markdown' || format === 'html' ? undefined : (width ?? terminal?.columns ?? DEFAULT_TERMINAL_WIDTH);\n if (format === 'ansi' || (format === 'auto' && shouldUseAnsi(env, terminal?.isTTY)))\n return createGenericFormatter(createAnsiStyler(theme), createTextLayout(), all, tw);\n if (format === 'console') return createGenericFormatter(createConsoleStyler(theme), createTextLayout(), all, tw);\n if (format === 'markdown') return createGenericFormatter(createMarkdownStyler(), createMarkdownLayout(), all);\n if (format === 'html') return createGenericFormatter(createHtmlStyler(), createHtmlLayout(), all);\n return createGenericFormatter(createTextStyler(), createTextLayout(), all, tw);\n}\n","import type { StandardJSONSchemaV1 } from '@standard-schema/spec';\nimport { extractSchemaMetadata, getJsonSchema, type PadroneArgsSchemaMeta, parsePositionalConfig } from '../core/args.ts';\nimport { findCommandByName } from '../core/commands.ts';\nimport type { AnyPadroneCommand } from '../types/index.ts';\nimport { getRootCommand } from '../util/utils.ts';\nimport type { ColorConfig, ColorTheme } from './colorizer.ts';\nimport {\n createFormatter,\n type HelpArgumentInfo,\n type HelpDetail,\n type HelpFormat,\n type HelpInfo,\n type HelpPositionalInfo,\n type HelpSubcommandInfo,\n} from './formatter.ts';\n\nexport type HelpPreferences = {\n format?: HelpFormat | 'auto';\n detail?: HelpDetail;\n theme?: ColorTheme | ColorConfig;\n /** Show all global commands and flags in full detail */\n all?: boolean;\n /** Terminal width for text wrapping. Defaults to terminal columns or 80. */\n width?: number;\n /** Terminal capabilities for auto-detection of ANSI and width. */\n terminal?: { columns?: number; isTTY?: boolean };\n /** Environment variables for auto-detection (e.g., NO_COLOR, CI). */\n env?: Record<string, string | undefined>;\n};\n\n/**\n * Extract positional arguments info from schema based on meta.positional config.\n */\nfunction extractPositionalArgsInfo(\n schema: StandardJSONSchemaV1,\n meta?: PadroneArgsSchemaMeta,\n): { args: HelpPositionalInfo[]; positionalNames: Set<string> } {\n const args: HelpPositionalInfo[] = [];\n const positionalNames = new Set<string>();\n\n if (!schema || !meta?.positional || meta.positional.length === 0) {\n return { args, positionalNames };\n }\n\n const positionalConfig = parsePositionalConfig(meta.positional);\n\n try {\n const jsonSchema = getJsonSchema(schema) as Record<string, any>;\n\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n const properties = jsonSchema.properties as Record<string, any>;\n const required = (jsonSchema.required as string[]) || [];\n\n for (const { name, variadic } of positionalConfig) {\n const prop = properties[name];\n if (!prop) continue;\n\n positionalNames.add(name);\n const optMeta = meta.fields?.[name];\n\n args.push({\n name: variadic ? `...${name}` : name,\n description: optMeta?.description ?? prop.description,\n optional: !required.includes(name),\n default: prop.default,\n type: variadic ? `array<${prop.items?.type || 'string'}>` : prop.type,\n enum: (prop.enum ?? prop.items?.enum) as string[] | undefined,\n });\n }\n }\n } catch {\n // Fallback to empty result if toJSONSchema fails\n }\n\n return { args, positionalNames };\n}\n\nfunction extractArgsInfo(schema: StandardJSONSchemaV1, meta?: PadroneArgsSchemaMeta, positionalNames?: Set<string>) {\n const result: HelpArgumentInfo[] = [];\n if (!schema) return result;\n\n const vendor = schema['~standard'].vendor;\n if (!vendor.includes('zod')) return result;\n\n const argsMeta = meta?.fields;\n\n try {\n const jsonSchema = getJsonSchema(schema) as Record<string, any>;\n\n // Handle object: z.object({ key: z.string(), ... })\n if (jsonSchema.type === 'object' && jsonSchema.properties) {\n const properties = jsonSchema.properties as Record<string, any>;\n const required = (jsonSchema.required as string[]) || [];\n const propertyNames = new Set(Object.keys(properties));\n\n // Helper to check if a negated version of an arg exists\n const hasExplicitNegation = (key: string): boolean => {\n // Check for noVerbose style (camelCase)\n const camelNegated = `no${key.charAt(0).toUpperCase()}${key.slice(1)}`;\n if (propertyNames.has(camelNegated)) return true;\n // Check for no-verbose style (kebab-case, though rare in JS)\n const kebabNegated = `no-${key}`;\n if (propertyNames.has(kebabNegated)) return true;\n return false;\n };\n\n // Helper to check if this arg is itself a negation of another arg\n const isNegationOf = (key: string): boolean => {\n // Check for noVerbose -> verbose (camelCase)\n if (key.startsWith('no') && key.length > 2 && key[2] === key[2]?.toUpperCase()) {\n const positiveKey = key.charAt(2).toLowerCase() + key.slice(3);\n if (propertyNames.has(positiveKey)) return true;\n }\n // Check for no-verbose -> verbose (kebab-case)\n if (key.startsWith('no-')) {\n const positiveKey = key.slice(3);\n if (propertyNames.has(positiveKey)) return true;\n }\n return false;\n };\n\n for (const [key, prop] of Object.entries(properties)) {\n // Skip positional arguments - they are shown in arguments section\n if (positionalNames?.has(key)) continue;\n\n const isOptional = !required.includes(key);\n const enumValues = (prop.enum ?? prop.items?.enum) as string[] | undefined;\n const optMeta = argsMeta?.[key];\n const propType = prop.type as string;\n\n // Booleans are negatable unless there's an explicit noArg property\n // or this arg is itself a negation of another arg\n const isNegatable = propType === 'boolean' && !hasExplicitNegation(key) && !isNegationOf(key);\n\n result.push({\n name: key,\n description: optMeta?.description ?? prop.description,\n optional: isOptional,\n default: prop.default,\n type: propType === 'array' ? `${prop.items?.type || 'string'}[]` : propType,\n enum: enumValues,\n deprecated: optMeta?.deprecated ?? prop?.deprecated,\n hidden: optMeta?.hidden ?? prop?.hidden,\n examples: optMeta?.examples ?? prop?.examples,\n variadic: propType === 'array',\n negatable: isNegatable,\n group: optMeta?.group,\n });\n }\n }\n } catch {\n // Fallback to empty result if toJSONSchema fails\n }\n\n return result;\n}\n\n// ============================================================================\n// Core Help Info Builder\n// ============================================================================\n\n/**\n * Builds a comprehensive HelpInfo structure from a command.\n * This is the single source of truth that all formatters use.\n * @param cmd - The command to build help info for\n * @param detail - The level of detail ('minimal', 'standard', or 'full')\n */\nexport function getHelpInfo(cmd: AnyPadroneCommand, detail: HelpPreferences['detail'] = 'standard', all?: boolean): HelpInfo {\n const rootCmd = getRootCommand(cmd);\n // A command is a \"default\" command if its name is '' or it has '' as an alias\n const isDefaultCommand = cmd.parent && (!cmd.name || cmd.aliases?.includes(''));\n // For commands with empty name, use the first non-empty alias as display name\n const nonEmptyAliases = cmd.aliases?.filter(Boolean);\n const commandName = cmd.path || cmd.name || nonEmptyAliases?.[0] || (cmd.parent ? '[default]' : 'program');\n // Build display aliases: real aliases (excluding the one promoted to display name) + [default] marker\n const remainingAliases = !cmd.name && nonEmptyAliases?.length ? nonEmptyAliases.slice(1) : (nonEmptyAliases ?? []);\n const displayAliases = isDefaultCommand ? [...remainingAliases, '[default]'] : nonEmptyAliases;\n\n // Extract positional args from schema based on meta.positional\n const { args: positionalArgs, positionalNames } = cmd.argsSchema\n ? extractPositionalArgsInfo(cmd.argsSchema, cmd.meta)\n : { args: [], positionalNames: new Set<string>() };\n\n const hasPositionals = positionalArgs.length > 0;\n\n const helpInfo: HelpInfo = {\n name: commandName,\n title: cmd.title,\n description: cmd.description,\n examples: cmd.examples,\n aliases: displayAliases,\n deprecated: cmd.deprecated,\n hidden: cmd.hidden,\n usage: {\n command: rootCmd === cmd ? commandName : `${rootCmd.name} ${commandName}`,\n hasSubcommands: !!(cmd.commands && cmd.commands.length > 0),\n hasPositionals,\n hasArguments: false, // updated below after extracting arguments\n stdinField: cmd.meta?.stdin,\n },\n };\n\n // Build subcommands info (filter out hidden commands unless showing full detail)\n if (cmd.commands && cmd.commands.length > 0) {\n const visibleCommands = detail === 'full' ? cmd.commands : cmd.commands.filter((c) => !c.hidden);\n // If the command has both a handler and subcommands, show the handler as a \"[default]\" entry\n const selfEntry: typeof helpInfo.subcommands = cmd.action\n ? [{ name: '[default]', title: cmd.title, description: cmd.description }]\n : [];\n\n helpInfo.subcommands = [\n ...selfEntry,\n ...visibleCommands.flatMap((c): HelpSubcommandInfo[] => {\n const isDefault = !c.name || c.aliases?.includes('');\n const nonEmptyAliases = c.aliases?.filter(Boolean);\n const displayName = c.name || nonEmptyAliases?.[0] || '[default]';\n const remainingAliases = !c.name && nonEmptyAliases?.length ? nonEmptyAliases.slice(1) : (nonEmptyAliases ?? []);\n // Only add [default] alias marker if it's not already the display name\n const displayAliases =\n isDefault && displayName !== '[default]' ? [...remainingAliases, '[default]'] : isDefault ? remainingAliases : nonEmptyAliases;\n const hasSubcommands = !!(c.commands && c.commands.length > 0);\n\n // If a command has subcommands AND a default handler (direct or '' subcommand),\n // show two entries: one for the default action, one for the subcommand router\n const hasDefaultHandler = c.action || c.commands?.some((sub) => !sub.name || sub.aliases?.includes(''));\n if (hasSubcommands && hasDefaultHandler) {\n const defaultSub = !c.action ? c.commands?.find((sub) => !sub.name || sub.aliases?.includes('')) : undefined;\n const hasDefaultSubInfo = defaultSub && (defaultSub.title || defaultSub.description);\n return [\n {\n name: displayName,\n title: hasDefaultSubInfo ? defaultSub.title : c.title,\n description: hasDefaultSubInfo ? defaultSub.description : c.description,\n aliases: displayAliases?.length ? displayAliases : undefined,\n deprecated: c.deprecated,\n hidden: c.hidden,\n group: c.group,\n },\n {\n name: displayName,\n title: c.title,\n description: c.description,\n deprecated: c.deprecated,\n hidden: c.hidden,\n hasSubcommands: true,\n group: c.group,\n },\n ];\n }\n\n return [\n {\n name: displayName,\n title: c.title,\n description: c.description,\n aliases: displayAliases?.length ? displayAliases : undefined,\n deprecated: c.deprecated,\n hidden: c.hidden,\n hasSubcommands,\n group: c.group,\n },\n ];\n }),\n ];\n\n // In 'full' detail mode, recursively build help for all nested commands\n if (detail === 'full') {\n helpInfo.nestedCommands = visibleCommands.map((c) => getHelpInfo(c, 'full'));\n }\n }\n\n // Build arguments info from positionals\n if (hasPositionals) {\n helpInfo.positionals = positionalArgs;\n }\n\n // Build arguments info with aliases (excluding positional args)\n if (cmd.argsSchema) {\n const argsInfo = extractArgsInfo(cmd.argsSchema, cmd.meta, positionalNames);\n const argMap: Record<string, HelpArgumentInfo> = Object.fromEntries(argsInfo.map((arg) => [arg.name, arg]));\n\n // Merge flags and aliases into arguments\n const { flags, aliases } = extractSchemaMetadata(cmd.argsSchema, cmd.meta?.fields, cmd.meta?.autoAlias);\n for (const [flag, name] of Object.entries(flags)) {\n const arg = argMap[name];\n if (!arg) continue;\n arg.flags = [...(arg.flags || []), flag];\n }\n for (const [alias, name] of Object.entries(aliases)) {\n const arg = argMap[name];\n if (!arg) continue;\n arg.aliases = [...(arg.aliases || []), alias];\n }\n\n // Filter out hidden arguments\n const visibleArgs = argsInfo.filter((arg) => !arg.hidden);\n if (visibleArgs.length > 0) {\n helpInfo.arguments = visibleArgs;\n helpInfo.usage.hasArguments = true;\n }\n }\n\n // Add global commands/flags (root command by default, all commands when --all is passed)\n if (!cmd.parent || all) {\n const builtins: HelpInfo['builtins'] = [];\n\n if (!findCommandByName('help', rootCmd.commands)) {\n builtins.push({\n name: 'help [command], -h, --help',\n description: 'Show help for a command',\n sub: [\n { name: '--all', description: 'Show all global commands and flags' },\n { name: '--detail <level>', description: 'Detail level (minimal, standard, full)' },\n { name: '--format <format>', description: 'Output format (text, ansi, json, markdown, html)' },\n ],\n });\n }\n\n if (!findCommandByName('version', rootCmd.commands)) {\n builtins.push({\n name: 'version, -v, --version',\n description: 'Show version information',\n });\n }\n\n if (!findCommandByName('completion', rootCmd.commands)) {\n builtins.push({\n name: 'completion [shell]',\n description: 'Generate shell completions (bash, zsh, fish, powershell)',\n });\n }\n\n if (!findCommandByName('man', rootCmd.commands)) {\n builtins.push({\n name: 'man',\n description: 'Show or install man pages (--setup to install, --remove to uninstall) (experimental)',\n });\n }\n\n builtins.push({\n name: '[command] --repl',\n description: 'Start interactive REPL scoped to a command',\n });\n\n if (!findCommandByName('mcp', rootCmd.commands)) {\n builtins.push({\n name: 'mcp [http|stdio]',\n description: 'Start a Model Context Protocol server to expose commands as AI tools (experimental)',\n sub: [\n { name: '--port <port>', description: 'HTTP port (default: 3000)' },\n { name: '--host <host>', description: 'HTTP host (default: 127.0.0.1)' },\n ],\n });\n }\n\n builtins.push({\n name: '--color [theme], --no-color',\n description: 'Set color theme (default, ocean, warm, monochrome) or disable colors',\n });\n\n if (builtins.length > 0) {\n helpInfo.builtins = builtins;\n }\n }\n\n return helpInfo;\n}\n\n// ============================================================================\n// Main Entry Point\n// ============================================================================\n\nexport function generateHelp(rootCommand: AnyPadroneCommand, commandObj: AnyPadroneCommand = rootCommand, prefs?: HelpPreferences): string {\n const helpInfo = getHelpInfo(commandObj, prefs?.detail, prefs?.all);\n const formatter = createFormatter(\n prefs?.format ?? 'auto',\n prefs?.detail,\n prefs?.theme,\n prefs?.all,\n prefs?.width,\n prefs?.terminal,\n prefs?.env,\n );\n return formatter.format(helpInfo);\n}\n"],"mappings":";;;AACA,MAAM,YAAuC;CAC3C,OAAO;CACP,MAAM;CACN,KAAK;CACL,QAAQ;CACR,WAAW;CACX,eAAe;CACf,KAAK;CACL,OAAO;CACP,QAAQ;CACR,MAAM;CACN,SAAS;CACT,MAAM;CACN,OAAO;CACP,MAAM;CACP;AAqDD,MAAM,eAAsC;CAC1C,SAAS,CAAC,QAAQ,OAAO;CACzB,KAAK,CAAC,QAAQ;CACd,MAAM,CAAC,SAAS;CAChB,aAAa,CAAC,MAAM;CACpB,OAAO,CAAC,OAAO;CACf,MAAM,CAAC,OAAO;CACd,SAAS,CAAC,YAAY;CACtB,cAAc,CAAC,SAAS;CACxB,YAAY,CAAC,iBAAiB,OAAO;CAC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ACP,OAAO,OACP,OAAO,KACP,OAAO,OACP,OAAO,UACP,OAAO,IACR,CACgB,OAAO,SAAS"}
@@ -1078,7 +1078,7 @@ type MountOptions<TContext, TNewContext> = {
1078
1078
  * Otherwise, a fresh builder with default types is used.
1079
1079
  */
1080
1080
  type InitialCommandBuilder<TProgramName extends string, TNameNested extends string, TParentPath extends string, TParentArgs extends PadroneSchema, TCommands extends [...AnyPadroneCommand[]], TParentContext> = [FindDirectChild<TCommands, TNameNested>] extends [never] ? PadroneBuilder<TProgramName, TNameNested, TParentPath, PadroneSchema<void>, void, [], TParentArgs, false, TParentContext> : FindDirectChild<TCommands, TNameNested> extends infer E extends AnyPadroneCommand ? PadroneBuilder<TProgramName, TNameNested, TParentPath, E['~types']['argsSchema'], E['~types']['result'], E['~types']['commands'], TParentArgs, E['~types']['async'], E['~types']['context'], E['~types']['contextProvided']> : PadroneBuilder<TProgramName, TNameNested, TParentPath, PadroneSchema<void>, void, [], TParentArgs, false, TParentContext>;
1081
- type AnyPadroneBuilder = InitialCommandBuilder<string, string, string, any, [...AnyPadroneCommand[]], any>;
1081
+ type AnyPadroneBuilder = InitialCommandBuilder<string, string, string, PadroneSchema, [...AnyPadroneCommand[]], unknown>;
1082
1082
  /**
1083
1083
  * Like InitialCommandBuilder but uses `any` for args in the fresh case.
1084
1084
  * Used as the default for TBuilder when no builderFn is provided.
@@ -1172,7 +1172,25 @@ type AnyPadroneProgram = PadroneProgram<string, string, string, any, any, [...An
1172
1172
  * ```
1173
1173
  */
1174
1174
  type PadroneExtension<TIn extends CommandTypesBase = CommandTypesBase, TOut extends CommandTypesBase = TIn> = (builder: TIn) => TOut;
1175
+ /**
1176
+ * Type for a command builder callback used with `.command()`.
1177
+ * Use this when defining commands in separate files where full return type inference isn't needed.
1178
+ *
1179
+ * For full type preservation at the parent, use `defineCommand()` instead.
1180
+ *
1181
+ * @example
1182
+ * ```ts
1183
+ * // my-command.ts
1184
+ * export const myCommand: DefineCommand = (c) =>
1185
+ * c.arguments(z.object({ name: z.string() }))
1186
+ * .action((args) => console.log(args.name));
1187
+ *
1188
+ * // cli.ts
1189
+ * createPadrone('test').command('my-command', myCommand)
1190
+ * ```
1191
+ */
1192
+ type DefineCommand<TContext = unknown, TParentArgs extends PadroneSchema = PadroneSchema> = (builder: PadroneBuilder<string, string, string, PadroneSchema<void>, void, [], TParentArgs, false, TContext>) => CommandTypesBase;
1175
1193
  type DefaultArgs = Record<string, unknown> | void;
1176
1194
  //#endregion
1177
- export { PadroneProgressOptions as $, InterceptorStartContext as A, WithInterceptor as B, InterceptorExecuteResult as C, InterceptorParseResult as D, InterceptorParseContext as E, PadroneInterceptorFn as F, PadroneServePreferences as G, PadroneSchema as H, Drained as I, InteractivePromptConfig as J, PadroneMcpPreferences as K, PickCommandByName as L, InterceptorValidateResult as M, PadroneContextInterceptor as N, InterceptorPhases as O, PadroneInterceptor as P, PadroneProgressIndicator as Q, PossibleCommands as R, InterceptorExecuteContext as S, InterceptorMeta as T, WrapConfig as U, AsyncPadroneSchema as V, WrapResult as W, PadroneBarChar as X, PadroneBarAnimation as Y, PadroneBarConfig as Z, ExtractInterceptorRequires as _, PadroneProgram as a, PadroneSpinnerPreset as at, InterceptorErrorContext as b, PadroneParseResult as c, CommandTypesBase as d, PadroneProgressShow as et, GetArgsMeta as f, ExtractInterceptorContext as g, PadroneProgramMeta as h, PadroneExtension as i, PadroneSpinnerConfig as it, InterceptorValidateContext as j, InterceptorShutdownContext as k, PadroneReplPreferences as l, PadroneCommand as m, AnyPadroneProgram as n, PadroneRuntime as nt, PadroneCommandResult as o, REPL_SIGINT as ot, PadroneActionContext as p, InteractiveMode as q, PadroneBuilder as r, PadroneSignal as rt, PadroneDrainResult as s, AnyPadroneBuilder as t, PadroneProgressUpdate as tt, AnyPadroneCommand as u, InterceptorBaseContext as v, InterceptorFactory as w, InterceptorErrorResult as x, InterceptorDefBuilder as y, WithCommand as z };
1178
- //# sourceMappingURL=index-BaU3X6dY.d.mts.map
1195
+ export { PadroneProgressIndicator as $, InterceptorShutdownContext as A, WithCommand as B, InterceptorExecuteContext as C, InterceptorParseContext as D, InterceptorMeta as E, PadroneInterceptor as F, WrapResult as G, AsyncPadroneSchema as H, PadroneInterceptorFn as I, InteractiveMode as J, PadroneServePreferences as K, Drained as L, InterceptorValidateContext as M, InterceptorValidateResult as N, InterceptorParseResult as O, PadroneContextInterceptor as P, PadroneBarConfig as Q, PickCommandByName as R, InterceptorErrorResult as S, InterceptorFactory as T, PadroneSchema as U, WithInterceptor as V, WrapConfig as W, PadroneBarAnimation as X, InteractivePromptConfig as Y, PadroneBarChar as Z, ExtractInterceptorContext as _, PadroneExtension as a, PadroneSpinnerConfig as at, InterceptorDefBuilder as b, PadroneDrainResult as c, AnyPadroneCommand as d, PadroneProgressOptions as et, CommandTypesBase as f, PadroneProgramMeta as g, PadroneCommand as h, PadroneBuilder as i, PadroneSignal as it, InterceptorStartContext as j, InterceptorPhases as k, PadroneParseResult as l, PadroneActionContext as m, AnyPadroneProgram as n, PadroneProgressUpdate as nt, PadroneProgram as o, PadroneSpinnerPreset as ot, GetArgsMeta as p, PadroneMcpPreferences as q, DefineCommand as r, PadroneRuntime as rt, PadroneCommandResult as s, REPL_SIGINT as st, AnyPadroneBuilder as t, PadroneProgressShow as tt, PadroneReplPreferences as u, ExtractInterceptorRequires as v, InterceptorExecuteResult as w, InterceptorErrorContext as x, InterceptorBaseContext as y, PossibleCommands as z };
1196
+ //# sourceMappingURL=index-D6-7dz0l.d.mts.map