@blundergoat/gruff-ts 0.1.0 → 0.2.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.
Files changed (45) hide show
  1. package/CHANGELOG.md +35 -11
  2. package/CONTRIBUTING.md +3 -3
  3. package/README.md +141 -183
  4. package/docs/README.md +23 -0
  5. package/docs/ci-integration.md +63 -0
  6. package/docs/{CONFIGURATION.md → configuration.md} +41 -20
  7. package/docs/dashboard.md +36 -0
  8. package/docs/output-formats.md +65 -0
  9. package/docs/{RELEASING.md → releasing.md} +17 -14
  10. package/docs/{REPORTS_AND_CI.md → reports-and-ci.md} +5 -2
  11. package/docs/rules.md +177 -0
  12. package/package.json +2 -2
  13. package/scripts/bump-version.sh +83 -18
  14. package/scripts/dependency-install.sh +96 -0
  15. package/scripts/dependency-update.sh +177 -0
  16. package/scripts/preflight-checks.sh +38 -0
  17. package/src/analyser.ts +9 -24
  18. package/src/blocks.ts +66 -12
  19. package/src/class-rules.ts +5 -6
  20. package/src/cli-program.ts +216 -39
  21. package/src/cli.ts +4 -1
  22. package/src/comment-rules.ts +2 -0
  23. package/src/config-load-error.ts +18 -0
  24. package/src/config-preservation.ts +64 -0
  25. package/src/config.ts +155 -29
  26. package/src/constants.ts +10 -2
  27. package/src/dashboard.ts +1 -1
  28. package/src/dead-code-rules.ts +62 -16
  29. package/src/doc-rules.ts +3 -3
  30. package/src/findings-helpers.ts +17 -0
  31. package/src/init-config.ts +308 -0
  32. package/src/line-rules.ts +64 -12
  33. package/src/naming-pushers.ts +7 -32
  34. package/src/pillar-summary.ts +129 -0
  35. package/src/project-config-rules.ts +1 -1
  36. package/src/report-html.ts +404 -0
  37. package/src/report-renderers.ts +210 -406
  38. package/src/rule-list.ts +65 -1
  39. package/src/rules.ts +36 -37
  40. package/src/safety-rules.ts +9 -4
  41. package/src/scoring.ts +41 -9
  42. package/src/test-block-rules.ts +43 -1
  43. package/src/test-fixtures.ts +13 -7
  44. package/src/text-scans.ts +1 -152
  45. package/src/types.ts +32 -6
package/CHANGELOG.md CHANGED
@@ -1,16 +1,40 @@
1
1
  # Changelog
2
2
 
