@tempo-ai/visual-review 0.0.140 → 0.0.141

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../git-provider/bitbucket/api.ts","../src/bitbucket-report.ts"],"sourcesContent":["/**\n * Bitbucket Cloud REST 2.0 client.\n *\n * Runs anywhere `fetch` exists (Electron main, Convex actions, Vercel\n * functions, the hosted MCP). The base URL is injectable so hermetic tests\n * point it at a local fake that speaks the same wire format; production\n * always uses `https://api.bitbucket.org/2.0`.\n *\n * Authentication is a Bearer OAuth access token (REST convention). Git\n * transport uses `x-token-auth:<token>` instead — see `../git-credentials`.\n */\n\nexport const BITBUCKET_API_BASE_URL = \"https://api.bitbucket.org/2.0\";\n\nexport type BitbucketErrorKind =\n | \"unauthorized\"\n | \"forbidden\"\n | \"not_found\"\n | \"conflict\"\n | \"invalid\"\n | \"rate_limited\"\n | \"server\"\n | \"network\";\n\nexport class BitbucketApiError extends Error {\n readonly kind: BitbucketErrorKind;\n readonly status: number | null;\n readonly retryAfterMs: number | null;\n readonly detail: string | null;\n\n constructor(args: {\n kind: BitbucketErrorKind;\n status: number | null;\n message: string;\n retryAfterMs?: number | null;\n detail?: string | null;\n }) {\n super(args.message);\n this.name = \"BitbucketApiError\";\n this.kind = args.kind;\n this.status = args.status;\n this.retryAfterMs = args.retryAfterMs ?? null;\n this.detail = args.detail ?? null;\n }\n}\n\n/** User-facing recovery text for an API failure — never mentions GitHub. */\nexport function describeBitbucketError(error: unknown): string {\n if (!(error instanceof BitbucketApiError)) {\n return error instanceof Error ? error.message : String(error);\n }\n switch (error.kind) {\n case \"unauthorized\":\n return \"Your Bitbucket connection expired. Reconnect Bitbucket in Settings → Connections.\";\n case \"forbidden\":\n return \"Your Bitbucket account doesn't have permission for this repository. Ask a workspace admin for write access, then reconnect Bitbucket.\";\n case \"not_found\":\n return \"Bitbucket couldn't find that repository. Check the workspace and repository name, and that your connected account can see it.\";\n case \"rate_limited\":\n return \"Bitbucket is rate limiting requests. Try again in a minute.\";\n case \"network\":\n return \"Couldn't reach Bitbucket. Check your network connection and try again.\";\n case \"conflict\":\n return error.detail ?? \"Bitbucket rejected the change because the repository changed. Refresh and try again.\";\n case \"invalid\":\n return error.detail ?? \"Bitbucket rejected the request.\";\n case \"server\":\n return \"Bitbucket returned a server error. Try again shortly.\";\n }\n}\n\nexport interface BitbucketLink {\n href: string;\n name?: string;\n}\n\nexport interface BitbucketAccount {\n uuid: string;\n account_id?: string;\n username?: string;\n nickname?: string;\n display_name?: string;\n links?: { avatar?: BitbucketLink; html?: BitbucketLink };\n}\n\nexport interface BitbucketWorkspace {\n uuid: string;\n slug: string;\n name: string;\n links?: { avatar?: BitbucketLink; html?: BitbucketLink };\n}\n\n/** One `GET /user/workspaces` row: a workspace the user can access. */\nexport interface BitbucketWorkspaceAccess {\n /** True when the user administers the workspace. */\n administrator: boolean;\n workspace: BitbucketWorkspace;\n}\n\nexport interface BitbucketRepository {\n uuid: string;\n full_name: string;\n name: string;\n slug?: string;\n is_private: boolean;\n mainbranch?: { name: string } | null;\n workspace?: BitbucketWorkspace;\n links?: {\n html?: BitbucketLink;\n clone?: BitbucketLink[];\n };\n updated_on?: string;\n}\n\nexport interface BitbucketBranch {\n name: string;\n target: { hash: string; date?: string };\n}\n\nexport type BitbucketPullRequestState = \"OPEN\" | \"MERGED\" | \"DECLINED\" | \"SUPERSEDED\";\n\nexport interface BitbucketParticipant {\n user: BitbucketAccount;\n role: \"PARTICIPANT\" | \"REVIEWER\";\n approved: boolean;\n state?: \"approved\" | \"changes_requested\" | null;\n participated_on?: string | null;\n}\n\nexport interface BitbucketPullRequest {\n id: number;\n title: string;\n description?: string;\n state: BitbucketPullRequestState;\n draft?: boolean;\n author?: BitbucketAccount;\n source: {\n branch: { name: string };\n commit?: { hash: string } | null;\n repository?: { full_name: string; uuid?: string };\n };\n destination: {\n branch: { name: string };\n commit?: { hash: string } | null;\n repository?: { full_name: string; uuid?: string };\n };\n merge_commit?: { hash: string } | null;\n participants?: BitbucketParticipant[];\n reviewers?: BitbucketAccount[];\n close_source_branch?: boolean;\n created_on?: string;\n updated_on?: string;\n links: { html: BitbucketLink; [name: string]: BitbucketLink | undefined };\n}\n\nexport type BitbucketCommitStatusState = \"SUCCESSFUL\" | \"FAILED\" | \"INPROGRESS\" | \"STOPPED\";\n\nexport interface BitbucketCommitStatus {\n key: string;\n state: BitbucketCommitStatusState;\n name?: string;\n description?: string;\n url?: string;\n refname?: string | null;\n created_on?: string;\n updated_on?: string;\n}\n\nexport interface BitbucketWebhook {\n uuid: string;\n url: string;\n description?: string;\n active: boolean;\n events: string[];\n secret_set?: boolean;\n}\n\nexport interface BitbucketPage<T> {\n values: T[];\n next?: string;\n page?: number;\n pagelen?: number;\n size?: number;\n}\n\nexport type BitbucketMergeStrategy = \"merge_commit\" | \"squash\" | \"fast_forward\";\n\n/**\n * Host-provided Bitbucket REST access for MCP servers (comments MCP,\n * visual-review setup, AI repository tools). The host authenticates as the\n * signed-in user; `path` is relative to the 2.0 base. Rejects with a\n * `BitbucketApiError` (or an Error carrying recovery copy when the user has\n * no connection).\n */\nexport type BitbucketApiHook = (request: {\n method: \"GET\" | \"POST\" | \"PUT\" | \"DELETE\";\n path: string;\n body?: unknown;\n /** Which connected Bitbucket account; default = the user's first. */\n accountUuid?: string;\n}) => Promise<unknown>;\n\nexport interface BitbucketClientOptions {\n /** OAuth access token, or a getter (lets the caller refresh lazily). */\n accessToken: string | (() => Promise<string>);\n baseUrl?: string;\n fetch?: typeof fetch;\n /** Retries for 429/5xx before surfacing the error. Default 2. */\n maxRetries?: number;\n /** Injected for tests; defaults to a real timer. */\n sleep?: (ms: number) => Promise<void>;\n /** Cap on items `paginate` collects. Default 1000. */\n maxItems?: number;\n}\n\nfunction kindForStatus(status: number): BitbucketErrorKind {\n if (status === 401) return \"unauthorized\";\n if (status === 403) return \"forbidden\";\n if (status === 404) return \"not_found\";\n if (status === 409) return \"conflict\";\n if (status === 429) return \"rate_limited\";\n if (status >= 500) return \"server\";\n return \"invalid\";\n}\n\nfunction errorDetail(body: unknown): string | null {\n if (body && typeof body === \"object\") {\n const err = (body as { error?: { message?: unknown; detail?: unknown } }).error;\n if (err && typeof err.message === \"string\") {\n return typeof err.detail === \"string\" ? `${err.message}: ${err.detail}` : err.message;\n }\n }\n return typeof body === \"string\" && body.trim() ? body.trim().slice(0, 500) : null;\n}\n\nconst enc = (segment: string) => encodeURIComponent(segment);\n\nexport class BitbucketClient {\n private readonly baseUrl: string;\n private readonly fetchImpl: typeof fetch;\n private readonly maxRetries: number;\n private readonly sleep: (ms: number) => Promise<void>;\n private readonly maxItems: number;\n private readonly options: BitbucketClientOptions;\n\n constructor(options: BitbucketClientOptions) {\n this.options = options;\n this.baseUrl = (options.baseUrl ?? BITBUCKET_API_BASE_URL).replace(/\\/+$/, \"\");\n this.fetchImpl = options.fetch ?? ((input, init) => fetch(input, init));\n this.maxRetries = options.maxRetries ?? 2;\n this.sleep = options.sleep ?? ((ms) => new Promise((r) => setTimeout(r, ms)));\n this.maxItems = options.maxItems ?? 1000;\n }\n\n private async token(): Promise<string> {\n const t = this.options.accessToken;\n return typeof t === \"function\" ? t() : t;\n }\n\n private url(pathOrUrl: string): string {\n if (!/^https?:\\/\\//.test(pathOrUrl)) return `${this.baseUrl}${pathOrUrl}`;\n // Absolute URLs come from responses (pagination `next`, `links.*`). The\n // bearer token goes with every request, so never follow one off the API\n // origin.\n if (new URL(pathOrUrl).origin !== new URL(this.baseUrl).origin) {\n throw new BitbucketApiError({\n kind: \"invalid\",\n status: null,\n message: \"Bitbucket returned a link outside its API; Tempo didn't follow it.\",\n });\n }\n return pathOrUrl;\n }\n\n /** Low-level request. Retries 429/5xx with `Retry-After`-aware backoff. */\n async request<T>(\n method: string,\n pathOrUrl: string,\n body?: unknown,\n opts: { raw?: boolean } = {},\n ): Promise<T> {\n const target = this.url(pathOrUrl);\n let attempt = 0;\n for (;;) {\n let res: Response;\n try {\n res = await this.fetchImpl(target, {\n method,\n headers: {\n Authorization: `Bearer ${await this.token()}`,\n Accept: \"application/json\",\n ...(body !== undefined ? { \"Content-Type\": \"application/json\" } : {}),\n },\n body: body !== undefined ? JSON.stringify(body) : undefined,\n });\n } catch (cause) {\n throw new BitbucketApiError({\n kind: \"network\",\n status: null,\n message: `Bitbucket request failed: ${cause instanceof Error ? cause.message : String(cause)}`,\n });\n }\n\n if (res.ok) {\n if (res.status === 204) return undefined as T;\n if (opts.raw) return (await res.text()) as T;\n const text = await res.text();\n return (text ? JSON.parse(text) : undefined) as T;\n }\n\n const retryAfterHeader = res.headers.get(\"retry-after\");\n const retryAfterMs = retryAfterHeader ? Number(retryAfterHeader) * 1000 : null;\n const retriable = res.status === 429 || res.status >= 500;\n if (retriable && attempt < this.maxRetries) {\n attempt += 1;\n await this.sleep(Math.min(retryAfterMs ?? 500 * 2 ** attempt, 10_000));\n continue;\n }\n\n const rawBody = await res.text().catch(() => \"\");\n let parsed: unknown = rawBody;\n try {\n parsed = rawBody ? JSON.parse(rawBody) : rawBody;\n } catch {\n // keep the text body\n }\n const detail = errorDetail(parsed);\n throw new BitbucketApiError({\n kind: kindForStatus(res.status),\n status: res.status,\n message: `Bitbucket ${method} ${pathOrUrl} failed with ${res.status}${detail ? `: ${detail}` : \"\"}`,\n retryAfterMs,\n detail,\n });\n }\n }\n\n /** Follow `next` links until exhausted or `maxItems` collected. */\n async paginate<T>(path: string, limit = this.maxItems): Promise<T[]> {\n const out: T[] = [];\n let next: string | undefined = path;\n while (next && out.length < limit) {\n const page: BitbucketPage<T> = await this.request<BitbucketPage<T>>(\"GET\", next);\n out.push(...page.values);\n next = page.next;\n }\n return out.slice(0, limit);\n }\n\n // ── Account ────────────────────────────────────────────────────────────\n\n getCurrentUser(): Promise<BitbucketAccount> {\n return this.request(\"GET\", \"/user\");\n }\n\n /**\n * Workspaces the user can access, with whether they administer each\n * (`GET /user/workspaces`; scope `account`). Replaces the removed\n * `/user/permissions/workspaces`.\n */\n listWorkspaces(): Promise<BitbucketWorkspaceAccess[]> {\n return this.paginate(\"/user/workspaces?pagelen=100\");\n }\n\n // ── Repositories ───────────────────────────────────────────────────────\n\n getRepository(workspace: string, repo: string): Promise<BitbucketRepository> {\n return this.request(\"GET\", `/repositories/${enc(workspace)}/${enc(repo)}`);\n }\n\n createRepository(\n workspace: string,\n slug: string,\n opts: { isPrivate?: boolean; description?: string; projectKey?: string } = {},\n ): Promise<BitbucketRepository> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(slug)}`, {\n scm: \"git\",\n is_private: opts.isPrivate ?? true,\n ...(opts.description ? { description: opts.description } : {}),\n ...(opts.projectKey ? { project: { key: opts.projectKey } } : {}),\n });\n }\n\n listBranches(workspace: string, repo: string, limit = 500): Promise<BitbucketBranch[]> {\n return this.paginate(\n `/repositories/${enc(workspace)}/${enc(repo)}/refs/branches?pagelen=100&sort=-target.date`,\n limit,\n );\n }\n\n getBranch(workspace: string, repo: string, branch: string): Promise<BitbucketBranch> {\n return this.request(\n \"GET\",\n `/repositories/${enc(workspace)}/${enc(repo)}/refs/branches/${enc(branch)}`,\n );\n }\n\n getCommit(workspace: string, repo: string, ref: string): Promise<{ hash: string; date?: string; parents?: { hash: string }[] }> {\n return this.request(\"GET\", `/repositories/${enc(workspace)}/${enc(repo)}/commit/${enc(ref)}`);\n }\n\n /** Raw file content at `ref` (commit, branch or tag). */\n getFileContent(workspace: string, repo: string, ref: string, path: string): Promise<string> {\n const p = path.split(\"/\").map(enc).join(\"/\");\n return this.request(\"GET\", `/repositories/${enc(workspace)}/${enc(repo)}/src/${enc(ref)}/${p}`, undefined, {\n raw: true,\n });\n }\n\n // ── Pull requests ──────────────────────────────────────────────────────\n\n /**\n * PRs whose source branch is `branch`, newest first. Includes every state\n * by default so a merged PR keeps resolving after its branch is deleted.\n */\n listPullRequestsForBranch(\n workspace: string,\n repo: string,\n branch: string,\n states: BitbucketPullRequestState[] = [\"OPEN\", \"MERGED\", \"DECLINED\", \"SUPERSEDED\"],\n ): Promise<BitbucketPullRequest[]> {\n const q = encodeURIComponent(`source.branch.name = \"${branch.replace(/\"/g, '\\\\\"')}\"`);\n const stateParams = states.map((s) => `state=${s}`).join(\"&\");\n return this.paginate(\n `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests?q=${q}&${stateParams}&sort=-updated_on&pagelen=50`,\n 50,\n );\n }\n\n listPullRequests(\n workspace: string,\n repo: string,\n opts: { states?: BitbucketPullRequestState[]; query?: string; limit?: number } = {},\n ): Promise<BitbucketPullRequest[]> {\n const params: string[] = [\"sort=-updated_on\", \"pagelen=50\"];\n for (const s of opts.states ?? [\"OPEN\"]) params.push(`state=${s}`);\n if (opts.query) params.push(`q=${encodeURIComponent(opts.query)}`);\n return this.paginate(\n `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests?${params.join(\"&\")}`,\n opts.limit ?? 200,\n );\n }\n\n getPullRequest(workspace: string, repo: string, id: number): Promise<BitbucketPullRequest> {\n return this.request(\"GET\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}`);\n }\n\n createPullRequest(\n workspace: string,\n repo: string,\n input: {\n title: string;\n description?: string;\n sourceBranch: string;\n destinationBranch?: string;\n draft?: boolean;\n reviewers?: { uuid: string }[];\n closeSourceBranch?: boolean;\n /** Fork PRs: the source repository's full name. */\n sourceRepository?: string;\n },\n ): Promise<BitbucketPullRequest> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests`, {\n title: input.title,\n ...(input.description !== undefined ? { description: input.description } : {}),\n source: {\n branch: { name: input.sourceBranch },\n ...(input.sourceRepository ? { repository: { full_name: input.sourceRepository } } : {}),\n },\n ...(input.destinationBranch ? { destination: { branch: { name: input.destinationBranch } } } : {}),\n ...(input.draft !== undefined ? { draft: input.draft } : {}),\n ...(input.reviewers ? { reviewers: input.reviewers } : {}),\n ...(input.closeSourceBranch !== undefined ? { close_source_branch: input.closeSourceBranch } : {}),\n });\n }\n\n updatePullRequest(\n workspace: string,\n repo: string,\n id: number,\n patch: { title?: string; description?: string; draft?: boolean; reviewers?: { uuid: string }[]; destinationBranch?: string },\n ): Promise<BitbucketPullRequest> {\n return this.request(\"PUT\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}`, {\n ...(patch.title !== undefined ? { title: patch.title } : {}),\n ...(patch.description !== undefined ? { description: patch.description } : {}),\n ...(patch.draft !== undefined ? { draft: patch.draft } : {}),\n ...(patch.reviewers !== undefined ? { reviewers: patch.reviewers } : {}),\n ...(patch.destinationBranch ? { destination: { branch: { name: patch.destinationBranch } } } : {}),\n });\n }\n\n approvePullRequest(workspace: string, repo: string, id: number): Promise<BitbucketParticipant> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/approve`);\n }\n\n unapprovePullRequest(workspace: string, repo: string, id: number): Promise<void> {\n return this.request(\"DELETE\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/approve`);\n }\n\n requestChanges(workspace: string, repo: string, id: number): Promise<BitbucketParticipant> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/request-changes`);\n }\n\n mergePullRequest(\n workspace: string,\n repo: string,\n id: number,\n opts: { strategy?: BitbucketMergeStrategy; message?: string; closeSourceBranch?: boolean } = {},\n ): Promise<BitbucketPullRequest> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/merge`, {\n type: \"pullrequest_merge_parameters\",\n ...(opts.strategy ? { merge_strategy: opts.strategy } : {}),\n ...(opts.message ? { message: opts.message } : {}),\n ...(opts.closeSourceBranch !== undefined ? { close_source_branch: opts.closeSourceBranch } : {}),\n });\n }\n\n declinePullRequest(workspace: string, repo: string, id: number): Promise<BitbucketPullRequest> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/decline`);\n }\n\n addPullRequestComment(workspace: string, repo: string, id: number, markdown: string): Promise<{ id: number; links?: { html?: BitbucketLink } }> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/comments`, {\n content: { raw: markdown },\n });\n }\n\n listPullRequestComments(workspace: string, repo: string, id: number): Promise<{ id: number; content: { raw: string }; user?: BitbucketAccount; created_on?: string; inline?: { path: string; to?: number | null } | null }[]> {\n return this.paginate(`/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/comments?pagelen=100`, 500);\n }\n\n /** Unified diff of a PR. */\n getPullRequestDiff(workspace: string, repo: string, id: number): Promise<string> {\n return this.request(\"GET\", `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/diff`, undefined, {\n raw: true,\n });\n }\n\n listPullRequestStatuses(workspace: string, repo: string, id: number): Promise<BitbucketCommitStatus[]> {\n return this.paginate(`/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${id}/statuses?pagelen=100`, 200);\n }\n\n // ── Commit statuses ────────────────────────────────────────────────────\n\n listCommitStatuses(workspace: string, repo: string, sha: string): Promise<BitbucketCommitStatus[]> {\n return this.paginate(`/repositories/${enc(workspace)}/${enc(repo)}/commit/${enc(sha)}/statuses?pagelen=100`, 200);\n }\n\n /** Create or update (same `key`) a build status on a commit. */\n setCommitStatus(\n workspace: string,\n repo: string,\n sha: string,\n status: { key: string; state: BitbucketCommitStatusState; name?: string; url: string; description?: string },\n ): Promise<BitbucketCommitStatus> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(repo)}/commit/${enc(sha)}/statuses/build`, {\n key: status.key,\n state: status.state,\n url: status.url,\n ...(status.name ? { name: status.name } : {}),\n ...(status.description ? { description: status.description.slice(0, 255) } : {}),\n });\n }\n\n // ── Webhooks ───────────────────────────────────────────────────────────\n\n listWebhooks(workspace: string, repo: string): Promise<BitbucketWebhook[]> {\n return this.paginate(`/repositories/${enc(workspace)}/${enc(repo)}/hooks?pagelen=100`, 200);\n }\n\n createWebhook(\n workspace: string,\n repo: string,\n hook: { url: string; description: string; events: string[]; secret?: string },\n ): Promise<BitbucketWebhook> {\n return this.request(\"POST\", `/repositories/${enc(workspace)}/${enc(repo)}/hooks`, {\n url: hook.url,\n description: hook.description,\n active: true,\n events: hook.events,\n ...(hook.secret ? { secret: hook.secret } : {}),\n });\n }\n}\n","import { BitbucketClient, BITBUCKET_API_BASE_URL } from \"@tempo-modules/git-provider/bitbucket/api\";\n\n/**\n * The sticky PR comment on Bitbucket (TEM-2737). Bitbucket renders comment\n * markdown with HTML stripped, so this is a markdown-only body (no\n * `<details>`/`<img>`), and its marker is a markdown link-reference\n * \"comment\" that renders as nothing. The GitHub HTML-comment marker is also\n * recognized so a comment written by any version is found and updated.\n */\nexport const BITBUCKET_STICKY_MARKER = \"[//]: # (tempo-visual-review)\";\nconst GITHUB_STICKY_MARKER = \"<!-- tempo-visual-review -->\";\n\n/** A repository access token with pull-request write access, stored as a\n * secured repository variable — the step's OIDC token cannot write to\n * Bitbucket. Absent → the comment is skipped (the status still posts). */\nexport const BITBUCKET_COMMENT_TOKEN_ENV = \"TEMPO_VISUAL_REVIEW_BITBUCKET_TOKEN\";\n\ntype BitbucketReportStatus = {\n reportUrl?: string;\n trackedTotal?: number;\n counts?: Record<string, number | undefined>;\n gate?: {\n satisfied?: boolean;\n required?: number;\n approvalsNeeded?: number;\n rejected?: number;\n blockingErrors?: number;\n };\n topChanged?: Array<{\n name?: string;\n storyboardId: string;\n diffRatio?: number | null;\n verdict: string;\n error?: string;\n baselineHash?: string;\n candidateHash?: string;\n }>;\n blobUrlTemplate?: string;\n approximateBase?: boolean;\n freshEpoch?: boolean;\n};\n\n/** Markdown has no escape for `](` inside link text; keep titles inert. */\nfunction inline(text: string): string {\n return text.replace(/[\\[\\]`*_|<>]/g, \" \").trim();\n}\n\nexport function buildBitbucketCommentBody(status: BitbucketReportStatus): string {\n const counts = status.counts ?? {};\n const gate = status.gate;\n const gateLine = gate?.satisfied\n ? \"✅ **Check passing** — every visual change is approved.\"\n : `🔴 **Check failing** — ${gate?.approvalsNeeded ?? \"?\"} of ${gate?.required ?? \"?\"} storyboards need approval${gate?.blockingErrors ? `, ${gate.blockingErrors} render error(s)` : \"\"}${gate?.rejected ? `, ${gate.rejected} rejected` : \"\"}. Approving in the report updates the build status instantly — no pipeline re-run. A new push needs a fresh approval.`;\n const summary = `| tracked | changed | new | removed | render errors | unchanged |\n| --- | --- | --- | --- | --- | --- |\n| ${status.trackedTotal ?? 0} | ${counts.changed ?? 0} | ${counts.added ?? 0} | ${counts.removed ?? 0} | ${counts.errors ?? 0} | ${counts.unchanged ?? 0} |`;\n\n const boards = (status.topChanged ?? [])\n .slice(0, 6)\n .map((board) => {\n const title = inline(board.name ?? board.storyboardId);\n const meta =\n board.diffRatio !== undefined && board.diffRatio !== null\n ? ` · ${(board.diffRatio * 100).toFixed(2)}%`\n : \"\";\n if (board.verdict === \"render-error\") {\n return `**${title}** — render error${board.error ? `: ${inline(board.error.slice(0, 120))}` : \"\"}`;\n }\n const image = (hash: string | undefined, label: string) =>\n hash && status.blobUrlTemplate\n ? `![${label}](${status.blobUrlTemplate}${hash})`\n : `_${label}: none_`;\n return `**${title}** — ${board.verdict}${meta}\\n\\n${image(board.baselineHash, \"baseline\")} ${image(board.candidateHash, \"candidate\")}`;\n })\n .join(\"\\n\\n\");\n\n const notes: string[] = [];\n if (status.approximateBase) {\n notes.push(\n \"⚠ exact merge-base had no visual run — compared against the nearest captured ancestor.\",\n );\n }\n if (status.freshEpoch) {\n notes.push(\n \"ℹ fresh baseline epoch (capture environment changed) — everything reports as new.\",\n );\n }\n\n return `${BITBUCKET_STICKY_MARKER}\n## 👁 Visual review\n\n${gateLine}\n\n${summary}\n\n${notes.length > 0 ? `${notes.join(\"\\n\\n\")}\\n\\n` : \"\"}${boards}\n\n📷 **[Open the visual review report](${status.reportUrl})** — side-by-side, onion-skin and diff views; approve, reject, and comment there.`;\n}\n\nexport function buildBitbucketNoVisualChangeComment(): string {\n return `${BITBUCKET_STICKY_MARKER}\n## 👁 Visual review\n\n✅ **Not applicable — no storyboard changes expected.** Storyboard capture was skipped from the pull request's declaration.`;\n}\n\n/**\n * Create or update the one sticky comment on a Bitbucket PR, authenticated\n * with the secured repository access token. Returns false (and logs) when\n * no token is configured — the build status is the verdict; the comment is\n * a convenience.\n */\nexport async function upsertBitbucketStickyComment(options: {\n repoFullName: string;\n prNumber: number;\n body: string;\n env?: Record<string, string | undefined>;\n fetchImpl?: typeof fetch;\n log?: (line: string) => void;\n}): Promise<boolean> {\n const env = options.env ?? process.env;\n const log = options.log ?? ((line: string) => console.log(`[visual-review] ${line}`));\n const token = env[BITBUCKET_COMMENT_TOKEN_ENV];\n if (!token) {\n log(\n `${BITBUCKET_COMMENT_TOKEN_ENV} is not set; skipped the sticky PR comment (add a repository access token with pull-request write access as a secured repository variable to enable it)`,\n );\n return false;\n }\n const [workspace, repo] = options.repoFullName.split(\"/\");\n if (!workspace || !repo) throw new Error(`unexpected Bitbucket repository name ${options.repoFullName}`);\n const client = new BitbucketClient({\n accessToken: token,\n baseUrl: env.TEMPO_VISUAL_REVIEW_BITBUCKET_API_URL || BITBUCKET_API_BASE_URL,\n ...(options.fetchImpl ? { fetch: options.fetchImpl } : {}),\n });\n const comments = await client.listPullRequestComments(workspace, repo, options.prNumber);\n const existing = comments.find(\n (comment) =>\n typeof comment.content?.raw === \"string\" &&\n (comment.content.raw.includes(BITBUCKET_STICKY_MARKER) ||\n comment.content.raw.includes(GITHUB_STICKY_MARKER)),\n );\n const enc = encodeURIComponent;\n if (existing) {\n await client.request(\n \"PUT\",\n `/repositories/${enc(workspace)}/${enc(repo)}/pullrequests/${options.prNumber}/comments/${existing.id}`,\n { content: { raw: options.body } },\n );\n } else {\n await client.addPullRequestComment(workspace, repo, options.prNumber, options.body);\n }\n return true;\n}\n"],"mappings":";;;AAYO,IAAM,yBAAyB;AAY/B,IAAM,oBAAN,cAAgC,MAAM;AAAA,EAM3C,YAAY,MAMT;AACD,UAAM,KAAK,OAAO;AAClB,SA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