@hop-top/kit 0.5.0-alpha.0 → 0.5.0-alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (100) hide show
  1. package/CHANGELOG.md +98 -0
  2. package/README.md +237 -9
  3. package/dist/aim-CTp-kJW2.d.ts +139 -0
  4. package/dist/aim.d.ts +1 -116
  5. package/dist/alias-dhhr08Ei.d.ts +88 -0
  6. package/dist/alias.d.ts +2 -73
  7. package/dist/api-miiso81x.d.ts +77 -0
  8. package/dist/api.d.ts +1 -62
  9. package/dist/auth-2-jfgiHn.d.ts +34 -0
  10. package/dist/auth.d.ts +1 -26
  11. package/dist/cli-DgOEOsPB.d.ts +450 -0
  12. package/dist/cli.d.ts +5 -309
  13. package/dist/cli.js +250 -62
  14. package/dist/config-BUY7_W2n.d.ts +103 -0
  15. package/dist/config.d.ts +1 -97
  16. package/dist/errcorrect-BcX1Ft0K.d.ts +44 -0
  17. package/dist/errcorrect.d.ts +1 -37
  18. package/dist/id/index.d.ts +2 -83
  19. package/dist/index--C7Mtsmm.d.ts +328 -0
  20. package/dist/index-C3Zw4wDJ.d.ts +359 -0
  21. package/dist/index-MLrRDvEG.d.ts +1073 -0
  22. package/dist/index-QSffbLnj.d.ts +94 -0
  23. package/dist/index.d.ts +26 -0
  24. package/dist/index.js +5863 -0
  25. package/dist/llm-B5XUWH8T.d.ts +231 -0
  26. package/dist/llm.d.ts +1 -188
  27. package/dist/mcp/index.d.ts +2 -0
  28. package/dist/mcp/index.js +1453 -0
  29. package/dist/netpolicy-asvCfwi8.d.ts +138 -0
  30. package/dist/netpolicy.d.ts +1 -0
  31. package/dist/netpolicy.js +118 -0
  32. package/dist/output-VFFLqor9.d.ts +521 -0
  33. package/dist/output.d.ts +2 -213
  34. package/dist/output.js +554 -43
  35. package/dist/progress-CAzyxeWl.d.ts +38 -0
  36. package/dist/progress.d.ts +1 -30
  37. package/dist/provenance-SMFHm5gx.d.ts +30 -0
  38. package/dist/provenance.d.ts +1 -24
  39. package/dist/routellm-PGSt2D1y.d.ts +75 -0
  40. package/dist/routellm.d.ts +2 -64
  41. package/dist/rpc-D5xLEf8V.d.ts +32 -0
  42. package/dist/rpc.d.ts +2 -25
  43. package/dist/safety-CUaYEjZc.d.ts +30 -0
  44. package/dist/safety.d.ts +1 -24
  45. package/dist/scope-BrhYB4ij.d.ts +141 -0
  46. package/dist/scope.d.ts +1 -121
  47. package/dist/stream-CrjeCp0M.d.ts +44 -0
  48. package/dist/stream.d.ts +1 -35
  49. package/dist/telemetry/index.d.ts +1 -315
  50. package/dist/telemetry/index.js +12 -1
  51. package/dist/tui/index.d.ts +4 -298
  52. package/dist/tui/index.js +61 -9
  53. package/dist/upgrade-p_zh3pvV.d.ts +102 -0
  54. package/dist/upgrade.d.ts +1 -95
  55. package/dist/xdg-DB7Shoib.d.ts +179 -0
  56. package/dist/xdg.d.ts +1 -169
  57. package/package.json +65 -25
  58. package/src/cli.offline.test.ts +93 -0
  59. package/src/cli.parity.test.ts +192 -0
  60. package/src/cli.ts +112 -12
  61. package/src/index.test.ts +58 -0
  62. package/src/index.ts +36 -0
  63. package/src/log.parity.test.ts +105 -0
  64. package/src/log.ts +64 -13
  65. package/src/mcp/bridge.test.ts +150 -0
  66. package/src/mcp/bridge.ts +246 -0
  67. package/src/mcp/conformance.test.ts +336 -0
  68. package/src/mcp/dispatch.ts +313 -0
  69. package/src/mcp/index.ts +138 -0
  70. package/src/mcp/legacy.ts +314 -0
  71. package/src/mcp/mcp.test.ts +697 -0
  72. package/src/mcp/modern-confirm.test.ts +520 -0
  73. package/src/mcp/modern-confirm.ts +452 -0
  74. package/src/mcp/modern.ts +723 -0
  75. package/src/mcp/tasks.ts +82 -0
  76. package/src/mcp/testtree.ts +250 -0
  77. package/src/mcp/types.ts +504 -0
  78. package/src/netpolicy.test.ts +202 -0
  79. package/src/netpolicy.ts +231 -0
  80. package/src/output/dispatch.ts +10 -2
  81. package/src/output/error.ts +293 -0
  82. package/src/output/formatter.ts +29 -5
  83. package/src/output/formatters/csv.ts +48 -12
  84. package/src/output/formatters/json.ts +4 -25
  85. package/src/output/formatters/project.ts +34 -0
  86. package/src/output/formatters/table.ts +8 -6
  87. package/src/output/formatters/text.ts +7 -3
  88. package/src/output/formatters/yaml.ts +5 -22
  89. package/src/output/projection.test.ts +298 -0
  90. package/src/output/projection.ts +33 -59
  91. package/src/output/template.ts +11 -21
  92. package/src/output.surface.test.ts +41 -0
  93. package/src/output.ts +39 -3
  94. package/src/telemetry/client.test.ts +31 -0
  95. package/src/telemetry/client.ts +7 -1
  96. package/src/telemetry/offline.test.ts +64 -0
  97. package/src/tui/parity.test.ts +142 -0
  98. package/src/tui/parity.ts +59 -13
  99. package/test/output/csv.test.ts +164 -0
  100. package/test/output/error.test.ts +241 -0
