superagent-skill 0.4.2 → 0.5.0

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.
package/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # superagent
2
2
 
3
- An agent that turns requests from GitHub, Feishu, and Twitter/X into tickets, and runs each ticket on the coding agent you choose.
3
+ An agent that turns requests from GitHub, GitLab, Feishu, and Twitter/X into tickets, and runs each ticket on the coding agent you choose.
4
4
 
5
5
  - **No web panel.** State is JSON files under `stateDir`, so `ls` and `cat` answer what a dashboard would.
6
6
  - **No vendor lock-in.** The executor is a configuration value: `claude`, `codex` or `opencode`, behind one interface.
@@ -29,8 +29,9 @@ superagent status
29
29
  `superagent setup` asks the CLIs that already know the answers, so no id is copied from a web page:
30
30
 
31
31
  ```sh
32
- superagent setup . # both Sources, from the CLIs in settings.yaml
32
+ superagent setup . # the forge in settings.yaml and Feishu, from the CLIs
33
33
  superagent setup . github # only the GitHub section
34
+ superagent setup . gitlab # only the GitLab section
34
35
  superagent setup . feishu --chat Team # the chat by name instead of id
35
36
  superagent setup . --allow alice,bob # who may ask; a Feishu user name becomes an open id
36
37
  ```
@@ -93,6 +94,31 @@ Arbitrary polling is not yet wired, so a person runs `poll` under cron or a syst
93
94
  */1 * * * * cd /path/to/install && superagent poll . --once >> state/poll.log 2>&1
94
95
  ```
95
96
 
97
+ ## GitLab, including a self-managed instance
98
+
99
+ A GitLab installation reads the agent account's pending *to-do items* — a mention, a direct address, an assignment or a
100
+ review request — and, when review is on, the project's open merge requests. The report goes back as a note on the issue
101
+ or merge request, and a review can squash-merge the merge request once verification and the review both pass.
102
+
103
+ ```yaml
104
+ gitlab:
105
+ host: gitlab.example.com # gitlab.com by default; a port is allowed for a self-managed instance
106
+ project: group/sub/project # the project path, subgroups included
107
+ cli: glab-agent # the CLI that acts as the agent's account; `glab auth login --hostname <host>`
108
+ pollSeconds: 60
109
+ allowed: [alice, bob] # GitLab usernames that may ask for work
110
+ mrReview:
111
+ enabled: true
112
+ pollOpenMrs: true
113
+ verifyCommands: ["npm test"]
114
+ autoMerge: true
115
+ squash: true # GitLab applies its project setting when false
116
+ ```
117
+
118
+ One installation serves one forge: `github.enabled` and `gitlab.enabled` cannot both be true, because the worker's git
119
+ credentials and CLI shim bind to one account. A merge request triggers the same review prompt as a pull request, with
120
+ GitLab's words and its `refs/merge-requests/<iid>/head` checkout.
121
+
96
122
  ## Compare with dsh-superagent
97
123
 
98
124
  [`docs/dsh-superagent-comparison.md`](docs/dsh-superagent-comparison.md)([中文版](docs/dsh-superagent-comparison.zh.md))
@@ -107,9 +133,10 @@ for how superagent incorporates the five core primitives from Anthropic's [*"Bui
107
133
  ## Status
108
134
 
109
135
  Done and tested: the domain, file-backed state, the settings file, three agent runners (verified against the real CLIs),
110
- the GitHub notification poller, the Feishu Source, worktree creation per ticket, the round loop, and delivery of the
111
- agent's report back to the conversation. The Feishu path is proven with a stand-in `lark-cli` and once end to end
112
- against a real Feishu bot.
136
+ the GitHub notification poller, the GitLab Source (to-dos, merge request review and merge), the Feishu Source, worktree
137
+ creation per ticket, the round loop, and delivery of the agent's report back to the conversation. The Feishu path is
138
+ proven with a stand-in `lark-cli` and once end to end against a real Feishu bot; the GitLab path is proven with a
139
+ stand-in `glab` and against the API's documented shapes, not yet against a live GitLab account.
113
140
 
114
141
  ## Install once
115
142
 
@@ -129,8 +156,8 @@ ln -sf "$PWD/bin/superagent.js" ~/.local/bin/superagent # a directory on PATH
129
156
  Start the loop from that directory: `superagent poll` keeps running, and `superagent poll --once` runs one round, which
130
157
  is what a cron entry calls each minute.
131
158
 
132
- `checkout` names the repository the tickets change, and `executor.agent` names the coding agent. Both `github` and
133
- `feishu` are optional, but at least one must be on.
159
+ `checkout` names the repository the tickets change, and `executor.agent` names the coding agent. The Sources are
160
+ optional, but at least one must be on; `github` and `gitlab` cannot both be, because one installation serves one forge.
134
161
 
135
162
  ## Tests
136
163
 
package/SKILL.md CHANGED
@@ -1,11 +1,11 @@
1
1
  ---
2
2
  name: superagent
3
- description: Run an agent that turns requests from GitHub issues, Feishu chats, or Twitter/X mentions into tickets and executes each ticket on a configurable coding agent (Claude Code, Codex, opencode). Use when the user wants an agent to watch a repository, a chat, or Twitter keywords, act on @ mentions, and record its work as plain files instead of a dashboard; when they ask what superagent has done, which tickets are open, or to change which coding agent runs tickets.
3
+ description: Run an agent that turns requests from GitHub issues, GitLab to-dos and merge requests, Feishu chats, or Twitter/X mentions into tickets and executes each ticket on a configurable coding agent (Claude Code, Codex, opencode). Use when the user wants an agent to watch a repository, a project, a chat, or Twitter keywords, act on @ mentions, and record its work as plain files instead of a dashboard; when they ask what superagent has done, which tickets are open, or to change which coding agent runs tickets.
4
4
  ---
5
5
 
6
6
  # Superagent
7
7
 
8
- Superagent listens to GitHub and Feishu. A request that names the agent becomes a **ticket**. Each ticket runs on a
8
+ Superagent listens to GitHub, GitLab and Feishu. A request that names the agent becomes a **ticket**. Each ticket runs on a
9
9
  coding agent you choose, in its own worktree, and records itself as files on disk. When the agent reports it is done,
10
10
  the summary goes back as a reply in the conversation that asked.
11
11
 
@@ -71,6 +71,11 @@ github:
71
71
  repository: owner/name
72
72
  cli: gh-agent # the CLI that acts as the agent's account
73
73
  allowed: [alice] # GitHub logins
74
+ gitlab:
75
+ host: gitlab.com # or a self-managed host, optionally with a port
76
+ project: group/project
77
+ cli: glab-agent # the CLI that acts as the agent's account on that host
78
+ allowed: [alice] # GitLab usernames
74
79
  feishu:
75
80
  cli: lark-bot # the CLI that acts as the bot
76
81
  chats: [{ chatId: oc_..., name: Team }]
@@ -83,6 +88,9 @@ twitter:
83
88
  allowed: [] # empty accepts any user matching query
84
89
  ```
85
90
 
91
+ One installation serves one forge: turn off either `github.enabled` or `gitlab.enabled`. The worker's git credentials and
92
+ CLI shims bind to one account, so a second forge would share them.
93
+
86
94
  The agent acts only as the accounts those CLIs are signed in to. Never point `cli` at a personal login: everything the
87
95
  agent writes would appear under that person's name.
88
96
 
@@ -157,12 +165,12 @@ In autonomous runs (unaddressed messages, timers, watchers), tools are automatic
157
165
  | Command | Does |
158
166
  | --- | --- |
159
167
  | `superagent init [dir]` | create `settings.yaml` and the state directory; a second run keeps both |
160
- | `superagent setup [dir] [github\|feishu] [--allow a,b] [--chat id\|name]` | fill the GitHub and Feishu sections from the configured CLIs; a CLI that cannot answer changes nothing and exits 1 |
168
+ | `superagent setup [dir] [github\|gitlab\|feishu] [--allow a,b] [--chat id\|name]` | fill the Source sections from the configured CLIs; a CLI that cannot answer changes nothing and exits 1 |
161
169
  | `superagent status [dir]` | print open and ended tickets, and the recent judgements of unaddressed messages, as Markdown |
162
- | `superagent doctor [dir]` | show installed agents and the selected one |
170
+ | `superagent doctor [dir]` | show installed agents, the selected one, and the Source project |
163
171
  | `superagent agents` | list the agent names a configuration may use |
164
172
  | `superagent run [dir] -p <text>` | run one prompt on the configured agent and print its report |
165
- | `superagent poll [dir] [--once]` | read GitHub notifications, accept mentions as tickets, and run them |
173
+ | `superagent poll [dir] [--once]` | read the Source's to-dos or notifications, accept them as tickets, and run them |
166
174
 
167
175
  The first argument is the installation directory and defaults to the current directory.
168
176
 
@@ -176,6 +184,8 @@ The first argument is the installation directory and defaults to the current dir
176
184
  | `Selected: **x** — not installed` | Install that CLI or choose another `executor.agent`. |
177
185
  | A ticket ends with a failed report | Read `state/tickets/<id>/log.md`; the agent's last message is at the end. |
178
186
  | Nothing happens after a mention | Check the author is on the allow list and `enabled` is true for that Source. |
187
+ | `glab ... 404` or a project not found | `gitlab.project` is the path, not the numeric id; `host` must name the instance `glab` is signed in to. |
188
+ | `one installation serves one forge` | Set `github.enabled` or `gitlab.enabled` to false; the worker's credentials bind to one account. |
179
189
 
180
190
  ## Going further
181
191
 