3
- ## [0.1.0] - 2026-05-23
3
+ ## v0.2.0 - 2026-05-28
4
+
5
+ Cross-format Pillars table, per-command gating defaults, JSON schema bumps (`v1` → `v2`), exported-doc rule split, a rule-precision sweep, config schema-versioning, and a code-review sweep against PR #4 feedback. Cut as a pre-1.0 minor bump because the cumulative rule-emission changes (new exported-doc surface, tightened naming/test-quality exemptions, schemaVersion requirement) materially shift findings for downstream consumers.
6
+
7
+ - **Per-command gating + schemaVersion contract** - `analyse` and `summary` default `--fail-on` flips from `error` to `advisory`; CI gates using the defaults go from "fail on errors only" to "fail on anything." New `minimumSeverity:` block in `.gruff-ts.yaml` pins per-command thresholds (`analyse / summary / report`) with precedence CLI flag > config > binary default; `dashboard` is rejected as a key because it has no `--fail-on` flag. `.gruff-ts.yaml` now requires `schemaVersion: gruff-ts.config.v0.1` at the top - pre-1.0 hard break, no transitional shim. Run `npx gruff-ts init --force` to migrate; the regenerated config preserves `paths.ignore` and `minimumSeverity`. (ADR-004, `src/config.ts`, `src/cli-program.ts`)
8
+ - **Cross-format Pillars table** - Canonical 7-column table (`Pillar | Grade | Score | Findings | Advisory | Warning | Error`) renders byte-aligned across `text`, `json`, `html`, and `markdown`, sorted `findings DESC` then `pillar ASC`. Clean pillars render as `A/100` rows so the column layout stays stable run-to-run; cross-port consumers can diff byte-for-byte. (`src/pillar-summary.ts`, `src/report-renderers.ts`, `src/report-html.ts`)
9
+ - **JSON schema bumps `v1` → `v2`** - `summary --format=json` emits `gruff.summary.v2`; the flat `{pillar, count}` per-pillar array is replaced with a richer shape carrying `grade`, `score`, `penalty`, `applicable`, `findings`, `advisory`, `warning`, `error`. `analyse` / `report --format=json` emit `gruff.analysis.v2`; `score.pillars[]` entries gain a `penalty: number` field, and the SARIF `runs[0].properties.gruffSchemaVersion` plus the JSON `schemaVersion` tag move in lockstep. Downstream consumers must gate on the `schemaVersion` field before decoding.
10
+ - **Public-API doc gate** - `docs.missing-function-doc` (advisory) is split into `docs.missing-exported-function-doc` (**warning**) and `docs.missing-internal-function-doc` (advisory). The warning variant fires on `export function`, `export const f = () => ...`, `export default function`, and locally-declared functions re-exported via `export { foo }` or `export default foo`; `export { foo } from "./other"` re-export-from clauses are correctly skipped via negative lookahead so a same-named local stays internal. Class methods of exported classes are intentionally treated as internal (advisory) by this release; enclosing-class scope tracking is deferred. Any `.gruff-ts.yaml` override targeting the old rule ID must be updated. (M04, `src/blocks.ts`, `src/doc-rules.ts`)
11
+ - **Summary readability + rule explain mode** - Per-severity grade breakdown under the composite (`Errors: A (0)`, `Warnings: D (276)`, `Advisory: F (1367)`) tells you whether an F composite is driven by errors or by a long tail of advisories; three grade pills in HTML. `summary` Top-N rule rows now show per-severity split and one-line descriptions: `- <ruleId>: <total> (<err> err / <warn> warn / <adv> adv) - <description>`; a `Tip:` line points at `summary --top=20` when `analyse` produces 50+ findings. `gruff-ts list-rules <ruleId>` accepts a positional argument and prints per-rule detail (text or JSON) with `Config keys:`, `Options:`, and `Allowlists:` blocks. Every tunable rule's `remediation` text now names its override knob (`rules.<id>.threshold`, `rules.<id>.severity`, allowlist keys) so the configuration surface is one greppable string away from any finding. (M05-M08)
12
+ - **Rule-precision sweep** - `naming.short-variable` exempts single-character `for (const X of Y)` bindings whose body is ≤ 10 lines (and only those; classic `for (let i = 0; ...)` and `for (const k in obj)` stay covered). `test-quality.loop-in-test` recognises fixture loops (literal-array iterable or `Object.entries|keys|values(literal)`, no conditional bodies, last meaningful statement is an assertion) and suppresses the finding for them. `waste.swallowed-catch` accepts six additional rationale comments: `/* ignore */`, `/* ignored */`, `/* cleanup */`, `/* teardown */`, `/* noop */`, `/* no-op */`. `waste.unreachable-code` no longer fires on the unconditional return after a braceless `if`/`while`/`for` with a multi-line predicate. Nine imperative-flag verbs added to default `booleanPrefixes` (`check`, `skip`, `enable`, `allow`, `include`, `exclude`, `with`, `without`, `omit`); `fn` and `cb` added to default `acceptedAbbreviations`. (M01-M03)
13
+ - **Severity-only rule overrides accepted** - `rules.<id>.severity: warning` now loads without requiring `threshold`, fixing the validator that previously blocked any severity tweak on rules with no `threshold` knob (security, naming, docs, etc.) even though `gruff-ts list-rules` advertised the override. Each field is independently optional. (`src/config.ts:assertRuleThresholdConfig`)
14
+ - **Graceful CLI config errors** - Malformed `.gruff-ts.yaml`, missing `--config <path>`, and syntax errors in `.gruff.json` produce a formatted `gruff-ts: config error\n ...\nSuggested fix: ...` message and exit code 2; raw `ENOENT` / `SyntaxError` no longer leak through as Node stack traces. `init --force` over pre-schemaVersion configs preserves `paths.ignore` and `minimumSeverity` via a new permissive reader (`src/config-preservation.ts`), so existing curated entries survive the schemaVersion migration. (`src/cli-program.ts:runWithConfigErrorHandling`, `src/config.ts:parseConfigFile`, `src/init-config.ts`)
15
+ - **Release tooling** - `scripts/bump-version.sh --check` verifies `CHANGELOG.md`'s most-recent version heading agrees with `package.json` / `package-lock.json` / `src/constants.ts`; the preflight gate's `Version consistency` step uses it. The awk regex skips non-version headings (e.g. `## [Unreleased]`-style entries from third-party Keep-a-Changelog projects).
16
+ - **Regression coverage** - FP-#12 through FP-#45 added to `src/false-positive-fixes.test.ts`, covering every rule-precision change above plus negative regression guards. The PR #4 review sweep added FP-#33b through FP-#33e for re-export detection, the C-style for / for-in regression cases under `naming-rules.test.ts`, the pre-schemaVersion preservation regression in `src/init-config.test.ts`, and the dedicated `src/config-preservation.test.ts` suite. M06 / M08 land their tests in `src/rule-catalogue.test.ts` and `src/cli-surfaces.test.ts` respectively; M10-M12 add parser-rejection tests in `src/project-config-rules.test.ts`. M09 (informational tier) was deleted as a no-signal milestone.
17
+ - **Cross-port harmony** - `minimumSeverity:` dimension aligns with the gruff family (`gruff-go` / `gruff-rs` / `gruff-py` / `gruff-php` should track). Off-switch value is `none` (not `never`) per the noun-position re-evaluation; the verb-shaped `failOn: never` was the prior cross-port draft, the noun-shaped `minimumSeverity: none` is the family-wide decision.
18
+
19
+ ## v0.1.1 - 2026-05-24
20
+
21
+ Onboarding flow, machine-readable summaries, and a `waste` → `maintainability` pillar rename. Catalogue is now 119 rules across 11 pillars.
22
+
23
+ - **Pillar rename `waste` → `maintainability`** - The pillar tag attached to every finding from a `waste.*` rule changed; rule IDs themselves keep their `waste.` prefix (so `waste.console-log` still fires as `waste.console-log`, only its pillar attribute moves). Text/JSON/SARIF parsers, dashboard nav, and the `Pillar` TypeScript union in `src/types.ts` must update.
24
+ - **Removed rules and config keys** - `docs.todo-density` and `naming.abbreviation` (both opt-in advisories) removed, along with the now-unused `allowlists.abbreviationDenylist` config key; stale config entries are silently ignored so existing `.gruff-ts.yaml` files keep loading. Consumers relying on either rule for CI gating lose that signal.
25
+ - **`gruff-ts init`** - Writes the default `.gruff-ts.yaml`, refusing to overwrite any supported config name without `--force` (which preserves existing `paths.ignore` entries). `analyse`, `summary`, `report`, and `dashboard` auto-prompt for `init` when no config is found, gated by `--no-interaction`, `--silent`/`--quiet`, and TTY checks so it never fires in CI.
26
+ - **Machine-readable summaries** - `summary --format=json` emits the new `gruff.summary.v1` schema; `summary --top <n>` controls digest size; a baseline status line surfaces source and suppression count. `dashboard --project-root <path>` sets the default scan root.
27
+ - **Docs index + audit gate** - New `docs/README.md` index plus `ci-integration.md`, `dashboard.md`, `output-formats.md`, `rules.md`; CI now runs `npm audit --audit-level=moderate`.
28
+ - **CLI input rejection + async exits** - `summary` and `list-rules` reject unsupported `--format` values via Commander instead of coercing to `text`; CLI switched to `parseAsync` so async handler rejections exit with the correct code.
29
+ - **Top-offender + flag-knowledge fixes** - `summary --top <n>` controls file-offender count beyond 10. `gruff.analysis.v1` `score.topOffenders` is now the full sorted file list (was capped at 10); HTML report and `--format=hotspot` still cap their own output at 10 rows. `init --force` help text now reflects that it also overrides the refusal triggered by non-canonical configs (`.gruff.yaml`/`.yml`/`.json`). `--top` added to the known-CLI-flag list so comments documenting it no longer trip `docs.stale-comment`.
30
+ - **Doc filename normalisation** - `CONFIGURATION.md` → `configuration.md`, `RELEASING.md` → `releasing.md`, `REPORTS_AND_CI.md` → `reports-and-ci.md`.
31
+
32
+ ## v0.1.0 - 2026-05-23
4
33
 
