Plan: Migrate DirectiveService from GitHubService to PlatformProvider#
Summary#
Replace direct GitHubService injection in DirectiveService with the PlatformProvider interface so directive handling becomes platform-agnostic. The service uses closePR, deleteBranch (via GitHubService), and postRawComment (via raw fetch) — all three call sites migrate to PlatformProvider.
Files#
| File | Action | Description |
|---|---|---|
src/directive/directive.service.ts | modify | Swap GitHubService → @Inject(PLATFORM_PROVIDER) platform: PlatformProvider; replace this.gitHubService.closePR/deleteBranch and postRawComment raw fetch with this.platform.* calls |
src/directive/directive.module.ts | modify | Import PlatformModule instead of GitHubModule |
src/directive/directive.service.spec.ts | modify | Replace GitHubService mock with PLATFORM_PROVIDER token mock; add postComment to mock surface |
src/platform/platform-provider.interface.ts | modify | Add closePR, deleteBranch, postComment if missing from interface (gap-fill per AC) |
Steps#
- Verify PlatformProvider interface coverage — check if
closePR(owner, repo, prNumber),deleteBranch(owner, repo, branch), andpostComment(repo, issueNumber, body)exist onPlatformProvider. Add any missing methods to the interface andGitHubPlatformProviderimplementation. - Update
directive.module.ts— replaceGitHubModuleimport withPlatformModule; removeGitHubModuleimport statement. - Update
directive.service.ts— replace constructor paramprivate readonly gitHubService: GitHubServicewith@Inject(PLATFORM_PROVIDER) private readonly platform: PlatformProvider. Replace allthis.gitHubService.closePR/deleteBranchcalls withthis.platform.closePR/deleteBranch. ReplacepostRawCommentraw fetch implementation withthis.platform.postComment(repo, issueNumber, body). RemoveGitHubServiceimport andConfigServiceusage for token (no longer needed for comment posting). - Update
directive.service.spec.ts— replace{ provide: GitHubService, useValue: gitHubService }with{ provide: PLATFORM_PROVIDER, useValue: platformProvider }. AddpostCommentto mock alongsideclosePR/deleteBranch. Update all assertions fromgitHubService.*toplatformProvider.*. Replace rawglobal.fetchassertions withplatformProvider.postCommentassertions. - Verify — run
tsc --noEmit,npm run lint,npm run test.
Verification#
grep -r "GitHubService\|GitHubModule" src/directive/returns zero matches- All existing directive unit tests pass with
PlatformProvidermock tsc --noEmitandnpm run lintpass clean
Risks#
- Dependency on #345:
PlatformProviderinterface andPlatformModulemust exist before implementation. If #345 hasn't merged torc/multi-tenant, this issue is blocked. - postRawComment migration: Current implementation uses raw
fetchwithConfigServicetoken — migrating toPlatformProvider.postComment()changes error handling semantics slightly. The provider implementation must handle missing tokens gracefully.