@blundergoat/gruff-ts 0.3.2 → 0.4.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/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## v0.4.0 - 2026-06-11
4
+
5
+ - **Circular imports group by SCC** - `design.circular-import` reports one finding per strongly connected component (member list in `metadata.files`); circular-import fingerprints and hook identities intentionally churn (ADR-015). OpenUI dropped from 108 findings to 3.
6
+ - **Cycles stay visible in scoped scans** - narrow path scans build root graph context for the circular rule only, and changed-region and hook runs keep a cycle when any member file changed.
7
+ - **Scan-surface notes** - reports gain an additive `notes` field: `no-analysable-files` for paths with nothing analysable, `bounded-deep-scan` for huge files that keep text rules but skip deep passes. Notes name their file; diagnostics still own exit 2.
8
+ - **Generated-source policy** - explicit generation markers (`@generated`, `DO NOT EDIT`, ...) suppress documentation and naming findings only; every other pillar still runs.
9
+ - **Real TypeScript parse diagnostics** - the TypeScript syntax parser replaces the delimiter heuristic, so valid TSX no longer false-positives and real syntax errors keep exit 2.
10
+ - **Sensitive-data precision** - exempts word-segment identifiers, character-set alphabets, code-expression env values, Luhn digit runs without card vocabulary, and explicit fake markers (`EXAMPLE`, `REDACTED`, ...); real secrets still flag.
11
+ - **Security and test-quality tuning** - `security.sql-concatenation` covers `prepare(...)`, validation-only publish gates stop flagging `security.risky-lifecycle-script`, `security.process-exec` carries `callName`/`argumentSource`/`shellEnabled` hints, and static-import test sentinels downgrade to review guidance.
12
+ - **`dead-code.unused-private-method`** - bare `this.method` references count as usage; unrelated properties sharing the name no longer mask an unused private method.
13
+ - **Execution-level rule gating** - rules disabled by config or profile now skip their scanner passes instead of filtering findings afterwards, and the comment-quality gate no longer silently disables `docs.fixture-purpose-missing`.
14
+ - **Hook efficiency** - changed-region hook runs reuse one analysis pass; the diff/since new-only replay stays a second pass and materializes every SCC member, so pre-existing cycles are not reported as new. vscode-scale repos still need the minimal profile.
15
+
3
16
  ## v0.3.2 - 2026-06-09
4
17
 
5
18
  - **Agent-hook contract v1** - adds `gruff-ts hook` and `gruff-ts hook --capabilities --format=json`, advertising `gruff.hook.v1` with `flagOrder:"any"`. Hook JSON uses the cross-analyzer contract fields (`file`, `scope`, `suppressed.count`, `ignored.paths`, `config.error`) with non-null remediation, stable hook identities, and machine-readable threshold metadata. Hook mode exits `0` when analysis runs, omits file/project-scope findings under changed-region attribution, and uses stable identity for baseline/diff new-only filtering (`--diff unstaged` compares against the index, `suppressed.count` never double-counts a re-emitted finding, and distinct project-scope findings such as separate import cycles anchored to one file keep distinct identities so baselining one never suppresses another). Operational failures (missing/malformed baseline, `--diff`/`--since` outside a git repo) report in-band as `config.error` with exit `2` rather than crashing. The conformance tests cover capabilities, scopes/enums, remediation, threshold metadata, stable identity across line/value changes (including multiple same-rule findings in one file and distinct import cycles sharing an anchor file), baseline and diff new-only, operational-failure JSON, flag ordering, advisory exit, ignored paths, and config-error JSON. Existing `analyse` / `summary` / `report` schema versions and exit semantics are unchanged. (`src/hook-contract.ts`, `src/cli-program.ts`, `src/hook-contract.test.ts`)
@@ -47,7 +47,7 @@ npx gruff-ts analyse --changed-ranges "12-40,88-90" src/foo.ts --fail-on=warning
47
47
  git diff | npx gruff-ts analyse --diff - --fail-on=warning
