Skip to content

fix: make doctor diagnostics actionable - #569

Merged
jeff-r2026 merged 1 commit into
Tencent:mainfrom
yuzhang-zhong:fix/doctor-diagnostics
Sep 16, 2026
Merged

jeff-r2026 merged 1 commit into
Tencent:mainfrom
yuzhang-zhong:fix/doctor-diagnostics

Conversation

@yuzhang-zhong

Copy link
Copy Markdown
Contributor

What changed

This is the doctor part of #545, resubmitted on its own after the review there. It contains no members --invite changes and does not change #517.

  • return exit code 1 when any diagnostic fails
  • avoid provider checks until a valid team config identifies the provider
  • resolve hook paths for the active scope and skip agents excluded by local config
  • document exit-code behavior in English and Chinese
  • cover both CLI exit paths with a built-binary E2E test

Why

teamai doctor could report failed checks and still exit 0. On a fresh install it could also ask for TGit tooling before TeamAI knew which provider the team used. That made the result confusing for people setting up TeamAI and unreliable in scripts.

Testing

  • npm run typecheck
  • npm run build
  • npx vitest run src/__tests__/doctor.test.ts src/__tests__/pkg-commands.test.ts (29 passed)
  • npm run test:e2e in Ubuntu (139 passed, 26 skipped, 0 failed)
  • npm test in Ubuntu (3133 passed, 8 failed)

The remaining 8 failures are all in local-agent.test.ts. Running that file against the current origin/main produces the same 8 failures.

@jeff-r2026

Copy link
Copy Markdown
Collaborator

The direction is right: exit 1 on failed checks, do not assume TGit before init, and keep hook checks aligned with inject. It cannot merge as-is — it conflicts with main on CHANGELOG.md (usage-guide also overlaps later landings). Please rebase first.

While rebasing:

  1. Put the doctor CHANGELOG line next to the existing Bug Fixes entries. Do not overwrite fix(import): restore --json for cache status and GC #580 / fix(dashboard): normalize Unicode correction keywords #575.
  2. Do not change README (EN/ZH or ja/ko/th). Exit-code behavior belongs in the usage guide / CHANGELOG. Please drop the README edits from this PR.
  3. After the !localConfig early return, Local config exists is always ✔, and the getUserHome() baseDir branch plus the remaining if (!localConfig) guards are dead. Remove them, or make the config check actually read disk.
  4. In the usage-guide packages section, do not replace the original package / marketplace / plugin wording with only “Check setup”. Keep that meaning and add the exit code.
  5. doctor-cli e2e only runs under npm run test:e2e; GitHub E2E was SKIPPED this time. The exit-0 case uses provider: git + toolPaths: {}, so almost nothing is actually checked. After rebase, please re-run doctor.test.ts and this e2e.

No must-block bug in the core logic. After the conflict is resolved and the notes above, this can merge.

@yuzhang-zhong

Copy link
Copy Markdown
Contributor Author

Rebased onto the current main and addressed each item:

  • Kept the existing Bug Fixes entries, including fix(import): restore --json for cache status and GC #580 and fix(dashboard): normalize Unicode correction keywords #575, and placed the doctor entry alongside them.
  • Dropped all README changes.
  • Removed the always-passing local-config check and the dead branches after the initialization guard.
  • Preserved the runtime, package, marketplace, and plugin wording in both usage guides while adding the exit-code behavior.
  • Strengthened the built-CLI E2E fixture with an enabled Claude agent and an actual hook configuration.
  • Added an initialized failure case proving that a missing Claude hook produces a failed diagnostic and exit code 1.

Verified with build, typecheck, 29 focused unit tests, and all 3 doctor CLI E2E cases. The Linux unit suite reports 3259 passing and 8 failures; the same 8 local-agent.test.ts failures reproduce on a clean origin/main.

@jeff-r2026
jeff-r2026 merged commit 8ea0612 into Tencent:main Sep 16, 2026
7 checks passed
jeff-r2026 pushed a commit that referenced this pull request Sep 17, 2026
The checks that catch "reported success, nothing on disk" lived inside
doctor() as a local array, so nothing else could run them, and the only
machine-readable result was the exit code #569 added.

Extract resolveDoctorContext() and buildChecks(), which render nothing,
and add --json: one object on stdout, every log line on stderr, exit code
unchanged. Human output is byte-for-byte what it was.
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
The checks that catch "reported success, nothing on disk" lived inside
doctor() as a local array, so nothing else could run them, and the only
machine-readable result was the exit code Tencent#569 added.

Extract resolveDoctorContext() and buildChecks(), which render nothing,
and add --json: one object on stdout, every log line on stderr, exit code
unchanged. Human output is byte-for-byte what it was.
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.

2 participants