hacksh 0.3.0 → 0.4.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
@@ -7,6 +7,12 @@ The name comes from 拍手 (_hakushu_), the Japanese word for "clap", as a nod t
7
7
  [clap](https://github.com/clap-rs/clap), the command-line argument parser for Rust. It is spelled
8
8
  with _hack_ and _sh_, as in shell.
9
9
 
10
+ hacksh draws heavily on [Citty](https://github.com/unjs/citty) for its command API design and
11
+ [Clack](https://github.com/bombshell-dev/clack) for its interactive prompts and terminal output.
12
+ Many thanks to both projects and their contributors. hacksh uses Zod schemas for argument validation
13
+ and type inference, including tuples for positional arguments; it does not guarantee API or behavior
14
+ compatibility with Citty or Clack.
15
+
10
16
  ## Install
11
17
 
12
18
  ```sh
@@ -374,7 +380,7 @@ wrappers and the later presentation or prompting layers.
374
380
 
375
381
  For parsing and usage rendering without execution, use the async composition APIs. `parseArgs`
376
382
  parses exactly the supplied command definition and argument segment, returns its schema output only,
377
- and throws `ZittyValidationError` on failure. It does not route subcommands, act on help or version
383
+ and throws `HackshValidationError` on failure. It does not route subcommands, act on help or version
378
384
  tokens, or bypass validation; callers that resolve commands themselves must pass the selected
379
385
  command and its segment. `renderUsage` has no output side effects; `showUsage` sends that same text
380
386
  through an explicit printer or the same automatic pretty/JSON selection used by command
@@ -432,8 +438,8 @@ await runMain(main, {
432
438
  });
433
439
  ```
434
440
 
435
- Usage failures are `ZittyUsageError` instances. Argument failures are
436
- `ZittyValidationError` instances whose `issues` identify CLI names such as `--repo` or `<PR>`.
441
+ Usage failures are `HackshUsageError` instances. Argument failures are
442
+ `HackshValidationError` instances whose `issues` identify CLI names such as `--repo` or `<PR>`.
437
443
  Prompt failures are `HackshPromptError` instances with structured `reason` and `prompt` fields.
438
444
 
439
445
  ## Development
@@ -451,5 +457,5 @@ The packed-consumer test must execute its Node consumer with exactly Node 22.18.
451
457
  under that version, or supply an absolute executable path explicitly:
452
458
 
453
459
  ```sh
454
- ZITTY_MINIMUM_NODE=/absolute/path/to/node-v22.18.0 pnpm test:packed
460
+ HACKSH_MINIMUM_NODE=/absolute/path/to/node-v22.18.0 pnpm test:packed
455
461
  ```
package/dist/index.d.ts CHANGED
@@ -1,17 +1,17 @@
1
1
  import { $ZodIssue, $ZodObject, output } from "zod/v4/core";
2
2
  //#region src/errors.d.ts
3
- interface ZittyIssue {
3
+ interface HackshIssue {
4
4
  arg: string;
5
5
  message: string;
6
6
  issue?: $ZodIssue;
7
7
  }
8
- declare class ZittyUsageError extends Error {
8
+ declare class HackshUsageError extends Error {
9
9
  readonly command: AnyCommandDef;
10
10
  constructor(message: string, command: AnyCommandDef, options?: ErrorOptions);
11
11
  }
12
- declare class ZittyValidationError extends ZittyUsageError {
13
- readonly issues: ReadonlyArray<ZittyIssue>;
14
- constructor(command: AnyCommandDef, issues: ReadonlyArray<ZittyIssue>);
12
+ declare class HackshValidationError extends HackshUsageError {
13
+ readonly issues: ReadonlyArray<HackshIssue>;
14
+ constructor(command: AnyCommandDef, issues: ReadonlyArray<HackshIssue>);
15
15
  }
16
16
  type PromptKind = "select" | "confirm" | "text";
17
17
  type HackshPromptErrorReason = "non-interactive" | "cancelled" | "eof" | "overlapping" | "invalid-options" | "input-error" | "printer-error";
@@ -332,5 +332,5 @@ interface RunMainOptions extends OutputOptions {
332
332
  declare function runMain<S extends ArgsSchema>(command: CommandDef<S>, options?: RunMainOptions): Promise<void>;
333
333
  declare function createMain<S extends ArgsSchema>(command: CommandDef<S>, options?: RunMainOptions): (argv?: string[]) => Promise<void>;
334
334
  //#endregion
335
- export { type ArgOptions, type ArgOptionsMap, type CommandContext, type CommandDef, type ConfirmOptions, type ConfirmPromptState, type ErrorPrintEvent, type HackshErrorKind, type HackshErrorSummary, HackshPromptError, type HackshPromptErrorReason, type JsonPrinterOptions, type LogKind, type LogLevel, type LogPrintEvent, type LogProperties, type LogRecord, type Logger, type OutputFormat, type OutputMode, type OutputOptions, type OutputPreference, type OutputWriter, type PrettyPrinterOptions, type PrintEvent, type PrintStream, type Printer, type PromptChoiceState, type PromptErrorDetails, type PromptKind, type PromptPrintEvent, type PromptState, type PromptStatus, type Prompter, type ResolveOutputModeOptions, type RunCommandOptions, type RunMainOptions, type SelectOption, type SelectOptions, type SelectPromptState, type ShowUsageCallback, type ShowUsageOptions, type StreamPrinterOptions, type TerminalInput, type TerminalOutput, type TextOptions, type TextPromptState, type UsageArgumentSummary, type UsageCommandSummary, type UsageOptionSummary, type UsageOutput, type UsagePrintEvent, type UsageSummary, type UsageWriter, type ValidationIssueSummary, type VersionPrintEvent, type ZittyIssue, ZittyUsageError, ZittyValidationError, consolePrinter, createJsonPrinter, createMain, createPrettyPrinter, createStreamPrinter, defineCommand, parseArgs, renderUsage, resolveOutputMode, runCommand, runMain, showUsage, summarizeUsage };
335
+ export { type ArgOptions, type ArgOptionsMap, type CommandContext, type CommandDef, type ConfirmOptions, type ConfirmPromptState, type ErrorPrintEvent, type HackshErrorKind, type HackshErrorSummary, type HackshIssue, HackshPromptError, type HackshPromptErrorReason, HackshUsageError, HackshValidationError, type JsonPrinterOptions, type LogKind, type LogLevel, type LogPrintEvent, type LogProperties, type LogRecord, type Logger, type OutputFormat, type OutputMode, type OutputOptions, type OutputPreference, type OutputWriter, type PrettyPrinterOptions, type PrintEvent, type PrintStream, type Printer, type PromptChoiceState, type PromptErrorDetails, type PromptKind, type PromptPrintEvent, type PromptState, type PromptStatus, type Prompter, type ResolveOutputModeOptions, type RunCommandOptions, type RunMainOptions, type SelectOption, type SelectOptions, type SelectPromptState, type ShowUsageCallback, type ShowUsageOptions, type StreamPrinterOptions, type TerminalInput, type TerminalOutput, type TextOptions, type TextPromptState, type UsageArgumentSummary, type UsageCommandSummary, type UsageOptionSummary, type UsageOutput, type UsagePrintEvent, type UsageSummary, type UsageWriter, type ValidationIssueSummary, type VersionPrintEvent, consolePrinter, createJsonPrinter, createMain, createPrettyPrinter, createStreamPrinter, defineCommand, parseArgs, renderUsage, resolveOutputMode, runCommand, runMain, showUsage, summarizeUsage };
336
336
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -130,19 +130,19 @@ function defineCommand(def) {
130
130
  }
131
131
  //#endregion
132
132
  //#region src/errors.ts
133
- var ZittyUsageError = class extends Error {
133
+ var HackshUsageError = class extends Error {
134
134
  command;
135
135
  constructor(message, command, options) {
136
136
  super(message, options);
137
- this.name = "ZittyUsageError";
137
+ this.name = "HackshUsageError";
138
138
  this.command = command;
139
139
  }
140
140
  };
141
- var ZittyValidationError = class extends ZittyUsageError {
141
+ var HackshValidationError = class extends HackshUsageError {
142
142
  issues;
143
143
  constructor(command, issues) {
144
144
  super(`Invalid arguments:\n${issues.map(({ arg, message }) => ` ${arg}: ${message}`).join("\n")}`, command);
145
- this.name = "ZittyValidationError";
145
+ this.name = "HackshValidationError";
146
146
  this.issues = issues;
147
147
  }
148
148
  };
@@ -220,8 +220,8 @@ function summarizeIssue({ arg, message, issue }, seen) {
220
220
  }
221
221
  function errorKind(error) {
222
222
  if (error instanceof HackshPromptError) return "prompt";
223
- if (error instanceof ZittyValidationError) return "validation";
224
- if (error instanceof ZittyUsageError) return "usage";
223
+ if (error instanceof HackshValidationError) return "validation";
224
+ if (error instanceof HackshUsageError) return "usage";
225
225
  return "error";
226
226
  }
227
227
  function summarizeErrorWithSeen(error, seen) {
@@ -235,7 +235,7 @@ function summarizeErrorWithSeen(error, seen) {
235
235
  const cause = readProperty(error, "cause");
236
236
  if (typeof stack === "string") summary.stack = stack;
237
237
  if (cause !== void 0) summary.cause = summarizeErrors(cause, seen);
238
- if (error instanceof ZittyValidationError) summary.issues = error.issues.map((issue) => summarizeIssue(issue, seen));
238
+ if (error instanceof HackshValidationError) summary.issues = error.issues.map((issue) => summarizeIssue(issue, seen));
239
239
  const reserved = /* @__PURE__ */ new Set([
240
240
  "name",
241
241
  "message",
@@ -508,7 +508,7 @@ function zodIssues(command, issues) {
508
508
  }));
509
509
  }
510
510
  async function parseCommandArgs(command, rawArgs, tokenized = tokenizeCommandArgs(command, rawArgs)) {
511
- if (tokenized.issues.length > 0) throw new ZittyValidationError(command, tokenized.issues.map(({ issue }) => issue));
511
+ if (tokenized.issues.length > 0) throw new HackshValidationError(command, tokenized.issues.map(({ issue }) => issue));
512
512
  const input = {};
513
513
  const positionals = commandPositionals(command);
514
514
  const positionalValues = [];
@@ -524,7 +524,7 @@ async function parseCommandArgs(command, rawArgs, tokenized = tokenizeCommandArg
524
524
  extraArgs
525
525
  };
526
526
  const result = await safeParseAsync(command.args, input);
527
- if (!result.success) throw new ZittyValidationError(command, zodIssues(command, result.error.issues));
527
+ if (!result.success) throw new HackshValidationError(command, zodIssues(command, result.error.issues));
528
528
  return {
529
529
  args: result.data,
530
530
  passthrough: tokenized.passthrough,
@@ -1493,7 +1493,7 @@ function resolveCommand(root, rawArgs) {
1493
1493
  }
1494
1494
  const name = remaining[index];
1495
1495
  const child = command.subCommands?.[name];
1496
- if (!child) throw new ZittyUsageError(`Unknown command \`${name}\``, command);
1496
+ if (!child) throw new HackshUsageError(`Unknown command \`${name}\``, command);
1497
1497
  const prefix = remaining.slice(0, index);
1498
1498
  const segment = {
1499
1499
  command,
@@ -1521,7 +1521,7 @@ async function executeCommand(root, argv, displayUsage, printer, loggerOptions)
1521
1521
  }
1522
1522
  for (const parent of resolved.parents) await parseCommandArgs(parent.command, parent.rawArgs, parent.tokenized);
1523
1523
  const parsed = await parseCommandArgs(resolved.command, resolved.rawArgs, resolved.tokenized);
1524
- if (!resolved.command.run) throw new ZittyUsageError("No command specified", resolved.command);
1524
+ if (!resolved.command.run) throw new HackshUsageError("No command specified", resolved.command);
1525
1525
  const category = resolved.segments.flatMap(({ command }) => command.name === void 0 ? [] : [command.name]);
1526
1526
  return resolved.command.run({
1527
1527
  ...parsed,
@@ -1609,7 +1609,7 @@ async function runMain(command, options = {}) {
1609
1609
  return drainAndExit(output, commandErrorExitCode(error));
1610
1610
  }
1611
1611
  try {
1612
- if (error instanceof ZittyUsageError) {
1612
+ if (error instanceof HackshUsageError) {
1613
1613
  await output.printer.print({
1614
1614
  type: "error",
1615
1615
  error: summarizeError(error)
@@ -1632,6 +1632,6 @@ function createMain(command, options = {}) {
1632
1632
  });
1633
1633
  }
1634
1634
  //#endregion
1635
- export { HackshPromptError, ZittyUsageError, ZittyValidationError, consolePrinter, createJsonPrinter, createMain, createPrettyPrinter, createStreamPrinter, defineCommand, parseArgs, renderUsage, resolveOutputMode, runCommand, runMain, showUsage, summarizeUsage };
1635
+ export { HackshPromptError, HackshUsageError, HackshValidationError, consolePrinter, createJsonPrinter, createMain, createPrettyPrinter, createStreamPrinter, defineCommand, parseArgs, renderUsage, resolveOutputMode, runCommand, runMain, showUsage, summarizeUsage };
1636
1636
 
1637
1637
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["safeString","parseNodeArgs","details","#interactive","#inputValue","#printEvent","#bufferedKeys","#print","#run","#active"],"sources":["../src/options.ts","../src/schema.ts","../src/command.ts","../src/errors.ts","../src/parser.ts","../src/serialization.ts","../src/printer.ts","../src/pretty.ts","../src/prompts.ts","../src/logger.ts","../src/output.ts","../src/usage.ts","../src/run.ts"],"sourcesContent":["export function kebabCase(value: string): string {\n return value.replaceAll(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\nexport function aliasList(value: string | readonly string[]): readonly string[] {\n return typeof value === \"string\" ? [value] : value;\n}\n","import { globalRegistry, type $ZodObject, type $ZodType } from \"zod/v4/core\";\n\nexport type ArgsSchema = $ZodObject;\nexport type EmptyArgs = $ZodObject<{}>;\nexport type ShapeOf<S extends ArgsSchema> = S[\"_zod\"][\"def\"][\"shape\"];\nexport type ArgKey<S extends ArgsSchema> = Extract<keyof ShapeOf<S>, string>;\nexport type OptionKey<S extends ArgsSchema> = Exclude<ArgKey<S>, typeof POSITIONALS_KEY>;\n\nexport const POSITIONALS_KEY = \"_\";\n\nexport interface ArgInfo {\n readonly takesValue: boolean;\n readonly required: boolean;\n readonly defaultValue: unknown;\n readonly description: string | undefined;\n readonly title: string | undefined;\n readonly choices: readonly string[] | undefined;\n}\n\nexport interface Positional {\n readonly schema: $ZodType;\n readonly label: string;\n}\n\nexport interface Positionals {\n readonly items: readonly Positional[];\n readonly rest: Positional | undefined;\n}\n\ntype ZodDef = Record<string, unknown> & { type: string };\n\nfunction definition(schema: $ZodType): ZodDef {\n return schema._zod.def as ZodDef;\n}\n\nfunction innerSchema(def: ZodDef): $ZodType | undefined {\n switch (def.type) {\n case \"optional\":\n case \"nonoptional\":\n case \"nullable\":\n case \"default\":\n case \"prefault\":\n case \"catch\":\n case \"readonly\":\n return def.innerType as $ZodType;\n case \"pipe\":\n return def.in as $ZodType;\n default:\n return undefined;\n }\n}\n\n/** Read only the common zod/v4/core definition and registry structures. */\nexport function readArgInfo(schema: $ZodType): ArgInfo {\n let current: $ZodType | undefined = schema;\n let required = true;\n let defaultValue: unknown;\n let description: string | undefined;\n let title: string | undefined;\n\n while (current) {\n const metadata = globalRegistry.get(current);\n description ??= metadata?.description;\n title ??= metadata?.title;\n\n const def = definition(current);\n if (def.type === \"optional\" || def.type === \"default\" || def.type === \"prefault\") {\n required = false;\n }\n if (def.type === \"default\" && defaultValue === undefined) defaultValue = def.defaultValue;\n current = innerSchema(def);\n }\n\n const base = unwrapInput(schema);\n return {\n takesValue: definition(base).type !== \"boolean\",\n required,\n defaultValue,\n description,\n title,\n choices: enumChoices(base),\n };\n}\n\n/** Read the `_` tuple or array schema that declares positional arguments. */\nexport function readPositionals(shape: Record<string, $ZodType>): Positionals | undefined {\n const field = shape[POSITIONALS_KEY];\n if (!field) return undefined;\n const def = definition(unwrapInput(field));\n let items: readonly $ZodType[];\n let rest: $ZodType | undefined;\n if (def.type === \"tuple\") {\n items = def.items as readonly $ZodType[];\n rest = (def.rest as $ZodType | null) ?? undefined;\n } else if (def.type === \"array\") {\n items = [];\n rest = def.element as $ZodType;\n } else {\n throw new TypeError(\"Positional arguments `_` must use a tuple or array schema\");\n }\n return {\n items: items.map((schema, index) => ({\n schema,\n label: readArgInfo(schema).title ?? `ARG${index + 1}`,\n })),\n rest: rest && { schema: rest, label: readArgInfo(rest).title ?? \"ARGS\" },\n };\n}\n\nfunction enumChoices(schema: $ZodType): readonly string[] | undefined {\n const def = definition(schema);\n const candidate = def.type === \"array\" ? unwrapInput(def.element as $ZodType) : schema;\n const candidateDef = definition(candidate);\n if (candidateDef.type !== \"enum\") return undefined;\n const values = candidate._zod.values;\n return values ? [...values].map(String) : undefined;\n}\n\n/** Whether the schema accepts an array after removing supported input wrappers. */\nexport function isArrayInput(schema: $ZodType): boolean {\n return definition(unwrapInput(schema)).type === \"array\";\n}\n\nfunction unwrapInput(schema: $ZodType): $ZodType {\n let current = schema;\n for (;;) {\n const inner = innerSchema(definition(current));\n if (!inner) return current;\n current = inner;\n }\n}\n\nexport function schemaShape(schema: ArgsSchema): Record<string, $ZodType> {\n return schema._zod.def.shape as Record<string, $ZodType>;\n}\n","import type { output } from \"zod/v4/core\";\nimport type { Logger } from \"./logger.ts\";\nimport { aliasList } from \"./options.ts\";\nimport {\n isArrayInput,\n POSITIONALS_KEY,\n readArgInfo,\n readPositionals,\n schemaShape,\n type ArgsSchema,\n type EmptyArgs,\n type OptionKey,\n} from \"./schema.ts\";\n\nexport interface ArgOptions {\n alias?: string | readonly string[];\n valueName?: string;\n}\n\nexport type ArgOptionsMap<S extends ArgsSchema> = Partial<Record<OptionKey<S>, ArgOptions>>;\n\nexport interface CommandContext<S extends ArgsSchema> {\n cmd: CommandDef<S>;\n args: output<S>;\n rawArgs: string[];\n passthrough: string[];\n extraArgs: string[];\n logger: Logger;\n}\n\nexport interface CommandDef<S extends ArgsSchema = EmptyArgs> {\n name?: string;\n version?: string;\n description?: string;\n hidden?: boolean;\n args?: S;\n argOptions?: ArgOptionsMap<S>;\n subCommands?: Record<string, CommandDef<ArgsSchema>>;\n run?(context: CommandContext<S>): unknown;\n}\n\nexport type AnyCommandDef = CommandDef<ArgsSchema>;\n\nexport function defineCommand<S extends ArgsSchema = EmptyArgs>(def: CommandDef<S>): CommandDef<S> {\n const shape = def.args ? schemaShape(def.args) : {};\n const positionals = readPositionals(shape);\n\n if (positionals) {\n let sawOptional = false;\n for (const { schema, label } of positionals.items) {\n const info = readArgInfo(schema);\n if (isArrayInput(schema)) {\n throw new TypeError(\n `Positional argument \\`${label}\\` cannot be an array; use a tuple rest`,\n );\n }\n if (!info.takesValue) {\n throw new TypeError(`Boolean argument \\`${label}\\` cannot be positional`);\n }\n if (sawOptional && info.required) {\n throw new TypeError(\n `Required positional \\`${label}\\` cannot follow an optional positional`,\n );\n }\n sawOptional ||= !info.required;\n }\n if (def.subCommands && Object.keys(def.subCommands).length > 0) {\n throw new TypeError(\"A command cannot define both positional arguments and subcommands\");\n }\n }\n\n const usedAliases = new Set<string>();\n for (const [key, options] of Object.entries(def.argOptions ?? {})) {\n if (key === POSITIONALS_KEY) {\n throw new TypeError(\"Positional arguments cannot have argument options\");\n }\n if (!shape[key]) throw new TypeError(`Unknown argument options key \\`${key}\\``);\n if (options?.alias === undefined) continue;\n for (const alias of aliasList(options.alias)) {\n if (alias.length !== 1)\n throw new TypeError(`Alias \\`${alias}\\` must be exactly one character`);\n if (usedAliases.has(alias)) throw new TypeError(`Duplicate alias \\`${alias}\\``);\n usedAliases.add(alias);\n }\n }\n\n for (const key of Object.keys(shape)) {\n if (key !== POSITIONALS_KEY && /^no[-A-Z]/.test(key)) {\n throw new TypeError(`Option \\`${key}\\` conflicts with --no- negation`);\n }\n }\n\n return def;\n}\n","import type { $ZodIssue } from \"zod/v4/core\";\nimport type { AnyCommandDef } from \"./command.ts\";\n\nexport interface ZittyIssue {\n arg: string;\n message: string;\n issue?: $ZodIssue;\n}\n\nexport class ZittyUsageError extends Error {\n readonly command: AnyCommandDef;\n\n constructor(message: string, command: AnyCommandDef, options?: ErrorOptions) {\n super(message, options);\n this.name = \"ZittyUsageError\";\n this.command = command;\n }\n}\n\nexport class ZittyValidationError extends ZittyUsageError {\n readonly issues: ReadonlyArray<ZittyIssue>;\n\n constructor(command: AnyCommandDef, issues: ReadonlyArray<ZittyIssue>) {\n super(\n `Invalid arguments:\\n${issues.map(({ arg, message }) => ` ${arg}: ${message}`).join(\"\\n\")}`,\n command,\n );\n this.name = \"ZittyValidationError\";\n this.issues = issues;\n }\n}\n\nexport type PromptKind = \"select\" | \"confirm\" | \"text\";\n\nexport type HackshPromptErrorReason =\n | \"non-interactive\"\n | \"cancelled\"\n | \"eof\"\n | \"overlapping\"\n | \"invalid-options\"\n | \"input-error\"\n | \"printer-error\";\n\nexport interface PromptErrorDetails {\n kind: PromptKind;\n message: string;\n choices?: readonly string[];\n}\n\n/** An input request that could not be completed safely. */\nexport class HackshPromptError extends Error {\n readonly reason: HackshPromptErrorReason;\n readonly prompt: PromptErrorDetails;\n\n constructor(\n reason: HackshPromptErrorReason,\n prompt: PromptErrorDetails,\n message: string,\n options?: ErrorOptions,\n ) {\n super(message, options);\n this.name = \"HackshPromptError\";\n this.reason = reason;\n this.prompt = prompt;\n }\n}\n\nexport type HackshErrorKind = \"error\" | \"prompt\" | \"usage\" | \"validation\" | \"thrown\";\n\nexport interface ValidationIssueSummary {\n arg: string;\n message: string;\n code?: string;\n path?: readonly PropertyKey[];\n details?: Readonly<Record<string, unknown>>;\n}\n\nexport interface HackshErrorSummary {\n kind: HackshErrorKind;\n name: string;\n message: string;\n stack?: string;\n cause?: unknown;\n issues?: readonly ValidationIssueSummary[];\n properties?: Readonly<Record<string, unknown>>;\n value?: unknown;\n}\n\nfunction safeString(value: unknown, fallback: string): string {\n try {\n return String(value);\n } catch {\n return fallback;\n }\n}\n\nfunction readProperty(value: object, key: PropertyKey): unknown {\n try {\n return Reflect.get(value, key);\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction enumerableKeys(value: object): string[] {\n try {\n return Object.keys(value);\n } catch {\n return [];\n }\n}\n\nfunction hasToJSON(value: object): boolean {\n try {\n return typeof Reflect.get(value, \"toJSON\") === \"function\";\n } catch {\n return false;\n }\n}\n\nfunction isPlainObject(value: object): boolean {\n try {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n } catch {\n return false;\n }\n}\n\nfunction summarizeIssue(\n { arg, message, issue }: ZittyIssue,\n seen: WeakMap<object, unknown>,\n): ValidationIssueSummary {\n if (!issue) return { arg, message };\n const details: Record<string, unknown> = {};\n for (const key of enumerableKeys(issue)) {\n if ([\"code\", \"path\", \"message\", \"inst\"].includes(key)) continue;\n details[key] = summarizeErrors(readProperty(issue, key), seen);\n }\n const code = readProperty(issue, \"code\");\n const path = readProperty(issue, \"path\");\n return {\n arg,\n message,\n ...(typeof code === \"string\" ? { code } : {}),\n ...(Array.isArray(path) ? { path } : {}),\n ...(Object.keys(details).length === 0 ? {} : { details }),\n };\n}\n\nfunction errorKind(error: Error): HackshErrorKind {\n if (error instanceof HackshPromptError) return \"prompt\";\n if (error instanceof ZittyValidationError) return \"validation\";\n if (error instanceof ZittyUsageError) return \"usage\";\n return \"error\";\n}\n\nfunction summarizeErrorWithSeen(error: Error, seen: WeakMap<object, unknown>): HackshErrorSummary {\n const summary: HackshErrorSummary = {\n kind: errorKind(error),\n name: safeString(readProperty(error, \"name\"), \"Error\"),\n message: safeString(readProperty(error, \"message\"), \"[Unserializable error message]\"),\n };\n seen.set(error, summary);\n\n const stack = readProperty(error, \"stack\");\n const cause = readProperty(error, \"cause\");\n if (typeof stack === \"string\") summary.stack = stack;\n if (cause !== undefined) summary.cause = summarizeErrors(cause, seen);\n if (error instanceof ZittyValidationError) {\n summary.issues = error.issues.map((issue) => summarizeIssue(issue, seen));\n }\n\n const reserved = new Set([\"name\", \"message\", \"stack\", \"cause\", \"command\", \"issues\"]);\n const properties: Record<string, unknown> = {};\n for (const key of enumerableKeys(error)) {\n if (reserved.has(key)) continue;\n properties[key] = summarizeErrors(readProperty(error, key), seen);\n }\n if (Object.keys(properties).length > 0) summary.properties = properties;\n return summary;\n}\n\n/** Recursively replace Error values with command- and schema-free summaries. */\nexport function summarizeErrors(\n value: unknown,\n seen: WeakMap<object, unknown> = new WeakMap(),\n): unknown {\n if (typeof value !== \"object\" || value === null) return value;\n const existing = seen.get(value);\n if (existing !== undefined) return existing;\n if (value instanceof Error) return summarizeErrorWithSeen(value, seen);\n\n if (Array.isArray(value)) {\n const result: unknown[] = [];\n seen.set(value, result);\n let changed = false;\n for (const item of value) {\n const summarized = summarizeErrors(item, seen);\n result.push(summarized);\n changed ||= summarized !== item;\n }\n if (changed) return result;\n seen.set(value, value);\n return value;\n }\n if (value instanceof Map) {\n const result = new Map<unknown, unknown>();\n seen.set(value, result);\n let changed = false;\n for (const [key, item] of value) {\n const summarizedKey = summarizeErrors(key, seen);\n const summarizedItem = summarizeErrors(item, seen);\n result.set(summarizedKey, summarizedItem);\n changed ||= summarizedKey !== key || summarizedItem !== item;\n }\n if (changed) return result;\n seen.set(value, value);\n return value;\n }\n if (value instanceof Set) {\n const result = new Set<unknown>();\n seen.set(value, result);\n let changed = false;\n for (const item of value) {\n const summarized = summarizeErrors(item, seen);\n result.add(summarized);\n changed ||= summarized !== item;\n }\n if (changed) return result;\n seen.set(value, value);\n return value;\n }\n if (ArrayBuffer.isView(value) || hasToJSON(value) || !isPlainObject(value)) return value;\n\n const result: Record<string, unknown> = {};\n seen.set(value, result);\n let changed = false;\n for (const key of enumerableKeys(value)) {\n const original = readProperty(value, key);\n const summarized = summarizeErrors(original, seen);\n result[key] = summarized;\n changed ||= summarized !== original;\n }\n if (changed) return result;\n seen.set(value, value);\n return value;\n}\n\n/** Convert any thrown value into a canonical error description. */\nexport function summarizeError(error: unknown): HackshErrorSummary {\n if (error instanceof Error) return summarizeErrorWithSeen(error, new WeakMap());\n return {\n kind: \"thrown\",\n name: \"NonErrorThrown\",\n message: safeString(error, \"[Unserializable thrown value]\"),\n value: summarizeErrors(error),\n };\n}\n","import { parseArgs as parseNodeArgs } from \"node:util\";\nimport { safeParseAsync, type $ZodIssue, type output } from \"zod/v4/core\";\nimport type { AnyCommandDef, CommandDef } from \"./command.ts\";\nimport { ZittyValidationError, type ZittyIssue } from \"./errors.ts\";\nimport { aliasList, kebabCase } from \"./options.ts\";\nimport {\n POSITIONALS_KEY,\n readArgInfo,\n readPositionals,\n schemaShape,\n type ArgsSchema,\n type Positionals,\n} from \"./schema.ts\";\n\nexport interface ParsedCommand<S extends ArgsSchema> {\n args: output<S>;\n passthrough: string[];\n extraArgs: string[];\n}\n\ninterface OptionDefinition {\n readonly key: string;\n readonly kebabName: string;\n readonly takesValue: boolean;\n}\n\ninterface OptionModel {\n readonly definitions: Map<string, OptionDefinition>;\n readonly parserOptions: Record<string, { type: \"string\" | \"boolean\"; short?: string }>;\n readonly aliases: Set<string>;\n}\n\ninterface KnownOptionToken {\n readonly kind: \"known-option\";\n readonly index: number;\n readonly definition: OptionDefinition;\n readonly value: string | boolean;\n}\n\ninterface UnknownOptionToken {\n readonly kind: \"unknown-option\";\n readonly index: number;\n readonly value: string;\n}\n\ninterface PositionalToken {\n readonly kind: \"positional\";\n readonly index: number;\n readonly value: string;\n}\n\ntype CommandToken = KnownOptionToken | UnknownOptionToken | PositionalToken;\n\nexport interface TokenizedCommandArgs {\n readonly tokens: readonly CommandToken[];\n readonly passthrough: string[];\n readonly issues: readonly IndexedIssue[];\n readonly help: boolean;\n readonly helpIndex: number | undefined;\n readonly version: boolean;\n readonly versionIndex: number | undefined;\n}\n\ninterface IndexedIssue {\n readonly index: number;\n readonly issue: ZittyIssue;\n}\n\nfunction optionModel(command: AnyCommandDef): OptionModel {\n const definitions = new Map<string, OptionDefinition>();\n const parserOptions: OptionModel[\"parserOptions\"] = {};\n const allAliases = new Set<string>();\n\n if (command.args) {\n for (const [key, schema] of Object.entries(schemaShape(command.args))) {\n if (key === POSITIONALS_KEY) continue;\n const alias = command.argOptions?.[key]?.alias;\n const aliases = alias ? aliasList(alias) : [];\n const definition: OptionDefinition = {\n key,\n kebabName: kebabCase(key),\n takesValue: readArgInfo(schema).takesValue,\n };\n const type = definition.takesValue ? \"string\" : \"boolean\";\n for (const name of new Set([key, definition.kebabName])) {\n definitions.set(name, definition);\n parserOptions[name] = { type };\n }\n for (const alias of aliases) {\n allAliases.add(alias);\n definitions.set(alias, definition);\n parserOptions[alias] = { type, short: alias };\n }\n }\n }\n return { definitions, parserOptions, aliases: allAliases };\n}\n\nfunction commandPositionals(command: AnyCommandDef): Positionals | undefined {\n return command.args ? readPositionals(schemaShape(command.args)) : undefined;\n}\n\nfunction displayName(command: AnyCommandDef, path: readonly PropertyKey[]): string {\n const [first, index] = path;\n if (typeof first !== \"string\") return \"arguments\";\n if (first !== POSITIONALS_KEY) return `--${kebabCase(first)}`;\n const positionals = commandPositionals(command);\n if (!positionals || typeof index !== \"number\") return \"arguments\";\n const item = positionals.items[index];\n if (item) return `<${item.label}>`;\n return positionals.rest ? `<${positionals.rest.label}...>` : \"arguments\";\n}\n\nexport function tokenizeCommandArgs(\n command: AnyCommandDef,\n rawArgs: readonly string[],\n): TokenizedCommandArgs {\n const model = optionModel(command);\n const separator = rawArgs.indexOf(\"--\");\n const beforeSeparator = separator === -1 ? [...rawArgs] : rawArgs.slice(0, separator);\n const passthrough = separator === -1 ? [] : rawArgs.slice(separator + 1);\n const negativeIndexes = new Set<number>();\n const valuedNegativeIndexes = new Set<number>();\n const issues: IndexedIssue[] = [];\n let recordedMissingValue = false;\n const parserArgs = beforeSeparator.map((raw, index) => {\n if (!raw.startsWith(\"--no-\")) return raw;\n const equals = raw.indexOf(\"=\");\n const name = raw.slice(5, equals === -1 ? undefined : equals);\n const definition = model.definitions.get(name);\n if (!definition || definition.takesValue) return raw;\n negativeIndexes.add(index);\n if (equals !== -1) {\n valuedNegativeIndexes.add(index);\n return `--${definition.key}${raw.slice(equals)}`;\n }\n return `--${definition.key}`;\n });\n\n const parsed = parseNodeArgs({\n args: parserArgs,\n options: model.parserOptions,\n allowPositionals: true,\n strict: false,\n tokens: true,\n });\n const tokens: CommandToken[] = [];\n const unknownIndexes = new Set<number>();\n let help = false;\n let helpIndex: number | undefined;\n let version = false;\n let versionIndex: number | undefined;\n for (const token of parsed.tokens) {\n if (token.kind === \"positional\") {\n tokens.push({ kind: \"positional\", index: token.index, value: token.value });\n continue;\n }\n if (token.kind !== \"option\") continue;\n const isHelp =\n token.rawName === \"--help\" || (token.rawName === \"-h\" && !model.aliases.has(\"h\"));\n const isVersion =\n token.rawName === \"--version\" || (token.rawName === \"-v\" && !model.aliases.has(\"v\"));\n if (isHelp) {\n help = true;\n helpIndex ??= token.index;\n }\n if (isVersion) {\n version = true;\n versionIndex ??= token.index;\n }\n const definition = model.definitions.get(token.name);\n if (definition) {\n if (\n definition.takesValue &&\n (token.value === undefined ||\n (!token.inlineValue && token.value.startsWith(\"-\") && token.value !== \"-\"))\n ) {\n if (!recordedMissingValue) {\n issues.push({\n index: token.index,\n issue: { arg: `--${definition.kebabName}`, message: \"requires a value\" },\n });\n recordedMissingValue = true;\n }\n }\n let value: string | boolean = token.value ?? true;\n if (!definition.takesValue) {\n if (valuedNegativeIndexes.has(token.index)) {\n const rawName = beforeSeparator[token.index]!.split(\"=\", 1)[0]!;\n issues.push({\n index: token.index,\n issue: { arg: rawName, message: \"does not accept a value\" },\n });\n value = false;\n } else if (negativeIndexes.has(token.index)) {\n value = false;\n } else if (token.inlineValue) {\n if (token.value === \"true\") value = true;\n else if (token.value === \"false\") value = false;\n else {\n issues.push({\n index: token.index,\n issue: { arg: token.rawName, message: \"expects true or false\" },\n });\n }\n }\n }\n tokens.push({\n kind: \"known-option\",\n index: token.index,\n definition,\n value: definition.takesValue ? (token.value ?? \"\") : value,\n });\n } else if (!unknownIndexes.has(token.index)) {\n unknownIndexes.add(token.index);\n tokens.push({\n kind: \"unknown-option\",\n index: token.index,\n value: beforeSeparator[token.index]!,\n });\n }\n }\n\n return {\n tokens,\n passthrough,\n issues,\n help,\n helpIndex,\n version,\n versionIndex,\n };\n}\n\nexport function tokenizedBefore(\n tokenized: TokenizedCommandArgs,\n endIndex: number,\n): TokenizedCommandArgs {\n const help = tokenized.helpIndex !== undefined && tokenized.helpIndex < endIndex;\n const version = tokenized.versionIndex !== undefined && tokenized.versionIndex < endIndex;\n return {\n tokens: tokenized.tokens.filter((token) => token.index < endIndex),\n passthrough: [],\n issues: tokenized.issues.filter(({ index }) => index < endIndex),\n help,\n helpIndex: help ? tokenized.helpIndex : undefined,\n version,\n versionIndex: version ? tokenized.versionIndex : undefined,\n };\n}\n\nfunction zodIssues(command: AnyCommandDef, issues: readonly $ZodIssue[]): ZittyIssue[] {\n return issues.map((issue) => ({\n arg: displayName(command, issue.path),\n message: issue.message,\n issue,\n }));\n}\n\nexport async function parseCommandArgs<S extends ArgsSchema>(\n command: CommandDef<S>,\n rawArgs: string[],\n tokenized: TokenizedCommandArgs = tokenizeCommandArgs(command, rawArgs),\n): Promise<ParsedCommand<S>> {\n if (tokenized.issues.length > 0) {\n throw new ZittyValidationError(\n command,\n tokenized.issues.map(({ issue }) => issue),\n );\n }\n\n const input: Record<string, string | boolean | string[] | undefined> = {};\n const positionals = commandPositionals(command);\n const positionalValues: string[] = [];\n if (positionals) input[POSITIONALS_KEY] = positionalValues;\n const extraArgs: string[] = [];\n for (const token of tokenized.tokens) {\n if (token.kind === \"known-option\") input[token.definition.key] = token.value;\n else if (token.kind === \"unknown-option\") extraArgs.push(token.value);\n else if (\n positionals &&\n (positionals.rest || positionalValues.length < positionals.items.length)\n ) {\n positionalValues.push(token.value);\n } else extraArgs.push(token.value);\n }\n\n if (!command.args)\n return { args: input as output<S>, passthrough: tokenized.passthrough, extraArgs };\n const result = await safeParseAsync(command.args, input);\n if (!result.success)\n throw new ZittyValidationError(command, zodIssues(command, result.error.issues));\n return { args: result.data, passthrough: tokenized.passthrough, extraArgs };\n}\n\n/**\n * Parse and validate one command segment without routing, builtin handling, or output.\n */\nexport async function parseArgs<S extends ArgsSchema>(\n command: CommandDef<S>,\n argv: string[],\n): Promise<output<S>> {\n return (await parseCommandArgs(command, argv)).args;\n}\n","import { stripVTControlCharacters } from \"node:util\";\nimport { summarizeError } from \"./errors.ts\";\n\nfunction safeString(value: unknown): string {\n try {\n return String(value);\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction normalizeProperty(value: object, key: PropertyKey, ancestors: Set<object>): unknown {\n try {\n return normalizeJson(Reflect.get(value, key), ancestors);\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction normalizedKeys(value: object): string[] | undefined {\n try {\n return Object.keys(value);\n } catch {\n return undefined;\n }\n}\n\nconst noToJson = Symbol(\"noToJson\");\n\nfunction normalizedToJson(value: object, ancestors: Set<object>): unknown {\n let toJSON: unknown;\n try {\n toJSON = Reflect.get(value, \"toJSON\");\n } catch {\n return noToJson;\n }\n if (typeof toJSON !== \"function\") return noToJson;\n try {\n const result = Reflect.apply(toJSON, value, []);\n return result === value ? noToJson : normalizeJson(result, ancestors);\n } catch {\n return noToJson;\n }\n}\n\nfunction isArrayBufferView(value: object): value is ArrayBufferView {\n try {\n return ArrayBuffer.isView(value);\n } catch {\n return false;\n }\n}\n\n/** Normalize arbitrary event data into values accepted by JSON.stringify. */\nexport function normalizeJson(value: unknown, ancestors = new Set<object>()): unknown {\n switch (typeof value) {\n case \"string\":\n return stripVTControlCharacters(value);\n case \"boolean\":\n return value;\n case \"number\":\n return Number.isFinite(value) ? value : null;\n case \"bigint\":\n return value.toString();\n case \"undefined\":\n return \"[undefined]\";\n case \"symbol\":\n return `[symbol:${stripVTControlCharacters(value.description ?? \"\")}]`;\n case \"function\":\n return `[function:${stripVTControlCharacters(value.name || \"anonymous\")}]`;\n case \"object\":\n break;\n }\n if (value === null) return null;\n if (ancestors.has(value)) return \"[Circular]\";\n\n const nextAncestors = new Set(ancestors).add(value);\n if (value instanceof Error) return normalizeJson(summarizeError(value), nextAncestors);\n\n const jsonValue = normalizedToJson(value, nextAncestors);\n if (jsonValue !== noToJson) return jsonValue;\n\n if (isArrayBufferView(value)) {\n if (value instanceof DataView) {\n return Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n }\n try {\n return Array.from(value as unknown as Iterable<unknown>, (item) =>\n normalizeJson(item, nextAncestors),\n );\n } catch {\n return \"[Unserializable]\";\n }\n }\n if (value instanceof ArrayBuffer) return Array.from(new Uint8Array(value));\n if (Array.isArray(value)) {\n return Array.from({ length: value.length }, (_, index) =>\n normalizeProperty(value, index, nextAncestors),\n );\n }\n if (value instanceof Map) {\n try {\n return [...value].map(([key, item]) => [\n normalizeJson(key, nextAncestors),\n normalizeJson(item, nextAncestors),\n ]);\n } catch {\n return \"[Unserializable]\";\n }\n }\n if (value instanceof Set) {\n try {\n return [...value].map((item) => normalizeJson(item, nextAncestors));\n } catch {\n return \"[Unserializable]\";\n }\n }\n\n const keys = normalizedKeys(value);\n if (!keys) return safeString(value);\n const result: Record<string, unknown> = {};\n for (const key of keys) {\n result[stripVTControlCharacters(key)] = normalizeProperty(value, key, nextAncestors);\n }\n return result;\n}\n","import type { HackshErrorSummary } from \"./errors.ts\";\nimport type { LogRecord } from \"./logger.ts\";\nimport { normalizeJson } from \"./serialization.ts\";\nimport type { UsageSummary } from \"./usage.ts\";\n\nexport type PrintStream = \"stdout\" | \"stderr\";\nexport type OutputPreference = \"auto\" | \"pretty\" | \"json\";\nexport type OutputFormat = Exclude<OutputPreference, \"auto\">;\n\nexport interface OutputMode {\n format: OutputFormat;\n interactive: boolean;\n color: boolean;\n}\n\nexport interface ResolveOutputModeOptions {\n output?: OutputPreference;\n env?: Readonly<Record<string, string | undefined>>;\n inputIsTTY?: boolean;\n outputIsTTY?: boolean;\n}\n\nfunction fallbackValue(value: unknown): string {\n try {\n return String(value);\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction validatePreference(value: unknown, source: string): OutputPreference | undefined {\n if (value === undefined) return undefined;\n if (value === \"auto\" || value === \"pretty\" || value === \"json\") return value;\n throw new TypeError(\n `Invalid ${source} value ${fallbackValue(value)}; expected auto, pretty, or json`,\n );\n}\n\nfunction readEnvironment(\n env: Readonly<Record<string, string | undefined>>,\n key: string,\n): string | undefined {\n try {\n return env[key];\n } catch {\n return undefined;\n }\n}\n\n/** Resolve output behavior once, before command routing or argument parsing. */\nexport function resolveOutputMode(options: ResolveOutputModeOptions = {}): OutputMode {\n const env = options.env ?? process.env;\n const configured = validatePreference(options.output, \"output\");\n const overridden = validatePreference(readEnvironment(env, \"HACKSH_OUTPUT\"), \"HACKSH_OUTPUT\");\n const requested = overridden ?? configured ?? \"auto\";\n const ci = Boolean(readEnvironment(env, \"CI\"));\n const format = requested === \"auto\" ? (ci ? \"json\" : \"pretty\") : requested;\n const inputIsTTY = options.inputIsTTY ?? process.stdin.isTTY === true;\n const outputIsTTY = options.outputIsTTY ?? process.stdout.isTTY === true;\n return {\n format,\n interactive: format === \"pretty\" && !ci && inputIsTTY && outputIsTTY,\n color: format === \"pretty\" && outputIsTTY && !readEnvironment(env, \"NO_COLOR\"),\n };\n}\n\nexport interface UsagePrintEvent {\n type: \"usage\";\n usage: UsageSummary;\n text: string;\n stream: PrintStream;\n}\n\nexport interface VersionPrintEvent {\n type: \"version\";\n version: string;\n}\n\nexport interface ErrorPrintEvent {\n type: \"error\";\n error: HackshErrorSummary;\n}\n\nexport interface LogPrintEvent {\n type: \"log\";\n record: LogRecord;\n}\n\nexport interface PromptChoiceState {\n value: string;\n label: string;\n hint?: string;\n selected: boolean;\n}\n\nexport type PromptStatus = \"active\" | \"error\" | \"submitted\" | \"closed\";\n\ninterface PromptStateBase {\n message: string;\n status: PromptStatus;\n error?: string;\n}\n\nexport interface SelectPromptState extends PromptStateBase {\n kind: \"select\";\n choices: readonly PromptChoiceState[];\n value: string;\n}\n\nexport interface ConfirmPromptState extends PromptStateBase {\n kind: \"confirm\";\n value: boolean;\n defaultValue?: boolean;\n}\n\nexport interface TextPromptState extends PromptStateBase {\n kind: \"text\";\n value: string;\n placeholder?: string;\n}\n\nexport type PromptState = SelectPromptState | ConfirmPromptState | TextPromptState;\n\nexport interface PromptPrintEvent {\n type: \"prompt\";\n prompt: PromptState;\n}\n\n/** A semantic, command- and schema-free output value emitted by hacksh. */\nexport type PrintEvent =\n | UsagePrintEvent\n | VersionPrintEvent\n | ErrorPrintEvent\n | LogPrintEvent\n | PromptPrintEvent;\n\n/** Receives every output event produced by one command invocation. */\nexport interface Printer {\n print(event: PrintEvent): void | Promise<void>;\n}\n\nfunction isErrorLevel(level: LogRecord[\"level\"]): boolean {\n return level === \"warning\" || level === \"error\" || level === \"fatal\";\n}\n\nexport function eventStream(event: PrintEvent): PrintStream {\n if (event.type === \"error\") return \"stderr\";\n if (event.type === \"usage\") return event.stream;\n if (event.type === \"log\" && isErrorLevel(event.record.level)) return \"stderr\";\n return \"stdout\";\n}\n\nfunction formatTextEvent(event: PrintEvent): string {\n switch (event.type) {\n case \"usage\":\n return event.text;\n case \"version\":\n return event.version;\n case \"error\":\n return event.error.kind === \"usage\" || event.error.kind === \"validation\"\n ? event.error.message\n : `Error: ${event.error.message}`;\n case \"log\":\n return event.record.message;\n case \"prompt\":\n return event.prompt.message;\n }\n}\n\n/** Undecorated console compatibility adapter; automatic output uses the selected format printer. */\nexport const consolePrinter: Printer = {\n print(event) {\n const text = formatTextEvent(event);\n return eventStream(event) === \"stdout\" ? console.log(text) : console.error(text);\n },\n};\n\nexport interface OutputWriter {\n write(text: string): unknown;\n}\n\nexport interface TerminalInput {\n readonly isTTY?: boolean;\n readonly isRaw?: boolean;\n readonly readableFlowing?: boolean | null;\n setRawMode?(mode: boolean): unknown;\n resume(): unknown;\n pause(): unknown;\n on(event: string, listener: (...args: never[]) => void): unknown;\n removeListener(event: string, listener: (...args: never[]) => void): unknown;\n}\n\nexport interface TerminalOutput extends OutputWriter {\n readonly isTTY?: boolean;\n readonly columns?: number;\n}\n\nexport interface JsonPrinterOptions {\n stdout?: OutputWriter;\n stderr?: OutputWriter;\n}\n\nexport interface StreamPrinterOptions {\n stdout: OutputWriter;\n stderr: OutputWriter;\n}\n\n/** Create an undecorated stream-backed compatibility adapter. */\nexport function createStreamPrinter(options: StreamPrinterOptions): Printer {\n return {\n print(event) {\n const writer = eventStream(event) === \"stdout\" ? options.stdout : options.stderr;\n writer.write(`${formatTextEvent(event)}\\n`);\n },\n };\n}\n\n/** Create a one-semantic-event-per-line JSON printer. */\nexport function createJsonPrinter(options: JsonPrinterOptions = {}): Printer {\n const stdout = options.stdout ?? process.stdout;\n const stderr = options.stderr ?? process.stderr;\n return {\n print(event) {\n let serialized: string;\n try {\n serialized = JSON.stringify(normalizeJson(event));\n } catch {\n serialized = JSON.stringify({\n type: event.type,\n serializationError: \"Event data could not be serialized\",\n });\n }\n const line = `${serialized}\\n`;\n (eventStream(event) === \"stdout\" ? stdout : stderr).write(line);\n },\n };\n}\n\nexport interface PrintQueue {\n printer: Printer;\n printChecked(event: PrintEvent): Promise<void>;\n drain(): Promise<void>;\n}\n\n/** Serialize printer calls and retain failures until the invocation drains its output. */\nexport function createPrintQueue(target: Printer): PrintQueue {\n let pending: Promise<void> | undefined;\n let failure: unknown;\n let failed = false;\n\n function recordFailure(error: unknown): void {\n if (!failed) failure = error;\n failed = true;\n }\n\n function track(execution: Promise<void>, retainFailure: boolean): Promise<void> {\n const barrier = execution.catch((error: unknown) => {\n if (retainFailure) recordFailure(error);\n });\n pending = barrier;\n void barrier.then(() => {\n if (pending === barrier) pending = undefined;\n });\n return retainFailure ? barrier : execution;\n }\n\n function enqueue(event: PrintEvent, retainFailure: boolean): void | Promise<void> {\n if (pending)\n return track(\n pending.then(() => target.print(event)),\n retainFailure,\n );\n try {\n const result = target.print(event);\n if (result) return track(Promise.resolve(result), retainFailure);\n } catch (error) {\n if (retainFailure) recordFailure(error);\n else return Promise.reject(error);\n }\n }\n\n const printer: Printer = {\n print(event) {\n return enqueue(event, true);\n },\n };\n\n return {\n printer,\n async printChecked(event) {\n await enqueue(event, false);\n },\n async drain() {\n await pending;\n if (failed) throw failure;\n },\n };\n}\n","import { inspect, stripVTControlCharacters, styleText } from \"node:util\";\nimport type { HackshErrorSummary } from \"./errors.ts\";\nimport type { LogLevel, LogRecord } from \"./logger.ts\";\nimport {\n eventStream,\n type OutputWriter,\n type Printer,\n type PrintEvent,\n type TerminalOutput,\n} from \"./printer.ts\";\n\ntype PrettyMark = LogLevel | \"step\" | \"success\" | \"usage\" | \"version\" | \"errorEvent\" | \"prompt\";\ntype TextStyle = Parameters<typeof styleText>[0];\n\ninterface PrettySymbols {\n bar: string;\n marks: Record<PrettyMark, string>;\n}\n\nconst unicodeSymbols: PrettySymbols = {\n bar: \"│\",\n marks: {\n trace: \"·\",\n debug: \"◆\",\n info: \"●\",\n warning: \"▲\",\n error: \"■\",\n fatal: \"✖\",\n step: \"◇\",\n success: \"✔\",\n usage: \"◆\",\n version: \"●\",\n errorEvent: \"■\",\n prompt: \"?\",\n },\n};\n\nconst asciiSymbols: PrettySymbols = {\n bar: \"|\",\n marks: {\n trace: \".\",\n debug: \":\",\n info: \"i\",\n warning: \"!\",\n error: \"x\",\n fatal: \"X\",\n step: \">\",\n success: \"+\",\n usage: \"?\",\n version: \"i\",\n errorEvent: \"x\",\n prompt: \"?\",\n },\n};\n\nconst markStyles: Record<PrettyMark, TextStyle> = {\n trace: \"gray\",\n debug: \"magenta\",\n info: \"blue\",\n warning: \"yellow\",\n error: \"red\",\n fatal: [\"bgRed\", \"white\", \"bold\"],\n step: \"cyan\",\n success: \"green\",\n usage: \"cyan\",\n version: \"blue\",\n errorEvent: \"red\",\n prompt: \"cyan\",\n};\n\nexport interface PrettyPrinterOptions {\n color: boolean;\n unicode: boolean;\n stdout?: TerminalOutput;\n stderr?: OutputWriter;\n}\n\nfunction safelyInspect(value: unknown): string {\n if (typeof value === \"string\") return value;\n try {\n return inspect(value, {\n breakLength: 80,\n colors: false,\n compact: false,\n depth: null,\n sorted: true,\n });\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction propertyLines(properties: Readonly<Record<string, unknown>>): string[] {\n const lines: string[] = [];\n for (const key of Object.keys(properties).sort()) {\n const rendered = ` ${key}: ${safelyInspect(properties[key])}`.split(\"\\n\");\n lines.push(rendered[0] ?? \"\");\n for (const continuation of rendered.slice(1)) lines.push(` ${continuation}`);\n }\n return lines;\n}\n\nfunction logLines(record: LogRecord): string[] {\n const category = record.category.length > 0 ? `[${record.category.join(\":\")}] ` : \"\";\n const message = record.message.split(\"\\n\");\n return [\n `${category}${message[0] ?? \"\"}`,\n ...message.slice(1),\n ...propertyLines(record.properties),\n ];\n}\n\nfunction errorLines(error: HackshErrorSummary): string[] {\n const lines = error.message.split(\"\\n\");\n const details: Record<string, unknown> = {};\n if (error.cause !== undefined) details.cause = error.cause;\n if (error.properties !== undefined) Object.assign(details, error.properties);\n if (error.value !== undefined) details.value = error.value;\n return [...lines, ...propertyLines(details)];\n}\n\nfunction eventMark(event: PrintEvent): PrettyMark {\n if (event.type === \"usage\") return \"usage\";\n if (event.type === \"version\") return \"version\";\n if (event.type === \"error\") return \"errorEvent\";\n if (event.type === \"prompt\") return event.prompt.status === \"submitted\" ? \"success\" : \"prompt\";\n return event.record.kind === \"message\" ? event.record.level : event.record.kind;\n}\n\nfunction eventLines(event: PrintEvent): string[] {\n switch (event.type) {\n case \"usage\":\n return event.text.split(\"\\n\");\n case \"version\":\n return event.version.split(\"\\n\");\n case \"error\":\n return errorLines(event.error);\n case \"log\":\n return logLines(event.record);\n case \"prompt\": {\n const { prompt } = event;\n if (prompt.status === \"submitted\") {\n const result =\n prompt.kind === \"select\"\n ? (prompt.choices.find(({ value }) => value === prompt.value)?.label ?? prompt.value)\n : prompt.kind === \"confirm\"\n ? prompt.value\n ? \"Yes\"\n : \"No\"\n : prompt.value;\n return [`${prompt.message}: ${result}`];\n }\n const lines = [prompt.message];\n if (prompt.kind === \"select\") {\n for (const choice of prompt.choices) {\n lines.push(\n `${choice.selected ? \">\" : \" \"} ${choice.label}${choice.hint ? ` — ${choice.hint}` : \"\"}`,\n );\n }\n } else if (prompt.kind === \"confirm\") {\n lines.push(\n `${prompt.value ? \"Yes\" : \"No\"}${prompt.defaultValue === undefined ? \"\" : ` (default: ${prompt.defaultValue ? \"yes\" : \"no\"})`}`,\n );\n } else {\n lines.push(prompt.value || (prompt.placeholder ? `(${prompt.placeholder})` : \"\"));\n }\n if (prompt.error) lines.push(prompt.error);\n return lines;\n }\n }\n}\n\nfunction colorize(enabled: boolean, style: TextStyle, text: string): string {\n return enabled ? styleText(style, text, { validateStream: false }) : text;\n}\n\nconst graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\nconst combiningMark = /\\p{Mark}/u;\nconst pictograph = /\\p{Extended_Pictographic}/u;\n\nfunction isWideCodePoint(codePoint: number): boolean {\n return (\n codePoint >= 0x1100 &&\n (codePoint <= 0x115f ||\n codePoint === 0x2329 ||\n codePoint === 0x232a ||\n (codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f) ||\n (codePoint >= 0xac00 && codePoint <= 0xd7a3) ||\n (codePoint >= 0xf900 && codePoint <= 0xfaff) ||\n (codePoint >= 0xfe10 && codePoint <= 0xfe19) ||\n (codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||\n (codePoint >= 0xff00 && codePoint <= 0xff60) ||\n (codePoint >= 0xffe0 && codePoint <= 0xffe6) ||\n (codePoint >= 0x20000 && codePoint <= 0x3fffd))\n );\n}\n\nfunction displayWidth(text: string): number {\n let width = 0;\n for (const { segment } of graphemeSegmenter.segment(stripVTControlCharacters(text))) {\n if (segment === \"\\t\") {\n width += 8 - (width % 8);\n continue;\n }\n if (\n pictograph.test(segment) ||\n Array.from(segment).some((value) => isWideCodePoint(value.codePointAt(0)!))\n ) {\n width += 2;\n continue;\n }\n for (const value of segment) {\n const codePoint = value.codePointAt(0)!;\n if (codePoint < 0x20 || (codePoint >= 0x7f && codePoint < 0xa0)) continue;\n if (codePoint === 0x200d || (codePoint >= 0xfe00 && codePoint <= 0xfe0f)) continue;\n if (!combiningMark.test(value)) width += 1;\n }\n }\n return width;\n}\n\nfunction renderedRows(rendered: string, columns: number | undefined): number {\n const width =\n Number.isInteger(columns) && columns !== undefined && columns > 0 ? columns : undefined;\n return rendered.split(\"\\n\").reduce((rows, line) => {\n if (!width) return rows + 1;\n return rows + Math.max(1, Math.ceil(displayWidth(line) / width));\n }, 0);\n}\n\n/** Create the fixed human-readable renderer used for pretty output. */\nexport function createPrettyPrinter(options: PrettyPrinterOptions): Printer {\n const stdout = options.stdout ?? process.stdout;\n const stderr = options.stderr ?? process.stderr;\n const symbols = options.unicode ? unicodeSymbols : asciiSymbols;\n let activePrompt: { rendered: string; lines: number } | undefined;\n\n function render(event: PrintEvent): string {\n const mark = eventMark(event);\n const lines = eventLines(event);\n const firstPrefix = colorize(options.color, markStyles[mark], symbols.marks[mark]);\n const barPrefix = colorize(options.color, \"gray\", symbols.bar);\n return lines\n .map((line, index) => `${index === 0 ? firstPrefix : barPrefix}${line ? ` ${line}` : \"\"}`)\n .join(\"\\n\");\n }\n\n function eraseActivePrompt(): string {\n return activePrompt ? \"\\u001b[1A\\u001b[2K\".repeat(activePrompt.lines) : \"\";\n }\n\n return {\n print(event) {\n const rendered = render(event);\n if (event.type === \"prompt\") {\n const erase = eraseActivePrompt();\n if (event.prompt.status === \"closed\") {\n activePrompt = undefined;\n if (erase) stdout.write(erase);\n return;\n }\n if (event.prompt.status === \"submitted\") activePrompt = undefined;\n else activePrompt = { rendered, lines: renderedRows(rendered, stdout.columns) };\n stdout.write(`${erase}${rendered}\\n`);\n return;\n }\n\n const erase = eraseActivePrompt();\n if (!activePrompt) {\n (eventStream(event) === \"stdout\" ? stdout : stderr).write(`${rendered}\\n`);\n return;\n }\n\n stdout.write(erase);\n if (event.type === \"error\") activePrompt = undefined;\n (eventStream(event) === \"stdout\" ? stdout : stderr).write(`${rendered}\\n`);\n if (activePrompt) stdout.write(`${activePrompt.rendered}\\n`);\n },\n };\n}\n","import { emitKeypressEvents } from \"node:readline\";\nimport { PassThrough } from \"node:stream\";\nimport type { HackshPromptErrorReason, PromptErrorDetails, PromptKind } from \"./errors.ts\";\nimport { HackshPromptError } from \"./errors.ts\";\nimport type {\n ConfirmPromptState,\n Printer,\n PromptState,\n PromptStatus,\n SelectPromptState,\n TerminalInput,\n TextPromptState,\n} from \"./printer.ts\";\n\nexport interface SelectOption<T extends string> {\n value: T;\n label?: string;\n hint?: string;\n}\n\nexport interface SelectOptions<T extends string> {\n message: string;\n options: readonly SelectOption<T>[];\n initialValue?: T;\n}\n\nexport interface ConfirmOptions {\n message: string;\n initialValue?: boolean;\n}\n\nexport interface TextOptions {\n message: string;\n placeholder?: string;\n validate?(value: string): string | undefined;\n}\n\nexport interface Prompter {\n select<const T extends string>(options: SelectOptions<T>): Promise<T>;\n confirm(options: ConfirmOptions): Promise<boolean>;\n text(options: TextOptions): Promise<string>;\n}\n\ninterface Key {\n name?: string;\n ctrl?: boolean;\n meta?: boolean;\n sequence?: string;\n}\n\ninterface PromptControllerOptions {\n interactive: boolean;\n input: TerminalInput;\n print(event: Parameters<Printer[\"print\"]>[0]): Promise<void>;\n}\n\ninterface BufferedKeypress {\n character: string | undefined;\n key: Key;\n}\n\nfunction details(\n kind: PromptKind,\n message: unknown,\n choices?: readonly string[],\n): PromptErrorDetails {\n let normalizedMessage: string;\n try {\n normalizedMessage = typeof message === \"string\" ? message : String(message);\n } catch {\n normalizedMessage = \"[Unserializable prompt message]\";\n }\n return {\n kind,\n message: normalizedMessage,\n ...(choices === undefined ? {} : { choices }),\n };\n}\n\nfunction promptError(\n reason: HackshPromptErrorReason,\n prompt: PromptErrorDetails,\n message: string,\n cause?: unknown,\n): HackshPromptError {\n return new HackshPromptError(\n reason,\n prompt,\n message,\n cause === undefined ? undefined : { cause },\n );\n}\n\nfunction validateMessage(kind: PromptKind, message: unknown, choices?: readonly string[]): void {\n if (typeof message !== \"string\" || message.length === 0) {\n throw promptError(\n \"invalid-options\",\n details(kind, message, choices),\n `Invalid ${kind} prompt: message must be a non-empty string`,\n );\n }\n}\n\nfunction asInput(value: TerminalInput, prompt: PromptErrorDetails): TerminalInput {\n if (\n typeof value !== \"object\" ||\n value === null ||\n typeof Reflect.get(value, \"on\") !== \"function\" ||\n typeof Reflect.get(value, \"removeListener\") !== \"function\" ||\n typeof Reflect.get(value, \"resume\") !== \"function\" ||\n typeof Reflect.get(value, \"pause\") !== \"function\"\n ) {\n throw promptError(\"input-error\", prompt, \"Interactive input is not a readable stream\");\n }\n return value;\n}\n\nexport class PromptController implements Prompter {\n readonly #interactive: boolean;\n readonly #inputValue: TerminalInput;\n readonly #printEvent: PromptControllerOptions[\"print\"];\n readonly #bufferedKeys: BufferedKeypress[] = [];\n #active = false;\n\n constructor(options: PromptControllerOptions) {\n this.#interactive = options.interactive;\n this.#inputValue = options.input;\n this.#printEvent = (event) => options.print(event);\n }\n\n async #print(state: PromptState, prompt: PromptErrorDetails): Promise<void> {\n try {\n await this.#printEvent({ type: \"prompt\", prompt: state });\n } catch (cause) {\n throw promptError(\"printer-error\", prompt, \"The prompt could not be displayed\", cause);\n }\n }\n\n async #run<T>(\n prompt: PromptErrorDetails,\n initial: PromptState,\n accept: (character: string, key: Key) => T | undefined,\n update: (character: string, key: Key) => PromptState | undefined,\n submitted: (value: T) => PromptState,\n closed: () => PromptState,\n ): Promise<T> {\n if (!this.#interactive) {\n throw promptError(\n \"non-interactive\",\n prompt,\n `Cannot request ${prompt.kind} input in non-interactive mode: ${prompt.message}`,\n );\n }\n if (this.#active) {\n throw promptError(\"overlapping\", prompt, \"Another prompt is already active\");\n }\n\n const input = asInput(this.#inputValue, prompt);\n this.#active = true;\n let originallyFlowing = false;\n let rawChanged = false;\n let outcome: { ok: true; value: T } | { ok: false; error: unknown };\n try {\n originallyFlowing = input.readableFlowing === true;\n if (input.setRawMode && input.isRaw !== true) {\n input.setRawMode(true);\n rawChanged = true;\n }\n await this.#print(initial, prompt);\n\n const value = await new Promise<T>((resolve, reject) => {\n const keypressInput = new PassThrough();\n emitKeypressEvents(keypressInput);\n let settled = false;\n let draining = false;\n let finalized = false;\n let completion: (() => void) | undefined;\n const queuedKeys = this.#bufferedKeys.splice(0);\n const finalize = (): void => {\n if (finalized || !settled || draining) return;\n finalized = true;\n cleanup();\n completion?.();\n };\n const finish = (action: () => void): void => {\n if (settled) return;\n settled = true;\n completion = action;\n finalize();\n };\n const fail = (reason: HackshPromptErrorReason, message: string, cause?: unknown): void => {\n finish(() => reject(promptError(reason, prompt, message, cause)));\n };\n const handleKeypress = async (\n character: string | undefined,\n key: Key = {},\n ): Promise<void> => {\n if (settled) return;\n if ((key.ctrl && key.name === \"c\") || key.name === \"escape\") {\n fail(\"cancelled\", \"Prompt cancelled\");\n return;\n }\n if (key.ctrl && key.name === \"d\") {\n fail(\"eof\", \"Prompt input ended before a value was submitted\");\n return;\n }\n try {\n const value = accept(character ?? \"\", key);\n if (value !== undefined) {\n finish(() => resolve(value));\n return;\n }\n const state = update(character ?? \"\", key);\n if (state) await this.#print(state, prompt);\n } catch (cause) {\n if (cause instanceof HackshPromptError) finish(() => reject(cause));\n else fail(\"input-error\", \"Prompt input could not be processed\", cause);\n }\n };\n const drainKeys = async (): Promise<void> => {\n if (draining || finalized) return;\n draining = true;\n try {\n while (queuedKeys.length > 0) {\n if (settled) {\n this.#bufferedKeys.push(...queuedKeys.splice(0));\n break;\n }\n const next = queuedKeys.shift()!;\n await handleKeypress(next.character, next.key);\n }\n } finally {\n draining = false;\n finalize();\n }\n };\n const onKeypress = (character: string | undefined, key: Key = {}): void => {\n queuedKeys.push({ character, key });\n void drainKeys().catch((cause: unknown) =>\n fail(\"input-error\", \"Prompt input could not be processed\", cause),\n );\n };\n const onEnd = (): void => fail(\"eof\", \"Prompt input ended before a value was submitted\");\n const onError = (cause: unknown): void => fail(\"input-error\", \"Prompt input failed\", cause);\n const onData = (chunk: unknown): void => {\n if (typeof chunk === \"string\" || chunk instanceof Uint8Array) keypressInput.write(chunk);\n else fail(\"input-error\", \"Prompt input produced a non-byte value\");\n };\n const cleanup = (): void => {\n keypressInput.removeListener(\"keypress\", onKeypress);\n keypressInput.destroy();\n input.removeListener(\"data\", onData as (...args: never[]) => void);\n input.removeListener(\"end\", onEnd as (...args: never[]) => void);\n input.removeListener(\"close\", onEnd as (...args: never[]) => void);\n input.removeListener(\"error\", onError as (...args: never[]) => void);\n };\n keypressInput.on(\"keypress\", onKeypress);\n input.on(\"data\", onData as (...args: never[]) => void);\n input.on(\"end\", onEnd as (...args: never[]) => void);\n input.on(\"close\", onEnd as (...args: never[]) => void);\n input.on(\"error\", onError as (...args: never[]) => void);\n input.resume();\n void drainKeys().catch((cause: unknown) =>\n fail(\"input-error\", \"Prompt input could not be processed\", cause),\n );\n });\n outcome = { ok: true, value };\n } catch (cause) {\n outcome = {\n ok: false,\n error:\n cause instanceof HackshPromptError\n ? cause\n : promptError(\"input-error\", prompt, \"Prompt input could not be initialized\", cause),\n };\n }\n\n let restoreError: HackshPromptError | undefined;\n try {\n if (rawChanged) input.setRawMode?.(false);\n if (!originallyFlowing) input.pause();\n } catch (cause) {\n restoreError = promptError(\n \"input-error\",\n prompt,\n \"Prompt input could not be restored\",\n cause,\n );\n }\n const closeWithFailure = async (failure: unknown): Promise<never> => {\n try {\n await this.#print(closed(), prompt);\n } catch {\n // Preserve the error that terminated the prompt, including an earlier printer failure.\n } finally {\n this.#active = false;\n }\n throw failure;\n };\n if (restoreError) return closeWithFailure(restoreError);\n if (!outcome.ok) return closeWithFailure(outcome.error);\n try {\n await this.#print(submitted(outcome.value), prompt);\n return outcome.value;\n } catch (error) {\n try {\n await this.#print(closed(), prompt);\n } catch {\n // The submitted-state failure remains the primary error.\n }\n throw error;\n } finally {\n this.#active = false;\n }\n }\n\n async select<const T extends string>(options: SelectOptions<T>): Promise<T> {\n const choices = Array.isArray(options?.options)\n ? options.options.map((option) =>\n typeof option === \"object\" && option !== null && typeof option.value === \"string\"\n ? option.value\n : \"[Invalid choice]\",\n )\n : [];\n const prompt = details(\"select\", options?.message, choices);\n validateMessage(\"select\", options?.message, choices);\n if (!Array.isArray(options.options) || options.options.length === 0) {\n throw promptError(\"invalid-options\", prompt, \"A select prompt requires at least one choice\");\n }\n const seen = new Set<string>();\n for (const option of options.options) {\n if (\n typeof option !== \"object\" ||\n option === null ||\n typeof option.value !== \"string\" ||\n option.value.length === 0 ||\n (option.label !== undefined && typeof option.label !== \"string\") ||\n (option.hint !== undefined && typeof option.hint !== \"string\")\n ) {\n throw promptError(\n \"invalid-options\",\n prompt,\n \"Select choices must have valid string values\",\n );\n }\n if (seen.has(option.value)) {\n throw promptError(\"invalid-options\", prompt, `Duplicate select choice: ${option.value}`);\n }\n seen.add(option.value);\n }\n let selected = options.initialValue === undefined ? 0 : choices.indexOf(options.initialValue);\n if (selected < 0) {\n throw promptError(\n \"invalid-options\",\n prompt,\n `Unknown initial select value: ${String(options.initialValue)}`,\n );\n }\n const state = (status: PromptStatus = \"active\"): SelectPromptState => ({\n kind: \"select\",\n message: options.message,\n status,\n value: options.options[selected]!.value,\n choices: options.options.map(({ value, label, hint }, index) => ({\n value,\n label: label ?? value,\n ...(hint === undefined ? {} : { hint }),\n selected: index === selected,\n })),\n });\n const value = await this.#run<T>(\n prompt,\n state(),\n (_character, key) =>\n key.name === \"return\" || key.name === \"enter\"\n ? options.options[selected]!.value\n : undefined,\n (_character, key) => {\n if (key.name !== \"up\" && key.name !== \"down\") return undefined;\n selected =\n (selected + (key.name === \"up\" ? -1 : 1) + options.options.length) %\n options.options.length;\n return state();\n },\n () => state(\"submitted\"),\n () => state(\"closed\"),\n );\n return value;\n }\n\n async confirm(options: ConfirmOptions): Promise<boolean> {\n const prompt = details(\"confirm\", options?.message);\n validateMessage(\"confirm\", options?.message);\n if (options.initialValue !== undefined && typeof options.initialValue !== \"boolean\") {\n throw promptError(\"invalid-options\", prompt, \"Confirm initialValue must be a boolean\");\n }\n const value = options.initialValue ?? false;\n const state = (result: boolean, status: PromptStatus = \"active\"): ConfirmPromptState => ({\n kind: \"confirm\",\n message: options.message,\n status,\n value: result,\n ...(options.initialValue === undefined ? {} : { defaultValue: options.initialValue }),\n });\n const result = await this.#run<boolean>(\n prompt,\n state(value),\n (character, key) => {\n if (key.name === \"return\" || key.name === \"enter\") return value;\n if (character.toLowerCase() === \"y\") return true;\n if (character.toLowerCase() === \"n\") return false;\n return undefined;\n },\n () => undefined,\n (submitted) => state(submitted, \"submitted\"),\n () => state(value, \"closed\"),\n );\n return result;\n }\n\n async text(options: TextOptions): Promise<string> {\n const prompt = details(\"text\", options?.message);\n validateMessage(\"text\", options?.message);\n if (options.placeholder !== undefined && typeof options.placeholder !== \"string\") {\n throw promptError(\"invalid-options\", prompt, \"Text placeholder must be a string\");\n }\n if (options.validate !== undefined && typeof options.validate !== \"function\") {\n throw promptError(\"invalid-options\", prompt, \"Text validate must be a function\");\n }\n let value = \"\";\n let validationError: string | undefined;\n const state = (\n status: PromptStatus = validationError ? \"error\" : \"active\",\n ): TextPromptState => ({\n kind: \"text\",\n message: options.message,\n status,\n value,\n ...(options.placeholder === undefined ? {} : { placeholder: options.placeholder }),\n ...(validationError === undefined ? {} : { error: validationError }),\n });\n const result = await this.#run<string>(\n prompt,\n state(),\n (_character, key) => {\n if (key.name !== \"return\" && key.name !== \"enter\") return undefined;\n let error: string | undefined;\n try {\n error = options.validate?.(value);\n } catch (cause) {\n throw promptError(\"input-error\", prompt, \"Text validation failed\", cause);\n }\n if (error !== undefined && typeof error !== \"string\") {\n throw promptError(\n \"input-error\",\n prompt,\n \"Text validation must return a string or undefined\",\n );\n }\n validationError = error || undefined;\n return validationError === undefined ? value : undefined;\n },\n (character, key) => {\n if (key.name === \"return\" || key.name === \"enter\") return state();\n validationError = undefined;\n if (key.name === \"backspace\") value = Array.from(value).slice(0, -1).join(\"\");\n else if (!key.ctrl && !key.meta && character.length > 0) value += character;\n else return undefined;\n return state();\n },\n () => state(\"submitted\"),\n () => state(\"closed\"),\n );\n return result;\n }\n}\n","import type { Printer, TerminalInput } from \"./printer.ts\";\nimport { summarizeErrors } from \"./errors.ts\";\nimport type { Prompter } from \"./prompts.ts\";\nimport { PromptController } from \"./prompts.ts\";\n\nexport type LogLevel = \"trace\" | \"debug\" | \"info\" | \"warning\" | \"error\" | \"fatal\";\n\nexport type LogKind = \"message\" | \"step\" | \"success\";\n\nexport type LogProperties = Record<string, unknown>;\n\n/** A structured message emitted by a command's logger. */\nexport interface LogRecord {\n level: LogLevel;\n kind: LogKind;\n category: readonly string[];\n message: string;\n rawMessage: string;\n properties: LogProperties;\n timestamp: number;\n}\n\nexport interface Logger extends Prompter {\n readonly category: readonly string[];\n trace(message: string, properties?: LogProperties): void;\n debug(message: string, properties?: LogProperties): void;\n info(message: string, properties?: LogProperties): void;\n warn(message: string, properties?: LogProperties): void;\n error(message: string | Error, properties?: LogProperties): void;\n fatal(message: string | Error, properties?: LogProperties): void;\n step(message: string, properties?: LogProperties): void;\n success(message: string, properties?: LogProperties): void;\n with(properties: LogProperties): Logger;\n getChild(category: string): Logger;\n}\n\nfunction interpolate(message: string, properties: LogProperties): string {\n return message.replace(/\\{([^{}]+)\\}/g, (placeholder, key: string) => {\n if (!Object.hasOwn(properties, key)) return placeholder;\n try {\n return String(properties[key]);\n } catch {\n return placeholder;\n }\n });\n}\n\nfunction createBoundLogger(\n printer: Printer,\n category: readonly string[],\n boundProperties: LogProperties,\n prompts: PromptController,\n): Logger {\n function emit(\n level: LogLevel,\n kind: LogKind,\n input: string | Error,\n properties: LogProperties = {},\n ): void {\n const rawMessage = input instanceof Error ? input.message : input;\n const mergedProperties = { ...boundProperties, ...properties };\n if (input instanceof Error) mergedProperties.error = input;\n const summarizedProperties = summarizeErrors(mergedProperties) as LogProperties;\n\n void printer.print({\n type: \"log\",\n record: {\n level,\n kind,\n category,\n message: interpolate(rawMessage, mergedProperties),\n rawMessage,\n properties: summarizedProperties,\n timestamp: Date.now(),\n },\n });\n }\n\n return {\n category,\n trace: (message, properties) => emit(\"trace\", \"message\", message, properties),\n debug: (message, properties) => emit(\"debug\", \"message\", message, properties),\n info: (message, properties) => emit(\"info\", \"message\", message, properties),\n warn: (message, properties) => emit(\"warning\", \"message\", message, properties),\n error: (message, properties) => emit(\"error\", \"message\", message, properties),\n fatal: (message, properties) => emit(\"fatal\", \"message\", message, properties),\n step: (message, properties) => emit(\"info\", \"step\", message, properties),\n success: (message, properties) => emit(\"info\", \"success\", message, properties),\n select: (options) => prompts.select(options),\n confirm: (options) => prompts.confirm(options),\n text: (options) => prompts.text(options),\n with: (properties) =>\n createBoundLogger(printer, category, { ...boundProperties, ...properties }, prompts),\n getChild: (child) => createBoundLogger(printer, [...category, child], boundProperties, prompts),\n };\n}\n\nexport interface CreateLoggerOptions {\n interactive: boolean;\n input: TerminalInput;\n printPrompt(event: Parameters<Printer[\"print\"]>[0]): Promise<void>;\n}\n\n/** Create the logger for one command invocation. */\nexport function createLogger(\n printer: Printer,\n category: readonly string[],\n options: CreateLoggerOptions,\n): Logger {\n const prompts = new PromptController({\n interactive: options.interactive,\n input: options.input,\n print: (event) => options.printPrompt(event),\n });\n return createBoundLogger(printer, [...category], {}, prompts);\n}\n","import { createPrettyPrinter } from \"./pretty.ts\";\nimport {\n createJsonPrinter,\n resolveOutputMode,\n type OutputMode,\n type OutputPreference,\n type OutputWriter,\n type Printer,\n type TerminalInput,\n type TerminalOutput,\n} from \"./printer.ts\";\n\nexport interface OutputOptions {\n output?: OutputPreference;\n /** Use Unicode presentation symbols in pretty output. Defaults to true. */\n unicode?: boolean;\n env?: Readonly<Record<string, string | undefined>>;\n stdin?: TerminalInput;\n stdout?: TerminalOutput;\n stderr?: OutputWriter;\n}\n\nfunction consoleWriter(method: \"log\" | \"error\", stream: TerminalOutput): TerminalOutput {\n return {\n get isTTY() {\n return stream.isTTY;\n },\n get columns() {\n return stream.columns;\n },\n write(text) {\n if (!text.endsWith(\"\\n\")) return stream.write(text);\n console[method](text.slice(0, -1));\n },\n };\n}\n\n/** Resolve the automatic output policy and select its printer for one operation. */\nexport function selectOutputPrinter(\n options: OutputOptions,\n override?: Printer,\n resolvedMode?: OutputMode,\n): Printer {\n const stdin = options.stdin ?? process.stdin;\n const stdout = options.stdout ?? process.stdout;\n const stderr = options.stderr ?? process.stderr;\n const mode =\n resolvedMode ??\n resolveOutputMode({\n output: options.output,\n env: options.env,\n inputIsTTY: stdin.isTTY,\n outputIsTTY: stdout.isTTY,\n });\n if (override) return override;\n if (mode.format === \"json\") return createJsonPrinter({ stdout, stderr });\n\n const useConsole = options.stdout === undefined && options.stderr === undefined;\n return createPrettyPrinter({\n color: mode.color,\n unicode: options.unicode ?? true,\n stdout: options.stdout ?? (useConsole ? consoleWriter(\"log\", stdout) : stdout),\n stderr: options.stderr ?? (useConsole ? consoleWriter(\"error\", process.stderr) : stderr),\n });\n}\n","import type { AnyCommandDef } from \"./command.ts\";\nimport { summarizeErrors } from \"./errors.ts\";\nimport { aliasList, kebabCase } from \"./options.ts\";\nimport { selectOutputPrinter, type OutputOptions } from \"./output.ts\";\nimport type { Printer, PrintStream } from \"./printer.ts\";\nimport { POSITIONALS_KEY, readArgInfo, readPositionals, schemaShape } from \"./schema.ts\";\n\nfunction details(\n description: string | undefined,\n required: boolean,\n defaultValue: unknown,\n choices: readonly string[] | undefined,\n): string {\n const parts = [description];\n if (choices) parts.push(`(Choices: ${choices.join(\", \")})`);\n if (required) parts.push(\"(Required)\");\n if (defaultValue !== undefined) parts.push(`(Default: ${formatDefault(defaultValue)})`);\n return parts.filter(Boolean).join(\" \");\n}\n\nfunction formatDefault(value: unknown): string {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") {\n return value.toString();\n }\n if (value === null) return \"null\";\n try {\n return JSON.stringify(value) ?? \"undefined\";\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nexport interface UsageArgumentSummary {\n name: string;\n required: boolean;\n variadic: boolean;\n description?: string;\n choices?: readonly string[];\n defaultValue?: unknown;\n}\n\nexport interface UsageOptionSummary {\n name: string;\n flags: readonly string[];\n takesValue: boolean;\n /** Whether the long flag also accepts a `--no-` prefixed form. */\n negatable: boolean;\n valueName?: string;\n required: boolean;\n description?: string;\n choices?: readonly string[];\n defaultValue?: unknown;\n}\n\nexport interface UsageCommandSummary {\n name: string;\n description?: string;\n}\n\n/** A schema-free description of the useful help metadata for a command. */\nexport interface UsageSummary {\n name: string;\n heading?: string;\n version?: string;\n description?: string;\n synopsis: string;\n arguments: readonly UsageArgumentSummary[];\n options: readonly UsageOptionSummary[];\n commands: readonly UsageCommandSummary[];\n}\n\nfunction heading(command: AnyCommandDef): string | undefined {\n const identity = command.name\n ? `${command.name}${command.version ? ` v${command.version}` : \"\"}`\n : command.version\n ? `v${command.version}`\n : undefined;\n if (command.description && identity) return `${command.description} (${identity})`;\n return command.description ?? identity;\n}\n\n/** Build a serializable help summary without retaining command or schema objects. */\nexport function summarizeUsage(command: AnyCommandDef): UsageSummary {\n const shape = command.args ? schemaShape(command.args) : {};\n const positionals = readPositionals(shape);\n const positionalItems = positionals?.items ?? [];\n const syntax = positionalItems.map(({ schema, label }) =>\n readArgInfo(schema).required ? `<${label}>` : `[${label}]`,\n );\n if (positionals?.rest) syntax.push(`[${positionals.rest.label}...]`);\n if (command.subCommands && Object.keys(command.subCommands).length > 0) syntax.push(\"<COMMAND>\");\n\n const args: UsageArgumentSummary[] = positionalItems.map(({ schema, label }) => {\n const info = readArgInfo(schema);\n return {\n name: label,\n required: info.required,\n variadic: false,\n ...(info.description === undefined ? {} : { description: info.description }),\n ...(info.choices === undefined ? {} : { choices: info.choices }),\n ...(info.defaultValue === undefined\n ? {}\n : { defaultValue: summarizeErrors(info.defaultValue) }),\n };\n });\n if (positionals?.rest) {\n const info = readArgInfo(positionals.rest.schema);\n args.push({\n name: positionals.rest.label,\n required: false,\n variadic: true,\n ...(info.description === undefined ? {} : { description: info.description }),\n ...(info.choices === undefined ? {} : { choices: info.choices }),\n });\n }\n\n const options = Object.entries(shape)\n .filter(([key]) => key !== POSITIONALS_KEY)\n .map(([key, schema]): UsageOptionSummary => {\n const info = readArgInfo(schema);\n const argOptions = command.argOptions?.[key];\n const aliases = argOptions?.alias\n ? aliasList(argOptions.alias).map((item) => `-${item}`)\n : [];\n const name = kebabCase(key);\n const valueName = argOptions?.valueName ?? name;\n return {\n name,\n flags: [...aliases, `--${name}`],\n takesValue: info.takesValue,\n negatable: !info.takesValue,\n required: info.required,\n ...(info.takesValue ? { valueName } : {}),\n ...(info.description === undefined ? {} : { description: info.description }),\n ...(info.choices === undefined ? {} : { choices: info.choices }),\n ...(info.defaultValue === undefined\n ? {}\n : { defaultValue: summarizeErrors(info.defaultValue) }),\n };\n });\n\n const commands = Object.entries(command.subCommands ?? {})\n .filter(([, child]) => !child.hidden)\n .map(([name, child]) => ({\n name,\n ...(child.description === undefined ? {} : { description: child.description }),\n }));\n const name = command.name ?? \"command\";\n const title = heading(command);\n return {\n name,\n ...(title === undefined ? {} : { heading: title }),\n ...(command.version === undefined ? {} : { version: command.version }),\n ...(command.description === undefined ? {} : { description: command.description }),\n synopsis: `${name} [OPTIONS]${syntax.length ? ` ${syntax.join(\" \")}` : \"\"}`,\n arguments: args,\n options,\n commands,\n };\n}\n\nfunction formatUsage(summary: UsageSummary): string {\n const lines: string[] = [];\n if (summary.heading) lines.push(summary.heading, \"\");\n lines.push(`USAGE ${summary.synopsis}`);\n\n if (summary.arguments.length > 0) {\n lines.push(\"\", \"ARGUMENTS\", \"\");\n for (const argument of summary.arguments) {\n lines.push(\n ` ${argument.name}${argument.variadic ? \"...\" : \"\"} ${details(argument.description, argument.required, argument.defaultValue, argument.choices)}`.trimEnd(),\n );\n }\n }\n\n if (summary.options.length > 0) {\n lines.push(\"\", \"OPTIONS\", \"\");\n for (const option of summary.options) {\n const flags = option.flags.map((flag) => {\n if (!flag.startsWith(\"--\")) return flag;\n if (option.takesValue) return `${flag}=<${option.valueName}>`;\n if (option.negatable) return `--[no-]${flag.slice(2)}`;\n return flag;\n });\n lines.push(\n ` ${flags.join(\", \")} ${details(option.description, option.required, option.defaultValue, option.choices)}`.trimEnd(),\n );\n }\n }\n\n if (summary.commands.length > 0) {\n lines.push(\"\", \"COMMANDS\", \"\");\n for (const command of summary.commands) {\n lines.push(` ${command.name} ${command.description ?? \"\"}`.trimEnd());\n }\n }\n return lines.join(\"\\n\");\n}\n\nexport type UsageWriter = (text: string) => void | Promise<void>;\n\nexport interface ShowUsageOptions extends OutputOptions {\n write?: UsageWriter;\n printer?: Printer;\n stream?: PrintStream;\n}\n\nexport type UsageOutput = Required<Pick<ShowUsageOptions, \"write\">>;\n\nexport type ShowUsageCallback = (\n command: AnyCommandDef,\n output: UsageOutput,\n) => void | Promise<void>;\n\n/** Generate usage text without writing to stdout or stderr. */\nexport async function renderUsage(command: AnyCommandDef): Promise<string> {\n return formatUsage(summarizeUsage(command));\n}\n\n/** Generate and write usage text, awaiting asynchronous writers. */\nexport async function showUsage(\n command: AnyCommandDef,\n options: ShowUsageOptions = {},\n): Promise<void> {\n const usage = summarizeUsage(command);\n const text = formatUsage(usage);\n if (options.write) return options.write(text);\n const printer = options.printer ?? selectOutputPrinter(options);\n return printer.print({\n type: \"usage\",\n usage,\n text,\n stream: options.stream ?? \"stdout\",\n });\n}\n","import type { ArgsSchema } from \"./schema.ts\";\nimport type { AnyCommandDef, CommandDef } from \"./command.ts\";\nimport { HackshPromptError, summarizeError, ZittyUsageError } from \"./errors.ts\";\nimport { createLogger } from \"./logger.ts\";\nimport {\n parseCommandArgs,\n tokenizedBefore,\n tokenizeCommandArgs,\n type TokenizedCommandArgs,\n} from \"./parser.ts\";\nimport {\n createJsonPrinter,\n createPrintQueue,\n resolveOutputMode,\n type Printer,\n type PrintQueue,\n type PrintStream,\n type TerminalInput,\n} from \"./printer.ts\";\nimport { selectOutputPrinter, type OutputOptions } from \"./output.ts\";\nimport { showUsage, summarizeUsage, type ShowUsageCallback } from \"./usage.ts\";\n\nexport type { OutputOptions } from \"./output.ts\";\n\ninterface CommandSegment {\n command: AnyCommandDef;\n rawArgs: string[];\n tokenized: TokenizedCommandArgs;\n}\n\ninterface ResolvedCommand extends CommandSegment {\n parents: CommandSegment[];\n segments: CommandSegment[];\n}\n\nfunction namedChild(child: AnyCommandDef, name: string): AnyCommandDef {\n return child.name ? child : { ...child, name };\n}\n\nfunction resolveCommand(root: AnyCommandDef, rawArgs: string[]): ResolvedCommand {\n let command = root;\n let remaining = rawArgs;\n const parents: ResolvedCommand[\"parents\"] = [];\n const segments: ResolvedCommand[\"segments\"] = [];\n\n for (;;) {\n const tokenized = tokenizeCommandArgs(command, remaining);\n const index = command.subCommands\n ? tokenized.tokens.find((token) => token.kind === \"positional\")?.index\n : undefined;\n if (index === undefined) {\n const segment = { command, rawArgs: remaining, tokenized };\n segments.push(segment);\n return { ...segment, parents, segments };\n }\n const name = remaining[index]!;\n const child = command.subCommands?.[name];\n if (!child) throw new ZittyUsageError(`Unknown command \\`${name}\\``, command);\n const prefix = remaining.slice(0, index);\n const segment = { command, rawArgs: prefix, tokenized: tokenizedBefore(tokenized, index) };\n parents.push(segment);\n segments.push(segment);\n command = namedChild(child, name);\n remaining = remaining.slice(index + 1);\n }\n}\n\nasync function executeCommand<S extends ArgsSchema>(\n root: CommandDef<S>,\n argv: string[],\n displayUsage: ShowUsageCallback,\n printer: Printer,\n loggerOptions: Parameters<typeof createLogger>[2],\n): Promise<unknown> {\n const resolved = resolveCommand(root, argv);\n if (resolved.segments[0]?.tokenized.version) {\n await printer.print({ type: \"version\", version: root.version ?? \"\" });\n return undefined;\n }\n if (resolved.segments.some(({ tokenized }) => tokenized.help)) {\n await printUsage(displayUsage, resolved.command, printer, \"stdout\");\n return undefined;\n }\n\n for (const parent of resolved.parents) {\n await parseCommandArgs(parent.command, parent.rawArgs, parent.tokenized);\n }\n const parsed = await parseCommandArgs(resolved.command, resolved.rawArgs, resolved.tokenized);\n if (!resolved.command.run) {\n throw new ZittyUsageError(\"No command specified\", resolved.command);\n }\n const category = resolved.segments.flatMap(({ command }) =>\n command.name === undefined ? [] : [command.name],\n );\n return resolved.command.run({\n ...parsed,\n cmd: resolved.command,\n rawArgs: resolved.rawArgs,\n logger: createLogger(printer, category, loggerOptions),\n });\n}\n\nfunction printUsage(\n displayUsage: ShowUsageCallback,\n command: AnyCommandDef,\n printer: Printer,\n stream: PrintStream,\n): void | Promise<void> {\n return displayUsage(command, {\n write: (text) => printer.print({ type: \"usage\", usage: summarizeUsage(command), text, stream }),\n });\n}\n\nexport interface RunCommandOptions extends OutputOptions {\n printer?: Printer;\n showUsage?: ShowUsageCallback;\n}\n\ninterface PreparedOutput extends PrintQueue {\n interactive: boolean;\n input: TerminalInput;\n}\n\nfunction prepareOutput(options: RunCommandOptions): PreparedOutput {\n const input = options.stdin ?? process.stdin;\n const mode = resolveOutputMode({\n output: options.output,\n env: options.env,\n inputIsTTY: input.isTTY,\n outputIsTTY: (options.stdout ?? process.stdout).isTTY,\n });\n return {\n ...createPrintQueue(selectOutputPrinter(options, options.printer, mode)),\n interactive: mode.interactive,\n input,\n };\n}\n\nexport async function runCommand<S extends ArgsSchema>(\n root: CommandDef<S>,\n argv: string[],\n options: RunCommandOptions = {},\n): Promise<unknown> {\n const output = prepareOutput(options);\n try {\n return await executeCommand(root, argv, options.showUsage ?? showUsage, output.printer, {\n interactive: output.interactive,\n input: output.input,\n printPrompt: (event) => output.printChecked(event),\n });\n } finally {\n await output.drain();\n }\n}\n\nexport interface RunMainOptions extends OutputOptions {\n onError?: (error: unknown) => void | Promise<void>;\n argv?: string[];\n printer?: Printer;\n showUsage?: ShowUsageCallback;\n}\n\nasync function drainAndExit(output: PrintQueue, code = 1): Promise<never> {\n try {\n await output.drain();\n } finally {\n process.exit(code);\n }\n}\n\nfunction commandErrorExitCode(error: unknown): number {\n return error instanceof HackshPromptError && error.reason === \"cancelled\" ? 130 : 1;\n}\n\nasync function reportOutputSetupError(error: unknown, options: RunMainOptions): Promise<never> {\n if (options.onError) {\n await options.onError(error);\n return drainAndExit(createPrintQueue(options.printer ?? { print: () => undefined }));\n }\n\n const output = createPrintQueue(\n options.printer ??\n createJsonPrinter({\n stdout: options.stdout ?? process.stdout,\n stderr: options.stderr ?? process.stderr,\n }),\n );\n await output.printer.print({ type: \"error\", error: summarizeError(error) });\n return drainAndExit(output);\n}\n\nexport async function runMain<S extends ArgsSchema>(\n command: CommandDef<S>,\n options: RunMainOptions = {},\n): Promise<void> {\n const displayUsage = options.showUsage ?? showUsage;\n let output: PreparedOutput;\n try {\n output = prepareOutput(options);\n } catch (error) {\n return reportOutputSetupError(error, options);\n }\n try {\n await executeCommand(\n command,\n options.argv ?? process.argv.slice(2),\n displayUsage,\n output.printer,\n {\n interactive: output.interactive,\n input: output.input,\n printPrompt: (event) => output.printChecked(event),\n },\n );\n } catch (error) {\n if (options.onError) {\n await options.onError(error);\n return drainAndExit(output, commandErrorExitCode(error));\n }\n try {\n if (error instanceof ZittyUsageError) {\n await output.printer.print({ type: \"error\", error: summarizeError(error) });\n await printUsage(displayUsage, error.command, output.printer, \"stderr\");\n } else {\n await output.printer.print({\n type: \"error\",\n error: summarizeError(error),\n });\n }\n } finally {\n await drainAndExit(output, commandErrorExitCode(error));\n }\n }\n await output.drain();\n}\n\nexport function createMain<S extends ArgsSchema>(\n command: CommandDef<S>,\n options: RunMainOptions = {},\n): (argv?: string[]) => Promise<void> {\n return (argv) => runMain(command, argv === undefined ? options : { ...options, argv });\n}\n"],"mappings":";;;;;AAAA,SAAgB,UAAU,OAAuB;CAC/C,OAAO,MAAM,WAAW,sBAAsB,OAAO,CAAC,CAAC,YAAY;AACrE;AAEA,SAAgB,UAAU,OAAsD;CAC9E,OAAO,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI;AAC/C;ACyBA,SAAS,WAAW,QAA0B;CAC5C,OAAO,OAAO,KAAK;AACrB;AAEA,SAAS,YAAY,KAAmC;CACtD,QAAQ,IAAI,MAAZ;EACE,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK;EACL,KAAK,YACH,OAAO,IAAI;EACb,KAAK,QACH,OAAO,IAAI;EACb,SACE;CACJ;AACF;;AAGA,SAAgB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GACpB,OAAO,OAAO;GACd,cAAc,UAAU,OAAO,aAAa,KAAK;EACnD,CACF;CACF,SAAS,OAAO;EACd,IAAI,QAAQ,SAAS;GACnB,MAAM,QAAQ,QAAQ,KAAK;GAC3B,OAAO,aAAa,QAAQ,qBAAqB,KAAK,CAAC;EACzD;EACA,IAAI;GACF,IAAI,iBAAiB,iBAAiB;IACpC,MAAM,OAAO,QAAQ,MAAM;KAAE,MAAM;KAAS,OAAO,eAAe,KAAK;IAAE,CAAC;IAC1E,MAAM,WAAW,cAAc,MAAM,SAAS,OAAO,SAAS,QAAQ;GACxE,OACE,MAAM,OAAO,QAAQ,MAAM;IACzB,MAAM;IACN,OAAO,eAAe,KAAK;GAC7B,CAAC;EAEL,UAAU;GACR,MAAM,aAAa,QAAQ,qBAAqB,KAAK,CAAC;EACxD;CACF;CACA,MAAM,OAAO,MAAM;AACrB;AAEA,SAAgB,WACd,SACA,UAA0B,CAAC,GACS;CACpC,QAAQ,SAAS,QAAQ,SAAS,SAAS,KAAA,IAAY,UAAU;EAAE,GAAG;EAAS;CAAK,CAAC;AACvF"}
1
+ {"version":3,"file":"index.js","names":["safeString","parseNodeArgs","details","#interactive","#inputValue","#printEvent","#bufferedKeys","#print","#run","#active"],"sources":["../src/options.ts","../src/schema.ts","../src/command.ts","../src/errors.ts","../src/parser.ts","../src/serialization.ts","../src/printer.ts","../src/pretty.ts","../src/prompts.ts","../src/logger.ts","../src/output.ts","../src/usage.ts","../src/run.ts"],"sourcesContent":["export function kebabCase(value: string): string {\n return value.replaceAll(/([a-z0-9])([A-Z])/g, \"$1-$2\").toLowerCase();\n}\n\nexport function aliasList(value: string | readonly string[]): readonly string[] {\n return typeof value === \"string\" ? [value] : value;\n}\n","import { globalRegistry, type $ZodObject, type $ZodType } from \"zod/v4/core\";\n\nexport type ArgsSchema = $ZodObject;\nexport type EmptyArgs = $ZodObject<{}>;\nexport type ShapeOf<S extends ArgsSchema> = S[\"_zod\"][\"def\"][\"shape\"];\nexport type ArgKey<S extends ArgsSchema> = Extract<keyof ShapeOf<S>, string>;\nexport type OptionKey<S extends ArgsSchema> = Exclude<ArgKey<S>, typeof POSITIONALS_KEY>;\n\nexport const POSITIONALS_KEY = \"_\";\n\nexport interface ArgInfo {\n readonly takesValue: boolean;\n readonly required: boolean;\n readonly defaultValue: unknown;\n readonly description: string | undefined;\n readonly title: string | undefined;\n readonly choices: readonly string[] | undefined;\n}\n\nexport interface Positional {\n readonly schema: $ZodType;\n readonly label: string;\n}\n\nexport interface Positionals {\n readonly items: readonly Positional[];\n readonly rest: Positional | undefined;\n}\n\ntype ZodDef = Record<string, unknown> & { type: string };\n\nfunction definition(schema: $ZodType): ZodDef {\n return schema._zod.def as ZodDef;\n}\n\nfunction innerSchema(def: ZodDef): $ZodType | undefined {\n switch (def.type) {\n case \"optional\":\n case \"nonoptional\":\n case \"nullable\":\n case \"default\":\n case \"prefault\":\n case \"catch\":\n case \"readonly\":\n return def.innerType as $ZodType;\n case \"pipe\":\n return def.in as $ZodType;\n default:\n return undefined;\n }\n}\n\n/** Read only the common zod/v4/core definition and registry structures. */\nexport function readArgInfo(schema: $ZodType): ArgInfo {\n let current: $ZodType | undefined = schema;\n let required = true;\n let defaultValue: unknown;\n let description: string | undefined;\n let title: string | undefined;\n\n while (current) {\n const metadata = globalRegistry.get(current);\n description ??= metadata?.description;\n title ??= metadata?.title;\n\n const def = definition(current);\n if (def.type === \"optional\" || def.type === \"default\" || def.type === \"prefault\") {\n required = false;\n }\n if (def.type === \"default\" && defaultValue === undefined) defaultValue = def.defaultValue;\n current = innerSchema(def);\n }\n\n const base = unwrapInput(schema);\n return {\n takesValue: definition(base).type !== \"boolean\",\n required,\n defaultValue,\n description,\n title,\n choices: enumChoices(base),\n };\n}\n\n/** Read the `_` tuple or array schema that declares positional arguments. */\nexport function readPositionals(shape: Record<string, $ZodType>): Positionals | undefined {\n const field = shape[POSITIONALS_KEY];\n if (!field) return undefined;\n const def = definition(unwrapInput(field));\n let items: readonly $ZodType[];\n let rest: $ZodType | undefined;\n if (def.type === \"tuple\") {\n items = def.items as readonly $ZodType[];\n rest = (def.rest as $ZodType | null) ?? undefined;\n } else if (def.type === \"array\") {\n items = [];\n rest = def.element as $ZodType;\n } else {\n throw new TypeError(\"Positional arguments `_` must use a tuple or array schema\");\n }\n return {\n items: items.map((schema, index) => ({\n schema,\n label: readArgInfo(schema).title ?? `ARG${index + 1}`,\n })),\n rest: rest && { schema: rest, label: readArgInfo(rest).title ?? \"ARGS\" },\n };\n}\n\nfunction enumChoices(schema: $ZodType): readonly string[] | undefined {\n const def = definition(schema);\n const candidate = def.type === \"array\" ? unwrapInput(def.element as $ZodType) : schema;\n const candidateDef = definition(candidate);\n if (candidateDef.type !== \"enum\") return undefined;\n const values = candidate._zod.values;\n return values ? [...values].map(String) : undefined;\n}\n\n/** Whether the schema accepts an array after removing supported input wrappers. */\nexport function isArrayInput(schema: $ZodType): boolean {\n return definition(unwrapInput(schema)).type === \"array\";\n}\n\nfunction unwrapInput(schema: $ZodType): $ZodType {\n let current = schema;\n for (;;) {\n const inner = innerSchema(definition(current));\n if (!inner) return current;\n current = inner;\n }\n}\n\nexport function schemaShape(schema: ArgsSchema): Record<string, $ZodType> {\n return schema._zod.def.shape as Record<string, $ZodType>;\n}\n","import type { output } from \"zod/v4/core\";\nimport type { Logger } from \"./logger.ts\";\nimport { aliasList } from \"./options.ts\";\nimport {\n isArrayInput,\n POSITIONALS_KEY,\n readArgInfo,\n readPositionals,\n schemaShape,\n type ArgsSchema,\n type EmptyArgs,\n type OptionKey,\n} from \"./schema.ts\";\n\nexport interface ArgOptions {\n alias?: string | readonly string[];\n valueName?: string;\n}\n\nexport type ArgOptionsMap<S extends ArgsSchema> = Partial<Record<OptionKey<S>, ArgOptions>>;\n\nexport interface CommandContext<S extends ArgsSchema> {\n cmd: CommandDef<S>;\n args: output<S>;\n rawArgs: string[];\n passthrough: string[];\n extraArgs: string[];\n logger: Logger;\n}\n\nexport interface CommandDef<S extends ArgsSchema = EmptyArgs> {\n name?: string;\n version?: string;\n description?: string;\n hidden?: boolean;\n args?: S;\n argOptions?: ArgOptionsMap<S>;\n subCommands?: Record<string, CommandDef<ArgsSchema>>;\n run?(context: CommandContext<S>): unknown;\n}\n\nexport type AnyCommandDef = CommandDef<ArgsSchema>;\n\nexport function defineCommand<S extends ArgsSchema = EmptyArgs>(def: CommandDef<S>): CommandDef<S> {\n const shape = def.args ? schemaShape(def.args) : {};\n const positionals = readPositionals(shape);\n\n if (positionals) {\n let sawOptional = false;\n for (const { schema, label } of positionals.items) {\n const info = readArgInfo(schema);\n if (isArrayInput(schema)) {\n throw new TypeError(\n `Positional argument \\`${label}\\` cannot be an array; use a tuple rest`,\n );\n }\n if (!info.takesValue) {\n throw new TypeError(`Boolean argument \\`${label}\\` cannot be positional`);\n }\n if (sawOptional && info.required) {\n throw new TypeError(\n `Required positional \\`${label}\\` cannot follow an optional positional`,\n );\n }\n sawOptional ||= !info.required;\n }\n if (def.subCommands && Object.keys(def.subCommands).length > 0) {\n throw new TypeError(\"A command cannot define both positional arguments and subcommands\");\n }\n }\n\n const usedAliases = new Set<string>();\n for (const [key, options] of Object.entries(def.argOptions ?? {})) {\n if (key === POSITIONALS_KEY) {\n throw new TypeError(\"Positional arguments cannot have argument options\");\n }\n if (!shape[key]) throw new TypeError(`Unknown argument options key \\`${key}\\``);\n if (options?.alias === undefined) continue;\n for (const alias of aliasList(options.alias)) {\n if (alias.length !== 1)\n throw new TypeError(`Alias \\`${alias}\\` must be exactly one character`);\n if (usedAliases.has(alias)) throw new TypeError(`Duplicate alias \\`${alias}\\``);\n usedAliases.add(alias);\n }\n }\n\n for (const key of Object.keys(shape)) {\n if (key !== POSITIONALS_KEY && /^no[-A-Z]/.test(key)) {\n throw new TypeError(`Option \\`${key}\\` conflicts with --no- negation`);\n }\n }\n\n return def;\n}\n","import type { $ZodIssue } from \"zod/v4/core\";\nimport type { AnyCommandDef } from \"./command.ts\";\n\nexport interface HackshIssue {\n arg: string;\n message: string;\n issue?: $ZodIssue;\n}\n\nexport class HackshUsageError extends Error {\n readonly command: AnyCommandDef;\n\n constructor(message: string, command: AnyCommandDef, options?: ErrorOptions) {\n super(message, options);\n this.name = \"HackshUsageError\";\n this.command = command;\n }\n}\n\nexport class HackshValidationError extends HackshUsageError {\n readonly issues: ReadonlyArray<HackshIssue>;\n\n constructor(command: AnyCommandDef, issues: ReadonlyArray<HackshIssue>) {\n super(\n `Invalid arguments:\\n${issues.map(({ arg, message }) => ` ${arg}: ${message}`).join(\"\\n\")}`,\n command,\n );\n this.name = \"HackshValidationError\";\n this.issues = issues;\n }\n}\n\nexport type PromptKind = \"select\" | \"confirm\" | \"text\";\n\nexport type HackshPromptErrorReason =\n | \"non-interactive\"\n | \"cancelled\"\n | \"eof\"\n | \"overlapping\"\n | \"invalid-options\"\n | \"input-error\"\n | \"printer-error\";\n\nexport interface PromptErrorDetails {\n kind: PromptKind;\n message: string;\n choices?: readonly string[];\n}\n\n/** An input request that could not be completed safely. */\nexport class HackshPromptError extends Error {\n readonly reason: HackshPromptErrorReason;\n readonly prompt: PromptErrorDetails;\n\n constructor(\n reason: HackshPromptErrorReason,\n prompt: PromptErrorDetails,\n message: string,\n options?: ErrorOptions,\n ) {\n super(message, options);\n this.name = \"HackshPromptError\";\n this.reason = reason;\n this.prompt = prompt;\n }\n}\n\nexport type HackshErrorKind = \"error\" | \"prompt\" | \"usage\" | \"validation\" | \"thrown\";\n\nexport interface ValidationIssueSummary {\n arg: string;\n message: string;\n code?: string;\n path?: readonly PropertyKey[];\n details?: Readonly<Record<string, unknown>>;\n}\n\nexport interface HackshErrorSummary {\n kind: HackshErrorKind;\n name: string;\n message: string;\n stack?: string;\n cause?: unknown;\n issues?: readonly ValidationIssueSummary[];\n properties?: Readonly<Record<string, unknown>>;\n value?: unknown;\n}\n\nfunction safeString(value: unknown, fallback: string): string {\n try {\n return String(value);\n } catch {\n return fallback;\n }\n}\n\nfunction readProperty(value: object, key: PropertyKey): unknown {\n try {\n return Reflect.get(value, key);\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction enumerableKeys(value: object): string[] {\n try {\n return Object.keys(value);\n } catch {\n return [];\n }\n}\n\nfunction hasToJSON(value: object): boolean {\n try {\n return typeof Reflect.get(value, \"toJSON\") === \"function\";\n } catch {\n return false;\n }\n}\n\nfunction isPlainObject(value: object): boolean {\n try {\n const prototype = Object.getPrototypeOf(value);\n return prototype === Object.prototype || prototype === null;\n } catch {\n return false;\n }\n}\n\nfunction summarizeIssue(\n { arg, message, issue }: HackshIssue,\n seen: WeakMap<object, unknown>,\n): ValidationIssueSummary {\n if (!issue) return { arg, message };\n const details: Record<string, unknown> = {};\n for (const key of enumerableKeys(issue)) {\n if ([\"code\", \"path\", \"message\", \"inst\"].includes(key)) continue;\n details[key] = summarizeErrors(readProperty(issue, key), seen);\n }\n const code = readProperty(issue, \"code\");\n const path = readProperty(issue, \"path\");\n return {\n arg,\n message,\n ...(typeof code === \"string\" ? { code } : {}),\n ...(Array.isArray(path) ? { path } : {}),\n ...(Object.keys(details).length === 0 ? {} : { details }),\n };\n}\n\nfunction errorKind(error: Error): HackshErrorKind {\n if (error instanceof HackshPromptError) return \"prompt\";\n if (error instanceof HackshValidationError) return \"validation\";\n if (error instanceof HackshUsageError) return \"usage\";\n return \"error\";\n}\n\nfunction summarizeErrorWithSeen(error: Error, seen: WeakMap<object, unknown>): HackshErrorSummary {\n const summary: HackshErrorSummary = {\n kind: errorKind(error),\n name: safeString(readProperty(error, \"name\"), \"Error\"),\n message: safeString(readProperty(error, \"message\"), \"[Unserializable error message]\"),\n };\n seen.set(error, summary);\n\n const stack = readProperty(error, \"stack\");\n const cause = readProperty(error, \"cause\");\n if (typeof stack === \"string\") summary.stack = stack;\n if (cause !== undefined) summary.cause = summarizeErrors(cause, seen);\n if (error instanceof HackshValidationError) {\n summary.issues = error.issues.map((issue) => summarizeIssue(issue, seen));\n }\n\n const reserved = new Set([\"name\", \"message\", \"stack\", \"cause\", \"command\", \"issues\"]);\n const properties: Record<string, unknown> = {};\n for (const key of enumerableKeys(error)) {\n if (reserved.has(key)) continue;\n properties[key] = summarizeErrors(readProperty(error, key), seen);\n }\n if (Object.keys(properties).length > 0) summary.properties = properties;\n return summary;\n}\n\n/** Recursively replace Error values with command- and schema-free summaries. */\nexport function summarizeErrors(\n value: unknown,\n seen: WeakMap<object, unknown> = new WeakMap(),\n): unknown {\n if (typeof value !== \"object\" || value === null) return value;\n const existing = seen.get(value);\n if (existing !== undefined) return existing;\n if (value instanceof Error) return summarizeErrorWithSeen(value, seen);\n\n if (Array.isArray(value)) {\n const result: unknown[] = [];\n seen.set(value, result);\n let changed = false;\n for (const item of value) {\n const summarized = summarizeErrors(item, seen);\n result.push(summarized);\n changed ||= summarized !== item;\n }\n if (changed) return result;\n seen.set(value, value);\n return value;\n }\n if (value instanceof Map) {\n const result = new Map<unknown, unknown>();\n seen.set(value, result);\n let changed = false;\n for (const [key, item] of value) {\n const summarizedKey = summarizeErrors(key, seen);\n const summarizedItem = summarizeErrors(item, seen);\n result.set(summarizedKey, summarizedItem);\n changed ||= summarizedKey !== key || summarizedItem !== item;\n }\n if (changed) return result;\n seen.set(value, value);\n return value;\n }\n if (value instanceof Set) {\n const result = new Set<unknown>();\n seen.set(value, result);\n let changed = false;\n for (const item of value) {\n const summarized = summarizeErrors(item, seen);\n result.add(summarized);\n changed ||= summarized !== item;\n }\n if (changed) return result;\n seen.set(value, value);\n return value;\n }\n if (ArrayBuffer.isView(value) || hasToJSON(value) || !isPlainObject(value)) return value;\n\n const result: Record<string, unknown> = {};\n seen.set(value, result);\n let changed = false;\n for (const key of enumerableKeys(value)) {\n const original = readProperty(value, key);\n const summarized = summarizeErrors(original, seen);\n result[key] = summarized;\n changed ||= summarized !== original;\n }\n if (changed) return result;\n seen.set(value, value);\n return value;\n}\n\n/** Convert any thrown value into a canonical error description. */\nexport function summarizeError(error: unknown): HackshErrorSummary {\n if (error instanceof Error) return summarizeErrorWithSeen(error, new WeakMap());\n return {\n kind: \"thrown\",\n name: \"NonErrorThrown\",\n message: safeString(error, \"[Unserializable thrown value]\"),\n value: summarizeErrors(error),\n };\n}\n","import { parseArgs as parseNodeArgs } from \"node:util\";\nimport { safeParseAsync, type $ZodIssue, type output } from \"zod/v4/core\";\nimport type { AnyCommandDef, CommandDef } from \"./command.ts\";\nimport { HackshValidationError, type HackshIssue } from \"./errors.ts\";\nimport { aliasList, kebabCase } from \"./options.ts\";\nimport {\n POSITIONALS_KEY,\n readArgInfo,\n readPositionals,\n schemaShape,\n type ArgsSchema,\n type Positionals,\n} from \"./schema.ts\";\n\nexport interface ParsedCommand<S extends ArgsSchema> {\n args: output<S>;\n passthrough: string[];\n extraArgs: string[];\n}\n\ninterface OptionDefinition {\n readonly key: string;\n readonly kebabName: string;\n readonly takesValue: boolean;\n}\n\ninterface OptionModel {\n readonly definitions: Map<string, OptionDefinition>;\n readonly parserOptions: Record<string, { type: \"string\" | \"boolean\"; short?: string }>;\n readonly aliases: Set<string>;\n}\n\ninterface KnownOptionToken {\n readonly kind: \"known-option\";\n readonly index: number;\n readonly definition: OptionDefinition;\n readonly value: string | boolean;\n}\n\ninterface UnknownOptionToken {\n readonly kind: \"unknown-option\";\n readonly index: number;\n readonly value: string;\n}\n\ninterface PositionalToken {\n readonly kind: \"positional\";\n readonly index: number;\n readonly value: string;\n}\n\ntype CommandToken = KnownOptionToken | UnknownOptionToken | PositionalToken;\n\nexport interface TokenizedCommandArgs {\n readonly tokens: readonly CommandToken[];\n readonly passthrough: string[];\n readonly issues: readonly IndexedIssue[];\n readonly help: boolean;\n readonly helpIndex: number | undefined;\n readonly version: boolean;\n readonly versionIndex: number | undefined;\n}\n\ninterface IndexedIssue {\n readonly index: number;\n readonly issue: HackshIssue;\n}\n\nfunction optionModel(command: AnyCommandDef): OptionModel {\n const definitions = new Map<string, OptionDefinition>();\n const parserOptions: OptionModel[\"parserOptions\"] = {};\n const allAliases = new Set<string>();\n\n if (command.args) {\n for (const [key, schema] of Object.entries(schemaShape(command.args))) {\n if (key === POSITIONALS_KEY) continue;\n const alias = command.argOptions?.[key]?.alias;\n const aliases = alias ? aliasList(alias) : [];\n const definition: OptionDefinition = {\n key,\n kebabName: kebabCase(key),\n takesValue: readArgInfo(schema).takesValue,\n };\n const type = definition.takesValue ? \"string\" : \"boolean\";\n for (const name of new Set([key, definition.kebabName])) {\n definitions.set(name, definition);\n parserOptions[name] = { type };\n }\n for (const alias of aliases) {\n allAliases.add(alias);\n definitions.set(alias, definition);\n parserOptions[alias] = { type, short: alias };\n }\n }\n }\n return { definitions, parserOptions, aliases: allAliases };\n}\n\nfunction commandPositionals(command: AnyCommandDef): Positionals | undefined {\n return command.args ? readPositionals(schemaShape(command.args)) : undefined;\n}\n\nfunction displayName(command: AnyCommandDef, path: readonly PropertyKey[]): string {\n const [first, index] = path;\n if (typeof first !== \"string\") return \"arguments\";\n if (first !== POSITIONALS_KEY) return `--${kebabCase(first)}`;\n const positionals = commandPositionals(command);\n if (!positionals || typeof index !== \"number\") return \"arguments\";\n const item = positionals.items[index];\n if (item) return `<${item.label}>`;\n return positionals.rest ? `<${positionals.rest.label}...>` : \"arguments\";\n}\n\nexport function tokenizeCommandArgs(\n command: AnyCommandDef,\n rawArgs: readonly string[],\n): TokenizedCommandArgs {\n const model = optionModel(command);\n const separator = rawArgs.indexOf(\"--\");\n const beforeSeparator = separator === -1 ? [...rawArgs] : rawArgs.slice(0, separator);\n const passthrough = separator === -1 ? [] : rawArgs.slice(separator + 1);\n const negativeIndexes = new Set<number>();\n const valuedNegativeIndexes = new Set<number>();\n const issues: IndexedIssue[] = [];\n let recordedMissingValue = false;\n const parserArgs = beforeSeparator.map((raw, index) => {\n if (!raw.startsWith(\"--no-\")) return raw;\n const equals = raw.indexOf(\"=\");\n const name = raw.slice(5, equals === -1 ? undefined : equals);\n const definition = model.definitions.get(name);\n if (!definition || definition.takesValue) return raw;\n negativeIndexes.add(index);\n if (equals !== -1) {\n valuedNegativeIndexes.add(index);\n return `--${definition.key}${raw.slice(equals)}`;\n }\n return `--${definition.key}`;\n });\n\n const parsed = parseNodeArgs({\n args: parserArgs,\n options: model.parserOptions,\n allowPositionals: true,\n strict: false,\n tokens: true,\n });\n const tokens: CommandToken[] = [];\n const unknownIndexes = new Set<number>();\n let help = false;\n let helpIndex: number | undefined;\n let version = false;\n let versionIndex: number | undefined;\n for (const token of parsed.tokens) {\n if (token.kind === \"positional\") {\n tokens.push({ kind: \"positional\", index: token.index, value: token.value });\n continue;\n }\n if (token.kind !== \"option\") continue;\n const isHelp =\n token.rawName === \"--help\" || (token.rawName === \"-h\" && !model.aliases.has(\"h\"));\n const isVersion =\n token.rawName === \"--version\" || (token.rawName === \"-v\" && !model.aliases.has(\"v\"));\n if (isHelp) {\n help = true;\n helpIndex ??= token.index;\n }\n if (isVersion) {\n version = true;\n versionIndex ??= token.index;\n }\n const definition = model.definitions.get(token.name);\n if (definition) {\n if (\n definition.takesValue &&\n (token.value === undefined ||\n (!token.inlineValue && token.value.startsWith(\"-\") && token.value !== \"-\"))\n ) {\n if (!recordedMissingValue) {\n issues.push({\n index: token.index,\n issue: { arg: `--${definition.kebabName}`, message: \"requires a value\" },\n });\n recordedMissingValue = true;\n }\n }\n let value: string | boolean = token.value ?? true;\n if (!definition.takesValue) {\n if (valuedNegativeIndexes.has(token.index)) {\n const rawName = beforeSeparator[token.index]!.split(\"=\", 1)[0]!;\n issues.push({\n index: token.index,\n issue: { arg: rawName, message: \"does not accept a value\" },\n });\n value = false;\n } else if (negativeIndexes.has(token.index)) {\n value = false;\n } else if (token.inlineValue) {\n if (token.value === \"true\") value = true;\n else if (token.value === \"false\") value = false;\n else {\n issues.push({\n index: token.index,\n issue: { arg: token.rawName, message: \"expects true or false\" },\n });\n }\n }\n }\n tokens.push({\n kind: \"known-option\",\n index: token.index,\n definition,\n value: definition.takesValue ? (token.value ?? \"\") : value,\n });\n } else if (!unknownIndexes.has(token.index)) {\n unknownIndexes.add(token.index);\n tokens.push({\n kind: \"unknown-option\",\n index: token.index,\n value: beforeSeparator[token.index]!,\n });\n }\n }\n\n return {\n tokens,\n passthrough,\n issues,\n help,\n helpIndex,\n version,\n versionIndex,\n };\n}\n\nexport function tokenizedBefore(\n tokenized: TokenizedCommandArgs,\n endIndex: number,\n): TokenizedCommandArgs {\n const help = tokenized.helpIndex !== undefined && tokenized.helpIndex < endIndex;\n const version = tokenized.versionIndex !== undefined && tokenized.versionIndex < endIndex;\n return {\n tokens: tokenized.tokens.filter((token) => token.index < endIndex),\n passthrough: [],\n issues: tokenized.issues.filter(({ index }) => index < endIndex),\n help,\n helpIndex: help ? tokenized.helpIndex : undefined,\n version,\n versionIndex: version ? tokenized.versionIndex : undefined,\n };\n}\n\nfunction zodIssues(command: AnyCommandDef, issues: readonly $ZodIssue[]): HackshIssue[] {\n return issues.map((issue) => ({\n arg: displayName(command, issue.path),\n message: issue.message,\n issue,\n }));\n}\n\nexport async function parseCommandArgs<S extends ArgsSchema>(\n command: CommandDef<S>,\n rawArgs: string[],\n tokenized: TokenizedCommandArgs = tokenizeCommandArgs(command, rawArgs),\n): Promise<ParsedCommand<S>> {\n if (tokenized.issues.length > 0) {\n throw new HackshValidationError(\n command,\n tokenized.issues.map(({ issue }) => issue),\n );\n }\n\n const input: Record<string, string | boolean | string[] | undefined> = {};\n const positionals = commandPositionals(command);\n const positionalValues: string[] = [];\n if (positionals) input[POSITIONALS_KEY] = positionalValues;\n const extraArgs: string[] = [];\n for (const token of tokenized.tokens) {\n if (token.kind === \"known-option\") input[token.definition.key] = token.value;\n else if (token.kind === \"unknown-option\") extraArgs.push(token.value);\n else if (\n positionals &&\n (positionals.rest || positionalValues.length < positionals.items.length)\n ) {\n positionalValues.push(token.value);\n } else extraArgs.push(token.value);\n }\n\n if (!command.args)\n return { args: input as output<S>, passthrough: tokenized.passthrough, extraArgs };\n const result = await safeParseAsync(command.args, input);\n if (!result.success)\n throw new HackshValidationError(command, zodIssues(command, result.error.issues));\n return { args: result.data, passthrough: tokenized.passthrough, extraArgs };\n}\n\n/**\n * Parse and validate one command segment without routing, builtin handling, or output.\n */\nexport async function parseArgs<S extends ArgsSchema>(\n command: CommandDef<S>,\n argv: string[],\n): Promise<output<S>> {\n return (await parseCommandArgs(command, argv)).args;\n}\n","import { stripVTControlCharacters } from \"node:util\";\nimport { summarizeError } from \"./errors.ts\";\n\nfunction safeString(value: unknown): string {\n try {\n return String(value);\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction normalizeProperty(value: object, key: PropertyKey, ancestors: Set<object>): unknown {\n try {\n return normalizeJson(Reflect.get(value, key), ancestors);\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction normalizedKeys(value: object): string[] | undefined {\n try {\n return Object.keys(value);\n } catch {\n return undefined;\n }\n}\n\nconst noToJson = Symbol(\"noToJson\");\n\nfunction normalizedToJson(value: object, ancestors: Set<object>): unknown {\n let toJSON: unknown;\n try {\n toJSON = Reflect.get(value, \"toJSON\");\n } catch {\n return noToJson;\n }\n if (typeof toJSON !== \"function\") return noToJson;\n try {\n const result = Reflect.apply(toJSON, value, []);\n return result === value ? noToJson : normalizeJson(result, ancestors);\n } catch {\n return noToJson;\n }\n}\n\nfunction isArrayBufferView(value: object): value is ArrayBufferView {\n try {\n return ArrayBuffer.isView(value);\n } catch {\n return false;\n }\n}\n\n/** Normalize arbitrary event data into values accepted by JSON.stringify. */\nexport function normalizeJson(value: unknown, ancestors = new Set<object>()): unknown {\n switch (typeof value) {\n case \"string\":\n return stripVTControlCharacters(value);\n case \"boolean\":\n return value;\n case \"number\":\n return Number.isFinite(value) ? value : null;\n case \"bigint\":\n return value.toString();\n case \"undefined\":\n return \"[undefined]\";\n case \"symbol\":\n return `[symbol:${stripVTControlCharacters(value.description ?? \"\")}]`;\n case \"function\":\n return `[function:${stripVTControlCharacters(value.name || \"anonymous\")}]`;\n case \"object\":\n break;\n }\n if (value === null) return null;\n if (ancestors.has(value)) return \"[Circular]\";\n\n const nextAncestors = new Set(ancestors).add(value);\n if (value instanceof Error) return normalizeJson(summarizeError(value), nextAncestors);\n\n const jsonValue = normalizedToJson(value, nextAncestors);\n if (jsonValue !== noToJson) return jsonValue;\n\n if (isArrayBufferView(value)) {\n if (value instanceof DataView) {\n return Array.from(new Uint8Array(value.buffer, value.byteOffset, value.byteLength));\n }\n try {\n return Array.from(value as unknown as Iterable<unknown>, (item) =>\n normalizeJson(item, nextAncestors),\n );\n } catch {\n return \"[Unserializable]\";\n }\n }\n if (value instanceof ArrayBuffer) return Array.from(new Uint8Array(value));\n if (Array.isArray(value)) {\n return Array.from({ length: value.length }, (_, index) =>\n normalizeProperty(value, index, nextAncestors),\n );\n }\n if (value instanceof Map) {\n try {\n return [...value].map(([key, item]) => [\n normalizeJson(key, nextAncestors),\n normalizeJson(item, nextAncestors),\n ]);\n } catch {\n return \"[Unserializable]\";\n }\n }\n if (value instanceof Set) {\n try {\n return [...value].map((item) => normalizeJson(item, nextAncestors));\n } catch {\n return \"[Unserializable]\";\n }\n }\n\n const keys = normalizedKeys(value);\n if (!keys) return safeString(value);\n const result: Record<string, unknown> = {};\n for (const key of keys) {\n result[stripVTControlCharacters(key)] = normalizeProperty(value, key, nextAncestors);\n }\n return result;\n}\n","import type { HackshErrorSummary } from \"./errors.ts\";\nimport type { LogRecord } from \"./logger.ts\";\nimport { normalizeJson } from \"./serialization.ts\";\nimport type { UsageSummary } from \"./usage.ts\";\n\nexport type PrintStream = \"stdout\" | \"stderr\";\nexport type OutputPreference = \"auto\" | \"pretty\" | \"json\";\nexport type OutputFormat = Exclude<OutputPreference, \"auto\">;\n\nexport interface OutputMode {\n format: OutputFormat;\n interactive: boolean;\n color: boolean;\n}\n\nexport interface ResolveOutputModeOptions {\n output?: OutputPreference;\n env?: Readonly<Record<string, string | undefined>>;\n inputIsTTY?: boolean;\n outputIsTTY?: boolean;\n}\n\nfunction fallbackValue(value: unknown): string {\n try {\n return String(value);\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction validatePreference(value: unknown, source: string): OutputPreference | undefined {\n if (value === undefined) return undefined;\n if (value === \"auto\" || value === \"pretty\" || value === \"json\") return value;\n throw new TypeError(\n `Invalid ${source} value ${fallbackValue(value)}; expected auto, pretty, or json`,\n );\n}\n\nfunction readEnvironment(\n env: Readonly<Record<string, string | undefined>>,\n key: string,\n): string | undefined {\n try {\n return env[key];\n } catch {\n return undefined;\n }\n}\n\n/** Resolve output behavior once, before command routing or argument parsing. */\nexport function resolveOutputMode(options: ResolveOutputModeOptions = {}): OutputMode {\n const env = options.env ?? process.env;\n const configured = validatePreference(options.output, \"output\");\n const overridden = validatePreference(readEnvironment(env, \"HACKSH_OUTPUT\"), \"HACKSH_OUTPUT\");\n const requested = overridden ?? configured ?? \"auto\";\n const ci = Boolean(readEnvironment(env, \"CI\"));\n const format = requested === \"auto\" ? (ci ? \"json\" : \"pretty\") : requested;\n const inputIsTTY = options.inputIsTTY ?? process.stdin.isTTY === true;\n const outputIsTTY = options.outputIsTTY ?? process.stdout.isTTY === true;\n return {\n format,\n interactive: format === \"pretty\" && !ci && inputIsTTY && outputIsTTY,\n color: format === \"pretty\" && outputIsTTY && !readEnvironment(env, \"NO_COLOR\"),\n };\n}\n\nexport interface UsagePrintEvent {\n type: \"usage\";\n usage: UsageSummary;\n text: string;\n stream: PrintStream;\n}\n\nexport interface VersionPrintEvent {\n type: \"version\";\n version: string;\n}\n\nexport interface ErrorPrintEvent {\n type: \"error\";\n error: HackshErrorSummary;\n}\n\nexport interface LogPrintEvent {\n type: \"log\";\n record: LogRecord;\n}\n\nexport interface PromptChoiceState {\n value: string;\n label: string;\n hint?: string;\n selected: boolean;\n}\n\nexport type PromptStatus = \"active\" | \"error\" | \"submitted\" | \"closed\";\n\ninterface PromptStateBase {\n message: string;\n status: PromptStatus;\n error?: string;\n}\n\nexport interface SelectPromptState extends PromptStateBase {\n kind: \"select\";\n choices: readonly PromptChoiceState[];\n value: string;\n}\n\nexport interface ConfirmPromptState extends PromptStateBase {\n kind: \"confirm\";\n value: boolean;\n defaultValue?: boolean;\n}\n\nexport interface TextPromptState extends PromptStateBase {\n kind: \"text\";\n value: string;\n placeholder?: string;\n}\n\nexport type PromptState = SelectPromptState | ConfirmPromptState | TextPromptState;\n\nexport interface PromptPrintEvent {\n type: \"prompt\";\n prompt: PromptState;\n}\n\n/** A semantic, command- and schema-free output value emitted by hacksh. */\nexport type PrintEvent =\n | UsagePrintEvent\n | VersionPrintEvent\n | ErrorPrintEvent\n | LogPrintEvent\n | PromptPrintEvent;\n\n/** Receives every output event produced by one command invocation. */\nexport interface Printer {\n print(event: PrintEvent): void | Promise<void>;\n}\n\nfunction isErrorLevel(level: LogRecord[\"level\"]): boolean {\n return level === \"warning\" || level === \"error\" || level === \"fatal\";\n}\n\nexport function eventStream(event: PrintEvent): PrintStream {\n if (event.type === \"error\") return \"stderr\";\n if (event.type === \"usage\") return event.stream;\n if (event.type === \"log\" && isErrorLevel(event.record.level)) return \"stderr\";\n return \"stdout\";\n}\n\nfunction formatTextEvent(event: PrintEvent): string {\n switch (event.type) {\n case \"usage\":\n return event.text;\n case \"version\":\n return event.version;\n case \"error\":\n return event.error.kind === \"usage\" || event.error.kind === \"validation\"\n ? event.error.message\n : `Error: ${event.error.message}`;\n case \"log\":\n return event.record.message;\n case \"prompt\":\n return event.prompt.message;\n }\n}\n\n/** Undecorated console compatibility adapter; automatic output uses the selected format printer. */\nexport const consolePrinter: Printer = {\n print(event) {\n const text = formatTextEvent(event);\n return eventStream(event) === \"stdout\" ? console.log(text) : console.error(text);\n },\n};\n\nexport interface OutputWriter {\n write(text: string): unknown;\n}\n\nexport interface TerminalInput {\n readonly isTTY?: boolean;\n readonly isRaw?: boolean;\n readonly readableFlowing?: boolean | null;\n setRawMode?(mode: boolean): unknown;\n resume(): unknown;\n pause(): unknown;\n on(event: string, listener: (...args: never[]) => void): unknown;\n removeListener(event: string, listener: (...args: never[]) => void): unknown;\n}\n\nexport interface TerminalOutput extends OutputWriter {\n readonly isTTY?: boolean;\n readonly columns?: number;\n}\n\nexport interface JsonPrinterOptions {\n stdout?: OutputWriter;\n stderr?: OutputWriter;\n}\n\nexport interface StreamPrinterOptions {\n stdout: OutputWriter;\n stderr: OutputWriter;\n}\n\n/** Create an undecorated stream-backed compatibility adapter. */\nexport function createStreamPrinter(options: StreamPrinterOptions): Printer {\n return {\n print(event) {\n const writer = eventStream(event) === \"stdout\" ? options.stdout : options.stderr;\n writer.write(`${formatTextEvent(event)}\\n`);\n },\n };\n}\n\n/** Create a one-semantic-event-per-line JSON printer. */\nexport function createJsonPrinter(options: JsonPrinterOptions = {}): Printer {\n const stdout = options.stdout ?? process.stdout;\n const stderr = options.stderr ?? process.stderr;\n return {\n print(event) {\n let serialized: string;\n try {\n serialized = JSON.stringify(normalizeJson(event));\n } catch {\n serialized = JSON.stringify({\n type: event.type,\n serializationError: \"Event data could not be serialized\",\n });\n }\n const line = `${serialized}\\n`;\n (eventStream(event) === \"stdout\" ? stdout : stderr).write(line);\n },\n };\n}\n\nexport interface PrintQueue {\n printer: Printer;\n printChecked(event: PrintEvent): Promise<void>;\n drain(): Promise<void>;\n}\n\n/** Serialize printer calls and retain failures until the invocation drains its output. */\nexport function createPrintQueue(target: Printer): PrintQueue {\n let pending: Promise<void> | undefined;\n let failure: unknown;\n let failed = false;\n\n function recordFailure(error: unknown): void {\n if (!failed) failure = error;\n failed = true;\n }\n\n function track(execution: Promise<void>, retainFailure: boolean): Promise<void> {\n const barrier = execution.catch((error: unknown) => {\n if (retainFailure) recordFailure(error);\n });\n pending = barrier;\n void barrier.then(() => {\n if (pending === barrier) pending = undefined;\n });\n return retainFailure ? barrier : execution;\n }\n\n function enqueue(event: PrintEvent, retainFailure: boolean): void | Promise<void> {\n if (pending)\n return track(\n pending.then(() => target.print(event)),\n retainFailure,\n );\n try {\n const result = target.print(event);\n if (result) return track(Promise.resolve(result), retainFailure);\n } catch (error) {\n if (retainFailure) recordFailure(error);\n else return Promise.reject(error);\n }\n }\n\n const printer: Printer = {\n print(event) {\n return enqueue(event, true);\n },\n };\n\n return {\n printer,\n async printChecked(event) {\n await enqueue(event, false);\n },\n async drain() {\n await pending;\n if (failed) throw failure;\n },\n };\n}\n","import { inspect, stripVTControlCharacters, styleText } from \"node:util\";\nimport type { HackshErrorSummary } from \"./errors.ts\";\nimport type { LogLevel, LogRecord } from \"./logger.ts\";\nimport {\n eventStream,\n type OutputWriter,\n type Printer,\n type PrintEvent,\n type TerminalOutput,\n} from \"./printer.ts\";\n\ntype PrettyMark = LogLevel | \"step\" | \"success\" | \"usage\" | \"version\" | \"errorEvent\" | \"prompt\";\ntype TextStyle = Parameters<typeof styleText>[0];\n\ninterface PrettySymbols {\n bar: string;\n marks: Record<PrettyMark, string>;\n}\n\nconst unicodeSymbols: PrettySymbols = {\n bar: \"│\",\n marks: {\n trace: \"·\",\n debug: \"◆\",\n info: \"●\",\n warning: \"▲\",\n error: \"■\",\n fatal: \"✖\",\n step: \"◇\",\n success: \"✔\",\n usage: \"◆\",\n version: \"●\",\n errorEvent: \"■\",\n prompt: \"?\",\n },\n};\n\nconst asciiSymbols: PrettySymbols = {\n bar: \"|\",\n marks: {\n trace: \".\",\n debug: \":\",\n info: \"i\",\n warning: \"!\",\n error: \"x\",\n fatal: \"X\",\n step: \">\",\n success: \"+\",\n usage: \"?\",\n version: \"i\",\n errorEvent: \"x\",\n prompt: \"?\",\n },\n};\n\nconst markStyles: Record<PrettyMark, TextStyle> = {\n trace: \"gray\",\n debug: \"magenta\",\n info: \"blue\",\n warning: \"yellow\",\n error: \"red\",\n fatal: [\"bgRed\", \"white\", \"bold\"],\n step: \"cyan\",\n success: \"green\",\n usage: \"cyan\",\n version: \"blue\",\n errorEvent: \"red\",\n prompt: \"cyan\",\n};\n\nexport interface PrettyPrinterOptions {\n color: boolean;\n unicode: boolean;\n stdout?: TerminalOutput;\n stderr?: OutputWriter;\n}\n\nfunction safelyInspect(value: unknown): string {\n if (typeof value === \"string\") return value;\n try {\n return inspect(value, {\n breakLength: 80,\n colors: false,\n compact: false,\n depth: null,\n sorted: true,\n });\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nfunction propertyLines(properties: Readonly<Record<string, unknown>>): string[] {\n const lines: string[] = [];\n for (const key of Object.keys(properties).sort()) {\n const rendered = ` ${key}: ${safelyInspect(properties[key])}`.split(\"\\n\");\n lines.push(rendered[0] ?? \"\");\n for (const continuation of rendered.slice(1)) lines.push(` ${continuation}`);\n }\n return lines;\n}\n\nfunction logLines(record: LogRecord): string[] {\n const category = record.category.length > 0 ? `[${record.category.join(\":\")}] ` : \"\";\n const message = record.message.split(\"\\n\");\n return [\n `${category}${message[0] ?? \"\"}`,\n ...message.slice(1),\n ...propertyLines(record.properties),\n ];\n}\n\nfunction errorLines(error: HackshErrorSummary): string[] {\n const lines = error.message.split(\"\\n\");\n const details: Record<string, unknown> = {};\n if (error.cause !== undefined) details.cause = error.cause;\n if (error.properties !== undefined) Object.assign(details, error.properties);\n if (error.value !== undefined) details.value = error.value;\n return [...lines, ...propertyLines(details)];\n}\n\nfunction eventMark(event: PrintEvent): PrettyMark {\n if (event.type === \"usage\") return \"usage\";\n if (event.type === \"version\") return \"version\";\n if (event.type === \"error\") return \"errorEvent\";\n if (event.type === \"prompt\") return event.prompt.status === \"submitted\" ? \"success\" : \"prompt\";\n return event.record.kind === \"message\" ? event.record.level : event.record.kind;\n}\n\nfunction eventLines(event: PrintEvent): string[] {\n switch (event.type) {\n case \"usage\":\n return event.text.split(\"\\n\");\n case \"version\":\n return event.version.split(\"\\n\");\n case \"error\":\n return errorLines(event.error);\n case \"log\":\n return logLines(event.record);\n case \"prompt\": {\n const { prompt } = event;\n if (prompt.status === \"submitted\") {\n const result =\n prompt.kind === \"select\"\n ? (prompt.choices.find(({ value }) => value === prompt.value)?.label ?? prompt.value)\n : prompt.kind === \"confirm\"\n ? prompt.value\n ? \"Yes\"\n : \"No\"\n : prompt.value;\n return [`${prompt.message}: ${result}`];\n }\n const lines = [prompt.message];\n if (prompt.kind === \"select\") {\n for (const choice of prompt.choices) {\n lines.push(\n `${choice.selected ? \">\" : \" \"} ${choice.label}${choice.hint ? ` — ${choice.hint}` : \"\"}`,\n );\n }\n } else if (prompt.kind === \"confirm\") {\n lines.push(\n `${prompt.value ? \"Yes\" : \"No\"}${prompt.defaultValue === undefined ? \"\" : ` (default: ${prompt.defaultValue ? \"yes\" : \"no\"})`}`,\n );\n } else {\n lines.push(prompt.value || (prompt.placeholder ? `(${prompt.placeholder})` : \"\"));\n }\n if (prompt.error) lines.push(prompt.error);\n return lines;\n }\n }\n}\n\nfunction colorize(enabled: boolean, style: TextStyle, text: string): string {\n return enabled ? styleText(style, text, { validateStream: false }) : text;\n}\n\nconst graphemeSegmenter = new Intl.Segmenter(undefined, { granularity: \"grapheme\" });\nconst combiningMark = /\\p{Mark}/u;\nconst pictograph = /\\p{Extended_Pictographic}/u;\n\nfunction isWideCodePoint(codePoint: number): boolean {\n return (\n codePoint >= 0x1100 &&\n (codePoint <= 0x115f ||\n codePoint === 0x2329 ||\n codePoint === 0x232a ||\n (codePoint >= 0x2e80 && codePoint <= 0xa4cf && codePoint !== 0x303f) ||\n (codePoint >= 0xac00 && codePoint <= 0xd7a3) ||\n (codePoint >= 0xf900 && codePoint <= 0xfaff) ||\n (codePoint >= 0xfe10 && codePoint <= 0xfe19) ||\n (codePoint >= 0xfe30 && codePoint <= 0xfe6f) ||\n (codePoint >= 0xff00 && codePoint <= 0xff60) ||\n (codePoint >= 0xffe0 && codePoint <= 0xffe6) ||\n (codePoint >= 0x20000 && codePoint <= 0x3fffd))\n );\n}\n\nfunction displayWidth(text: string): number {\n let width = 0;\n for (const { segment } of graphemeSegmenter.segment(stripVTControlCharacters(text))) {\n if (segment === \"\\t\") {\n width += 8 - (width % 8);\n continue;\n }\n if (\n pictograph.test(segment) ||\n Array.from(segment).some((value) => isWideCodePoint(value.codePointAt(0)!))\n ) {\n width += 2;\n continue;\n }\n for (const value of segment) {\n const codePoint = value.codePointAt(0)!;\n if (codePoint < 0x20 || (codePoint >= 0x7f && codePoint < 0xa0)) continue;\n if (codePoint === 0x200d || (codePoint >= 0xfe00 && codePoint <= 0xfe0f)) continue;\n if (!combiningMark.test(value)) width += 1;\n }\n }\n return width;\n}\n\nfunction renderedRows(rendered: string, columns: number | undefined): number {\n const width =\n Number.isInteger(columns) && columns !== undefined && columns > 0 ? columns : undefined;\n return rendered.split(\"\\n\").reduce((rows, line) => {\n if (!width) return rows + 1;\n return rows + Math.max(1, Math.ceil(displayWidth(line) / width));\n }, 0);\n}\n\n/** Create the fixed human-readable renderer used for pretty output. */\nexport function createPrettyPrinter(options: PrettyPrinterOptions): Printer {\n const stdout = options.stdout ?? process.stdout;\n const stderr = options.stderr ?? process.stderr;\n const symbols = options.unicode ? unicodeSymbols : asciiSymbols;\n let activePrompt: { rendered: string; lines: number } | undefined;\n\n function render(event: PrintEvent): string {\n const mark = eventMark(event);\n const lines = eventLines(event);\n const firstPrefix = colorize(options.color, markStyles[mark], symbols.marks[mark]);\n const barPrefix = colorize(options.color, \"gray\", symbols.bar);\n return lines\n .map((line, index) => `${index === 0 ? firstPrefix : barPrefix}${line ? ` ${line}` : \"\"}`)\n .join(\"\\n\");\n }\n\n function eraseActivePrompt(): string {\n return activePrompt ? \"\\u001b[1A\\u001b[2K\".repeat(activePrompt.lines) : \"\";\n }\n\n return {\n print(event) {\n const rendered = render(event);\n if (event.type === \"prompt\") {\n const erase = eraseActivePrompt();\n if (event.prompt.status === \"closed\") {\n activePrompt = undefined;\n if (erase) stdout.write(erase);\n return;\n }\n if (event.prompt.status === \"submitted\") activePrompt = undefined;\n else activePrompt = { rendered, lines: renderedRows(rendered, stdout.columns) };\n stdout.write(`${erase}${rendered}\\n`);\n return;\n }\n\n const erase = eraseActivePrompt();\n if (!activePrompt) {\n (eventStream(event) === \"stdout\" ? stdout : stderr).write(`${rendered}\\n`);\n return;\n }\n\n stdout.write(erase);\n if (event.type === \"error\") activePrompt = undefined;\n (eventStream(event) === \"stdout\" ? stdout : stderr).write(`${rendered}\\n`);\n if (activePrompt) stdout.write(`${activePrompt.rendered}\\n`);\n },\n };\n}\n","import { emitKeypressEvents } from \"node:readline\";\nimport { PassThrough } from \"node:stream\";\nimport type { HackshPromptErrorReason, PromptErrorDetails, PromptKind } from \"./errors.ts\";\nimport { HackshPromptError } from \"./errors.ts\";\nimport type {\n ConfirmPromptState,\n Printer,\n PromptState,\n PromptStatus,\n SelectPromptState,\n TerminalInput,\n TextPromptState,\n} from \"./printer.ts\";\n\nexport interface SelectOption<T extends string> {\n value: T;\n label?: string;\n hint?: string;\n}\n\nexport interface SelectOptions<T extends string> {\n message: string;\n options: readonly SelectOption<T>[];\n initialValue?: T;\n}\n\nexport interface ConfirmOptions {\n message: string;\n initialValue?: boolean;\n}\n\nexport interface TextOptions {\n message: string;\n placeholder?: string;\n validate?(value: string): string | undefined;\n}\n\nexport interface Prompter {\n select<const T extends string>(options: SelectOptions<T>): Promise<T>;\n confirm(options: ConfirmOptions): Promise<boolean>;\n text(options: TextOptions): Promise<string>;\n}\n\ninterface Key {\n name?: string;\n ctrl?: boolean;\n meta?: boolean;\n sequence?: string;\n}\n\ninterface PromptControllerOptions {\n interactive: boolean;\n input: TerminalInput;\n print(event: Parameters<Printer[\"print\"]>[0]): Promise<void>;\n}\n\ninterface BufferedKeypress {\n character: string | undefined;\n key: Key;\n}\n\nfunction details(\n kind: PromptKind,\n message: unknown,\n choices?: readonly string[],\n): PromptErrorDetails {\n let normalizedMessage: string;\n try {\n normalizedMessage = typeof message === \"string\" ? message : String(message);\n } catch {\n normalizedMessage = \"[Unserializable prompt message]\";\n }\n return {\n kind,\n message: normalizedMessage,\n ...(choices === undefined ? {} : { choices }),\n };\n}\n\nfunction promptError(\n reason: HackshPromptErrorReason,\n prompt: PromptErrorDetails,\n message: string,\n cause?: unknown,\n): HackshPromptError {\n return new HackshPromptError(\n reason,\n prompt,\n message,\n cause === undefined ? undefined : { cause },\n );\n}\n\nfunction validateMessage(kind: PromptKind, message: unknown, choices?: readonly string[]): void {\n if (typeof message !== \"string\" || message.length === 0) {\n throw promptError(\n \"invalid-options\",\n details(kind, message, choices),\n `Invalid ${kind} prompt: message must be a non-empty string`,\n );\n }\n}\n\nfunction asInput(value: TerminalInput, prompt: PromptErrorDetails): TerminalInput {\n if (\n typeof value !== \"object\" ||\n value === null ||\n typeof Reflect.get(value, \"on\") !== \"function\" ||\n typeof Reflect.get(value, \"removeListener\") !== \"function\" ||\n typeof Reflect.get(value, \"resume\") !== \"function\" ||\n typeof Reflect.get(value, \"pause\") !== \"function\"\n ) {\n throw promptError(\"input-error\", prompt, \"Interactive input is not a readable stream\");\n }\n return value;\n}\n\nexport class PromptController implements Prompter {\n readonly #interactive: boolean;\n readonly #inputValue: TerminalInput;\n readonly #printEvent: PromptControllerOptions[\"print\"];\n readonly #bufferedKeys: BufferedKeypress[] = [];\n #active = false;\n\n constructor(options: PromptControllerOptions) {\n this.#interactive = options.interactive;\n this.#inputValue = options.input;\n this.#printEvent = (event) => options.print(event);\n }\n\n async #print(state: PromptState, prompt: PromptErrorDetails): Promise<void> {\n try {\n await this.#printEvent({ type: \"prompt\", prompt: state });\n } catch (cause) {\n throw promptError(\"printer-error\", prompt, \"The prompt could not be displayed\", cause);\n }\n }\n\n async #run<T>(\n prompt: PromptErrorDetails,\n initial: PromptState,\n accept: (character: string, key: Key) => T | undefined,\n update: (character: string, key: Key) => PromptState | undefined,\n submitted: (value: T) => PromptState,\n closed: () => PromptState,\n ): Promise<T> {\n if (!this.#interactive) {\n throw promptError(\n \"non-interactive\",\n prompt,\n `Cannot request ${prompt.kind} input in non-interactive mode: ${prompt.message}`,\n );\n }\n if (this.#active) {\n throw promptError(\"overlapping\", prompt, \"Another prompt is already active\");\n }\n\n const input = asInput(this.#inputValue, prompt);\n this.#active = true;\n let originallyFlowing = false;\n let rawChanged = false;\n let outcome: { ok: true; value: T } | { ok: false; error: unknown };\n try {\n originallyFlowing = input.readableFlowing === true;\n if (input.setRawMode && input.isRaw !== true) {\n input.setRawMode(true);\n rawChanged = true;\n }\n await this.#print(initial, prompt);\n\n const value = await new Promise<T>((resolve, reject) => {\n const keypressInput = new PassThrough();\n emitKeypressEvents(keypressInput);\n let settled = false;\n let draining = false;\n let finalized = false;\n let completion: (() => void) | undefined;\n const queuedKeys = this.#bufferedKeys.splice(0);\n const finalize = (): void => {\n if (finalized || !settled || draining) return;\n finalized = true;\n cleanup();\n completion?.();\n };\n const finish = (action: () => void): void => {\n if (settled) return;\n settled = true;\n completion = action;\n finalize();\n };\n const fail = (reason: HackshPromptErrorReason, message: string, cause?: unknown): void => {\n finish(() => reject(promptError(reason, prompt, message, cause)));\n };\n const handleKeypress = async (\n character: string | undefined,\n key: Key = {},\n ): Promise<void> => {\n if (settled) return;\n if ((key.ctrl && key.name === \"c\") || key.name === \"escape\") {\n fail(\"cancelled\", \"Prompt cancelled\");\n return;\n }\n if (key.ctrl && key.name === \"d\") {\n fail(\"eof\", \"Prompt input ended before a value was submitted\");\n return;\n }\n try {\n const value = accept(character ?? \"\", key);\n if (value !== undefined) {\n finish(() => resolve(value));\n return;\n }\n const state = update(character ?? \"\", key);\n if (state) await this.#print(state, prompt);\n } catch (cause) {\n if (cause instanceof HackshPromptError) finish(() => reject(cause));\n else fail(\"input-error\", \"Prompt input could not be processed\", cause);\n }\n };\n const drainKeys = async (): Promise<void> => {\n if (draining || finalized) return;\n draining = true;\n try {\n while (queuedKeys.length > 0) {\n if (settled) {\n this.#bufferedKeys.push(...queuedKeys.splice(0));\n break;\n }\n const next = queuedKeys.shift()!;\n await handleKeypress(next.character, next.key);\n }\n } finally {\n draining = false;\n finalize();\n }\n };\n const onKeypress = (character: string | undefined, key: Key = {}): void => {\n queuedKeys.push({ character, key });\n void drainKeys().catch((cause: unknown) =>\n fail(\"input-error\", \"Prompt input could not be processed\", cause),\n );\n };\n const onEnd = (): void => fail(\"eof\", \"Prompt input ended before a value was submitted\");\n const onError = (cause: unknown): void => fail(\"input-error\", \"Prompt input failed\", cause);\n const onData = (chunk: unknown): void => {\n if (typeof chunk === \"string\" || chunk instanceof Uint8Array) keypressInput.write(chunk);\n else fail(\"input-error\", \"Prompt input produced a non-byte value\");\n };\n const cleanup = (): void => {\n keypressInput.removeListener(\"keypress\", onKeypress);\n keypressInput.destroy();\n input.removeListener(\"data\", onData as (...args: never[]) => void);\n input.removeListener(\"end\", onEnd as (...args: never[]) => void);\n input.removeListener(\"close\", onEnd as (...args: never[]) => void);\n input.removeListener(\"error\", onError as (...args: never[]) => void);\n };\n keypressInput.on(\"keypress\", onKeypress);\n input.on(\"data\", onData as (...args: never[]) => void);\n input.on(\"end\", onEnd as (...args: never[]) => void);\n input.on(\"close\", onEnd as (...args: never[]) => void);\n input.on(\"error\", onError as (...args: never[]) => void);\n input.resume();\n void drainKeys().catch((cause: unknown) =>\n fail(\"input-error\", \"Prompt input could not be processed\", cause),\n );\n });\n outcome = { ok: true, value };\n } catch (cause) {\n outcome = {\n ok: false,\n error:\n cause instanceof HackshPromptError\n ? cause\n : promptError(\"input-error\", prompt, \"Prompt input could not be initialized\", cause),\n };\n }\n\n let restoreError: HackshPromptError | undefined;\n try {\n if (rawChanged) input.setRawMode?.(false);\n if (!originallyFlowing) input.pause();\n } catch (cause) {\n restoreError = promptError(\n \"input-error\",\n prompt,\n \"Prompt input could not be restored\",\n cause,\n );\n }\n const closeWithFailure = async (failure: unknown): Promise<never> => {\n try {\n await this.#print(closed(), prompt);\n } catch {\n // Preserve the error that terminated the prompt, including an earlier printer failure.\n } finally {\n this.#active = false;\n }\n throw failure;\n };\n if (restoreError) return closeWithFailure(restoreError);\n if (!outcome.ok) return closeWithFailure(outcome.error);\n try {\n await this.#print(submitted(outcome.value), prompt);\n return outcome.value;\n } catch (error) {\n try {\n await this.#print(closed(), prompt);\n } catch {\n // The submitted-state failure remains the primary error.\n }\n throw error;\n } finally {\n this.#active = false;\n }\n }\n\n async select<const T extends string>(options: SelectOptions<T>): Promise<T> {\n const choices = Array.isArray(options?.options)\n ? options.options.map((option) =>\n typeof option === \"object\" && option !== null && typeof option.value === \"string\"\n ? option.value\n : \"[Invalid choice]\",\n )\n : [];\n const prompt = details(\"select\", options?.message, choices);\n validateMessage(\"select\", options?.message, choices);\n if (!Array.isArray(options.options) || options.options.length === 0) {\n throw promptError(\"invalid-options\", prompt, \"A select prompt requires at least one choice\");\n }\n const seen = new Set<string>();\n for (const option of options.options) {\n if (\n typeof option !== \"object\" ||\n option === null ||\n typeof option.value !== \"string\" ||\n option.value.length === 0 ||\n (option.label !== undefined && typeof option.label !== \"string\") ||\n (option.hint !== undefined && typeof option.hint !== \"string\")\n ) {\n throw promptError(\n \"invalid-options\",\n prompt,\n \"Select choices must have valid string values\",\n );\n }\n if (seen.has(option.value)) {\n throw promptError(\"invalid-options\", prompt, `Duplicate select choice: ${option.value}`);\n }\n seen.add(option.value);\n }\n let selected = options.initialValue === undefined ? 0 : choices.indexOf(options.initialValue);\n if (selected < 0) {\n throw promptError(\n \"invalid-options\",\n prompt,\n `Unknown initial select value: ${String(options.initialValue)}`,\n );\n }\n const state = (status: PromptStatus = \"active\"): SelectPromptState => ({\n kind: \"select\",\n message: options.message,\n status,\n value: options.options[selected]!.value,\n choices: options.options.map(({ value, label, hint }, index) => ({\n value,\n label: label ?? value,\n ...(hint === undefined ? {} : { hint }),\n selected: index === selected,\n })),\n });\n const value = await this.#run<T>(\n prompt,\n state(),\n (_character, key) =>\n key.name === \"return\" || key.name === \"enter\"\n ? options.options[selected]!.value\n : undefined,\n (_character, key) => {\n if (key.name !== \"up\" && key.name !== \"down\") return undefined;\n selected =\n (selected + (key.name === \"up\" ? -1 : 1) + options.options.length) %\n options.options.length;\n return state();\n },\n () => state(\"submitted\"),\n () => state(\"closed\"),\n );\n return value;\n }\n\n async confirm(options: ConfirmOptions): Promise<boolean> {\n const prompt = details(\"confirm\", options?.message);\n validateMessage(\"confirm\", options?.message);\n if (options.initialValue !== undefined && typeof options.initialValue !== \"boolean\") {\n throw promptError(\"invalid-options\", prompt, \"Confirm initialValue must be a boolean\");\n }\n const value = options.initialValue ?? false;\n const state = (result: boolean, status: PromptStatus = \"active\"): ConfirmPromptState => ({\n kind: \"confirm\",\n message: options.message,\n status,\n value: result,\n ...(options.initialValue === undefined ? {} : { defaultValue: options.initialValue }),\n });\n const result = await this.#run<boolean>(\n prompt,\n state(value),\n (character, key) => {\n if (key.name === \"return\" || key.name === \"enter\") return value;\n if (character.toLowerCase() === \"y\") return true;\n if (character.toLowerCase() === \"n\") return false;\n return undefined;\n },\n () => undefined,\n (submitted) => state(submitted, \"submitted\"),\n () => state(value, \"closed\"),\n );\n return result;\n }\n\n async text(options: TextOptions): Promise<string> {\n const prompt = details(\"text\", options?.message);\n validateMessage(\"text\", options?.message);\n if (options.placeholder !== undefined && typeof options.placeholder !== \"string\") {\n throw promptError(\"invalid-options\", prompt, \"Text placeholder must be a string\");\n }\n if (options.validate !== undefined && typeof options.validate !== \"function\") {\n throw promptError(\"invalid-options\", prompt, \"Text validate must be a function\");\n }\n let value = \"\";\n let validationError: string | undefined;\n const state = (\n status: PromptStatus = validationError ? \"error\" : \"active\",\n ): TextPromptState => ({\n kind: \"text\",\n message: options.message,\n status,\n value,\n ...(options.placeholder === undefined ? {} : { placeholder: options.placeholder }),\n ...(validationError === undefined ? {} : { error: validationError }),\n });\n const result = await this.#run<string>(\n prompt,\n state(),\n (_character, key) => {\n if (key.name !== \"return\" && key.name !== \"enter\") return undefined;\n let error: string | undefined;\n try {\n error = options.validate?.(value);\n } catch (cause) {\n throw promptError(\"input-error\", prompt, \"Text validation failed\", cause);\n }\n if (error !== undefined && typeof error !== \"string\") {\n throw promptError(\n \"input-error\",\n prompt,\n \"Text validation must return a string or undefined\",\n );\n }\n validationError = error || undefined;\n return validationError === undefined ? value : undefined;\n },\n (character, key) => {\n if (key.name === \"return\" || key.name === \"enter\") return state();\n validationError = undefined;\n if (key.name === \"backspace\") value = Array.from(value).slice(0, -1).join(\"\");\n else if (!key.ctrl && !key.meta && character.length > 0) value += character;\n else return undefined;\n return state();\n },\n () => state(\"submitted\"),\n () => state(\"closed\"),\n );\n return result;\n }\n}\n","import type { Printer, TerminalInput } from \"./printer.ts\";\nimport { summarizeErrors } from \"./errors.ts\";\nimport type { Prompter } from \"./prompts.ts\";\nimport { PromptController } from \"./prompts.ts\";\n\nexport type LogLevel = \"trace\" | \"debug\" | \"info\" | \"warning\" | \"error\" | \"fatal\";\n\nexport type LogKind = \"message\" | \"step\" | \"success\";\n\nexport type LogProperties = Record<string, unknown>;\n\n/** A structured message emitted by a command's logger. */\nexport interface LogRecord {\n level: LogLevel;\n kind: LogKind;\n category: readonly string[];\n message: string;\n rawMessage: string;\n properties: LogProperties;\n timestamp: number;\n}\n\nexport interface Logger extends Prompter {\n readonly category: readonly string[];\n trace(message: string, properties?: LogProperties): void;\n debug(message: string, properties?: LogProperties): void;\n info(message: string, properties?: LogProperties): void;\n warn(message: string, properties?: LogProperties): void;\n error(message: string | Error, properties?: LogProperties): void;\n fatal(message: string | Error, properties?: LogProperties): void;\n step(message: string, properties?: LogProperties): void;\n success(message: string, properties?: LogProperties): void;\n with(properties: LogProperties): Logger;\n getChild(category: string): Logger;\n}\n\nfunction interpolate(message: string, properties: LogProperties): string {\n return message.replace(/\\{([^{}]+)\\}/g, (placeholder, key: string) => {\n if (!Object.hasOwn(properties, key)) return placeholder;\n try {\n return String(properties[key]);\n } catch {\n return placeholder;\n }\n });\n}\n\nfunction createBoundLogger(\n printer: Printer,\n category: readonly string[],\n boundProperties: LogProperties,\n prompts: PromptController,\n): Logger {\n function emit(\n level: LogLevel,\n kind: LogKind,\n input: string | Error,\n properties: LogProperties = {},\n ): void {\n const rawMessage = input instanceof Error ? input.message : input;\n const mergedProperties = { ...boundProperties, ...properties };\n if (input instanceof Error) mergedProperties.error = input;\n const summarizedProperties = summarizeErrors(mergedProperties) as LogProperties;\n\n void printer.print({\n type: \"log\",\n record: {\n level,\n kind,\n category,\n message: interpolate(rawMessage, mergedProperties),\n rawMessage,\n properties: summarizedProperties,\n timestamp: Date.now(),\n },\n });\n }\n\n return {\n category,\n trace: (message, properties) => emit(\"trace\", \"message\", message, properties),\n debug: (message, properties) => emit(\"debug\", \"message\", message, properties),\n info: (message, properties) => emit(\"info\", \"message\", message, properties),\n warn: (message, properties) => emit(\"warning\", \"message\", message, properties),\n error: (message, properties) => emit(\"error\", \"message\", message, properties),\n fatal: (message, properties) => emit(\"fatal\", \"message\", message, properties),\n step: (message, properties) => emit(\"info\", \"step\", message, properties),\n success: (message, properties) => emit(\"info\", \"success\", message, properties),\n select: (options) => prompts.select(options),\n confirm: (options) => prompts.confirm(options),\n text: (options) => prompts.text(options),\n with: (properties) =>\n createBoundLogger(printer, category, { ...boundProperties, ...properties }, prompts),\n getChild: (child) => createBoundLogger(printer, [...category, child], boundProperties, prompts),\n };\n}\n\nexport interface CreateLoggerOptions {\n interactive: boolean;\n input: TerminalInput;\n printPrompt(event: Parameters<Printer[\"print\"]>[0]): Promise<void>;\n}\n\n/** Create the logger for one command invocation. */\nexport function createLogger(\n printer: Printer,\n category: readonly string[],\n options: CreateLoggerOptions,\n): Logger {\n const prompts = new PromptController({\n interactive: options.interactive,\n input: options.input,\n print: (event) => options.printPrompt(event),\n });\n return createBoundLogger(printer, [...category], {}, prompts);\n}\n","import { createPrettyPrinter } from \"./pretty.ts\";\nimport {\n createJsonPrinter,\n resolveOutputMode,\n type OutputMode,\n type OutputPreference,\n type OutputWriter,\n type Printer,\n type TerminalInput,\n type TerminalOutput,\n} from \"./printer.ts\";\n\nexport interface OutputOptions {\n output?: OutputPreference;\n /** Use Unicode presentation symbols in pretty output. Defaults to true. */\n unicode?: boolean;\n env?: Readonly<Record<string, string | undefined>>;\n stdin?: TerminalInput;\n stdout?: TerminalOutput;\n stderr?: OutputWriter;\n}\n\nfunction consoleWriter(method: \"log\" | \"error\", stream: TerminalOutput): TerminalOutput {\n return {\n get isTTY() {\n return stream.isTTY;\n },\n get columns() {\n return stream.columns;\n },\n write(text) {\n if (!text.endsWith(\"\\n\")) return stream.write(text);\n console[method](text.slice(0, -1));\n },\n };\n}\n\n/** Resolve the automatic output policy and select its printer for one operation. */\nexport function selectOutputPrinter(\n options: OutputOptions,\n override?: Printer,\n resolvedMode?: OutputMode,\n): Printer {\n const stdin = options.stdin ?? process.stdin;\n const stdout = options.stdout ?? process.stdout;\n const stderr = options.stderr ?? process.stderr;\n const mode =\n resolvedMode ??\n resolveOutputMode({\n output: options.output,\n env: options.env,\n inputIsTTY: stdin.isTTY,\n outputIsTTY: stdout.isTTY,\n });\n if (override) return override;\n if (mode.format === \"json\") return createJsonPrinter({ stdout, stderr });\n\n const useConsole = options.stdout === undefined && options.stderr === undefined;\n return createPrettyPrinter({\n color: mode.color,\n unicode: options.unicode ?? true,\n stdout: options.stdout ?? (useConsole ? consoleWriter(\"log\", stdout) : stdout),\n stderr: options.stderr ?? (useConsole ? consoleWriter(\"error\", process.stderr) : stderr),\n });\n}\n","import type { AnyCommandDef } from \"./command.ts\";\nimport { summarizeErrors } from \"./errors.ts\";\nimport { aliasList, kebabCase } from \"./options.ts\";\nimport { selectOutputPrinter, type OutputOptions } from \"./output.ts\";\nimport type { Printer, PrintStream } from \"./printer.ts\";\nimport { POSITIONALS_KEY, readArgInfo, readPositionals, schemaShape } from \"./schema.ts\";\n\nfunction details(\n description: string | undefined,\n required: boolean,\n defaultValue: unknown,\n choices: readonly string[] | undefined,\n): string {\n const parts = [description];\n if (choices) parts.push(`(Choices: ${choices.join(\", \")})`);\n if (required) parts.push(\"(Required)\");\n if (defaultValue !== undefined) parts.push(`(Default: ${formatDefault(defaultValue)})`);\n return parts.filter(Boolean).join(\" \");\n}\n\nfunction formatDefault(value: unknown): string {\n if (typeof value === \"string\") return value;\n if (typeof value === \"number\" || typeof value === \"boolean\" || typeof value === \"bigint\") {\n return value.toString();\n }\n if (value === null) return \"null\";\n try {\n return JSON.stringify(value) ?? \"undefined\";\n } catch {\n return \"[Unserializable]\";\n }\n}\n\nexport interface UsageArgumentSummary {\n name: string;\n required: boolean;\n variadic: boolean;\n description?: string;\n choices?: readonly string[];\n defaultValue?: unknown;\n}\n\nexport interface UsageOptionSummary {\n name: string;\n flags: readonly string[];\n takesValue: boolean;\n /** Whether the long flag also accepts a `--no-` prefixed form. */\n negatable: boolean;\n valueName?: string;\n required: boolean;\n description?: string;\n choices?: readonly string[];\n defaultValue?: unknown;\n}\n\nexport interface UsageCommandSummary {\n name: string;\n description?: string;\n}\n\n/** A schema-free description of the useful help metadata for a command. */\nexport interface UsageSummary {\n name: string;\n heading?: string;\n version?: string;\n description?: string;\n synopsis: string;\n arguments: readonly UsageArgumentSummary[];\n options: readonly UsageOptionSummary[];\n commands: readonly UsageCommandSummary[];\n}\n\nfunction heading(command: AnyCommandDef): string | undefined {\n const identity = command.name\n ? `${command.name}${command.version ? ` v${command.version}` : \"\"}`\n : command.version\n ? `v${command.version}`\n : undefined;\n if (command.description && identity) return `${command.description} (${identity})`;\n return command.description ?? identity;\n}\n\n/** Build a serializable help summary without retaining command or schema objects. */\nexport function summarizeUsage(command: AnyCommandDef): UsageSummary {\n const shape = command.args ? schemaShape(command.args) : {};\n const positionals = readPositionals(shape);\n const positionalItems = positionals?.items ?? [];\n const syntax = positionalItems.map(({ schema, label }) =>\n readArgInfo(schema).required ? `<${label}>` : `[${label}]`,\n );\n if (positionals?.rest) syntax.push(`[${positionals.rest.label}...]`);\n if (command.subCommands && Object.keys(command.subCommands).length > 0) syntax.push(\"<COMMAND>\");\n\n const args: UsageArgumentSummary[] = positionalItems.map(({ schema, label }) => {\n const info = readArgInfo(schema);\n return {\n name: label,\n required: info.required,\n variadic: false,\n ...(info.description === undefined ? {} : { description: info.description }),\n ...(info.choices === undefined ? {} : { choices: info.choices }),\n ...(info.defaultValue === undefined\n ? {}\n : { defaultValue: summarizeErrors(info.defaultValue) }),\n };\n });\n if (positionals?.rest) {\n const info = readArgInfo(positionals.rest.schema);\n args.push({\n name: positionals.rest.label,\n required: false,\n variadic: true,\n ...(info.description === undefined ? {} : { description: info.description }),\n ...(info.choices === undefined ? {} : { choices: info.choices }),\n });\n }\n\n const options = Object.entries(shape)\n .filter(([key]) => key !== POSITIONALS_KEY)\n .map(([key, schema]): UsageOptionSummary => {\n const info = readArgInfo(schema);\n const argOptions = command.argOptions?.[key];\n const aliases = argOptions?.alias\n ? aliasList(argOptions.alias).map((item) => `-${item}`)\n : [];\n const name = kebabCase(key);\n const valueName = argOptions?.valueName ?? name;\n return {\n name,\n flags: [...aliases, `--${name}`],\n takesValue: info.takesValue,\n negatable: !info.takesValue,\n required: info.required,\n ...(info.takesValue ? { valueName } : {}),\n ...(info.description === undefined ? {} : { description: info.description }),\n ...(info.choices === undefined ? {} : { choices: info.choices }),\n ...(info.defaultValue === undefined\n ? {}\n : { defaultValue: summarizeErrors(info.defaultValue) }),\n };\n });\n\n const commands = Object.entries(command.subCommands ?? {})\n .filter(([, child]) => !child.hidden)\n .map(([name, child]) => ({\n name,\n ...(child.description === undefined ? {} : { description: child.description }),\n }));\n const name = command.name ?? \"command\";\n const title = heading(command);\n return {\n name,\n ...(title === undefined ? {} : { heading: title }),\n ...(command.version === undefined ? {} : { version: command.version }),\n ...(command.description === undefined ? {} : { description: command.description }),\n synopsis: `${name} [OPTIONS]${syntax.length ? ` ${syntax.join(\" \")}` : \"\"}`,\n arguments: args,\n options,\n commands,\n };\n}\n\nfunction formatUsage(summary: UsageSummary): string {\n const lines: string[] = [];\n if (summary.heading) lines.push(summary.heading, \"\");\n lines.push(`USAGE ${summary.synopsis}`);\n\n if (summary.arguments.length > 0) {\n lines.push(\"\", \"ARGUMENTS\", \"\");\n for (const argument of summary.arguments) {\n lines.push(\n ` ${argument.name}${argument.variadic ? \"...\" : \"\"} ${details(argument.description, argument.required, argument.defaultValue, argument.choices)}`.trimEnd(),\n );\n }\n }\n\n if (summary.options.length > 0) {\n lines.push(\"\", \"OPTIONS\", \"\");\n for (const option of summary.options) {\n const flags = option.flags.map((flag) => {\n if (!flag.startsWith(\"--\")) return flag;\n if (option.takesValue) return `${flag}=<${option.valueName}>`;\n if (option.negatable) return `--[no-]${flag.slice(2)}`;\n return flag;\n });\n lines.push(\n ` ${flags.join(\", \")} ${details(option.description, option.required, option.defaultValue, option.choices)}`.trimEnd(),\n );\n }\n }\n\n if (summary.commands.length > 0) {\n lines.push(\"\", \"COMMANDS\", \"\");\n for (const command of summary.commands) {\n lines.push(` ${command.name} ${command.description ?? \"\"}`.trimEnd());\n }\n }\n return lines.join(\"\\n\");\n}\n\nexport type UsageWriter = (text: string) => void | Promise<void>;\n\nexport interface ShowUsageOptions extends OutputOptions {\n write?: UsageWriter;\n printer?: Printer;\n stream?: PrintStream;\n}\n\nexport type UsageOutput = Required<Pick<ShowUsageOptions, \"write\">>;\n\nexport type ShowUsageCallback = (\n command: AnyCommandDef,\n output: UsageOutput,\n) => void | Promise<void>;\n\n/** Generate usage text without writing to stdout or stderr. */\nexport async function renderUsage(command: AnyCommandDef): Promise<string> {\n return formatUsage(summarizeUsage(command));\n}\n\n/** Generate and write usage text, awaiting asynchronous writers. */\nexport async function showUsage(\n command: AnyCommandDef,\n options: ShowUsageOptions = {},\n): Promise<void> {\n const usage = summarizeUsage(command);\n const text = formatUsage(usage);\n if (options.write) return options.write(text);\n const printer = options.printer ?? selectOutputPrinter(options);\n return printer.print({\n type: \"usage\",\n usage,\n text,\n stream: options.stream ?? \"stdout\",\n });\n}\n","import type { ArgsSchema } from \"./schema.ts\";\nimport type { AnyCommandDef, CommandDef } from \"./command.ts\";\nimport { HackshPromptError, summarizeError, HackshUsageError } from \"./errors.ts\";\nimport { createLogger } from \"./logger.ts\";\nimport {\n parseCommandArgs,\n tokenizedBefore,\n tokenizeCommandArgs,\n type TokenizedCommandArgs,\n} from \"./parser.ts\";\nimport {\n createJsonPrinter,\n createPrintQueue,\n resolveOutputMode,\n type Printer,\n type PrintQueue,\n type PrintStream,\n type TerminalInput,\n} from \"./printer.ts\";\nimport { selectOutputPrinter, type OutputOptions } from \"./output.ts\";\nimport { showUsage, summarizeUsage, type ShowUsageCallback } from \"./usage.ts\";\n\nexport type { OutputOptions } from \"./output.ts\";\n\ninterface CommandSegment {\n command: AnyCommandDef;\n rawArgs: string[];\n tokenized: TokenizedCommandArgs;\n}\n\ninterface ResolvedCommand extends CommandSegment {\n parents: CommandSegment[];\n segments: CommandSegment[];\n}\n\nfunction namedChild(child: AnyCommandDef, name: string): AnyCommandDef {\n return child.name ? child : { ...child, name };\n}\n\nfunction resolveCommand(root: AnyCommandDef, rawArgs: string[]): ResolvedCommand {\n let command = root;\n let remaining = rawArgs;\n const parents: ResolvedCommand[\"parents\"] = [];\n const segments: ResolvedCommand[\"segments\"] = [];\n\n for (;;) {\n const tokenized = tokenizeCommandArgs(command, remaining);\n const index = command.subCommands\n ? tokenized.tokens.find((token) => token.kind === \"positional\")?.index\n : undefined;\n if (index === undefined) {\n const segment = { command, rawArgs: remaining, tokenized };\n segments.push(segment);\n return { ...segment, parents, segments };\n }\n const name = remaining[index]!;\n const child = command.subCommands?.[name];\n if (!child) throw new HackshUsageError(`Unknown command \\`${name}\\``, command);\n const prefix = remaining.slice(0, index);\n const segment = { command, rawArgs: prefix, tokenized: tokenizedBefore(tokenized, index) };\n parents.push(segment);\n segments.push(segment);\n command = namedChild(child, name);\n remaining = remaining.slice(index + 1);\n }\n}\n\nasync function executeCommand<S extends ArgsSchema>(\n root: CommandDef<S>,\n argv: string[],\n displayUsage: ShowUsageCallback,\n printer: Printer,\n loggerOptions: Parameters<typeof createLogger>[2],\n): Promise<unknown> {\n const resolved = resolveCommand(root, argv);\n if (resolved.segments[0]?.tokenized.version) {\n await printer.print({ type: \"version\", version: root.version ?? \"\" });\n return undefined;\n }\n if (resolved.segments.some(({ tokenized }) => tokenized.help)) {\n await printUsage(displayUsage, resolved.command, printer, \"stdout\");\n return undefined;\n }\n\n for (const parent of resolved.parents) {\n await parseCommandArgs(parent.command, parent.rawArgs, parent.tokenized);\n }\n const parsed = await parseCommandArgs(resolved.command, resolved.rawArgs, resolved.tokenized);\n if (!resolved.command.run) {\n throw new HackshUsageError(\"No command specified\", resolved.command);\n }\n const category = resolved.segments.flatMap(({ command }) =>\n command.name === undefined ? [] : [command.name],\n );\n return resolved.command.run({\n ...parsed,\n cmd: resolved.command,\n rawArgs: resolved.rawArgs,\n logger: createLogger(printer, category, loggerOptions),\n });\n}\n\nfunction printUsage(\n displayUsage: ShowUsageCallback,\n command: AnyCommandDef,\n printer: Printer,\n stream: PrintStream,\n): void | Promise<void> {\n return displayUsage(command, {\n write: (text) => printer.print({ type: \"usage\", usage: summarizeUsage(command), text, stream }),\n });\n}\n\nexport interface RunCommandOptions extends OutputOptions {\n printer?: Printer;\n showUsage?: ShowUsageCallback;\n}\n\ninterface PreparedOutput extends PrintQueue {\n interactive: boolean;\n input: TerminalInput;\n}\n\nfunction prepareOutput(options: RunCommandOptions): PreparedOutput {\n const input = options.stdin ?? process.stdin;\n const mode = resolveOutputMode({\n output: options.output,\n env: options.env,\n inputIsTTY: input.isTTY,\n outputIsTTY: (options.stdout ?? process.stdout).isTTY,\n });\n return {\n ...createPrintQueue(selectOutputPrinter(options, options.printer, mode)),\n interactive: mode.interactive,\n input,\n };\n}\n\nexport async function runCommand<S extends ArgsSchema>(\n root: CommandDef<S>,\n argv: string[],\n options: RunCommandOptions = {},\n): Promise<unknown> {\n const output = prepareOutput(options);\n try {\n return await executeCommand(root, argv, options.showUsage ?? showUsage, output.printer, {\n interactive: output.interactive,\n input: output.input,\n printPrompt: (event) => output.printChecked(event),\n });\n } finally {\n await output.drain();\n }\n}\n\nexport interface RunMainOptions extends OutputOptions {\n onError?: (error: unknown) => void | Promise<void>;\n argv?: string[];\n printer?: Printer;\n showUsage?: ShowUsageCallback;\n}\n\nasync function drainAndExit(output: PrintQueue, code = 1): Promise<never> {\n try {\n await output.drain();\n } finally {\n process.exit(code);\n }\n}\n\nfunction commandErrorExitCode(error: unknown): number {\n return error instanceof HackshPromptError && error.reason === \"cancelled\" ? 130 : 1;\n}\n\nasync function reportOutputSetupError(error: unknown, options: RunMainOptions): Promise<never> {\n if (options.onError) {\n await options.onError(error);\n return drainAndExit(createPrintQueue(options.printer ?? { print: () => undefined }));\n }\n\n const output = createPrintQueue(\n options.printer ??\n createJsonPrinter({\n stdout: options.stdout ?? process.stdout,\n stderr: options.stderr ?? process.stderr,\n }),\n );\n await output.printer.print({ type: \"error\", error: summarizeError(error) });\n return drainAndExit(output);\n}\n\nexport async function runMain<S extends ArgsSchema>(\n command: CommandDef<S>,\n options: RunMainOptions = {},\n): Promise<void> {\n const displayUsage = options.showUsage ?? showUsage;\n let output: PreparedOutput;\n try {\n output = prepareOutput(options);\n } catch (error) {\n return reportOutputSetupError(error, options);\n }\n try {\n await executeCommand(\n command,\n options.argv ?? process.argv.slice(2),\n displayUsage,\n output.printer,\n {\n interactive: output.interactive,\n input: output.input,\n printPrompt: (event) => output.printChecked(event),\n },\n );\n } catch (error) {\n if (options.onError) {\n await options.onError(error);\n return drainAndExit(output, commandErrorExitCode(error));\n }\n try {\n if (error instanceof HackshUsageError) {\n await output.printer.print({ type: \"error\", error: summarizeError(error) });\n await printUsage(displayUsage, error.command, output.printer, \"stderr\");\n } else {\n await output.printer.print({\n type: \"error\",\n error: summarizeError(error),\n });\n }\n } finally {\n await drainAndExit(output, commandErrorExitCode(error));\n }\n }\n await output.drain();\n}\n\nexport function createMain<S extends ArgsSchema>(\n command: CommandDef<S>,\n options: RunMainOptions = {},\n): (argv?: string[]) => Promise<void> {\n return (argv) => runMain(command, argv === undefined ? options : { ...options, argv });\n}\n"],"mappings":";;;;;AAAA,SAAgB,UAAU,OAAuB;CAC/C,OAAO,MAAM,WAAW,sBAAsB,OAAO,CAAC,CAAC,YAAY;AACrE;AAEA,SAAgB,UAAU,OAAsD;CAC9E,OAAO,OAAO,UAAU,WAAW,CAAC,KAAK,IAAI;AAC/C;ACyBA,SAAS,WAAW,QAA0B;CAC5C,OAAO,OAAO,KAAK;AACrB;AAEA,SAAS,YAAY,KAAmC;CACtD,QAAQ,IAAI,MAAZ;EACE,KAAK;EACL,KAAK;EACL,KA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O,OAAO;CAC9C;CACA,IAAI;EACF,MAAM,eACJ,SACA,QAAQ,QAAQ,QAAQ,KAAK,MAAM,CAAC,GACpC,cACA,OAAO,SACP;GACE,aAAa,OAAO;GACpB,OAAO,OAAO;GACd,cAAc,UAAU,OAAO,aAAa,KAAK;EACnD,CACF;CACF,SAAS,OAAO;EACd,IAAI,QAAQ,SAAS;GACnB,MAAM,QAAQ,QAAQ,KAAK;GAC3B,OAAO,aAAa,QAAQ,qBAAqB,KAAK,CAAC;EACzD;EACA,IAAI;GACF,IAAI,iBAAiB,kBAAkB;IACrC,MAAM,OAAO,QAAQ,MAAM;KAAE,MAAM;KAAS,OAAO,eAAe,KAAK;IAAE,CAAC;IAC1E,MAAM,WAAW,cAAc,MAAM,SAAS,OAAO,SAAS,QAAQ;GACxE,OACE,MAAM,OAAO,QAAQ,MAAM;IACzB,MAAM;IACN,OAAO,eAAe,KAAK;GAC7B,CAAC;EAEL,UAAU;GACR,MAAM,aAAa,QAAQ,qBAAqB,KAAK,CAAC;EACxD;CACF;CACA,MAAM,OAAO,MAAM;AACrB;AAEA,SAAgB,WACd,SACA,UAA0B,CAAC,GACS;CACpC,QAAQ,SAAS,QAAQ,SAAS,SAAS,KAAA,IAAY,UAAU;EAAE,GAAG;EAAS;CAAK,CAAC;AACvF"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hacksh",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "Type-safe command-line interfaces powered by Zod 4 schemas.",
5
5
  "keywords": [
6
6
  "cli",