48
48
  ```
49
49
 
50
- Changed-region scans keep only findings attributable to the changed hunk or its enclosing symbol, so the agent fixes its own work instead of inheriting the whole backlog. In `hook` mode, whole-file metrics such as `size.file-length` are omitted under changed-region attribution and counted in `suppressed.count`; they return only in full-scan hook output or when `--baseline` / `--diff` shows their stable identity is new. In `analyse`, use `--changed-scope file` for CI jobs that intentionally want every finding from a touched file.
50
+ Changed-region scans keep only findings attributable to the changed hunk, its enclosing symbol, or a project relationship that includes the requested file, so the agent fixes its own work instead of inheriting the whole backlog. In `hook` mode, whole-file metrics such as `size.file-length` are omitted under changed-region attribution and counted in `suppressed.count`; they return only in full-scan hook output or when `--baseline` / `--diff` shows their stable identity is new. Circular-import findings can appear as project-scope findings when the requested file participates in the SCC; they keep the canonical SCC anchor rather than re-anchoring to the edited file. In `analyse`, use `--changed-scope file` for CI jobs that intentionally want every finding from a touched file.
51
51
 
52
52
  ## Respect the project's ignore policy
53
53
 
@@ -133,6 +133,21 @@ gruff-ts check-ignore src/generated-client.ts --format json
133
133
  # [ { "path": "src/generated-client.ts", "ignored": true, "source": "config", "pattern": "src/generated-client.ts" } ]
134
134
  ```
135
135
 
136
+ ## Generated Markers
137
+
138
+ Use `paths.ignore` when a generated or vendored surface should not be scanned at
139
+ all. If the file should stay in the scan, gruff treats a source file as generated
140
+ only when one of these explicit markers appears in the first 10 lines:
141
+ `AUTO-GENERATED`, `@generated`, `GENERATED FILE`, `Code generated`,
142
+ `Generated by`, `DO NOT EDIT`, or `Copied from`.
143
+
144
+ Generated files skip documentation and naming findings only. Security,
145
+ sensitive-data, size, complexity, maintainability, modernisation, and
146
+ test-quality checks still run, so a generated file can still report a leaked
147
+ credential, unsafe execution, or a file-size finding. Path names such as
148
+ `fixtures/`, `testdata/`, or `perf-tests/` do not by themselves suppress any
149
+ rule family.
150
+
136
151
  ## Allowlists
137
152
 
138
153
  `allowlists.acceptedAbbreviations` lowers naming-rule noise for project-specific
@@ -12,6 +12,10 @@ the local dashboard.
12
12
  - `2` when diagnostics were produced, such as missing inputs or parse/config
13
13
  diagnostics.
14
14
 
15
+ Parse diagnostics for TypeScript and JavaScript source use TypeScript's
16
+ syntax-only parser, including TSX and JSX modes by extension. They do not run
17
+ semantic typechecking.
18
+
15
19
  Examples:
16
20
 
17
21
  ```bash
@@ -49,6 +53,23 @@ Schema strings:
49
53
  - `gruff.baseline.v1` for baselines.
50
54
  - `gruff.hotspot.v1` for hotspot output.
51
55
 
56
+ `gruff.analysis.v2` may include an optional `notes` array. Notes are non-fatal:
57
+ they explain scan-surface limits without changing exit codes. `diagnostics`
58
+ still owns exit `2`.
59
+
60
+ Current note types:
61
+
62
+ - `no-analysable-files` - a requested path existed but contributed no supported
63
+ files, usually because ignore rules excluded everything under it.
64
+ - `bounded-deep-scan` - a script file exceeded the deep-scan budget. It still
65
+ counts as analysed and text-level rules still run, but deep TypeScript passes,
66
+ parse diagnostics, and project-graph retention are skipped for that file.
67
+
68
+ The deep-scan budget is `20,000` lines or `2,000,000` UTF-8 bytes, whichever
69
+ limit is hit first. Text output prints notes in a `Notes:` block. JSON reports
70
+ omit `notes` when there are no notes, so ordinary scans keep the same report
71
+ shape.
72
+
52
73
  ## GitHub Actions
53
74
 
54
75
  Use GitHub annotation output in a workflow step:
package/docs/rules.md CHANGED
@@ -18,6 +18,13 @@ Use the CLI when you need machine-readable metadata:
18
18
  gruff-ts list-rules --format=json
19
19
  ```
20
20
 
