feat: deepdive doctor — aggregated health report#4
Merged
Merged
Conversation
One command, one paste-able report. Mirrors dario's doctor philosophy:
every subsystem deepdive depends on (Node, the LLM endpoint, the search
adapter, Playwright + Chromium, the cache dir) gets probed; anything
unhealthy is visible without chasing error messages across three
separate commands. Exit code 1 on any fail, 0 otherwise.
13 checks by default, grouped into five categories:
# environment — Node version, platform, deepdive version
# cache — dir, writable, file count, total bytes, oldest entry
# llm — base URL, model, reachability (max_tokens=1 probe),
response-shape validation
# search — configured adapter, live probe against "hello world"
# browser — playwright module, chromium launch + close
Text output is the default (sectioned with # headers, color when TTY).
`--json` emits the same structured report for piping.
Sub-subsystems can be skipped via DoctorOptions for tests (`skipLLM`,
`skipSearch`, `skipBrowser`, `skipCache`). `fetchImpl` and `now` are
injectable hooks.
New exports on the public API: runDoctor, renderDoctorText,
renderDoctorJson, exitCodeFor, plus pure helpers scrubPath (home-dir +
backslash scrubber used throughout so error messages don't leak paths),
formatBytes, formatDuration, classifyFetchError (ECONNREFUSED /
ENOTFOUND / timeout / TLS / fallback), nodeMeetsMinimum.
Tests: 18 assertions (134 total, up from 116). Pure-helper coverage,
rendering round-trips, and mock-HTTP-server integration tests
covering the healthy LLM, 500, and non-Anthropic-shape paths plus
cache-dir inspection with mixed file types.
The CLI now dispatches on `deepdive doctor` as a subcommand; `--json`
selects structured output, `--help` still documents everything. USAGE
banner updated to show both paths.
| detail: model, | ||
| }); | ||
|
|
||
| const url = `${baseUrl.replace(/\/+$/, "")}/v1/messages`; |
3 tasks
askalf
added a commit
that referenced
this pull request
Apr 23, 2026
) CodeQL flagged `baseUrl.replace(/\/+$/, "")` in doctor.ts as polynomial- ReDoS after PR #4 landed doctor.ts. Same class as the original 7 fixed in #3; the regex is actually benign (no nested repetition) but using the shared trimTrailingSlashes helper from url-util.ts keeps the pattern consistent and CodeQL's query clean. Co-authored-by: askalf <263217947+askalf@users.noreply.github.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds
deepdive doctor— one command, one paste-able health report across every subsystem. Mirrors dario's doctor philosophy: the user's supposed to paste the output when filing an issue, and we surface everything that could be wrong in one place.Output
13 checks by default, five categories, OK/WARN/FAIL/INFO badges:
--jsonfor structured output. Exit code 1 on any fail (warnings alone don't fail).New exports (library API)
runDoctor,renderDoctorText,renderDoctorJson,exitCodeForscrubPath,formatBytes,formatDuration,classifyFetchError,nodeMeetsMinimumCheckResult,CheckStatus,DoctorReport,DoctorOptionsDoctorOptionshasskipLLM/skipSearch/skipBrowser/skipCacheswitches andfetchImpl/nowinjection points for tests.Probe cost
max_tokens=1request per run (few tokens, essentially free on subscription billing)Nothing persists across the run.
Test plan
npm run build— clean under strict: truenpm test— 134 pass (up from 116), 0 fail