5
34
  Initial public release of the `@blundergoat/gruff-ts` npm package.
6
35
 
7
- - TypeScript/JavaScript code quality scanner: 121 rules across 11 pillars
8
- (complexity, dead-code, design, documentation, modernisation, naming,
9
- security, sensitive-data, size, test-quality, waste).
10
- - CLI commands: `analyse`, `summary`, `report`, `list-rules`, `dashboard`,
11
- `completion`.
12
- - Output formats: `text`, `json`, `html`, `markdown`, `github`, `hotspot`,
13
- `sarif`. Stable schemas: `gruff.analysis.v1`, `gruff.baseline.v1`,
14
- `gruff.hotspot.v1`.
15
- - Baselines via stable per-finding fingerprints, `--diff` for changed-file
16
- scans, local dashboard on `127.0.0.1:8767`. Released under MIT.
36
+ - **TypeScript/JavaScript code-quality scanner** - 121 rules across 11 pillars: complexity, dead-code, design, documentation, maintainability, modernisation, naming, security, sensitive-data, size, test-quality.
37
+ - **CLI commands** - `analyse`, `summary`, `report`, `list-rules`, `dashboard`, `completion`.
38
+ - **Output formats** - `text`, `json`, `html`, `markdown`, `github`, `hotspot`, `sarif`. Stable schemas: `gruff.analysis.v1`, `gruff.baseline.v1`, `gruff.hotspot.v1`.
39
+ - **Baselines and diff scans** - Stable per-finding fingerprints; `--diff` for changed-file scans against the prior baseline. Local dashboard on `127.0.0.1:8767`.
40
+ - **License** - Released under MIT.
package/CONTRIBUTING.md CHANGED
@@ -68,9 +68,9 @@ Update docs when behavior changes:
68
68
 
