Skip to content

Refactor merge mode from provider-specific to generic (pr, draft-pr)#859

Draft
acreeger wants to merge 12 commits intofeature/bitbucket-integrationfrom
refactor/issue-842__provider-to-generic
Draft

Refactor merge mode from provider-specific to generic (pr, draft-pr)#859
acreeger wants to merge 12 commits intofeature/bitbucket-integrationfrom
refactor/issue-842__provider-to-generic

Conversation

@acreeger
Copy link
Copy Markdown
Collaborator

@acreeger acreeger commented Mar 1, 2026

Fixes #842

Refactor merge mode from provider-specific to generic (pr, draft-pr)

Problem

The mergeBehavior.mode setting currently bakes the VCS provider name into the mode value: local, github-pr, github-draft-pr, bitbucket-pr. This creates a combinatorial explosion as we add providers — each new VCS provider needs its own mode variants. It also forces users to change their merge mode if they switch VCS providers.

Desired Behavior

Decouple the merge strategy from the VCS provider:

  • mergeBehavior.mode becomes: local | pr | draft-pr
  • The VCS provider (versionControl.provider) determines how the PR is created
  • draft-pr should be skipped/downgraded gracefully if the provider doesn't support draft PRs (BitBucket doesn't)

Scope

Key areas that reference the current provider-specific modes:

  • Schema: src/lib/SettingsManager.ts — enum definitions (2 schemas: with and without defaults)
  • Finish command: src/commands/finish.ts — branches on mode for PR creation logic
  • Init wizard: templates/prompts/init-prompt.txt — merge mode selection step
  • Summary: src/commands/summary.ts — displays merge mode
  • Telemetry: src/types/telemetry.tsmerge_behavior property
  • Tests: across finish, settings, and init
  • Migration: Need a settings migration to map github-pr to pr, github-draft-pr to draft-pr, bitbucket-pr to pr for existing users

Constraints

  • Must be backwards-compatible via migration (old settings auto-upgrade)
  • finish.ts already has a unified createVCSPullRequest method — the mode branching that selects it should simplify
  • BitBucket doesn't support draft PRs — if draft-pr is selected with BitBucket provider, either warn at init time or fall back to regular PR at finish time

This PR was created automatically by iloom.

NoahCardoza and others added 12 commits February 22, 2026 22:13
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>
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>
- Add bitbucket-pr to JSON mode validation guard to prevent interactive
  hang in CI/scripted workflows
- Add pagination to listPullRequests matching getAllWorkspaceMembers pattern
- Add --mine flag support for BitBucket PR listing via current user filtering
- Apply prTitlePrefix setting to GitHub PRs for consistency with BitBucket
…assumptions (#704)

* feat: add VCS-conditional CI/CD commands in agent template STEP 5.5

Replace hardcoded gh CLI commands in STEP 5.5 (Auto-Commit and Push)
with a Handlebars conditional that branches on IS_BITBUCKET:
- GitHub path retains existing gh run list, gh pr view, gh api commands
- BitBucket path provides BitBucket Pipelines API guidance via curl

Wire IS_BITBUCKET template variable in IgniteCommand.buildTemplateVariables()
from settings.versionControl.provider and add it to TemplateVariables interface.

fixes #700

* feat: add BitBucket support to init wizard

Update init-prompt.txt to include BitBucket as a VCS provider option:
- Add VCS provider selection step (Step 1b) between issue tracker and
  provider-specific config, offering GitHub (default) or BitBucket
- Add BitBucket credential configuration step (Step 2b) asking for
  username, API token (stored in settings.local.json only), and
  optional workspace slug
- Add bitbucket-pr as a merge mode option alongside local, github-pr,
  github-draft-pr; auto-suggest it when BitBucket VCS is selected
- Extract currentVCSProvider, currentBitBucketUsername,
  currentBitBucketApiToken, currentBitBucketWorkspace in Phase 0
- Display BitBucket fields in Phase 0 current config and Phase 3 summary
- Add versionControl JSON generation rules (item 6) with proper file
  split: provider in settings.json, credentials in settings.local.json
- Update mergeBehavior note to include bitbucket-pr as a valid mode
- Add BitBucket VCS configuration example in Advanced Configuration
- Add combined Jira + BitBucket configuration example showing the full
  dual-provider setup with proper file separation
- Renumber Advanced Configuration items to maintain consistent ordering
- Update Phase 9 wrap-up to mention BitBucket PR workflow option

fixes #699

* fixes #702

Add vcsProvider field to loom metadata

- Add `vcsProvider?: string` to MetadataFile interface
- Add `vcsProvider?: string` to WriteMetadataInput interface
- Add `vcsProvider: string | null` to LoomMetadata interface
- Update toMetadata() to map vcsProvider with null fallback for legacy looms
- Update writeMetadata() to persist vcsProvider when provided
- Populate vcsProvider in createIloom() and reuseIloom() from settings.versionControl.provider
- Add unit tests verifying GitHub and BitBucket VCS provider population and backward compatibility

* fixes #697

Replace hardcoded GitHubService fallback in PR detection with VCS-provider-aware routing, so `il start <pr-number>` works for Jira+BitBucket teams. Both `start.ts` and `LoomManager.fetchIssueData()` now check for a configured `VersionControlProvider` before falling back to GitHub.

* fixes #698

Route MCP get_pr, create_comment, and update_comment tools through the
configured VCS provider. When versionControl.provider is 'bitbucket' in
settings, PR operations use BitBucketVCSProvider instead of hardcoding
GitHubIssueManagementProvider.

- get_pr: fetches PR data from BitBucket via fetchPR() when configured
- create_comment type:pr: posts comment to BitBucket PR via createPRComment()
- update_comment type:pr: throws descriptive error (BitBucket REST API
  does not support PR comment editing)
- GitHub path unchanged; no regression for existing GitHub users
- BitBucketApiClient does not log Authorization header or credentials
- Added unit tests covering both GitHub fallback and BitBucket routing paths

* fixes #703

Unify github-pr and bitbucket-pr code paths in finish.ts into a single
executeVCSPRWorkflow method that delegates provider-specific operations
through VersionControlProvider. Pass null for GitHub (uses PRManager),
pass a VersionControlProvider for BitBucket. Reads vcsProvider from
loom metadata for routing context when in bitbucket-pr mode.

Net reduction of 67 lines. All 4268 tests pass.

* fixes #701

Co-Authored-By: Adam Creeger <acreeger@users.noreply.github.com>

* Fixes #690

---------

Co-authored-by: Adam Creeger <acreeger@users.noreply.github.com>
- Fix error swallowing in start.ts PR detection (only catch 404s)
- Fix error swallowing in checkForExistingPR (only return null for 404)
- Bound workspace member pagination to 10 pages max
- Replace dynamic imports with static imports in finish.ts BitBucket path
- Add vcs_provider telemetry to loom.created, bitbucket-pr to loom.finished
- Improve MCP fallback warning when BitBucket config is invalid
- Pass prNumber to session summary for BitBucket PRs
Resolve conflicts in:
- src/commands/start.ts: keep both VCS and recap imports
- src/lib/SettingsManager.test.ts: keep both redactSensitiveFields and subAgentTimeout tests
- src/mcp/issue-management-server.ts: keep BitBucket routing + add Jira sanitization
- templates/prompts/init-prompt.txt: keep BitBucket config examples + add Swarm Quality Mode and Color Sync sections
@acreeger acreeger force-pushed the feature/bitbucket-integration branch from 86d53a8 to d1b85f2 Compare March 1, 2026 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants