Skip to content

Fix#163

Open
marcode04 wants to merge 1 commit into
easingthemes:mainfrom
marcode04:feature/bitbucket-support
Open

Fix#163
marcode04 wants to merge 1 commit into
easingthemes:mainfrom
marcode04:feature/bitbucket-support

Conversation

@marcode04

@marcode04 marcode04 commented Jun 2, 2026

Copy link
Copy Markdown
Contributor

PR Description

What does this PR do?

Extends dx-pr-review, dx-pr-answer, and dx-init to support Bitbucket Cloud and Bitbucket Data Center alongside the existing Azure DevOps path. Adds platform detection, per-platform API branching, a shared Bitbucket REST reference, and auto-detection of Bitbucket remotes in detect-env.sh.

Why?

dx-pr-review and dx-pr-answer were hardwired to Azure DevOps — every API call used mcp__ado__* tools. Teams on Bitbucket Cloud or Bitbucket DC got an immediate failure with no fallback. Since AEM projects frequently live on Bitbucket, this blocked a large share of users from the core PR workflow entirely.

What changed

Platform detection added to steps 1, 2, 3, 8, 9 of dx-pr-review and steps 1–3, 5, 7 of dx-pr-answer.
Each step that previously made an unconditional ADO MCP call now detects PLATFORM from the URL or scm.provider config and branches: ADO keeps its existing MCP path unchanged; Bitbucket uses curl with a bearer token (BITBUCKET_TOKEN env → scm.bitbucket-token config).

Key API differences handled:

  • Bitbucket has no thread objects — comments are flat, grouped by parent.id
  • Inline comments: Cloud uses inline.path/to; DC uses anchor.line/lineType/fileType/path
  • Votes: Cloud = POST /approve or POST /request-changes; DC = POST /approve or PUT /participants/{slug} with status: NEEDS_WORK
  • Identity for skip-own-PR: ADO/DC expose email; Cloud exposes author.nickname only

Type of Change

  • Bug fix (patch)
  • New skill/agent (minor)
  • Enhancement to existing skill/agent (minor)
  • Breaking change (major)
  • Documentation only

Checklist

  • No hardcoded org URLs, project names, paths, or branch names
  • New config fields documented in docs/reference/config-reference.md
  • Skill/agent catalogs updated if applicable
  • Shell scripts are chmod +x
  • Version bumped in all 4 version files (if non-trivial change)
  • Tested manually by running the skill in a test project

Files Changed

File Change
shared/bitbucket-config.md New — full Bitbucket REST API reference (endpoints, request bodies, vote mapping, idempotency)
skills/dx-pr-review/SKILL.md Platform detection + branching in steps 1–3, 8–9, follow-up mode
skills/dx-pr-review/references/post-findings.md Multi-platform posting and vote procedure
skills/dx-pr-answer/SKILL.md Platform detection + branching in steps 1–3, 5, 7
skills/dx-pr-answer/references/apply-fixes.md Bitbucket reply-after-fix sections added
shared/provider-config.md Bitbucket added to valid provider list
templates/config.yaml.template Bitbucket provider options and repos[] workspace/project fields
skills/dx-init/scripts/detect-env.sh Auto-detects Bitbucket Cloud/DC from git remote; extracts workspace, project, host, repo slug
skills/dx-init/SKILL.md Config generation for Bitbucket projects; fixed scm.provider vs tracker.provider conflation bug
docs/reference/config-reference.md Bitbucket fields documented
docs/bitbucket-pr-review-support.md Implementation notes and known gaps

Known Gaps

Gap Notes
discover-review-queue.sh is ADO-only Autonomous PR-review queue won't discover Bitbucket PRs — needs a separate script
dx-doctor doesn't validate Bitbucket config Missing bitbucket-host or BITBUCKET_TOKEN won't be caught
Bitbucket Cloud own-PR detection Requires BITBUCKET_USERNAME / scm.bitbucket-username — Cloud doesn't expose author email
dx-pr / dx-pr-commit PR creation ADO-only, out of scope

