@taskless/cli 0.11.0 → 0.11.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,106 @@
1
+ /**
2
+ * Public entry for `@taskless/cli/schemas`.
3
+ *
4
+ * The shapes this CLI's `--json` output is produced from, as data. A consumer
5
+ * parsing `taskless verify --json` validates against the schema the CLI emits
6
+ * from, rather than against an interface it hand-wrote by reading our output
7
+ * once.
8
+ *
9
+ * ## Why this is published
10
+ *
11
+ * This is `@taskless/cli/layout`'s argument applied to the other half of the
12
+ * contract. A hand-written interface is a copy that nothing checks: the CLI can
13
+ * add a field, change what one means, or extend an enum, and the copy stays
14
+ * confidently wrong until something downstream misbehaves. The Cloud eval team
15
+ * is doing exactly that today against the `verify` envelope.
16
+ *
17
+ * ## What this is NOT
18
+ *
19
+ * Not an SDK. Nothing here performs verification, and no `verify()` or `test()`
20
+ * is exported. Both spawn a vendored platform binary — ast-grep or Vale — so
21
+ * anywhere a function call could run them, `npx @taskless/cli verify --json`
22
+ * runs too: the export would buy a call site, not a capability, while making
23
+ * internal signatures public. The CLI stays the execution surface; this
24
+ * describes what it says.
25
+ *
26
+ * Nothing here reaches the filesystem, a process, the network or the command
27
+ * tree, so a Worker can import it — and the build fails rather than emitting an
28
+ * entry whose graph reaches a host capability. `writeJsonError` is deliberately
29
+ * absent for that reason: it writes to stdout, and a consumer asking what shape
30
+ * an error takes should not thereby acquire something that emits one.
31
+ *
32
+ * ## Zod is bundled, and that is the point
33
+ *
34
+ * This entry ships its own copy of zod rather than resolving the consumer's.
35
+ * That follows from the build's standing rule for library entries — everything
36
+ * but node builtins is bundled — but it is also the behaviour we want, so do
37
+ * not "fix" it by making zod external.
38
+ *
39
+ * **A consumer's zod is not ours.** Marking it external would make validation
40
+ * depend on whichever version resolved on the other side, so the same payload
41
+ * could parse there and not here, and the schema would stop being a statement
42
+ * about what this CLI emits. Bundling makes `parse()` answer with our zod's
43
+ * semantics wherever it runs.
44
+ *
45
+ * **And `parse()` is stronger than a JSON Schema of the same shape.** It
46
+ * strips: `parse({ ok: true, rules: [], surprise: 1 })` returns
47
+ * `{ ok: true, rules: [] }`, where a JSON Schema validator hands back the
48
+ * object it was given, unknown keys included. Every schema here is plain today
49
+ * — objects, enums, arrays, optionals — so a JSON Schema rendering would lose
50
+ * little beyond that. It is the moment we add a refinement that the difference
51
+ * bites, and it would bite silently: the rendering would go on validating a
52
+ * weaker shape while claiming to describe this one.
53
+ *
54
+ * `z.toJSONSchema()` therefore stays unexported, and the criterion is the
55
+ * TRANSPORT rather than the consumer's language. JSON Schema is what you reach
56
+ * for when the schema itself has to travel — when the far side can receive JSON
57
+ * and nothing else, so a description of the shape is the most that fits. That
58
+ * is not this boundary. A consumer here takes a dependency on our schema files,
59
+ * which means it can assert the payload rather than assert against a
60
+ * description of the payload, and rendering ours down to what a JSON transport
61
+ * could carry would give that up in exchange for nothing.
62
+ */
63
+ export {
64
+ /**
65
+ * `taskless verify --json` and `taskless test --json`.
66
+ *
67
+ * One envelope for both, because the commands share an implementation and
68
+ * differ only in what they run against each rule.
69
+ */
70
+ outputSchema as verifyTestOutputSchema, } from "./verify-test.js";
71
+ export {
72
+ /**
73
+ * The layered detail behind one ast-grep rule's verification — schema
74
+ * validation, Taskless requirement checks, and `sg test`, kept separate
75
+ * rather than flattened into `verifyTestOutputSchema`'s single envelope.
76
+ *
77
+ * Not what `taskless verify --json` or `taskless test --json` print. Both
78
+ * commands compute this internally via `verifyRule()` and then flatten it
79
+ * before printing anything, so there is no current CLI invocation that
80
+ * emits this shape verbatim. A command that did — `taskless rule verify
81
+ * <id> --json` — existed once and was removed when rule addressing moved
82
+ * from id to path, because an id can name a rule under two engines and a
83
+ * path cannot (see `resolve-path.ts`). This schema describes the pre-
84
+ * flattening detail that command used to print, unchanged since.
85
+ */
86
+ verifyOutputSchema,
87
+ /** The same, for a Vale rule — a different shape, discriminated on `engine`. */
88
+ valeVerifyOutputSchema, } from "./rules-verify.js";
89
+ export type {
90
+ /**
91
+ * A constraint `verify` or `test` enforces beyond an engine's own schema.
92
+ *
93
+ * The type of the entries in `@taskless/cli/reference.json`'s
94
+ * `constraints[]`, so a consumer reading the corpus and a consumer reading a
95
+ * rejection are working from one definition.
96
+ */
97
+ RuleConstraint,
98
+ /** One constraint a rule broke, as `violations[]` carries it. */
99
+ RuleViolation,
100
+ /** The id of a constraint this CLI publishes. */
101
+ RuleConstraintId, } from "../rules/constraints.js";
102
+ export type {
103
+ /** The stable code an error envelope carries under `--json`. */
104
+ CLIErrorCode,
105
+ /** The envelope itself. Not every `--json` failure is a rule result. */
106
+ CLIErrorEnvelope, } from "../types/errors.js";
@@ -11,6 +11,7 @@ export declare const outputSchema: z.ZodObject<{
11
11
  ruleId: z.ZodString;
12
12
  rules: z.ZodArray<z.ZodString>;
13
13
  files: z.ZodArray<z.ZodString>;
14
+ notices: z.ZodOptional<z.ZodArray<z.ZodString>>;
14
15
  }, z.core.$strip>;
