@wirecat/cli-base 0.21.0 → 0.23.0
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/README.md +16 -2
- package/dist/commands/document.d.ts +72 -0
- package/dist/commands/document.d.ts.map +1 -0
- package/dist/commands/document.js +71 -0
- package/dist/commands/document.js.map +1 -0
- package/dist/commands/index.d.ts +7 -0
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +23 -0
- package/dist/commands/index.js.map +1 -1
- package/dist/deadline.js +4 -4
- package/dist/deadline.js.map +1 -1
- package/dist/dev/bin.js +0 -0
- package/dist/dev/lint.d.ts +33 -0
- package/dist/dev/lint.d.ts.map +1 -0
- package/dist/dev/lint.js +257 -0
- package/dist/dev/lint.js.map +1 -0
- package/dist/dev/main.d.ts.map +1 -1
- package/dist/dev/main.js +132 -2
- package/dist/dev/main.js.map +1 -1
- package/dist/errors.d.ts +4 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +5 -1
- package/dist/errors.js.map +1 -1
- package/dist/failure.d.ts +76 -0
- package/dist/failure.d.ts.map +1 -0
- package/dist/failure.js +150 -0
- package/dist/failure.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/logging.d.ts +17 -15
- package/dist/logging.d.ts.map +1 -1
- package/dist/logging.js +49 -28
- package/dist/logging.js.map +1 -1
- package/dist/output-buffer.js +4 -4
- package/dist/output-buffer.js.map +1 -1
- package/dist/standards/errors.d.ts +51 -0
- package/dist/standards/errors.d.ts.map +1 -0
- package/dist/standards/errors.js +82 -0
- package/dist/standards/errors.js.map +1 -0
- package/dist/standards/index.d.ts +8 -0
- package/dist/standards/index.d.ts.map +1 -0
- package/dist/standards/index.js +8 -0
- package/dist/standards/index.js.map +1 -0
- package/dist/standards/lint.d.ts +29 -0
- package/dist/standards/lint.d.ts.map +1 -0
- package/dist/standards/lint.js +62 -0
- package/dist/standards/lint.js.map +1 -0
- package/dist/standards/log.d.ts +21 -0
- package/dist/standards/log.d.ts.map +1 -0
- package/dist/standards/log.js +18 -0
- package/dist/standards/log.js.map +1 -0
- package/dist/standards/output.d.ts +126 -0
- package/dist/standards/output.d.ts.map +1 -0
- package/dist/standards/output.js +54 -0
- package/dist/standards/output.js.map +1 -0
- package/dist/standards/registry.d.ts +18 -0
- package/dist/standards/registry.d.ts.map +1 -0
- package/dist/standards/registry.js +41 -0
- package/dist/standards/registry.js.map +1 -0
- package/dist/standards/steps.d.ts +28 -0
- package/dist/standards/steps.d.ts.map +1 -0
- package/dist/standards/steps.js +56 -0
- package/dist/standards/steps.js.map +1 -0
- package/dist/standards/vocabulary.d.ts +40 -0
- package/dist/standards/vocabulary.d.ts.map +1 -0
- package/dist/standards/vocabulary.js +255 -0
- package/dist/standards/vocabulary.js.map +1 -0
- package/package.json +27 -20
package/dist/logging.d.ts
CHANGED
|
@@ -1,31 +1,33 @@
|
|
|
1
1
|
import type { Logger } from "./logger.js";
|
|
2
|
+
import type { LogRecord } from "./standards/log.js";
|
|
2
3
|
/**
|
|
3
4
|
* Field names whose value must never reach a log file. This is the **second** line of defence, not
|
|
4
5
|
* the first: a secret should not be handed to a logger at all. Redaction catches the one that
|
|
5
6
|
* slipped into a nested object nobody thought about.
|
|
6
7
|
*/
|
|
7
8
|
export declare const REDACTED_FIELDS: string[];
|
|
8
|
-
export interface
|
|
9
|
-
/**
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
level?: string;
|
|
16
|
-
base?: Record<string, unknown>;
|
|
9
|
+
export interface RecordLogOptions {
|
|
10
|
+
/** A file the JSON lines are appended to, or a function handed each line. Omit for a log that writes nowhere. */
|
|
11
|
+
to?: string | ((line: string) => void);
|
|
12
|
+
runId: string;
|
|
13
|
+
command: string;
|
|
14
|
+
resource: LogRecord["resource"];
|
|
15
|
+
traceId?: string;
|
|
17
16
|
/** Added to `REDACTED_FIELDS` — the names only this program knows about. */
|
|
18
17
|
redact?: string[];
|
|
19
18
|
/**
|
|
20
|
-
* Told once when the file cannot be
|
|
21
|
-
*
|
|
19
|
+
* Told once when the file cannot be written; every record after that is dropped. Without it the
|
|
20
|
+
* failure is silent, so a host that promised a log should say it is gone.
|
|
22
21
|
*/
|
|
23
22
|
onError?: (error: Error) => void;
|
|
23
|
+
now?: () => Date;
|
|
24
24
|
}
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
26
|
+
* One `LogRecord` per line, OpenTelemetry's field names, flat — never OTLP's nested export format.
|
|
27
|
+
* The event becomes `attributes`; `body` is the message when one is given, else the event's own
|
|
28
|
+
* `event` name, so it never needs content to say what happened.
|
|
29
|
+
*
|
|
30
|
+
* Appended synchronously: a log exists to explain the exit that would have dropped a buffered tail.
|
|
29
31
|
*/
|
|
30
|
-
export declare const
|
|
32
|
+
export declare const createRecordLog: ({ to, runId, command, resource, traceId, redact, onError, now, }: RecordLogOptions) => Logger;
|
|
31
33
|
//# sourceMappingURL=logging.d.ts.map
|
package/dist/logging.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACzC,OAAO,KAAK,EAAE,SAAS,EAAe,MAAM,oBAAoB,CAAA;AAEhE;;;;GAIG;AACH,eAAO,MAAM,eAAe,UAa3B,CAAA;AAED,MAAM,WAAW,gBAAgB;IAC/B,iHAAiH;IACjH,EAAE,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC,CAAA;IACtC,KAAK,EAAE,MAAM,CAAA;IACb,OAAO,EAAE,MAAM,CAAA;IACf,QAAQ,EAAE,SAAS,CAAC,UAAU,CAAC,CAAA;IAC/B,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,4EAA4E;IAC5E,MAAM,CAAC,EAAE,MAAM,EAAE,CAAA;IACjB;;;OAGG;IACH,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,GAAG,CAAC,EAAE,MAAM,IAAI,CAAA;CACjB;AAED;;;;;;GAMG;AACH,eAAO,MAAM,eAAe,qEASzB,gBAAgB,KAAG,MAqCrB,CAAA"}
|
package/dist/logging.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { pino } from "pino";
|
|
1
|
+
import { appendFileSync } from "node:fs";
|
|
3
2
|
/**
|
|
4
3
|
* Field names whose value must never reach a log file. This is the **second** line of defence, not
|
|
5
4
|
* the first: a secret should not be handed to a logger at all. Redaction catches the one that
|
|
@@ -20,34 +19,56 @@ export const REDACTED_FIELDS = [
|
|
|
20
19
|
"phone",
|
|
21
20
|
];
|
|
22
21
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
22
|
+
* One `LogRecord` per line, OpenTelemetry's field names, flat — never OTLP's nested export format.
|
|
23
|
+
* The event becomes `attributes`; `body` is the message when one is given, else the event's own
|
|
24
|
+
* `event` name, so it never needs content to say what happened.
|
|
25
|
+
*
|
|
26
|
+
* Appended synchronously: a log exists to explain the exit that would have dropped a buffered tail.
|
|
26
27
|
*/
|
|
27
|
-
export const
|
|
28
|
-
if (
|
|
29
|
-
return
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
28
|
+
export const createRecordLog = ({ to, runId, command, resource, traceId, redact = [], onError = () => { }, now = () => new Date(), }) => {
|
|
29
|
+
if (to === undefined)
|
|
30
|
+
return silent;
|
|
31
|
+
const hidden = new Set([...REDACTED_FIELDS, ...redact]);
|
|
32
|
+
let broken = false;
|
|
33
|
+
const write = typeof to === "string"
|
|
34
|
+
? (line) => {
|
|
35
|
+
if (broken)
|
|
36
|
+
return;
|
|
37
|
+
try {
|
|
38
|
+
appendFileSync(to, line, { mode: 0o600 });
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
broken = true;
|
|
42
|
+
onError(error instanceof Error ? error : new Error(String(error)));
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
: (line) => to(line.trimEnd());
|
|
46
|
+
const at = (severity) => (event, message) => {
|
|
47
|
+
const attributes = redacted(event, hidden);
|
|
48
|
+
const name = typeof attributes.event === "string" ? attributes.event : "";
|
|
49
|
+
const record = {
|
|
50
|
+
time: now().toISOString(),
|
|
51
|
+
severity,
|
|
52
|
+
body: message ?? name,
|
|
53
|
+
runId,
|
|
54
|
+
...(traceId === undefined ? {} : { traceId }),
|
|
55
|
+
command,
|
|
56
|
+
attributes,
|
|
57
|
+
resource,
|
|
58
|
+
};
|
|
59
|
+
write(`${JSON.stringify(record)}\n`);
|
|
50
60
|
};
|
|
61
|
+
return { debug: at("debug"), info: at("info"), warn: at("warn"), error: at("error") };
|
|
62
|
+
};
|
|
63
|
+
const redacted = (value, hidden) => {
|
|
64
|
+
const plain = value !== null && typeof value === "object" && "toJSON" in value && typeof value.toJSON === "function"
|
|
65
|
+
? value.toJSON()
|
|
66
|
+
: value;
|
|
67
|
+
if (Array.isArray(plain))
|
|
68
|
+
return plain.map((item) => redacted(item, hidden));
|
|
69
|
+
if (plain === null || typeof plain !== "object")
|
|
70
|
+
return plain;
|
|
71
|
+
return Object.fromEntries(Object.entries(plain).map(([key, item]) => [key, hidden.has(key) ? "[redacted]" : redacted(item, hidden)]));
|
|
51
72
|
};
|
|
52
73
|
const silent = {
|
|
53
74
|
debug: () => { },
|
package/dist/logging.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"logging.js","sourceRoot":"","sources":["../src/logging.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAA;AAIxC;;;;GAIG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG;IAC7B,eAAe;IACf,eAAe;IACf,QAAQ;IACR,SAAS;IACT,OAAO;IACP,aAAa;IACb,cAAc;IACd,cAAc;IACd,UAAU;IACV,QAAQ;IACR,YAAY;IACZ,OAAO;CACR,CAAA;AAmBD;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,EAC9B,EAAE,EACF,KAAK,EACL,OAAO,EACP,QAAQ,EACR,OAAO,EACP,MAAM,GAAG,EAAE,EACX,OAAO,GAAG,GAAG,EAAE,GAAE,CAAC,EAClB,GAAG,GAAG,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,GACL,EAAU,EAAE;IAC7B,IAAI,EAAE,KAAK,SAAS;QAAE,OAAO,MAAM,CAAA;IAEnC,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,eAAe,EAAE,GAAG,MAAM,CAAC,CAAC,CAAA;IACvD,IAAI,MAAM,GAAG,KAAK,CAAA;IAClB,MAAM,KAAK,GACT,OAAO,EAAE,KAAK,QAAQ;QACpB,CAAC,CAAC,CAAC,IAAY,EAAE,EAAE;YACf,IAAI,MAAM;gBAAE,OAAM;YAClB,IAAI,CAAC;gBACH,cAAc,CAAC,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAA;YAC3C,CAAC;YAAC,OAAO,KAAK,EAAE,CAAC;gBAC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,KAAK,GACT,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,UAAU;QACpG,CAAC,CAAE,KAAK,CAAC,MAAM,EAAc;QAC7B,CAAC,CAAC,KAAK,CAAA;IACX,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAA;IAC5E,IAAI,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAA;IAC7D,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,CAC3G,CAAA;AACH,CAAC,CAAA;AAED,MAAM,MAAM,GAAW;IACrB,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;IACf,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,IAAI,EAAE,GAAG,EAAE,GAAE,CAAC;IACd,KAAK,EAAE,GAAG,EAAE,GAAE,CAAC;CAChB,CAAA"}
|
package/dist/output-buffer.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliError } from "./errors.js";
|
|
1
|
+
import { CliError, isCliError } from "./errors.js";
|
|
2
2
|
import { fieldsOf, projectFields } from "./result-fields.js";
|
|
3
3
|
export const createOutputBuffer = ({ maxOutputBytes = 4 * 1024 * 1024, fields, format, } = {}) => {
|
|
4
4
|
if (!Number.isSafeInteger(maxOutputBytes) || maxOutputBytes < 0)
|
|
@@ -32,10 +32,10 @@ export const createOutputBuffer = ({ maxOutputBytes = 4 * 1024 * 1024, fields, f
|
|
|
32
32
|
: project(text) + (text.endsWith("\n") ? "\n" : "");
|
|
33
33
|
}
|
|
34
34
|
catch (error) {
|
|
35
|
-
if (error
|
|
35
|
+
if (isCliError(error))
|
|
36
36
|
throw error;
|
|
37
37
|
throw new CliError("invalid_response", "field projection requires complete JSON values or JSONL lines", {
|
|
38
|
-
reason: "
|
|
38
|
+
reason: "output.fields-unavailable",
|
|
39
39
|
retryable: false,
|
|
40
40
|
});
|
|
41
41
|
}
|
|
@@ -43,7 +43,7 @@ export const createOutputBuffer = ({ maxOutputBytes = 4 * 1024 * 1024, fields, f
|
|
|
43
43
|
const size = Buffer.byteLength(result);
|
|
44
44
|
if (!Number.isSafeInteger(bytes + size) || (maxOutputBytes !== 0 && bytes + size > maxOutputBytes))
|
|
45
45
|
throw new CliError("invalid_response", "output exceeds the configured byte limit", {
|
|
46
|
-
reason: "
|
|
46
|
+
reason: "output.too-large",
|
|
47
47
|
maxBytes: maxOutputBytes,
|
|
48
48
|
bufferedBytes: bytes,
|
|
49
49
|
retryable: false,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"output-buffer.js","sourceRoot":"","sources":["../src/output-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAA;
|
|
1
|
+
{"version":3,"file":"output-buffer.js","sourceRoot":"","sources":["../src/output-buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AAElD,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAA;AAgB5D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,EACjC,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,IAAI,EAChC,MAAM,EACN,MAAM,GACP,GAAwB,EAA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AI,CAAA;YACf,MAAM,GAAG,EAAE,CAAA;QACb,CAAC;KACF,CAAA;AACH,CAAC,CAAA"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/**
|
|
3
|
+
* What a failure that is not a `CliError` reports: a bug, not a refusal. Outside `errorCodes` on purpose,
|
|
4
|
+
* so no command can raise it; it exits with `GENERIC_FAILURE`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const CRASH_CODE = "internal_error";
|
|
7
|
+
export declare const CRASH_REASON = "command.crashed";
|
|
8
|
+
/** The one error object, on stderr in machine mode and as MCP's `isError` content alike. */
|
|
9
|
+
export declare const errorObjectSchema: v.StrictObjectSchema<{
|
|
10
|
+
readonly error: v.StrictObjectSchema<{
|
|
11
|
+
readonly code: v.PicklistSchema<["validation_error", "configuration_error", "authentication_error", "permission_error", "not_found", "confirmation_required", "rate_limited", "timeout", "network_error", "provider_error", "provider_unavailable", "invalid_response", "outcome_unknown", "cancelled", "internal_error"], undefined>;
|
|
12
|
+
readonly reason: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "dotted lower-case words, such as `page.next`">]>;
|
|
13
|
+
readonly message: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
14
|
+
/** The option or argument at fault. */
|
|
15
|
+
readonly param: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>;
|
|
16
|
+
readonly details: v.OptionalSchema<v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>, undefined>;
|
|
17
|
+
readonly next: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StrictObjectSchema<{
|
|
18
|
+
readonly step: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "dotted lower-case words, such as `page.next`">]>;
|
|
19
|
+
readonly command: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
20
|
+
readonly args: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
|
|
21
|
+
readonly why: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
22
|
+
}, undefined>, undefined>, v.MaxLengthAction<{
|
|
23
|
+
step: string;
|
|
24
|
+
command: string;
|
|
25
|
+
args: {
|
|
26
|
+
[x: string]: unknown;
|
|
27
|
+
};
|
|
28
|
+
why: string;
|
|
29
|
+
}[], 3, undefined>]>, undefined>;
|
|
30
|
+
/** Optional until every CLI keeps a run for each failure. */
|
|
31
|
+
readonly runId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>;
|
|
32
|
+
}, undefined>;
|
|
33
|
+
}, undefined>;
|
|
34
|
+
export type ErrorObject = v.InferOutput<typeof errorObjectSchema>;
|
|
35
|
+
declare const reasonSchema: v.StrictObjectSchema<{
|
|
36
|
+
readonly reason: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "dotted lower-case words, such as `page.next`">]>;
|
|
37
|
+
readonly code: v.PicklistSchema<["validation_error", "configuration_error", "authentication_error", "permission_error", "not_found", "confirmation_required", "rate_limited", "timeout", "network_error", "provider_error", "provider_unavailable", "invalid_response", "outcome_unknown", "cancelled", "internal_error"], undefined>;
|
|
38
|
+
/** `{name}` placeholders, each one of `details`. */
|
|
39
|
+
readonly message: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, v.MaxLengthAction<string, 120, undefined>]>;
|
|
40
|
+
readonly details: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a camelCase key">]>, undefined>;
|
|
41
|
+
readonly step: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "dotted lower-case words, such as `page.next`">]>, undefined>;
|
|
42
|
+
}, undefined>;
|
|
43
|
+
export type ErrorReason = v.InferOutput<typeof reasonSchema>;
|
|
44
|
+
/** Reasons live where they are raised; each package defines its own list with this. */
|
|
45
|
+
export declare const defineReasons: (input: unknown) => ErrorReason[];
|
|
46
|
+
/** Keys any reason's `details` may carry; the handler drops every other key it was not told about. */
|
|
47
|
+
export declare const COMMON_DETAILS: readonly ["retryable", "retryAfterMs", "attempts", "status", "requestId", "operation"];
|
|
48
|
+
/** One reason per code, used when the code site named none, the crash, and the reasons cli-base raises itself. */
|
|
49
|
+
export declare const BASE_REASONS: ErrorReason[];
|
|
50
|
+
export {};
|
|
51
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/standards/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAK5B;;;GAGG;AACH,eAAO,MAAM,UAAU,mBAAmB,CAAA;AAC1C,eAAO,MAAM,YAAY,oBAAoB,CAAA;AAE7C,4FAA4F;AAC5F,eAAO,MAAM,iBAAiB;;;;;QAK1B,uCAAuC;;;;;;;;;;;;;;;;QAIvC,6DAA6D;;;aAG/D,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,iBAAiB,CAAC,CAAA;AAEjE,QAAA,MAAM,YAAY;;;IAGhB,oDAAoD;;;;aAIpD,CAAA;AAEF,MAAM,MAAM,WAAW,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,YAAY,CAAC,CAAA;AAE5D,uFAAuF;AACvF,eAAO,MAAM,aAAa,UAAW,OAAO,KAAG,WAAW,EAQtD,CAAA;AAEJ,sGAAsG;AACtG,eAAO,MAAM,cAAc,YAAI,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,QAAQ,EAAE,WAAW,EAAE,WAAW,CAAU,CAAA;AAEpH,kHAAkH;AAClH,eAAO,MAAM,YAAY,EAAE,WAAW,EAsCpC,CAAA"}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { errorCodes } from "../errors.js";
|
|
3
|
+
import { MAX_NEXT_STEPS, nextStepSchema } from "./output.js";
|
|
4
|
+
import { dottedId, duplicates, parseRegistry, placeholders, text } from "./registry.js";
|
|
5
|
+
/**
|
|
6
|
+
* What a failure that is not a `CliError` reports: a bug, not a refusal. Outside `errorCodes` on purpose,
|
|
7
|
+
* so no command can raise it; it exits with `GENERIC_FAILURE`.
|
|
8
|
+
*/
|
|
9
|
+
export const CRASH_CODE = "internal_error";
|
|
10
|
+
export const CRASH_REASON = "command.crashed";
|
|
11
|
+
/** The one error object, on stderr in machine mode and as MCP's `isError` content alike. */
|
|
12
|
+
export const errorObjectSchema = v.strictObject({
|
|
13
|
+
error: v.strictObject({
|
|
14
|
+
code: v.picklist([...errorCodes, CRASH_CODE]),
|
|
15
|
+
reason: dottedId,
|
|
16
|
+
message: text,
|
|
17
|
+
/** The option or argument at fault. */
|
|
18
|
+
param: v.optional(text),
|
|
19
|
+
details: v.optional(v.record(v.string(), v.unknown())),
|
|
20
|
+
next: v.optional(v.pipe(v.array(nextStepSchema), v.maxLength(MAX_NEXT_STEPS))),
|
|
21
|
+
/** Optional until every CLI keeps a run for each failure. */
|
|
22
|
+
runId: v.optional(text),
|
|
23
|
+
}),
|
|
24
|
+
});
|
|
25
|
+
const reasonSchema = v.strictObject({
|
|
26
|
+
reason: dottedId,
|
|
27
|
+
code: v.picklist([...errorCodes, CRASH_CODE]),
|
|
28
|
+
/** `{name}` placeholders, each one of `details`. */
|
|
29
|
+
message: v.pipe(text, v.maxLength(120)),
|
|
30
|
+
details: v.array(v.pipe(v.string(), v.regex(/^[a-z][a-zA-Z0-9]*$/, "a camelCase key"))),
|
|
31
|
+
step: v.optional(dottedId),
|
|
32
|
+
});
|
|
33
|
+
/** Reasons live where they are raised; each package defines its own list with this. */
|
|
34
|
+
export const defineReasons = (input) => parseRegistry("error reasons", v.array(reasonSchema), input, (reasons) => [
|
|
35
|
+
...duplicates(reasons.map((entry) => entry.reason)).map((reason) => `"${reason}" is listed twice`),
|
|
36
|
+
...reasons.flatMap((entry) => placeholders(entry.message)
|
|
37
|
+
.filter((name) => !entry.details.includes(name))
|
|
38
|
+
.map((name) => `${entry.reason}: the message names {${name}}, which is not one of its details`)),
|
|
39
|
+
]);
|
|
40
|
+
/** Keys any reason's `details` may carry; the handler drops every other key it was not told about. */
|
|
41
|
+
export const COMMON_DETAILS = ["retryable", "retryAfterMs", "attempts", "status", "requestId", "operation"];
|
|
42
|
+
/** One reason per code, used when the code site named none, the crash, and the reasons cli-base raises itself. */
|
|
43
|
+
export const BASE_REASONS = defineReasons([
|
|
44
|
+
{ reason: "input.invalid", code: "validation_error", message: "the input is not valid", details: [] },
|
|
45
|
+
{ reason: "config.invalid", code: "configuration_error", message: "the configuration is not valid", details: [] },
|
|
46
|
+
{ reason: "auth.failed", code: "authentication_error", message: "the sign-in did not work", details: [] },
|
|
47
|
+
{ reason: "access.denied", code: "permission_error", message: "this account may not do that", details: [] },
|
|
48
|
+
{ reason: "item.not-found", code: "not_found", message: "nothing found by that name", details: [] },
|
|
49
|
+
{
|
|
50
|
+
reason: "confirmation.required",
|
|
51
|
+
code: "confirmation_required",
|
|
52
|
+
message: "this changes something; confirm it",
|
|
53
|
+
details: [],
|
|
54
|
+
},
|
|
55
|
+
{ reason: "provider.rate-limited", code: "rate_limited", message: "too many requests; wait", details: [] },
|
|
56
|
+
{ reason: "command.timed-out", code: "timeout", message: "the command took too long", details: ["timeoutMs"] },
|
|
57
|
+
{ reason: "network.failed", code: "network_error", message: "the network did not answer", details: [] },
|
|
58
|
+
{ reason: "provider.refused", code: "provider_error", message: "the provider refused", details: [] },
|
|
59
|
+
{ reason: "provider.unavailable", code: "provider_unavailable", message: "the provider is down", details: [] },
|
|
60
|
+
{
|
|
61
|
+
reason: "provider.invalid-response",
|
|
62
|
+
code: "invalid_response",
|
|
63
|
+
message: "the answer could not be read",
|
|
64
|
+
details: [],
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
reason: "output.too-large",
|
|
68
|
+
code: "invalid_response",
|
|
69
|
+
message: "the output is over {maxBytes} bytes",
|
|
70
|
+
details: ["maxBytes", "bufferedBytes", "partialOutput"],
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
reason: "output.fields-unavailable",
|
|
74
|
+
code: "invalid_response",
|
|
75
|
+
message: "fields can be picked only from whole JSON values",
|
|
76
|
+
details: [],
|
|
77
|
+
},
|
|
78
|
+
{ reason: "outcome.unknown", code: "outcome_unknown", message: "it is not known whether it worked", details: [] },
|
|
79
|
+
{ reason: "command.cancelled", code: "cancelled", message: "the command was cancelled", details: [] },
|
|
80
|
+
{ reason: CRASH_REASON, code: CRASH_CODE, message: "the command failed; this is a bug", details: [] },
|
|
81
|
+
]);
|
|
82
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/standards/errors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAA;AACzC,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AAC5D,OAAO,EAAE,QAAQ,EAAE,UAAU,EAAE,aAAa,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEvF;;;GAGG;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,gBAAgB,CAAA;AAC1C,MAAM,CAAC,MAAM,YAAY,GAAG,iBAAiB,CAAA;AAE7C,4FAA4F;AAC5F,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,CAAC,YAAY,CAAC;IAC9C,KAAK,EAAE,CAAC,CAAC,YAAY,CAAC;QACpB,IAAI,EAAE,CAAC,CAAC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iB,EAAE,OAAO,EAAE,mCAAmC,EAAE,OAAO,EAAE,EAAE,EAAE;IACjH,EAAE,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,2BAA2B,EAAE,OAAO,EAAE,EAAE,EAAE;IACrG,EAAE,MAAM,EAAE,YAAY,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,mCAAmC,EAAE,OAAO,EAAE,EAAE,EAAE;CACtG,CAAC,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BASE_REASONS, COMMON_DETAILS, CRASH_CODE, CRASH_REASON, defineReasons, type ErrorObject, type ErrorReason, errorObjectSchema, } from "./errors.js";
|
|
2
|
+
export { baselineProblems, baselineSchema, defineLintRules, LINT_RULES, LINT_SEVERITIES, type LintRule, type LintSeverity, OVERRIDE_BUDGET, type Override, overridesProblems, overridesSchema, } from "./lint.js";
|
|
3
|
+
export { LOG_SEVERITIES, type LogRecord, type LogSeverity, logRecordSchema } from "./log.js";
|
|
4
|
+
export { defineFieldRules, FIELD_RULES, type FieldRule, type ItemEnvelope, isoTime, itemEnvelopeSchema, type ListEnvelope, listEnvelopeSchema, MAX_NEXT_STEPS, type Meta, type Missing, metaSchema, missingSchema, type NextStep, nextStepSchema, type Page, pageSchema, } from "./output.js";
|
|
5
|
+
export { fill, jsonSchemaOf, RegistryError } from "./registry.js";
|
|
6
|
+
export { defineSteps, SAME_COMMAND, STEPS, type StepDefinition, type StepInput, stepOf } from "./steps.js";
|
|
7
|
+
export { defineVocabulary, FLAG_TYPES, type FlagType, VOCABULARY, type Vocabulary, type VocabularyFlag, type VocabularyNoun, type VocabularyVerb, vocabularySchema, } from "./vocabulary.js";
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/standards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,EACZ,aAAa,EACb,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,iBAAiB,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EACf,KAAK,QAAQ,EACb,KAAK,YAAY,EACjB,eAAe,EACf,KAAK,QAAQ,EACb,iBAAiB,EACjB,eAAe,GAChB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,cAAc,EAAE,KAAK,SAAS,EAAE,KAAK,WAAW,EAAE,eAAe,EAAE,MAAM,UAAU,CAAA;AAC5F,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,OAAO,EACP,kBAAkB,EAClB,KAAK,YAAY,EACjB,kBAAkB,EAClB,cAAc,EACd,KAAK,IAAI,EACT,KAAK,OAAO,EACZ,UAAU,EACV,aAAa,EACb,KAAK,QAAQ,EACb,cAAc,EACd,KAAK,IAAI,EACT,UAAU,GACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAE,KAAK,cAAc,EAAE,KAAK,SAAS,EAAE,MAAM,EAAE,MAAM,YAAY,CAAA;AAC1G,OAAO,EACL,gBAAgB,EAChB,UAAU,EACV,KAAK,QAAQ,EACb,UAAU,EACV,KAAK,UAAU,EACf,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,gBAAgB,GACjB,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export { BASE_REASONS, COMMON_DETAILS, CRASH_CODE, CRASH_REASON, defineReasons, errorObjectSchema, } from "./errors.js";
|
|
2
|
+
export { baselineProblems, baselineSchema, defineLintRules, LINT_RULES, LINT_SEVERITIES, OVERRIDE_BUDGET, overridesProblems, overridesSchema, } from "./lint.js";
|
|
3
|
+
export { LOG_SEVERITIES, logRecordSchema } from "./log.js";
|
|
4
|
+
export { defineFieldRules, FIELD_RULES, isoTime, itemEnvelopeSchema, listEnvelopeSchema, MAX_NEXT_STEPS, metaSchema, missingSchema, nextStepSchema, pageSchema, } from "./output.js";
|
|
5
|
+
export { fill, jsonSchemaOf, RegistryError } from "./registry.js";
|
|
6
|
+
export { defineSteps, SAME_COMMAND, STEPS, stepOf } from "./steps.js";
|
|
7
|
+
export { defineVocabulary, FLAG_TYPES, VOCABULARY, vocabularySchema, } from "./vocabulary.js";
|
|
8
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/standards/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,YAAY,EACZ,aAAa,EAGb,iBAAiB,GAClB,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,gBAAgB,EAChB,cAAc,EACd,eAAe,EACf,UAAU,EACV,eAAe,EAGf,eAAe,EAEf,iBAAiB,EACjB,eAAe,GAChB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,cAAc,EAAoC,eAAe,EAAE,MAAM,UAAU,CAAA;AAC5F,OAAO,EACL,gBAAgB,EAChB,WAAW,EAGX,OAAO,EACP,kBAAkB,EAElB,kBAAkB,EAClB,cAAc,EAGd,UAAU,EACV,aAAa,EAEb,cAAc,EAEd,UAAU,GACX,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,eAAe,CAAA;AACjE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,KAAK,EAAuC,MAAM,EAAE,MAAM,YAAY,CAAA;AAC1G,OAAO,EACL,gBAAgB,EAChB,UAAU,EAEV,UAAU,EAKV,gBAAgB,GACjB,MAAM,iBAAiB,CAAA"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
export declare const LINT_SEVERITIES: readonly ["high", "medium", "low"];
|
|
3
|
+
declare const lintRuleSchema: v.StrictObjectSchema<{
|
|
4
|
+
readonly id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>;
|
|
5
|
+
readonly severity: v.PicklistSchema<readonly ["high", "medium", "low"], undefined>;
|
|
6
|
+
/** What the rule looks at; a violation's target names one of these. */
|
|
7
|
+
readonly scope: v.PicklistSchema<["command", "group", "argument", "option", "flag"], undefined>;
|
|
8
|
+
readonly summary: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
9
|
+
}, undefined>;
|
|
10
|
+
export type LintRule = v.InferOutput<typeof lintRuleSchema>;
|
|
11
|
+
export type LintSeverity = (typeof LINT_SEVERITIES)[number];
|
|
12
|
+
export declare const defineLintRules: (input: unknown) => LintRule[];
|
|
13
|
+
/** Ids and severities follow the Azure CLI linter (`azdev linter`): a rule is named after what it finds. */
|
|
14
|
+
export declare const LINT_RULES: LintRule[];
|
|
15
|
+
/** `lint/baseline/<rule-id>.json`: today's violations of one rule, by target. It may only shrink. */
|
|
16
|
+
export declare const baselineSchema: v.ArraySchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, undefined>;
|
|
17
|
+
/** `lint/overrides.json`: permanent exceptions, each with its reason, counted against a budget. */
|
|
18
|
+
export declare const overridesSchema: v.ArraySchema<v.StrictObjectSchema<{
|
|
19
|
+
readonly rule: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "a lower-case word, words joined by -">]>;
|
|
20
|
+
readonly target: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
21
|
+
readonly reason: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>, v.MinLengthAction<string, 10, "say why, in a sentence">]>;
|
|
22
|
+
}, undefined>, undefined>;
|
|
23
|
+
export type Override = v.InferOutput<typeof overridesSchema>[number];
|
|
24
|
+
/** What the schemas cannot say, so they stay convertible to JSON Schema: no entry twice. */
|
|
25
|
+
export declare const baselineProblems: (targets: readonly string[]) => string[];
|
|
26
|
+
export declare const overridesProblems: (entries: readonly Override[]) => string[];
|
|
27
|
+
export declare const OVERRIDE_BUDGET = 10;
|
|
28
|
+
export {};
|
|
29
|
+
//# sourceMappingURL=lint.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.d.ts","sourceRoot":"","sources":["../../src/standards/lint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAG5B,eAAO,MAAM,eAAe,YAAI,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAU,CAAA;AAEjE,QAAA,MAAM,cAAc;;;IAGlB,uEAAuE;;;aAGvE,CAAA;AAEF,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,cAAc,CAAC,CAAA;AAC3D,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;AAE3D,eAAO,MAAM,eAAe,UAAW,OAAO,KAAG,QAAQ,EAGtD,CAAA;AAEH,4GAA4G;AAC5G,eAAO,MAAM,UAAU,EAAE,QAAQ,EAyC/B,CAAA;AAEF,qGAAqG;AACrG,eAAO,MAAM,cAAc,8HAAgB,CAAA;AAE3C,mGAAmG;AACnG,eAAO,MAAM,eAAe;;;;yBAE3B,CAAA;AAED,MAAM,MAAM,QAAQ,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,eAAe,CAAC,CAAC,MAAM,CAAC,CAAA;AAEpE,4FAA4F;AAC5F,eAAO,MAAM,gBAAgB,YAAa,SAAS,MAAM,EAAE,KAAG,MAAM,EACA,CAAA;AAEpE,eAAO,MAAM,iBAAiB,YAAa,SAAS,QAAQ,EAAE,KAAG,MAAM,EACyC,CAAA;AAEhH,eAAO,MAAM,eAAe,KAAK,CAAA"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { duplicates, parseRegistry, text, word } from "./registry.js";
|
|
3
|
+
export const LINT_SEVERITIES = ["high", "medium", "low"];
|
|
4
|
+
const lintRuleSchema = v.strictObject({
|
|
5
|
+
id: word,
|
|
6
|
+
severity: v.picklist(LINT_SEVERITIES),
|
|
7
|
+
/** What the rule looks at; a violation's target names one of these. */
|
|
8
|
+
scope: v.picklist(["command", "group", "argument", "option", "flag"]),
|
|
9
|
+
summary: text,
|
|
10
|
+
});
|
|
11
|
+
export const defineLintRules = (input) => parseRegistry("lint rules", v.array(lintRuleSchema), input, (rules) => duplicates(rules.map((rule) => rule.id)).map((id) => `"${id}" is listed twice`));
|
|
12
|
+
/** Ids and severities follow the Azure CLI linter (`azdev linter`): a rule is named after what it finds. */
|
|
13
|
+
export const LINT_RULES = defineLintRules([
|
|
14
|
+
{
|
|
15
|
+
id: "unknown-verb",
|
|
16
|
+
severity: "high",
|
|
17
|
+
scope: "command",
|
|
18
|
+
summary: "a command's last word is a verb or view noun from the vocabulary; a top-level one may be a root word; under search, a resource or all",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
id: "unknown-resource",
|
|
22
|
+
severity: "medium",
|
|
23
|
+
scope: "group",
|
|
24
|
+
summary: "a group is a resource from the vocabulary (plural, or a registered singular) or a root word",
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
id: "flag-two-meanings",
|
|
28
|
+
severity: "high",
|
|
29
|
+
scope: "flag",
|
|
30
|
+
summary: "a flag takes the same kind of value in every command, and the one the vocabulary gives it",
|
|
31
|
+
},
|
|
32
|
+
{ id: "missing-command-help", severity: "high", scope: "command", summary: "every command has a summary" },
|
|
33
|
+
{
|
|
34
|
+
id: "command-help-too-long",
|
|
35
|
+
severity: "low",
|
|
36
|
+
scope: "command",
|
|
37
|
+
summary: "a summary is at most 80 characters",
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
id: "command-example-count",
|
|
41
|
+
severity: "medium",
|
|
42
|
+
scope: "command",
|
|
43
|
+
summary: "a leaf command has one to three examples; generated commands are exempt",
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
id: "faulty-help-example-parameters",
|
|
47
|
+
severity: "high",
|
|
48
|
+
scope: "command",
|
|
49
|
+
summary: "an example starts with the tool, runs its own command, and gives only arguments and options it takes",
|
|
50
|
+
},
|
|
51
|
+
{ id: "missing-argument-help", severity: "high", scope: "argument", summary: "every argument is described" },
|
|
52
|
+
{ id: "missing-option-help", severity: "high", scope: "option", summary: "every option is described" },
|
|
53
|
+
]);
|
|
54
|
+
/** `lint/baseline/<rule-id>.json`: today's violations of one rule, by target. It may only shrink. */
|
|
55
|
+
export const baselineSchema = v.array(text);
|
|
56
|
+
/** `lint/overrides.json`: permanent exceptions, each with its reason, counted against a budget. */
|
|
57
|
+
export const overridesSchema = v.array(v.strictObject({ rule: word, target: text, reason: v.pipe(text, v.minLength(10, "say why, in a sentence")) }));
|
|
58
|
+
/** What the schemas cannot say, so they stay convertible to JSON Schema: no entry twice. */
|
|
59
|
+
export const baselineProblems = (targets) => duplicates(targets).map((target) => `"${target}" is listed twice`);
|
|
60
|
+
export const overridesProblems = (entries) => duplicates(entries.map((entry) => `${entry.rule} ${entry.target}`)).map((both) => `"${both}" is listed twice`);
|
|
61
|
+
export const OVERRIDE_BUDGET = 10;
|
|
62
|
+
//# sourceMappingURL=lint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lint.js","sourceRoot":"","sources":["../../src/standards/lint.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,IAAI,EAAE,IAAI,EAAE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AAG,CAAC,OAA4B,EAAY,EAAE,CAC1E,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,GAAG,KAAK,CAAC,IAAI,IAAI,KAAK,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,IAAI,mBAAmB,CAAC,CAAA;AAEhH,MAAM,CAAC,MAAM,eAAe,GAAG,EAAE,CAAA"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
/** Upper-cased, these are OpenTelemetry's SeverityText values. */
|
|
3
|
+
export declare const LOG_SEVERITIES: readonly ["trace", "debug", "info", "warn", "error", "fatal"];
|
|
4
|
+
/** One log record, OpenTelemetry's field names, one flat JSON line. */
|
|
5
|
+
export declare const logRecordSchema: v.StrictObjectSchema<{
|
|
6
|
+
readonly time: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.IsoTimestampAction<string, "an ISO 8601 time with a zone">]>;
|
|
7
|
+
readonly severity: v.PicklistSchema<readonly ["trace", "debug", "info", "warn", "error", "fatal"], undefined>;
|
|
8
|
+
readonly body: v.StringSchema<undefined>;
|
|
9
|
+
readonly runId: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
10
|
+
/** From an MCP caller's `_meta.traceparent`, when it sent one. */
|
|
11
|
+
readonly traceId: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "32 lower-case hex digits">]>, undefined>;
|
|
12
|
+
readonly command: v.StringSchema<undefined>;
|
|
13
|
+
readonly attributes: v.RecordSchema<v.StringSchema<undefined>, v.UnknownSchema, undefined>;
|
|
14
|
+
readonly resource: v.StrictObjectSchema<{
|
|
15
|
+
readonly service: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
16
|
+
readonly version: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.RegexAction<string, "must not be empty">]>;
|
|
17
|
+
}, undefined>;
|
|
18
|
+
}, undefined>;
|
|
19
|
+
export type LogRecord = v.InferOutput<typeof logRecordSchema>;
|
|
20
|
+
export type LogSeverity = (typeof LOG_SEVERITIES)[number];
|
|
21
|
+
//# sourceMappingURL=log.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.d.ts","sourceRoot":"","sources":["../../src/standards/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAI5B,kEAAkE;AAClE,eAAO,MAAM,cAAc,YAAI,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAU,CAAA;AAE3F,uEAAuE;AACvE,eAAO,MAAM,eAAe;;;;;IAK1B,kEAAkE;;;;;;;;aAKlE,CAAA;AAEF,MAAM,MAAM,SAAS,GAAG,CAAC,CAAC,WAAW,CAAC,OAAO,eAAe,CAAC,CAAA;AAC7D,MAAM,MAAM,WAAW,GAAG,CAAC,OAAO,cAAc,CAAC,CAAC,MAAM,CAAC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import * as v from "valibot";
|
|
2
|
+
import { isoTime } from "./output.js";
|
|
3
|
+
import { text } from "./registry.js";
|
|
4
|
+
/** Upper-cased, these are OpenTelemetry's SeverityText values. */
|
|
5
|
+
export const LOG_SEVERITIES = ["trace", "debug", "info", "warn", "error", "fatal"];
|
|
6
|
+
/** One log record, OpenTelemetry's field names, one flat JSON line. */
|
|
7
|
+
export const logRecordSchema = v.strictObject({
|
|
8
|
+
time: isoTime,
|
|
9
|
+
severity: v.picklist(LOG_SEVERITIES),
|
|
10
|
+
body: v.string(),
|
|
11
|
+
runId: text,
|
|
12
|
+
/** From an MCP caller's `_meta.traceparent`, when it sent one. */
|
|
13
|
+
traceId: v.optional(v.pipe(v.string(), v.regex(/^[0-9a-f]{32}$/, "32 lower-case hex digits"))),
|
|
14
|
+
command: v.string(),
|
|
15
|
+
attributes: v.record(v.string(), v.unknown()),
|
|
16
|
+
resource: v.strictObject({ service: text, version: text }),
|
|
17
|
+
});
|
|
18
|
+
//# sourceMappingURL=log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"log.js","sourceRoot":"","sources":["../../src/standards/log.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAA;AAEpC,kEAAkE;AAClE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,CAAU,CAAA;AAE3F,uEAAuE;AACvE,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAC,YAAY,CAAC;IAC5C,IAAI,EAAE,OAAO;IACb,QAAQ,EAAE,CAAC,CAAC,QAAQ,CAAC,cAAc,CAAC;IACpC,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE;IAChB,KAAK,EAAE,IAAI;IACX,kEAAkE;IAClE,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,gBAAgB,EAAE,0BAA0B,CAAC,CAAC,CAAC;IAC9F,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE;IACnB,UAAU,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC,OAAO,EAAE,CAAC;IAC7C,QAAQ,EAAE,CAAC,CAAC,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;CAC3D,CAAC,CAAA"}
|