Skip to content

EPIC: Complete BitBucket VCS abstraction — eliminate GitHub-specific assumptions#704

Merged
acreeger merged 8 commits intofeature/bitbucket-integrationfrom
feat/issue-690__bitbucket-vcs-abstraction
Feb 22, 2026
Merged

EPIC: Complete BitBucket VCS abstraction — eliminate GitHub-specific assumptions#704
acreeger merged 8 commits intofeature/bitbucket-integrationfrom
feat/issue-690__bitbucket-vcs-abstraction

Conversation

@acreeger
Copy link
Collaborator

Fixes #690

EPIC: Complete BitBucket VCS abstraction — eliminate GitHub-specific assumptions

Context

PR #609 introduces BitBucket VCS provider and Jira issue tracker support. Code review + deep analysis across 4 dimensions (VCS abstraction layer, command-level hardcoding, settings/config, MCP/issue management) revealed 11 medium+ issues where GitHub is assumed as the only VCS provider.

The PR introduces a two-track architecture: BitBucket uses the new VersionControlProvider abstraction, while GitHub uses the legacy PRManager + gh CLI. This is pragmatic for the initial integration but creates maintenance burden and functional gaps for Jira+BitBucket teams.

Goal: Make BitBucket a first-class VCS provider with full feature parity.


HIGH — Functional Bugs / Gaps

1. il start <pr-number> broken for Jira+BitBucket

Files: start.ts:413-433, 456-465, LoomManager.ts:607-614

When the issue tracker doesn't support PRs (Jira), start.ts falls back to hardcoded GitHubService for PR detection. For a Jira+BitBucket team, il start 42 queries GitHub for PR #42 instead of BitBucket. The same pattern exists in LoomManager.fetchIssueData() (3 instances of hardcoded GitHub fallback).

Fix: Replace GitHubService fallback with VCS-provider-aware routing (check VCSProviderFactory before falling back to GitHub).

2. MCP get_pr hardcodes GitHub provider

File: issue-management-server.ts:256-258

The get_pr tool creates new GitHubIssueManagementProvider() directly, ignoring all provider config. Agents running in BitBucket workspaces cannot read PR details.

Fix: Route get_pr through the VCS provider abstraction or add BitBucket MCP support.

3. MCP PR comments hardcode GitHub

File: issue-management-server.ts:362-363, 412-413

create_comment and update_comment with type: 'pr' are hardcoded to use the GitHub provider. Agent PR comments always go to GitHub even when using BitBucket.

Fix: Route PR comment operations through VCS provider when BitBucket is configured.

4. Init wizard has zero BitBucket awareness

File: templates/prompts/init-prompt.txt:514-784

  • Merge mode options only list local, github-pr, github-draft-pr — missing bitbucket-pr
  • No VCS provider configuration steps
  • No BitBucket credential documentation
  • JSON generation examples don't include versionControl config

Fix: Add bitbucket-pr merge mode, VCS provider selection, and BitBucket config steps to init wizard.


MEDIUM — Incomplete Paths / Limitations

5. summary.ts ignores bitbucket-pr mode

File: summary.ts:64-76