69
69
  - `README.md` for user-facing workflow changes.
70
70
  - `CHANGELOG.md` for release-visible changes.
71
- - `docs/CONFIGURATION.md` for config shape or threshold changes.
72
- - `docs/REPORTS_AND_CI.md` for output, CI, dashboard, or baseline changes.
73
- - `docs/RELEASING.md` for release process changes.
71
+ - `docs/configuration.md` for config shape or threshold changes.
72
+ - `docs/reports-and-ci.md` for output, CI, dashboard, or baseline changes.
73
+ - `docs/releasing.md` for release process changes.
74
74
 
75
75
  ## Pull Request Checklist
76
76
 
package/README.md CHANGED
@@ -1,23 +1,38 @@
1
1
  # gruff-ts
2
2
 
3
- `gruff-ts` is a static analyzer for TypeScript and JavaScript projects. The
4
- dependency-light Node.js CLI scans source, tests, package metadata, and
5
- common config files, then reports quality findings across 11 pillars with
6
- stable fingerprints for baselines and repeatable machine output.
3
+ `gruff-ts` is an opinionated static analyser for TypeScript and JavaScript projects. The dependency-light Node.js CLI scans source, tests, package metadata, and common config files, then emits reports for terminals, CI annotations, SARIF consumers, static HTML, and a local dashboard. It is heuristic static analysis; run it beside `tsc`, ESLint, tests, dependency scanners, and code review, not instead of them.
7
4
 
8
- The 0.1.0 release ships 121 rules across 11 pillars,
9
- JSON/HTML/Markdown/GitHub/SARIF/hotspot output, baseline support, changed-file
10
- filtering, local score history, a rule catalogue, and a dark local dashboard.
11
- Scanned file types include TypeScript, JavaScript, CSS, JSON, YAML, TOML, INI,
12
- XML, and `.env*`.
5
+ ## Status At A Glance
6
+
7
+ | Field | Value |
8
+ | --- | --- |
9
+ | Release line | Published `0.2.0` package line |
10
+ | Runtime | Node.js `22+` |
11
+ | Package | `@blundergoat/gruff-ts` |
12
+ | Binary | `gruff-ts` |
13
+ | Rule catalogue | 119 rules across 11 pillars |
14
+ | Primary config | `.gruff-ts.yaml`; `.gruff.json`, `.gruff.yaml`, and `.gruff.yml` are fallback files |
15
+ | Analysis schema | `gruff.analysis.v2` |
16
+ | Baseline schema | `gruff.baseline.v1` |
17
+ | Severity gate | `--fail-on` with `none`, `advisory`, `warning`, `error` |
18
+ | Dashboard | `127.0.0.1:8767` by default |
19
+
20
+ Scanned file types include TypeScript, JavaScript, CSS, JSON, YAML, TOML, INI, XML, and `.env*`.
21
+
22
+ ## Requirements
23
+
24
+ - Node.js `22+`, matching [`package.json`](package.json).
25
+ - npm for source-checkout development.
26
+ - Git only for diff modes.
13
27
 
14
28
  ## Install
15
29
 
16
- Install the scoped npm package; it exposes the `gruff-ts` CLI command:
30
+ Install as a project dev dependency:
17
31
 
18
32
  ```bash
19
33
  npm install --save-dev @blundergoat/gruff-ts
20
- npx gruff-ts analyse . --fail-on=none
34
+ npx gruff-ts init
35
+ npx gruff-ts summary
21
36
  ```
22
37
 
23
38
  From this checkout:
@@ -29,170 +44,90 @@ npm install
29
44
 
30
45
  ## Quick Start
31
46
 
32
- Run an exploratory scan without failing the shell on findings:
33
-
34
47
  ```bash
35
- gruff-ts analyse . --fail-on=none
36
- ```
48
+ # Create the project config.
49
+ npx gruff-ts init
37
50
 
38
- Scan specific paths:
51
+ # Review the current finding mix.
52
+ npx gruff-ts summary
39
53
 
40
- ```bash
41
- gruff-ts analyse src fixtures/sample.ts --fail-on=none
42
- ```
54
+ # Explore without failing because of findings.
55
+ npx gruff-ts analyse . --fail-on=none
43
56
 
44
- Generate a static HTML report:
57
+ # Gate on warning and error findings.
58
+ npx gruff-ts analyse . --fail-on=warning
45
59
 
46
- ```bash
47
- gruff-ts report . --output gruff-report.html
48
- ```
60
+ # Emit SARIF for code scanning.
61
+ npx gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
49
62
 
50
- Start the local dashboard:
63
+ # Generate a fresh-start baseline.
64
+ npx gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
51
65
 
52
- ```bash
53
- gruff-ts dashboard
66
+ # Start the local dashboard.
67
+ npx gruff-ts dashboard
54
68
  ```
55
69
 
