@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.
- package/CHANGELOG.md +107 -0
- package/README.md +333 -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-DLygZLi9.d.ts +450 -0
- package/dist/cli.d.ts +6 -309
- package/dist/cli.js +192 -63
- 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/error-DISJKeDu.d.ts +144 -0
- package/dist/id/index.d.ts +2 -83
- package/dist/index-Bc5c7Ty5.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 +28 -0
- package/dist/index.js +6794 -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-4aXs91GY.d.ts +396 -0
- package/dist/output.d.ts +3 -213
- package/dist/output.js +567 -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/serve-DE-jscpb.d.ts +646 -0
- package/dist/serve.d.ts +3 -0
- package/dist/serve.js +1019 -0
- 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 +5 -298
- package/dist/tui/index.js +3 -10
- 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 +26 -3
- 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 +37 -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 +316 -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 +41 -3
- package/src/serve.test.ts +1257 -0
- package/src/serve.ts +1665 -0
- 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 +120 -31
- package/src/tui/parity.ts +58 -7
- package/test/output/csv.test.ts +164 -0
- package/test/output/error.test.ts +246 -0
- package/src/tui/parity.json +0 -74
package/dist/output.d.ts
CHANGED
|
@@ -1,213 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
* Core Formatter interface + Options/OptionSpec/ColumnSpec types and
|
|
5
|
-
* parseOptions helper. Mirrors Go's go/console/output Formatter interface.
|
|
6
|
-
*/
|
|
7
|
-
/** Kinds of values an OptionSpec accepts. */
|
|
8
|
-
type OptionType = 'string' | 'int' | 'bool' | 'enum';
|
|
9
|
-
/** Describes one option accepted by a Formatter via --format-opt key=value. */
|
|
10
|
-
interface OptionSpec {
|
|
11
|
-
readonly name: string;
|
|
12
|
-
readonly type: OptionType;
|
|
13
|
-
readonly default?: string | number | boolean;
|
|
14
|
-
readonly usage: string;
|
|
15
|
-
readonly enum?: readonly string[];
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Validated map of option values produced by parseOptions. Keys are
|
|
19
|
-
* OptionSpec.name; values are coerced to the spec's declared type.
|
|
20
|
-
*/
|
|
21
|
-
type Options = Readonly<Record<string, string | number | boolean>>;
|
|
22
|
-
/**
|
|
23
|
-
* Column metadata used by table/csv/text formatters and --cols validation.
|
|
24
|
-
*
|
|
25
|
-
* - `header` is the user-visible label and the value matched against --cols.
|
|
26
|
-
* - `key` is the property name on the row object.
|
|
27
|
-
* - `priority` (optional) controls hide-on-overflow for table; higher wins.
|
|
28
|
-
*/
|
|
29
|
-
interface ColumnSpec {
|
|
30
|
-
readonly header: string;
|
|
31
|
-
readonly key: string;
|
|
32
|
-
readonly priority?: number;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* A Formatter encodes structured data to a writable stream.
|
|
36
|
-
*
|
|
37
|
-
* Implementations declare their key, file extensions, and the option keys
|
|
38
|
-
* they accept. The dispatch helper validates --format-opt input against
|
|
39
|
-
* options() before invoking render(), so render() may trust opts to only
|
|
40
|
-
* contain declared keys with values coerced to declared types.
|
|
41
|
-
*/
|
|
42
|
-
interface Formatter<T = unknown> {
|
|
43
|
-
/** Unique format identifier exposed via --format <key>. */
|
|
44
|
-
readonly key: string;
|
|
45
|
-
/**
|
|
46
|
-
* File extensions (with leading dot, e.g. ".csv") that map to this
|
|
47
|
-
* formatter for --output extension inference. May be empty.
|
|
48
|
-
*/
|
|
49
|
-
readonly extensions: readonly string[];
|
|
50
|
-
/** Option specs accepted by this formatter via --format-opt key=value. */
|
|
51
|
-
readonly options: readonly OptionSpec[];
|
|
52
|
-
/**
|
|
53
|
-
* Renders data to out.
|
|
54
|
-
*
|
|
55
|
-
* @param out Destination writable stream.
|
|
56
|
-
* @param data Single row or readonly array of rows.
|
|
57
|
-
* @param opts Validated options; only declared keys with coerced values.
|
|
58
|
-
* @param cols User-requested column projection; empty means "all columns".
|
|
59
|
-
*/
|
|
60
|
-
render(out: NodeJS.WritableStream, data: T | readonly T[], opts: Options, cols: readonly string[]): Promise<void> | void;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* Validates raw `key=value` pairs against specs and returns a coerced
|
|
64
|
-
* Options map. Unknown keys, type errors, and out-of-enum values throw an
|
|
65
|
-
* Error listing the offending key and the valid set.
|
|
66
|
-
*
|
|
67
|
-
* A pair without `=` (e.g. `"no-header"`) is treated as bool true; only
|
|
68
|
-
* valid when the matching spec has type `'bool'`.
|
|
69
|
-
*
|
|
70
|
-
* Defaults from specs fill in any keys not present in pairs.
|
|
71
|
-
*/
|
|
72
|
-
declare function parseOptions(pairs: readonly string[], specs: readonly OptionSpec[]): Options;
|
|
73
|
-
/** Pretty-print an OptionType. */
|
|
74
|
-
declare function optionTypeName(t: OptionType): string;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* @module output/registry
|
|
78
|
-
*
|
|
79
|
-
* Registry holds Formatter implementations keyed by Formatter.key. Mirrors
|
|
80
|
-
* Go's *Registry. Built-in formatters register against `defaultRegistry` at
|
|
81
|
-
* module-load time.
|
|
82
|
-
*/
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Registry holds Formatter implementations.
|
|
86
|
-
*
|
|
87
|
-
* - `register` throws on duplicate keys (init-time fail-loud).
|
|
88
|
-
* - `override` quietly replaces — use when intentionally swapping a built-in.
|
|
89
|
-
* - `lookup` returns the formatter for a key, or undefined.
|
|
90
|
-
* - `keys` returns sorted format identifiers.
|
|
91
|
-
* - `formatters` returns sorted formatters.
|
|
92
|
-
* - `extensionMap` returns ext→key (e.g. ".csv" → "csv"); later
|
|
93
|
-
* registrations win on collision (alphabetical key order is the tie-break).
|
|
94
|
-
*/
|
|
95
|
-
declare class Registry {
|
|
96
|
-
private readonly byKey;
|
|
97
|
-
/**
|
|
98
|
-
* Adds f to the registry. Throws Error on duplicate key or empty key.
|
|
99
|
-
* Use `override` to intentionally replace.
|
|
100
|
-
*/
|
|
101
|
-
register<T>(f: Formatter<T>): void;
|
|
102
|
-
/** Replaces (or registers) the formatter for f.key. */
|
|
103
|
-
override<T>(f: Formatter<T>): void;
|
|
104
|
-
/** Returns the formatter registered under key, if any. */
|
|
105
|
-
lookup(key: string): Formatter | undefined;
|
|
106
|
-
/** Returns all registered format keys, sorted alphabetically. */
|
|
107
|
-
keys(): readonly string[];
|
|
108
|
-
/** Returns all registered formatters in key order. */
|
|
109
|
-
formatters(): readonly Formatter[];
|
|
110
|
-
/**
|
|
111
|
-
* Returns extension→key mappings (e.g. ".csv" → "csv") across all
|
|
112
|
-
* registered formatters. Later registrations win on collision; iteration
|
|
113
|
-
* is in sorted-key order so resolution is deterministic.
|
|
114
|
-
*/
|
|
115
|
-
extensionMap(): ReadonlyMap<string, string>;
|
|
116
|
-
}
|
|
117
|
-
/** Module-level Registry. Built-ins register here at module-load time. */
|
|
118
|
-
declare const defaultRegistry: Registry;
|
|
119
|
-
/** Returns a new, empty Registry — no built-ins registered. */
|
|
120
|
-
declare function newRegistry(): Registry;
|
|
121
|
-
|
|
122
|
-
/**
|
|
123
|
-
* @module output/formatters/json
|
|
124
|
-
*
|
|
125
|
-
* Built-in JSON formatter. Honors `indent` option (default 2) + trailing
|
|
126
|
-
* newline. When `cols` is non-empty, projects rows to header-keyed objects.
|
|
127
|
-
*/
|
|
128
|
-
|
|
129
|
-
/**
|
|
130
|
-
* Build the JSON formatter. The `columns` ref is optional; when provided
|
|
131
|
-
* (via dispatch with a ColumnSpec list), rows are projected before encode.
|
|
132
|
-
*/
|
|
133
|
-
declare const jsonFormatter: Formatter;
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* @module output/formatters/yaml
|
|
137
|
-
*
|
|
138
|
-
* Built-in YAML formatter. Honors `flow-level` option (default -1, mapping
|
|
139
|
-
* to js-yaml's default block style). When `cols` is non-empty, projects
|
|
140
|
-
* rows to header-keyed objects.
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
declare const yamlFormatter: Formatter;
|
|
144
|
-
|
|
145
|
-
/**
|
|
146
|
-
* @module output/formatters/table
|
|
147
|
-
*
|
|
148
|
-
* Built-in table formatter. Hand-rolled aligner (matches the original
|
|
149
|
-
* output.ts behaviour). Honors `cols` to filter columns; preserves first-
|
|
150
|
-
* row key order otherwise.
|
|
151
|
-
*/
|
|
152
|
-
|
|
153
|
-
declare const tableFormatter: Formatter;
|
|
154
|
-
|
|
155
|
-
/**
|
|
156
|
-
* @module output
|
|
157
|
-
* @package @hop-top/kit
|
|
158
|
-
*
|
|
159
|
-
* Output rendering — writes structured values to a writable stream in one of
|
|
160
|
-
* the registered formats: table, JSON, YAML, CSV, text, etc.
|
|
161
|
-
*
|
|
162
|
-
* ## Quick start
|
|
163
|
-
*
|
|
164
|
-
* ```ts
|
|
165
|
-
* import { render, TABLE_FORMAT, JSON_FORMAT, YAML_FORMAT } from '@hop-top/kit/output';
|
|
166
|
-
*
|
|
167
|
-
* // Write a table to stdout
|
|
168
|
-
* render(process.stdout, TABLE_FORMAT, [{ id: '1', name: 'Alice' }]);
|
|
169
|
-
*
|
|
170
|
-
* // Write indented JSON
|
|
171
|
-
* render(process.stdout, JSON_FORMAT, { ok: true });
|
|
172
|
-
*
|
|
173
|
-
* // Write YAML
|
|
174
|
-
* render(process.stdout, YAML_FORMAT, { version: 1 });
|
|
175
|
-
* ```
|
|
176
|
-
*
|
|
177
|
-
* ## Programmatic Formatter API
|
|
178
|
-
*
|
|
179
|
-
* For typed flag wiring + custom formatters use the Formatter / Registry
|
|
180
|
-
* surface from `output/formatter` and `output/registry`. The `render()`
|
|
181
|
-
* helper exported here is a thin shim over `defaultRegistry`.
|
|
182
|
-
*
|
|
183
|
-
* ## Backward compatibility
|
|
184
|
-
*
|
|
185
|
-
* `render(w, format, v)` keeps its original signature. New per-format
|
|
186
|
-
* options + column projection are accessed via `dispatch()`.
|
|
187
|
-
*/
|
|
188
|
-
|
|
189
|
-
/**
|
|
190
|
-
* Supported output formats. Includes the original three for backward-compat
|
|
191
|
-
* + new built-ins (csv, text) registered on the default registry.
|
|
192
|
-
*/
|
|
193
|
-
type Format = string;
|
|
194
|
-
/** Constant for the JSON output format. */
|
|
195
|
-
declare const JSON_FORMAT: "json";
|
|
196
|
-
/** Constant for the YAML output format. */
|
|
197
|
-
declare const YAML_FORMAT: "yaml";
|
|
198
|
-
/** Constant for the table output format. */
|
|
199
|
-
declare const TABLE_FORMAT: "table";
|
|
200
|
-
/** Constant for the CSV output format. */
|
|
201
|
-
declare const CSV_FORMAT: "csv";
|
|
202
|
-
/** Constant for the text output format. */
|
|
203
|
-
declare const TEXT_FORMAT: "text";
|
|
204
|
-
/**
|
|
205
|
-
* Renders `v` to `w` in the requested `format`.
|
|
206
|
-
*
|
|
207
|
-
* Backward-compatible thin shim over `defaultRegistry.lookup(format).render`.
|
|
208
|
-
*
|
|
209
|
-
* @throws {Error} For unknown format strings.
|
|
210
|
-
*/
|
|
211
|
-
declare function render(w: NodeJS.WritableStream, format: Format, v: unknown): void;
|
|
212
|
-
|
|
213
|
-
export { CSV_FORMAT, type ColumnSpec, type Format, type Formatter, JSON_FORMAT, type OptionSpec, type OptionType, type Options, Registry, TABLE_FORMAT, TEXT_FORMAT, YAML_FORMAT, defaultRegistry, jsonFormatter, newRegistry, optionTypeName, parseOptions, render, tableFormatter, yamlFormatter };
|
|
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';
|
|
3
|
+
import 'commander';
|