feat(cli): add shep doctor command for self-diagnosis and auto-fix#438
Open
feat(cli): add shep doctor command for self-diagnosis and auto-fix#438
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…utor flows Address user feedback: shep doctor now supports both shep maintainers (who push directly to shep-ai/cli without forking) and external contributors (who fork first). Uses gh api permission check to auto-detect push access and select the appropriate flow automatically. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…p doctor Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…octor 15 tasks across 6 phases: TypeSpec domain models, service interface ports, infrastructure implementations, use case orchestration, CLI command with DI wiring, and integration testing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…fig extension Add DoctorDiagnosticReport TypeSpec value object with FailedRunSummary and SystemInfo sub-models for structured diagnostic data collection. Extend WorkflowConfig with optional doctorMaxFixAttempts field (default 1) to control fix retry behavior in the shep doctor workflow. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add IGitHubIssueService interface with createIssue method, error types, and result DTO. Extend IGitHubRepositoryService with checkPushAccess and forkRepository methods for maintainer vs contributor flow detection. Extend IGitPrService with createPrFromArgs for programmatic cross-fork PR creation. Includes implementations and comprehensive interface tests. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Implement GitHubIssueCreatorService wrapping gh issue create with typed error handling (GH_NOT_FOUND, AUTH_FAILURE, NETWORK_ERROR, CREATE_FAILED). Register IGitHubIssueService in DI container. Add comprehensive unit tests covering success and error paths. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add tests for checkPushAccess (true/false/error fallback paths), forkRepository (new fork, existing fork, error handling), and createPrFromArgs (same-repo, cross-fork with --repo flag, error handling). All three methods were implemented in phase 2 and now have comprehensive test coverage. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
… and fix workflow Implement DoctorDiagnoseUseCase orchestrating the full shep doctor workflow: - Collect diagnostics (failed agent runs, CLI version, system info) - Create structured GitHub issue on shep-ai/cli - Auto-detect push access for maintainer vs contributor flow - Clone/fork repo, invoke AI agent, commit and create PR - Graceful degradation on failures, temp directory cleanup 24 unit tests covering both flows, edge cases, and NFR compliance. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add top-level `shep doctor` CLI command that diagnoses shep failures, creates GitHub issues, and optionally attempts automated fixes. Register DoctorDiagnoseUseCase in DI container and wire command into the CLI program. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Clean ANSI codes from evidence files and add complete headers with test suite names, file paths, dates, and structured pass/fail markers. All 8 evidence files updated with fresh test runs confirming: - 11/11 github-issue-creator service tests passing - 24/24 doctor use case unit tests passing - 28/28 doctor command unit tests passing - 19/19 doctor integration tests passing - TypeSpec types verified in generated output - CLI help and command registration confirmed - Build succeeds with no errors Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
TypeSpec compiler v0.60.1 now emits double-quoted strings in enum values. Regenerated output.ts to match current compiler output and prevent freshness check failures. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.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
shep doctortop-level CLI command that lets users report operational failures, auto-creates GitHub issues on shep-ai/cli, optionally invokes an AI agent to attempt a fix, and opens a PR with the proposed fixChanges
Domain Layer (TypeSpec)
DoctorDiagnosticReport,FailedRunSummary, andSystemInfovalue objects in TypeSpecWorkflowConfigwithdoctorMaxFixAttemptssettingApplication Layer
DoctorDiagnoseUseCaseorchestrating the full diagnose → issue → clone/fork → agent fix → PR flowIGitHubIssueCreatorService(issue creation),IGitHubPermissionService(push access check),IDoctorRepositoryService(clone/fork management)Infrastructure Layer
GitHubIssueCreatorService— wrapsgh issue createwith error mapping (not found, auth, network)GitHubPermissionService— checks push access viagh api repos/.../permissionsDoctorRepositoryService— handles clone, fork, branch creation, and cleanupPresentation Layer
doctor.command.ts— Commander.js command with[description]positional arg,--fix/--no-fix/--workdiroptionsDI Container
container.tsTest Coverage
Total: 82 new tests, all passing
Test plan
pnpm buildcompiles without errorspnpm validate(lint + format + typecheck + tsp) passespnpm test:unit— all 4619 tests pass (336 test files)Evidence
shep doctorregistered as top-level command,--helpshows all optionsSpec:
specs/073-shep-doctor/🤖 Generated with Claude Code