56
- The dashboard binds to `127.0.0.1:8767` by default.
57
-
58
- ## What It Checks
59
-
60
- Findings are grouped into 11 public pillars:
61
-
62
- - `size`
63
- - `complexity`
64
- - `dead-code`
65
- - `waste`
66
- - `naming`
67
- - `documentation`
68
- - `modernisation`
69
- - `security`
70
- - `sensitive-data`
71
- - `test-quality`
72
- - `design`
73
-
74
- Inspect the exact rule ids, severities, confidence levels, remediation text,
75
- threshold values, and options:
76
-
77
- ```bash
78
- gruff-ts list-rules
79
- gruff-ts list-rules --format=json
80
- ```
70
+ Open `http://127.0.0.1:8767/` for the dashboard.
81
71
 
82
72
  ## Commands
83
73
 
84
74
  | Command | Purpose |
85
75
  | --- | --- |
86
- | `analyse [paths...]` | Run the scanner and print findings. |
87
- | `summary [paths...]` | Print per-pillar counts, top rules, and top file offenders without per-finding output. |
88
- | `report [paths...]` | Render an HTML or JSON report, optionally to a file. |
89
- | `list-rules` | Print rule catalogue metadata. |
90
- | `dashboard` | Serve the local HTTP dashboard. |
76
+ | `analyse [paths...]` | Run the analyser and print findings. |
77
+ | `summary [paths...]` | Print compact score, pillar, rule, and file summaries. |
78
+ | `report [paths...]` | Render an HTML or JSON report to stdout or `--output`. |
79
+ | `init` | Write the default `.gruff-ts.yaml` to the current directory (`--force` to overwrite). |
80
+ | `list-rules` | Print rule metadata as text or JSON. |
81
+ | `dashboard` | Serve the local browser dashboard. |
91
82
  | `completion [shell]` | Print a shell completion script for `bash`, `zsh`, or `fish`. |
92
- | `list` | Print the Symfony-style command catalogue. |
93
-
94
- Useful help commands:
95
-
96
- ```bash
97
- gruff-ts --help
98
- gruff-ts list
99
- gruff-ts analyse --help
100
- gruff-ts summary --help
101
- gruff-ts report --help
102
- gruff-ts dashboard --help
103
- ```
83
+ | `list`, `help` | Show command lists and command-specific help. |
104
84
 
105
- Global console options match the `gruff` PHP CLI surface: `--silent`,
106
- `--quiet`, `--ansi` / `--no-ansi`, `--no-interaction`, and `-v` / `-vv` /
107
- `-vvv`. The command menu uses the same ANSI colour treatment as `gruff` when
108
- stdout is a TTY; `--ansi` forces colour and `--no-ansi` disables it.
85
+ Global console options match the broader gruff CLI surface: `--silent`, `--quiet`, `--ansi` / `--no-ansi`, `--no-interaction`, and `-v` / `-vv` / `-vvv`.
109
86
 
110
87
  ## Output Formats
111
88
 
112
- `analyse` supports:
89
+ `analyse --format <fmt>` accepts:
113
90
 
114
- | Format | Use case |
91
+ | Format | Use it for |
115
92
  | --- | --- |
116
93
  | `text` | Human terminal output. |
117
- | `json` | Full machine-readable `gruff.analysis.v1` report. |
118
- | `html` | Self-contained dark inspection report. |
119
- | `markdown` | Short Markdown summary. |
120
- | `github` | GitHub Actions annotation commands. |
121
- | `hotspot` | Compact `gruff.hotspot.v1` top-offender payload. |
122
- | `sarif` | SARIF 2.1.0 code-scanning output. |
123
-
124
- Examples:
125
-
126
- ```bash
127
- gruff-ts analyse . --format=json --fail-on=none
128
- gruff-ts analyse . --format=github --fail-on=warning
129
- gruff-ts analyse . --format=hotspot --fail-on=none
130
- gruff-ts analyse . --format=sarif --fail-on=none > gruff.sarif
131
- ```
132
-
133
- `report` supports `html` and `json`:
134
-
135
- ```bash
136
- gruff-ts report . --format=json --output gruff-report.json
137
- ```
138
-
139
- ## CI
140
-
141
- `analyse` defaults to `--fail-on error`.
142
-
143
- ```bash
144
- # Exploratory scan: never fail because of findings.
145
- gruff-ts analyse . --fail-on=none
146
-
147
- # CI gate only on error findings.
148
- gruff-ts analyse . --fail-on=error
149
-
150
- # Stricter CI gate on warnings and errors.
151
- gruff-ts analyse . --fail-on=warning
152
- ```
94
+ | `json` | Full `gruff.analysis.v2` report. |
95
+ | `html` | Self-contained inspection report. |
96
+ | `markdown` | Pull-request or issue comment summary. |
97
+ | `github` | GitHub Actions workflow annotations. |
98
+ | `hotspot` | `gruff.hotspot.v1` file-offender JSON. |
99
+ | `sarif` | SARIF 2.1.0 for code scanning. |
153
100
 
