@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.
- package/CHANGELOG.md +98 -0
- package/README.md +237 -9
- package/dist/aim-CTp-kJW2.d.ts +139 -0
- package/dist/aim.d.ts +1 -116
- package/dist/alias-dhhr08Ei.d.ts +88 -0
- package/dist/alias.d.ts +2 -73
- package/dist/api-miiso81x.d.ts +77 -0
- package/dist/api.d.ts +1 -62
- package/dist/auth-2-jfgiHn.d.ts +34 -0
- package/dist/auth.d.ts +1 -26
- package/dist/cli-DgOEOsPB.d.ts +450 -0
- package/dist/cli.d.ts +5 -309
- package/dist/cli.js +250 -62
- package/dist/config-BUY7_W2n.d.ts +103 -0
- package/dist/config.d.ts +1 -97
- package/dist/errcorrect-BcX1Ft0K.d.ts +44 -0
- package/dist/errcorrect.d.ts +1 -37
- package/dist/id/index.d.ts +2 -83
- package/dist/index--C7Mtsmm.d.ts +328 -0
- package/dist/index-C3Zw4wDJ.d.ts +359 -0
- package/dist/index-MLrRDvEG.d.ts +1073 -0
- package/dist/index-QSffbLnj.d.ts +94 -0
- package/dist/index.d.ts +26 -0
- package/dist/index.js +5863 -0
- package/dist/llm-B5XUWH8T.d.ts +231 -0
- package/dist/llm.d.ts +1 -188
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +1453 -0
- package/dist/netpolicy-asvCfwi8.d.ts +138 -0
- package/dist/netpolicy.d.ts +1 -0
- package/dist/netpolicy.js +118 -0
- package/dist/output-VFFLqor9.d.ts +521 -0
- package/dist/output.d.ts +2 -213
- package/dist/output.js +554 -43
- package/dist/progress-CAzyxeWl.d.ts +38 -0
- package/dist/progress.d.ts +1 -30
- package/dist/provenance-SMFHm5gx.d.ts +30 -0
- package/dist/provenance.d.ts +1 -24
- package/dist/routellm-PGSt2D1y.d.ts +75 -0
- package/dist/routellm.d.ts +2 -64
- package/dist/rpc-D5xLEf8V.d.ts +32 -0
- package/dist/rpc.d.ts +2 -25
- package/dist/safety-CUaYEjZc.d.ts +30 -0
- package/dist/safety.d.ts +1 -24
- package/dist/scope-BrhYB4ij.d.ts +141 -0
- package/dist/scope.d.ts +1 -121
- package/dist/stream-CrjeCp0M.d.ts +44 -0
- package/dist/stream.d.ts +1 -35
- package/dist/telemetry/index.d.ts +1 -315
- package/dist/telemetry/index.js +12 -1
- package/dist/tui/index.d.ts +4 -298
- package/dist/tui/index.js +61 -9
- package/dist/upgrade-p_zh3pvV.d.ts +102 -0
- package/dist/upgrade.d.ts +1 -95
- package/dist/xdg-DB7Shoib.d.ts +179 -0
- package/dist/xdg.d.ts +1 -169
- package/package.json +65 -25
- package/src/cli.offline.test.ts +93 -0
- package/src/cli.parity.test.ts +192 -0
- package/src/cli.ts +112 -12
- package/src/index.test.ts +58 -0
- package/src/index.ts +36 -0
- package/src/log.parity.test.ts +105 -0
- package/src/log.ts +64 -13
- package/src/mcp/bridge.test.ts +150 -0
- package/src/mcp/bridge.ts +246 -0
- package/src/mcp/conformance.test.ts +336 -0
- package/src/mcp/dispatch.ts +313 -0
- package/src/mcp/index.ts +138 -0
- package/src/mcp/legacy.ts +314 -0
- package/src/mcp/mcp.test.ts +697 -0
- package/src/mcp/modern-confirm.test.ts +520 -0
- package/src/mcp/modern-confirm.ts +452 -0
- package/src/mcp/modern.ts +723 -0
- package/src/mcp/tasks.ts +82 -0
- package/src/mcp/testtree.ts +250 -0
- package/src/mcp/types.ts +504 -0
- package/src/netpolicy.test.ts +202 -0
- package/src/netpolicy.ts +231 -0
- package/src/output/dispatch.ts +10 -2
- package/src/output/error.ts +293 -0
- package/src/output/formatter.ts +29 -5
- package/src/output/formatters/csv.ts +48 -12
- package/src/output/formatters/json.ts +4 -25
- package/src/output/formatters/project.ts +34 -0
- package/src/output/formatters/table.ts +8 -6
- package/src/output/formatters/text.ts +7 -3
- package/src/output/formatters/yaml.ts +5 -22
- package/src/output/projection.test.ts +298 -0
- package/src/output/projection.ts +33 -59
- package/src/output/template.ts +11 -21
- package/src/output.surface.test.ts +41 -0
- package/src/output.ts +39 -3
- package/src/telemetry/client.test.ts +31 -0
- package/src/telemetry/client.ts +7 -1
- package/src/telemetry/offline.test.ts +64 -0
- package/src/tui/parity.test.ts +142 -0
- package/src/tui/parity.ts +59 -13
- package/test/output/csv.test.ts +164 -0
- package/test/output/error.test.ts +241 -0
|
@@ -0,0 +1,44 @@
|
|
|
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
|
+
type errcorrect_CorrectedError = CorrectedError;
|
|
38
|
+
declare const errcorrect_createCorrectedError: typeof createCorrectedError;
|
|
39
|
+
declare const errcorrect_formatError: typeof formatError;
|
|
40
|
+
declare namespace errcorrect {
|
|
41
|
+
export { type errcorrect_CorrectedError as CorrectedError, errcorrect_createCorrectedError as createCorrectedError, errcorrect_formatError as formatError };
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { type CorrectedError as C, createCorrectedError as c, errcorrect as e, formatError as f };
|
package/dist/errcorrect.d.ts
CHANGED
|
@@ -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';
|
package/dist/id/index.d.ts
CHANGED
|
@@ -1,83 +1,2 @@
|
|
|
1
|
-
import
|
|
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-DgOEOsPB.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 };
|