feat: complete BitBucket VCS provider integration gaps#862
Conversation
Analysis Phase
Executive SummaryThis issue requires wiring BitBucket VCS operations into 4 distinct subsystems: (1) changing Questions and Key Decisions
HIGH/CRITICAL Risks
Impact Summary
Complete Technical Reference (click to expand for implementation details)Problem Space ResearchProblem UnderstandingBitBucket VCS support was added in PR #609 but left gaps: PR operations in the MCP server are hardcoded to GitHub, Architectural ContextThe system has two parallel provider abstractions:
PR operations currently split across both systems. The MCP server uses Edge Cases Identified
Codebase Research FindingsChange 1:
|
Implementation Plan for Issue #861SummaryThis issue requires completing BitBucket VCS provider integration across 4 subsystems: (1) changing Questions and Key Decisions
High-Level Execution Phases
Quick Stats
Potential Risks (HIGH/CRITICAL only)
Complete Implementation Guide (click to expand for step-by-step details)Automated Test Cases to CreateTest File:
|
Implementation CompleteSummaryCompleted BitBucket VCS provider integration across 8 files, adding PR comment CRUD operations, review comment support, proper Changes Made
Validation Results
|
7a9b83a to
b049861
Compare
Wire BitBucket PR operations through the VCS provider layer: - Add ReviewComment type and update createPR/createPRComment return types - Add PUT support, updatePRComment, listPRComments, addInlinePRComment to BitBucketApiClient - Implement updatePRComment, getReviewComments, createReviewComment on BitBucketVCSProvider - Route MCP server PR tools through VCS provider with GitHub fallback - Fix SessionSummaryService to route PR comments through VCS provider - Fix finish.ts to use PRCreationResult and generate summaries for new PRs - Add pagination safety limits and hostname validation for SSRF defense - Document VCS provider configuration in iloom-commands.md
b049861 to
61d0b3c
Compare
* feat: add BitBucket integration for pull request management Adds BitBucket Cloud support including: - BitBucketApiClient for REST API v2.0 communication - BitBucketVCSProvider implementing VersionControlProvider interface - VCSProviderFactory for provider instantiation - ProviderCoordinator for cross-provider workflows - bitbucket-pr merge mode in finish command - Reviewer auto-assignment with username-to-UUID resolution - Auto-detection of workspace/repo from git remote - Debug subcommand for integration testing Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(issues): fetch PRs from BitBucket when versionControl.provider is bitbucket Implements the TODO(bitbucket) in the issues command to detect the configured VCS provider and use BitBucketApiClient.listPullRequests() instead of fetchGitHubPRList() when provider is 'bitbucket'. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(test): mock terminal and env utilities in LoomManager tests Prevent real subprocess spawning (execa for dark mode detection) and file system reads (dotenv-flow) that caused timeouts in non-interactive shells. Uses plain functions instead of vi.fn() to survive vitest mockReset between tests. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * refactor: add static fromSettings() to JiraIssueTracker and BitBucketVCSProvider Move settings extraction and validation logic from factories and issues.ts into the provider classes themselves, reducing duplication and simplifying call sites. Also adds listPullRequests() to BitBucketVCSProvider to encapsulate workspace detection + PR listing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix(security): redact sensitive tokens from debug log output Add redactSensitiveFields() to mask apiToken, token, secret, and password values in settings debug logs, preventing credential exposure. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * fix: address code review issues on BitBucket integration branch Fix error swallowing in checkForExistingPR (re-throw 401/403 auth errors), escape branch names in BBQL queries to prevent injection, remove verbose allMembers debug dump, add 'credential' to redaction keys, use dynamic import for BitBucketVCSProvider in issues command, remove dead ProviderCoordinator.ts, fix prTitlePrefix default to false, remove redundant vi.clearAllMocks(), and add test coverage for redactSensitiveFields, checkForExistingPR error handling, and BitBucket URL patterns in remote parsing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> * feat(issue-850): replace provider-specific merge mode values with generic schema and backwards-compatible transform * feat(issue-853): update summary, contribute, and CLI commands to use generic mode values Replace provider-specific mode strings (github-pr, github-draft-pr) with generic values (pr, draft-pr) in summary.ts, contribute.ts, and cli.ts. Update cli.ts tool requirement checks to use VCS provider configuration instead of mode name prefixes. Cast mode to string for comparisons since type definitions are updated separately in #850. * feat(finish): unify PR workflows under generic mode values Route PR creation through VCSProviderFactory for non-GitHub providers, falling back to legacy PRManager for GitHub. Add draft PR capability checking with graceful downgrade for providers that don't support drafts. Normalize legacy mode values (github-pr, github-draft-pr, bitbucket-pr) to generic equivalents (pr, draft-pr) for backward compatibility until schema migration in #850 lands. fixes #851 * feat(issue-854): update init wizard template and docs for generic merge mode values Replace provider-specific merge mode values (github-pr, github-draft-pr) with generic canonical values (local, pr, draft-pr) across init wizard template, README, command reference, and getting started guide. Add provider-agnostic guidance explaining VCS provider determines PR creation. * feat(issue-852): update LoomManager and MergeManager for generic mode values Replace provider-specific merge mode values (github-pr, github-draft-pr, bitbucket-pr) with generic values (pr, draft-pr) in LoomManager and MergeManager. Add VCSProviderFactory integration to check draft PR capability before attempting creation, while ensuring git operations (fetch, push, branch tracking) run regardless of provider capability. * feat(issue-855): clean up stale provider-specific merge mode references across codebase Update comments, type annotations, and test fixtures in 12 files to use generic mode values (local, pr, draft-pr) instead of old provider-specific values (github-pr, github-draft-pr, bitbucket-pr). No functional changes - backwards-compatible transform retained in finish.ts. * feat(epic-842): replace provider-specific merge modes with generic schema Decouples merge strategy from VCS provider by replacing provider-specific mode values (github-pr, github-draft-pr, bitbucket-pr) with generic ones (local, pr, draft-pr). Adds backwards-compatible Zod transform so existing settings files continue to work. Updates all consumers: finish command, LoomManager, MergeManager, summary, contribute, CLI, init wizard, and docs. Fixes #842 * fix(review): address code review findings on PR interface and gh CLI validation - Fix createPR call to use positional args matching VersionControlProvider interface - Only require gh CLI for PR modes when no non-GitHub VCS provider is configured - Remove dead bitbucket-pr code path and executeBitBucketPRWorkflow method - Use openBrowser utility for VCS provider browser opening * feat(issue-861): complete BitBucket VCS provider integration gaps (#862) Wire BitBucket PR operations through the VCS provider layer: - Add ReviewComment type and update createPR/createPRComment return types - Add PUT support, updatePRComment, listPRComments, addInlinePRComment to BitBucketApiClient - Implement updatePRComment, getReviewComments, createReviewComment on BitBucketVCSProvider - Route MCP server PR tools through VCS provider with GitHub fallback - Fix SessionSummaryService to route PR comments through VCS provider - Fix finish.ts to use PRCreationResult and generate summaries for new PRs - Add pagination safety limits and hostname validation for SSRF defense - Document VCS provider configuration in iloom-commands.md * fix(docs): correct typo in draft-pr mode description * docs: add BitBucket integration acknowledgment for NoahCardoza --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com> Co-authored-by: Adam Creeger <adamcreeger@gmail.com>
Fixes #861
feat: complete BitBucket VCS provider integration gaps
Context
PR #609 adds BitBucket VCS provider support. After merging the generic merge mode refactoring (epic #842), a gap analysis identified several places where BitBucket isn't fully wired in.
Important correction: An earlier analysis incorrectly claimed that some MCP PR operations (
get_pr,create_comment(type:pr)) already routed through BitBucket. This was wrong — all MCP PR operations have always been GitHub-only. No BitBucket routing has ever existed in the MCP server.Current State
The MCP server (
src/mcp/issue-management-server.ts) has these PR-related tools, all hardcoded to GitHub:get_prnew GitHubIssueManagementProvider()get_review_commentsnew GitHubIssueManagementProvider()create_comment(type:pr)providerType = 'github'update_comment(type:pr)providerType = 'github'All have comments saying "PRs only exist on GitHub" which is no longer true with BitBucket support.
Additionally,
VersionControlProvider.createPR()returnsPromise<string>(URL only), which meansfinish.tscan never pass a PR number toSessionSummaryServicefor BitBucket PRs.Changes Required
1. Fix
createPR()return typeFiles:
src/lib/VersionControlProvider.ts,src/lib/providers/bitbucket/BitBucketVCSProvider.ts,src/commands/finish.tscreatePR()returnsPromise<string>(line 46) butPRCreationResultinterface already exists (lines 9-13) with{ url, number, wasExisting }createPR()return type toPromise<PRCreationResult>BitBucketVCSProvider.createPR()to return{ url: pr.links.html.href, number: pr.id, wasExisting: false }finish.tsto extractprNumberfrom the resultSessionSummaryServicewhich already has VCS routing code but never gets aprNumberfor BitBucket2. Add BitBucket PR comment API methods to
BitBucketApiClientFile:
src/lib/providers/bitbucket/BitBucketApiClient.tsCurrently only has
addPRComment()for general comments. Need:a)
updatePRComment(workspace, repoSlug, prId, commentId, content)/2.0/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/comments/{comment_id}{ "content": { "raw": "text" } }b)
listPRComments(workspace, repoSlug, prId)/2.0/repositories/{workspace}/{repo_slug}/pullrequests/{pull_request_id}/commentsinlinemetadata (from,to,pathfields)getAllWorkspaceMemberspattern)c)
addInlinePRComment(workspace, repoSlug, prId, content, filePath, line)addPRCommentbut withinline: { to: line, path: filePath }in body3. Add VCS provider methods to
BitBucketVCSProviderFile:
src/lib/providers/bitbucket/BitBucketVCSProvider.tsAdd methods that delegate to
BitBucketApiClient:updatePRComment(prNumber, commentId, body, cwd?)getReviewComments(prNumber, cwd?)— callslistPRComments, filters for comments withinlinepropertycreateReviewComment(prNumber, path, line, body, cwd?)— callsaddInlinePRComment4. Update
VersionControlProviderinterfaceFile:
src/lib/VersionControlProvider.tsAdd to the interface:
updatePRComment(prNumber: number, commentId: string, body: string, cwd?: string): Promise<{ id: string; url: string }>getReviewComments(prNumber: number, cwd?: string): Promise<ReviewComment[]>createReviewComment(prNumber: number, path: string, line: number, body: string, cwd?: string): Promise<{ id: string; url: string }>Define
ReviewCommenttype to match what the MCP tool's output schema expects.5. Route MCP PR operations through VCS provider
File:
src/mcp/issue-management-server.tsThe MCP server needs to load the VCS provider at startup (like it does for issue provider) and route PR operations through it.
a) At startup: initialize a VCS provider from settings using
VCSProviderFactoryb)
get_pr(line 257-263): Use VCS provider'sfetchPR()when BitBucket configured, fall back to GitHubc)
create_comment(type:pr)(line 438-443): Use VCS provider'screatePRComment()when BitBucket configuredd)
update_comment(type:pr)(line 490-495): Use VCS provider'supdatePRComment()when BitBucket configurede)
get_review_comments(line 327-334): Use VCS provider'sgetReviewComments()when BitBucket configuredf) Remove all "PRs only exist on GitHub" comments
6. Documentation
File:
docs/iloom-commands.mdversionControl.providerandversionControl.bitbucketsettingsOut of Scope
Must-Haves
createPR()returnsPRCreationResult({ url, number, wasExisting })BitBucketApiClienthasupdatePRComment(),addInlinePRComment(),listPRComments()methodsBitBucketVCSProviderhasupdatePRComment(),getReviewComments(),createReviewComment()methodsVersionControlProviderinterface updated with new methodspnpm buildsucceedspnpm testpassesdocs/iloom-commands.mdThis PR was created automatically by iloom.