getPRNumberForPosting() handles github-draft-pr and github-pr but not bitbucket-pr. Falls through to undefined, so summaries always post to the issue. Currently documented as intentional in finish.ts:1259-1261, but should be revisited once MCP PR comments support BitBucket (#3).

6. Agent templates hardcode gh CLI commands

File: templates/prompts/issue-prompt.txt:968-987

STEP 5.5 (Auto-Commit and Push) uses gh run list, gh pr view, gh api for CI/CD checks. These fail in BitBucket-only environments.

Fix: Add conditional templating for BitBucket vs GitHub CI/CD check commands.

7. PRManager.generatePRBody() prompt says "GitHub" but serves BitBucket too

Files: PRManager.ts:135, finish.ts:1220-1222

The BitBucket PR workflow calls prManager.generatePRBody() which tells the AI it's writing a "GitHub pull request body". Functionally harmless (Markdown is universal) but misleading.

Fix: Make the prompt provider-agnostic, or have BitBucket use its own body generation.

8. plan.ts error messages assume GitHub or Linear only

File: plan.ts:297-340

Error messages only branch on provider === 'github' vs else (assumed Linear). Jira users get unhelpful error messages referencing LINEAR_API_TOKEN.

Fix: Add Jira-specific error messaging branch.

9. Metadata stores issueTracker but not vcsProvider

File: MetadataManager.ts:12-39

Loom metadata records which issue tracker was used but not the VCS provider. finish/cleanup must re-derive from settings, which is fragile if settings change between start and finish.

Fix: Add vcsProvider field to MetadataFile interface and populate during start.

10. Three near-duplicate PR workflow paths in finish.ts

File: finish.ts:735-864, 1041-1272

github-pr, github-draft-pr, and bitbucket-pr share significant logic (push branch, generate title, get base branch, check existing PR, create PR, transition issue, generate summary, archive metadata, handle cleanup). Adding a 4th VCS provider would require a 4th copy.

Fix: Extract shared PR workflow logic into a common method, with provider-specific operations delegated through the VersionControlProvider interface.

11. SessionSummaryService routes PR summaries via hardcoded GitHub

File: SessionSummaryService.ts:406-409

PR summary posting is hardcoded to use the 'github' provider.

Fix: Route through VCS provider abstraction.


Suggested Implementation Order

  1. Initialize TypeScript Project and CLI Structure #1 (start.ts PR detection) — highest user impact, blocks basic il start for Jira+BitBucket
  2. Core Git Worktree Management Module #2 + GitHub Integration Module #3 (MCP PR routing) — needed for agent workflows with BitBucket PRs
  3. Environment Management Module #4 (init wizard) — needed for discoverability / onboarding
  4. Implement 'start' Command #6 (agent templates) — needed for CI/CD in BitBucket environments
  5. Implement 'cleanup' Command #8 (plan.ts errors) — quick fix, improves Jira UX
  6. Implement 'list' Command #9 (metadata vcsProvider) — small change, improves robustness
  7. Implement 'finish' Command #7, Implement 'switch' Command #10, Claude Context Generation #11 (cleanup / refactoring) — lower urgency but reduces maintenance burden
  8. Database Branch Management (Neon) #5 (summary.ts) — depends on Core Git Worktree Management Module #2/GitHub Integration Module #3

Related


This PR was created automatically by iloom.

@acreeger acreeger force-pushed the feat/issue-690__bitbucket-vcs-abstraction branch from b4e0a6e to 529461d Compare February 22, 2026 18:18
@acreeger acreeger marked this pull request as ready for review February 22, 2026 18:38
@acreeger
Copy link
Collaborator Author

iloom Session Summary

Key Themes:

  • All 7 child issues (Fix il start PR detection for non-GitHub VCS providers #697Refactor finish.ts PR workflows to reduce duplication #703) were implemented in parallel by a swarm and merged cleanly into the epic branch.
  • The vcsProvider metadata field is intentionally typed as string | null (not a union type) to keep the scope minimal — populated from settings.versionControl?.provider ?? 'github' at loom creation time, with null as the backward-compatible fallback for legacy looms.
  • update_comment with type: 'pr' on BitBucket intentionally throws a descriptive error — the BitBucket REST API does not support PR comment editing.

Session Details (click to expand)

Key Insights

  • VCS provider routing pattern: All routing goes through VCSProviderFactory — when settings.versionControl.provider === 'bitbucket', operations use BitBucketVCSProvider; otherwise they fall back to GitHubService. This pattern is now consistent across start.ts, LoomManager.ts, issue-management-server.ts, SessionSummaryService.ts, and finish.ts.
  • finish.ts unification: The three near-duplicate PR workflow paths (github-pr, github-draft-pr, bitbucket-pr) were consolidated into a single executeVCSPRWorkflow method. The method accepts VersionControlProvider | nullnull = GitHub via PRManager, non-null = delegates to the VCS provider. Adding a future VCS provider (e.g. GitLab) requires only implementing the interface, not adding a new code path.
  • Dry-run bug fixed as side effect: The BitBucket path in finish.ts was archiving metadata even in dry-run mode — this was corrected during the Refactor finish.ts PR workflows to reduce duplication #703 refactor.
  • vcsProvider in metadata vs. settings: The field is stored at loom creation time so finish/cleanup don't re-derive from current settings. This prevents breakage if settings change between il start and il finish (e.g. team migrates VCS mid-loom).
  • IS_BITBUCKET template variable: Added to TemplateVariables interface and wired in IgniteCommand.buildTemplateVariables() from settings.versionControl.provider. This is now the canonical way to conditionally render provider-specific content in agent templates.

Decisions Made

  • vcsProvider as string | null, not a typed union: Keeping it as a plain optional string avoids introducing a type contract that could break with future providers. Legacy looms without the field return null and fall back to deriving from settings.
  • update_comment for BitBucket throws, not silently ignores: Documents a real API limitation rather than silently doing nothing, which would be confusing to agents trying to update PR comments.
  • BitBucket CI/CD guidance uses curl + Pipelines REST API: Rather than requiring a BitBucket CLI, the agent template gives curl-based fallback instructions so agents can check pipeline status without additional tooling.

Challenges Resolved

Lessons Learned

  • The VCSProviderFactory abstraction from PR feat: add BitBucket integration for pull request management #609 was designed correctly — all 7 child issues consumed it without needing to modify the interface itself.
  • MCP server tools that hardcode a provider need careful attention: get_pr, create_comment, and update_comment all independently instantiated GitHubIssueManagementProvider directly, bypassing the factory. This pattern should be audited for any future tools added to the MCP server.
  • Template variables for Handlebars conditionals (like IS_BITBUCKET) must be wired in IgniteCommand.buildTemplateVariables() AND declared in the TemplateVariables interface — both are required for the template to render correctly.

Generated with 🤖❤️ by iloom.ai

@acreeger acreeger force-pushed the feature/bitbucket-integration branch from 816f935 to e6fcc36 Compare February 22, 2026 18:42
acreeger and others added 8 commits February 22, 2026 14:00
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
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
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
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.
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
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.
Co-Authored-By: Adam Creeger <acreeger@users.noreply.github.com>
@acreeger acreeger force-pushed the feat/issue-690__bitbucket-vcs-abstraction branch from 2fd27b2 to 0a3240f Compare February 22, 2026 19:00
@acreeger acreeger merged commit 8ae098f into feature/bitbucket-integration Feb 22, 2026
acreeger added a commit that referenced this pull request Feb 23, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant