@hop-top/kit 0.5.0-alpha.6 → 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.
- package/CHANGELOG.md +36 -0
- package/LICENSE-cobra.txt +174 -0
- package/NOTICE +15 -0
- package/README.md +3 -3
- package/dist/{alias-BOj0-VAr.d.ts → alias-BsJ2jGqQ.d.ts} +9 -1
- package/dist/alias.d.ts +1 -1
- package/dist/alias.js +4 -2
- package/dist/chunk-263IZ6Z6.js +915 -0
- package/dist/{chunk-S45UHXQF.js → chunk-DIDN4X5C.js} +8 -6
- package/dist/{chunk-7FDIN5KE.js → chunk-GHPJJV5L.js} +8 -4
- package/dist/chunk-JKMQSAJP.js +174 -0
- package/dist/chunk-JZ22ZUFA.js +1131 -0
- package/dist/{chunk-GAZPYCQD.js → chunk-NLMS7HGP.js} +93 -35
- package/dist/chunk-QQQYCWSC.js +240 -0
- package/dist/chunk-XJTRY453.js +868 -0
- package/dist/cli.js +6 -4
- package/dist/completion-sDKVXPUL.d.ts +109 -0
- package/dist/completion-values-By-mnjNt.d.ts +142 -0
- package/dist/completion-values.d.ts +1 -0
- package/dist/completion-values.js +29 -0
- package/dist/completion.d.ts +2 -1
- package/dist/completion.js +23 -2
- package/dist/compliance-AxFf-uMy.d.ts +60 -0
- package/dist/compliance.d.ts +1 -0
- package/dist/compliance.js +17 -0
- package/dist/config-CaK60ByQ.d.ts +241 -0
- package/dist/config.d.ts +1 -1
- package/dist/config.js +4 -2
- package/dist/index.d.ts +7 -5
- package/dist/index.js +26 -18
- package/dist/log-CkaxMX3U.d.ts +115 -0
- package/dist/log.d.ts +1 -1
- package/dist/log.js +2 -2
- package/dist/toolspec-UrWnoJ3Y.d.ts +336 -0
- package/dist/toolspec.d.ts +2 -1
- package/dist/toolspec.js +27 -2
- package/package.json +19 -3
- package/src/alias.test.ts +110 -1
- package/src/alias.ts +19 -4
- package/src/cli.ts +5 -0
- package/src/completion-scripts.ts +16 -0
- package/src/completion-values.test.ts +70 -10
- package/src/completion-values.ts +170 -66
- package/src/completion.conformance.test.ts +297 -0
- package/src/completion.test.ts +256 -145
- package/src/completion.ts +764 -121
- package/src/config-merge.test.ts +425 -0
- package/src/config.test.ts +41 -0
- package/src/config.ts +265 -18
- package/src/index.test.ts +2 -1
- package/src/index.ts +5 -1
- package/src/log.test.ts +270 -1
- package/src/log.ts +172 -44
- package/src/published-types.test.ts +18 -0
- package/src/toolspec-internal.ts +197 -0
- package/src/toolspec-manifest.test.ts +82 -0
- package/src/toolspec-manifest.ts +404 -0
- package/src/toolspec-spec-schemas.ts +12 -0
- package/src/toolspec-spec.test.ts +273 -0
- package/src/toolspec-spec.ts +458 -0
- package/src/toolspec.from-command.test.ts +216 -0
- package/src/toolspec.ts +159 -0
- package/test/toolspec/fixture.ts +73 -0
- package/dist/chunk-6RFRV4VP.js +0 -128
- package/dist/chunk-IQXEISMC.js +0 -142
- package/dist/chunk-W7ERKNSQ.js +0 -171
- package/dist/completion-CVnPcWMZ.d.ts +0 -32
- package/dist/config-Bm9fBXch.d.ts +0 -134
- package/dist/log-uKjHsK-c.d.ts +0 -62
- package/dist/toolspec-DPBr18Ub.d.ts +0 -106
|
@@ -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-
|
|
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
|
-
|
|
3
|
+
|
|
4
|
+
var _chunkQQQYCWSCjs = require('./chunk-QQQYCWSC.js');
|
|
4
5
|
require('./chunk-R5U7XKVJ.js');
|
|
5
6
|
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
|
|
9
|
+
exports.load = _chunkQQQYCWSCjs.load; exports.mergeLayers = _chunkQQQYCWSCjs.mergeLayers;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export { a as aim } from './aim-DZHwwiIc.js';
|
|
2
|
-
export { a as alias } from './alias-
|
|
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
6
|
export { c as cli } from './cli-C5B5tnpA.js';
|
|
7
|
-
export { c as completion } from './completion-
|
|
8
|
-
export { c as
|
|
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';
|
|
9
11
|
export { e as errcorrect } from './errcorrect-BcX1Ft0K.js';
|
|
10
12
|
export { i as id } from './index-VLDcI5NF.js';
|
|
11
13
|
export { l as llm } from './llm-DYuR7_uX.js';
|
|
12
|
-
export { l as log } from './log-
|
|
14
|
+
export { l as log } from './log-CkaxMX3U.js';
|
|
13
15
|
export { i as mcp } from './index-B-pqGHhU.js';
|
|
14
16
|
export { n as netpolicy } from './netpolicy-Brx5XZUB.js';
|
|
15
17
|
export { l as openai } from './llm-openai-DyFrucmV.js';
|
|
@@ -23,7 +25,7 @@ export { s as scope } from './scope-BrhYB4ij.js';
|
|
|
23
25
|
export { s as serve } from './serve-D8yWMrTc.js';
|
|
24
26
|
export { s as stream } from './stream-CrjeCp0M.js';
|
|
25
27
|
export { i as telemetry } from './index-C3Zw4wDJ.js';
|
|
26
|
-
export { t as toolspec } from './toolspec-
|
|
28
|
+
export { t as toolspec } from './toolspec-UrWnoJ3Y.js';
|
|
27
29
|
export { i as tui } from './index-DCe1boBz.js';
|
|
28
30
|
export { u as upgrade } from './upgrade-p_zh3pvV.js';
|
|
29
31
|
export { x as xdg } from './xdg-DB7Shoib.js';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,12 @@
|
|
|
1
1
|
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
2
|
|
|
3
|
-
var
|
|
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');
|
|
4
10
|
|
|
5
11
|
|
|
6
12
|
var _chunkWWUKGJB5js = require('./chunk-WWUKGJB5.js');
|
|
@@ -15,7 +21,10 @@ var _chunkJTMPNXVQjs = require('./chunk-JTMPNXVQ.js');
|
|
|
15
21
|
var _chunkYOBAUCVNjs = require('./chunk-YOBAUCVN.js');
|
|
16
22
|
|
|
17
23
|
|
|
18
|
-
var
|
|
24
|
+
var _chunkIXVQ62NZjs = require('./chunk-IXVQ62NZ.js');
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
var _chunkBDNNPRX6js = require('./chunk-BDNNPRX6.js');
|
|
19
28
|
|
|
20
29
|
|
|
21
30
|
var _chunk6SVOHNICjs = require('./chunk-6SVOHNIC.js');
|
|
@@ -36,7 +45,10 @@ var _chunkWBVO43HUjs = require('./chunk-WBVO43HU.js');
|
|
|
36
45
|
var _chunkMQXYDYRDjs = require('./chunk-MQXYDYRD.js');
|
|
37
46
|
|
|
38
47
|
|
|
39
|
-
var
|
|
48
|
+
var _chunkQQQYCWSCjs = require('./chunk-QQQYCWSC.js');
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
var _chunk3FIKGFKIjs = require('./chunk-3FIKGFKI.js');
|
|
40
52
|
|
|
41
53
|
|
|
42
54
|
var _chunkT46YPHKNjs = require('./chunk-T46YPHKN.js');
|
|
@@ -49,13 +61,7 @@ require('./chunk-YGYQUFGY.js');
|
|
|
49
61
|
var _chunkPSFYJGDGjs = require('./chunk-PSFYJGDG.js');
|
|
50
62
|
|
|
51
63
|
|
|
52
|
-
var
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
var _chunkIXVQ62NZjs = require('./chunk-IXVQ62NZ.js');
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
var _chunkBDNNPRX6js = require('./chunk-BDNNPRX6.js');
|
|
64
|
+
var _chunkNLMS7HGPjs = require('./chunk-NLMS7HGP.js');
|
|
59
65
|
|
|
60
66
|
|
|
61
67
|
var _chunkQJVSKKRQjs = require('./chunk-QJVSKKRQ.js');
|
|
@@ -64,7 +70,7 @@ var _chunkQJVSKKRQjs = require('./chunk-QJVSKKRQ.js');
|
|
|
64
70
|
var _chunk4UE5TCMQjs = require('./chunk-4UE5TCMQ.js');
|
|
65
71
|
|
|
66
72
|
|
|
67
|
-
var
|
|
73
|
+
var _chunkDIDN4X5Cjs = require('./chunk-DIDN4X5C.js');
|
|
68
74
|
|
|
69
75
|
|
|
70
76
|
var _chunkCSJWB6D3js = require('./chunk-CSJWB6D3.js');
|
|
@@ -73,22 +79,22 @@ var _chunkCSJWB6D3js = require('./chunk-CSJWB6D3.js');
|
|
|
73
79
|
var _chunkUKZIAQA7js = require('./chunk-UKZIAQA7.js');
|
|
74
80
|
|
|
75
81
|
|
|
76
|
-
var
|
|
82
|
+
var _chunkGHPJJV5Ljs = require('./chunk-GHPJJV5L.js');
|
|
83
|
+
require('./chunk-72XZWQX7.js');
|
|
84
|
+
require('./chunk-POR5L2DG.js');
|
|
77
85
|
require('./chunk-QPUCXQXT.js');
|
|
78
86
|
|
|
79
87
|
|
|
80
88
|
var _chunkKVG7YCTSjs = require('./chunk-KVG7YCTS.js');
|
|
81
|
-
require('./chunk-72XZWQX7.js');
|
|
82
|
-
require('./chunk-POR5L2DG.js');
|
|
83
89
|
|
|
84
90
|
|
|
85
|
-
var
|
|
91
|
+
var _chunkJZ22ZUFAjs = require('./chunk-JZ22ZUFA.js');
|
|
86
92
|
|
|
87
93
|
|
|
88
|
-
var
|
|
94
|
+
var _chunkJKMQSAJPjs = require('./chunk-JKMQSAJP.js');
|
|
89
95
|
|
|
90
96
|
|
|
91
|
-
var
|
|
97
|
+
var _chunkXJTRY453js = require('./chunk-XJTRY453.js');
|
|
92
98
|
require('./chunk-R5U7XKVJ.js');
|
|
93
99
|
|
|
94
100
|
|
|
@@ -120,4 +126,6 @@ require('./chunk-R5U7XKVJ.js');
|
|
|
120
126
|
|
|
121
127
|
|
|
122
128
|
|
|
123
|
-
|
|
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
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import './parity-CvMuYcVI.js';
|
|
2
|
-
export { L as
|
|
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
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
var
|
|
6
|
+
var _chunkNLMS7HGPjs = require('./chunk-NLMS7HGP.js');
|
|
7
7
|
require('./chunk-QPUCXQXT.js');
|
|
8
8
|
require('./chunk-R5U7XKVJ.js');
|
|
9
9
|
|
|
@@ -11,4 +11,4 @@ require('./chunk-R5U7XKVJ.js');
|
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
14
|
-
exports.createLogger =
|
|
14
|
+
exports.createLogger = _chunkNLMS7HGPjs.createLogger; exports.quietLevel = _chunkNLMS7HGPjs.quietLevel; exports.verbosityLevel = _chunkNLMS7HGPjs.verbosityLevel; exports.withVerbose = _chunkNLMS7HGPjs.withVerbose;
|