From af249007ace49fa44cab6a6fe60586ed4b62a01f Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sun, 29 Nov 2026 14:17:09 -0800 Subject: [PATCH 1/2] docs(check): document --rule, and summary-then-rule for large repos --- .changeset/check-rule-recipe.md | 5 +++++ packages/cli/src/agent/check.md | 14 +++++++------ packages/cli/test/check-recipe.test.ts | 28 ++++++++++++++++++++++++++ 3 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 .changeset/check-rule-recipe.md create mode 100644 packages/cli/test/check-recipe.test.ts diff --git a/.changeset/check-rule-recipe.md b/.changeset/check-rule-recipe.md new file mode 100644 index 000000000..2b40d163b --- /dev/null +++ b/.changeset/check-rule-recipe.md @@ -0,0 +1,5 @@ +--- +"@taskless/cli": patch +--- + +The `check` agent recipe (topic v12) now documents `--rule `, which has existed since 0.11.3: it runs only the named rule, repeats (`--rule a --rule b`), and works with `--json` and `--summary`. For a large repository the recipe gives the order to use: `check --json --summary` to see which rules fired and how often, then `check --json --rule ` for one rule's findings, so an agent never has to read or filter every finding to see where one rule fired. diff --git a/packages/cli/src/agent/check.md b/packages/cli/src/agent/check.md index b48c76ba0..9c3c6be9c 100644 --- a/packages/cli/src/agent/check.md +++ b/packages/cli/src/agent/check.md @@ -1,4 +1,4 @@ -# Topic: check (CLI v%(CLI_VERSION)s / topic v11) +# Topic: check (CLI v%(CLI_VERSION)s / topic v12) %(ONE_COMMAND_PER_CALL)s @@ -22,6 +22,8 @@ in CI (diff-only scan), or after rule create/improve to validate. - `--summary`: per-rule counts instead of every finding. With `--json` it omits `results` and keeps `summary`, so the output stays small on any repository. Use it when the question is "how many", not "where". +- `--rule `: run only the named rule (its directory name); + repeatable. Works with `--json` and `--summary`. - `--anonymous`: run only static rules; skip runtime rules. - `--dangerously-run-scripts`: run runtime `check.ts` unverified. - `--timeout `: per-runtime-check wall-clock bound (default 10). @@ -111,11 +113,11 @@ in CI (diff-only scan), or after rule create/improve to validate. only rules that fired, most findings first, keyed by `engine` and `ruleId` as `verify` keys `rules[]`. - **To measure a whole repository, add `--summary`.** `results` can run - to hundreds of kilobytes; `check --json --summary` returns only - `summary`, one entry per rule that fired. Do not count `results` - yourself, and do not read an absent `results` as clean: read - `summary.total`. + **On a large repository, run `check --json --summary` first** to see + which rules fired, then `check --json --rule ` for + one rule's findings. `results` can run to hundreds of kilobytes. Do + not count `results` yourself, and do not read an absent `results` as + clean: read `summary.total`. 4. **Report findings to the user.** Group by `file`. Show `severity`, `message`, and `ruleId` for each finding; the `range.start` is the diff --git a/packages/cli/test/check-recipe.test.ts b/packages/cli/test/check-recipe.test.ts new file mode 100644 index 000000000..6b03c74bd --- /dev/null +++ b/packages/cli/test/check-recipe.test.ts @@ -0,0 +1,28 @@ +import { describe, expect, it } from "vitest"; + +import { getRecipe } from "../src/prompts/recipes"; + +const check = getRecipe("check"); +if (check === undefined) throw new Error("no recipe for check"); + +describe("the check recipe", () => { + it("is topic v12", () => { + expect(check).toMatch(/^# Topic: check {5}\(CLI v.+ \/ topic v12\)/m); + }); + + it("lists --rule among its flags", () => { + const flags = check.slice( + check.indexOf("## Flags"), + check.indexOf("## Steps") + ); + expect(flags).toContain("- `--rule `:"); + expect(flags).toContain("repeatable"); + }); + + it("orders a large repository as summary first, then one rule", () => { + const summary = check.indexOf("run `check --json --summary` first"); + const rule = check.indexOf("`check --json --rule `"); + expect(summary).toBeGreaterThan(-1); + expect(rule).toBeGreaterThan(summary); + }); +}); From 02bb44428593efd426d75ef296299b4f5bda7bbb Mon Sep 17 00:00:00 2001 From: Jakob Heuser Date: Sun, 29 Nov 2026 14:24:27 -0800 Subject: [PATCH 2/2] docs(check): list RULE_NOT_FOUND for an unknown --rule id --- packages/cli/src/agent/check.md | 32 +++++++++++++------------- packages/cli/test/check-recipe.test.ts | 7 ++++++ 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/packages/cli/src/agent/check.md b/packages/cli/src/agent/check.md index 9c3c6be9c..ea2e53c12 100644 --- a/packages/cli/src/agent/check.md +++ b/packages/cli/src/agent/check.md @@ -57,17 +57,15 @@ in CI (diff-only scan), or after rule create/improve to validate. %(TASKLESS_CLI)s check --json src/foo.ts src/deleted.ts ``` Paths that don't exist on disk are skipped, so you can pass every - path `git diff` printed without pre-filtering. The skipped paths - are named in a notice (`notices` under `--json`), so a mistyped - path is visible rather than reading as clean. + path `git diff` printed without pre-filtering. Skipped paths are + named in `notices`, so a mistyped path does not read as clean. - Paths must be inside the project (the working directory, or - `--dir`). A path outside it, existing or not, is refused with - `INVALID_INPUT` and exit 1, and nothing is scanned. Run `check` - from the project that holds the files instead. + A path outside the project (the working directory, or `--dir`), + existing or not, is refused with `INVALID_INPUT` and nothing is + scanned. When runtime rules were present but not run (e.g. logged out), the - JSON also carries `"skipped": [{ "rule": "", "reason": "…" }]` + JSON carries `"skipped": [{ "rule": "", "reason": "…" }]` alongside `success`/`results`. Surface it so CI can tell that runtime rules did not execute. It never affects the exit code on its own; an accompanying `entitlement` with a non-empty `withheld` does (see @@ -114,9 +112,9 @@ in CI (diff-only scan), or after rule create/improve to validate. `ruleId` as `verify` keys `rules[]`. **On a large repository, run `check --json --summary` first** to see - which rules fired, then `check --json --rule ` for - one rule's findings. `results` can run to hundreds of kilobytes. Do - not count `results` yourself, and do not read an absent `results` as + which rules fired, then `check --json --rule ` for one rule's + findings, since `results` can run to hundreds of kilobytes. Do not + count `results` yourself, and do not read an absent `results` as clean: read `summary.total`. 4. **Report findings to the user.** Group by `file`. Show `severity`, @@ -146,16 +144,18 @@ in CI (diff-only scan), or after rule create/improve to validate. - `1`: Errors detected, scan failed, runtime rules withheld because the plan does not include them, an issued ast-grep or Vale rule was edited or copied under a new id, a rule was unaccounted for, two - engines share a rule id, or a supplied path is outside the project + engines share a rule id, a supplied path is outside the project, or a + `--rule` id names no rule ## Errors When `--json` is set, failures emit `{ ok: false, code, message }`: -| code | meaning | fix | -|-----------------|-------------------------------|-------------------------------------------| -| `SCAN_FAILED` | ast-grep scan errored | Report; check rule YAML validity | -| `INVALID_INPUT` | a path is outside the project | Run from the project that holds the files | +| code | meaning | fix | +|------------------|-------------------------------|-------------------------------------------| +| `SCAN_FAILED` | ast-grep scan errored | Report; check rule YAML validity | +| `INVALID_INPUT` | a path is outside the project | Run from the project that holds the files | +| `RULE_NOT_FOUND` | a `--rule` id names no rule | Use the rule's directory name | ## What runs diff --git a/packages/cli/test/check-recipe.test.ts b/packages/cli/test/check-recipe.test.ts index 6b03c74bd..cc16f1098 100644 --- a/packages/cli/test/check-recipe.test.ts +++ b/packages/cli/test/check-recipe.test.ts @@ -25,4 +25,11 @@ describe("the check recipe", () => { expect(summary).toBeGreaterThan(-1); expect(rule).toBeGreaterThan(summary); }); + + it("lists RULE_NOT_FOUND for an unknown --rule id", () => { + const errors = check.slice(check.indexOf("## Errors")); + expect(errors).toContain( + "| `RULE_NOT_FOUND` | a `--rule` id names no rule" + ); + }); });