feat(mcp): let doctor --exit-code gate CI with a non-zero exit on failure#359
feat(mcp): let doctor --exit-code gate CI with a non-zero exit on failure#359glorydavid03023 wants to merge 2 commits into
Conversation
JSONbored
left a comment
There was a problem hiding this comment.
@glorydavid03023 the doctor --exit-code behavior is useful, but this branch is mechanically blocked.
A few notes:
- The default-exit compatibility behavior is the right compatibility choice.
validateis failing intest/unit/mcp-cli.test.ts.- The branch also conflicts with current MCP CLI tests.
Required changes:
- Fix the TypeScript errors in the new async
execFiletest. - Rebase and resolve the
test/unit/mcp-cli.test.tsconflict. - Add the missing Safety section for MCP CLI stdout/stderr/JSON behavior.
Validation expected:
- Rerun
npm run typecheck, the focused MCP CLI test file,npm run build:mcp, andnpm run test:mcp-pack.
…lure `gittensory-mcp doctor` computes a status (ok / warnings / needs_attention) but the process always exits 0, so it cannot gate a CI step or pre-commit hook. Add an opt-in `--exit-code` flag: when a diagnostic check fails (status "needs_attention"), the process exits 1. The diagnostic report is still printed; only the exit code changes. The default is unchanged — without `--exit-code`, doctor still exits 0 — so existing scripts that ignore the exit code keep working. Warnings also stay at exit 0; only hard failures are surfaced as a non-zero code. Implemented by letting runCli's command result carry an optional numeric exit code (doctor is the only command that returns one); every other command still resolves to exit 0. Tests cover the default exit-0-on-failure behavior, the non-zero exit under --exit-code on failure, and exit 0 under --exit-code when checks pass. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0d1d04d to
ab665c0
Compare
|
Rebased onto the latest
While validating, I caught and fixed a real TypeScript error in the exit-code test: the async The only locally-failing test is the pre-existing |
|
Important Gittensory found maintainer review notesScoped related-work signals were found for this PR. They are advisory unless the gate reports a blocker. Readiness score: 68/100
Signal definitions
Review context
Maintainer notes
Contributor next steps
Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers. Learn more about Gittensor contribution workflows. |
JSONbored
left a comment
There was a problem hiding this comment.
@glorydavid03023 this is good to land, after fixing merge conflicts.
A few notes:
- The default
doctorexit behavior stays compatible. --exit-codegives CI/pre-commit users the stricter behavior they need without changing existing scripts.- The tests cover default exit 0, failure exit 1 under the flag, and passing exit 0 under the flag.
- Fix merge conflicts, then I'll approve once done.
Summary
gittensory-mcp doctoralready computes astatus(ok/warnings/needs_attention), but the process always exits 0 — so it cannot gate a CI step or a pre-commit hook. This adds an opt-in--exit-codeflag:# In CI / a git hook: fail the step if the local MCP setup is broken. gittensory-mcp doctor --exit-codeWhen a diagnostic check fails (
status: "needs_attention"), the process exits1. The diagnostic report is still printed — only the exit code changes.Behavior / compatibility
--exit-code,doctorstill exits0, so existing scripts that ignore the exit code keep working.needs_attention) produce a non-zero code, so transient/advisory warnings don't break pipelines.Why no linked issue
Additive, opt-in CLI ergonomics with no change to default behavior. No public-behavior, auth/session, schema, deploy, or frontend-architecture change, so per CONTRIBUTING this does not require an issue first. Happy to file one if maintainers prefer.
Implementation
runCli's command result now carries an optional numeric exit code, and the entry point uses it:process.exit(typeof exitCode === "number" ? exitCode : 0).doctoris the only command that returns a number; every other command resolves toundefinedand therefore still exits 0.Changes
packages/gittensory-mcp/bin/gittensory-mcp.js— thread an optional exit code through the CLI entry point;doctorreturns1only under--exit-codeonneeds_attention; help-text usage line.test/unit/mcp-cli.test.ts— cover (1) default exit-0 even when a check fails, (2) non-zero exit under--exit-codeon failure, (3) exit 0 under--exit-codewhen checks pass.packages/gittensory-mcp/README.md— document the flag and its semantics.Contract notes
No MCP tool or HTTP/OpenAPI contract changes. Local CLI behavior only; stdout output shape is unchanged.
Validation
Intended gate (CONTRIBUTING required checks):
Transparency note: my local authoring environment had no Node runtime available, so I could not execute the gate locally before opening this PR. The change was prepared against the existing CLI dispatch/doctor/test patterns and is intended to be validated by CI on this PR (I will also run the full gate locally). If any check needs adjustment I'll follow up promptly.
Security / privacy
No auth, cookie, CORS, GitHub App output, identity, or contributor-evidence changes. Only an exit-code signal is added; no new data is printed or transmitted.