154
- Exit codes:
101
+ `report --format <fmt>` accepts `html` and `json`.
155
102
 
156
- - `0`: scan completed and no finding met `--fail-on`.
157
- - `1`: scan completed and at least one finding met `--fail-on`.
158
- - `2`: scan produced diagnostics such as missing inputs or parse/config errors.
103
+ ## Exit Codes
159
104
 
160
- Changed-file scans:
105
+ | Code | Meaning |
106
+ | --- | --- |
107
+ | `0` | Run completed and no finding met `--fail-on`. |
108
+ | `1` | At least one finding met `--fail-on`. |
109
+ | `2` | Fatal diagnostic such as missing input, parse error, config error, diff failure, baseline failure, or invalid input. |
161
110
 
162
- ```bash
163
- gruff-ts analyse . --diff=working-tree --format=github --fail-on=warning
164
- gruff-ts analyse . --diff=staged --format=json --fail-on=none
165
- ```
111
+ `analyse` and `summary` default to `--fail-on advisory`; `report` defaults to `--fail-on none`. The defaults can be overridden per-project by a `minimumSeverity:` block in `.gruff-ts.yaml`. CLI flag wins over config; config wins over the binary default. See ADR-004 and the Configuration section.
166
112
 
167
- `--diff` accepts `working-tree`, `staged`, `unstaged`, or a base ref.
113
+ ## CI Usage
168
114
 
169
- Security-focused CI can run without baseline suppression so new error-severity
170
- security or sensitive-data findings cannot be hidden by an adoption baseline:
115
+ Generic CI command:
171
116
 
172
117
  ```bash
173
- gruff-ts analyse . --no-baseline --fail-on=error
118
+ npx gruff-ts analyse . --format=github --fail-on=warning
174
119
  ```
175
120
 
176
- ## Baselines And History
177
-
178
- Baselines suppress existing findings by stable fingerprint so teams can adopt
179
- the tool without fixing every current issue first.
121
+ SARIF jobs can write an artifact for code scanning:
180
122
 
181
123
  ```bash
182
- gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
183
- gruff-ts analyse . --baseline gruff-baseline.json --fail-on=warning
184
- gruff-ts analyse . --no-baseline --fail-on=none
124
+ npx gruff-ts analyse . --format=sarif --fail-on=none > gruff-ts.sarif
185
125
  ```
186
126
 
187
- Baseline files use `schemaVersion: "gruff.baseline.v1"`.
188
-
189
- `report` is intended for raw inspection output and does not accept
190
- `--baseline`; use `analyse` when you need baseline suppression in CI.
191
-
192
- Append local score history:
127
+ Security-focused gates can bypass adoption baselines:
193
128
 
194
129
  ```bash
195
- gruff-ts analyse . --history-file .gruff-history.json --fail-on=none
130
+ npx gruff-ts analyse . --no-baseline --fail-on=error
196
131
  ```
197
132
 
198
133
  ## Configuration
@@ -204,18 +139,7 @@ gruff-ts analyse . --history-file .gruff-history.json --fail-on=none
204
139
  3. `.gruff.yaml`
205
140
  4. `.gruff.yml`
206
141
 
207
- Use an explicit config or skip config loading:
208
-
209
- ```bash
210
- gruff-ts analyse . --config .gruff-ts.yaml
211
- gruff-ts analyse . --no-config
212
- ```
213
-
214
- Recursive scans respect root and nested `.gitignore` files. Use
215
- `--include-ignored` to include default and Git-ignored paths for a run;
216
- `paths.ignore` entries still apply as project policy.
217
-
218
- Minimal YAML example:
142
+ Use `--config <path>` for an explicit file or `--no-config` to skip config loading. Recursive scans respect root and nested `.gitignore` files; `--include-ignored` includes default and Git-ignored paths for one run, but `paths.ignore` entries still apply as project policy.
219
143
 
220
144
  ```yaml
221
145
  paths:
@@ -237,41 +161,74 @@ rules:
237
161
  severity: warning
238
162
  ```
239
163
 
240
- See [Configuration](docs/CONFIGURATION.md) for the full config shape and
241
- examples.
164
+ See [Configuration](docs/configuration.md) for the full config shape.
242
165
 
243
- ## Dashboard
166
+ ## Rules And Pillars
167
+
168
+ The v0.1 catalogue contains 119 rules:
169
+
170
+ | Pillar | Rules |
171
+ | --- | ---: |
172
+ | `complexity` | 3 |
173
+ | `dead-code` | 1 |
174
+ | `design` | 6 |
175
+ | `documentation` | 17 |
176
+ | `maintainability` | 14 |
177
+ | `modernisation` | 14 |
178
+ | `naming` | 10 |
179
+ | `security` | 27 |
180
+ | `sensitive-data` | 8 |
181
+ | `size` | 4 |
182
+ | `test-quality` | 15 |
183
+
184
+ Use `npx gruff-ts list-rules --format=json` for exact rule IDs, severities, confidence levels, remediation text, thresholds, and options.
244
185
 
