Skip to content

feat(cli): squirrel pages lists the pages of a stored audit as a table #701 - #1400

Closed
nc9 wants to merge 5 commits into
mainfrom
feat/pages-command-701
Closed

nc9 wants to merge 5 commits into
mainfrom
feat/pages-command-701

Conversation

@nc9

@nc9 nc9 commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Part 1 of #701 (the CLI half; --format html, --diff and the hosted list_pages follow, see below). Refs #701.

squirrel pages prints one row per crawled page of a stored audit, modelled on squirrel entities (same project-scoped store access, --crawl, -f, -o, exit 0 on every answer).

  • Columns: url, finalUrl, status, depth, canonical, noindex, title and length, description and length, h1Count, wordCount, schemaTypes, inlinks, internalOutlinks, externalOutlinks and externalDomains, loadTimeMs, lastModified, flags.
  • Formats: json, csv, markdown; default is a console table of the first 50 rows on a TTY, markdown when piped or -o. CSV is RFC 4180 with the spreadsheet formula guard the entities export has; markdown cells go through escapeMarkdownCell.
  • Filters (combine, all must match): --missing title|description|h1|schema, --duplicate title|description, --too-long (75 / 160, the rules' defaults), --orphan, --section /blog (segment boundary), --page <text>.
  • Flags column from the audit's own rule results, so the table and the issue list agree: core/meta-title, core/meta-description, core/h1, core/title-unique, content/duplicate-title, content/duplicate-description, links/orphan-pages, core/canonical, core/robots-meta, content/word-count, plus the facts noindex and no-schema. --duplicate and --orphan select on those flags.
  • No extra cost: everything is read from the store (pages, page_features, the pages' stored parse for links, rule_results); nothing is fetched. One new storage read, getFlaggedPages, returns only rule id, page and item ids (a page rule's page_url, a duplicate group's items[].sourcePages, an orphan's item id). Link counts come from the stored parse (link_appearances holds external links only), in id batches.
  • Shell completions (bash, zsh, fish), the help listing and docs/cli/pages.mdx (+ nav and CLI index) are in.

Not in this PR, and why

  • --format html (a sortable, filterable table) and --diff <audit>: next PR.
  • Anchor text per link (a separate command, see below).
  • A replayed column for smart re-audits, hosted list_pages (MCP and REST), the row cap and the open questions on the issue: the hosted side is the private repo. Failed pages are included as rows with their status (open question 3, recommended yes); --orphan follows the rule (no internal in-link, not sitemap-only; open question 4).
  • Internal link edge list / squirrel links (from the comment on the issue): a separate command, not started.

Tests: packages/report/tests/page-map-701.test.ts (15: every filter and combination, csv escaping and formula guard, markdown cell escaping, json), packages/crawler/tests/page-map-701.test.ts (2: flagged pages from page and site rules), apps/cli/tests/cli/pages-command-e2e.test.ts (9: real audit of a local site, then json/csv/markdown, each filter, -o, bad flag values, unknown crawl, --crawl), completion tests for all three shells, the help-listing test. Gates: tsgo in apps/cli, packages/report and packages/crawler, cli format:check and lint, make validate, released-changelog guard.

Skill: the squirrelscan agent skill should list squirrel pages (an agent reading a site's titles and links wants it). Needs a private issue with the skills label; I have not filed it.

nik

Security round: every string from an audited page (url, finalUrl, title, description, canonical, schema types, the site name) is cleaned before it reaches a terminal, csv or markdown: cleanText strips C0 and C1 controls (so ESC sequences, OSC 8 hyperlinks and 8-bit CSI are inert), bidi overrides and isolates, and line breaks (one value is one line). csv additionally prefixes a formula start (=, +, -, @, after any whitespace) with an apostrophe. markdown cells and code spans are escaped as before. json keeps the bytes (it escapes them itself). Shared helper stripUnsafeLineText in core-contracts (same text as in #1394, so the two merge cleanly). Tests: report (cleanText, csvSafeText, hostile row through csv, markdown, json), console table (printTable, unparseable URL and escapes in path), and the e2e site now serves a page whose title carries ESC[2J, an OSC 8 hyperlink, a bidi override and a newline and whose description is =cmd|...; csv and markdown contain no control character and csv neutralises the formula.

Review round 2 (independent review)

  • P1 link counts: link targets and each page's own key now use the same normalizeUrl the orphan and internal-link rules use, so a page stored with a trailing slash or a query string gets its in- and out-links (and its self link is not counted). The e2e site now has /b?id=1 and /blog/post/; the test fails (0 instead of 5) without the fix, and asserts the orphan rule does not flag them either.
  • P2 markdown: a pipe in a URL is escaped (urlCell), tested by counting unescaped pipes per row.
  • P2 columns: my earlier claim that H1 text, heading count and JSON-LD @id are not stored per page was wrong; they are in the stored parse. New columns h1, headingCount, schemaIds (first 20), in json, csv and the docs; the false sentence is gone.
  • P2 json: renderPageMapJson writes DEL, C1 controls, bidi overrides, invisible characters and line separators as \uXXXX (lossless, still valid JSON).
  • P3 done: cleanText removes zero-width and tag-block characters (zero-width joiner and non-joiner kept, scripts need them); --missing only judges pages that answered below 400 and were parsed; --section and --page are case-insensitive and match percent-encoded paths (/café); --orphan help and docs say what the rule's minimum is and that a skipped rule flags nothing; -o to an unwritable path is a clean error; more than one --crawl without --diff is a usage error.
  • Not done, listed: flag names title/description still merge missing, short and long (they mirror the rule's one verdict); --too-long keeps the rules' default limits; getFlaggedPages has no index on (crawl_id, rule_id) and scans the crawl's rule results (a schema migration, separate); no streaming for 10k+ page audits; a missing audit prints prose on stdout with exit 0 even for -f json, as squirrel entities does (decision for the maintainer).
  • Shared helper change: stripUnsafeLineText now also removes invisible characters. fix(report): squirrel report --input reads skippedChecks back #518 #1394 carries the earlier text of the same function, so whichever merges second takes this version.
  • Skill: private issue squirrelscan/repo#3698 already covers squirrel pages (labels: skills).

Comment thread packages/report/src/page-map.ts Fixed
nc9 added 4 commits October 31, 2026 14:04
…e (json, csv, markdown, filters, flags) #701

Signed-off-by: Nik Cubrilovic <[email protected]>
…d bidi overrides, csv formula guard #701

Signed-off-by: Nik Cubrilovic <[email protected]>
…URL cells, json escapes C1 and bidi, h1/headings/@id columns, invisible chars, filters #701

Signed-off-by: Nik Cubrilovic <[email protected]>
…ters; code point sweep and escape fixpoint tests; json escape moves here #701

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/pages-command-701 branch from 1a8a4e9 to a140bf0 Compare October 31, 2026 03:07
… via split/join, e2e covers query variants and a self link, CodeQL i flag #701

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9 nc9 mentioned this pull request Oct 31, 2026
@nc9

nc9 commented Oct 31, 2026

Copy link
Copy Markdown
Contributor Author

Landed in v0.0.149 as 5e87c938 e5d03887 fd1e3e09 6e7af0e5 a31bf513 via #1432. Release: https://github.com/squirrelscan/squirrelscan/releases/tag/v0.0.149. Closing this original.

nik

@nc9 nc9 closed this Oct 31, 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.

2 participants