package/lib/cli.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { C as reasonText, D as key, L as runningAssignment, N as latestReport, a as readSettings, b as directionAllowed, c as AGENT_NAMES, g as readState, h as FileRepositories, l as installed, m as runProcess, o as stringifyYaml, p as reportInstructions, r as defaultSettings, s as writeSettings, t as SETTINGS_FILE, u as runnerFor, v as RuleAssessmentSchema, x as Engine, z as threadKey } from "./settings-Dud0f9wo.mjs";
1
+ import { C as reasonText, D as key, L as runningAssignment, N as latestReport, a as readSettings, b as directionAllowed, c as AGENT_NAMES, g as readState, h as FileRepositories, l as installed, m as runProcess, o as stringifyYaml, p as reportInstructions, r as defaultSettings, s as writeSettings, t as SETTINGS_FILE, u as runnerFor, v as RuleAssessmentSchema, x as Engine, z as threadKey } from "./settings-BwRUbWkx.mjs";
2
2
  import { createHash } from "node:crypto";
3
3
  import { z } from "zod";
4
4
  import { access, appendFile, lstat, mkdir, readFile, readdir, rename, rm, stat, unlink, writeFile } from "node:fs/promises";
@@ -20,6 +20,7 @@ const MARKER = "# Written by superagent on every start; edits are lost.";
20
20
  /** Commands the shims provide, which a blocked list must never shadow. */
21
21
  const WORKER_COMMANDS = [
22
22
  "gh",
23
+ "glab",
23
24
  "git",
24
25
  "lark-cli"
25
26
  ];
@@ -71,9 +72,10 @@ async function writeEnvironment(accounts, blockedCommands) {
71
72
  ].join("\n");
72
73
  const run = (program) => `${withoutShims}\nexec ${shellQuote(program)} "$@"`;
73
74
  const fail = (message) => `echo ${shellQuote(message)} >&2\nexit 1`;
74
- await shim("gh", run(accounts.githubCli));
75
+ await shim("gh", accounts.githubCli ? run(accounts.githubCli) : fail("gh is unavailable: this installation has no GitHub Source."));
76
+ await shim("glab", accounts.gitlabCli ? run(accounts.gitlabCli) : fail("glab is unavailable: this installation has no GitLab Source."));
75
77
  await shim("lark-cli", accounts.feishuCli ? run(accounts.feishuCli) : fail("lark-cli is unavailable: this installation has no Feishu bot."));
76
- for (const name of new Set(blockedCommands.filter((name) => !WORKER_COMMANDS.includes(name)))) await shim(name, fail(`${name} is blocked in this installation; use gh, which acts as ${accounts.agentLogin}.`));
78
+ for (const name of new Set(blockedCommands.filter((name) => !WORKER_COMMANDS.includes(name)))) await shim(name, fail(`${name} is blocked in this installation${accounts.agentLogin ? `; work as ${accounts.agentLogin}` : ""}.`));
77
79
  for (const name of before) if (!kept.has(name)) await unlink(join(dir, name));
