@hop-top/kit 0.5.0-alpha.5 → 0.5.0-alpha.7

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 (70) hide show
  1. package/CHANGELOG.md +43 -0
  2. package/LICENSE-cobra.txt +174 -0
  3. package/NOTICE +15 -0
  4. package/README.md +10 -10
  5. package/dist/{alias-BOj0-VAr.d.ts → alias-BsJ2jGqQ.d.ts} +9 -1
  6. package/dist/alias.d.ts +1 -1
  7. package/dist/alias.js +4 -2
  8. package/dist/chunk-263IZ6Z6.js +915 -0
  9. package/dist/{chunk-S45UHXQF.js → chunk-DIDN4X5C.js} +8 -6
  10. package/dist/{chunk-ZC5TZYZJ.js → chunk-GHPJJV5L.js} +7 -3
  11. package/dist/chunk-JKMQSAJP.js +174 -0
  12. package/dist/chunk-JZ22ZUFA.js +1131 -0
  13. package/dist/chunk-NLMS7HGP.js +178 -0
  14. package/dist/chunk-QQQYCWSC.js +240 -0
  15. package/dist/chunk-XJTRY453.js +868 -0
  16. package/dist/{cli-8rfITnv4.d.ts → cli-C5B5tnpA.d.ts} +1 -60
  17. package/dist/cli.d.ts +2 -1
  18. package/dist/cli.js +5 -3
  19. package/dist/completion-sDKVXPUL.d.ts +109 -0
  20. package/dist/completion-values-By-mnjNt.d.ts +142 -0
  21. package/dist/completion-values.d.ts +1 -0
  22. package/dist/completion-values.js +29 -0
  23. package/dist/completion.d.ts +3 -0
  24. package/dist/completion.js +34 -0
  25. package/dist/compliance-AxFf-uMy.d.ts +60 -0
  26. package/dist/compliance.d.ts +1 -0
  27. package/dist/compliance.js +17 -0
  28. package/dist/config-CaK60ByQ.d.ts +241 -0
  29. package/dist/config.d.ts +1 -1
  30. package/dist/config.js +4 -2
  31. package/dist/{index-DEyjGoo2.d.ts → index-DCe1boBz.d.ts} +1 -1
  32. package/dist/index.d.ts +10 -4
  33. package/dist/index.js +40 -20
  34. package/dist/log-CkaxMX3U.d.ts +115 -0
  35. package/dist/log.d.ts +2 -0
  36. package/dist/log.js +14 -0
  37. package/dist/parity-CvMuYcVI.d.ts +61 -0
  38. package/dist/toolspec-UrWnoJ3Y.d.ts +336 -0
  39. package/dist/toolspec.d.ts +2 -0
  40. package/dist/toolspec.js +36 -0
  41. package/dist/tui/index.d.ts +3 -2
  42. package/package.json +43 -3
  43. package/src/alias.test.ts +110 -1
  44. package/src/alias.ts +19 -4
  45. package/src/cli.ts +5 -0
  46. package/src/completion-scripts.ts +16 -0
  47. package/src/completion-values.test.ts +70 -10
  48. package/src/completion-values.ts +170 -66
  49. package/src/completion.conformance.test.ts +297 -0
  50. package/src/completion.test.ts +256 -145
  51. package/src/completion.ts +764 -121
  52. package/src/config-merge.test.ts +425 -0
  53. package/src/config.test.ts +41 -0
  54. package/src/config.ts +265 -18
  55. package/src/index.test.ts +2 -1
  56. package/src/index.ts +8 -1
  57. package/src/log.test.ts +270 -1
  58. package/src/log.ts +172 -44
  59. package/src/published-types.test.ts +18 -0
  60. package/src/toolspec-internal.ts +197 -0
  61. package/src/toolspec-manifest.test.ts +82 -0
  62. package/src/toolspec-manifest.ts +404 -0
  63. package/src/toolspec-spec-schemas.ts +12 -0
  64. package/src/toolspec-spec.test.ts +273 -0
  65. package/src/toolspec-spec.ts +458 -0
  66. package/src/toolspec.from-command.test.ts +216 -0
  67. package/src/toolspec.ts +159 -0
  68. package/test/toolspec/fixture.ts +73 -0
  69. package/dist/chunk-IQXEISMC.js +0 -142
  70. package/dist/config-Bm9fBXch.d.ts +0 -134
