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

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.
@@ -1,4 +1,5 @@
1
1
  import { Command } from 'commander';
2
+ import { C as CODE_CONFLICT, a as CODE_GENERIC, b as CODE_NOT_FOUND, c as CODE_OK, d as CODE_PROVENANCE_MISSING, e as CODE_RATE_LIMITED, f as CODE_TRANSIENT, g as CODE_UNAUTHORIZED, h as CODE_USAGE, i as CliError, E as EXIT_GENERIC, j as EXIT_PROVENANCE_MISSING, k as EXIT_RATE_LIMITED, l as EXIT_TRANSIENT, T as TRANSIENCE_PERMANENT, m as TRANSIENCE_TRANSIENT, n as TRANSIENCE_UNKNOWN, o as conflictError, p as genericError, q as notFoundError, r as provenanceMissingError, s as rateLimitedError, t as renderError, u as transienceForCode, v as transientError, w as unauthorizedError, x as unwrapError, y as usageError, z as withTransience, A as wrapError } from './error-DISJKeDu.js';
2
3
 
3
4
  /**
4
5
  * @module output/formatter
@@ -268,134 +269,6 @@ interface DispatchOptions<T = unknown> {
268
269
  */
269
270
  declare function dispatch<T>(cmd: Command, data: T | readonly T[], options?: DispatchOptions<T>): Promise<void>;