78
80
  await own(workerGitConfig(accounts.stateDir), [
79
81
  MARKER,
@@ -81,11 +83,20 @@ async function writeEnvironment(accounts, blockedCommands) {
81
83
  " useConfigOnly = true",
82
84
  "[credential]",
83
85
  " helper =",
84
- "[credential \"https://github.com\"]",
85
- `\thelper = ${gitQuote(credentialHelper(accounts.githubCli))}`,
86
- "[url \"https://github.com/\"]",
87
- " insteadOf = git@github.com:",
88
- " insteadOf = ssh://git@github.com:",
86
+ ...accounts.gitlabCli && accounts.gitlabHost ? [
87
+ `[credential "https://${accounts.gitlabHost}"]`,
88
+ `\thelper = ${gitQuote(credentialHelper(accounts.gitlabCli))}`,
89
+ `[url "https://${accounts.gitlabHost}/"]`,
90
+ `\tinsteadOf = git@${accounts.gitlabHost}:`,
91
+ `\tinsteadOf = ssh://git@${accounts.gitlabHost}:`
92
+ ] : [],
93
+ ...accounts.githubCli ? [
94
+ "[credential \"https://github.com\"]",
95
+ `\thelper = ${gitQuote(credentialHelper(accounts.githubCli))}`,
96
+ "[url \"https://github.com/\"]",
97
+ " insteadOf = git@github.com:",
98
+ " insteadOf = ssh://git@github.com:"
99
+ ] : [],
89
100
  "[filter \"lfs\"]",
90
101
  " clean = git-lfs clean -- %f",
91
102
  " smudge = git-lfs smudge -- %f",
@@ -169,18 +180,31 @@ const STANDING_DIR = join(dirname(fileURLToPath(import.meta.url)), "..", "prompt
169
180
  async function standingRules() {
170
181
  return Promise.all(STANDING_FILES.map(async (name) => (await readFile(join(STANDING_DIR, name), "utf8")).trim()));
171
182
  }
172
- /** Composes the prompt for reviewing and verifying a pull request. */
183
+ /** The forge's own words, so a GitLab ticket is not told to open a pull request. */
184
+ const forgeWords = (source) => source === "gitlab" ? {
185
+ name: "GitLab",
186
+ request: "merge request",
187
+ Request: "Merge Request",
188
+ short: "MR"
189
+ } : {
190
+ name: "GitHub",
191
+ request: "pull request",
192
+ Request: "Pull Request",
193
+ short: "PR"
194
+ };
195
+ /** Composes the prompt for reviewing and verifying a pull request or a merge request. */
173
196
  function composePrReviewPrompt(input) {
174
197
  const { ticket, trigger, repository, agentLogin, instructions, standing = [], notes = [], prNumber, prVerification, autoMergeAllowed } = input;
175
- const asked = trigger ? `Pull Request #${prNumber} details:\n\n${quote(trigger.text)}` : `Pull Request #${prNumber} review:\n\n${quote(ticket.title)}`;
198
+ const words = forgeWords(input.source);
199
+ const asked = trigger ? `${words.Request} #${prNumber} details:\n\n${quote(trigger.text)}` : `${words.Request} #${prNumber} review:\n\n${quote(ticket.title)}`;
176
200
  return [
177
- `# Ticket ${ticket.id} — Pull Request #${prNumber} Review & Verification`,
201
+ `# Ticket ${ticket.id} — ${words.Request} #${prNumber} Review & Verification`,
178
202
  "",
179
- `You are reviewing Pull Request #${prNumber} on repository \`${repository}\`.`,
180
- `The PR's code has been checked out directly into this working directory.`,
181
- `Your GitHub account is \`${agentLogin}\`.`,
203
+ `You are reviewing ${words.Request} #${prNumber} on repository \`${repository}\`.`,
204
+ `The ${words.short}'s code has been checked out directly into this working directory.`,
205
+ `Your ${words.name} account is \`${agentLogin}\`.`,
182
206
  "",
183
- "## The Pull Request",
207
+ `## The ${words.Request}`,
184
208
  "",
185
209
  asked,
186
210
  ...notes.filter(Boolean).flatMap((note) => [
@@ -197,12 +221,12 @@ function composePrReviewPrompt(input) {
197
221
  "## Review Instructions & Standards",
198
222
  "",
199
223
  "- **Inspect Every Line**: Scrutinize the git diff and logic changes. Do not blindly trust community submissions.",
200
- "- **Zero Tolerance for AI Slop**: Many PRs are generated hastily by coding agents without testing. Ensure logic is sound, error handling is thorough, and no regressions are introduced.",
201
- ...prVerification && !prVerification.passed ? ["- ⚠️ **CRITICAL: Local automated verification has FAILED.** You MUST NOT approve or merge this PR. Clearly point out the failure logs and what the author needs to fix."] : [],
224
+ "- **Zero Tolerance for AI Slop**: Many requests are generated hastily by coding agents without testing. Ensure logic is sound, error handling is thorough, and no regressions are introduced.",
225
+ ...prVerification && !prVerification.passed ? [`- ⚠️ **CRITICAL: Local automated verification has FAILED.** You MUST NOT approve or merge this ${words.request}. Clearly point out the failure logs and what the author needs to fix.`] : [],
202
226
  "- **Decision Standards**:",
203
227
  autoMergeAllowed && (!prVerification || prVerification.passed) ? " - Conclude your report with `DECISION: MERGE` ONLY if all automated checks passed AND your line-by-line review confirms the code is robust and bug-free." : " - Conclude your report with `DECISION: APPROVE` if all tests passed and the code is clean (human maintainer will merge).",
204
228
  " - Conclude your report with `DECISION: REQUEST_CHANGES` if tests failed, or if you found bugs, flaws, or missing tests.",
205
- " - Conclude your report with `DECISION: CLOSE` if the PR is spam, malicious, completely misguided, or unfixable.",
229
+ ` - Conclude your report with \`DECISION: CLOSE\` if the ${words.request} is spam, malicious, completely misguided, or unfixable.`,
206
230
  "",
207
231
  ...standing.filter(Boolean).flatMap((rule) => ["", rule]),
208
232
  ...instructions.trim() ? [
@@ -218,11 +242,12 @@ function composePrReviewPrompt(input) {
218
242
  function composePrompt(input) {
219
243
  if (input.isPrReview && input.prNumber) return composePrReviewPrompt(input);
220
244
  const { ticket, trigger, repository, agentLogin, branchPrefix, instructions, source = "github", branch, standing = [], notes = [] } = input;
245
+ const words = forgeWords(source);
221
246
  const asked = trigger ? `A person wrote this in ${trigger.url ?? trigger.channel?.thread ?? "the source conversation"}:\n\n${quote(trigger.text)}` : `The ticket has no source message; work on the title alone:\n\n${quote(ticket.title)}`;
222
247
  return [
223
248
  `# Ticket ${ticket.id}`,
224
249
  "",
225
- ...source === "feishu" ? [`You work on the repository \`${repository}\`. The request came from a chat, which has no branch of its own, so open your`, "pull request from a new branch and say in your report where the person can find it."] : [`You work on the repository \`${repository}\`. Your GitHub account is \`${agentLogin}\`; every GitHub action you take is`, "visible to the team under that name."],
250
+ ...source === "feishu" ? [`You work on the repository \`${repository}\`. The request came from a chat, which has no branch of its own, so open your`, `${words.request} from a new branch and say in your report where the person can find it.`] : [`You work on the repository \`${repository}\`. Your ${words.name} account is \`${agentLogin}\`; every ${words.name} action you take is`, "visible to the team under that name."],
226
251
  "",
227
252
  "## The request",
228
253
  "",
@@ -237,9 +262,9 @@ function composePrompt(input) {
237
262
  "## How to work",
238
263
  "",
239
264
  `- Work only in this directory. It is a worktree of the repository on a new branch.`,
240
- branch ? `- Commit on the branch \`${branch}\`, which this directory is already on, and open a pull request from it when done.` : `- Put your branch under \`${branchPrefix}\` followed by a short name, and open a pull request from it when done.`,
265
+ branch ? `- Commit on the branch \`${branch}\`, which this directory is already on, and open a ${words.request} from it when done.` : `- Put your branch under \`${branchPrefix}\` followed by a short name, and open a ${words.request} from it when done.`,
241
266
  "- Run the tests the repository has. Do not claim a check passed unless you ran it.",
242
- "- Do not merge the pull request. A person merges it.",
267
+ `- Do not merge the ${words.request}. A person merges it.`,
243
268
  "- If the request needs a decision you cannot make, stop and ask one concrete question.",
244
269
  ...input.readOnly ? ["- Autonomous run mode: you may inspect, search, and run tests, but do NOT push commits or make permanent mutations.", "- If code changes or human decisions are required, report state as \"blocked\" and provide a \"question\" for human approval."] : [],
245
270
  ...standing.filter(Boolean).flatMap((rule) => ["", rule]),
@@ -293,6 +318,26 @@ function sourceScope(settings) {
293
318
  observed: true
294
319
  };
295
320
  }
321
+ if (input.source === "gitlab") {
322
+ const gitlab = settings.gitlab;
323
+ if (!gitlab?.enabled) return {
324
+ listened: false,
325
+ reason: "sourceOff"
326
+ };
327
+ const project = input.meta.repository ?? gitlab.project;
328
+ if (!project) return {
329
+ listened: false,
330
+ reason: "unsupported"
331
+ };
332
+ if (project.toLowerCase() !== gitlab.project.toLowerCase()) return {
333
+ listened: false,
334
+ reason: "otherRepository"
335
+ };
336
+ return {
337
+ listened: true,
338
+ observed: Boolean(input.meta.isPr) && Boolean(gitlab.mrReview?.enabled)
339
+ };
340
+ }
296
341
  if (input.source !== "github") return {
297
342
  listened: false,
298
343
  reason: "unsupported"
@@ -320,7 +365,7 @@ function sourceScope(settings) {
320
365
  const UNASKED_RULE = "unasked";
321
366
  /** The Policy of one settings file, rebuilt whenever the round reads it. */
322
367
  function buildPolicy(settings, scope) {
323
- const people = (source) => new Set((source === "feishu" ? settings.feishu?.allowed : source === "twitter" ? settings.twitter?.allowed : settings.github?.allowed)?.map((id) => id.toLowerCase()) ?? []);
368
+ const people = (source) => new Set((source === "feishu" ? settings.feishu?.allowed : source === "twitter" ? settings.twitter?.allowed : source === "gitlab" ? settings.gitlab?.allowed : settings.github?.allowed)?.map((id) => id.toLowerCase()) ?? []);
324
369
  return {
325
370
  version: `${settings.policy.mode}:${settings.policy.rules.filter((rule) => rule.enabled).map((rule) => rule.id).join(",")}`,
326
371
  paused: false,
@@ -334,7 +379,10 @@ function buildPolicy(settings, scope) {
334
379
  cell: "listedUnaddressed"
335
380
  }
336
381
  };
337
- if (trigger.source === "github" && Boolean(trigger.meta?.isPr) && Boolean(settings.github?.prReview?.enabled) && settings.github?.prReview?.allowCommunityPrs !== false) {
382
+ const reviewEnabled = trigger.source === "gitlab" ? settings.gitlab?.mrReview?.enabled : trigger.source === "github" ? settings.github?.prReview?.enabled : false;
383
+ const isPrReview = Boolean(trigger.meta?.isPr) && Boolean(reviewEnabled);
384
+ const community = trigger.source === "gitlab" ? settings.gitlab?.mrReview?.allowCommunityMrs !== false : settings.github?.prReview?.allowCommunityPrs !== false;
385
+ if (isPrReview && community) {
338
386
  const addressed = !!trigger.addressed;
339
387
  const basis = addressed ? {
340
388
  via: "listed",
@@ -889,15 +937,15 @@ const escapeRegExp = (text) => text.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
889
937
  * A notification only says that something mentioned the account. The comment itself is read afterwards, so the Trigger
890
938
  * carries what the person wrote, not the notification's summary.
891
939
  */
892
- const SOURCE$2 = "github";
940
+ const SOURCE$3 = "github";
893
941
  /** A thread identifier for an Issue or pull request number; both share one sequence in GitHub. */
894
942
  const githubThread = (number) => ({
895
- source: SOURCE$2,
943
+ source: SOURCE$3,
896
944
  id: String(number)
897
945
  });
898
946
  /** Where a reply to this number goes. */
899
947
  const githubChannel = (repository, number, url) => ({
900
- source: SOURCE$2,
948
+ source: SOURCE$3,
901
949
  thread: threadKey(githubThread(number)),
902
950
  address: {
903
951
  number: String(number),
@@ -972,10 +1020,10 @@ function commentTrigger(input) {
972
1020
  const login = comment.user.login;
973
1021
  return {
974
1022
  id: key("github-comment", url, String(comment.id ?? ""), at),
975
- source: SOURCE$2,
1023
+ source: SOURCE$3,
976
1024
  threads: [githubThread(number)],
977
1025
  actor: {
978
- source: SOURCE$2,
1026
+ source: SOURCE$3,
979
1027
  id: login
980
1028
  },
981
1029
  human: isHumanLogin(comment.user) && !sameName(login, agent),
@@ -1076,10 +1124,10 @@ async function pollOpenPullRequests(input) {
1076
1124
  const url = pr.url ?? githubPage(input.repository, pr.number, true);
1077
1125
  triggers.push({
1078
1126
  id: prKey,
1079
- source: SOURCE$2,
1127
+ source: SOURCE$3,
1080
1128
  threads: [githubThread(pr.number)],
1081
1129
  actor: {
1082
- source: SOURCE$2,
1130
+ source: SOURCE$3,
1083
1131
  id: pr.author.login
1084
1132
  },
1085
1133
  human: isHumanLogin(pr.author) && !sameName(pr.author.login, input.agent),
@@ -1101,6 +1149,247 @@ async function pollOpenPullRequests(input) {
1101
1149
  }
1102
1150
  return triggers;
1103
1151
  }
1152
+ // src/sources/gitlab.ts
1153
+ /**
1154
+ * The GitLab Source: turns to-do items addressed to the agent and open merge requests into Triggers.
1155
+ *
1156
+ * GitLab delivers a mention, a direct address or an assignment to the agent's account as a to-do item, so the poll reads
1157
+ * `/todos` rather than every note in the project. A to-do carries the note's text, its author and the issue or merge
1158
+ * request it sits on, so a second request is not needed to know what the person wrote.
1159
+ *
1160
+ * The same project path and host reach a self-managed GitLab: `glab --hostname` chooses the instance, and every URL this
1161
+ * module builds names that host rather than gitlab.com.
1162
+ */
1163
+ const SOURCE$2 = "gitlab";
1164
+ /** GitLab's API names a project by its URL-encoded namespace path, subgroups included. */
1165
+ const projectPath = (project) => encodeURIComponent(project);
1166
+ /** Web address of an issue or a merge request on the configured host. */
1167
+ const gitlabPage = (host, project, iid, mergeRequest = false) => `https://${host}/${project}/-/${mergeRequest ? "merge_requests" : "issues"}/${iid}`;
1168
+ /** A thread names its kind, because an issue and a merge request can share the same iid in one project. */
1169
+ const gitlabThread = (project, iid, mergeRequest = false) => ({
1170
+ source: SOURCE$2,
1171
+ id: `${project}${mergeRequest ? "!" : "#"}${iid}`
1172
+ });
1173
+ const gitlabChannel = (host, project, iid, kind, url) => ({
1174
+ source: SOURCE$2,
1175
+ thread: threadKey(gitlabThread(project, iid, kind === "merge_request")),
1176
+ address: {
1177
+ host,
1178
+ project,
1179
+ number: String(iid),
1180
+ kind,
1181
+ ...url ? { url } : {}
1182
+ }
1183
+ });
1184
+ /** True for an account GitLab reports as a bot rather than a person. */
1185
+ const isBot = (user) => user?.bot === true || /_bot(?:\b|_)/.test(user?.username ?? "") || /\[bot\]$/.test(user?.username ?? "");
1186
+ const PersonSchema = z.looseObject({
1187
+ username: z.string().nullish(),
1188
+ name: z.string().nullish(),
1189
+ bot: z.boolean().nullish()
1190
+ }).nullish().transform((user) => user ?? {
1191
+ username: "",
1192
+ name: null,
1193
+ bot: null
1194
+ });
1195
+ /** Actions that put a person's request in front of the agent. A build failure or an approval is not one. */
1196
+ const ADDRESSING = /* @__PURE__ */ new Set([
1197
+ "mentioned",
1198
+ "directly_addressed",
1199
+ "assigned",
1200
+ "review_requested"
1201
+ ]);
1202
+ z.looseObject({
1203
+ id: z.union([z.number(), z.string()]),
1204
+ action_name: z.string(),
1205
+ target_type: z.string(),
1206
+ author: PersonSchema,
1207
+ target: z.looseObject({
1208
+ iid: z.number().nullish(),
1209
+ title: z.string().nullish(),
1210
+ description: z.string().nullish(),
1211
+ web_url: z.string().nullish(),
1212
+ state: z.string().nullish()
1213
+ }).nullish(),
1214
+ project: z.looseObject({ path_with_namespace: z.string().nullish() }).nullish(),
1215
+ body: z.string().nullish(),
1216
+ target_url: z.string().nullish(),
1217
+ created_at: z.string().nullish(),
1218
+ updated_at: z.string().nullish()
1219
+ });
1220
+ /**
1221
+ * Builds a Trigger from one to-do item, or `undefined` when it names no issue or merge request.
1222
+ *
1223
+ * `mentioned` and `directly_addressed` mean the person wrote to the agent; `assigned` and `review_requested` mean the
1224
+ * agent was handed the item without a mention, which is still a request aimed at the agent and no one else.
1225
+ */
1226
+ function todoTrigger(input) {
1227
+ const { todo, host, project, agent } = input;
1228
+ const iid = todo.target?.iid;
1229
+ if (!iid) return void 0;
1230
+ const mergeRequest = todo.target_type === "MergeRequest";
1231
+ const kind = mergeRequest ? "merge_request" : "issue";
1232
+ const username = todo.author?.username ?? "";
1233
+ const text = [todo.target?.title?.trim() ?? "", todo.body?.trim() || todo.target?.description?.trim() || ""].filter(Boolean).join("\n\n") || "(the to-do carried no text)";
1234
+ const url = todo.target?.web_url ?? todo.target_url ?? gitlabPage(host, project, iid, mergeRequest);
1235
+ const at = todo.updated_at ?? todo.created_at ?? (/* @__PURE__ */ new Date()).toISOString();
1236
+ const addressing = ADDRESSING.has(todo.action_name);
1237
+ return {
1238
+ id: key("gitlab-todo", project, String(todo.id)),
1239
+ source: SOURCE$2,
1240
+ threads: [gitlabThread(project, iid, mergeRequest)],
1241
+ actor: {
1242
+ source: SOURCE$2,
1243
+ id: username
1244
+ },
1245
+ human: !isBot(todo.author) && !sameName(username, agent),
1246
+ ...addressing ? { addressed: /mentioned|directly_addressed/.test(todo.action_name) ? "mention" : "direct" } : {},
1247
+ at,
1248
+ text,
1249
+ url,
1250
+ channel: gitlabChannel(host, project, iid, kind, url),
1251
+ meta: {
1252
+ number: iid,
1253
+ isPr: mergeRequest,
1254
+ kind,
1255
+ repository: project,
1256
+ host,
1257
+ author: username,
1258
+ action: todo.action_name
1259
+ }
1260
+ };
1261
+ }
1262
+ z.looseObject({
1263
+ iid: z.number(),
1264
+ title: z.string(),
1265
+ description: z.string().nullish(),
1266
+ author: PersonSchema,
1267
+ updated_at: z.string().nullish(),
1268
+ web_url: z.string().nullish(),
1269
+ source_branch: z.string().nullish(),
1270
+ sha: z.string().nullish(),
1271
+ draft: z.boolean().nullish(),
1272
+ work_in_progress: z.boolean().nullish()
1273
+ });
1274
+ /** The username the CLI acts as on `host`, which the Trigger builder uses to tell the agent's own work apart. */
1275
+ async function gitlabLogin(cli, host, signal) {
1276
+ const user = await runJson(cli, apiArgs(host, "user"), { signal });
1277
+ if (!user.username) throw new Error(`${cli} api user named no username on ${host}`);
1278
+ return user.username;
1279
+ }
1280
+ /** One `glab api` call: the host is named every time, so a checkout cannot choose another GitLab by accident. */
1281
+ const apiArgs = (host, path, extra = []) => [
1282
+ "api",
1283
+ "--hostname",
1284
+ host,
1285
+ path,
1286
+ ...extra
1287
+ ];
1288
+ /**
1289
+ * Polls pending to-do items for the project and returns the Triggers not seen before.
1290
+ *
1291
+ * A to-do for another project is marked seen as well: the account may receive to-dos from everywhere, and only this
1292
+ * project's are this installation's work.
1293
+ */
1294
+ async function pollTodos(input) {
1295
+ const todos = await runJson(input.cli, apiArgs(input.host, "todos?state=pending&per_page=100"), { signal: input.signal });
1296
+ const triggers = [];
1297
+ for (const todo of todos) {
1298
+ const id = `gitlab:todo:${todo.id}`;
1299
+ if (input.seen(id)) continue;
1300
+ input.mark(id);
1301
+ if (!sameName(todo.project?.path_with_namespace ?? "", input.project)) continue;
1302
+ if (!ADDRESSING.has(todo.action_name)) continue;
1303
+ const username = todo.author?.username ?? "";
1304
+ if (isBot(todo.author) || sameName(username, input.agent)) continue;
1305
+ const trigger = todoTrigger({
1306
+ todo,
1307
+ host: input.host,
1308
+ project: input.project,
1309
+ agent: input.agent
1310
+ });
1311
+ if (trigger) triggers.push(trigger);
1312
+ }
1313
+ return triggers;
1314
+ }
1315
+ /**
1316
+ * Polls open merge requests and returns one Trigger per new or updated merge request.
1317
+ *
1318
+ * The key carries `updated_at`, so a push to the source branch asks for another review while an untouched merge request
1319
+ * is not reviewed twice.
1320
+ */
1321
+ async function pollOpenMergeRequests(input) {
1322
+ const mergeRequests = await runJson(input.cli, apiArgs(input.host, `projects/${projectPath(input.project)}/merge_requests?state=opened&per_page=100`), { signal: input.signal });
1323
+ const triggers = [];
1324
+ for (const mergeRequest of mergeRequests) {
1325
+ const author = mergeRequest.author?.username ?? "";
1326
+ if (isBot(mergeRequest.author) || sameName(author, input.agent)) continue;
1327
+ const at = mergeRequest.updated_at ?? (/* @__PURE__ */ new Date()).toISOString();
1328
+ const id = key("gitlab-mr-review", input.project, String(mergeRequest.iid), at);
1329
+ if (input.seen(id)) continue;
1330
+ input.mark(id);
1331
+ const url = mergeRequest.web_url ?? gitlabPage(input.host, input.project, mergeRequest.iid, true);
1332
+ triggers.push({
1333
+ id,
1334
+ source: SOURCE$2,
1335
+ threads: [gitlabThread(input.project, mergeRequest.iid, true)],
1336
+ actor: {
1337
+ source: SOURCE$2,
1338
+ id: author
1339
+ },
1340
+ human: true,
1341
+ addressed: "mention",
1342
+ at,
1343
+ text: `# Merge Request Review: !${mergeRequest.iid} ${mergeRequest.title}\n\nAuthor: @${author}\nURL: ${url}\n\n${mergeRequest.description ?? ""}`,
1344
+ channel: gitlabChannel(input.host, input.project, mergeRequest.iid, "merge_request", url),
1345
+ url,
1346
+ meta: {
1347
+ number: mergeRequest.iid,
1348
+ isPr: true,
1349
+ kind: "pull_review",
1350
+ repository: input.project,
1351
+ host: input.host,
1352
+ author,
1353
+ updatedAt: at
1354
+ }
1355
+ });
1356
+ }
1357
+ return triggers;
1358
+ }
1359
+ /** Posts a note on an issue or a merge request. */
1360
+ async function replyNote(input) {
1361
+ const kind = input.kind === "merge_request" ? "merge_requests" : "issues";
1362
+ await run(input.cli, apiArgs(input.host, `projects/${projectPath(input.project)}/${kind}/${input.iid}/notes`, [
1363
+ "--method",
1364
+ "POST",
1365
+ "--raw-field",
1366
+ `body=${input.body}`
1367
+ ]), { signal: input.signal });
1368
+ }
1369
+ /**
1370
+ * Merges a merge request, optionally only once its pipeline succeeds.
1371
+ *
1372
+ * GitLab decides whether a merge squashes by project settings, not per request, so `squash` asks for the project's
1373
+ * squash behaviour rather than naming a merge method.
1374
+ */
1375
+ async function mergeMergeRequest(input) {
1376
+ await run(input.cli, apiArgs(input.host, `projects/${projectPath(input.project)}/merge_requests/${input.iid}/merge`, [
1377
+ "--method",
1378
+ "PUT",
1379
+ "--field",
1380
+ `squash=${input.squash}`,
1381
+ ...input.autoMerge ? ["--field", "merge_when_pipeline_succeeds=true"] : []
1382
+ ]), { signal: input.signal });
1383
+ }
1384
+ /** Closes a merge request without merging it. */
1385
+ async function closeMergeRequest(input) {
1386
+ await run(input.cli, apiArgs(input.host, `projects/${projectPath(input.project)}/merge_requests/${input.iid}`, [
1387
+ "--method",
1388
+ "PUT",
1389
+ "--field",
1390
+ "state_event=close"
1391
+ ]), { signal: input.signal });
1392
+ }
1104
1393
  // src/sources/feishu.ts
1105
1394
  /**
1106
1395
  * The Feishu Source: a bot listens in chats, and a message that mentions it, or a direct message, becomes a Trigger.
@@ -1534,7 +1823,7 @@ async function isGitRepository(directory) {
1534
1823
  }
1535
1824
  /**
1536
1825
  * Creates the worktree for a ticket and returns its directory.
1537
- * When `prNumber` is specified, fetches the PR branch/head and checks it out directly into the worktree.
1826
+ * When `prNumber` is specified, fetches the review's head and checks it out directly into the worktree.
1538
1827
  *
1539
1828
  * @throws when git cannot create the worktree, such as when the checkout has no commit yet; the caller then reports the
1540
1829
  * ticket as failed instead of starting an agent in a directory that is not the repository.
@@ -1545,6 +1834,8 @@ async function prepareWorktree(options) {
1545
1834
  if ((await readdir(directory)).length) return directory;
1546
1835
  if (!await isGitRepository(checkout)) return directory;
1547
1836
  if (prNumber) {
1837
+ const head = options.ref ?? `pull/${prNumber}/head`;
1838
+ const remote = options.remote ?? (repository ? `https://github.com/${repository}.git` : void 0);
1548
1839
  let fetched = false;
1549
1840
  try {
1550
1841
  await run("git", [
@@ -1552,20 +1843,20 @@ async function prepareWorktree(options) {
1552
1843
  checkout,
1553
1844
  "fetch",
1554
1845
  "origin",
1555
- `pull/${prNumber}/head:${branch}`
1846
+ `${head}:${branch}`
1556
1847
  ], {
1557
1848
  signal,
1558
1849
  timeoutMs: 6e4
1559
1850
  });
1560
1851
  fetched = true;
1561
1852
  } catch {
1562
- if (repository) try {
1853
+ if (remote) try {
1563
1854
  await run("git", [
1564
1855
  "-C",
1565
1856
  checkout,
1566
1857
  "fetch",
1567
- `https://github.com/${repository}.git`,
1568
- `pull/${prNumber}/head:${branch}`
1858
+ remote,
1859
+ `${head}:${branch}`
1569
1860
  ], {
1570
1861
  signal,
1571
1862
  timeoutMs: 6e4
@@ -1586,7 +1877,7 @@ async function prepareWorktree(options) {
1586
1877
  timeoutMs: 12e4
1587
1878
  }).catch(async (error) => {
1588
1879
  await removeWorktree(checkout, directory, signal, branch);
1589
- throw new Error(`${directory} is not a branch point for PR #${prNumber}: ${error.message}`, { cause: error });
1880
+ throw new Error(`${directory} is not a branch point for review #${prNumber}: ${error.message}`, { cause: error });
1590
1881
  });
1591
1882
  return directory;
1592
1883
  }
@@ -1825,6 +2116,30 @@ async function send(channel, clis, log, attentionConfig) {
1825
2116
  }
1826
2117
  continue;
1827
2118
  }
2119
+ if (message.channel.source === "gitlab") {
2120
+ const address = message.channel.address;
2121
+ if (!clis.gitlab) {
2122
+ log(`Cannot post on ${address.project}: the GitLab Source is off`);
2123
+ continue;
2124
+ }
2125
+ if (!address.project || !address.number) continue;
2126
+ const kind = address.kind === "merge_request" ? "merge_request" : "issue";
2127
+ const url = `${address.project}${kind === "merge_request" ? "!" : "#"}${address.number}`;
2128
+ try {
2129
+ await replyNote({
2130
+ cli: clis.gitlab.cli,
2131
+ host: address.host ?? clis.gitlab.host,
2132
+ project: address.project,
2133
+ iid: Number(address.number),
2134
+ kind,
2135
+ body: message.text
2136
+ });
2137
+ log(`Posted a note on ${url}`);
2138
+ } catch (error) {
2139
+ log(`Could not post on ${url}: ${error.message}`);
2140
+ }
2141
+ continue;
2142
+ }
1828
2143
  const address = message.channel.address;
1829
2144
  if (!address.number || !address.repository) continue;
1830
2145
  if (!clis.github) {
@@ -1931,11 +2246,13 @@ var AgentExecutor = class {
1931
2246
  });
1932
2247
  }
1933
2248
  async execute(ticket, assignment, controller) {
1934
- const { settings, runner, stateDir, accounts, feishuCli, site, repo, log } = this.options;
2249
+ const { settings, runner, stateDir, accounts, site, repo, log } = this.options;
1935
2250
  const directory = ticket.execution?.directory ?? join(stateDir, "work", ticket.id);
1936
2251
  const trigger = repo?.triggers.get(ticket.origin.triggerId);
1937
2252
  const isPrReview = Boolean(trigger?.meta?.isPr) || ticket.mandate.scope === "pr_review";
1938
2253
  const prNumber = typeof trigger?.meta?.number === "number" ? trigger.meta.number : void 0;
2254
+ const source = trigger?.source === "gitlab" ? "gitlab" : "github";
2255
+ const review = source === "gitlab" ? settings.gitlab?.mrReview : settings.github?.prReview;
1939
2256
  try {
1940
2257
  const branch = ticketBranch(settings.branchPrefix, ticket.title, ticket.id);
1941
2258
  await prepareWorktree({
@@ -1943,7 +2260,11 @@ var AgentExecutor = class {
1943
2260
  directory,
1944
2261
  branch,
1945
2262
  prNumber: isPrReview ? prNumber : void 0,
1946
- repository: settings.github?.repository,
2263
+ repository: source === "gitlab" ? settings.gitlab?.project : settings.github?.repository,
2264
+ ...source === "gitlab" && settings.gitlab && prNumber !== void 0 ? {
2265
+ ref: `refs/merge-requests/${prNumber}/head`,
2266
+ remote: `https://${settings.gitlab.host}/${settings.gitlab.project}.git`
2267
+ } : {},
1947
2268
  signal: controller.signal
1948
2269
  });
1949
2270
  if (settings.executor.prepare) await run("/bin/sh", ["-c", settings.executor.prepare], {
@@ -1951,10 +2272,10 @@ var AgentExecutor = class {
1951
2272
  timeoutMs: 12e4
1952
2273
  });
1953
2274
  let prVerification;
1954
- if (isPrReview && settings.github?.prReview?.verifyCommands?.length) prVerification = await runPrVerification({
2275
+ if (isPrReview && review?.verifyCommands?.length) prVerification = await runPrVerification({
1955
2276
  cwd: directory,
1956
- commands: settings.github.prReview.verifyCommands,
1957
- timeoutSeconds: settings.github.prReview.verifyTimeoutSeconds,
2277
+ commands: review.verifyCommands,
2278
+ timeoutSeconds: review.verifyTimeoutSeconds,
1958
2279
  signal: controller.signal
1959
2280
  });
1960
2281
  const prompt = await this.options.prompt(ticket, directory, branch, prVerification);
@@ -1962,58 +2283,97 @@ var AgentExecutor = class {
1962
2283
  const result = await runner.run({
1963
2284
  prompt,
1964
2285
  cwd: directory,
1965
- env: runEnvironment(feishuCli ? {
1966
- ...accounts,
1967
- feishuCli
1968
- } : accounts, this.variables(ticket, directory, branch)),
2286
+ env: runEnvironment(accounts, this.variables(ticket, directory, branch)),
1969
2287
  signal: controller.signal,
1970
2288
  timeoutMs: settings.executor.timeoutMinutes * 6e4,
1971
2289
  model: settings.executor.model,
1972
2290
  readOnly: isAutonomous
1973
2291
  });
1974
2292
  const report = result.report ?? inferReport(result.finalText, result.ok);
1975
- if (isPrReview && prNumber && settings.github) {
2293
+ if (isPrReview && prNumber && review) {
1976
2294
  const textToAnalyze = `${result.finalText}\n${report.summary}`;
1977
2295
  const decisionMatch = /DECISION:\s*(MERGE|APPROVE|REQUEST_CHANGES|CLOSE)/i.exec(textToAnalyze);
1978
2296
  const decision = decisionMatch ? decisionMatch[1].toUpperCase() : report.state === "ready" ? "APPROVE" : "REQUEST_CHANGES";
1979
- if (decision === "MERGE" && settings.github.prReview?.autoMerge && (!prVerification || prVerification.passed)) {
1980
- const method = settings.github.prReview.mergeMethod ?? "squash";
1981
- try {
1982
- await run(settings.github.cli, [
2297
+ const request = source === "gitlab" ? `MR !${prNumber}` : `PR #${prNumber}`;
2298
+ const project = source === "gitlab" ? settings.gitlab?.project : settings.github?.repository;
2299
+ const verdict = (state) => `🤖 **SuperAgent Review Verdict: ${state}**\n\n${deliverable(report.summary)}`;
2300
+ if (decision === "MERGE" && review.autoMerge && (!prVerification || prVerification.passed)) try {
2301
+ if (source === "gitlab" && settings.gitlab) {
2302
+ const gitlab = settings.gitlab;
2303
+ await mergeMergeRequest({
2304
+ cli: gitlab.cli,
2305
+ host: gitlab.host,
2306
+ project: gitlab.project,
2307
+ iid: prNumber,
2308
+ squash: gitlab.mrReview?.squash ?? true,
2309
+ autoMerge: true
2310
+ });
2311
+ await replyNote({
2312
+ cli: gitlab.cli,
2313
+ host: gitlab.host,
2314
+ project: gitlab.project,
2315
+ iid: prNumber,
2316
+ kind: "merge_request",
2317
+ body: `${verdict("MERGED")}\n\nAutomated local verification passed and code review approved.`
2318
+ }).catch(() => {});
2319
+ } else if (settings.github) {
2320
+ const github = settings.github;
2321
+ const method = github.prReview?.mergeMethod ?? "squash";
2322
+ await run(github.cli, [
1983
2323
  "pr",
1984
2324
  "merge",
1985
2325
  String(prNumber),
1986
2326
  `--${method}`,
1987
2327
  "--auto",
1988
2328
  "--repo",
1989
- settings.github.repository
2329
+ github.repository
1990
2330
  ]);
1991
- await run(settings.github.cli, [
2331
+ await run(github.cli, [
1992
2332
  "pr",
1993
2333
  "comment",
1994
2334
  String(prNumber),
1995
2335
  "--repo",
1996
- settings.github.repository,
2336
+ github.repository,
1997
2337
  "-b",
1998
- `🤖 **SuperAgent Review Verdict: MERGED**\n\n${deliverable(report.summary)}\n\nAutomated local verification passed and code review approved.`
2338
+ `${verdict("MERGED")}\n\nAutomated local verification passed and code review approved.`
1999
2339
  ]).catch(() => {});
2000
- log?.(`Merged PR #${prNumber} on ${settings.github.repository}`);
2001
- } catch (mergeErr) {
2002
- log?.(`Could not merge PR #${prNumber}: ${mergeErr.message}`);
2003
2340
  }
2004
- } else if (decision === "CLOSE") try {
2005
- await run(settings.github.cli, [
2006
- "pr",
2007
- "close",
2008
- String(prNumber),
2009
- "--repo",
2010
- settings.github.repository,
2011
- "-c",
2012
- `🤖 **SuperAgent Review Verdict: CLOSED**\n\n${deliverable(report.summary)}`
2013
- ]);
2014
- log?.(`Closed PR #${prNumber} on ${settings.github.repository}`);
2341
+ log?.(`Merged ${request} on ${project}`);
2342
+ } catch (mergeErr) {
2343
+ log?.(`Could not merge ${request}: ${mergeErr.message}`);
2344
+ }
2345
+ else if (decision === "CLOSE") try {
2346
+ if (source === "gitlab" && settings.gitlab) {
2347
+ const gitlab = settings.gitlab;
2348
+ await closeMergeRequest({
2349
+ cli: gitlab.cli,
2350
+ host: gitlab.host,
2351
+ project: gitlab.project,
2352
+ iid: prNumber
2353
+ });
2354
+ await replyNote({
2355
+ cli: gitlab.cli,
2356
+ host: gitlab.host,
2357
+ project: gitlab.project,
2358
+ iid: prNumber,
2359
+ kind: "merge_request",
2360
+ body: verdict("CLOSED")
2361
+ }).catch(() => {});
2362
+ } else if (settings.github) {
2363
+ const github = settings.github;
2364
+ await run(github.cli, [
2365
+ "pr",
2366
+ "close",
2367
+ String(prNumber),
2368
+ "--repo",
2369
+ github.repository,
2370
+ "-c",
2371
+ verdict("CLOSED")
2372
+ ]);
2373
+ }
2374
+ log?.(`Closed ${request} on ${project}`);
2015
2375
  } catch (closeErr) {
2016
- log?.(`Could not close PR #${prNumber}: ${closeErr.message}`);
2376
+ log?.(`Could not close ${request}: ${closeErr.message}`);
2017
2377
  }
2018
2378
  }
2019
2379
  if (report.followupAfterSeconds && report.followupAfterSeconds > 0) await new TimerStore(stateDir).save({
@@ -2098,16 +2458,24 @@ async function runLoop(options) {
2098
2458
  if (!options.once) caller.addEventListener("abort", () => stop.abort(), { once: true });
2099
2459
  const signal = stop.signal;
2100
2460
  const github = settings.github?.enabled ? settings.github : void 0;
2461
+ const gitlab = settings.gitlab?.enabled ? settings.gitlab : void 0;
2101
2462
  const feishu = settings.feishu?.enabled ? settings.feishu : void 0;
2102
2463
  const twitter = settings.twitter?.enabled ? settings.twitter : void 0;
2103
- if (!github && !feishu && !twitter) throw new Error("No Source is on in settings.yaml; nothing to poll.");
2104
- const login = github ? await agentLogin(github.cli, signal) : "";
2464
+ if (!github && !gitlab && !feishu && !twitter) throw new Error("No Source is on in settings.yaml; nothing to poll.");
2465
+ const login = github ? await agentLogin(github.cli, signal) : gitlab ? await gitlabLogin(gitlab.cli, gitlab.host, signal) : "";
2105
2466
  const twitterBot = twitter ? await twitterAccount(twitter.cli, signal) : "";
2106
2467
  const accounts = {
2107
2468
  stateDir: settings.stateDir,
2108
- githubCli: github?.cli ?? "gh",
2469
+ ...github ? { githubCli: github.cli } : {},
2470
+ ...gitlab ? {
2471
+ gitlabCli: gitlab.cli,
2472
+ gitlabHost: gitlab.host
2473
+ } : {},
2474
+ ...feishu ? { feishuCli: feishu.cli } : {},
2109
2475
  agentLogin: login
2110
2476
  };
2477
+ /** The project the tickets change, in the forge's own naming. */
2478
+ const repository = github?.repository ?? gitlab?.project ?? settings.checkout;
2111
2479
  await writeEnvironment(accounts, settings.executor.blockedCommands);
2112
2480
  const standing = await standingRules();
2113
2481
  const channel = outbox();
@@ -2127,55 +2495,54 @@ async function runLoop(options) {
2127
2495
  executor: void 0,
2128
2496
  outbox: channel
2129
2497
  });
2130
- const site = {
2131
- started: (ticketId, assignmentId) => engine.assignmentStarted(ticketId, assignmentId),
2132
- reported: (ticketId, report) => {
2133
- record(engine, repo, [{
2134
- ticketId,
2135
- report
2136
- }], log);
2137
- },
2138
- failed: (ticketId, _assignmentId, summary) => {
2139
- record(engine, repo, [{
2140
- ticketId,
2141
- report: {
2142
- state: "failed",
2143
- summary
2144
- }
2145
- }], log);
2146
- },
2147
- interrupted: (ticketId, assignmentId) => {
2148
- try {
2149
- engine.assignmentInterrupted(ticketId, assignmentId);
2150
- } catch (error) {
2151
- log(`Could not recover ${ticketId}: ${error.message}`);
2152
- }
2153
- }
2154
- };
2155
2498
  const executor = new AgentExecutor({
2156
2499
  engine,
2157
2500
  settings,
2158
2501
  maxWorkers: settings.executor.maxWorkers,
2159
2502
  runner: runnerFor(settings.executor.agent, settings.executor.binary),
2160
2503
  stateDir: settings.stateDir,
2161
- repository: github?.repository ?? settings.checkout,
2504
+ repository,
2162
2505
  agent: login,
2163
2506
  accounts,
2164
- ...feishu ? { feishuCli: feishu.cli } : {},
2165
- site,
2507
+ site: {
2508
+ started: (ticketId, assignmentId) => engine.assignmentStarted(ticketId, assignmentId),
2509
+ reported: (ticketId, report) => {
2510
+ record(engine, repo, [{
2511
+ ticketId,
2512
+ report
2513
+ }], log);
2514
+ },
2515
+ failed: (ticketId, _assignmentId, summary) => {
2516
+ record(engine, repo, [{
2517
+ ticketId,
2518
+ report: {
2519
+ state: "failed",
2520
+ summary
2521
+ }
2522
+ }], log);
2523
+ },
2524
+ interrupted: (ticketId, assignmentId) => {
2525
+ try {
2526
+ engine.assignmentInterrupted(ticketId, assignmentId);
2527
+ } catch (error) {
2528
+ log(`Could not recover ${ticketId}: ${error.message}`);
2529
+ }
2530
+ }
2531
+ },
2166
2532
  repo,
2167
2533
  log,
2168
2534
  prompt: async (ticket, directory, branch, prVerification) => {
2169
2535
  const trigger = repo.triggers.get(ticket.origin.triggerId);
2170
- const source = trigger?.source === "feishu" ? "feishu" : "github";
2536
+ const source = trigger?.source === "feishu" ? "feishu" : trigger?.source === "gitlab" ? "gitlab" : "github";
2171
2537
  const isPrReview = Boolean(trigger?.meta?.isPr) || ticket.mandate.scope === "pr_review";
2172
2538
  const prNumber = typeof trigger?.meta?.number === "number" ? trigger.meta.number : void 0;
2173
2539
  const notes = ticket.inputs.flatMap((input) => input.kind === "text" ? [input.text] : []);
2174
2540
  const readOnly = ticket.mandate.strength === "inferred" && !isPrReview;
2541
+ const autoMerge = source === "gitlab" ? gitlab?.mrReview?.autoMerge : github?.prReview?.autoMerge;
2175
2542
  return composePrompt({
2176
2543
  ticket,
2177
2544
  trigger,
2178
- repository: github?.repository ?? settings.checkout,
2545
+ repository,
2179
2546
  agentLogin: login,
2180
2547
  branchPrefix: settings.branchPrefix,
2181
2548
  source,
@@ -2187,7 +2554,7 @@ async function runLoop(options) {
2187
2554
  isPrReview,
2188
2555
  prNumber,
2189
2556
  prVerification,
2190
- autoMergeAllowed: Boolean(github?.prReview?.autoMerge)
2557
+ autoMergeAllowed: Boolean(autoMerge)
2191
2558
  });
2192
2559
  }
2193
2560
  });
@@ -2322,6 +2689,36 @@ async function runLoop(options) {
2322
2689
  since = round;
2323
2690
  repo.setMeta(pollKey, since);
2324
2691
  }
2692
+ if (gitlab) {
2693
+ try {
2694
+ const triggers = await pollTodos({
2695
+ cli: gitlab.cli,
2696
+ host: gitlab.host,
2697
+ project: gitlab.project,
2698
+ agent: login,
2699
+ signal,
2700
+ seen: (id) => repo.getMeta(seenKey(id)) === true,
2701
+ mark: (id) => repo.setMeta(seenKey(id), true)
2702
+ });
2703
+ for (const trigger of triggers) if (engine.receive(trigger) !== "duplicate") log(`Received ${trigger.id} from ${trigger.actor.id} on ${trigger.threads[0].id}`);
2704
+ } catch (error) {
2705
+ if (!signal.aborted) log(`GitLab poll failed: ${error.message}`);
2706
+ }
2707
+ if (gitlab.mrReview?.enabled && gitlab.mrReview.pollOpenMrs !== false) try {
2708
+ const triggers = await pollOpenMergeRequests({
2709
+ cli: gitlab.cli,
2710
+ host: gitlab.host,
2711
+ project: gitlab.project,
2712
+ agent: login,
2713
+ signal,
2714
+ seen: (id) => repo.getMeta(`gitlab:seen:${id}`) === true,
2715
+ mark: (id) => repo.setMeta(`gitlab:seen:${id}`, true)
2716
+ });
2717
+ for (const trigger of triggers) if (engine.receive(trigger) !== "duplicate") log(`Received MR review trigger for !${trigger.meta?.number} from ${trigger.actor.id}`);
2718
+ } catch (error) {
2719
+ if (!signal.aborted) log(`Merge request poll failed: ${error.message}`);
2720
+ }
2721
+ }
2325
2722
  if (twitter) try {
2326
2723
  const triggers = await searchTweets(twitter.cli, twitter.query, {
2327
2724
  seen: (id) => repo.getMeta(`twitter:seen:${id}`) === true,
@@ -2408,6 +2805,10 @@ async function runLoop(options) {
2408
2805
  await repo.flush();
2409
2806
  await send(channel, {
2410
2807
  ...github ? { github: github.cli } : {},
2808
+ ...gitlab ? { gitlab: {
2809
+ cli: gitlab.cli,
2810
+ host: gitlab.host
2811
+ } } : {},
2411
2812
  ...feishu ? { feishu: feishu.cli } : {},
2412
2813
  ...twitter ? { twitter: twitter.cli } : {}
2413
2814
  }, log, settings.attention);
@@ -2417,7 +2818,7 @@ async function runLoop(options) {
2417
2818
  if (!signal.aborted) log(`Round failed: ${error.message}\n${error.stack?.split("\n").slice(1, 4).join("\n")}`);
2418
2819
  }
2419
2820
  if (options.once) break;
2420
- const seconds = Math.min(github?.pollSeconds ?? Infinity, feishu ? 15 : Infinity, twitter?.pollSeconds ?? Infinity);
2821
+ const seconds = Math.min(github?.pollSeconds ?? Infinity, gitlab?.pollSeconds ?? Infinity, feishu ? 15 : Infinity, twitter?.pollSeconds ?? Infinity);
2421
2822
  let left = options.once ? 0 : seconds * 1e3;
2422
2823
  while (left > 0 && !signal.aborted) {
2423
2824
  const began = Date.now();
@@ -2534,7 +2935,11 @@ async function resolveMembers(cli, chatId, names) {
2534
2935
  }
2535
2936
  /** Splits `a,b, c` and drops the blanks, so one flag can name several people. */
2536
2937
  const names = (value) => (value ?? "").split(",").map((item) => item.trim()).filter(Boolean);
2537
- const MANAGED = ["github", "feishu"];
2938
+ const MANAGED = [
2939
+ "github",
2940
+ "feishu",
2941
+ "gitlab"
2942
+ ];
2538
2943
  /**
2539
2944
  * The settings file with only the Source sections replaced, so this command keeps the text an operator wrote.
2540
2945
  *
@@ -2584,6 +2989,11 @@ async function setupGithub(options) {
2584
2989
  let login;
2585
2990
  await update(options.dir, async (settings) => {
2586
2991
  const cli = settings.github?.cli ?? "gh";
2992
+ if (settings.gitlab?.enabled) {
2993
+ lines.push("GitHub: this installation already serves GitLab; set `gitlab.enabled` to false before adding GitHub");
2994
+ failed = true;
2995
+ return false;
2996
+ }
2587
2997
  try {
2588
2998
  login = await githubLogin(cli);
2589
2999
  } catch (error) {
@@ -2625,6 +3035,84 @@ async function setupGithub(options) {
2625
3035
  failed
2626
3036
  };
2627
3037
  }
3038
+ /** The host and project of a GitLab remote URL, in either the https or the ssh form. */
3039
+ function gitlabOrigin(origin) {
3040
+ const match = /^(?:https?:\/\/([^/]+)\/|ssh:\/\/git@([^/]+)\/|git@([^/]+):)(.+?)(?:\.git)?\/?$/.exec(origin.trim());
3041
+ if (!match) return void 0;
3042
+ const host = (match[1] ?? match[2] ?? match[3] ?? "").replace(/^[^@]+@/, "");
3043
+ const project = match[4];
3044
+ return host && project ? {
3045
+ host,
3046
+ project
3047
+ } : void 0;
3048
+ }
3049
+ /** Fills the GitLab Source from `glab` and the checkout's origin, so a self-managed instance is one field. */
3050
+ async function setupGitlab(options) {
3051
+ const lines = [];
3052
+ let failed = false;
3053
+ await update(options.dir, async (settings) => {
3054
+ const cli = settings.gitlab?.cli ?? "glab";
3055
+ if (settings.github?.enabled) {
3056
+ lines.push("GitLab: this installation already serves GitHub; set `github.enabled` to false before adding GitLab");
3057
+ failed = true;
3058
+ return false;
3059
+ }
3060
+ const origin = options.stateDir ? await originOf(settings.checkout, options.stateDir) : void 0;
3061
+ const parsed = origin ? gitlabOrigin(origin) : void 0;
3062
+ const configuredHost = settings.gitlab?.host;
3063
+ const host = configuredHost && configuredHost !== "gitlab.com" ? configuredHost : parsed?.host ?? configuredHost ?? "gitlab.com";
3064
+ const project = settings.gitlab?.project ?? parsed?.project;
3065
+ if (!project) {
3066
+ lines.push("GitLab: no `group/project` in settings and none in the checkout origin; set `gitlab.project`");
3067
+ failed = true;
3068
+ return false;
3069
+ }
3070
+ let login;
3071
+ try {
3072
+ login = await gitlabLogin(cli, host);
3073
+ } catch (error) {
3074
+ lines.push(`GitLab: ${error.message}`);
3075
+ failed = true;
3076
+ return false;
3077
+ }
3078
+ lines.push(`GitLab account: ${login} (${cli} on ${host})`);
3079
+ try {
3080
+ const meta = await runJson(cli, [
3081
+ "api",
3082
+ "--hostname",
3083
+ host,
3084
+ `projects/${encodeURIComponent(project)}`
3085
+ ]);
3086
+ const gitlab = settings.gitlab = {
3087
+ ...settings.gitlab ?? {
3088
+ enabled: true,
3089
+ host,
3090
+ project,
3091
+ cli,
3092
+ pollSeconds: 60,
3093
+ allowed: []
3094
+ },
3095
+ enabled: settings.gitlab?.enabled ?? true,
3096
+ host,
3097
+ cli,
3098
+ project: meta.path_with_namespace ?? project,
3099
+ allowed: options.allow.length ? [...options.allow] : settings.gitlab?.allowed ?? []
3100
+ };
3101
+ lines.push(`Project: ${gitlab.project}${meta.visibility ? ` (${meta.visibility})` : ""}`);
3102
+ lines.push(`Allowed users: ${gitlab.allowed.join(", ") || "(none)"}`);
3103
+ if (gitlab.allowed.every((item) => item.toLowerCase() !== login.toLowerCase())) lines.push(`Note: ${login} is not allowed to ask for work; add it with \`--allow ${login}\` if the agent should answer itself.`);
3104
+ return true;
3105
+ } catch (error) {
3106
+ lines.push(`GitLab: ${error.message}`);
3107
+ failed = true;
3108
+ return false;
3109
+ }
3110
+ });
3111
+ return {
3112
+ lines,
3113
+ failed
3114
+ };
3115
+ }
2628
3116
  async function findChat(cli, wanted, current) {
2629
3117
  if (wanted?.startsWith("oc_")) return wanted;
2630
3118
  const chats = await botChats(cli);
@@ -2708,11 +3196,12 @@ async function setupFeishu(options) {
2708
3196
  }
2709
3197
  /** Runs the steps in order and prints what each found; a failed GitHub step still lets Feishu run. */
2710
3198
  async function setup(options) {
2711
- const targets = options.targets.length ? options.targets : ["github", "feishu"];
3199
+ const forge = (await readSettings(join(options.dir, "settings.yaml")).catch(() => void 0))?.gitlab?.enabled ? "gitlab" : "github";
3200
+ const targets = options.targets.length ? options.targets : [forge, "feishu"];
2712
3201
  let failed = false;
2713
3202
  try {
2714
3203
  for (const target of targets) {
2715
- const report = target === "github" ? await setupGithub(options) : await setupFeishu(options);
3204
+ const report = target === "github" ? await setupGithub(options) : target === "feishu" ? await setupFeishu(options) : await setupGitlab(options);
2716
3205
  for (const line of report.lines) options.log(line);
2717
3206
  failed ||= report.failed;
2718
3207
  }
@@ -2731,10 +3220,10 @@ async function setup(options) {
2731
3220
  * The command prints Markdown because people and agents both read it: an agent that needs to know what is open runs
2732
3221
  * `superagent status` and gets an answer it can put straight into a prompt.
2733
3222
  */
2734
- const USAGE = `superagent — an agent that turns GitHub and Feishu requests into tickets
3223
+ const USAGE = `superagent — an agent that turns GitHub, GitLab and Feishu requests into tickets
2735
3224
 
2736
3225
  superagent init [dir] create ${SETTINGS_FILE} and the state directory in dir (default: .)
2737
- superagent setup [dir] [what…] fill the GitHub and Feishu settings from the configured CLIs
3226
+ superagent setup [dir] [what…] fill the Source settings from the configured CLIs
2738
3227
  superagent status [dir] print open tickets and recent activity as Markdown
2739
3228
  superagent doctor [dir] show which coding agents are installed and which one is selected
2740
3229
  superagent agents list the coding agents a configuration may name
@@ -2743,10 +3232,10 @@ const USAGE = `superagent — an agent that turns GitHub and Feishu requests int
2743
3232
 
2744
3233
  superagent setup asks the CLIs that already know the answers, so a person does not copy ids out of a web page:
2745
3234
 
2746
- --allow <names> logins or Feishu user names that may ask for work, comma separated
2747
- (a name becomes the member's open id; the chat's members are added too)
3235
+ --allow <names> logins, GitLab usernames or Feishu user names that may ask for work, comma separated
3236
+ (a Feishu name becomes the member's open id; the chat's members are added too)
2748
3237
  --chat <id|name> the Feishu chat the bot listens to
2749
- github, feishu set up only one of them (the default is both)
3238
+ github, feishu, gitlab set up only one of them (the default is GitHub and Feishu)
2750
3239
 
2751
3240
  Every command that reads an installation takes the directory that holds ${SETTINGS_FILE}.`;
2752
3241
  async function exists(path) {
@@ -2783,7 +3272,7 @@ async function init(dir) {
2783
3272
  "",
2784
3273
  `State lives in ${settings.stateDir}.`,
2785
3274
  "",
2786
- "Next: set `github.repository` and `github.allowed`, choose `executor.agent`, then run `superagent doctor`.",
3275
+ "Next: set `github.repository` or `gitlab.project`, fill its allowed list, choose `executor.agent`, then run `superagent doctor`.",
2787
3276
  ""
2788
3277
  ].join("\n"));
2789
3278
  return 0;
@@ -2794,7 +3283,7 @@ async function setupSources(dir, rest) {
2794
3283
  const index = rest.indexOf(name);
2795
3284
  return index < 0 ? void 0 : rest[index + 1];
2796
3285
  };
2797
- const targets = rest.filter((item) => item === "github" || item === "feishu");
3286
+ const targets = rest.filter((item) => item === "github" || item === "feishu" || item === "gitlab");
2798
3287
  let settings;
2799
3288
  try {
2800
3289
  settings = await readSettings(join(dir, SETTINGS_FILE));
@@ -2874,6 +3363,7 @@ async function doctor(dir) {
2874
3363
  const chosen = settings.executor.agent;
2875
3364
  lines.push("", `Selected: **${chosen}**${found[chosen] ? "" : " — not installed"}`, "");
2876
3365
  if (settings.github) lines.push(`Repository: \`${settings.github.repository}\`, allowed logins: ${settings.github.allowed.join(", ") || "(none)"}`, "");
3366
+ if (settings.gitlab) lines.push(`GitLab project: \`${settings.gitlab.project}\` on \`${settings.gitlab.host}\`, allowed users: ${settings.gitlab.allowed.join(", ") || "(none)"}`, "");
2877
3367
  const stateFound = await exists(settings.stateDir);
2878
3368
  lines.push(`State directory: \`${settings.stateDir}\`${stateFound ? "" : " — missing, run `superagent init`"}`, "");
2879
3369
  process.stdout.write(lines.join("\n"));
package/lib/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { A as followupOwners, B as ticketOutcome, C as reasonText, D as key, E as ticketStage, F as reached, I as readUntil, L as runningAssignment, M as latestAssignment, N as latestReport, O as USER_ERRORS, P as liveTicket, R as settled, S as REASONS, T as canRetry, V as waitsForPerson, _ as AdmissionDirectionSchema, a as readSettings, b as directionAllowed, c as AGENT_NAMES, d as REPORT_FILE, f as readReport, g as readState, h as FileRepositories, i as parseYaml, j as isoTime, k as UserError, l as installed, n as SettingsSchema, o as stringifyYaml, p as reportInstructions, r as defaultSettings, s as writeSettings, t as SETTINGS_FILE, u as runnerFor, v as RuleAssessmentSchema, w as said, x as Engine, y as RuleMatchSchema, z as threadKey } from "./settings-Dud0f9wo.mjs";
1
+ import { A as followupOwners, B as ticketOutcome, C as reasonText, D as key, E as ticketStage, F as reached, I as readUntil, L as runningAssignment, M as latestAssignment, N as latestReport, O as USER_ERRORS, P as liveTicket, R as settled, S as REASONS, T as canRetry, V as waitsForPerson, _ as AdmissionDirectionSchema, a as readSettings, b as directionAllowed, c as AGENT_NAMES, d as REPORT_FILE, f as readReport, g as readState, h as FileRepositories, i as parseYaml, j as isoTime, k as UserError, l as installed, n as SettingsSchema, o as stringifyYaml, p as reportInstructions, r as defaultSettings, s as writeSettings, t as SETTINGS_FILE, u as runnerFor, v as RuleAssessmentSchema, w as said, x as Engine, y as RuleMatchSchema, z as threadKey } from "./settings-BwRUbWkx.mjs";
2
2
  // src/core/memory.ts
3
3
  /** In-memory repository implementation for testing and ephemeral engine instances. */
4
4
  const clone = (value) => structuredClone(value);
@@ -2623,6 +2623,23 @@ const PrReviewSchema = z.object({
2623
2623
  /** Whether community PRs (from authors not explicitly in allowed list) may be reviewed. */
2624
2624
  allowCommunityPrs: z.boolean().default(true)
2625
2625
  });
2626
+ /** Merge request review on GitLab: the same work as `PrReviewSchema`, with GitLab's squash-instead-of-method. */
2627
+ const MrReviewSchema = z.object({
2628
+ /** Whether autonomous merge request review is enabled. */
2629
+ enabled: z.boolean().default(true),
2630
+ /** When true, actively polls open merge requests in the project. */
2631
+ pollOpenMrs: z.boolean().default(true),
2632
+ /** Commands to run locally inside the worktree to verify the merge request, e.g. ["npm test"]. */
2633
+ verifyCommands: z.array(z.string()).default([]),
2634
+ /** Timeout in seconds for each verify command. Default 300s. */
2635
+ verifyTimeoutSeconds: z.number().int().min(10).max(3600).default(300),
2636
+ /** Whether to merge the merge request if verification and review both pass. */
2637
+ autoMerge: z.boolean().default(false),
2638
+ /** Whether the merge squashes the commits. GitLab applies its project setting when this is false. */
2639
+ squash: z.boolean().default(true),
2640
+ /** Whether merge requests from authors not explicitly in the allowed list may be reviewed. */
2641
+ allowCommunityMrs: z.boolean().default(true)
2642
+ });
2626
2643
  const SettingsSchema = z.object({
2627
2644
  /** Where tickets, triggers and logs live, as an absolute path. */
2628
2645
  stateDir: z.string().min(1),
@@ -2666,6 +2683,21 @@ const SettingsSchema = z.object({
2666
2683
  /** Twitter handles that may trigger tickets; empty accepts any user matching the query. */
2667
2684
  allowed: z.array(z.string()).default([])
2668
2685
  }).optional(),
2686
+ gitlab: z.object({
2687
+ enabled: z.boolean().default(true),
2688
+ /** The instance to talk to: `gitlab.com`, or the host of a self-managed GitLab, optionally with a port. */
2689
+ host: z.string().regex(/^[A-Za-z0-9.-]+(?::\d+)?$/, "expected a host such as gitlab.com or git.example.com:8443").default("gitlab.com"),
2690
+ /** The project to work on, as `group/project`; subgroups are part of the path. */
2691
+ project: z.string().regex(/^[\w.-]+(?:\/[\w.-]+)+$/, "expected group/project"),
2692
+ /** The CLI that acts as the agent's account, such as `glab-agent`. */
2693
+ cli: z.string().default("glab"),
2694
+ /** How often to poll to-do items, in seconds. */
2695
+ pollSeconds: z.number().int().min(15).max(3600).default(60),
2696
+ /** GitLab usernames that may ask for work. Empty accepts nobody. */
2697
+ allowed: z.array(z.string()).default([]),
2698
+ /** Merge request review, checkout, and verification settings. */
2699
+ mrReview: MrReviewSchema.optional()
2700
+ }).optional(),
2669
2701
  executor: ExecutorSchema.optional().transform((value) => ExecutorSchema.parse(value ?? {})),
2670
2702
  policy: PolicySchema.optional().transform((value) => PolicySchema.parse(value ?? {})),
2671
2703
  /** Who assesses a candidate and with what: the `claude` CLI, or a runner named here. */
@@ -2689,6 +2721,12 @@ const SettingsSchema = z.object({
2689
2721
  timers: TimersSchema.optional().transform((value) => TimersSchema.parse(value ?? {})),
2690
2722
  /** Pull-based active watchers for external sources without webhooks. */
2691
2723
  watchers: z.array(WatcherSchema).default([])
2724
+ }).strict().superRefine((settings, context) => {
2725
+ if (settings.github?.enabled && settings.gitlab?.enabled) context.addIssue({
2726
+ code: "custom",
2727
+ path: ["gitlab"],
2728
+ message: "one installation serves one forge: set `github.enabled` or `gitlab.enabled` to false"
2729
+ });
2692
2730
  });
2693
2731
  /** The default an installation starts from, for `superagent init`. */
2694
2732
  function defaultSettings(cwd, home) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "superagent-skill",
3
- "version": "0.4.2",
3
+ "version": "0.5.0",
4
4
  "type": "module",
5
5
  "description": "A headless, file-backed agent that turns requests from GitHub issues, Feishu chats, or Twitter mentions into tickets and runs each ticket on a configurable coding agent: Claude Code, Codex or opencode.",
6
6
  "bin": {
@@ -1,4 +1,4 @@
1
- Describe the change in the pull request, with the checks you ran and any limitation a reviewer should know.
1
+ Describe the change in the request you opened — a pull request or a merge request — with the checks you ran and any limitation a reviewer should know.
2
2
 
3
- If a person's branch or pull request already contains this change, close your pull request with one sentence naming theirs.
3
+ If a person's branch or request already contains this change, close yours with one sentence naming theirs.
4
4
  Do not close it for work that is only related.
@@ -1,5 +1,5 @@
1
- Review the pull request carefully before approving or merging.
2
- Presume community PRs may be authored by unassisted coding agents without human testing.
1
+ Review the request carefully before approving or merging.
2
+ Presume community requests may be authored by unassisted coding agents without human testing.
3
3
  Verify that all unit tests, linters, and builds have succeeded locally in the checked-out worktree.
4
4
  Never merge code that breaks existing tests, introduces security flaws, or degrades maintainability.
5
- If changes are needed, provide constructive, line-specific feedback or close unfixable/spam PRs.
5
+ If changes are needed, provide constructive, line-specific feedback or close unfixable/spam requests.