feat(cli): add shep doctor command for self-diagnosis and auto-fix#438
Open
arielshad wants to merge 28 commits into
Open
feat(cli): add shep doctor command for self-diagnosis and auto-fix#438arielshad wants to merge 28 commits into
arielshad wants to merge 28 commits into
Conversation
Contributor
Contributor
Contributor
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>
…diagnostics When a feature ID (or prefix) is provided via --feature-id, doctor scopes its diagnostic collection to agent runs associated with that feature. The feature name and ID are included in the GitHub issue body under a new "Feature Context" section, and failed runs are filtered to only those matching the feature. - Add featureId/featureName optional fields to DoctorDiagnosticReport TypeSpec model - Inject IFeatureRepository into DoctorDiagnoseUseCase for feature lookup - Support both full ID and prefix-based feature resolution - Filter failed agent runs by featureId when provided - Include feature context section in formatted GitHub issue body - Add --feature-id <id> CLI option to doctor command - Add 5 new unit tests for feature-specific diagnostics - Add 3 new command tests for --feature-id option - Update integration test mocks for new IFeatureRepository dependency 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>
… diagnostics Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…r use case 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>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
b876b2a to
34fb45e
Compare
Contributor
Merge origin/main into feat/shep-doctor, resolving conflicts in IGitHubRepositoryService interface and implementations. Main added getViewerPermission + GitHubPermissionError while this branch added checkPushAccess + forkRepository + GitHubForkError — both sets are retained. Updated all mock objects across test files to include the complete interface. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The recoverAll tests fail when run inside a shep-spawned child process because SHEP_SKIP_RECOVERY=1 is inherited from the parent, causing recoverAll to early-return. Save and restore the env var around the recoverAll describe block. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
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 fix--feature-idoption — scopes agent run collection to a specific feature and includes feature context in the GitHub issueChanges
Domain Layer (TypeSpec)
DoctorDiagnosticReport,FailedRunSummary, andSystemInfovalue objects in TypeSpecWorkflowConfigwithdoctorMaxFixAttemptssettingfeatureIdandfeatureNameoptional fields toDoctorDiagnosticReportfor feature-scoped diagnosticsApplication Layer
DoctorDiagnoseUseCaseorchestrating the full diagnose → issue → clone/fork → agent fix → PR flowIFeatureRepositoryto resolve feature by ID or prefix when--feature-idis providedfeatureIdwhen feature-scopedInfrastructure Layer
GitHubIssueCreatorService— wrapsgh issue createwith error mapping (not found, auth, network)Presentation Layer
doctor.command.ts— Commander.js command with[description]positional arg,--fix/--no-fix/--workdir/--feature-idoptionsDI Container
container.tsTest Coverage
Total: 90 new tests, all passing
Test plan
pnpm buildcompiles without errorspnpm validate(lint + format + typecheck + tsp) passesEvidence
shep doctorregistered as top-level command,--helpshows all options including--feature-idSpec:
specs/073-shep-doctor/🤖 Generated with Claude Code