@hop-top/kit 0.5.0-alpha.1 → 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.
Files changed (107) hide show
  1. package/CHANGELOG.md +107 -0
  2. package/README.md +333 -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-DLygZLi9.d.ts +450 -0
  12. package/dist/cli.d.ts +6 -309
  13. package/dist/cli.js +192 -63
  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/error-DISJKeDu.d.ts +144 -0
  19. package/dist/id/index.d.ts +2 -83
  20. package/dist/index-Bc5c7Ty5.d.ts +328 -0
  21. package/dist/index-C3Zw4wDJ.d.ts +359 -0
  22. package/dist/index-MLrRDvEG.d.ts +1073 -0
  23. package/dist/index-QSffbLnj.d.ts +94 -0
  24. package/dist/index.d.ts +28 -0
  25. package/dist/index.js +6794 -0
  26. package/dist/llm-B5XUWH8T.d.ts +231 -0
  27. package/dist/llm.d.ts +1 -188
  28. package/dist/mcp/index.d.ts +2 -0
  29. package/dist/mcp/index.js +1453 -0
  30. package/dist/netpolicy-asvCfwi8.d.ts +138 -0
  31. package/dist/netpolicy.d.ts +1 -0
  32. package/dist/netpolicy.js +118 -0
  33. package/dist/output-4aXs91GY.d.ts +396 -0
  34. package/dist/output.d.ts +3 -213
  35. package/dist/output.js +567 -43
  36. package/dist/progress-CAzyxeWl.d.ts +38 -0
  37. package/dist/progress.d.ts +1 -30
  38. package/dist/provenance-SMFHm5gx.d.ts +30 -0
  39. package/dist/provenance.d.ts +1 -24
  40. package/dist/routellm-PGSt2D1y.d.ts +75 -0
  41. package/dist/routellm.d.ts +2 -64
  42. package/dist/rpc-D5xLEf8V.d.ts +32 -0
  43. package/dist/rpc.d.ts +2 -25
  44. package/dist/safety-CUaYEjZc.d.ts +30 -0
  45. package/dist/safety.d.ts +1 -24
  46. package/dist/scope-BrhYB4ij.d.ts +141 -0
  47. package/dist/scope.d.ts +1 -121
  48. package/dist/serve-DE-jscpb.d.ts +646 -0
  49. package/dist/serve.d.ts +3 -0
  50. package/dist/serve.js +1019 -0
  51. package/dist/stream-CrjeCp0M.d.ts +44 -0
  52. package/dist/stream.d.ts +1 -35
  53. package/dist/telemetry/index.d.ts +1 -315
  54. package/dist/telemetry/index.js +12 -1
  55. package/dist/tui/index.d.ts +5 -298
  56. package/dist/tui/index.js +3 -10
  57. package/dist/upgrade-p_zh3pvV.d.ts +102 -0
  58. package/dist/upgrade.d.ts +1 -95
  59. package/dist/xdg-DB7Shoib.d.ts +179 -0
  60. package/dist/xdg.d.ts +1 -169
  61. package/package.json +26 -3
  62. package/src/cli.offline.test.ts +93 -0
  63. package/src/cli.parity.test.ts +192 -0
  64. package/src/cli.ts +112 -12
  65. package/src/index.test.ts +58 -0
  66. package/src/index.ts +37 -0
  67. package/src/log.parity.test.ts +105 -0
  68. package/src/log.ts +64 -13
  69. package/src/mcp/bridge.test.ts +150 -0
  70. package/src/mcp/bridge.ts +246 -0
  71. package/src/mcp/conformance.test.ts +336 -0
  72. package/src/mcp/dispatch.ts +313 -0
  73. package/src/mcp/index.ts +138 -0
  74. package/src/mcp/legacy.ts +314 -0
  75. package/src/mcp/mcp.test.ts +697 -0
  76. package/src/mcp/modern-confirm.test.ts +520 -0
  77. package/src/mcp/modern-confirm.ts +452 -0
  78. package/src/mcp/modern.ts +723 -0
  79. package/src/mcp/tasks.ts +82 -0
  80. package/src/mcp/testtree.ts +250 -0
  81. package/src/mcp/types.ts +504 -0
  82. package/src/netpolicy.test.ts +202 -0
  83. package/src/netpolicy.ts +231 -0
  84. package/src/output/dispatch.ts +10 -2
  85. package/src/output/error.ts +316 -0
  86. package/src/output/formatter.ts +29 -5
  87. package/src/output/formatters/csv.ts +48 -12
  88. package/src/output/formatters/json.ts +4 -25
  89. package/src/output/formatters/project.ts +34 -0
  90. package/src/output/formatters/table.ts +8 -6
  91. package/src/output/formatters/text.ts +7 -3
  92. package/src/output/formatters/yaml.ts +5 -22
  93. package/src/output/projection.test.ts +298 -0
  94. package/src/output/projection.ts +33 -59
  95. package/src/output/template.ts +11 -21
  96. package/src/output.surface.test.ts +41 -0
  97. package/src/output.ts +41 -3
  98. package/src/serve.test.ts +1257 -0
  99. package/src/serve.ts +1665 -0
  100. package/src/telemetry/client.test.ts +31 -0
  101. package/src/telemetry/client.ts +7 -1
  102. package/src/telemetry/offline.test.ts +64 -0
  103. package/src/tui/parity.test.ts +120 -31
  104. package/src/tui/parity.ts +58 -7
  105. package/test/output/csv.test.ts +164 -0
  106. package/test/output/error.test.ts +246 -0
  107. package/src/tui/parity.json +0 -74