245
- Start the local dashboard:
186
+ ## Baselines And Changed-Code Scans
187
+
188
+ Baselines suppress reviewed findings by stable fingerprint:
246
189
 
247
190
  ```bash
248
- gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
191
+ npx gruff-ts analyse . --generate-baseline gruff-baseline.json --fail-on=none
192
+ npx gruff-ts analyse . --baseline gruff-baseline.json --fail-on=warning
193
+ npx gruff-ts analyse . --no-baseline --fail-on=none
249
194
  ```
250
195
 
251
- The dashboard serves a local iframe report and a compact controls panel. Keep
252
- the default loopback bind unless the network is trusted. The `/scan` endpoint
253
- analyses filesystem paths from request parameters, so the bind address is the
254
- main safety boundary.
196
+ Changed-file scans use Git only when requested:
255
197
 
256
- ## Safety And Limitations
198
+ ```bash
199
+ npx gruff-ts analyse . --diff=working-tree --format=github --fail-on=warning
200
+ npx gruff-ts analyse . --diff=staged --format=json --fail-on=none
201
+ ```
257
202
 
258
- - Secret-like findings include redacted previews; raw secret values should not
259
- appear in findings or rendered output.
260
- - The scanner is heuristic. It is not a TypeScript compiler, type checker, or
261
- full JavaScript parser.
262
- - Rule confidence is included in the rule catalogue and each finding. Treat low
263
- and medium confidence findings as review prompts.
264
- - Baselines suppress matching fingerprints. Review baseline diffs carefully so
265
- new findings are not hidden by accident.
203
+ `--diff` accepts `working-tree`, `staged`, `unstaged`, or a base ref. `report` renders raw inspection output and does not accept `--baseline`; use `analyse` when baseline suppression matters.
266
204
 
267
- ## Documentation
205
+ ## Dashboard
268
206
 
269
- - [Changelog](CHANGELOG.md)
270
- - [Configuration](docs/CONFIGURATION.md)
271
- - [Reports and CI](docs/REPORTS_AND_CI.md)
272
- - [Contributing](CONTRIBUTING.md)
273
- - [Security](SECURITY.md)
274
- - [Release checklist](docs/RELEASING.md)
207
+ ```bash
208
+ npx gruff-ts dashboard --host 127.0.0.1 --port 8767 --project-root .
209
+ ```
210
+
211
+ The dashboard serves a local iframe report and compact controls panel. It has no authentication; keep the default loopback bind unless the network is trusted. The `/scan` endpoint analyses filesystem paths from request parameters, so the bind address is the main safety boundary.
212
+
213
+ In polyglot repositories, `gruff-ts` defaults to port `8767`, `gruff-rs` defaults to `8766`, and `gruff-go`, `gruff-php`, and `gruff-py` default to `8765`; use `--port` when running multiple dashboards at the same time.
214
+
215
+ ## Trust Boundary
216
+
217
+ Default scans are local source inspections. `gruff-ts` parses supported source, config, and package metadata files; it does not execute target application code, run tests, invoke the TypeScript compiler, query package registries, or read vulnerability feeds. Git is used only for explicit diff modes. Secret-like findings use redacted previews; raw secret values should not appear in terminal, JSON, SARIF, GitHub, Markdown, hotspot, or HTML output.
218
+
219
+ ## Stability Contract
220
+
221
+ The `0.1.x` line treats rule IDs, finding fingerprints, baseline identity, `gruff.analysis.v2`, `gruff.baseline.v1`, `gruff.hotspot.v1`, SARIF rendering, and CLI exit semantics as compatibility-sensitive. Breaking changes should be tagged as a future minor release and recorded in [`CHANGELOG.md`](CHANGELOG.md).
222
+
223
+ ## How It Compares
224
+
225
+ | Tool | Relationship |
226
+ | --- | --- |
227
+ | `tsc` | Type checking. `gruff-ts` does not prove type correctness or replace compiler diagnostics. |
228
+ | ESLint | Rule-driven linting. `gruff-ts` adds scoring, baselines, reports, dashboard, and cross-file/project-quality signals. |
229
+ | Prettier / formatters | Formatting only. `gruff-ts` does not format code. |
230
+ | Knip / ts-prune | Focused unused export/dead-code tools. `gruff-ts` includes broader quality and security-oriented heuristics. |
231
+ | `npm audit` / dependency scanners | Advisory-backed dependency checks. `gruff-ts` reports local static signals and does not replace advisory feeds. |
275
232
 
276
233
  ## Development
277
234
 
@@ -283,16 +240,17 @@ npm run start-dev
283
240
  ./bin/gruff-ts analyse . --fail-on=none
