feat(gitlab): add repository, code-review, and CI job tools + validation fixes#5205
Conversation
…ion fixes Expand the GitLab integration with 12 new tools (all host-aware via getGitLabApiBase, wired through types/index/registry/block): - Repository: list_repository_tree, get_file, create_file, update_file, create_branch, list_branches, list_commits - Code review: get_merge_request_changes, approve_merge_request - CI jobs: list_pipeline_jobs, get_job_log, play_job Validation fixes from /validate-integration: - Correct the block inputs key (credential -> accessToken) so it matches the subBlock id and the params the block reads - Trim projectId before encoding in all tool request URLs (input hygiene) /validate-connector and /validate-trigger passed clean against the GitLab REST API v4 docs — no changes required.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PR SummaryMedium Risk Overview Repository & CI: New actions cover browsing the tree, reading/creating/updating files, listing commits and branches, creating branches, listing pipeline jobs, fetching job traces, and playing manual jobs. Code review: Fixes & docs: The GitLab block now exposes Reviewed by Cursor Bugbot for commit 1e23b62. Configure here. |
|
@greptile |
|
@cursor review |
Greptile SummaryThis PR expands the GitLab integration with 12 new tools (repository tree, file CRUD, list branches/commits, MR diffs/approval, and CI job management), registers them in the block and global registry, and fixes the existing
Confidence Score: 5/5Safe to merge — all 12 new tools follow established patterns, no existing tool behavior changed beyond the whitespace trim, and the credential key fix is correct. All new tools are self-contained additions wired end-to-end with correct endpoints, method/body/header shapes, and type coverage. The only gaps are optional params (lastCommitId in update_file, date/author filters in list_commits) that the block config case omits — the tools themselves work correctly when called directly. apps/sim/blocks/blocks/gitlab.ts — the config.tool cases for gitlab_update_file and gitlab_list_commits silently drop some optional tool params that may be useful in certain workflows. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
Block["GitLab Block\n(gitlab.ts)"] -->|config.tool| Dispatcher["Operation Dispatcher\n(switch/case)"]
Dispatcher --> RepoOps["Repository Ops"]
Dispatcher --> MROps["Merge Request Ops"]
Dispatcher --> CIOps["CI / Job Ops"]
RepoOps --> T1["list_repository_tree"]
RepoOps --> T2["get_file"]
RepoOps --> T3["create_file"]
RepoOps --> T4["update_file"]
RepoOps --> T5["list_branches"]
RepoOps --> T6["create_branch"]
RepoOps --> T7["list_commits"]
MROps --> T8["get_merge_request_changes\n(/diffs endpoint)"]
MROps --> T9["approve_merge_request"]
CIOps --> T10["list_pipeline_jobs"]
CIOps --> T11["get_job_log"]
CIOps --> T12["play_job"]
T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9 & T10 & T11 & T12 --> Base["getGitLabApiBase(host)\n→ gitlab.com or self-managed"]
Base --> API["GitLab REST API v4"]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
Block["GitLab Block\n(gitlab.ts)"] -->|config.tool| Dispatcher["Operation Dispatcher\n(switch/case)"]
Dispatcher --> RepoOps["Repository Ops"]
Dispatcher --> MROps["Merge Request Ops"]
Dispatcher --> CIOps["CI / Job Ops"]
RepoOps --> T1["list_repository_tree"]
RepoOps --> T2["get_file"]
RepoOps --> T3["create_file"]
RepoOps --> T4["update_file"]
RepoOps --> T5["list_branches"]
RepoOps --> T6["create_branch"]
RepoOps --> T7["list_commits"]
MROps --> T8["get_merge_request_changes\n(/diffs endpoint)"]
MROps --> T9["approve_merge_request"]
CIOps --> T10["list_pipeline_jobs"]
CIOps --> T11["get_job_log"]
CIOps --> T12["play_job"]
T1 & T2 & T3 & T4 & T5 & T6 & T7 & T8 & T9 & T10 & T11 & T12 --> Base["getGitLabApiBase(host)\n→ gitlab.com or self-managed"]
Base --> API["GitLab REST API v4"]
Reviews (3): Last reviewed commit: "fix(gitlab): address review feedback + r..." | Re-trigger Greptile |
Greptile SummaryThis PR extends the GitLab integration with 12 new tools covering repository file operations (list tree, get/create/update file, list commits), branch management (list/create branches), code review (get MR diffs, approve MR), and CI jobs (list pipeline jobs, get job log, play job). It also fixes a long-standing bug where the block's credential input was keyed as
Confidence Score: 4/5The PR is safe to merge; the new tools are well-structured and the credential key fix unblocks the entire existing GitLab surface. All 12 new tools follow existing patterns, are wired end-to-end, and have correct request/response shapes. The only gap is that the list_repository_tree block case doesn't expose or forward the ref param, locking users of that operation to the default branch when going through the block UI. apps/sim/blocks/blocks/gitlab.ts — the list_repository_tree tool case and the block's ref input condition both need a small addition to support non-default branches. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[GitLab Block UI] -->|operation selected| B{Operation Router\nconfig.tool}
B -->|gitlab_list_repository_tree| C[list_repository_tree.ts\nGET /repository/tree]
B -->|gitlab_get_file| D[get_file.ts\nGET /repository/files/:path\nBase64 decode]
B -->|gitlab_create_file| E[create_file.ts\nPOST /repository/files/:path]
B -->|gitlab_update_file| F[update_file.ts\nPUT /repository/files/:path]
B -->|gitlab_list_branches| G[list_branches.ts\nGET /repository/branches]
B -->|gitlab_create_branch| H[create_branch.ts\nPOST /repository/branches]
B -->|gitlab_list_commits| I[list_commits.ts\nGET /repository/commits]
B -->|gitlab_get_merge_request_changes| J[get_merge_request_changes.ts\nGET /merge_requests/:iid/changes]
B -->|gitlab_approve_merge_request| K[approve_merge_request.ts\nPOST /merge_requests/:iid/approve]
B -->|gitlab_list_pipeline_jobs| L[list_pipeline_jobs.ts\nGET /pipelines/:id/jobs]
B -->|gitlab_get_job_log| M[get_job_log.ts\nGET /jobs/:id/trace]
B -->|gitlab_play_job| N[play_job.ts\nPOST /jobs/:id/play]
C & D & E & F & G & H & I & J & K & L & M & N -->|PRIVATE-TOKEN header| O[(GitLab API v4\nhttps://gitlab.com or self-hosted)]
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
A[GitLab Block UI] -->|operation selected| B{Operation Router\nconfig.tool}
B -->|gitlab_list_repository_tree| C[list_repository_tree.ts\nGET /repository/tree]
B -->|gitlab_get_file| D[get_file.ts\nGET /repository/files/:path\nBase64 decode]
B -->|gitlab_create_file| E[create_file.ts\nPOST /repository/files/:path]
B -->|gitlab_update_file| F[update_file.ts\nPUT /repository/files/:path]
B -->|gitlab_list_branches| G[list_branches.ts\nGET /repository/branches]
B -->|gitlab_create_branch| H[create_branch.ts\nPOST /repository/branches]
B -->|gitlab_list_commits| I[list_commits.ts\nGET /repository/commits]
B -->|gitlab_get_merge_request_changes| J[get_merge_request_changes.ts\nGET /merge_requests/:iid/changes]
B -->|gitlab_approve_merge_request| K[approve_merge_request.ts\nPOST /merge_requests/:iid/approve]
B -->|gitlab_list_pipeline_jobs| L[list_pipeline_jobs.ts\nGET /pipelines/:id/jobs]
B -->|gitlab_get_job_log| M[get_job_log.ts\nGET /jobs/:id/trace]
B -->|gitlab_play_job| N[play_job.ts\nPOST /jobs/:id/play]
C & D & E & F & G & H & I & J & K & L & M & N -->|PRIVATE-TOKEN header| O[(GitLab API v4\nhttps://gitlab.com or self-hosted)]
|
- get_merge_request_changes: use the /diffs endpoint (/changes was removed in GitLab 18.0); return the diff array + count (drops the MR envelope that /diffs no longer provides), fetch max page size in a single call - create_file/update_file: send explicit `encoding: 'text'` for clarity - Remove `// =====` separator comments from types.ts (repo convention) - Regenerate GitLab integration docs + catalog for the 12 new tools
|
Addressed all review feedback in
Also removed |
|
@greptile |
|
@cursor review |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 1e23b62. Configure here.
Summary
getGitLabApiBase) and wired end-to-end (types → index → registry → block):inputs.credential→inputs.accessToken(matched the subBlock id and the params the block reads).trim()onprojectIdbefore URL-encoding in all existing tool request URLs (input hygiene)Backwards compatibility
String(projectId)→String(projectId).trim()(18 files;list_projectsuntouched). No-op when there's no surrounding whitespace; only prevents accidental-whitespace 404s. No endpoint/method/param/response/output of any existing tool changed.types.tsremoved only 4 dead, unused branch type stubs (repurposed for the new tools);registry.tsis a re-sort + additions (no existing entry dropped); block changes are additive plus the one input-key fix.Type of Change
Testing
check:api-validationall pass,tools/gitlab/utils.test.ts7/7Checklist