@@ -0,0 +1,241 @@
1
+ /**
2
+ * @packageDocumentation
3
+ *
4
+ * Layered configuration loader (YAML by default) — TypeScript port of
5
+ * hop.top/kit/config.
6
+ *
7
+ * Merges configuration from up to three file layers in priority order:
8
+ * system → user → project → envOverride
9
+ *
10
+ * Each layer merges into `dst` with these rules:
11
+ *
12
+ * - Plain objects merge recursively, key by key, so a later layer only
13
+ * overrides the keys it sets (`db: {port: 2}` keeps an earlier `db.host`).
14
+ * - Arrays and scalars are replaced wholesale.
15
+ * - `null` clears an object or array; it leaves a scalar untouched.
16
+ * - On a type conflict (object vs non-object) the later value replaces the
17
+ * earlier one.
18
+ * - Non-plain objects (`Date`, `Map`, class instances) are never merged
19
+ * into; a later value replaces them.
20
+ *
21
+ * {@link mergeLayers} applies the same rules to objects you already parsed,
22
+ * and {@link MergeOptions} (also accepted by {@link load} as `merge`) can
23
+ * relax them: `null` keeps the lower value, objects merge only to a set depth,
24
+ * arrays concatenate or union, globally or per dotted key path. A file in
25
+ * another format goes through {@link Options.parse}.
26
+ *
27
+ * The defaults match Go's `kit/core/config` for struct fields. Go differs where its
28
+ * target type differs: a `map[...]` value or an `any` field is replaced
29
+ * whole rather than merged, and a type conflict on a typed field is a decode
30
+ * error rather than a replacement.
31
+ *
32
+ * Missing files are silently skipped. A file that exists but contains invalid
33
+ * YAML causes {@link load} to throw. A document whose root is not a mapping
34
+ * is ignored.
35
+ *
36
+ * Each file is checked before it merges, with aliases expanded, and
37
+ * {@link load} throws `config: failed to parse <path>: <reason>` when:
38
+ *
39
+ * - its aliases expand past Go yaml.v3's budget: more than 100 nodes inside
40
+ * alias expansions and more than 1000 in total, with the share inside
41
+ * aliases above 0.99 (up to 400k nodes), falling linearly to 0.10 at 4M
42
+ * (`document contains excessive aliasing`). Go counts only the keys its
43
+ * target struct reads; TS has no target, so it counts every key, and a
44
+ * file Go accepts because the aliases sit under ignored keys fails here.
45
+ * - collections nest deeper than 100, counted through aliases
46
+ * (`nesting exceeded maxDepth (100)`). Go allows 10000 levels of text
47
+ * nesting and caps alias chains only through the budget above.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * import { load } from "@hop-top/kit/config";
52
+ *
53
+ * interface AppConfig {
54
+ * host: string;
55
+ * port: number;
56
+ * debug: boolean;
57
+ * token: string;
58
+ * }
59
+ *
60
+ * const cfg: AppConfig = { host: "localhost", port: 3000, debug: false, token: "" };
61
+ *
62
+ * load(cfg, {
63
+ * systemConfigPath: "/etc/mytool/config.yaml",
64
+ * userConfigPath: `${process.env.HOME}/.config/mytool/config.yaml`,
65
+ * projectConfigPath: ".mytool.yaml",
66
+ * envOverride(c) {
67
+ * if (process.env.HOST) c.host = process.env.HOST;
68
+ * if (process.env.PORT) c.port = Number(process.env.PORT);
69
+ * if (process.env.TOKEN) c.token = process.env.TOKEN;
70
+ * },
71
+ * });
72
+ * ```
73
+ */
74
+ /**
75
+ * Configuration sources for {@link load}.
76
+ *
77
+ * All path fields are optional; an empty or omitted path is silently skipped.
78
+ * {@link Options.envOverride} is called last, after all file layers, so it can
79
+ * apply environment-variable overrides on top of file values.
80
+ */
81
+ interface Options<T extends object = object> {
82
+ /**
83
+ * Path to the system-wide config file, e.g. `/etc/mytool/config.yaml`.
84
+ * Applied first (lowest priority).
85
+ */
86
+ systemConfigPath?: string;
87
+ /**
88
+ * Path to the per-user config file, e.g. `~/.config/mytool/config.yaml`.
89
+ * Applied second; merges over system values (see the module merge rules).
90
+ */
91
+ userConfigPath?: string;
92
+ /**
93
+ * Path to the project-level config file, e.g. `.mytool.yaml`.
94
+ * Applied third; merges over system and user values.
95
+ */
96
+ projectConfigPath?: string;
97
+ /**
98
+ * Optional callback invoked after all file layers have been merged.
99
+ * Receives the fully-merged `dst` object so the caller can apply
100
+ * environment-variable overrides last (highest priority).
101
+ *
102
+ * @param cfg - The merged config object (same reference as `dst`).
103
+ */
104
+ envOverride?: (cfg: T) => void;
105
+ /**
106
+ * Parser for file contents; YAML when omitted. A function parses every
107
+ * file. A record maps a lowercased extension with its dot (`".json"`;
108
+ * `""` for an extensionless file such as `.toolrc`) to a parser, and files
109
+ * whose extension has no entry parse as YAML. The parser gets the text and
110
+ * the path (so a `.js` parser can `require` the path instead); a throw
111
+ * fails the load like a YAML error, and a result that is not a plain
112
+ * object is ignored. Without a parser a `.js` file parses as YAML text
113
+ * and is never executed.
114
+ */
115
+ parse?: ConfigParser | Record<string, ConfigParser>;
116
+ /**
117
+ * Merge policies for the file layers, `dst` being the lowest layer. They
118
+ * do not touch {@link envOverride}, which assigns whatever it sets.
119
+ * Defaults are the module merge rules.
120
+ */
121
+ merge?: MergeOptions;
122
+ }
123
+ /** Parses one config file's text; see {@link Options.parse}. */
124
+ type ConfigParser = (text: string, filePath: string) => unknown;
125
+ /** What a `null` in a higher layer does; see {@link MergeOptions.nullPolicy}. */
126
+ type NullPolicy = "clear" | "keep-lower";
127
+ /** How two arrays at one key combine; see {@link MergeOptions.arrayPolicy}. */
128
+ type ArrayPolicy = "replace" | "concat" | "union";
129
+ /**
130
+ * Custom array merge for one path: gets the lower array (already in the
131
+ * result), a copy of the higher array and the dotted path; returns the value
132
+ * to store.
133
+ */
134
+ type ArrayMergeFn = (lower: unknown[], higher: unknown[], path: string) => unknown;
135
+ /**
136
+ * Merge policies for {@link mergeLayers} and {@link Options.merge}. All
137
+ * policies act only where a higher layer's key meets a key already in the
138
+ * result; a value with nothing under it (a new key, a type conflict, an
139
+ * object past `maxDepth`) is copied whole, as is.
140
+ */
141
+ interface MergeOptions {
142
+ /**
143
+ * `"clear"` (default): `null` clears an object or array, sets a key that
144
+ * is absent or already `null`, and leaves a scalar untouched.
145
+ * `"keep-lower"`: `null` is skipped, so the lower value stays and an
146
+ * absent key stays absent.
147
+ */
148
+ nullPolicy?: NullPolicy;
149
+ /**
150
+ * How many object levels below the root merge key by key; deeper objects
151
+ * replace whole. `Infinity` (default) merges at every depth, `1` merges the
152
+ * root and the objects directly under it (`{db: {opts: {...}}}` merges
153
+ * `db` but replaces `db.opts`), `0` assigns root keys only, like
154
+ * `Object.assign`. Must be a non-negative integer or `Infinity`.
155
+ */
156
+ maxDepth?: number;
157
+ /**
158
+ * How two arrays at one key combine. `"replace"` (default): the higher
159
+ * array wins. `"concat"`: lower items, then higher items. `"union"`: lower
160
+ * then higher items, keeping the first of equal items, where plain objects
161
+ * and arrays compare structurally (object key order ignored) and other
162
+ * values by SameValueZero. A policy acts only when both sides are arrays;
163
+ * otherwise the higher value replaces.
164
+ */
165
+ arrayPolicy?: ArrayPolicy;
166
+ /**
167
+ * Per-path override of {@link arrayPolicy}: dotted key path from the root
168
+ * (`"scope.hints"`, split on every `.` like the Go SDK's dotted keys, so a
169
+ * key containing a dot cannot be named) to a policy or an
170
+ * {@link ArrayMergeFn}, which gets the concrete path. A segment that is
171
+ * exactly `*` matches any one key (`"scopes.*.hints"`, never zero or
172
+ * several; `a*` is literal, `**` throws). When several entries match, the
173
+ * exact path wins, then the pattern with the fewest `*`, then the
174
+ * lexically smallest pattern (UTF-16 order, so `*.b.c` beats `a.*.c`).
175
+ */
176
+ arrayPolicyByPath?: Record<string, ArrayPolicy | ArrayMergeFn>;
177
+ }
178
+ /**
179
+ * Merges already-parsed layers, lowest priority first, into a new object and
180
+ * returns it. Layers that are not plain objects (`null`, arrays, scalars)
181
+ * are skipped; the layers are never mutated or shared with the result.
182
+ * Defaults follow the module merge rules; {@link MergeOptions} relaxes them.
183
+ *
184
+ * @throws {Error} `config: layer <i>: <reason>` when a layer nests deeper
185
+ * than 100 levels or contains a cycle, and on an invalid option.
186
+ *
187
+ * @example
188
+ * ```ts
189
+ * const cfg = mergeLayers([globalRc, projectRc], {
190
+ * nullPolicy: "keep-lower",
191
+ * maxDepth: 1,
192
+ * arrayPolicyByPath: { hints: "union" },
193
+ * });
194
+ * ```
195
+ */
196
+ declare function mergeLayers<T extends object = Record<string, unknown>>(layers: readonly unknown[], opts?: MergeOptions): T;
197
+ /**
198
+ * Merges layered YAML configuration into `dst` and returns it.
199
+ *
200
+ * Merge order: `systemConfigPath` → `userConfigPath` → `projectConfigPath` →
201
+ * `envOverride`.
202
+ *
203
+ * - Objects merge recursively; arrays and scalars replace; `null` clears
204
+ * objects and arrays but not scalars (see the module docs for details),
205
+ * unless {@link Options.merge} says otherwise.
206
+ * - Files parse as YAML unless {@link Options.parse} supplies a parser.
207
+ * - Missing files (ENOENT) are silently skipped.
208
+ * - A file that exists but is not valid YAML causes this function to throw
209
+ * a descriptive error wrapping the parse failure.
210
+ * - `envOverride`, when provided, is called last with the merged `dst`.
211
+ * - Returns `dst` (the same object reference passed in).
212
+ *
213
+ * @param dst - Destination object to merge config into. Must be a non-null
214
+ * object; mutated in place.
215
+ * @param opts - Config sources. All fields are optional.
216
+ * @returns The mutated `dst` object.
217
+ * @throws {Error} When a file exists but cannot be parsed, or on an
218
+ * invalid {@link Options.merge}.
219
+ *
220
+ * @example
221
+ * ```ts
222
+ * const cfg = { host: "localhost", port: 8080 };
223
+ * load(cfg, { projectConfigPath: ".tool.yaml" });
224
+ * console.log(cfg.host); // value from .tool.yaml, or "localhost" if file missing
225
+ * ```
226
+ */
227
+ declare function load<T extends object>(dst: T, opts?: Options<T>): T;
228
+
229
+ type config_ArrayMergeFn = ArrayMergeFn;
230
+ type config_ArrayPolicy = ArrayPolicy;
231
+ type config_ConfigParser = ConfigParser;
232
+ type config_MergeOptions = MergeOptions;
233
+ type config_NullPolicy = NullPolicy;
234
+ type config_Options<T extends object = object> = Options<T>;
235
+ declare const config_load: typeof load;
236
+ declare const config_mergeLayers: typeof mergeLayers;
237
+ declare namespace config {
238
+ export { type config_ArrayMergeFn as ArrayMergeFn, type config_ArrayPolicy as ArrayPolicy, type config_ConfigParser as ConfigParser, type config_MergeOptions as MergeOptions, type config_NullPolicy as NullPolicy, type config_Options as Options, config_load as load, config_mergeLayers as mergeLayers };
239
+ }
240
+
241
+ export { type ArrayMergeFn as A, type ConfigParser as C, type MergeOptions as M, type NullPolicy as N, type Options as O, type ArrayPolicy as a, config as c, load as l, mergeLayers as m };
package/dist/config.d.ts CHANGED
@@ -1 +1 @@
1
- export { O as Options, l as load } from './config-Bm9fBXch.js';
1
+ export { A as ArrayMergeFn, a as ArrayPolicy, C as ConfigParser, M as MergeOptions, N as NullPolicy, O as Options, l as load, m as mergeLayers } from './config-CaK60ByQ.js';
package/dist/config.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkIQXEISMCjs = require('./chunk-IQXEISMC.js');
3
+
4
+ var _chunkQQQYCWSCjs = require('./chunk-QQQYCWSC.js');
4
5
  require('./chunk-R5U7XKVJ.js');