284
241
  ```
285
242
 
286
- Source lives under `src/`: `src/cli.ts` is the thin bootstrap,
287
- `src/cli-program.ts` owns Commander wiring, `src/analyser.ts` orchestrates the
288
- scan, `src/rules.ts` holds the descriptor catalogue, and focused sibling
289
- modules own rule packs and renderers. Tests live in focused `src/*.test.ts`
290
- files.
243
+ Source lives under `src/`: `src/cli.ts` is the bootstrap, `src/cli-program.ts` owns Commander wiring, `src/analyser.ts` orchestrates scans, and focused sibling modules own rules and renderers.
291
244
 
292
- To bump the released version, run `scripts/bump-version.sh <new-version>` - it
293
- updates `package.json` and `src/constants.ts` in lockstep so the CLI
294
- `--version` output stays consistent with the published `@blundergoat/gruff-ts`
295
- package.
245
+ ## Documentation
246
+
247
+ - [Changelog](CHANGELOG.md)
248
+ - [Configuration](docs/configuration.md)
249
+ - [Rules catalogue](docs/rules.md)
250
+ - [Reports and CI](docs/reports-and-ci.md)
251
+ - [Release checklist](docs/releasing.md)
252
+ - [Contributing](CONTRIBUTING.md)
253
+ - [Security](SECURITY.md)
296
254
 
297
255
  ## Author
298
256
 
package/docs/README.md ADDED
@@ -0,0 +1,23 @@
1
+ # gruff-ts docs
2
+
3
+ Use these docs with the top-level README for the stable user-facing surface.
4
+
5
+ ## Core Docs
6
+
7
+ - [Configuration](configuration.md) - config discovery, schema, allowlists, and rule overrides.
8
+ - [Rules](rules.md) - rule IDs, severities, thresholds, and remediation guidance.
9
+ - [Output Formats](output-formats.md) - text, JSON, HTML, Markdown, GitHub annotations, hotspot, and SARIF.
10
+ - [CI Integration](ci-integration.md) - GitHub Actions, SARIF upload, baselines, and diff scans.
11
+ - [Dashboard](dashboard.md) - local dashboard flags and safety model.
12
+ - [Releasing](releasing.md) - release checks and packaging notes.
13
+
14
+ ## Extra Docs
15
+
16
+ - [Reports And CI](reports-and-ci.md) - combined reporting and CI details retained for existing links.
17
+
18
+ ## Shared Contract
19
+
20
+ Cross-language naming and CLI expectations live in
21
+ [`../../CONTRACT.md`](../../CONTRACT.md). TypeScript keeps `summary` analysis
22
+ flags as documented extensions while also supporting the common `--format` and
23
+ `--top` summary surface.
@@ -0,0 +1,63 @@
1
+ # CI Integration
2
+
3
+ gruff-ts is designed to run as a deterministic CI quality gate.
4
+
5
+ ## GitHub Actions
6
+
7
+ ```yaml
8
+ name: gruff-ts
9
+
10
+ on: [push, pull_request]
11
+
12
+ jobs:
13
+ analyse:
14
+ runs-on: ubuntu-latest
15
+ steps:
16
+ - uses: actions/checkout@v4
17
+ - uses: actions/setup-node@v4
18
+ with:
19
+ node-version: "22"
20
+ - run: npm ci
21
+ - run: ./bin/gruff-ts analyse src --format=sarif --fail-on=none > gruff-ts.sarif
22
+ - uses: github/codeql-action/upload-sarif@v3
23
+ with:
24
+ sarif_file: gruff-ts.sarif
25
+ ```
26
+
27
+ ## Quality Gate
28
+
29
+ For blocking jobs, choose the lowest severity that should fail the build:
30
+
31
+ ```sh
32
+ ./bin/gruff-ts analyse src --fail-on=warning
33
+ ```
34
+
35
+ Use `--fail-on=none` when the job should only publish reports.
36
+
37
+ ## Baselines
38
+
39
+ Generate an adoption baseline after reviewing current findings:
40
+
41
+ ```sh
42
+ ./bin/gruff-ts analyse src --generate-baseline gruff-baseline.json --fail-on=none
43
+ ```
44
+
45
+ Future scans auto-apply `gruff-baseline.json` when present. Use
46
+ `--no-baseline` to audit the full unsuppressed result.
47
+
48
+ ## Diff Scans
49
+
50
+ TypeScript supports working-tree, staged, unstaged, and base-ref diff scans:
51
+
52
+ ```sh
53
+ ./bin/gruff-ts analyse src --diff=working-tree --format=github --fail-on=warning
54
+ ./bin/gruff-ts analyse src --diff=origin/main --format=json --fail-on=none
55
+ ```
56
+
57
+ ## Check
58
+
59
+ Run the local TypeScript gate before release:
60
+
61
+ ```sh
62
+ npm run check
63
+ ```