Environment Tested

Field Value
Platform Claude Code
Model
OS

@easingthemes easingthemes left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review of the Bitbucket support changes. Overall a clean, additive implementation — the ADO path is untouched and the API-difference handling (flat comments grouped by parent.id, Cloud inline.* vs DC anchor.*, vote clamping on all platforms) is accurate. A few robustness notes inline, plus two non-blocking process items:

  • PR title is Fix — this is a feat (new Bitbucket support, minor bump). Since the repo runs semantic-release on conventional-commit prefixes, a squash-merge of Fix won't trigger the intended minor release. Suggest feat: add Bitbucket Cloud + DC support to dx-pr-review/answer/init.
  • Description lists docs/bitbucket-pr-review-support.md in the Files Changed table, but it's not in the diff (10 files changed, 11 rows). Verify whether that doc was meant to ship.

Nothing blocking — recommend addressing the unanchored-grep parsing (flagged inline, it recurs in 4 files) before merge.

2. `scm.bitbucket-token` from `.ai/config.yaml`

```bash
TOKEN="${BITBUCKET_TOKEN:-$(grep 'bitbucket-token:' .ai/config.yaml 2>/dev/null | awk '{print $2}' | tr -d '"')}"

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Medium] Unanchored grep matches commented template lines.

The generated config ships bitbucket-token/bitbucket-host as commented examples (# bitbucket-token: ""). grep 'bitbucket-token:' matches that comment, and awk '{print $2}' on # bitbucket-token: "" returns the literal bitbucket-token:.

Failure mode: a Bitbucket project where the user relies on BITBUCKET_TOKEN but it's unset and the line stays commented → TOKEN becomes the garbage string bitbucket-token: (non-empty), so the [ -z "$TOKEN" ] guard passes and curl sends Authorization: Bearer bitbucket-token: → an opaque 401 instead of the intended clear "token not found, exit 2".

Same hazard for BB_HOST: if a real value coexists with the example comment, grep returns two lines and BB_BASE becomes a malformed multi-line URL.

This grep pattern recurs in dx-pr-review/SKILL.md, dx-pr-answer/SKILL.md, and post-findings.md. Fix it here (the shared source of truth) and reference it:

TOKEN="${BITBUCKET_TOKEN:-$(grep -E '^[[:space:]]*bitbucket-token:' .ai/config.yaml 2>/dev/null | head -1 | awk '{print $2}' | tr -d '\"')}"

```bash
# Resolve slug from email
USER_SLUG=$(curl -s -H "Authorization: Bearer $TOKEN" \
"$BASE/users?filter={email}" | jq -r '.values[0].slug')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Low] Email isn't URL-encoded in the ?filter= query param. @ and + are unencoded query values here. Most DC instances tolerate raw @, but it's fragile. Also worth a note that the subsequent participant PUT /participants/{slug} assumes the user is already a participant/reviewer on the PR — some DC versions reject the status change otherwise.

If no URL was provided (PR ID only), read `scm.provider` from `.ai/config.yaml`:

```bash
PLATFORM=$(grep 'provider:' .ai/config.yaml | head -1 | awk '{print $2}' | tr -d '"')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Low] PLATFORM detection relies on scm.provider being the first provider: in the file. Works today only because scm: precedes tracker: in the template, and grep also matches commented # provider: lines. It silently breaks if blocks are reordered or scm.provider is commented. Suggest anchoring: grep -E '^[[:space:]]*provider:' ... | head -1 (or scope to the scm: block).

For Bitbucket DC, also read the host:

```bash
BB_HOST=$(grep 'bitbucket-host:' .ai/config.yaml | awk '{print $2}' | tr -d '"')

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same unanchored-grep issue as flagged in shared/bitbucket-config.md (line 37): grep 'bitbucket-host:' will match the commented template example. If both the example comment and a real value are present, BB_HOST captures two lines → malformed BB_BASE. Use grep -E '^[[:space:]]*bitbucket-host:' ... | head -1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants