Repository navigation
feat(lint): readable multi-line output with context and category icons - #2
Merged
Merged
Conversation
The default lint output is now a rustc-style report: a header per finding with severity and category icons, the location (file:line:col), the surrounding source lines with the offending call underlined, and a copy-pasteable @openshell directive under "= help:". Findings are grouped by file and end with a summary by severity and category. - new flags: --format human|json|compact, --color auto|always|never, --no-icons (alias --ascii). --json stays as an alias of --format json. - compact reproduces the old one-line format byte for byte, json is unchanged (new Finding fields are not serialized); exit codes and --deny-warnings are independent of the format. - colour honours NO_COLOR and CLICOLOR_FORCE; icons fall back to ASCII for non-UTF-8 locales and TERM=dumb. - ast sites now carry a column span; no new dependencies. - README, developer guide and the AI skill document the formats (agents should parse --format compact); generated CLI docs refreshed. Signed-off-by: Ilan Harel <[email protected]>
ilanh
added a commit
that referenced
this pull request
Nov 2, 2026
## What `scan`, `diff-logs` and the `generate` summary get the same readable treatment as `lint` (PR #2): multi-line grouped output, `file:line` with a source snippet, category icons, counts and colour. - **scan**: directives grouped by file, each with its icon (🌐 net, 📁 fs, 🔑 env, ⚙️ exec, 📝 directive), reason, `--> file:line` and the source line. Footer: `✔ 8 directives in 4 files` and counts by category. - **diff-logs**: sections by action (missing directives, binary not covered, L7 rules too narrow, manual review, 🧹 stale, declined, not actionable). Each fix is previewed as an inserted `+` line above the line `--write` would use (with the file's own comment leader), plus `= why:` / `= where:` / `= add:`. Footer counts suggestions and names the follow-up `--write` command. - **generate**: the policy YAML on stdout / `-o FILE` is byte-identical for every format. The readable summary goes to **stderr**: rules with endpoints, access, binaries and the `file:line` they came from, filesystem roots, providers (and unmapped), process, wrapped warnings. ## Flags (shared with lint) `--format human|json|compact` (default `human`), `--color auto|always|never` (honours `NO_COLOR`, `CLICOLOR_FORCE`, `TERM=dumb`; for `generate` the colour decision follows stderr), `--no-icons` / `--ascii` (also automatic for non-UTF-8 locales). - `--format compact` is the previous output, byte for byte (checked against the old binary for scan and diff-logs, and for generate's stderr). - `--json` stays an alias for `--format json` (conflicts with `--format`). `generate --format json` prints a JSON summary on stderr. - Exit codes do not depend on the format. ## Other - `src/render.rs` (new) holds the three renderers; `report.rs` only exposes a few helpers. - Docs: README section with samples, `docs/CLI.md` regenerated, `AGENTS.md` note; the AI skill now uses `--format compact` for `scan` and `diff-logs` (parsing). - Separate commit: fixes the clippy `needless_late_init` hit by the newer stable toolchain in `src/directive.rs` (pre-existing on main). ## Checks - `TOOLCHAIN=1.94 scripts/ci-local.sh` passes (fmt, clippy -D warnings, 46 integration tests + unit + docs tests, docs check); `cargo +stable clippy --all-targets -- -D warnings` clean. - New tests: plain and colour snapshots (`tests/golden`) for scan, diff-logs and generate summary; byte-identical policy for every format and with `-o`; compact/json stability; colour and ASCII flag/env matrix for all three commands. - Fixtures repo (no sandbox): 116 pass / 0 fail, identical to the run with the previous binary. --------- Signed-off-by: Ilan Harel <[email protected]> Co-authored-by: Ilan Harel <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
lintnow prints a rustc/miette-style report instead of one line per finding: severity + category icons in the header,file:line:col, the surrounding source with the offending call underlined, a copy-pasteable@openshelldirective under= help:(with the right comment leader for the language),= note:where useful, findings grouped by file and a summary by severity and category.Flags
--format human|json|compacthumanis the new default.compactis the old one-line format, byte for byte.jsonis unchanged.--jsonstays as an alias of--format json--color auto|always|neverauto= terminal only; honoursNO_COLOR,CLICOLOR_FORCE,TERM=dumb. The flag wins over the environment--no-icons(alias--ascii)TERM=dumbIcons
Compatibility
--format compact(identical to the old output, including thelint: N directive(s); ...line on stderr) or--format json. The AI skill and the docs now say so.Findingfields areserde(skip)); exit codes and--deny-warningsare unchanged for every format. The fixtures suite (116 checks) passes unmodified against the new binary.src/report.rs), socargo auditis unaffected.Before
After
full report (icons, no colour)
Tests
tests/golden/,UPDATE_GOLDEN=1rewrites them), icon and ASCII fallback matrix, colour flag/env matrix, JSON/compact stability and exit codes across formats, windowing of long lines, tabs and multibyte text, policy findings, a usage-message case, plus 4 unit tests inreport.rs.--format compact.TOOLCHAIN=1.94 scripts/ci-local.shpasses: fmt, clippy-D warnings, tests, docs check.