21
+ Generated source policy: a file whose first 10 lines include an explicit marker
22
+ such as `AUTO-GENERATED`, `@generated`, `Generated by`, `DO NOT EDIT`, or
23
+ `Copied from` skips documentation and naming findings only. All other pillars,
24
+ including security, sensitive-data, size, complexity, and test-quality, still
25
+ run. A path segment such as `fixtures`, `testdata`, or `perf-tests` does not by
26
+ itself suppress any rule family.
27
+
21
28
  ## Pillar Counts
22
29
 
23
30
  - complexity: 2
@@ -39,11 +46,11 @@ gruff-ts list-rules --format=json
39
46
 
40
47
  ## Dead Code
41
48
 
42
- - `dead-code.unused-private-method` (advisory; low confidence): Flags private methods without an apparent same-file call site.
49
+ - `dead-code.unused-private-method` (advisory; low confidence): Flags private methods without an apparent same-file call site. Bare method references (`items.map(this.double)`, `onClick={this.handler}`) count as usage. Low confidence by design - tests, decorators, framework hooks, and reflection can still reach a method invisibly. Pre-existing scope boundary: `private async`/`private static` declarations and `#name` ECMAScript-private members are not matched by the declaration scan.
43
50
 
44
51
  ## Design
45
52
 
46
- - `design.circular-import` (warning; medium confidence): Flags simple relative import cycles inside the discovered source set.
53
+ - `design.circular-import` (warning; medium confidence): Flags strongly connected relative import components. Each component reports once, anchored on the lexicographically first member path, with sorted member paths and a representative cycle path in metadata. Narrow path scans build root graph context for this rule only, then emit SCCs that include a requested file; per-file rules and `paths.analysedFiles` remain scoped to the requested paths.
47
54
  - `design.deep-relative-import` (advisory; medium confidence; threshold 2): Flags relative imports that climb too many parent directories.
48
55
  - `design.large-module-concentration` (advisory; medium confidence; threshold 55; options: minFiles, minLines): Flags a production module that dominates project source lines.
49
56
  - `design.package-bin-missing` (warning; high confidence): Flags package bin entries that point at missing files.
@@ -119,11 +126,11 @@ gruff-ts list-rules --format=json
119
126
  - `security.new-function` (error; high confidence): Flags Function constructor dynamic code execution.
120
127
  - `security.open-redirect-candidate` (warning; medium confidence): Flags external input sent to redirect or navigation sinks.
121
128
  - `security.path-traversal-candidate` (warning; medium confidence): Flags external input sent to filesystem path sinks.
122
- - `security.process-exec` (warning; high confidence): Flags child-process execution calls.
129
+ - `security.process-exec` (warning; high confidence): Flags child-process execution calls and annotates emitted findings with command-source and shell-mode hints.
123
130
  - `security.proto-access` (warning; medium confidence): Flags direct __proto__ access that can enable prototype pollution.
124
131
  - `security.remote-install-script` (error; medium confidence): Flags package scripts that pipe remote content to a shell.
125
- - `security.risky-lifecycle-script` (warning; medium confidence): Flags package lifecycle scripts that run automatically.
126
- - `security.sql-concatenation` (warning; high confidence): Flags SQL text composed with runtime string interpolation.
132
+ - `security.risky-lifecycle-script` (warning; medium confidence): Flags install-time and side-effectful publish lifecycle scripts while allowing validation-only publish gates.
133
+ - `security.sql-concatenation` (warning; high confidence): Flags SQL text composed with runtime interpolation or concatenation in `query`, `execute`, `raw`, or `prepare` calls. Parameterized value placeholders stay quiet, but unknown runtime identifier interpolation such as table prefixes remains visible unless a project proves and documents a trusted source. The scanner is line-local and does not inspect multi-line SQL templates.
127
134
  - `security.ssrf-candidate` (warning; medium confidence): Flags external input sent to network request sinks.
128
135
  - `security.string-timer` (warning; high confidence): Flags string callbacks passed to timers.
129
136
  - `security.throw-non-error` (warning; medium confidence): Flags thrown non-Error values.
@@ -134,15 +141,17 @@ gruff-ts list-rules --format=json
134
141
 
135
142
  ## Sensitive Data
136
143
 