@@ -1,37 +1 @@
1
- /**
2
- * @module errcorrect
3
- * @package @hop-top/kit
4
- *
5
- * Factor 4 — Corrective Error Model.
6
- *
7
- * Structured errors with machine-readable code, human-readable message,
8
- * likely cause, suggested fix, and alternative commands.
9
- */
10
- interface CorrectedError {
11
- code: string;
12
- message: string;
13
- cause?: string;
14
- fix?: string;
15
- alternatives?: string[];
16
- retryable?: boolean;
17
- }
18
- /**
19
- * Creates an Error instance augmented with CorrectedError fields.
20
- * Serializes cleanly to JSON (only defined fields).
21
- */
22
- declare function createCorrectedError(opts: CorrectedError): Error & CorrectedError;
23
- /**
24
- * Formats a CorrectedError for terminal display.
25
- *
26
- * ```
27
- * ERROR mission not found
28
- * Cause: no mission matches "bogux"
29
- * Fix: spaced mission list
30
- * Try: spaced mission search bogux
31
- * ```
32
- */
33
- declare function formatError(err: CorrectedError, opts?: {
34
- noColor?: boolean;
35
- }): string;
36
-
37
- export { type CorrectedError, createCorrectedError, formatError };
1
+ export { C as CorrectedError, c as createCorrectedError, f as formatError } from './errcorrect-BcX1Ft0K.js';
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @module output/error
3
+ *
4
+ * Structured-error envelope. Mirrors Go's `go/console/output` error
5
+ * envelope: when a command fails under `--format json|yaml`, the error is
6
+ * materialized as a {@link CliError} and rendered to stderr by
7
+ * {@link renderError}. Plaintext mode (`--format table` or unset) prints
8
+ * `"Code: Message\nFix: ...\n"`.
9
+ *
10
+ * Fields use the on-wire snake_case keys directly (like the telemetry
11
+ * `Envelope`) so `JSON.stringify` is wire-exact; empty optional fields
12
+ * stay off the wire, mirroring Go's `omitempty`.
13
+ */
14
+ /** Marks a failure a retry may clear (rate limit, timeout, upstream blip). */
15
+ declare const TRANSIENCE_TRANSIENT = "transient";
16
+ /**
17
+ * Marks a failure retrying cannot clear without changing the input or the
18
+ * environment.
19
+ */
20
+ declare const TRANSIENCE_PERMANENT = "permanent";
21
+ /**
22
+ * Marks a failure kit cannot classify. Agents should treat retries as
23
+ * best-effort and bounded.
24
+ */
25
+ declare const TRANSIENCE_UNKNOWN = "unknown";
26
+ declare const CODE_OK = "OK";
27
+ declare const CODE_GENERIC = "GENERIC";
28
+ declare const CODE_USAGE = "USAGE";
29
+ declare const CODE_NOT_FOUND = "NOT_FOUND";
30
+ declare const CODE_CONFLICT = "CONFLICT";
31
+ declare const CODE_UNAUTHORIZED = "UNAUTHORIZED";
32
+ declare const CODE_TRANSIENT = "TRANSIENT";
33
+ declare const CODE_PROVENANCE_MISSING = "PROVENANCE_MISSING";
34
+ declare const CODE_RATE_LIMITED = "RATE_LIMITED";
35
+ /**
36
+ * Spec-assigned exit code for the generic failure class: the command
37
+ * failed and no narrower code applies. Pair it with {@link genericError}
38
+ * rather than hand-rolling exit 1, so the envelope carries a transience
39
+ * class.
40
+ */
41
+ declare const EXIT_GENERIC = 1;
42
+ /**
43
+ * Spec-assigned exit code for transient/retryable failures (Factor 11).
44
+ * Agents branch on it before parsing stderr: exit 6 means a retry may
45
+ * clear the failure.
46
+ */
47
+ declare const EXIT_TRANSIENT = 6;
48
+ /** Conventional exit code for Factor-10 rate-limit refusals. */
49
+ declare const EXIT_RATE_LIMITED = 64;
50
+ /**
51
+ * Conventional exit code for Factor-12 strict-mode provenance refusals.
52
+ * Lives at 65 in kit's extension band (alongside RATE_LIMITED at 64):
53
+ * the spec reserves 0-6 for its core taxonomy and leaves >6 to per-tool
54
+ * codes, and kit as a library stays out of the low per-tool range.
55
+ */
56
+ declare const EXIT_PROVENANCE_MISSING = 65;
57
+ /**
58
+ * Structured-error envelope rendered to stderr when `--format json|yaml`
59
+ * is set. Keys are the on-wire snake_case names.
60
+ *
61
+ * `transience` classifies the failure for retry decisions (Factor 4):
62
+ * transient (retry-worthy), permanent (do not retry), or unknown.
63
+ * Constructors and {@link wrapError} populate it; {@link renderError}
64
+ * normalizes an unset value to unknown so every structured error carries
65
+ * a valid class on the wire.
66
+ */
67
+ interface CliError {
68
+ code: string;
69
+ message: string;
70
+ cause?: string;
71
+ suggested_fix?: string;
72
+ alternatives?: string[];
73
+ exit_code: number;
74
+ transience?: string;
75
+ }
76
+ /**
77
+ * Default transience class for one of the standard codes. Unrecognized
78
+ * (adopter-defined) codes map to unknown; adopters set `transience`
79
+ * (or use {@link withTransience}) to classify their own codes.
80
+ */
81
+ declare function transienceForCode(code: string): string;
82
+ /**
83
+ * Builds an envelope from `err`, retaining it for {@link unwrapError}
84
+ * while rendering as `code` and message. Transience defaults from the
85
+ * code via {@link transienceForCode}; use {@link withTransience} to
86
+ * override.
87
+ */
88
+ declare function wrapError(err: unknown, code: string, exitCode: number): CliError | null;
89
+ /**
90
+ * The error this envelope was built from via {@link wrapError}, so
91
+ * callers can classify failures by cause instead of string-matching
92
+ * `message`. Mirrors Go's `(*Error).Unwrap`.
93
+ */
94
+ declare function unwrapError(e: CliError): unknown;
95
+ /**
96
+ * Copy of `e` with `transience` set, every other field (and the retained
97
+ * source error) untouched. Copies rather than mutating: adopters
98
+ * commonly share module-level envelopes, and writing to one would leak
99
+ * across call sites.
100
+ */
101
+ declare function withTransience(e: CliError, transience: string): CliError;
102
+ /**
103
+ * CODE_GENERIC envelope with exit code 1. The catch-all for failures no
104
+ * narrower code describes; permanent because retrying the same input
105
+ * in the same environment is not expected to help. Wrapping an
106
+ * arbitrary error as CODE_GENERIC via {@link wrapError} still defaults
107
+ * to unknown.
108
+ */
109
+ declare function genericError(message: string): CliError;
110
+ /** CODE_NOT_FOUND envelope with exit code 3. */
111
+ declare function notFoundError(message: string): CliError;
112
+ /** CODE_CONFLICT envelope with exit code 4. */
113
+ declare function conflictError(message: string): CliError;
114
+ /** CODE_UNAUTHORIZED envelope with exit code 5. */
115
+ declare function unauthorizedError(message: string): CliError;
116
+ /** CODE_USAGE envelope with exit code 2. */
117
+ declare function usageError(message: string): CliError;
118
+ /**
119
+ * CODE_TRANSIENT envelope with exit code 6 (Factor 11). Use it for
120
+ * failures a retry may clear: upstream timeouts, connection resets,
121
+ * service-unavailable responses.
122
+ */
123
+ declare function transientError(message: string): CliError;
124
+ /** CODE_RATE_LIMITED envelope with exit code 64 (Factor 10). */
125
+ declare function rateLimitedError(message: string): CliError;
126
+ /**
127
+ * CODE_PROVENANCE_MISSING envelope with exit code 65 (Factor 12).
128
+ * `detail` is a free-form string suitable for the `cause` slot
129
+ * (typically the JSON-pointer list of offending fields).
130
+ */
131
+ declare function provenanceMissingError(detail: string): CliError;
132
+ /**
133
+ * Writes `err` to `w` in the requested format. `format === ''` or
134
+ * `'table'` renders human-readable plain text (`"Code: Message\nFix:
135
+ * ..."`); JSON/YAML render the envelope structurally. An unset
136
+ * transience is normalized to unknown on the wire (Factor 4) without
137
+ * mutating `err`. Always returns; the caller decides the exit code from
138
+ * `err.exit_code` after rendering.
139
+ */
140
+ declare function renderError(w: {
141
+ write(chunk: string): unknown;
142
+ }, format: string, err: CliError | null | undefined): void;
143
+
144
+ export { wrapError as A, CODE_CONFLICT as C, EXIT_GENERIC as E, TRANSIENCE_PERMANENT as T, CODE_GENERIC as a, 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, type CliError as i, EXIT_PROVENANCE_MISSING as j, EXIT_RATE_LIMITED as k, EXIT_TRANSIENT as l, TRANSIENCE_TRANSIENT as m, TRANSIENCE_UNKNOWN as n, conflictError as o, genericError as p, notFoundError as q, provenanceMissingError as r, rateLimitedError as s, renderError as t, transienceForCode as u, transientError as v, unauthorizedError as w, unwrapError as x, usageError as y, withTransience as z };
@@ -1,83 +1,2 @@
1
- import { z } from 'zod';
2
-
3
- /**
4
- * @module id
5
- * @package @hop-top/kit
6
- *
7
- * TypeID primitive — thin wrapper around `typeid-js` (jetify-com)
8
- * implementing the cross-language kit API SHAPE per ADR 0001.
9
- *
10
- * Canonical wire form: `<prefix>_<26-char-base32>` where the suffix is
11
- * a Crockford-base32-encoded UUIDv7. The TS surface adds a
12
- * template-literal `Typed<P>` for compile-time prefix safety on top of
13
- * the runtime guarantees provided by `typeid-js`.
14
- *
15
- * URI composition (e.g. `tlc://task/task_…`) is NOT in this module —
16
- * callers should use the `@hop-top/cite` package directly. This
17
- * keeps `kit/id` free of any transitive dependency on the URI
18
- * registry, per the ADR's scope boundary.
19
- */
20
-
21
- /**
22
- * Compile-time-typed canonical TypeID string for prefix `P`.
23
- *
24
- * The template-literal `${P}_${string}` form means a `Typed<'task'>`
25
- * is statically distinguishable from a `Typed<'invoice'>` even though
26
- * both are runtime `string`s. Pair with {@link newTyped} or
27
- * {@link parseTyped} to mint values whose prefix is enforced both at
28
- * compile time and at runtime.
29
- */
30
- type Typed<P extends string> = `${P}_${string}`;
31
- /** Parsed components of a canonical TypeID string. */
32
- interface Parsed {
33
- /** Prefix segment (everything before the final underscore). */
34
- prefix: string;
35
- /** Backing UUID in canonical 8-4-4-4-12 hyphenated form. */
36
- uuid: string;
37
- }
38
- /**
39
- * Generate a new TypeID with the given prefix, returning the canonical
40
- * string `<prefix>_<26-char-base32>`.
41
- *
42
- * @example
43
- * newId('task') // => 'task_01h2e8kqv8000000000000000'
44
- */
45
- declare function newId(prefix: string): string;
46
- /**
47
- * Parse a canonical TypeID string into its prefix and backing UUID.
48
- *
49
- * @throws {Error} when the input is not a syntactically valid TypeID
50
- * (e.g. malformed suffix, illegal prefix characters).
51
- */
52
- declare function parse(s: string): Parsed;
53
- /**
54
- * Typed variant of {@link newId}. Returns a `Typed<P>` whose static
55
- * type carries the literal prefix, enabling compile-time discrimination
56
- * between e.g. `TaskId` and `InvoiceId`.
57
- */
58
- declare function newTyped<P extends string>(prefix: P): Typed<P>;
59
- /**
60
- * Typed variant of {@link parse}. Validates that the parsed prefix
61
- * matches the expected `prefix` argument at runtime; returns the
62
- * canonical string narrowed to `Typed<P>`.
63
- *
64
- * @throws {Error} when the parsed prefix does not match `prefix`, or
65
- * when the input is not a syntactically valid TypeID.
66
- */
67
- declare function parseTyped<P extends string>(prefix: P, s: string): Typed<P>;
68
- /**
69
- * Zod schema for runtime validation of a `${prefix}_<26-char-base32>`
70
- * canonical TypeID string.
71
- *
72
- * The schema only validates structure (prefix match + 26-char Crockford
73
- * base32 suffix with the spec's leading-bit constraint). It does not
74
- * decode the UUIDv7 timestamp; use {@link parse} if you need the
75
- * underlying UUID.
76
- *
77
- * @example
78
- * const TaskIdSchema = typeIdSchema('task');
79
- * TaskIdSchema.parse('task_01h2e8kqv8000000000000000');
80
- */
81
- declare function typeIdSchema(prefix: string): z.ZodString;
82
-
83
- export { type Parsed, type Typed, newId, newTyped, parse, parseTyped, typeIdSchema };
1
+ import 'zod';
2
+ export { P as Parsed, T as Typed, n as newId, a as newTyped, p as parse, b as parseTyped, t as typeIdSchema } from '../index-QSffbLnj.js';
@@ -0,0 +1,328 @@
1
+ import { T as Theme } from './cli-DLygZLi9.js';
2
+
3
+ /**
4
+ * @module tui/badge
5
+ * @package @hop-top/kit
6
+ *
7
+ * Renders a styled badge/pill string.
8
+ * Mirrors Go's badge concept from hop.top/kit/tui — pure string, no bubbletea dep.
9
+ */
10
+
11
+ interface BadgeOpts {
12
+ /** Override background color (hex, e.g. "#FF0000"). Defaults to theme.accent. */
13
+ color?: string;
14
+ }
15
+ /**
16
+ * Renders a styled inline badge.
17
+ *
18
+ * Background defaults to `theme.accent`; text is rendered in white for contrast.
19
+ * Padding of one space is added on each side (mirrors lipgloss Padding(0, 1)).
20
+ *
21
+ * @param theme - Active CLI theme.
22
+ * @param text - Badge label text.
23
+ * @param opts - Optional overrides.
24
+ * @returns ANSI-styled badge string.
25
+ *
26
+ * @example
27
+ * ```ts
28
+ * import { buildTheme } from '@hop-top/kit/cli';
29
+ * import { badge } from '@hop-top/kit/tui';
30
+ * console.log(badge(buildTheme(), '^ UPDATE'));
31
+ * ```
32
+ */
33
+ declare function badge(theme: Theme, text: string, opts?: BadgeOpts): string;
34
+
35
+ /**
36
+ * @module tui/status
37
+ * @package @hop-top/kit
38
+ *
39
+ * Renders a prefixed status line with kind-derived symbol + color.
40
+ * Mirrors Go's InfoType/Status concept from hop.top/kit/tui.
41
+ */
42
+
43
+ /** Classification of a status message — maps to indicator symbol and color. */
44
+ type StatusKind = 'info' | 'success' | 'error' | 'warn';
45
+ /**
46
+ * Renders a prefixed status line.
47
+ *
48
+ * Indicator symbols and colors mirror Go's InfoType constants:
49
+ * - info → ℹ accent
50
+ * - success → ✓ success
51
+ * - error → ● error
52
+ * - warn → ▲ secondary
53
+ *
54
+ * @param theme - Active CLI theme.
55
+ * @param text - Status message text.
56
+ * @param kind - Message classification (default: `'info'`).
57
+ * @returns ANSI-styled status string with indicator prefix.
58
+ *
59
+ * @example
60
+ * ```ts
61
+ * import { buildTheme } from '@hop-top/kit/cli';
62
+ * import { status } from '@hop-top/kit/tui';
63
+ * console.log(status(buildTheme(), 'Operation complete', 'success'));
64
+ * ```
65
+ */
66
+ declare function status(theme: Theme, text: string, kind?: StatusKind): string;
67
+
68
+ /**
69
+ * @module tui/pills
70
+ * @package @hop-top/kit
71
+ *
72
+ * Renders a horizontal list of styled pills.
73
+ * Mirrors Go's Pill/PillBar concept from hop.top/kit/tui — pure string output.
74
+ */
75
+
76
+ /**
77
+ * Renders a space-separated row of styled pills.
78
+ *
79
+ * Each item is wrapped in `theme.secondary` foreground color with one space of
80
+ * padding on each side, mirroring lipgloss Padding(0, 1) on a blurred pill.
81
+ *
82
+ * @param theme - Active CLI theme.
83
+ * @param items - Labels to render as pills.
84
+ * @returns Space-joined ANSI-styled pill string. Empty string when no items.
85
+ *
86
+ * @example
87
+ * ```ts
88
+ * import { buildTheme } from '@hop-top/kit/cli';
89
+ * import { pills } from '@hop-top/kit/tui';
90
+ * console.log(pills(buildTheme(), ['branch: main', 'env: prod']));
91
+ * ```
92
+ */
93
+ declare function pills(theme: Theme, items: string[]): string;
94
+
95
+ /**
96
+ * @module tui/spinner
97
+ * @package @hop-top/kit
98
+ *
99
+ * Terminal spinner component.
100
+ * Mirrors Go's NewSpinner from hop.top/kit/tui — pure ANSI, no bubbletea dep.
101
+ */
102
+
103
+ interface Spinner {
104
+ /** Start spinning with optional message. */
105
+ start(msg?: string): void;
106
+ /** Stop spinner, print optional final message. */
107
+ stop(msg?: string): void;
108
+ /** Update the spinner message while running. */
109
+ message(msg: string): void;
110
+ }
111
+ /**
112
+ * Creates a terminal spinner styled with theme.accent.
113
+ *
114
+ * Renders to stderr; uses \r to overwrite the current line each frame.
115
+ *
116
+ * @param theme - Active CLI theme.
117
+ * @returns Spinner control object.
118
+ *
119
+ * @example
120
+ * ```ts
121
+ * import { buildTheme } from '@hop-top/kit/cli';
122
+ * import { spinner } from '@hop-top/kit/tui';
123
+ * const s = spinner(buildTheme());
124
+ * s.start('Loading…');
125
+ * // await work
126
+ * s.stop('Done');
127
+ * ```
128
+ */
129
+ declare function spinner(theme: Theme): Spinner;
130
+
131
+ /**
132
+ * @module tui/progress
133
+ * @package @hop-top/kit
134
+ *
135
+ * Terminal progress bar component.
136
+ * Mirrors Go's Progress from hop.top/kit/tui — pure ANSI, no bubbletea dep.
137
+ *
138
+ * Renders a 30-char ASCII bar: filled chars in theme.accent, empty in theme.muted.
139
+ */
140
+
141
+ interface Progress {
142
+ /** Start the progress bar with optional message. */
143
+ start(msg?: string): void;
144
+ /** Update progress value (0.0–1.0) with optional message. */
145
+ update(value: number, msg?: string): void;
146
+ /** Stop the progress bar with optional final message. */
147
+ stop(msg?: string): void;
148
+ }
149
+ /**
150
+ * Creates a terminal progress bar styled with theme colors.
151
+ *
152
+ * Fill chars rendered in theme.accent; empty track in theme.muted.
153
+ * Renders to stderr using \r to overwrite the current line.
154
+ *
155
+ * @param theme - Active CLI theme.
156
+ * @param total - Optional total units (unused — value is always 0.0–1.0 ratio).
157
+ * @returns Progress control object.
158
+ *
159
+ * @example
160
+ * ```ts
161
+ * import { buildTheme } from '@hop-top/kit/cli';
162
+ * import { progress } from '@hop-top/kit/tui';
163
+ * const p = progress(buildTheme());
164
+ * p.start('Downloading…');
165
+ * p.update(0.5, 'Half done');
166
+ * p.stop('Complete');
167
+ * ```
168
+ */
169
+ declare function progress(theme: Theme, _total?: number): Progress;
170
+ declare function clamp01(v: number): number;
171
+ /** Render a plain bar string (no ANSI) for testing. */
172
+ declare function renderBarPlain(value: number): string;
173
+
174
+ /**
175
+ * @module tui/anim
176
+ * @package @hop-top/kit
177
+ *
178
+ * Gradient animation component — cycling character scramble.
179
+ * Mirrors Go's Anim from hop.top/kit/tui — pure ANSI, no bubbletea dep.
180
+ *
181
+ * Cycles random chars through a gradient from theme.accent → theme.secondary
182
+ * at ~100ms per frame. Uses \r to overwrite the current line.
183
+ */
184
+
185
+ interface AnimOpts {
186
+ /** Number of animated characters (default: 10). */
187
+ width?: number;
188
+ /** Optional label rendered after the animation. */
189
+ label?: string;
190
+ }
191
+ interface Anim {
192
+ /** Start the animation loop. */
193
+ start(): void;
194
+ /** Stop the animation loop and clear the line. */
195
+ stop(): void;
196
+ /** Update the label shown after the animated chars. */
197
+ setLabel(label: string): void;
198
+ }
199
+ /**
200
+ * Creates a gradient-cycling character scramble animation.
201
+ *
202
+ * Colors cycle from theme.accent to theme.secondary across the width.
203
+ * Renders to stderr; uses \r to overwrite the current line each tick.
204
+ *
205
+ * @param theme - Active CLI theme.
206
+ * @param opts - Optional width and initial label.
207
+ * @returns Anim control object.
208
+ *
209
+ * @example
210
+ * ```ts
211
+ * import { buildTheme } from '@hop-top/kit/cli';
212
+ * import { anim } from '@hop-top/kit/tui';
213
+ * const a = anim(buildTheme(), { label: 'processing' });
214
+ * a.start();
215
+ * // await work
216
+ * a.stop();
217
+ * ```
218
+ */
219
+ declare function anim(theme: Theme, opts?: AnimOpts): Anim;
220
+ /** Linear RGB blend from hexA → hexB across `steps` positions. */
221
+ declare function makeGradient(hexA: string, hexB: string, steps: number): Array<[number, number, number]>;
222
+
223
+ /**
224
+ * @module tui/confirm
225
+ * @package @hop-top/kit
226
+ *
227
+ * Interactive yes/no confirmation prompt.
228
+ * Wraps @clack/prompts confirm(); throws on cancel (Ctrl-C).
229
+ * Mirrors Go's NewConfirm from hop.top/kit/tui.
230
+ */
231
+
232
+ interface ConfirmOpts {
233
+ /** Default selection when user presses Enter without input. */
234
+ initial?: boolean;
235
+ }
236
+ /**
237
+ * Prompt the user with a yes/no question.
238
+ *
239
+ * @param _theme - Active CLI theme (reserved for future accent styling).
240
+ * @param message - Question to display.
241
+ * @param opts - Optional config; `initial` sets the default selection.
242
+ * @returns `true` if accepted, `false` if denied.
243
+ * @throws Error('cancelled') if user presses Ctrl-C.
244
+ *
245
+ * @example
246
+ * ```ts
247
+ * import { buildTheme } from '@hop-top/kit/cli';
248
+ * import { confirm } from '@hop-top/kit/tui';
249
+ * const ok = await confirm(buildTheme(), 'Deploy now?');
250
+ * ```
251
+ */
252
+ declare function confirm(_theme: Theme, message: string, opts?: ConfirmOpts): Promise<boolean>;
253
+
254
+ /**
255
+ * @module tui/list
256
+ * @package @hop-top/kit
257
+ *
258
+ * Interactive selection list prompt.
259
+ * Wraps @clack/prompts select(); throws on cancel (Ctrl-C).
260
+ * Mirrors Go's NewList from hop.top/kit/tui (selection variant).
261
+ */
262
+
263
+ interface ListItem {
264
+ /** Display label shown in the prompt. */
265
+ label: string;
266
+ /** Value returned when this item is selected. */
267
+ value: string;
268
+ /** Optional hint shown alongside the label. */
269
+ hint?: string;
270
+ }
271
+ interface ListOpts {
272
+ /** Value of the initially highlighted item. */
273
+ initial?: string;
274
+ }
275
+ /**
276
+ * Prompt the user to pick one item from a list.
277
+ *
278
+ * @param _theme - Active CLI theme (reserved for future accent styling).
279
+ * @param message - Prompt label shown above the list.
280
+ * @param items - Selectable options.
281
+ * @param opts - Optional config; `initial` sets the pre-selected value.
282
+ * @returns The `value` of the selected item.
283
+ * @throws Error('cancelled') if user presses Ctrl-C.
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * import { buildTheme } from '@hop-top/kit/cli';
288
+ * import { list } from '@hop-top/kit/tui';
289
+ * const env = await list(buildTheme(), 'Pick environment', [
290
+ * { label: 'Production', value: 'prod' },
291
+ * { label: 'Staging', value: 'staging', hint: 'default' },
292
+ * ]);
293
+ * ```
294
+ */
295
+ declare function list(_theme: Theme, message: string, items: ListItem[], opts?: ListOpts): Promise<string>;
296
+
297
+ /**
298
+ * @module tui
299
+ * @package @hop-top/kit
300
+ *
301
+ * Barrel re-export of TUI display components.
302
+ */
303
+
304
+ type index_Anim = Anim;
305
+ type index_AnimOpts = AnimOpts;
306
+ type index_BadgeOpts = BadgeOpts;
307
+ type index_ConfirmOpts = ConfirmOpts;
308
+ type index_ListItem = ListItem;
309
+ type index_ListOpts = ListOpts;
310
+ type index_Progress = Progress;
311
+ type index_Spinner = Spinner;
312
+ type index_StatusKind = StatusKind;
313
+ declare const index_anim: typeof anim;
314
+ declare const index_badge: typeof badge;
315
+ declare const index_clamp01: typeof clamp01;
316
+ declare const index_confirm: typeof confirm;
317
+ declare const index_list: typeof list;
318
+ declare const index_makeGradient: typeof makeGradient;
319
+ declare const index_pills: typeof pills;
320
+ declare const index_progress: typeof progress;
321
+ declare const index_renderBarPlain: typeof renderBarPlain;
322
+ declare const index_spinner: typeof spinner;
323
+ declare const index_status: typeof status;
324
+ declare namespace index {
325
+ export { type index_Anim as Anim, type index_AnimOpts as AnimOpts, type index_BadgeOpts as BadgeOpts, type index_ConfirmOpts as ConfirmOpts, type index_ListItem as ListItem, type index_ListOpts as ListOpts, type index_Progress as Progress, type index_Spinner as Spinner, type index_StatusKind as StatusKind, index_anim as anim, index_badge as badge, index_clamp01 as clamp01, index_confirm as confirm, index_list as list, index_makeGradient as makeGradient, index_pills as pills, index_progress as progress, index_renderBarPlain as renderBarPlain, index_spinner as spinner, index_status as status };
326
+ }
327
+
328
+ export { type Anim as A, type BadgeOpts as B, type ConfirmOpts as C, type ListItem as L, type Progress as P, type Spinner as S, type AnimOpts as a, type ListOpts as b, type StatusKind as c, anim as d, badge as e, clamp01 as f, confirm as g, progress as h, index as i, status as j, list as l, makeGradient as m, pills as p, renderBarPlain as r, spinner as s };