feat: add BitBucket integration for pull request management#609
feat: add BitBucket integration for pull request management#609acreeger merged 19 commits intoiloom-ai:mainfrom
Conversation
|
Rebasing now |
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>
…s 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>
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>
…VCSProvider 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>
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>
393621d to
ac4ce7d
Compare
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>
ac4ce7d to
e51c314
Compare
|
Hey @NoahCardoza — thanks so much for this PR! Really solid work on the BitBucket integration. The security hygiene (token redaction), error handling patterns, and test coverage are all well done. The We ran a code review and found 3 bugs that we're fixing up now:
Also applying Will push these fixes shortly! |
# Conflicts: # src/cli.ts # src/lib/SettingsManager.test.ts # src/lib/SettingsManager.ts
…eric schema and backwards-compatible transform
…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 iloom-ai#850.
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 iloom-ai#850 lands. fixes iloom-ai#851
…ge 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.
… 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.
…es 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.
…hema 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 iloom-ai#842
…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
VCS Provider Gap AnalysisAfter completing the generic merge mode refactoring (epic #842, merged via NoahCardoza#19), I did a thorough audit of how the new VCS provider abstraction integrates across the codebase. There are several gaps where BitBucket as a VCS provider isn't fully wired in. These are all pre-existing architectural issues — not regressions from #842. Critical Gaps1.
|
| # | Gap | Effort | Impact |
|---|---|---|---|
| 1 | Fix createPR() return type → { url: string; number: number } |
Small | Unblocks session summaries on BB PRs |
| 2 | Add inline comment methods to BitBucketApiClient |
Medium | Enables review comments on BB PRs |
| 3 | Route get_review_comments through VCS provider |
Medium | Agents can read BB review threads |
| 4 | Route update_comment(type:pr) through VCS provider |
Small | Agents can reply to BB reviews |
| 5 | Add VCS provider configuration to docs | Small | Users know how to set up BB |
| 6 | Document supported provider combinations | Small | Clear expectations for mixed setups |
Architecture Investigation: VCS Provider Routing
Executive SummaryThe VCS provider gap analysis from the previous comment identified 8 gaps. After tracing all code paths, I found that several gaps have already been addressed in the current branch -- the MCP server already routes Questions and Key Decisions
HIGH/CRITICAL Risks
Impact Summary
Complete Technical Reference (click to expand for implementation details)Q1: GitHub Issues + BitBucket VCS CombinationHow
|
| Tool | Issue type routing | PR type routing |
|---|---|---|
get_issue |
ISSUE_PROVIDER env var |
N/A |
get_pr |
N/A | bitBucketVCSProvider if set, else GitHubIssueManagementProvider |
get_review_comments |
N/A | Always GitHubIssueManagementProvider (hardcoded) |
get_comment |
ISSUE_PROVIDER env var |
N/A |
create_comment |
ISSUE_PROVIDER for issue type |
bitBucketVCSProvider for PR type if set, else 'github' hardcoded |
update_comment |
ISSUE_PROVIDER for issue type |
Throws error if bitBucketVCSProvider set for PR type, else 'github' hardcoded |
What would need to change for full VCS routing
The MCP server already has the basic routing structure in place. Remaining items:
- Fix
update_commentto support BitBucket PR comment updates (add PUT method toBitBucketApiClient) - Add
get_review_commentsrouting throughbitBucketVCSProvider(requires newlistPRCommentsmethod with inline support) - The settings-based initialization approach works well -- no additional env vars needed
Affected Files
/src/lib/VersionControlProvider.ts:40-46--createPR()method returnsPromise<string>, should returnPromise<PRCreationResult>(the interface is already defined at line 9-13 but unused)/src/lib/providers/bitbucket/BitBucketVCSProvider.ts:112-165--createPR()returnspr.links.html.href(string), haspr.idavailable at line 155 but discards it/src/commands/finish.ts:1192-1199-- VCS provider path setsprNumber = undefinedbecausecreatePR()returns string/src/mcp/issue-management-server.ts:539-545--update_commentthrows for BitBucket PRs with incorrect claim that API doesn't support it/src/mcp/issue-management-server.ts:356-383--get_review_commentshardcoded to GitHub/src/lib/providers/bitbucket/BitBucketApiClient.ts-- MissingupdatePRComment(),addInlineComment(),listPRComments()methods/src/mcp/types.ts:33--GetPRInputdoc comment says "PRs only exist on GitHub" (stale)/src/lib/LoomManager.ts:234-329-- Draft PR creation hardcoded toPRManager/src/commands/finish.ts:866-868--markPRReady()hardcoded toPRManager
Integration Points
finish.tscallsSessionSummaryService.generateAndPostSummary()withprNumberfromexecuteVCSPRWorkflowSessionSummaryService.postSummaryToIssue()callsVCSProviderFactory.create(settings)to decide BitBucket vs GitHub routing- MCP
issue-management-server.tsmain()callsBitBucketVCSProvider.fromSettings(settings)to initialize the module-levelbitBucketVCSProvider - All MCP PR tool handlers check
bitBucketVCSProvidertruthiness to decide routing BitBucketVCSProviderdelegates toBitBucketApiClientfor all REST API calls
Medium Severity Risks
- Draft PR mode has no VCS provider abstraction: If a user configures
github-draft-prmerge mode with BitBucket VCS,LoomManagerwill try to usegh prCLI commands which will fail. There's no validation preventing this combination. - MCP server settings resolution path: The MCP server calls
loadSettings()without arguments (line 1114), which means it resolves settings fromprocess.cwd(). If the MCP server's working directory differs from the loom worktree, it might load wrong settings or fail to find them.
…oom-ai#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
Code Review: GitHub Flow VerificationRan 4 parallel review agents focused on verifying the default GitHub flow is preserved after the BitBucket integration + epic #842 merge mode refactoring + issue #861 MCP routing work. Result: Ready to mergeAll 4,634 tests pass across 138 test files. The default GitHub flow is fully preserved across:
Minor Findings (non-breaking, for future reference)
Thanks @NoahCardoza for the excellent foundation on this PR! The BitBucket integration, security hygiene (token redaction), error handling patterns, and test coverage were all well done. The |
I'm not sure if this is referring to Bitbucket as a service or our interface with Bitbucket. Bitbucket does support draft PR's, which is a rather new feature (released almost exactly a year ago), relative to GitHub at least. I may be able to look into adding this functionality. |
Summary
Test plan
pnpm buildcompiles successfullypnpm test— all 3937 tests passcheckForExistingPRerror propagation (401/403 re-thrown, network errors return null)redactSensitiveFields(null/undefined, primitives, sensitive keys, nested objects, arrays)parseGitRemotes(HTTPS/SSH, with/without .git)🤖 Generated with Claude Code