144
+ Pattern detectors (AWS keys, API keys, credential URLs, JWTs) skip values carrying explicit fake markers inside the matched value itself (`EXAMPLE`, `REDACTED`, `PLACEHOLDER`, `CHANGEME`, or masked `****`/`XXXX` runs) - the canonical AWS documentation keys end in `EXAMPLE`. A test or fixture file path alone never suppresses a production-shaped secret.
145
+
137
146
  - `sensitive-data.api-key-pattern` (error; high confidence): Flags vendor API key patterns including GitHub, GitLab, npm, Google API, Slack, Discord, and Stripe/OpenAI-style keys.
138
147
  - `sensitive-data.aws-access-key` (error; high confidence): Flags AWS access key looking values.
139
148
  - `sensitive-data.database-url-password` (error; high confidence): Flags database and HTTP(S) URLs that include passwords or embedded credentials.
140
149
  - `sensitive-data.gcp-service-account-key` (error; high confidence): Flags GCP service-account key files (type service_account alongside a private key).
141
- - `sensitive-data.hardcoded-env-value` (error; medium confidence; threshold 16): Flags environment-style secret values committed in text.
142
- - `sensitive-data.high-entropy-string` (error; medium confidence; threshold 32): Flags high-entropy string literals that may be secrets.
150
+ - `sensitive-data.hardcoded-env-value` (error; medium confidence; threshold 16): Flags environment-style secret values committed in text. In script files (TS/JS) only quoted values count: an unquoted right-hand side is a code expression (schema builder, secret-provider plumbing), not an embedded literal.
151
+ - `sensitive-data.high-entropy-string` (error; medium confidence; threshold 32): Flags high-entropy string literals that may be secrets. Identifier-shaped values that decompose entirely into short dictionary-like word segments (dotted namespaces such as `Com.Example2.Services.TokenProvider`, underscored constants, slug-like catalog names) are exempt because credential alphabets interleave case and digits rather than forming words; JWTs and 20+ char mixed-case segments never earn the exemption. Character-set enumerations (a 10+ run of consecutive code points, e.g. base64 translation alphabets) are also exempt.
143
152
  - `sensitive-data.jwt-token` (error; high confidence): Flags JWT-looking token literals.
144
153
  - `sensitive-data.phi-pattern` (error; high confidence): Flags PHI identifiers such as Medicare (MBI) and medical record numbers.
145
- - `sensitive-data.pii-pattern` (error; high confidence): Flags PII-like identifier patterns including SSN-shaped values and Luhn-valid payment cards.
154
+ - `sensitive-data.pii-pattern` (error; high confidence): Flags PII-like identifier patterns including SSN-shaped values and Luhn-valid payment cards. A bare unseparated digit run additionally needs card vocabulary on its line (statistics can pass Luhn by coincidence); separator-grouped numbers flag without context.
146
155
  - `sensitive-data.private-key` (error; high confidence): Flags private key block markers.
147
156
 
148
157
  ## Size
@@ -164,7 +173,7 @@ gruff-ts list-rules --format=json
164
173
  - `test-quality.only-skip` (advisory; high confidence): Flags focused or skipped test markers.
165
174
  - `test-quality.sleep-in-test` (advisory; high confidence): Flags sleeps in tests.
166
175
  - `test-quality.snapshot-only-test` (advisory; high confidence): Flags tests that rely only on snapshots.
167
- - `test-quality.static-analysis-redundant-test` (advisory; high confidence): Flags tests that primarily assert code shape rather than behavior.
176
+ - `test-quality.static-analysis-redundant-test` (advisory; high confidence): Flags tests that primarily assert code shape rather than behavior, with review guidance for importability sentinels.
168
177
  - `test-quality.trivial-assertion` (warning; high confidence): Flags tautological assertions.
169
178
  - `test-quality.unused-mock` (advisory; medium confidence): Flags mocks created but not used.
170
179
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blundergoat/gruff-ts",
3
- "version": "0.3.2",
3
+ "version": "0.4.0",
4
4
  "description": "Governs AI-generated code so a human can verify it: a TypeScript/JavaScript static analyzer - 120 rules across 11 quality pillars, SARIF output, baselines, and a local dashboard.",
5
5
  "license": "MIT",
6
6
  "author": "Matthew Hansen (https://www.blundergoat.com/about)",