Skip to content

feat(cli): setup ends by offering the first audit; install scripts lead with it #1195 - #1201

Merged
nc9 merged 3 commits into
mainfrom
feat/first-audit-offer
Oct 27, 2026
Merged

nc9 merged 3 commits into
mainfrom
feat/first-audit-offer

Conversation

@nc9

@nc9 nc9 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

Closes #1195. Depends on #1198 (this branch is built on its head, so the diff shows its commits until it merges; I rebase once it lands). Tracked internally.

What

  • install.sh and install.ps1 closing message lead with squirrel audit https://your-site.com (one line saying what it does); squirrel setup comes second.
  • squirrel setup ends by asking for a site URL and offering to run the audit now. A bare host (example.com) is taken as https; a typed URL runs the audit in-process; enter skips; one retry on a malformed answer.
  • Non-interactive (no TTY, CI, an agent), --yes and --dry-run never ask or block: they print the audit command.
  • Emits setup_audit_accepted / setup_audit_declined (no URL), the two event names feat(cli): measure the first run: setup, login and first-audit telemetry, persist install source #1194 #1198 added to the allow-list.
  • Docs: setup, quickstart, cli index, --yes help text. CHANGELOG. No new flag, so no completion change.

Skill

No change needed to the squirrelscan skill (no new command or flag).

Verified

format:check, lint, typecheck, tangly strict; tests by path (setup-audit-offer: URL parser + --yes/--dry-run print the command and make no network call; setup-telemetry). Smoke: built binary, isolated HOME under ops/scratch, pty-driven squirrel setup: declined sign-in and skills, typed a site at the offer, the audit ran (3 pages via a project max_pages) and printed the report; setup --yes </dev/null and --dry-run print the command and exit. Nothing was written to the real ~/.squirrel.

@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown

Review of #1201 (setup ends with a first-audit offer). The core logic reads sound: the non-interactive, --yes and --dry-run paths never block, telemetry carries no URL, and the URL parser rejects non-http(s) schemes. I did not run the tests or the CLI. Findings:

  • (medium) setup.ts parseAuditTarget: a bare localhost or localhost:3000 becomes https://localhost:3000/. Local dev servers are almost always plain http, so the audit will likely fail on a TLS error. The PR accepts localhost on purpose, so default bare localhost (and probably bare IPs) to http://. The test at line ~48 currently pins the https behaviour.
  • (low) setup.ts: runCommand(audit, { rawArgs: [target] }) runs in-process, so audit sees none of the top-level flags setup was given (for example --offline or a config path). Please confirm process.exitCode from a failed audit propagates, and that the first-audit telemetry in audit.ts fires only once when it is reached through setup.
  • (low) audit.ts: trackFirstAudit runs in the success path and again in the catch path. If it throws after the success call, the catch reports a second exception result. Please confirm trackFirstAudit is once-only and cannot throw.
  • (low) Tests: only --yes and --dry-run are covered. The interactive accept, decline and retry-then-skip paths of offerFirstAudit (including the setup_audit_* events) have no test. A fake Asker would make this easy.
  • (nit) The line prompt shows "a URL, or enter to skip". After a malformed answer the retry uses the same prompt, so say what was wrong, for example "try https://example.com".

@nc9

nc9 commented Oct 27, 2026

Copy link
Copy Markdown
Contributor Author

Triage: fixed bare localhost and IPs default to http (tested); retry hint says what to type; added tests for accept, skip, retry-then-skip, retry-then-accept and non-interactive/dry-run (offerFirstAudit exported with a fake asker). Confirmed: audit is awaited in-process so process.exitCode from a failed audit propagates; trackFirstAudit is once-only (module guard plus on-disk marker) and does not throw (updateSettings returns a Result), so the catch path cannot double report. setup's own flags are not forwarded by design (--yes/--dry-run never reach the offer).

