@hop-top/kit 0.5.0-alpha.1 → 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 (101) hide show
  1. package/CHANGELOG.md +87 -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 +190 -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 +1 -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 +21 -3
  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 +120 -31
  98. package/src/tui/parity.ts +58 -7
  99. package/test/output/csv.test.ts +164 -0
  100. package/test/output/error.test.ts +241 -0
  101. package/src/tui/parity.json +0 -74
package/dist/output.d.ts CHANGED
@@ -1,213 +1,2 @@
1
- /**
2
- * @module output/formatter
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 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';
2
+ import 'commander';