agentleFS
VercelKnown publishervercel/chat/packages/adapter-gitlab/AGENTS.md

chat / adapter-gitlab

AGENTS.md2.4k starsChanged 20 days agoMITView on GitHub

Guidance for coding agents working inside the GitLab adapter package. The top-level repository AGENTS.md covers monorepo-wide build, lint, and release rules. Read it first. @chat-adapter/gitlab connects a Chat SDK bot to merge request and issue comments on GitLab.com, GitLab Self-Managed, and GitLab Dedicated: - Webhook endpoint at /api/webhooks/gitlab for Note Hook (comments) and Emoji Hook (reactions) events. - Webhook verification with a signing token (Standard Webhooks webhook-signature, GitLab 19.0+), a secret token (X-Gitlab-Token), or a custom webhookVerifier. - REST API…

We split this AGENTS.md into the rules it gives an agent

1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈1

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 0

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Never log the access token or webhook tokens.

    line 128

≈ “Common” is an estimate: at least 1 in 5 of the 36,368 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

AGENTS.md — @chat-adapter/gitlab

Guidance for coding agents working inside the GitLab adapter package. The top-level repository AGENTS.md covers monorepo-wide build, lint, and release rules. Read it first.

Overview

@chat-adapter/gitlab connects a Chat SDK bot to merge request and issue comments on GitLab.com, GitLab Self-Managed, and GitLab Dedicated:

  • Webhook endpoint at /api/webhooks/gitlab for Note Hook (comments) and Emoji Hook (reactions) events.
  • Webhook verification with a signing token (Standard Webhooks webhook-signature, GitLab 19.0+), a secret token (X-Gitlab-Token), or a custom webhookVerifier.
  • REST API v4 over fetch with one access token (GITLAB_TOKEN). There is no SDK dependency.
  • Bot identity (userName, botUserId) detected from GET /user during initialize() unless configured. ensureBotIdentity() retries the lookup when a comment arrives and the ID is still unknown (at most every 30 seconds). isSelf() compares user IDs, falling back to a configured username. With neither known, comments are dropped with a warning so the bot can't reply to itself.

Directory layout

packages/adapter-gitlab/
├── src/
│   ├── index.ts             # GitLabAdapter + createGitLabAdapter
│   ├── index.test.ts
│   ├── cards.ts             # Card → GLFM markdown
│   ├── cards.test.ts
│   ├── markdown.ts          # GitLabFormatConverter (mdast ↔ GLFM)
│   ├── markdown.test.ts
│   ├── subclass.test-d.ts
│   └── types.ts             # config, thread ID, REST and webhook types
├── package.json
├── tsconfig.json
├── tsup.config.ts
├── vitest.config.ts
└── README.md

Build, test, typecheck

pnpm --filter @chat-adapter/gitlab build
pnpm --filter @chat-adapter/gitlab test
pnpm --filter @chat-adapter/gitlab typecheck

Thread ID format

gitlab:{projectId}:mr:{iid}
gitlab:{projectId}:issue:{iid}
gitlab:{projectId}:{mr|issue}:{iid}:{discussionId}
  • projectId is the numeric project ID, which survives project renames and transfers. Never encode the project path: it contains /.
  • Note Hook and Emoji Hook payloads carry each note's discussion_id, including top-level (type: null) comments, so every webhook note maps to its discussion thread and postMessage replies inside that discussion. Replying to a top-level comment turns it into a thread in GitLab's UI.
  • Webhooks never produce the merge request or issue thread (gitlab:{projectId}:{mr|issue}:{iid}). listThreads returns it, posting to it creates a new top-level comment, and fetchMessages on it returns every comment except system and internal notes, paged by x-next-page.
  • encodeThreadId / decodeThreadId are the only sanctioned constructors.
  • The channel ID is gitlab:{projectId}.

Webhook handling

  • Notes with an action other than create (edits) are ignored, as are system notes and commit or snippet comments.
  • Internal notes, Confidential Note Hook events, and event_type: "confidential_note" are ignored on purpose. Replying would post their content into a public comment. For the same reason, fetchMessages drops internal notes and fetchMessage returns null for one: the bot's token can read them, but a reply built from history is public.
  • isMention is set by the adapter: @userName counts only outside inline code, code blocks, and block quotes.
  • metadata.edited is always false. GitLab bumps updated_at on resolve and thread conversion, and the API has no last-edited field.
  • The signing token is the whsec_ value, with the prefix optional (32 bytes: 43 base64 characters plus =). Malformed tokens throw at construction.
  • Webhook notes are normalized into the REST GitLabNote shape (object_attributes.note becomes body, the top-level user becomes author) so parsing has one code path.
  • Older payloads use YYYY-MM-DD HH:MM:SS UTC timestamps; parseGitLabDate handles both formats.

REST API notes

  • Edits and deletes use the notes API (/notes/:note_id) for every note, including discussion notes.
  • Emoji reactions use /notes/:note_id/award_emoji. GITLAB_EMOJI_NAMES holds the normalized emoji whose Slack-style shortcode isn't GitLab's canonical award name; everything else uses the shortcode. Incoming award names are reverse-mapped through the same table.
  • List endpoints paginate with x-next-page; requestAll follows it up to MAX_PAGES. listThreads and merge request or issue fetchMessages return the header as nextCursor instead, with per_page capped at 100.
  • The listThreads root message is the merge request description (or title), not a note. Its ID is mr-{iid}. notePath rejects non-numeric IDs with ValidationError, and fetchMessage returns null for them.
  • Errors map to @chat-adapter/shared errors: 400 and 422 ValidationError with GitLab's reason, 401 AuthenticationError, 403 PermissionError, 404 ResourceNotFoundError, 429 AdapterRateLimitError, anything else NetworkError.
  • Streaming is buffered and posted once: GitLab rejects empty note bodies, so the default post-then-edit fallback can't post a placeholder. An empty stream throws ValidationError.
  • Strings, { raw }, { markdown }, and streamed text are posted as written apart from emoji placeholders, so GitLab references (~label, !12, #12) render. AST input is serialized with remark.

Coding conventions

  • Named exports only. Webhook and REST types live in types.ts.
  • Top-level regex literals.
  • Never log the access token or webhook tokens.

Releases

Behavioral changes need a changeset (pnpm changeset, choose @chat-adapter/gitlab, plus chat if a public type changed).

Where to look next

Download now (ZIP)

Trending

Less talk lately.thin dataabout the whole repository

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 1 mentionMar 2026: 4 mentionsApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 1 mentionJul 2026: 0 mentionsAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 1 mentionNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the vercel/chat repository that our weekly crawl found: only 9 in all, so this is a hint, not a trend. There is no adoption data for this file yet.

Who's talking about vercel/chat

The biggest 5 of 9 mentions linking to the repository that our crawl found. Each line is their own headline.

See all 9

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.