hacksh 0.16.0 → 0.18.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/README.md CHANGED
@@ -23,6 +23,7 @@ interactive input with `prompt`.
23
23
  - [Output formats](#output-formats)
24
24
  - [Programmatic API and errors](#programmatic-api-and-errors)
25
25
  - [Entry points](#entry-points)
26
+ - [Composable run functions](#composable-run-functions)
26
27
  - [Printers and events](#printers-and-events)
27
28
  - [Standalone parsing and help](#standalone-parsing-and-help)
28
29
  - [Errors](#errors)
@@ -129,6 +130,7 @@ const copy = defineCommand({
129
130
  }),
130
131
  run({ args }) {
131
132
  const [destination, ...files] = args.positionals; // [string, ...string[]]
133
+ return { destination, files };
132
134
  },
133
135
  });
134
136
  ```
@@ -346,6 +348,8 @@ context API to `node:child_process`, `spawnSync`, or a custom subprocess wrapper
346
348
  handler so execution uses the invocation’s environment, cancellation, and printer.
347
349
 
348
350
  ```ts
351
+ import { HackshExecError } from "hacksh";
352
+
349
353
  const check = defineCommand({
350
354
  name: "check-head",
351
355
  async run({ exec, logger }) {
@@ -359,7 +363,7 @@ const check = defineCommand({
359
363
  return;
360
364
  }
361
365
  // Missing executables, cancellation, and other failures must still fail the command.
362
- throw new Error("Could not inspect HEAD", { cause: head });
366
+ throw new HackshExecError("Could not inspect HEAD", head);
363
367
  }
364
368
  logger.info("HEAD is {commit}", { commit: head.stdout });
365
369
  },
@@ -482,8 +486,9 @@ holding the exact text, including the newline `println` adds, or
482
486
  pretty stdout, except that terminal control sequences are removed as in every JSON string. `json`
483
487
  values are normalized like log properties.
484
488
 
485
- hacksh never prints a `run` return value; it is returned to `runCommand` callers only. Output that
486
- was written before a failure stays written, and the error follows on stderr. Like logger calls,
489
+ hacksh never prints a `run` return value; it is returned to `runCommand` callers only.
490
+ `runMain` reports thrown `HackshError` instances on stderr and rethrows other exceptions.
491
+ Output that was written before a failure stays written. Like logger calls,
487
492
  `output` calls do not need to be awaited and are drained before execution finishes. Writing to
488
493
  `process.stdout` or `console.log` directly bypasses the printer, the output mode, and any `stdout`
489
494
  writer given to `runMain` or `runCommand`.
@@ -523,7 +528,7 @@ finishes. A printer failure rejects the invocation without changing a successful
523
528
 
524
529
  ### Interactive input
525
530
 
526
- Every `run` context has a `prompt` with `select`, `confirm`, and `text` methods. Interactive input
531
+ Every `run` context has a `prompt` with `select`, `autocomplete`, `confirm`, and `text` methods. Interactive input
527
532
  is separate from `logger`: prompts share the invocation's selected printer, serialized output queue,
528
533
  terminal lock, output mode, and abort signal.
529
534
 
@@ -557,15 +562,57 @@ uses `initialValue` when supplied and otherwise means no. Text displays its plac
557
562
  using it as input, supports editing, and repeats the prompt only when `validate` returns a nonempty
558
563
  message; `""` means valid. Backspace removes one Unicode code point. Input pasted after a selection
559
564
  or confirmation is retained for the next sequential prompt instead of being discarded.
560
- The built-in prompt API intentionally stops at select, confirm, and text; it does not provide a
561
- multiselect prompt.
565
+ The built-in prompt API does not provide a multiselect prompt.
566
+
567
+ Use `autocomplete` for a searchable single choice:
568
+
569
+ ```ts
570
+ const environment = await prompt.autocomplete({
571
+ message: "Environment",
572
+ placeholder: "Type to filter…",
573
+ options: [
574
+ { value: "production", label: "Production", priority: 20 },
575
+ { value: "staging", label: "Staging", hint: "safe default", priority: 10 },
576
+ ],
577
+ sortBy: (item) => item.priority,
578
+ }); // "production" | "staging"; displays Staging before Production
579
+ ```
580
+
581
+ Autocomplete filters labels (falling back to values) by case-insensitive substring,
582
+ preserving the configured option order rather than ranking matches. An empty query
583
+ shows all options, initially with none selected. Down enters selection at the first
584
+ match; Up/Down move without wrapping. Up at the first match or Escape returns to
585
+ editing. Typing or Backspace while selecting edits the query and returns to input.
586
+ Enter submits only a selected match; it does nothing while editing or with no matches.
587
+ Backspace removes one grapheme cluster. Escape while editing and Ctrl-C cancel.
588
+ The placeholder is display-only, reappears when the query becomes empty, and remains
589
+ until the terminal delivers committed input; OS IME composition is not observable.
590
+ The pretty printer anchors the real cursor at the input end, including wrapped input.
591
+
592
+ Both `select` and `autocomplete` accept `sortBy: (item) => string | number`. The
593
+ callback receives the complete inferred option item, including custom fields such
594
+ as `priority`; the prompt still returns only its `value`, preserving literal types.
595
+ Without `sortBy`, options retain their definition order. With it, keys are computed
596
+ once per option at prompt startup and sorted ascending, stably: equal keys retain
597
+ definition order, and the original array is never reordered. Autocomplete filtering
598
+ preserves this sorted order without recomputing keys. `initialValue` on select
599
+ chooses a value in the sorted list without changing that order.
600
+
601
+ Numeric keys use numeric order; strings use locale-independent UTF-16 lexical
602
+ order, not locale-aware collation or numeric-string ordering. All keys in one
603
+ prompt must have the same type. Invalid keys (including `NaN`) or mixed types
604
+ produce `HackshPromptError` with reason `invalid-options`; a thrown callback
605
+ produces `input-error` with the original error as `cause`.
606
+ Explicit option types take the whole item type, for example
607
+ `SelectOptions<{ value: "staging" | "production"; priority: number }>`.
562
608
 
563
609
  Prompts are allowed only when the resolved mode is interactive: pretty output outside CI with TTY
564
610
  stdin and stdout. JSON, CI, and non-TTY invocations throw `HackshPromptError` immediately even if a
565
611
  default is available. Its `reason` and `prompt` fields identify why input failed and the prompt's
566
- `kind`, `message`, and select `choices`. Reasons distinguish `non-interactive`, `cancelled`,
612
+ `kind`, `message`, and select/autocomplete `choices`. Reasons distinguish `non-interactive`, `cancelled`,
567
613
  `aborted`, `eof`, `overlapping`, `invalid-options`, `input-error`, and `printer-error`. Ctrl-C and
568
- Escape cancel; `runMain` reports cancellation and exits with status 130. A prompt that starts or is
614
+ Escape cancel (except Escape from autocomplete selection, which returns to editing);
615
+ `runMain` reports cancellation and exits with status 130. A prompt that starts or is
569
616
  waiting after the invocation's `signal` aborts fails with `aborted` and the signal's reason as its
570
617
  `cause`. Only one prompt may be active in an invocation. Input listeners and raw terminal mode are
571
618
  restored after every outcome.
@@ -606,14 +653,15 @@ later aborts the context's `signal`.
606
653
 
607
654
  `runMain` listens for `SIGINT` and `SIGTERM` while it runs and removes those listeners before it
608
655
  returns or exits. The first signal aborts the invocation with an `AbortError` named after the
609
- signal; once `run` settles, output is drained and the process exits with 130 for `SIGINT` or 143 for
610
- `SIGTERM`, even if `run` threw. A second signal while `run` is still pending exits immediately with
611
- that signal's status.
656
+ signal. When `run` returns, throws a `HackshError`, or rejects with that exact signal reason,
657
+ output is drained and the process exits with 130 for `SIGINT` or 143 for `SIGTERM`. Unrelated
658
+ exceptions and output failures still reject instead of being converted to a signal exit.
659
+ A second signal while the invocation is pending exits immediately with that signal's status.
612
660
 
613
661
  Throw `HackshExitError(exitCode, message?)` to choose the exit status, an integer from 0 to 255.
614
- `runMain` prints a non-empty message as an ordinary error and prints nothing when the message is
615
- omitted; `onError` still receives the error. `runCommand` rethrows it, so library callers read
616
- `exitCode` from the caught error. Other failures exit with 1, or 130 for a cancelled prompt.
662
+ `runMain` prints a non-empty message as an ordinary CLI error and prints nothing when the message
663
+ is omitted; `onError` still receives the error. `runCommand` rethrows it unchanged.
664
+ Other `HackshError` instances exit with 1, or 130 for a cancelled prompt.
617
665
 
618
666
  ## Output formats
619
667
 
@@ -621,10 +669,9 @@ omitted; `onError` still receives the error. `runCommand` rethrows it, so librar
621
669
  Their `output` option accepts `"auto"` (the default), `"pretty"`, or `"json"`. A valid
622
670
  `HACKSH_OUTPUT` environment value takes precedence over that option. `auto` selects JSON only when
623
671
  `CI` has a non-empty value; redirecting or piping stdout alone retains pretty output. Invalid
624
- explicit option or environment values never execute the command. `runCommand` rejects with a
625
- `TypeError`. `runMain` gives that error to `onError` when configured; otherwise it emits the error
626
- through a supplied printer or as a dedicated JSON error line, drains output, and exits with status
627
- code `1`. Output values are case-sensitive.
672
+ explicit option or environment values never execute the command. Both entry points reject with a
673
+ `TypeError`; `runMain` does not call `onError`, print a fallback error event, or force an exit.
674
+ Output values are case-sensitive.
628
675
 
629
676
  ```ts
630
677
  await runMain(main, { output: "auto" });
@@ -687,13 +734,19 @@ the semantic events that the command emits.
687
734
 
688
735
  ### Entry points
689
736
 
690
- `defineCommand` preserves the handler's return type. `runCommand(command, argv, options)` handles
691
- help and version output without exiting, throws errors to its caller, and returns a promise of the
692
- awaited handler result, unioned with results from every possible routed descendant and `undefined`
693
- for help/version. Routing-only commands add no handler result. Async and void handlers retain their
694
- result types; `runMain` deliberately discards results.
695
-
696
- `runMain(command)` reads `process.argv`, prints validation or usage errors, and exits with status 1.
737
+ `defineCommand` preserves the handler's exact return type. Handlers are ordinary functions that
738
+ return values or `void`, synchronously or asynchronously. `runCommand(command, argv, options)`
739
+ returns a promise of the awaited result, unioned with results from every possible routed
740
+ descendant and `undefined` for help/version. Routing-only commands add no handler result.
741
+ Thrown exceptions, argument errors, and output failures reject the promise. `runCommand` never
742
+ exits or automatically prints a return value or error.
743
+
744
+ `runMain(command)` reads `process.argv`, discards return values, and only handles thrown
745
+ `HackshError` instances as normal CLI failures. Other exceptions reject without automatic error
746
+ display, `onError`, or process exit. Pending output is drained and signal listeners are removed
747
+ on both success and rejection. Output failures also reject, including while reporting a CLI
748
+ error; they are not hidden by a forced exit. See
749
+ [Cancellation and exit status](#cancellation-and-exit-status) for exit codes.
697
750
  Use `argv` to inject arguments. Omitting it uses `process.argv.slice(2)`; an empty array is an
698
751
  explicit empty invocation. `runMain` returns `Promise<void>`. A reusable entry point is an ordinary
699
752
  local function:
@@ -708,18 +761,73 @@ await mainEntry([]); // explicitly supplies no arguments
708
761
 
709
762
  Help and the usage appended to validation or routing errors use the invocation's printer.
710
763
  Usage events target stdout for help and stderr for errors. Pass `onError` to replace the entire
711
- default error display, including usage; output written by this application callback remains its
712
- own responsibility:
764
+ default display of a `HackshError`, including usage. It receives the original error instance;
765
+ output written by this application callback remains its own responsibility. If the callback
766
+ throws or rejects, `runMain` drains output, removes its listeners, and rejects without exiting:
713
767
 
714
768
  ```ts
715
769
  await runMain(main, {
716
770
  argv: ["--help"],
717
771
  async onError(error) {
718
- console.error(`gh-pr-commits: ${error instanceof Error ? error.message : String(error)}`);
772
+ console.error(`gh-pr-commits: ${error.message}`);
719
773
  },
720
774
  });
721
775
  ```
722
776
 
777
+ ### Composable run functions
778
+
779
+ Use ordinary functions and `await`; no handler factory or result envelope is required.
780
+ Throw a `HackshError` subclass for an expected CLI failure. Catch only the specific failures
781
+ the caller can recover from and rethrow everything else:
782
+
783
+ ```ts
784
+ import { z } from "zod";
785
+ import { defineCommand, HackshError, type CommandContext } from "hacksh";
786
+
787
+ class AppError extends HackshError {}
788
+
789
+ class NotFoundError extends AppError {
790
+ readonly id: string;
791
+
792
+ constructor(id: string) {
793
+ super(`User ${id} was not found`);
794
+ this.id = id;
795
+ }
796
+ }
797
+
798
+ const users = new Map([["alice", { id: "alice", displayName: "Alice" }]]);
799
+
800
+ function loadUser(id: string) {
801
+ const user = users.get(id);
802
+ if (!user) throw new NotFoundError(id);
803
+ return user;
804
+ }
805
+
806
+ const schema = z.object({ id: z.string() });
807
+
808
+ function run({ args }: CommandContext<typeof schema>) {
809
+ try {
810
+ return loadUser(args.id);
811
+ } catch (error) {
812
+ if (error instanceof NotFoundError) {
813
+ return { id: error.id, displayName: "Guest" };
814
+ }
815
+ throw error;
816
+ }
817
+ }
818
+
819
+ const command = defineCommand({ args: schema, run });
820
+ ```
821
+
822
+ The context's `args` is the validated, transformed schema output, not raw argv. Domain functions
823
+ such as `loadUser` need not depend on `CommandContext`. Omit the recovery branch when an expected
824
+ failure should reach `runMain` and be displayed there.
825
+
826
+ `HackshError(message?, options?)` supports the standard `ErrorOptions.cause` and uses the concrete
827
+ subclass name as `error.name`. Application subclasses can add their own fields. A plain `Error`,
828
+ `TypeError`, or non-error thrown value is not classified as an expected CLI failure. Do not
829
+ blanket-wrap unknown exceptions in `HackshError`: doing so would hide that distinction.
830
+
723
831
  ### Printers and events
724
832
 
725
833
  The root `hacksh` entry exposes command-definition and execution APIs. Import printer factories,
@@ -790,6 +898,8 @@ await showUsage(main, {
790
898
 
791
899
  ### Errors
792
900
 
901
+ - `HackshError` — base class for expected CLI failures. Extend it for application-specific errors;
902
+ all error classes below inherit from it.
793
903
  - `HackshUsageError` — routing and usage failures (such as an unknown subcommand).
794
904
  - `HackshValidationError` — argument and option validation failures, whose `issues` identify CLI
795
905
  names such as `--repo` or `<PR>` and rejected unknown tokens in `issues[].arg`.
@@ -810,6 +920,17 @@ await showUsage(main, {
810
920
  | `vp run ready` | Run check, test, and build |
811
921
  | `pnpm test:packed` | Test the tarball with Node 22.18, host Node, and Deno |
812
922
 
923
+ The autocomplete API has PTY tests in `src/autocomplete-pty.test.ts`.
924
+ Run them with `pnpm test run src/autocomplete-pty.test.ts`. They launch
925
+ `src/fixtures/autocomplete-pty-cli.ts`, a CLI using the public `prompt.autocomplete`
926
+ API, and interpret its output with a headless terminal, checking visible choices,
927
+ placeholder transitions, cursor coordinates, and submission/cancellation cleanup.
928
+ For manual terminal verification, run `node src/fixtures/autocomplete-pty-cli.ts`.
929
+ Expected screens use indented multiline strings; ANSI handling stays in
930
+ `src/test-support/terminal.ts`. OS IME composition windows are outside this suite.
931
+ The development-only `node-pty` dependency requires Python and a C/C++ build
932
+ toolchain (Xcode Command Line Tools on macOS).
933
+
813
934
  The packed-consumer test must execute its Node consumer with exactly Node 22.18.0. Run pnpm itself
814
935
  under that version, or supply an absolute executable path explicitly:
815
936
 
@@ -79,7 +79,11 @@ interface HackshIssue {
79
79
  message: string;
80
80
  issue?: $ZodIssue;
81
81
  }
82
- declare class HackshUsageError extends Error {
82
+ /** An expected CLI failure that runMain reports; application errors can extend this class. */
83
+ declare class HackshError extends Error {
84
+ constructor(message?: string, options?: ErrorOptions);
85
+ }
86
+ declare class HackshUsageError extends HackshError {
83
87
  readonly command: AnyCommandDef;
84
88
  constructor(message: string, command: AnyCommandDef, options?: ErrorOptions);
85
89
  }
@@ -87,7 +91,7 @@ declare class HackshValidationError extends HackshUsageError {
87
91
  readonly issues: ReadonlyArray<HackshIssue>;
88
92
  constructor(command: AnyCommandDef, issues: ReadonlyArray<HackshIssue>);
89
93
  }
90
- type PromptKind = "select" | "confirm" | "text";
94
+ type PromptKind = "select" | "autocomplete" | "confirm" | "text";
91
95
  type HackshPromptErrorReason = "non-interactive" | "cancelled" | "aborted" | "eof" | "overlapping" | "invalid-options" | "input-error" | "printer-error";
92
96
  interface PromptErrorDetails {
93
97
  kind: PromptKind;
@@ -95,19 +99,19 @@ interface PromptErrorDetails {
95
99
  choices?: readonly string[];
96
100
  }
97
101
  /** An input request that could not be completed safely. */
98
- declare class HackshPromptError extends Error {
102
+ declare class HackshPromptError extends HackshError {
99
103
  readonly reason: HackshPromptErrorReason;
100
104
  readonly prompt: PromptErrorDetails;
101
105
  constructor(reason: HackshPromptErrorReason, prompt: PromptErrorDetails, message: string, options?: ErrorOptions);
102
106
  }
103
107
  /** An external command that did not succeed; `result` is not enumerable so error summaries omit child output. */
104
- declare class HackshExecError extends Error {
108
+ declare class HackshExecError extends HackshError {
105
109
  #private;
106
110
  constructor(message: string, result: ExecFailure, options?: ErrorOptions);
107
111
  get result(): ExecFailure;
108
112
  }
109
113
  /** A requested process exit status; `runMain` exits with it and reports only a non-empty message. */
110
- declare class HackshExitError extends Error {
114
+ declare class HackshExitError extends HackshError {
111
115
  readonly exitCode: number;
112
116
  constructor(exitCode: number, message?: string, options?: ErrorOptions);
113
117
  }
@@ -273,7 +277,15 @@ interface TextPromptState extends PromptStateBase {
273
277
  value: string;
274
278
  placeholder?: string;
275
279
  }
276
- type PromptState = SelectPromptState | ConfirmPromptState | TextPromptState;
280
+ interface AutocompletePromptState extends PromptStateBase {
281
+ kind: "autocomplete";
282
+ query: string;
283
+ placeholder?: string;
284
+ phase: "input" | "select";
285
+ choices: readonly PromptChoiceState[];
286
+ value?: string;
287
+ }
288
+ type PromptState = SelectPromptState | ConfirmPromptState | TextPromptState | AutocompletePromptState;
277
289
  interface PromptPrintEvent {
278
290
  type: "prompt";
279
291
  prompt: PromptState;
@@ -348,10 +360,16 @@ interface SelectOption<T extends string> {
348
360
  label?: string;
349
361
  hint?: string;
350
362
  }
351
- interface SelectOptions<T extends string> {
363
+ interface ChoiceOptions<TItem extends SelectOption<string>> {
352
364
  message: string;
353
- options: readonly SelectOption<T>[];
354
- initialValue?: T;
365
+ options: readonly TItem[];
366
+ sortBy?: (item: NoInfer<TItem>) => string | number;
367
+ }
368
+ interface SelectOptions<TItem extends SelectOption<string>> extends ChoiceOptions<TItem> {
369
+ initialValue?: NoInfer<TItem["value"]>;
370
+ }
371
+ interface AutocompleteOptions<TItem extends SelectOption<string>> extends ChoiceOptions<TItem> {
372
+ placeholder?: string;
355
373
  }
356
374
  interface ConfirmOptions {
357
375
  message: string;
@@ -363,7 +381,8 @@ interface TextOptions {
363
381
  validate?(value: string): string | undefined;
364
382
  }
365
383
  interface Prompter {
366
- select<const T extends string>(options: SelectOptions<T>): Promise<T>;
384
+ select<const TItem extends SelectOption<string>>(options: SelectOptions<TItem>): Promise<TItem["value"]>;
385
+ autocomplete<const TItem extends SelectOption<string>>(options: AutocompleteOptions<TItem>): Promise<TItem["value"]>;
367
386
  confirm(options: ConfirmOptions): Promise<boolean>;
368
387
  text(options: TextOptions): Promise<string>;
369
388
  }
@@ -410,7 +429,7 @@ interface CommandDef<S extends ArgsSchema = EmptyArgs, R = unknown, Children ext
410
429
  run?(context: CommandContext<S>): R;
411
430
  }
412
431
  type AnyCommandDef = CommandDef<ArgsSchema>;
413
- declare function defineCommand<S extends ArgsSchema = EmptyArgs, R = never, Children extends Record<string, AnyCommandDef> = {}>(def: CommandDef<S, R, Children>): CommandDef<S, NoInfer<R>, NoInfer<Children>>;
432
+ declare function defineCommand<S extends ArgsSchema = EmptyArgs, R = never, Children extends Record<string, AnyCommandDef> = {}>(def: CommandDef<S, R, Children>): NoInfer<CommandDef<S, R, Children>>;
414
433
  //#endregion
415
- export { HackshErrorSummary as $, SelectPromptState as A, UsageArgumentSummary as B, PrintStream as C, PromptState as D, PromptPrintEvent as E, UsagePrintEvent as F, showUsage as G, UsageOptionSummary as H, VersionPrintEvent as I, LogLevel as J, summarizeUsage as K, createJsonPrinter as L, TerminalInput as M, TerminalOutput as N, PromptStatus as O, TextPromptState as P, HackshErrorKind as Q, resolveOutputMode as R, PrintEvent as S, PromptChoiceState as T, UsageSummary as U, UsageCommandSummary as V, renderUsage as W, LogRecord as X, LogProperties as Y, Logger as Z, OutputFormat as _, ExecSkipped as _t, ArgsSchema as a, HackshUsageError as at, OutputPrintEvent as b, SelectOption as c, PromptKind as ct, Output as d, ExecCommand as dt, HackshExecError as et, ConfirmPromptState as f, ExecFailure as ft, LogPrintEvent as g, ExecReturn as gt, JsonPrinterOptions as h, ExecResult as ht, defineCommand as i, HackshPromptErrorReason as it, StreamColors as j, ResolveOutputModeOptions as k, SelectOptions as l, ValidationIssueSummary as lt, ExecPrintEvent as m, ExecOptions as mt, CommandContext as n, HackshIssue as nt, ConfirmOptions as o, HackshValidationError as ot, ErrorPrintEvent as p, ExecFailureReason as pt, LogKind as q, CommandDef as r, HackshPromptError as rt, Prompter as s, PromptErrorDetails as st, AnyCommandDef as t, HackshExitError as tt, TextOptions as u, Exec as ut, OutputMode as v, ExecSuccess as vt, Printer as w, OutputWriter as x, OutputPreference as y, ShowUsageOptions as z };
416
- //# sourceMappingURL=command-B-Ok_6KW.d.ts.map
434
+ export { Logger as $, PromptStatus as A, resolveOutputMode as B, OutputWriter as C, PromptChoiceState as D, Printer as E, TerminalOutput as F, UsageSummary as G, UsageArgumentSummary as H, TextPromptState as I, summarizeUsage as J, renderUsage as K, UsagePrintEvent as L, SelectPromptState as M, StreamColors as N, PromptPrintEvent as O, TerminalInput as P, LogRecord as Q, VersionPrintEvent as R, OutputPrintEvent as S, PrintStream as T, UsageCommandSummary as U, ShowUsageOptions as V, UsageOptionSummary as W, LogLevel as X, LogKind as Y, LogProperties as Z, JsonPrinterOptions as _, ExecOptions as _t, ArgsSchema as a, HackshIssue as at, OutputMode as b, ExecSkipped as bt, Prompter as c, HackshUsageError as ct, TextOptions as d, PromptKind as dt, HackshError as et, Output as f, ValidationIssueSummary as ft, ExecPrintEvent as g, ExecFailureReason as gt, ErrorPrintEvent as h, ExecFailure as ht, defineCommand as i, HackshExitError as it, ResolveOutputModeOptions as j, PromptState as k, SelectOption as l, HackshValidationError as lt, ConfirmPromptState as m, ExecCommand as mt, CommandContext as n, HackshErrorSummary as nt, AutocompleteOptions as o, HackshPromptError as ot, AutocompletePromptState as p, Exec as pt, showUsage as q, CommandDef as r, HackshExecError as rt, ConfirmOptions as s, HackshPromptErrorReason as st, AnyCommandDef as t, HackshErrorKind as tt, SelectOptions as u, PromptErrorDetails as ut, LogPrintEvent as v, ExecResult as vt, PrintEvent as w, OutputPreference as x, ExecSuccess as xt, OutputFormat as y, ExecReturn as yt, createJsonPrinter as z };
435
+ //# sourceMappingURL=command-Czf4qXhe.d.ts.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { G as showUsage, K as summarizeUsage, M as TerminalInput, N as TerminalOutput, W as renderUsage, Z as Logger, _t as ExecSkipped, a as ArgsSchema, at as HackshUsageError, c as SelectOption, ct as PromptKind, d as Output, dt as ExecCommand, et as HackshExecError, ft as ExecFailure, gt as ExecReturn, ht as ExecResult, i as defineCommand, it as HackshPromptErrorReason, l as SelectOptions, mt as ExecOptions, n as CommandContext, nt as HackshIssue, o as ConfirmOptions, ot as HackshValidationError, pt as ExecFailureReason, r as CommandDef, rt as HackshPromptError, s as Prompter, st as PromptErrorDetails, t as AnyCommandDef, tt as HackshExitError, u as TextOptions, ut as Exec, vt as ExecSuccess, w as Printer, y as OutputPreference, z as ShowUsageOptions } from "./command-B-Ok_6KW.js";
1
+ import { $ as Logger, E as Printer, F as TerminalOutput, J as summarizeUsage, K as renderUsage, P as TerminalInput, V as ShowUsageOptions, _t as ExecOptions, a as ArgsSchema, at as HackshIssue, bt as ExecSkipped, c as Prompter, ct as HackshUsageError, d as TextOptions, dt as PromptKind, et as HackshError, f as Output, gt as ExecFailureReason, ht as ExecFailure, i as defineCommand, it as HackshExitError, l as SelectOption, lt as HackshValidationError, mt as ExecCommand, n as CommandContext, o as AutocompleteOptions, ot as HackshPromptError, pt as Exec, q as showUsage, r as CommandDef, rt as HackshExecError, s as ConfirmOptions, st as HackshPromptErrorReason, t as AnyCommandDef, u as SelectOptions, ut as PromptErrorDetails, vt as ExecResult, x as OutputPreference, xt as ExecSuccess, yt as ExecReturn } from "./command-Czf4qXhe.js";
2
2
  import { output } from "zod/v4/core";
3
3
  //#region src/parser.d.ts
4
4
  /**
@@ -33,11 +33,11 @@ type CommandResult<C> = HandlerResult<C> | (C extends {
33
33
  } ? Children extends Record<string, AnyCommandDef> ? string extends keyof Children ? unknown : CommandResult<Children[keyof Children]> : never : never);
34
34
  declare function runCommand<C extends AnyCommandDef>(root: C, argv: string[], options?: RunCommandOptions): Promise<CommandResult<C> | undefined>;
35
35
  interface RunMainOptions extends OutputOptions {
36
- onError?: (error: unknown) => void | Promise<void>;
36
+ onError?: (error: HackshError) => void | Promise<void>;
37
37
  argv?: string[];
38
38
  printer?: Printer;
39
39
  }
40
40
  declare function runMain<S extends ArgsSchema>(command: CommandDef<S>, options?: RunMainOptions): Promise<void>;
41
41
  //#endregion
42
- export { type CommandContext, type CommandDef, type ConfirmOptions, type Exec, type ExecCommand, type ExecFailure, type ExecFailureReason, type ExecOptions, type ExecResult, type ExecReturn, type ExecSkipped, type ExecSuccess, HackshExecError, HackshExitError, type HackshIssue, HackshPromptError, type HackshPromptErrorReason, HackshUsageError, HackshValidationError, type Logger, type Output, type OutputOptions, type PromptErrorDetails, type PromptKind, type Prompter, type RunCommandOptions, type RunMainOptions, type SelectOption, type SelectOptions, type ShowUsageOptions, type TextOptions, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage, summarizeUsage };
42
+ export { type AutocompleteOptions, type CommandContext, type CommandDef, type ConfirmOptions, type Exec, type ExecCommand, type ExecFailure, type ExecFailureReason, type ExecOptions, type ExecResult, type ExecReturn, type ExecSkipped, type ExecSuccess, HackshError, HackshExecError, HackshExitError, type HackshIssue, HackshPromptError, type HackshPromptErrorReason, HackshUsageError, HackshValidationError, type Logger, type Output, type OutputOptions, type PromptErrorDetails, type PromptKind, type Prompter, type RunCommandOptions, type RunMainOptions, type SelectOption, type SelectOptions, type ShowUsageOptions, type TextOptions, defineCommand, parseArgs, renderUsage, runCommand, runMain, showUsage, summarizeUsage };
43
43
  //# sourceMappingURL=index.d.ts.map