Skip to content

chore(cli): delete the unreferenced external checker and sitemap/robots copies #756 - #782

Merged
nc9 merged 2 commits into
mainfrom
chore/cli-drop-dead-forks-756
Oct 15, 2026
Merged

nc9 merged 2 commits into
mainfrom
chore/cli-drop-dead-forks-756

Conversation

@nc9

@nc9 nc9 commented Oct 14, 2026

Copy link
Copy Markdown
Contributor

Closes #756.

What changed

The CLI kept its own copies of three shared modules that nothing in it runs any more:

  • apps/cli/src/crawler/external-checker.ts: the audit's external link phase runs on the engine's checker. Only the ExternalCheckResult type was imported, and it now comes from @squirrelscan/audit-engine.
  • apps/cli/src/crawl/sitemaps.ts, robots.ts and the index.ts that re-exported them: the crawl uses @squirrelscan/crawler's sitemap code and robots evaluator, and @squirrelscan/utils' robots.txt parser. hybrid-fetcher.ts (imported by the audit controller) and csr-detect.ts (a re-export of @squirrelscan/fetchers) stay.

Their tests exercised the copies, not the code users run. Each case now runs against the shared code, or is dropped where a shared-package test already covers it:

Was Now
CLI discover-sitemaps.test.ts (parse, URL list, recursive fetch dedupe, discovery) moved to packages/crawler/tests/sitemap-parse-756.test.ts, against the crawler's parseSitemap, getUrlsFromSitemaps, fetchSitemapsRecursive and discoverSitemaps. One expectation changes: the crawler decodes &amp; in a <loc> (the copy's regex kept it), which is correct and already pinned by sitemap-xml-escapes.
CLI fetch-robots.test.ts, parseRobotsTxt cases moved to packages/utils/tests/robots-txt-756.test.ts, against @squirrelscan/utils/robots-txt, which had no direct parse tests.
CLI fetch-robots.test.ts, isUrlAllowed cases rewritten as packages/crawler/tests/robots-evaluator-756.test.ts, against createRobotsEvaluator().isAllowed, the check the crawl makes.
CLI fetch-deadline.test.ts, sitemap deadline cases moved to packages/crawler/tests/sitemap-fetch-deadline.test.ts, against the crawler's fetchSitemap. Its reasons are the crawler's: a stalled body is Empty response (not settled), as persisted failure records have always read.
CLI fetch-deadline.test.ts, external checker deadline cases dropped: the engine's fetch-deadline.test.ts has the same two cases.
CLI undecoded-fetches.test.ts, external link case dropped: the engine's undecoded-probe-fetches.test.ts covers it.
CLI capped-read-closes-connection-766.test.ts, external checker case dropped: the engine's #766 test covers it.
CLI request-deadline.test.ts, the copy's fetchRobotsTxt stall dropped: the crawler's preamble-budget.test.ts covers a stalled robots.txt.

The CLI script fetcher (a live fork used by the analyze pass) keeps its tests in the CLI.

Checks

  • tsgo --noEmit passes in apps/cli and packages/audit-engine.
  • CLI format:check and lint pass.
  • detect-secrets passes on the changed files.
  • The moved and trimmed tests pass:
    • crawler: sitemap-parse-756, robots-evaluator-756, sitemap-fetch-deadline
    • utils: robots-txt-756
    • CLI: fetch-deadline, undecoded-fetches, capped-read-closes-connection-766, request-deadline
  • checkReachability returns instead of hanging on a stalled body in request-deadline fails locally on macOS, which does not route 127.0.0.2. It fails the same way on main and passes on Linux CI.

Docs and skill

No user-facing change, so no docs change. CHANGELOG entry under Changed, marked internal.

The squirrelscan agent skill needs no change.

@nc9
nc9 force-pushed the chore/cli-drop-dead-forks-756 branch from 22bc5c8 to 5378202 Compare October 15, 2026 01:26
@nc9
nc9 marked this pull request as ready for review October 15, 2026 01:42
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review of #782 (dead-code removal in the CLI)

I found no problems. I couldn't run the test suite or typecheck here, and CI was still pending when I checked.

  • The PR deletes apps/cli/src/crawl/{index,robots,sitemaps}.ts and crawler/external-checker.ts, along with their CLI-side tests.
  • No imports of the removed modules remain. @/crawl/hybrid-fetcher and csr-detect.ts are kept and still used.
  • adapter.ts now takes ExternalCheckResult from @squirrelscan/audit-engine. That package exports it (packages/audit-engine/src/index.ts:203).
  • The sitemap deadline, sitemap parsing and robots.txt parsing tests now live in packages/crawler and packages/utils, so the behaviour stays covered.
  • The CHANGELOG entry is accurate.

Merge once the pending Format, lint, and typecheck and docs checks pass.

nc9 added 2 commits October 15, 2026 15:14
…ts copies #756

Nothing in the CLI ran apps/cli/src/crawler/external-checker.ts or
apps/cli/src/crawl/{sitemaps,robots,index}.ts: audits use the engine's
checker and the crawler's sitemap and robots code. Import
ExternalCheckResult from @squirrelscan/audit-engine. Tests that covered the
copies now run against the shared code (sitemap parsing and the fetch
deadline in the crawler, robots parsing in utils, allow rules on the
crawler's evaluator) or are dropped where an engine or crawler test covers
the same case.

Signed-off-by: Nik Cubrilovic <[email protected]>
Drop the robots.txt fixture branch nothing requests now, say the external link deadline cases were dropped (the engine covers them) rather than moved, and word the CHANGELOG entry as fetchers, not parsers.

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the chore/cli-drop-dead-forks-756 branch from 55aa874 to c06254f Compare October 15, 2026 04:15
@claude

claude Bot commented Oct 15, 2026

Copy link
Copy Markdown

Review of #782 (removes the dead CLI copies of the external link checker, sitemap fetcher and robots.txt fetcher).

No findings.

  • I grepped the repo for the deleted modules (@/crawl, crawl/robots, crawl/sitemaps, external-checker) and found no remaining imports in apps or packages.
  • ExternalCheckResult is exported from packages/audit-engine/src/index.ts. audit/cloud.ts already imports it from there, and the adapter.ts change does the same.
  • apps/cli/tests/crawler/sitemap-cap.test.ts already imports from @squirrelscan/crawler/sitemaps, so it is unaffected.
  • The sitemap deadline, sitemap parsing and robots.txt tests now live in packages/crawler and packages/utils. SITEMAP_FETCH_TIMEOUT_MS also exists in packages/crawler/src/sitemaps.ts.
  • I did not read the moved tests line by line to confirm their coverage matches the deleted CLI tests.
  • CI checks (typecheck, docs build, secret scan) were still pending when I reviewed, so I haven't seen them pass.

The changelog entry reads well.

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.

CLI: delete the unreferenced external link checker and sitemap parser copies, and point their tests at the shared packages

1 participant