Skip to content

feat(cli): --include-pages adds crawled pages with status and rule count to the JSON report #1260 - #1325

Closed
nc9 wants to merge 2 commits into
mainfrom
feat/json-pages-1260
Closed

nc9 wants to merge 2 commits into
mainfrom
feat/json-pages-1260

Conversation

@nc9

@nc9 nc9 commented Oct 30, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #1260 (the pages list; executedRules stays open, see below)

Opt-in pages list in the JSON report, per the decision on the issue (Nik, 2026-10-29): off by default, fields url, status, ruleCount, capped with a truncated marker beyond a documented limit, report schema minor version bump, docs.

What changed

  • squirrel audit -f json --include-pages and squirrel report -f json --include-pages: pages: [{ url, status, ruleCount }], plus pagesTotal and pagesTruncated. Without the flag the report has none of the three keys, so existing consumers and size are unchanged.
  • ruleCount = distinct rules with at least one non-skipped check stored under the page (one indexed GROUP BY in SQLiteStorage.getRuleCountsByPage, no checks materialized; site-scope results are not counted). Computed when the report is rebuilt from the store, so report --include-pages gives the same numbers.
  • Cap: JSON_REPORT_PAGES.maxEntries = 2000 in core-contracts limits.ts (about 200 KB worst case). One over the cap: 2000 entries, pagesTotal the real count, pagesTruncated: true.
  • Schema version: the JSON report had no schema version, so this adds meta.schemaVersion: "1.1" to every JSON report (1.1 = the version that added pages; a report without it reads as 1.0). That one field is the only change to a default report; please confirm that is what "minor version bump" meant.
  • Other formats ignore the flag and say so on stderr; report --input has no pages to read back and says so (same pattern as --include-passed).
  • Flag in bash, zsh and fish completions for audit and report.

Not in this PR (the issue's wider ACs)

The issue body also asked for finalUrl, outcome (ok, http-error, rate-limited, error, skipped) with a reason, and a top-level executedRules. The recorded decision narrowed pages[] to url, status, ruleCount, so those are not built; the AC checkboxes for them stay unticked. Pages with no stored response (connection error, a 5xx that survived retries, rate-limited) are not pages in the store and are not listed; I observed a 500 from the test site absent from the list, and the docs say so. If outcomes for those are still wanted, that is a follow-up (they are only known as crawl stats, not per URL).

Tests

  • packages/report/tests/json-pages-1260.test.ts: off by default, rows, empty crawl, at the limit vs one over, no extra row fields, schemaVersion.
  • apps/cli/tests/cli/audit-include-pages-e2e.test.ts: real CLI against a local site (ok pages and a 404): audit lists statuses and a positive ruleCount, report --include-pages reads the same list from the store, no flag means no pages key, a non-JSON format warns and still prints.
  • Also run: report suite (scripts/test-suites.ts --run report, 1032 pass), cli report, json, include-passed, reconstruct and completion tests, cli lint, format:check and tsgo, tsgo on report and crawler, make validate.
  • Not run: the full cli and rules suites, a 2,000-plus-page real crawl (the cap is covered by the renderer test). Local Bun is 1.4.3, not the pinned 1.4.0.

Docs: docs/cli/audit.mdx (flag row, "Pages list"), docs/cli/report.mdx, docs/configuration/output.mdx (schema and versioning). Skill: no change needed.

Review round

Per-page rule counts are now computed only for --include-pages (a flag on reconstructReport, plumbed from audit and report; a test asserts a default report never calls getRuleCountsByPage). I did not add an index: with the flag only, the GROUP BY cost applies to the opt-in run. The split JSDoc is fixed.

nc9 added 2 commits October 30, 2026 20:44
…unt to the JSON report; meta.schemaVersion 1.1 #1260

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9

nc9 commented Oct 30, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.144 as 46410d79 b3594dab via #1356. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.144. Closing this original.

nik

@nc9 nc9 closed this Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JSON report: list crawled pages with their HTTP outcome and the rules that ran

1 participant