Skip to content

fix(doctor): do not prompt Fix/Skip in a non-interactive shell - #1671

Merged
rohitg00 merged 1 commit into
mainfrom
fix/doctor-noninteractive
Nov 4, 2026
Merged

rohitg00 merged 1 commit into
mainfrom
fix/doctor-noninteractive

Conversation

@rohitg00

@rohitg00 rohitg00 commented Nov 4, 2026 •

Copy link
Copy Markdown
Owner

Bug

agentmemory doctor with CI=1 (or without a terminal) still showed the interactive select:

[env-missing] ~/.agentmemory/.env is missing.
F  Fix / S  Skip / ?  More info / Q  Quit doctor

Found on a clean Windows Server 2022 run. It only avoided hanging because stdin was not a terminal; in a CI job with an attached pseudo-terminal it waits forever.

Cause

runDoctor asked askFixAction for every auto-fixable failure unless --all was passed. Nothing checked CI or whether stdin/stdout are terminals.

Fix

  • doctorPromptsAllowed(env, stdinIsTTY, stdoutIsTTY) in src/cli/doctor-diagnostics.ts: true only with both terminals and no CI.
  • In a non-interactive shell doctor still reports every failure, skips the fix, and prints one hint: run agentmemory doctor --all to apply the fixes. Exit codes do not change.

Testing

  • test/cli-doctor-env-file.test.ts: runs the built CLI doctor with CI=1 and no env file. It fails on main (output contains the Fix prompt) and passes here.
  • test/cli-doctor-fixes.test.ts: unit cases for doctorPromptsAllowed.
  • npm run build, npm run skills:check, both doctor test files pass (44 tests).

Summary by CodeRabbit

  • Bug Fixes
    • The doctor command now skips interactive fix prompts in CI and other non-interactive environments, and displays a hint to run agentmemory doctor --all.

Windows verification

Clean Windows Server 2022, CI=1, stdin closed: doctor finished in 0.8 s with no Fix/Skip prompt and printed the agentmemory doctor --all hint; exit 1 comes from two real failing checks (no .env, no LLM key). Devin session: https://app.devin.ai/sessions/19b3aff181f8433a8c776ced7a077a59

agentmemory doctor showed the Fix/Skip/More/Quit select for every
auto-fixable failure even with CI set or without a terminal. It only
avoided hanging because clack gave up on a closed stdin.

Doctor now prompts only when stdin and stdout are terminals and CI is
unset. Otherwise it reports each failure, skips the fix, and prints
one hint to run `agentmemory doctor --all`.
@vercel

vercel Bot commented Nov 4, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agentmemory Ready Ready Preview Nov 4, 2026 7:12am UTC

Request Review

@coderabbitai

coderabbitai Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The doctor command now gates auto-fix prompts on CI and stdin/stdout TTY status. When prompts are unavailable, it skips each auto-fixable failing diagnostic and prints the agentmemory doctor --all hint once. Tests cover the eligibility rules and non-interactive command output.

Changes: Doctor prompt gating

Layer / File(s) Summary
Prompt eligibility rules
src/cli/doctor-diagnostics.ts, test/cli-doctor-fixes.test.ts
The new doctorPromptsAllowed helper returns true only when CI is falsy and both stdin and stdout are TTYs. Tests cover these conditions.
Doctor non-interactive behavior
src/cli.ts, test/cli-doctor-env-file.test.ts
runDoctor skips auto-fix prompts when they are disallowed and displays the agentmemory doctor --all hint once. The command test checks the hint, env-missing, and absence of Fix when invoked without arguments in CI.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Possibly related PRs

  • rohitg00/agentmemory#895: Adds auto-fix classification and manual-fix handling to the Doctor fix loop, which the prompt-gating change also affects.

Suggested reviewers: dmazhukov

Merge Risk: Minimal · up to 019c6

Non-interactive doctor runs skip prompts while retaining explicit fixes, dry-run behavior, and failure reporting. No actionable merge-blocking risk was identified.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentat… Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed The title clearly and concisely describes the main change: preventing Fix/Skip prompts in non-interactive shells.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Docstring Coverage

Explanation

Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff with cyclomatic complexity of at least 2. Documentation-only edits and deletions within surviving functions are included; unchanged diff context and fully deleted functions are excluded. Analyzed 3 functions across 4 files.

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

Finishing Touches
Generate docstrings
  • Commit to this branch
  • Create a new PR
Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share
Recent review info
Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a1672ea4-3f5a-47ef-90ef-ddb4f5c54510
Commits

Reviewing files that changed from the base of the PR and between 9890b7a and 019c6df.

Files selected for processing: 4
  • src/cli.ts
  • src/cli/doctor-diagnostics.ts
  • test/cli-doctor-env-file.test.ts
  • test/cli-doctor-fixes.test.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 0 remain after this review.

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Devin Review

Comment thread src/cli.ts Resolved
@rohitg00
rohitg00 merged commit e9be964 into main Nov 4, 2026
15 checks passed
@rohitg00
rohitg00 deleted the fix/doctor-noninteractive branch November 4, 2026 08:09

This branch was successfully deployed

1 active deployment
Preview — 019c6df7 Deployed Nov 4, 2026 by vercel[bot]
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.

1 participant