270
271
 
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
272
  /**
400
273
  * @module output
401
274
  * @package @hop-top/kit
@@ -465,9 +338,10 @@ declare const output_CODE_TRANSIENT: typeof CODE_TRANSIENT;
465
338
  declare const output_CODE_UNAUTHORIZED: typeof CODE_UNAUTHORIZED;
466
339
  declare const output_CODE_USAGE: typeof CODE_USAGE;
467
340
  declare const output_CSV_FORMAT: typeof CSV_FORMAT;
468
- type output_CliError = CliError;
341
+ declare const output_CliError: typeof CliError;
469
342
  type output_ColumnSpec = ColumnSpec;
470
343
  type output_DispatchOptions<T = unknown> = DispatchOptions<T>;
344
+ declare const output_EXIT_GENERIC: typeof EXIT_GENERIC;
471
345
  declare const output_EXIT_PROVENANCE_MISSING: typeof EXIT_PROVENANCE_MISSING;
472
346
  declare const output_EXIT_RATE_LIMITED: typeof EXIT_RATE_LIMITED;
473
347
  declare const output_EXIT_TRANSIENT: typeof EXIT_TRANSIENT;
@@ -491,6 +365,7 @@ declare const output_conflictError: typeof conflictError;
491
365
  declare const output_defaultRegistry: typeof defaultRegistry;
492
366
  declare const output_deriveHeaders: typeof deriveHeaders;
493
367
  declare const output_dispatch: typeof dispatch;
368
+ declare const output_genericError: typeof genericError;
494
369
  declare const output_jsonFormatter: typeof jsonFormatter;
495
370
  declare const output_newRegistry: typeof newRegistry;
496
371
  declare const output_notFoundError: typeof notFoundError;
@@ -515,7 +390,7 @@ declare const output_withTransience: typeof withTransience;
515
390
  declare const output_wrapError: typeof wrapError;
516
391
  declare const output_yamlFormatter: typeof yamlFormatter;
517
392
  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 };
393
+ 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, output_CliError as CliError, type output_ColumnSpec as ColumnSpec, type output_DispatchOptions as DispatchOptions, output_EXIT_GENERIC as EXIT_GENERIC, 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_genericError as genericError, 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
394
  }
520
395
 
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 };
396
+ export { CSV_FORMAT as C, type DispatchOptions as D, type Format as F, JSON_FORMAT as J, type OptionSpec as O, type RegisterOutputFlagsOptions as R, TABLE_FORMAT as T, YAML_FORMAT as Y, type ColumnSpec as a, type Formatter as b, type OptionType as c, type Options as d, Registry as e, TEXT_FORMAT as f, columnName as g, defaultRegistry as h, deriveHeaders as i, dispatch as j, jsonFormatter as k, output as l, projectRows as m, newRegistry as n, optionTypeName as o, parseOptions as p, registryFor as q, registerOutputFlags as r, render as s, resolveCols as t, resolveEffectiveCols as u, tableFormatter as v, yamlFormatter as y };
package/dist/output.d.ts CHANGED
@@ -1,2 +1,3 @@
1
- export { C as CODE_CONFLICT, a as CODE_GENERIC, b as CODE_NOT_FOUND, c as CODE_OK, d as CODE_PROVENANCE_MISSING, e as CODE_RATE_LIMITED, f as CODE_TRANSIENT, g as CODE_UNAUTHORIZED, h as CODE_USAGE, i as CSV_FORMAT, j as CliError, k as ColumnSpec, D as DispatchOptions, E as EXIT_PROVENANCE_MISSING, l as EXIT_RATE_LIMITED, m as EXIT_TRANSIENT, F as Format, n as Formatter, J as JSON_FORMAT, O as OptionSpec, o as OptionType, p as Options, R as RegisterOutputFlagsOptions, q as Registry, T as TABLE_FORMAT, r as TEXT_FORMAT, s as TRANSIENCE_PERMANENT, t as TRANSIENCE_TRANSIENT, u as TRANSIENCE_UNKNOWN, Y as YAML_FORMAT, v as columnName, w as conflictError, x as defaultRegistry, y as deriveHeaders, z as dispatch, A as jsonFormatter, B as newRegistry, G as notFoundError, H as optionTypeName, K as parseOptions, L as projectRows, M as provenanceMissingError, N as rateLimitedError, P as registerOutputFlags, Q as registryFor, S as render, U as renderError, V as resolveCols, W as resolveEffectiveCols, X as tableFormatter, Z as transienceForCode, _ as transientError, $ as unauthorizedError, a0 as unwrapError, a1 as usageError, a2 as withTransience, a3 as wrapError, a4 as yamlFormatter } from './output-VFFLqor9.js';
1
+ export { C as CSV_FORMAT, a as ColumnSpec, D as DispatchOptions, F as Format, b as Formatter, J as JSON_FORMAT, O as OptionSpec, c as OptionType, d as Options, R as RegisterOutputFlagsOptions, e as Registry, T as TABLE_FORMAT, f as TEXT_FORMAT, Y as YAML_FORMAT, g as columnName, h as defaultRegistry, i as deriveHeaders, j as dispatch, k as jsonFormatter, n as newRegistry, o as optionTypeName, p as parseOptions, m as projectRows, r as registerOutputFlags, q as registryFor, s as render, t as resolveCols, u as resolveEffectiveCols, v as tableFormatter, y as yamlFormatter } from './output-4aXs91GY.js';
2
+ export { C as CODE_CONFLICT, a as CODE_GENERIC, b as CODE_NOT_FOUND, c as CODE_OK, d as CODE_PROVENANCE_MISSING, e as CODE_RATE_LIMITED, f as CODE_TRANSIENT, g as CODE_UNAUTHORIZED, h as CODE_USAGE, i as CliError, E as EXIT_GENERIC, j as EXIT_PROVENANCE_MISSING, k as EXIT_RATE_LIMITED, l as EXIT_TRANSIENT, T as TRANSIENCE_PERMANENT, m as TRANSIENCE_TRANSIENT, n as TRANSIENCE_UNKNOWN, o as conflictError, p as genericError, q as notFoundError, r as provenanceMissingError, s as rateLimitedError, t as renderError, u as transienceForCode, v as transientError, w as unauthorizedError, x as unwrapError, y as usageError, z as withTransience, A as wrapError } from './error-DISJKeDu.js';
2
3
  import 'commander';
package/dist/output.js CHANGED
@@ -40,6 +40,7 @@ __export(output_exports, {
40
40
  CODE_UNAUTHORIZED: () => CODE_UNAUTHORIZED,
41
41
  CODE_USAGE: () => CODE_USAGE,
42
42
  CSV_FORMAT: () => CSV_FORMAT,
43
+ EXIT_GENERIC: () => EXIT_GENERIC,
43
44
  EXIT_PROVENANCE_MISSING: () => EXIT_PROVENANCE_MISSING,
44
45
  EXIT_RATE_LIMITED: () => EXIT_RATE_LIMITED,
45
46
  EXIT_TRANSIENT: () => EXIT_TRANSIENT,
@@ -56,6 +57,7 @@ __export(output_exports, {
56
57
  defaultRegistry: () => defaultRegistry,
57
58
  deriveHeaders: () => deriveHeaders,
58
59
  dispatch: () => dispatch,
60
+ genericError: () => genericError,
59
61
  jsonFormatter: () => jsonFormatter,
60
62
  newRegistry: () => newRegistry,
61
63
  notFoundError: () => notFoundError,
@@ -606,6 +608,7 @@ var CODE_UNAUTHORIZED = "UNAUTHORIZED";
606
608
  var CODE_TRANSIENT = "TRANSIENT";
607
609
  var CODE_PROVENANCE_MISSING = "PROVENANCE_MISSING";
608
610
  var CODE_RATE_LIMITED = "RATE_LIMITED";
611
+ var EXIT_GENERIC = 1;
609
612
  var EXIT_TRANSIENT = 6;
610
613
  var EXIT_RATE_LIMITED = 64;
611
614
  var EXIT_PROVENANCE_MISSING = 65;
@@ -644,6 +647,14 @@ function withTransience(e, transience) {
644
647
  if (retained.has(e)) retained.set(clone, retained.get(e));
645
648
  return clone;
646
649
  }
650
+ function genericError(message) {
651
+ return {
652
+ code: CODE_GENERIC,
653
+ message,
654
+ exit_code: EXIT_GENERIC,
655
+ transience: TRANSIENCE_PERMANENT
656
+ };
657
+ }
647
658
  function notFoundError(message) {
648
659
  return {
649
660
  code: CODE_NOT_FOUND,
@@ -916,6 +927,7 @@ function render(w, format, v) {
916
927
  CODE_UNAUTHORIZED,
917
928
  CODE_USAGE,
918
929
  CSV_FORMAT,
930
+ EXIT_GENERIC,
919
931
  EXIT_PROVENANCE_MISSING,
920
932
  EXIT_RATE_LIMITED,
921
933
  EXIT_TRANSIENT,
@@ -932,6 +944,7 @@ function render(w, format, v) {
932
944
  defaultRegistry,
933
945
  deriveHeaders,
934
946
  dispatch,
947
+ genericError,
935
948
  jsonFormatter,
936
949
  newRegistry,
937
950
  notFoundError,