@@ -0,0 +1,521 @@
1
+ import { Command } from 'commander';
2
+
3
+ /**
4
+ * @module output/formatter
5
+ *
6
+ * Core Formatter interface + Options/OptionSpec/ColumnSpec types and
7
+ * parseOptions helper. Mirrors Go's go/console/output Formatter interface.
8
+ */
9
+ /** Kinds of values an OptionSpec accepts. */
10
+ type OptionType = 'string' | 'int' | 'bool' | 'enum';
11
+ /** Describes one option accepted by a Formatter via --format-opt key=value. */
12
+ interface OptionSpec {
13
+ readonly name: string;
14
+ readonly type: OptionType;
15
+ readonly default?: string | number | boolean;
16
+ readonly usage: string;
17
+ readonly enum?: readonly string[];
18
+ }
19
+ /**
20
+ * Validated map of option values produced by parseOptions. Keys are
21
+ * OptionSpec.name; values are coerced to the spec's declared type.
22
+ */
23
+ type Options = Readonly<Record<string, string | number | boolean>>;
24
+ /**
25
+ * Column metadata used by every built-in formatter and by --cols validation.
26
+ *
27
+ * - `header` is the user-visible label, the name matched against --cols, AND
28
+ * the property read off the row object: header == key, universally. Go
29
+ * cannot express a header/key split through `table:""` struct tags, so no
30
+ * SDK offers one.
31
+ * - `key` is retained for source compatibility and must equal `header`;
32
+ * `columnName` reports the single effective name.
33
+ * - `priority` is accepted and stored but ignored — hide-on-overflow is a
34
+ * Go-only feature today.
35
+ */
36
+ interface ColumnSpec {
37
+ readonly header: string;
38
+ readonly key: string;
39
+ readonly priority?: number;
40
+ }
41
+ /**
42
+ * Returns a ColumnSpec's effective column name, rejecting a header/key split.
43
+ *
44
+ * Validating at read time keeps drift impossible while `key` still exists as
45
+ * a field.
46
+ */
47
+ declare function columnName(c: ColumnSpec): string;
48
+ /**
49
+ * A Formatter encodes structured data to a writable stream.
50
+ *
51
+ * Implementations declare their key, file extensions, and the option keys
52
+ * they accept. The dispatch helper validates --format-opt input against
53
+ * options() before invoking render(), so render() may trust opts to only
54
+ * contain declared keys with values coerced to declared types.
55
+ */
56
+ interface Formatter<T = unknown> {
57
+ /** Unique format identifier exposed via --format <key>. */
58
+ readonly key: string;
59
+ /**
60
+ * File extensions (with leading dot, e.g. ".csv") that map to this
61
+ * formatter for --output extension inference. May be empty.
62
+ */
63
+ readonly extensions: readonly string[];
64
+ /** Option specs accepted by this formatter via --format-opt key=value. */
65
+ readonly options: readonly OptionSpec[];
66
+ /**
67
+ * Renders data to out.
68
+ *
69
+ * @param out Destination writable stream.
70
+ * @param data Single row or readonly array of rows.
71
+ * @param opts Validated options; only declared keys with coerced values.
72
+ * @param cols Effective column list, already resolved by dispatch: the
73
+ * user's `--cols` when supplied, else the caller's ColumnSpec headers in
74
+ * list order, else empty meaning "fall back to payload key order".
75
+ * Render columns in exactly this order — it is both the labels and, since
76
+ * header == key, the lookup names on each row.
77
+ */
78
+ render(out: NodeJS.WritableStream, data: T | readonly T[], opts: Options, cols: readonly string[]): Promise<void> | void;
79
+ }
80
+ /**
81
+ * Validates raw `key=value` pairs against specs and returns a coerced
82
+ * Options map. Unknown keys, type errors, and out-of-enum values throw an
83
+ * Error listing the offending key and the valid set.
84
+ *
85
+ * A pair without `=` (e.g. `"no-header"`) is treated as bool true; only
86
+ * valid when the matching spec has type `'bool'`.
87
+ *
88
+ * Defaults from specs fill in any keys not present in pairs.
89
+ */
90
+ declare function parseOptions(pairs: readonly string[], specs: readonly OptionSpec[]): Options;
91
+ /** Pretty-print an OptionType. */
92
+ declare function optionTypeName(t: OptionType): string;
93
+
94
+ /**
95
+ * @module output/projection
96
+ *
97
+ * Helpers for projecting structured data through ColumnSpec lists. Mirrors
98
+ * Go's projection.go (projectToMaps / TableHeaders).
99
+ *
100
+ * Unlike Go (which uses `table:""` struct tags), TS callers pass an explicit
101
+ * ColumnSpec[] list. When no columns are provided, callers fall back to
102
+ * deriving headers from the first row's own enumerable keys.
103
+ *
104
+ * A ColumnSpec's `header` and `key` are the same name: validation and value
105
+ * lookup are one operation, matching what Go's `table:""` tag can express.
106
+ * `--cols` reorders as well as selects, so the user's order wins over the
107
+ * ColumnSpec list's.
108
+ */
109
+
110
+ /** Returns the list of headers for a row source given an optional ColumnSpec list. */
111
+ declare function deriveHeaders(rows: readonly unknown[], columns?: readonly ColumnSpec[]): readonly string[];
112
+ /**
113
+ * Resolves the effective column list a formatter should render.
114
+ *
115
+ * Precedence, per the settled ordering contract:
116
+ * - `cols` non-empty → the user's `--cols`, verbatim and in user order
117
+ * (rule 2: --cols reorders as well as selects).
118
+ * - else a ColumnSpec list → its headers, in list order (rule 1).
119
+ * - else → empty, meaning "fall back to payload key order".
120
+ *
121
+ * Because header == key (rule 3), an ordered array of names carries
122
+ * everything a formatter needs: the labels and the row lookup keys are the
123
+ * same strings. Resolving here keeps precedence in one place and leaves the
124
+ * public Formatter signature untouched.
125
+ */
126
+ declare function resolveEffectiveCols(cols: readonly string[], columns: readonly ColumnSpec[] | undefined): readonly string[];
127
+ /**
128
+ * Projects rows to plain objects keyed by column name, in `cols` order.
129
+ * An empty `cols` passes rows through untouched, so JSON/YAML keep whatever
130
+ * shape the caller handed in.
131
+ */
132
+ declare function projectRows(rows: readonly unknown[], cols: readonly string[]): readonly Record<string, unknown>[];
133
+
134
+ /**
135
+ * @module output/registry
136
+ *
137
+ * Registry holds Formatter implementations keyed by Formatter.key. Mirrors
138
+ * Go's *Registry. Built-in formatters register against `defaultRegistry` at
139
+ * module-load time.
140
+ */
141
+
142
+ /**
143
+ * Registry holds Formatter implementations.
144
+ *
145
+ * - `register` throws on duplicate keys (init-time fail-loud).
146
+ * - `override` quietly replaces — use when intentionally swapping a built-in.
147
+ * - `lookup` returns the formatter for a key, or undefined.
148
+ * - `keys` returns sorted format identifiers.
149
+ * - `formatters` returns sorted formatters.
150
+ * - `extensionMap` returns ext→key (e.g. ".csv" → "csv"); later
151
+ * registrations win on collision (alphabetical key order is the tie-break).
152
+ */
153
+ declare class Registry {
154
+ private readonly byKey;
155
+ /**
156
+ * Adds f to the registry. Throws Error on duplicate key or empty key.
157
+ * Use `override` to intentionally replace.
158
+ */
159
+ register<T>(f: Formatter<T>): void;
160
+ /** Replaces (or registers) the formatter for f.key. */
161
+ override<T>(f: Formatter<T>): void;
162
+ /** Returns the formatter registered under key, if any. */
163
+ lookup(key: string): Formatter | undefined;
164
+ /** Returns all registered format keys, sorted alphabetically. */
165
+ keys(): readonly string[];
166
+ /** Returns all registered formatters in key order. */
167
+ formatters(): readonly Formatter[];
168
+ /**
169
+ * Returns extension→key mappings (e.g. ".csv" → "csv") across all
170
+ * registered formatters. Later registrations win on collision; iteration
171
+ * is in sorted-key order so resolution is deterministic.
172
+ */
173
+ extensionMap(): ReadonlyMap<string, string>;
174
+ }
175
+ /** Module-level Registry. Built-ins register here at module-load time. */
176
+ declare const defaultRegistry: Registry;
177
+ /** Returns a new, empty Registry — no built-ins registered. */
178
+ declare function newRegistry(): Registry;
179
+
180
+ /**
181
+ * @module output/formatters/json
182
+ *
183
+ * Built-in JSON formatter. Honors `indent` option (default 2) + trailing
184
+ * newline. Emitted key order follows the ColumnSpec list, narrowed and
185
+ * reordered by `cols`; without either, the payload passes through untouched.
186
+ */
187
+
188
+ declare const jsonFormatter: Formatter;
189
+
190
+ /**
191
+ * @module output/formatters/yaml
192
+ *
193
+ * Built-in YAML formatter. Honors `flow-level` option (default -1, mapping
194
+ * to js-yaml's default block style). Emitted key order follows the ColumnSpec
195
+ * list, narrowed and reordered by `cols`; without either, the payload passes
196
+ * through untouched.
197
+ */
198
+
199
+ declare const yamlFormatter: Formatter;
200
+
201
+ /**
202
+ * @module output/formatters/table
203
+ *
204
+ * Built-in table formatter. Hand-rolled aligner (matches the original
205
+ * output.ts behaviour). Column order comes from the ColumnSpec list, or the
206
+ * first row's key order when none was supplied; `cols` narrows and reorders.
207
+ */
208
+
209
+ declare const tableFormatter: Formatter;
210
+
211
+ /**
212
+ * @module output/flags
213
+ *
214
+ * Commander integration: registerOutputFlags adds the standard output
215
+ * flag suite (--format, --format-opt, --format-help, --cols, --template,
216
+ * --output|-o) to a Commander program. Mirrors Go's RegisterFlagsWith.
217
+ */
218
+
219
+ /** Returns the Registry attached to cmd (walks parents) or defaultRegistry. */
220
+ declare function registryFor(cmd: Command): Registry;
221
+ /** Options for registerOutputFlags. */
222
+ interface RegisterOutputFlagsOptions {
223
+ /** Custom registry (default: defaultRegistry). */
224
+ registry?: Registry;
225
+ /** Per-flag opt-out. */
226
+ disable?: {
227
+ format?: boolean;
228
+ formatOpt?: boolean;
229
+ formatHelp?: boolean;
230
+ cols?: boolean;
231
+ template?: boolean;
232
+ output?: boolean;
233
+ };
234
+ }
235
+ /**
236
+ * Adds the output flag suite to a Commander program. Each flag is opt-out
237
+ * via `opts.disable.<flag>`. The active registry can be swapped via
238
+ * `opts.registry`; tests + multi-CLI binaries use this for isolated sets.
239
+ */
240
+ declare function registerOutputFlags(program: Command, opts?: RegisterOutputFlagsOptions): void;
241
+ /**
242
+ * Merges --cols + --columns from a Commander opts object into a single
243
+ * ordered, deduped string[]. Trims whitespace, drops empty entries.
244
+ */
245
+ declare function resolveCols(opts: Record<string, unknown>): string[];
246
+
247
+ /** Optional inputs to dispatch. */
248
+ interface DispatchOptions<T = unknown> {
249
+ /** ColumnSpec list for projection + --cols validation. */
250
+ columns?: readonly ColumnSpec[];
251
+ /** Override registry (default: registry stashed on cmd, else defaultRegistry). */
252
+ registry?: Registry;
253
+ /** Default format when --format isn't explicit (default: "table"). */
254
+ defaultFormat?: string;
255
+ _phantom?: T;
256
+ }
257
+ /**
258
+ * Renders `data` through the active formatter resolved from cmd's flags.
259
+ *
260
+ * Resolution order:
261
+ * 1. Resolve writer: empty/'-' → cmd.stdout (process.stdout), else file.
262
+ * 2. --format-help short-circuit: list registry or show one formatter.
263
+ * 3. Resolve format: explicit --format wins; else infer from --output ext.
264
+ * 4. Mismatch detection: explicit --format + ext mapping to different
265
+ * formatter is a hard error.
266
+ * 5. --template: build {items, cols} input, run eta, return.
267
+ * 6. Else: parseOptions, validateCols, formatter.render.
268
+ */
269
+ declare function dispatch<T>(cmd: Command, data: T | readonly T[], options?: DispatchOptions<T>): Promise<void>;
270
+
271
+ /**
272
+ * @module output/error
273
+ *
274
+ * Structured-error envelope. Mirrors Go's `go/console/output` error
275
+ * envelope: when a command fails under `--format json|yaml`, the error is
276
+ * materialized as a {@link CliError} and rendered to stderr by
277
+ * {@link renderError}. Plaintext mode (`--format table` or unset) prints
278
+ * `"Code: Message\nFix: ...\n"`.
279
+ *
280
+ * Fields use the on-wire snake_case keys directly (like the telemetry
281
+ * `Envelope`) so `JSON.stringify` is wire-exact; empty optional fields
282
+ * stay off the wire, mirroring Go's `omitempty`.
283
+ */
284
+ /** Marks a failure a retry may clear (rate limit, timeout, upstream blip). */
285
+ declare const TRANSIENCE_TRANSIENT = "transient";
286
+ /**
287
+ * Marks a failure retrying cannot clear without changing the input or the
288
+ * environment.
289
+ */
290
+ declare const TRANSIENCE_PERMANENT = "permanent";
291
+ /**
292
+ * Marks a failure kit cannot classify. Agents should treat retries as
293
+ * best-effort and bounded.
294
+ */
295
+ declare const TRANSIENCE_UNKNOWN = "unknown";
296
+ declare const CODE_OK = "OK";
297
+ declare const CODE_GENERIC = "GENERIC";
298
+ declare const CODE_USAGE = "USAGE";
299
+ declare const CODE_NOT_FOUND = "NOT_FOUND";
300
+ declare const CODE_CONFLICT = "CONFLICT";
301
+ declare const CODE_UNAUTHORIZED = "UNAUTHORIZED";
302
+ declare const CODE_TRANSIENT = "TRANSIENT";
303
+ declare const CODE_PROVENANCE_MISSING = "PROVENANCE_MISSING";
304
+ declare const CODE_RATE_LIMITED = "RATE_LIMITED";
305
+ /**
306
+ * Spec-assigned exit code for transient/retryable failures (Factor 11).
307
+ * Agents branch on it before parsing stderr: exit 6 means a retry may
308
+ * clear the failure.
309
+ */
310
+ declare const EXIT_TRANSIENT = 6;
311
+ /** Conventional exit code for Factor-10 rate-limit refusals. */
312
+ declare const EXIT_RATE_LIMITED = 64;
313
+ /**
314
+ * Conventional exit code for Factor-12 strict-mode provenance refusals.
315
+ * Lives at 65 in kit's extension band (alongside RATE_LIMITED at 64):
316
+ * the spec reserves 0-6 for its core taxonomy and leaves >6 to per-tool
317
+ * codes, and kit as a library stays out of the low per-tool range.
318
+ */
319
+ declare const EXIT_PROVENANCE_MISSING = 65;
320
+ /**
321
+ * Structured-error envelope rendered to stderr when `--format json|yaml`
322
+ * is set. Keys are the on-wire snake_case names.
323
+ *
324
+ * `transience` classifies the failure for retry decisions (Factor 4):
325
+ * transient (retry-worthy), permanent (do not retry), or unknown.
326
+ * Constructors and {@link wrapError} populate it; {@link renderError}
327
+ * normalizes an unset value to unknown so every structured error carries
328
+ * a valid class on the wire.
329
+ */
330
+ interface CliError {
331
+ code: string;
332
+ message: string;
333
+ cause?: string;
334
+ suggested_fix?: string;
335
+ alternatives?: string[];
336
+ exit_code: number;
337
+ transience?: string;
338
+ }
339
+ /**
340
+ * Default transience class for one of the standard codes. Unrecognized
341
+ * (adopter-defined) codes map to unknown; adopters set `transience`
342
+ * (or use {@link withTransience}) to classify their own codes.
343
+ */
344
+ declare function transienceForCode(code: string): string;
345
+ /**
346
+ * Builds an envelope from `err`, retaining it for {@link unwrapError}
347
+ * while rendering as `code` and message. Transience defaults from the
348
+ * code via {@link transienceForCode}; use {@link withTransience} to
349
+ * override.
350
+ */
351
+ declare function wrapError(err: unknown, code: string, exitCode: number): CliError | null;
352
+ /**
353
+ * The error this envelope was built from via {@link wrapError}, so
354
+ * callers can classify failures by cause instead of string-matching
355
+ * `message`. Mirrors Go's `(*Error).Unwrap`.
356
+ */
357
+ declare function unwrapError(e: CliError): unknown;
358
+ /**
359
+ * Copy of `e` with `transience` set, every other field (and the retained
360
+ * source error) untouched. Copies rather than mutating: adopters
361
+ * commonly share module-level envelopes, and writing to one would leak
362
+ * across call sites.
363
+ */
364
+ declare function withTransience(e: CliError, transience: string): CliError;
365
+ /** CODE_NOT_FOUND envelope with exit code 3. */
366
+ declare function notFoundError(message: string): CliError;
367
+ /** CODE_CONFLICT envelope with exit code 4. */
368
+ declare function conflictError(message: string): CliError;
369
+ /** CODE_UNAUTHORIZED envelope with exit code 5. */
370
+ declare function unauthorizedError(message: string): CliError;
371
+ /** CODE_USAGE envelope with exit code 2. */
372
+ declare function usageError(message: string): CliError;
373
+ /**
374
+ * CODE_TRANSIENT envelope with exit code 6 (Factor 11). Use it for
375
+ * failures a retry may clear: upstream timeouts, connection resets,
376
+ * service-unavailable responses.
377
+ */
378
+ declare function transientError(message: string): CliError;
379
+ /** CODE_RATE_LIMITED envelope with exit code 64 (Factor 10). */
380
+ declare function rateLimitedError(message: string): CliError;
381
+ /**
382
+ * CODE_PROVENANCE_MISSING envelope with exit code 65 (Factor 12).
383
+ * `detail` is a free-form string suitable for the `cause` slot
384
+ * (typically the JSON-pointer list of offending fields).
385
+ */
386
+ declare function provenanceMissingError(detail: string): CliError;
387
+ /**
388
+ * Writes `err` to `w` in the requested format. `format === ''` or
389
+ * `'table'` renders human-readable plain text (`"Code: Message\nFix:
390
+ * ..."`); JSON/YAML render the envelope structurally. An unset
391
+ * transience is normalized to unknown on the wire (Factor 4) without
392
+ * mutating `err`. Always returns; the caller decides the exit code from
393
+ * `err.exit_code` after rendering.
394
+ */
395
+ declare function renderError(w: {
396
+ write(chunk: string): unknown;
397
+ }, format: string, err: CliError | null | undefined): void;
398
+
399
+ /**
400
+ * @module output
401
+ * @package @hop-top/kit
402
+ *
403
+ * Output rendering — writes structured values to a writable stream in one of
404
+ * the registered formats: table, JSON, YAML, CSV, text, etc.
405
+ *
406
+ * ## Quick start
407
+ *
408
+ * ```ts
409
+ * import { render, TABLE_FORMAT, JSON_FORMAT, YAML_FORMAT } from '@hop-top/kit/output';
410
+ *
411
+ * // Write a table to stdout
412
+ * render(process.stdout, TABLE_FORMAT, [{ id: '1', name: 'Alice' }]);
413
+ *
414
+ * // Write indented JSON
415
+ * render(process.stdout, JSON_FORMAT, { ok: true });
416
+ *
417
+ * // Write YAML
418
+ * render(process.stdout, YAML_FORMAT, { version: 1 });
419
+ * ```
420
+ *
421
+ * ## Programmatic Formatter API
422
+ *
423
+ * For typed flag wiring + custom formatters use the Formatter / Registry
424
+ * surface from `output/formatter` and `output/registry`. The `render()`
425
+ * helper exported here is a thin shim over `defaultRegistry`.
426
+ *
427
+ * ## Backward compatibility
428
+ *
429
+ * `render(w, format, v)` keeps its original signature and renders every
430
+ * column in payload key order. New per-format options and column ordering
431
+ * (ColumnSpec lists, `--cols`) are accessed via `dispatch()`.
432
+ */
433
+
434
+ /**
435
+ * Supported output formats. Includes the original three for backward-compat
436
+ * + new built-ins (csv, text) registered on the default registry.
437
+ */
438
+ type Format = string;
439
+ /** Constant for the JSON output format. */
440
+ declare const JSON_FORMAT: "json";
441
+ /** Constant for the YAML output format. */
442
+ declare const YAML_FORMAT: "yaml";
443
+ /** Constant for the table output format. */
444
+ declare const TABLE_FORMAT: "table";
445
+ /** Constant for the CSV output format. */
446
+ declare const CSV_FORMAT: "csv";
447
+ /** Constant for the text output format. */
448
+ declare const TEXT_FORMAT: "text";
449
+ /**
450
+ * Renders `v` to `w` in the requested `format`.
451
+ *
452
+ * Backward-compatible thin shim over `defaultRegistry.lookup(format).render`.
453
+ *
454
+ * @throws {Error} For unknown format strings.
455
+ */
456
+ declare function render(w: NodeJS.WritableStream, format: Format, v: unknown): void;
457
+
458
+ declare const output_CODE_CONFLICT: typeof CODE_CONFLICT;
459
+ declare const output_CODE_GENERIC: typeof CODE_GENERIC;
460
+ declare const output_CODE_NOT_FOUND: typeof CODE_NOT_FOUND;
461
+ declare const output_CODE_OK: typeof CODE_OK;
462
+ declare const output_CODE_PROVENANCE_MISSING: typeof CODE_PROVENANCE_MISSING;
463
+ declare const output_CODE_RATE_LIMITED: typeof CODE_RATE_LIMITED;
464
+ declare const output_CODE_TRANSIENT: typeof CODE_TRANSIENT;
465
+ declare const output_CODE_UNAUTHORIZED: typeof CODE_UNAUTHORIZED;
466
+ declare const output_CODE_USAGE: typeof CODE_USAGE;
467
+ declare const output_CSV_FORMAT: typeof CSV_FORMAT;
468
+ type output_CliError = CliError;
469
+ type output_ColumnSpec = ColumnSpec;
470
+ type output_DispatchOptions<T = unknown> = DispatchOptions<T>;
471
+ declare const output_EXIT_PROVENANCE_MISSING: typeof EXIT_PROVENANCE_MISSING;
472
+ declare const output_EXIT_RATE_LIMITED: typeof EXIT_RATE_LIMITED;
473
+ declare const output_EXIT_TRANSIENT: typeof EXIT_TRANSIENT;
474
+ type output_Format = Format;
475
+ type output_Formatter<T = unknown> = Formatter<T>;
476
+ declare const output_JSON_FORMAT: typeof JSON_FORMAT;
477
+ type output_OptionSpec = OptionSpec;
478
+ type output_OptionType = OptionType;
479
+ type output_Options = Options;
480
+ type output_RegisterOutputFlagsOptions = RegisterOutputFlagsOptions;
481
+ type output_Registry = Registry;
482
+ declare const output_Registry: typeof Registry;
483
+ declare const output_TABLE_FORMAT: typeof TABLE_FORMAT;
484
+ declare const output_TEXT_FORMAT: typeof TEXT_FORMAT;
485
+ declare const output_TRANSIENCE_PERMANENT: typeof TRANSIENCE_PERMANENT;
486
+ declare const output_TRANSIENCE_TRANSIENT: typeof TRANSIENCE_TRANSIENT;
487
+ declare const output_TRANSIENCE_UNKNOWN: typeof TRANSIENCE_UNKNOWN;
488
+ declare const output_YAML_FORMAT: typeof YAML_FORMAT;
489
+ declare const output_columnName: typeof columnName;
490
+ declare const output_conflictError: typeof conflictError;
491
+ declare const output_defaultRegistry: typeof defaultRegistry;
492
+ declare const output_deriveHeaders: typeof deriveHeaders;
493
+ declare const output_dispatch: typeof dispatch;
494
+ declare const output_jsonFormatter: typeof jsonFormatter;
495
+ declare const output_newRegistry: typeof newRegistry;
496
+ declare const output_notFoundError: typeof notFoundError;
497
+ declare const output_optionTypeName: typeof optionTypeName;
498
+ declare const output_parseOptions: typeof parseOptions;
499
+ declare const output_projectRows: typeof projectRows;
500
+ declare const output_provenanceMissingError: typeof provenanceMissingError;
501
+ declare const output_rateLimitedError: typeof rateLimitedError;
502
+ declare const output_registerOutputFlags: typeof registerOutputFlags;
503
+ declare const output_registryFor: typeof registryFor;
504
+ declare const output_render: typeof render;
505
+ declare const output_renderError: typeof renderError;
506
+ declare const output_resolveCols: typeof resolveCols;
507
+ declare const output_resolveEffectiveCols: typeof resolveEffectiveCols;
508
+ declare const output_tableFormatter: typeof tableFormatter;
509
+ declare const output_transienceForCode: typeof transienceForCode;
510
+ declare const output_transientError: typeof transientError;
511
+ declare const output_unauthorizedError: typeof unauthorizedError;
512
+ declare const output_unwrapError: typeof unwrapError;
513
+ declare const output_usageError: typeof usageError;
514
+ declare const output_withTransience: typeof withTransience;
515
+ declare const output_wrapError: typeof wrapError;
516
+ declare const output_yamlFormatter: typeof yamlFormatter;
517
+ declare namespace output {
518
+ export { output_CODE_CONFLICT as CODE_CONFLICT, output_CODE_GENERIC as CODE_GENERIC, output_CODE_NOT_FOUND as CODE_NOT_FOUND, output_CODE_OK as CODE_OK, output_CODE_PROVENANCE_MISSING as CODE_PROVENANCE_MISSING, output_CODE_RATE_LIMITED as CODE_RATE_LIMITED, output_CODE_TRANSIENT as CODE_TRANSIENT, output_CODE_UNAUTHORIZED as CODE_UNAUTHORIZED, output_CODE_USAGE as CODE_USAGE, output_CSV_FORMAT as CSV_FORMAT, type output_CliError as CliError, type output_ColumnSpec as ColumnSpec, type output_DispatchOptions as DispatchOptions, output_EXIT_PROVENANCE_MISSING as EXIT_PROVENANCE_MISSING, output_EXIT_RATE_LIMITED as EXIT_RATE_LIMITED, output_EXIT_TRANSIENT as EXIT_TRANSIENT, type output_Format as Format, type output_Formatter as Formatter, output_JSON_FORMAT as JSON_FORMAT, type output_OptionSpec as OptionSpec, type output_OptionType as OptionType, type output_Options as Options, type output_RegisterOutputFlagsOptions as RegisterOutputFlagsOptions, output_Registry as Registry, output_TABLE_FORMAT as TABLE_FORMAT, output_TEXT_FORMAT as TEXT_FORMAT, output_TRANSIENCE_PERMANENT as TRANSIENCE_PERMANENT, output_TRANSIENCE_TRANSIENT as TRANSIENCE_TRANSIENT, output_TRANSIENCE_UNKNOWN as TRANSIENCE_UNKNOWN, output_YAML_FORMAT as YAML_FORMAT, output_columnName as columnName, output_conflictError as conflictError, output_defaultRegistry as defaultRegistry, output_deriveHeaders as deriveHeaders, output_dispatch as dispatch, output_jsonFormatter as jsonFormatter, output_newRegistry as newRegistry, output_notFoundError as notFoundError, output_optionTypeName as optionTypeName, output_parseOptions as parseOptions, output_projectRows as projectRows, output_provenanceMissingError as provenanceMissingError, output_rateLimitedError as rateLimitedError, output_registerOutputFlags as registerOutputFlags, output_registryFor as registryFor, output_render as render, output_renderError as renderError, output_resolveCols as resolveCols, output_resolveEffectiveCols as resolveEffectiveCols, output_tableFormatter as tableFormatter, output_transienceForCode as transienceForCode, output_transientError as transientError, output_unauthorizedError as unauthorizedError, output_unwrapError as unwrapError, output_usageError as usageError, output_withTransience as withTransience, output_wrapError as wrapError, output_yamlFormatter as yamlFormatter };
519
+ }
520
+
521
+ export { unauthorizedError as $, jsonFormatter as A, newRegistry as B, CODE_CONFLICT as C, type DispatchOptions as D, EXIT_PROVENANCE_MISSING as E, type Format as F, notFoundError as G, optionTypeName as H, output as I, JSON_FORMAT as J, parseOptions as K, projectRows as L, provenanceMissingError as M, rateLimitedError as N, type OptionSpec as O, registerOutputFlags as P, registryFor as Q, type RegisterOutputFlagsOptions as R, render as S, TABLE_FORMAT as T, renderError as U, resolveCols as V, resolveEffectiveCols as W, tableFormatter as X, YAML_FORMAT as Y, transienceForCode as Z, transientError as _, CODE_GENERIC as a, unwrapError as a0, usageError as a1, withTransience as a2, wrapError as a3, yamlFormatter as a4, CODE_NOT_FOUND as b, CODE_OK as c, CODE_PROVENANCE_MISSING as d, CODE_RATE_LIMITED as e, CODE_TRANSIENT as f, CODE_UNAUTHORIZED as g, CODE_USAGE as h, CSV_FORMAT as i, type CliError as j, type ColumnSpec as k, EXIT_RATE_LIMITED as l, EXIT_TRANSIENT as m, type Formatter as n, type OptionType as o, type Options as p, Registry as q, TEXT_FORMAT as r, TRANSIENCE_PERMANENT as s, TRANSIENCE_TRANSIENT as t, TRANSIENCE_UNKNOWN as u, columnName as v, conflictError as w, defaultRegistry as x, deriveHeaders as y, dispatch as z };