@nc9
nc9 force-pushed the feat/first-audit-offer branch from 5edc3ea to 34d6fac Compare October 27, 2026 10:22
nc9 added a commit that referenced this pull request Oct 27, 2026
… setup_audit_* events (owned by #1201)

Signed-off-by: Nik Cubrilovic <[email protected]>
nc9 added a commit that referenced this pull request Oct 27, 2026
… setup_audit_* events (owned by #1201)

Signed-off-by: Nik Cubrilovic <[email protected]>
@nc9
nc9 force-pushed the feat/first-audit-offer branch from 34d6fac to 2024086 Compare October 27, 2026 11:17
@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown

Review of #1201: the setup flow, parser and telemetry look sound. I found two medium issues and some small ones. I did not run the tests.

  • (medium) CHANGELOG.md: the diff adds a second copy of the long "First-run telemetry" bullet right after the new bullet. The context above it already repeats that bullet three times, which looks like a bad rebase on top of feat(cli): measure the first run: setup, login and first-audit telemetry, persist install source #1194 #1198. Per AGENTS.md, start from main's file and re-add only your own bullet, then check that git diff origin/main -- CHANGELOG.md shows only your lines.
  • (medium) setup.ts (the runCommand(audit, { rawArgs: [target] }) call): the accepted path is never exercised by a test, so the in-process audit hand-off is only covered by the manual smoke test. Please check two things. First, that audit does not call process.exit or set an exit code in a way that skips the return/telemetry flush. Second, that its failures (a bad host, an unreachable site) surface sensibly at the end of setup instead of as an unhandled rejection. Consider stubbing runCommand and asserting it is called with the parsed target.
  • (low) parseAuditTarget: userinfo is accepted (https://user:[email protected]), and the URL is then passed to the audit as typed. That is harmless locally, but you could reject credentials in the URL, or at least avoid echoing them. Also, hasScheme matches host:3000-style input such as localhost:3000 as a scheme (localhost:), but the regex requires //, so it works. A test for example.com:8080/path would pin that down.
  • (low) Asker.line: ask() opens a fresh readline on stdin for every prompt. After rl.close() stdin may be paused, which could interact with the audit that runs afterwards. The smoke test passed, so this is probably fine, but note it.
  • (nit) The tests do not cover the --yes + TTY case. createAsker makes it non-interactive, so this is covered indirectly.
  • (nit) install.ps1 and install.sh: the wording "Then set up sign-in, agent skills and defaults" is fine, but "(crawls the site, scores it, lists exact fixes)" duplicates the quickstart copy. Fine to keep.

@nc9
nc9 force-pushed the feat/first-audit-offer branch from 2024086 to 4c11c91 Compare October 27, 2026 11:28
@claude

claude Bot commented Oct 27, 2026

Copy link
Copy Markdown

Review of #1201. The code is small and the tests cover the parser and the non-interactive paths. I found one real problem (the CHANGELOG) and a few small things.

  • (medium) CHANGELOG.md: the PR adds a second copy of the "First-run telemetry" bullet right after the new "First audit right after install" bullet. The context lines above it already repeat that bullet, which looks like a bad merge from the stacked feat(cli): measure the first run: setup, login and first-audit telemetry, persist install source #1194 #1198 branch. Rebase once feat(cli): measure the first run: setup, login and first-audit telemetry, persist install source #1194 #1198 lands, and make git diff origin/main -- CHANGELOG.md show only the one new audit-offer bullet. It also needs the issue reference (#1195) at the end, which AGENTS.md asks for.
  • (low) apps/cli/src/cli/commands/setup.ts (ask): if stdin closes mid-prompt (Ctrl+D or a closed pty), rl.question never resolves. Setup then either hangs or exits silently, depending on what else is keeping the event loop alive. Listen for rl.on("close") and resolve with "", so the offer counts as declined.
  • (low) setup.ts (the in-process runCommand(audit, ...)): the audit's exit code is lost, and a failing audit won't change setup's result. Check that audit doesn't call process.exit in a way that skips the first_audit_* telemetry. Otherwise this is fine.
  • (nit) setup-audit-offer.test.ts: parseAuditTarget has no cases for [::1]:3000, a host with no dot such as intranet, or a trailing-dot host. The IPv6 bracket stripping in particular is untested.
  • (nit) Declined and accepted telemetry are tracked, but a user who gets a malformed URL twice is counted as "declined". That is acceptable, but a distinct outcome would keep the funnel data cleaner.

No security issues. The typed URL goes only to the audit and is not sent in telemetry.

@nc9
nc9 merged commit 9589caf into main Oct 27, 2026
15 checks passed
@nc9
nc9 deleted the feat/first-audit-offer branch October 27, 2026 11:43
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.

First audit right after install: install.sh and setup lead to an audit

1 participant