5
6
 
6
7
 
7
- exports.load = _chunkIQXEISMCjs.load;
8
+
9
+ exports.load = _chunkQQQYCWSCjs.load; exports.mergeLayers = _chunkQQQYCWSCjs.mergeLayers;
@@ -1,4 +1,4 @@
1
- import { T as Theme } from './cli-8rfITnv4.js';
1
+ import { T as Theme } from './cli-C5B5tnpA.js';
2
2
 
3
3
  /**
4
4
  * @module tui/badge
package/dist/index.d.ts CHANGED
@@ -1,13 +1,17 @@
1
1
  export { a as aim } from './aim-DZHwwiIc.js';
2
- export { a as alias } from './alias-BOj0-VAr.js';
2
+ export { a as alias } from './alias-BsJ2jGqQ.js';
3
3
  export { l as anthropic } from './llm-anthropic-Cd_I2xXB.js';
4
4
  export { a as api } from './api-DAexsu2H.js';
5
5
  export { a as auth } from './auth-2-jfgiHn.js';
6
- export { c as cli } from './cli-8rfITnv4.js';
7
- export { c as config } from './config-Bm9fBXch.js';
6
+ export { c as cli } from './cli-C5B5tnpA.js';
7
+ export { c as completion } from './completion-sDKVXPUL.js';
8
+ export { c as completionValues } from './completion-values-By-mnjNt.js';
9
+ export { c as compliance } from './compliance-AxFf-uMy.js';
10
+ export { c as config } from './config-CaK60ByQ.js';
8
11
  export { e as errcorrect } from './errcorrect-BcX1Ft0K.js';
9
12
  export { i as id } from './index-VLDcI5NF.js';
10
13
  export { l as llm } from './llm-DYuR7_uX.js';
14
+ export { l as log } from './log-CkaxMX3U.js';
11
15
  export { i as mcp } from './index-B-pqGHhU.js';
12
16
  export { n as netpolicy } from './netpolicy-Brx5XZUB.js';
13
17
  export { l as openai } from './llm-openai-DyFrucmV.js';
@@ -21,10 +25,12 @@ export { s as scope } from './scope-BrhYB4ij.js';
21
25
  export { s as serve } from './serve-D8yWMrTc.js';
22
26
  export { s as stream } from './stream-CrjeCp0M.js';
23
27
  export { i as telemetry } from './index-C3Zw4wDJ.js';
24
- export { i as tui } from './index-DEyjGoo2.js';
28
+ export { t as toolspec } from './toolspec-UrWnoJ3Y.js';
29
+ export { i as tui } from './index-DCe1boBz.js';
25
30
  export { u as upgrade } from './upgrade-p_zh3pvV.js';
26
31
  export { x as xdg } from './xdg-DB7Shoib.js';
27
32
  import 'commander';
33
+ import './parity-CvMuYcVI.js';
28
34
  import 'node:stream';
29
35
  import 'zod';
30
36
  import '@modelcontextprotocol/server';
package/dist/index.js CHANGED
@@ -1,5 +1,17 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
+ var _chunkGGWJRWWAjs = require('./chunk-GGWJRWWA.js');
4
+
5
+
6
+ var _chunkBRNEKPWXjs = require('./chunk-BRNEKPWX.js');
7
+
8
+
9
+ var _chunk263IZ6Z6js = require('./chunk-263IZ6Z6.js');
10
+
11
+
12
+ var _chunkWWUKGJB5js = require('./chunk-WWUKGJB5.js');
13
+
14
+
3
15
  var _chunkL23O2FFEjs = require('./chunk-L23O2FFE.js');
4
16
 
5
17
 
@@ -9,40 +21,37 @@ var _chunkJTMPNXVQjs = require('./chunk-JTMPNXVQ.js');
9
21
  var _chunkYOBAUCVNjs = require('./chunk-YOBAUCVN.js');
10
22
 
11
23
 
12
- var _chunkGGWJRWWAjs = require('./chunk-GGWJRWWA.js');
13
-
14
-
15
- var _chunkWUOAQVOAjs = require('./chunk-WUOAQVOA.js');
24
+ var _chunkIXVQ62NZjs = require('./chunk-IXVQ62NZ.js');
16
25
 
17
26
 
18
- var _chunk6HFAEZ52js = require('./chunk-6HFAEZ52.js');
27
+ var _chunkBDNNPRX6js = require('./chunk-BDNNPRX6.js');
19
28
 
20
29
 
21
- var _chunkWBVO43HUjs = require('./chunk-WBVO43HU.js');
30
+ var _chunk6SVOHNICjs = require('./chunk-6SVOHNIC.js');
22
31
 
23
32
 
24
- var _chunkMQXYDYRDjs = require('./chunk-MQXYDYRD.js');
33
+ var _chunkMUIQVU6Ejs = require('./chunk-MUIQVU6E.js');
25
34
 
26
35
 
27
- var _chunkBRNEKPWXjs = require('./chunk-BRNEKPWX.js');
36
+ var _chunkWUOAQVOAjs = require('./chunk-WUOAQVOA.js');
28
37
 
29
38
 
30
- var _chunkWWUKGJB5js = require('./chunk-WWUKGJB5.js');
39
+ var _chunk6HFAEZ52js = require('./chunk-6HFAEZ52.js');
31
40
 
32
41
 
33
- var _chunkT46YPHKNjs = require('./chunk-T46YPHKN.js');
42
+ var _chunkWBVO43HUjs = require('./chunk-WBVO43HU.js');
34
43
 
35
44
 
36
- var _chunkIXVQ62NZjs = require('./chunk-IXVQ62NZ.js');
45
+ var _chunkMQXYDYRDjs = require('./chunk-MQXYDYRD.js');
37
46
 
38
47
 
39
- var _chunkBDNNPRX6js = require('./chunk-BDNNPRX6.js');
48
+ var _chunkQQQYCWSCjs = require('./chunk-QQQYCWSC.js');
40
49
 
41
50
 
42
- var _chunk6SVOHNICjs = require('./chunk-6SVOHNIC.js');
51
+ var _chunk3FIKGFKIjs = require('./chunk-3FIKGFKI.js');
43
52
 
44
53
 
45
- var _chunkMUIQVU6Ejs = require('./chunk-MUIQVU6E.js');
54
+ var _chunkT46YPHKNjs = require('./chunk-T46YPHKN.js');
46
55
 
47
56
 
48
57
  var _chunkABQSE7AIjs = require('./chunk-ABQSE7AI.js');
@@ -52,13 +61,16 @@ require('./chunk-YGYQUFGY.js');
52
61
  var _chunkPSFYJGDGjs = require('./chunk-PSFYJGDG.js');
53
62
 
54
63
 
64
+ var _chunkNLMS7HGPjs = require('./chunk-NLMS7HGP.js');
65
+
66
+
55
67
  var _chunkQJVSKKRQjs = require('./chunk-QJVSKKRQ.js');
56
68
 
57
69
 
58
70
  var _chunk4UE5TCMQjs = require('./chunk-4UE5TCMQ.js');
59
71
 
60
72
 
61
- var _chunkS45UHXQFjs = require('./chunk-S45UHXQF.js');
73
+ var _chunkDIDN4X5Cjs = require('./chunk-DIDN4X5C.js');
62
74
 
63
75
 
64
76
  var _chunkCSJWB6D3js = require('./chunk-CSJWB6D3.js');
@@ -67,19 +79,22 @@ var _chunkCSJWB6D3js = require('./chunk-CSJWB6D3.js');
67
79
  var _chunkUKZIAQA7js = require('./chunk-UKZIAQA7.js');
68
80
 
69
81
 
70
- var _chunkZC5TZYZJjs = require('./chunk-ZC5TZYZJ.js');
71
- require('./chunk-QPUCXQXT.js');
82
+ var _chunkGHPJJV5Ljs = require('./chunk-GHPJJV5L.js');
72
83
  require('./chunk-72XZWQX7.js');
73
84
  require('./chunk-POR5L2DG.js');
85
+ require('./chunk-QPUCXQXT.js');
74
86
 
75
87
 
76
88
  var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
77
89
 
78
90
 
79
- var _chunkIQXEISMCjs = require('./chunk-IQXEISMC.js');
91
+ var _chunkJZ22ZUFAjs = require('./chunk-JZ22ZUFA.js');
80
92
 
81
93
 
82
- var _chunk3FIKGFKIjs = require('./chunk-3FIKGFKI.js');
94
+ var _chunkJKMQSAJPjs = require('./chunk-JKMQSAJP.js');
95
+
96
+
97
+ var _chunkXJTRY453js = require('./chunk-XJTRY453.js');
83
98
  require('./chunk-R5U7XKVJ.js');
84
99
 
85
100
 
@@ -108,4 +123,9 @@ require('./chunk-R5U7XKVJ.js');
108
123
 
109
124
 
110
125
 
111
- exports.aim = _chunkQJVSKKRQjs.aim_exports; exports.alias = _chunkS45UHXQFjs.alias_exports; exports.anthropic = _chunkT46YPHKNjs.llm_anthropic_exports; exports.api = _chunkCSJWB6D3js.api_exports; exports.auth = _chunkUKZIAQA7js.auth_exports; exports.cli = _chunkZC5TZYZJjs.cli_exports; exports.config = _chunkIQXEISMCjs.config_exports; exports.errcorrect = _chunk3FIKGFKIjs.errcorrect_exports; exports.id = _chunkL23O2FFEjs.id_exports; exports.llm = _chunkPSFYJGDGjs.llm_exports; exports.mcp = _chunkJTMPNXVQjs.mcp_exports; exports.netpolicy = _chunkKVG7YCTSjs.netpolicy_exports; exports.openai = _chunkABQSE7AIjs.llm_openai_exports; exports.output = _chunkIXVQ62NZjs.output_exports; exports.progress = _chunkBDNNPRX6js.progress_exports; exports.provenance = _chunk6SVOHNICjs.provenance_exports; exports.routellm = _chunkMUIQVU6Ejs.routellm_exports; exports.rpc = _chunkWUOAQVOAjs.rpc_exports; exports.safety = _chunk6HFAEZ52js.safety_exports; exports.scope = _chunkWBVO43HUjs.scope_exports; exports.serve = _chunkMQXYDYRDjs.serve_exports; exports.stream = _chunkBRNEKPWXjs.stream_exports; exports.telemetry = _chunkYOBAUCVNjs.telemetry_exports; exports.tui = _chunkGGWJRWWAjs.tui_exports; exports.upgrade = _chunkWWUKGJB5js.upgrade_exports; exports.xdg = _chunk4UE5TCMQjs.xdg_exports;
126
+
127
+
128
+
129
+
130
+
131
+ exports.aim = _chunkQJVSKKRQjs.aim_exports; exports.alias = _chunkDIDN4X5Cjs.alias_exports; exports.anthropic = _chunkT46YPHKNjs.llm_anthropic_exports; exports.api = _chunkCSJWB6D3js.api_exports; exports.auth = _chunkUKZIAQA7js.auth_exports; exports.cli = _chunkGHPJJV5Ljs.cli_exports; exports.completion = _chunkJZ22ZUFAjs.completion_exports; exports.completionValues = _chunkJKMQSAJPjs.completion_values_exports; exports.compliance = _chunkXJTRY453js.compliance_exports; exports.config = _chunkQQQYCWSCjs.config_exports; exports.errcorrect = _chunk3FIKGFKIjs.errcorrect_exports; exports.id = _chunkL23O2FFEjs.id_exports; exports.llm = _chunkPSFYJGDGjs.llm_exports; exports.log = _chunkNLMS7HGPjs.log_exports; exports.mcp = _chunkJTMPNXVQjs.mcp_exports; exports.netpolicy = _chunkKVG7YCTSjs.netpolicy_exports; exports.openai = _chunkABQSE7AIjs.llm_openai_exports; exports.output = _chunkIXVQ62NZjs.output_exports; exports.progress = _chunkBDNNPRX6js.progress_exports; exports.provenance = _chunk6SVOHNICjs.provenance_exports; exports.routellm = _chunkMUIQVU6Ejs.routellm_exports; exports.rpc = _chunkWUOAQVOAjs.rpc_exports; exports.safety = _chunk6HFAEZ52js.safety_exports; exports.scope = _chunkWBVO43HUjs.scope_exports; exports.serve = _chunkMQXYDYRDjs.serve_exports; exports.stream = _chunkBRNEKPWXjs.stream_exports; exports.telemetry = _chunkYOBAUCVNjs.telemetry_exports; exports.toolspec = _chunk263IZ6Z6js.toolspec_exports; exports.tui = _chunkGGWJRWWAjs.tui_exports; exports.upgrade = _chunkWWUKGJB5js.upgrade_exports; exports.xdg = _chunk4UE5TCMQjs.xdg_exports;
@@ -0,0 +1,115 @@
1
+ import { P as ParityData } from './parity-CvMuYcVI.js';
2
+
3
+ /**
4
+ * Structured logger wrapping pino — applies kit's charmtone theme
5
+ * colors to stderr output (or an injected `output` sink).
6
+ *
7
+ * API: `logger.info('msg', 'key', val, 'key2', val2)` (variadic key-value)
8
+ * This matches Go's charm/log API, not pino's native object API.
9
+ * Pino handles transports, serialization, and performance under the hood.
10
+ *
11
+ * The `-V` count → level mapping and the `--quiet` override both come from
12
+ * the parity contract (`parity.json` verbosity block), so the level
13
+ * vocabulary stays identical across the Go, TypeScript and Python ports.
14
+ */
15
+
16
+ interface Logger {
17
+ info(msg: string, ...keyvals: any[]): void;
18
+ warn(msg: string, ...keyvals: any[]): void;
19
+ error(msg: string, ...keyvals: any[]): void;
20
+ debug(msg: string, ...keyvals: any[]): void;
21
+ trace(msg: string, ...keyvals: any[]): void;
22
+ /**
23
+ * Info-level line marked as a success: label `SUCC` in the theme's
24
+ * success colour. Filtered exactly like `info` (not a new level).
25
+ */
26
+ success(msg: string, ...keyvals: any[]): void;
27
+ }
28
+ /** Minimal sink the logger writes rendered lines to. */
29
+ interface LogOutput {
30
+ write(chunk: string): unknown;
31
+ }
32
+ /** Kit level vocabulary (same spellings as Go/py and `parity.json`). */
33
+ type LogLevelName = 'trace' | 'debug' | 'info' | 'warn' | 'error' | 'fatal';
34
+ /** One log line, as handed to a custom `formatter`. */
35
+ interface LogRecord {
36
+ level: LogLevelName;
37
+ msg: string;
38
+ /** Key-value pairs in call order (after pino serialization). */
39
+ fields: Record<string, unknown>;
40
+ /** Set on `success()` lines, whose `level` is `'info'`. */
41
+ kind?: 'success';
42
+ }
43
+ /** Renders a record to one line; a missing trailing newline is appended. */
44
+ type LogFormatter = (rec: LogRecord) => string;
45
+ interface LoggerOptions {
46
+ quiet?: boolean;
47
+ noColor?: boolean;
48
+ /**
49
+ * Explicit threshold; wins over the factory default and the `-V` count.
50
+ * `'silent'` drops everything. `quiet` only raises it (to the contract's
51
+ * `quiet_override`), never lowers it — same as Go's `WithLevel`.
52
+ * TS-only option; not a parity verbosity entry.
53
+ */
54
+ level?: LogLevelName | 'silent';
55
+ /**
56
+ * Where rendered lines go. Defaults to `process.stderr`, resolved at
57
+ * write time. Mirrors Go's `(*log.Logger).SetOutput`; useful for
58
+ * capturing output in tests.
59
+ */
60
+ output?: LogOutput;
61
+ /**
62
+ * Line format. `'text'` (default) is `LEVEL msg k=v`; `'json'` is one
63
+ * object per line shaped like Go charm/log's JSONFormatter:
64
+ * `{"level":"info","msg":"...",...kv}` (no time/pid/hostname, no ANSI).
65
+ * `success` lines carry `"level":"info","kind":"success"`. Selected by
66
+ * this option only — no env var or flag.
67
+ */
68
+ format?: 'text' | 'json';
69
+ /**
70
+ * TS extension point: render each line yourself (glyph prefixes, house
71
+ * styles). The returned string is written as-is, plus `\n` if missing.
72
+ * Wins over `format` and `noColor`; level filtering still applies.
73
+ */
74
+ formatter?: LogFormatter;
75
+ }
76
+ /**
77
+ * Resolve a `-V` count against a parity contract's `verbosity.levels`
78
+ * table. Counts above the highest declared key clamp to that key's level;
79
+ * an empty or unresolvable table falls back to `info`.
80
+ *
81
+ * Taking the contract as a parameter (rather than reading the module-level
82
+ * `parity`) keeps the mapping testable against a constructed `ParityData`
83
+ * without mutating the shared `parity.json`.
84
+ */
85
+ declare function verbosityLevel(d: ParityData, verbose: number): string;
86
+ /**
87
+ * Resolve a parity contract's `verbosity.quiet_override` to a pino level
88
+ * name. An unrecognized or absent override falls back to `warn`.
89
+ */
90
+ declare function quietLevel(d: ParityData): string;
91
+ declare function createLogger(opts?: LoggerOptions): Logger;
92
+ /**
93
+ * Map verbose count to a pino level through the parity contract's
94
+ * `verbosity.levels` table. An explicit `level` wins over the count.
95
+ * Quiet raises to the contract's `quiet_override` level.
96
+ */
97
+ declare function withVerbose(opts: LoggerOptions & {
98
+ verbose?: number;
99
+ }): Logger;
100
+
101
+ type log_LogFormatter = LogFormatter;
102
+ type log_LogLevelName = LogLevelName;
103
+ type log_LogOutput = LogOutput;
104
+ type log_LogRecord = LogRecord;
105
+ type log_Logger = Logger;
106
+ type log_LoggerOptions = LoggerOptions;
107
+ declare const log_createLogger: typeof createLogger;
108
+ declare const log_quietLevel: typeof quietLevel;
109
+ declare const log_verbosityLevel: typeof verbosityLevel;
110
+ declare const log_withVerbose: typeof withVerbose;
111
+ declare namespace log {
112
+ export { type log_LogFormatter as LogFormatter, type log_LogLevelName as LogLevelName, type log_LogOutput as LogOutput, type log_LogRecord as LogRecord, type log_Logger as Logger, type log_LoggerOptions as LoggerOptions, log_createLogger as createLogger, log_quietLevel as quietLevel, log_verbosityLevel as verbosityLevel, log_withVerbose as withVerbose };
113
+ }
114
+
115
+ export { type LogFormatter as L, type LogLevelName as a, type LogOutput as b, type LogRecord as c, type Logger as d, type LoggerOptions as e, createLogger as f, log as l, quietLevel as q, verbosityLevel as v, withVerbose as w };
package/dist/log.d.ts ADDED
@@ -0,0 +1,2 @@
1
+ import './parity-CvMuYcVI.js';
2
+ export { L as LogFormatter, a as LogLevelName, b as LogOutput, c as LogRecord, d as Logger, e as LoggerOptions, f as createLogger, q as quietLevel, v as verbosityLevel, w as withVerbose } from './log-CkaxMX3U.js';
package/dist/log.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
+
3
+
4
+
5
+
6
+ var _chunkNLMS7HGPjs = require('./chunk-NLMS7HGP.js');
7
+ require('./chunk-QPUCXQXT.js');
8
+ require('./chunk-R5U7XKVJ.js');
9
+
10
+
11
+
12
+
13
+
14
+ exports.createLogger = _chunkNLMS7HGPjs.createLogger; exports.quietLevel = _chunkNLMS7HGPjs.quietLevel; exports.verbosityLevel = _chunkNLMS7HGPjs.verbosityLevel; exports.withVerbose = _chunkNLMS7HGPjs.withVerbose;
@@ -0,0 +1,61 @@
1
+ /**
2
+ * @module tui/parity
3
+ * @package @hop-top/kit
4
+ *
5
+ * Cross-language parity constants SoT. Values are read from the canonical
6
+ * `contracts/parity/parity.json` at build time — tsup/esbuild inlines the
7
+ * JSON into the emitted bundle, so the published package stays
8
+ * self-contained without vendoring a second copy of the file.
9
+ *
10
+ * All TUI modules should import constants from here, not hardcode them.
11
+ */
12
+ /** Display metadata for a single help section. */
13
+ interface SectionConfig {
14
+ title: string;
15
+ }
16
+ /**
17
+ * ParityData models every content block `parity.json` declares.
18
+ *
19
+ * A block present in the JSON but absent here is decoration: nothing loads
20
+ * it, so no test and no consumer can see it drift. `PARITY_BLOCKS` below is
21
+ * the machine-checkable half of that rule.
22
+ */
23
+ interface ParityData {
24
+ description: string;
25
+ status: {
26
+ symbols: Record<'info' | 'success' | 'error' | 'warn', string>;
27
+ };
28
+ spinner: {
29
+ frames: string[];
30
+ interval_ms: number;
31
+ };
32
+ anim: {
33
+ runes: string;
34
+ interval_ms: number;
35
+ default_width: number;
36
+ };
37
+ help: {
38
+ /** Fang-vocabulary section names in render order. */
39
+ section_order: string[];
40
+ /** Display metadata keyed by fang section name. */
41
+ sections: Record<string, SectionConfig>;
42
+ };
43
+ verbosity: {
44
+ flag: string;
45
+ /**
46
+ * Maps the stacked `-V` count (as a decimal string) to a log level name.
47
+ * Keys are strings because JSON object keys are.
48
+ */
49
+ levels: Record<string, string>;
50
+ quiet_override: string;
51
+ };
52
+ streams: {
53
+ flag: string;
54
+ label_format: string;
55
+ output: string;
56
+ };
57
+ /** Sibling contract files the parity suite also covers. */
58
+ extends: string[];
59
+ }
60
+
61
+ export type { ParityData as P };