15
16
  /** Error schema for `taskless rule create --json` on failure */
16
17
  export declare const errorSchema: z.ZodObject<{
@@ -14,6 +14,7 @@ export declare const outputSchema: z.ZodObject<{
14
14
  requestId: z.ZodString;
15
15
  rules: z.ZodArray<z.ZodString>;
16
16
  files: z.ZodArray<z.ZodString>;
17
+ notices: z.ZodOptional<z.ZodArray<z.ZodString>>;
17
18
  }, z.core.$strip>;
18
19
  /** Error schema for `taskless rule improve --json` on failure */
19
20
  export declare const errorSchema: z.ZodObject<{
@@ -0,0 +1,67 @@
1
+ import { z } from "zod";
2
+ export declare const schemaOutputSchema: z.ZodObject<{
3
+ astGrepSchema: z.ZodRecord<z.ZodString, z.ZodUnknown>;
4
+ tasklessRequirements: z.ZodObject<{
5
+ requiredFields: z.ZodArray<z.ZodString>;
6
+ rules: z.ZodArray<z.ZodObject<{
7
+ name: z.ZodString;
8
+ description: z.ZodString;
9
+ }, z.core.$strip>>;
10
+ }, z.core.$strip>;
11
+ examples: z.ZodArray<z.ZodObject<{
12
+ description: z.ZodString;
13
+ rule: z.ZodRecord<z.ZodString, z.ZodUnknown>;
14
+ }, z.core.$strip>>;
15
+ }, z.core.$strip>;
16
+ export declare const verifyOutputSchema: z.ZodObject<{
17
+ engine: z.ZodLiteral<"sg">;
18
+ success: z.ZodBoolean;
19
+ ruleId: z.ZodString;
20
+ schema: z.ZodObject<{
21
+ valid: z.ZodBoolean;
22
+ errors: z.ZodArray<z.ZodString>;
23
+ notice: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>;
25
+ requirements: z.ZodObject<{
26
+ valid: z.ZodBoolean;
27
+ errors: z.ZodArray<z.ZodString>;
28
+ }, z.core.$strip>;
29
+ tests: z.ZodObject<{
30
+ valid: z.ZodBoolean;
31
+ errors: z.ZodArray<z.ZodString>;
32
+ passed: z.ZodNumber;
33
+ failed: z.ZodNumber;
34
+ }, z.core.$strip>;
35
+ }, z.core.$strip>;
36
+ /**
37
+ * Vale verification output.
38
+ *
39
+ * Deliberately not squeezed into the ast-grep shape. `sg` verification is three
40
+ * layers over a rule file and its test cases; Vale verification is one question
41
+ * asked of two fixture buckets — did every `fail/` document fire, did every
42
+ * `pass/` document stay quiet. Mapping the second onto `schema`/`requirements`/
43
+ * `tests` would invent two empty layers and lose the fixture coverage, which is
44
+ * the part that catches a rule that was never really verified.
45
+ *
46
+ * `engine` is the discriminant. A consumer branches on it before reading
47
+ * anything else, and adding an engine cannot silently change the meaning of a
48
+ * field another engine already emits.
49
+ */
50
+ export declare const valeVerifyOutputSchema: z.ZodObject<{
51
+ engine: z.ZodLiteral<"vale">;
52
+ success: z.ZodBoolean;
53
+ ruleId: z.ZodString;
54
+ fixtures: z.ZodEnum<{
55
+ both: "both";
56
+ "pass-only": "pass-only";
57
+ "fail-only": "fail-only";
58
+ none: "none";
59
+ }>;
60
+ missingFailures: z.ZodArray<z.ZodString>;
61
+ unexpectedFindings: z.ZodArray<z.ZodString>;
62
+ notice: z.ZodOptional<z.ZodString>;
63
+ }, z.core.$strip>;
64
+ export declare const verifyErrorSchema: z.ZodObject<{
65
+ success: z.ZodLiteral<false>;
66
+ error: z.ZodString;
67
+ }, z.core.$strip>;
@@ -0,0 +1,22 @@
1
+ import { z } from "zod";
2
+ /** Output schema for `taskless verify --json` and `taskless test --json`. */
3
+ export declare const outputSchema: z.ZodObject<{
4
+ ok: z.ZodBoolean;
5
+ rules: z.ZodArray<z.ZodObject<{
6
+ engine: z.ZodEnum<{
7
+ sg: "sg";
8
+ vale: "vale";
9
+ runtime: "runtime";
10
+ }>;
11
+ ruleId: z.ZodString;
12
+ ok: z.ZodBoolean;
13
+ errors: z.ZodArray<z.ZodString>;
14
+ violations: z.ZodArray<z.ZodObject<{
15
+ constraintId: z.ZodString;
16
+ message: z.ZodString;
17
+ }, z.core.$strip>>;
18
+ ran: z.ZodOptional<z.ZodBoolean>;
19
+ refused: z.ZodOptional<z.ZodString>;
20
+ notice: z.ZodOptional<z.ZodString>;
21
+ }, z.core.$strip>>;
22
+ }, z.core.$strip>;