Repository navigation
feat(cli): audit levels (--level quick|surface|full) and the audit levels docs page - #598
Conversation
…602) Adds @squirrelscan/core-contracts/audit-levels: the three levels plus custom, their preset settings, AUDIT_LEVEL_COPY and AUDIT_SETTING_COPY, resolve/clamp helpers, plan and balance limits (whole pages, NaN fails closed), the cloud's old four depths as legacy aliases, crawlStrategyCoverageMode and parseResolvedAuditSettings. AuditReport gains an optional auditLevel snapshot; CoverageMode is now the AuditLevel type (same three words). Additive: the CLI --level flag, docs and changelog stay in #598. Signed-off-by: Nik Cubrilovic <[email protected]>
|
The core-contracts half of this PR landed on its own in #602 (0f960e9) so the cloud dashboard could build on it. Rebase this branch onto main: its |
a8ab59e to
562401a
Compare
The level is now one definition (core-contracts audit-levels) read by the audit and crawl commands, the local MCP tools, the config schema and the shell completions. - `--level quick|surface|full`; `--coverage`/`-C` and `[crawler] coverage` still work, `fast` still means quick, anything else exits with the list of levels. `--level` and `-C` naming different levels is refused. - A level fills in every setting (pages, crawl strategy, cloud checks, render, external links, probing) as the default; the existing flags and config values override single settings. Any change makes the run custom, and the banner says so: `Level custom (surface + max_pages 200)`. - Quick spends no credits when signed in: a run without cloud checks does not register (no audit base, no page settlement) and does not use the cloud browser unless asked to render. - Quick no longer checks external links or probes by default; surface and full probe actively whoever is signed in. Defaults `squirrel init` writes (max_pages = 100, external links on) still read as unset. - `squirrel crawl -C fast` no longer crawls unbounded: the level and a non-numeric --max-pages are validated through the shared helper. - Reports carry `auditLevel` (level, basedOn, changes, settings): JSON meta, an `<audit-level>` LLM element, a markdown/text/html line. Existing fields keep their names. - core-contracts: crawlStrategyCoverageMode and AUDIT_SETTING_COPY; CoverageMode and the crawler's mode type derive from AuditLevel. - config now depends on core-contracts (workspace). Signed-off-by: Nik Cubrilovic <[email protected]>
…ry page Signed-off-by: Nik Cubrilovic <[email protected]>
…nto it New page guides/audit-levels (Concepts, after Crawling): the three levels with every setting, defaults, custom levels in the CLI, dashboard and reports, plan and credit limits, which level to pick, probing and rendering, and the older names. cli/audit, cli/crawl, crawl, quickstart, local and cloud audit guides, crawler/security/cloud/external-links/output config, scheduled audits, MCP and reports pages now say level, --level and the level defaults, and link to it. Fixes: quick is free when signed in, surface sampling is a priority penalty, quick falls back to links without a sitemap, scheduled runs use the site's level, quick_check is not a single-page pass. Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
…el on reload A quick audit does not register, so the affordability preflight never ran for it, and an explicit --render on a quick run had no spend bound. It is now held to the balance and max_credits_per_audit on the worst case of every page rendering (2 credits each), and falls back to HTTP when not one render fits. A JSON report loaded back with squirrel report keeps meta.auditLevel, read through the new core-contracts parseResolvedAuditSettings so a forged file only yields valid level and setting words. Signed-off-by: Nik Cubrilovic <[email protected]>
Signed-off-by: Nik Cubrilovic <[email protected]>
… unknown names Signed-off-by: Nik Cubrilovic <[email protected]>
No audit is free in credits. A signed-in quick audit registers the run (50-credit base plus 2 per audited page) and renders the pages that need JavaScript in the cloud browser, as before audit levels. The quick level only skips the cloud checks. Drops the no-register path, the render-only page budget and the suppressed spend notice, restores the register wiring tests that run at quick, and replaces the free-quick test with one that pins registration, hybrid cloud rendering and the 50 + 2 per page quote. Docs, CHANGELOG, help and MCP copy no longer say quick is free. Signed-off-by: Nik Cubrilovic <[email protected]>
562401a to
259dc86
Compare
Pins the other half of the billing rule: signed out there is nothing to bill, so quick reads no balance, registers nothing and renders nothing. The docs say local, no account needed, for signed-out quick, and up to 100 credits signed in. Signed-off-by: Nik Cubrilovic <[email protected]>
Signed in, audit_website adds the cloud checks at surface and full without registering a billed cloud audit. Its description, the MCP docs and the CHANGELOG now say so and point at the hosted run_audit for a billed audit; #628 tracks billing it like squirrel audit. Refs #628 Signed-off-by: Nik Cubrilovic <[email protected]>
|
Reviewed the CLI wiring (
No critical or high-severity issues found in the parts I read. Test coverage looks thorough, with new tests for the level parser, wiring, billing, crawl, MCP, completions and report output. |
…er-off and anonymous probing tests - audit, crawl and the MCP tools read the `[crawler] max_pages` sentinel through configMaxPagesChoice instead of a literal 100. - A repeated --level or -C is refused with its own error. - Tests pin that a signed-out, online audit probes actively at surface and full and passively at quick, and that a signed-in audit with rendering off (--http, --render-mode off, [cloud] render = "off") never sends a page to the cloud browser at any level. - Rewrap the probe.ts header comment. Signed-off-by: Nik Cubrilovic <[email protected]>
|
Review triage for 900bee4. All fixes are in 367727b.
Gates on 367727b: tsgo (apps/cli, config), the touched test files, root |
|
Reviewed the CLI wiring (
The rest looks good. The single level definition, the NaN-cap guard and the clear errors for |
Audit levels for the CLI and the docs:
--level quick|surface|full, built on the shared definition inpackages/core-contracts/src/audit-levels.ts, which is on main since #602. Rebased onto main at 2f93601; this PR no longer changes core-contracts.Draft for review. Nothing here should merge before the maintainer has read the behaviour changes below.
What changes
audit,crawl, the local MCP tools,[crawler] coverage, the completions and the help text all read the levels from core-contracts. No other level list or per-level page count is left in the CLI. The config schema, the crawler's mode type and the engine's run input derive fromAUDIT_LEVELS(@squirrelscan/confignow depends on core-contracts).--level, with--coverage/-Ckept as the older name.faststill means quick. An unknown value exits 1 withunknown audit level 'turbo'. Valid: quick, surface, full (fast is accepted as quick).--leveland-Cnaming different levels is refused.Level surface · max 100 pages,Level custom (surface + max_pages 200),Level custom (surface + render off) · max 100 pages. It replaces theCoverageline.auto), as on main. Quick only skips the cloud checks. Signed out there is nothing to bill: quick stays local, no account needed. (An earlier commit on this branch made signed-in quick free;fix(cli): bill a signed-in quick audit like every other leveltakes that out.)squirrel crawl -C fastbug fixed. The crawl resolves its level through the shared parser; a non-numeric--max-pagesis refused too.auditLevel(level,basedOn,changes,settings) on the report, JSONmeta.auditLevel, LLM<audit-level>, anAudit level:line in text, Markdown and HTML. No field renamed;coverageModestill stamped. A JSON report loaded back keeps it, through a parser that only returns valid words.AUDIT_LEVEL_PRESETS,crawlStrategyCoverageMode,AUDIT_SETTING_COPY,parseResolvedAuditSettings,CoverageModeasAuditLevel,AuditReport.auditLevel) landed with feat(core-contracts): audit levels definition (quick, surface, full) #602; the branch's own contracts commit was dropped in the rebase, since feat(core-contracts): audit levels definition (quick, surface, full) #602 contains all of it.docs/guides/audit-levels.mdx) (Guides, Concepts, after Crawling), plus every page that described coverage modes. CHANGELOG entry under[Unreleased].Behaviour changes to review
Against current main (2f93601):
--level surfacenow sends active probes, and every quick run skips external links.Maintainer sign-off: the maintainer (Nik) approved active probing for signed-out surface and full audits on 2026-10-10, reviewing this exact item ("Probing now follows the level, not sign-in") in the behaviour walkthrough before approving the merge.
audit-level-wiring.test.tspins it: signed out and online,--level quickprobespassiveand--level surfaceand--level fullprobeactive.max_pages = 100and[external_links] enabled = truestill read as unset, becausesquirrel initwrites both into every config. There is no flag for external links either, so quick cannot check them at all: pick surface.[crawler] coveragenow acceptsfastand any letter case (before: a config validation error); other unknown values still fail.audit_websitetakeslevel(coveragestill works; both naming different levels is an error). It now applies the project config the waysquirrel auditdoes:[crawler] max_pages,[security] probe,[external_links] enabled = false, and[cloud] renderas the fetch mode. At surface and full it probes actively (before: always passive).quick_checkno longer checks external links. At quick the tools stay local, as on main.Known gap (as on main): signed in,
audit_websiteadds the cloud checks at surface and full but never registers a billed cloud audit, so it is not billed the waysquirrel auditis (a configured[cloud] renderdoes cost 2 credits per rendered page). Its description,docs/cli/mcp.mdx,docs/developers/mcp.mdxand the CHANGELOG now say so and point at the hostedrun_audit. Local MCP audit_website runs cloud checks without billing a signed-in audit #628 bills it like the CLI, in a follow-up PR after this one.squirrel crawl.--leveladded; an unknown level stops before the crawl (before:-C fastcrawled with no page limit), and so does a non-numeric--max-pages.Levelinstead ofCoverage; locked-check and page-limit messages point at--levelinstead of-C; the quick-level locked message no longer says "coverage". No copy says quick is free: the docs say a signed-in quick audit costs 50 + 2 per page,--helplists quick as "no cloud checks" (main says "fast/local/free"), the MCP descriptions drop "free" and "no credits", andcloud-audits.mdxandquickstart.mdxlose main's old "fast, free scan" lines.Not changed: registration, the affordability preflight, the once-only cost notice and cloud rendering at quick are all as on main.
Evidence
On the rebased head:
apps/cli/tests/cli/audit-level.test.ts(renamed fromcoverage.test.ts, resolution and banner text),tests/commands/audit-level-wiring.test.ts(real citty argv),tests/commands/audit-quick-billing-wiring.test.ts(signed-in quick registers, quotes 50 + 2 per page, renders a client-rendered page in the cloud browser and keeps a server-rendered one on HTTP;--offlineand--httpcontrols; a signed-out quick run reads no balance, registers nothing and renders nothing; the signed-in cases fail 5 of 6 against the earlier free-quick code, and the same file with-C quickpasses 6 of 6 on origin/main, so main already billed signed-in quick and only its copy said free),tests/commands/crawl-level.test.ts(fast, quick, surface, full, invalid),tests/mcp/audit-level-options.test.ts,packages/report/tests/audit-level-line.test.ts. Updated: configprobe.test.ts, CLIconfig,completion,audit-probe-wiring,report,tips,page-limit-hint,locked-rules-footer, reportlocked-rules-*. Also run: core-contractsaudit-levels, the other CLI, report and engine tests that read coverage or the level (quick-skips-cloud,coverage-mode,smart-audits,cloud-spend,render-decision,render-spend, MCPreport-tools,publish-metaand others), and main's newdecode-failures,json-stdout,console-warning-totals,toml-syntax-error. All pass.bun run format:checkandbun run lint,scripts/test-suites.ts --check,notices:check: pass.detect-secrets-hook --baseline .secrets.baselineover tracked files): passes; the baseline only moves one line number.make validatein docs:Pages: 426 Orphans: 1 ✓ All checks passed.resolve-publish-decision,audit-run-lifecycle-wiring,audit-local-store-wiringandaudit-non-public-host-wiringare back to main's versions, which register at quick, and pass.packages/synthetic-site, 600 pages,--offline):After the rebase,
--level turboand--level surface -C quickstill exit 1 with their messages, andaudit --helplists the levels.audit-schedule-notice-wiring.test.tsandaudit-non-public-host-wiring.test.tspass withHOME=$(mktemp -d). Without it they time out here, on main as well: the publish path opens every project database under the real~/.squirrel/projects(17,248 on this machine).Agent skill
Yes, the squirrelscan agent skill needs a change: it says quick is the default (signed in it is surface), uses
-C, and should mention--leveland custom levels, and say that quick skips the cloud checks but is billed like any level signed in (50 + 2 per page).