@catladder/cli 3.15.0 → 3.16.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.
@@ -4,6 +4,7 @@ exports.setupAgents = void 0;
4
4
  const gitlab_1 = require("../../../../../utils/gitlab");
5
5
  const getProjectConfig_1 = require("../../../../../config/getProjectConfig");
6
6
  const gitProjectInformation_1 = require("../../../../../git/gitProjectInformation");
7
+ const git_1 = require("../../../../../git");
7
8
  const listTriggerTokens = async (instance, projectId) => {
8
9
  return await (0, gitlab_1.doGitlabRequest)(instance, `projects/${projectId}/triggers`);
9
10
  };
@@ -25,7 +26,8 @@ const updateWebhook = async (instance, projectId, hookId, webhookData) => {
25
26
  const setupAgentWebhook = async (instance, projectId, agentName, triggerToken) => {
26
27
  const webhookName = `cl_agent_${agentName}_webhook`;
27
28
  const { gitRemoteHost } = await (0, gitProjectInformation_1.getGitRemoteHostAndPath)();
28
- const webhookUrl = `https://${gitRemoteHost}/api/v4/projects/${projectId}/ref/main/trigger/pipeline?token=${triggerToken}`;
29
+ const mainBranch = await (0, git_1.getMainBranch)();
30
+ const webhookUrl = `https://${gitRemoteHost}/api/v4/projects/${projectId}/ref/${mainBranch}/trigger/pipeline?token=${triggerToken}`;
29
31
  instance.log(`Setting up webhook for agent: ${agentName}`);
30
32
  // List existing webhooks
31
33
  const existingWebhooks = await listWebhooks(instance, projectId);
@@ -1 +1 @@
1
- {"version":3,"file":"setupAgents.js","sourceRoot":"","sources":["../../../../../../../../src/apps/cli/commands/project/setup/setupAgents.ts"],"names":[],"mappings":";;;AACA,wDAA8E;AAC9E,6EAA0E;AAC1E,oFAAmF;AAyDnF,MAAM,iBAAiB,GAAG,KAAK,EAC7B,QAAyB,EACzB,SAAiB,EACQ,EAAE;IAC3B,OAAO,MAAM,IAAA,wBAAe,EAAC,QAAQ,EAAE,YAAY,SAAS,WAAW,CAAC,CAAC;AAC3E,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,KA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AAC,8BAA8B,CAAC,CAAC;IAC7C,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IACjB,QAAQ,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IAC1C,QAAQ,CAAC,GAAG,CAAC,+DAA+D,CAAC,CAAC;IAC9E,QAAQ,CAAC,GAAG,CAAC,gDAAgD,CAAC,CAAC;IAC/D,QAAQ,CAAC,GAAG,CACV,6EAA6E,CAC9E,CAAC;IACF,QAAQ,CAAC,GAAG,CACV,oGAAoG,CACrG,CAAC;AACJ,CAAC,CAAC;AA/BW,QAAA,WAAW,eA+BtB"}
1
+ {"version":3,"file":"setupAgents.js","sourceRoot":"","sources":["../../../../../../../../src/apps/cli/commands/project/setup/setupAgents.ts"],"names":[],"mappings":";;;AACA,wDAA8E;AAC9E,6EAA0E;AAC1E,oFAAmF;AACnF,4CAAmD;AAyDnD,MAAM,iBAAiB,GAAG,KAAK,EAC7B,QAAyB,EACzB,SAAiB,EACQ,EAAE;IAC3B,OAAO,MAAM,IAAA,wBAAe,EAAC,QAAQ,EAAE,YAAY,SAAS,WAAW,CAAC,CAAC;AAC3E,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,KAAK,EAC9B,QAAyB,EACzB,SAAiB,EACjB,SAAiB,EACF,EAAE;IACjB,MAAM,IAAA,wBAAe,EACnB,QAAQ,EACR,YAAY,SAAS,aAAa,SAAS,EAAE,EAC7C,SAAS,EACT,QAAQ,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,KAAK,EAC9B,QAAyB,EACzB,SAAiB,EACjB,WAAmB,EACI,EAAE;IACzB,OAAO,MAAM,IAAA,wBAAe,EAC1B,QAAQ,EACR,YAAY,SAAS,WAAW,EAChC,EAAE,WAAW,EAAE,EACf,MAAM,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,YAAY,GAAG,KAAK,EACxB,QAAyB,EACzB,SAAiB,EACG,EAAE;IACtB,OAAO,MAAM,I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: () => Promise<string>;
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getMainBranch = void 0;
4
+ const child_process_promise_1 = require("child-process-promise");
5
+ const getMainBranch = async () => {
6
+ const { stdout } = await (0, child_process_promise_1.exec)("git rev-parse --abbrev-ref HEAD");
7
+ return stdout.trim();
8
+ };
9
+ exports.getMainBranch = getMainBranch;
10
+ //# sourceMappingURL=getGetMainBranch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"getGetMainBranch.js","sourceRoot":"","sources":["../../../../src/git/getGetMainBranch.ts"],"names":[],"mappings":";;;AAAA,iEAA6C;AACtC,MAAM,aAAa,GAAG,KAAK,IAAI,EAAE;IACtC,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,4BAAI,EAAC,iCAAiC,CAAC,CAAC;IACjE,OAAO,MAAM,CAAC,IAAI,EAAE,CAAC;AACvB,CAAC,CAAC;AAHW,QAAA,aAAa,iBAGxB"}
@@ -1,2 +1,3 @@
1
1
  export * from "./gitConfig";
2
2
  export * from "./gitProjectInformation";
3
+ export * from "./getGetMainBranch";
@@ -16,4 +16,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./gitConfig"), exports);
18
18
  __exportStar(require("./gitProjectInformation"), exports);
19
+ __exportStar(require("./getGetMainBranch"), exports);
19
20
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/git/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,0DAAwC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/git/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,0DAAwC;AACxC,qDAAmC"}
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
- // prompts.ts — MCP-only, DRY, review-first-then-push, CI logic, self-mention guard,
3
- // event prompt supports review-on-demand via manual "agent-review" job or fallback MR review.
4
- // Prevents double-runs: event-triggered work cancels any running "agent-review" job on the same MR.
2
+ // prompts.ts — MCP-only, DRY, review-first-then-push, CI diagnosis (no retries), self-mention guard,
3
+ // conversations-aware: always read the thread first (issues & MRs), reply inline, avoid duplicates.
4
+ // Prevents double-runs: event-triggered work cancels any running "agent-review" job on the MR's own pipeline.
5
5
  Object.defineProperty(exports, "__esModule", { value: true });
6
6
  exports.getMergeRequestPrompt = exports.getEventPrompt = void 0;
7
7
  /* ---------- Shared blocks ---------- */
@@ -24,6 +24,30 @@ const goldenRules = ({ agentUserName }) => `
24
24
  - Keep actions minimal and idempotent. Avoid duplicate comments or duplicate MRs.
25
25
  - Use ONE stable \`source_branch\` per run; do not regenerate its name later.
26
26
  `;
27
+ /* ---------- NEW: conversation intake + threading rules ---------- */
28
+ const conversationsIntake = ({ agentUserName }) => `
29
+ ## Conversations Intake & Threading (MANDATORY before acting)
30
+ Always load and reason about the current conversation to avoid duplicates and to respond in the right place.
31
+
32
+ ### What to fetch
33
+ - **MRs**: Use \`mr_discussions({ projectId: $CI_PROJECT_ID, mergeRequestIid })\` to load all threads and notes.
34
+ - **Issues**: If an issue-discussions/listing tool exists, use it. If not available in \`gitlab-mcp\`, rely on the **event payload** and **your last note ids** if present; otherwise post a single concise note acknowledging the limitation and proceed.
35
+
36
+ ### How to use it
37
+ 1) **Detect review/answer context**:
38
+ - Identify the **latest human note** in the thread (exclude notes authored by "${agentUserName}").
39
+ - If the latest human note **replies to you** (mentions you or is in a discussion you started), reply **in the same discussion**.
40
+ 2) **De-duplication**:
41
+ - If your most recent message is the **last message overall** and **no one else replied** since, prefer **updating your last note** instead of posting a new one:
42
+ - Use \`update_merge_request_note\` or \`update_issue_note\` accordingly.
43
+ 3) **Reply placement**:
44
+ - For MR code discussions: reply **inline in the same discussion** (preserve thread context).
45
+ - For general/MR overview threads: add a single consolidated reply (avoid multiple scattered notes).
46
+ 4) **Sanitize before write**:
47
+ - Apply the Self-mention Guard, then post.
48
+ 5) **If conversations list is unavailable**:
49
+ - Post one short note: that you cannot fetch the full conversation due to missing MCP capability, then proceed minimally (no spam).
50
+ `;
27
51
  const selfMentionGuard = ({ agentUserName }) => `
28
52
  ## Self-mention Guard (mandatory preflight for ALL writes)
29
53
  Before ANY call that writes text (comment/create/update MR/issue/commit message), sanitize the text:
@@ -64,11 +88,11 @@ const mcpOnly = () => `
64
88
  - list_issues({ projectId, state?: "opened"|"closed", scope?: "all"|... })
65
89
 
66
90
  - **Branch & Files**
67
- - create_branch({ projectId, branchName, ref }) // ref = default branch or SHA
91
+ - create_branch({ projectId, branchName, ref })
68
92
  - push_files({ projectId, branch, commitMessage, files: [{ filePath, content }] })
69
93
  - create_or_update_file({ projectId, branch, filePath, content, commitMessage })
70
94
  - get_file_contents({ projectId, ref, path })
71
- - get_branch_diffs({ projectId, from, to }) // compare refs
95
+ - get_branch_diffs({ projectId, from, to })
72
96
 
73
97
  - **Merge Requests**
74
98
  - create_merge_request({ projectId, sourceBranch, targetBranch, title, description, assigneeUsernames?: string[] })
@@ -79,10 +103,10 @@ const mcpOnly = () => `
79
103
  - merge_merge_request(...) // **Do NOT use** (never merge)
80
104
 
81
105
  - **Pipelines / Jobs** (requires env USE_PIPELINE=true)
106
+ - list_pipelines({ projectId, ref?, sha?, status?, orderBy?, sort? })
107
+ - get_pipeline({ projectId, pipelineId })
82
108
  - list_pipeline_jobs({ projectId, pipelineId })
83
109
  - get_pipeline_job_output({ projectId, pipelineId, jobId })
84
- - retry_pipeline({ projectId, pipelineId })
85
- - retry_pipeline_job({ projectId, jobId })
86
110
  - play_pipeline_job({ projectId, jobId })
87
111
  - cancel_pipeline_job({ projectId, jobId })
88
112
  `;
@@ -103,43 +127,48 @@ From \`event_json\`, extract:
103
127
  - note_id if present (\`#note_<id>\`)
104
128
  - description/body text, state, author \`user_username\`, timestamps
105
129
  - project id/path; detect default branch via \`get_merge_request\`/context as needed
106
-
107
- If any key is missing, choose the safest minimal action or briefly explain via a comment.
130
+ - If available: the discussion id / thread context of the note to enable inline replies.
131
+ `;
132
+ /* Helper used by Single-Runner Guard and Review-on-Demand to find the MR’s own pipeline */
133
+ const resolveMrPipeline = () => `
134
+ ## Resolve MR Pipeline (for MR IID resolved from the event)
135
+ Given \`mr_iid\`:
136
+ 1) Call \`get_merge_request({ projectId: $CI_PROJECT_ID, mergeRequestIid: mr_iid })\` to obtain:
137
+ - \`sourceBranch\` (required)
138
+ - \`sha\` or head SHA (if available)
139
+ 2) Prefer **SHA-based** lookup:
140
+ - \`list_pipelines({ projectId: $CI_PROJECT_ID, sha })\` ordered by most recent; pick the newest.
141
+ 3) Fallback to **ref-based** lookup if SHA not available:
142
+ - \`list_pipelines({ projectId: $CI_PROJECT_ID, ref: sourceBranch, orderBy: "updated_at", sort: "desc" })\`; pick the newest.
143
+ 4) The chosen pipeline becomes \`mr_pipeline_id\`. Use it for all job queries/plays/cancels related to this MR.
144
+ - If no pipeline is found, post a short MR note explaining that no pipeline was located for the current MR head and proceed with review actions without CI job control.
108
145
  `;
109
- // NEW: Single-runner guard (event-triggered → existing MR)
110
146
  const singleRunnerGuard = () => `
111
147
  ## Single-Runner Guard (event-triggered work on an existing MR)
112
148
  Before entering MR Review Mode from an event:
113
149
 
114
- - **Goal:** Avoid two agents working the same MR. If a **running or pending** CI job whose name **ends with "agent-review"** is active for this MR, **cancel** it first.
115
-
116
- **Best-effort procedure (MCP-only):**
117
- 1) If \`$CI_PIPELINE_ID\` is available (this event is executing inside a CI context for the same MR):
118
- - Call \`list_pipeline_jobs({ projectId: $CI_PROJECT_ID, pipelineId: $CI_PIPELINE_ID })\`.
119
- - Identify any job where \`status\` is \`"running"\` or \`"pending"\` **and** \`name\` **endsWith** \`"agent-review"\`.
120
- - For each match, call \`cancel_pipeline_job({ projectId: $CI_PROJECT_ID, jobId })\`.
121
- - Proceed with review immediately after issuing cancellations (do not wait).
150
+ - **Goal:** Avoid two agents working the same MR. If a **running or pending** CI job whose name **ends with "agent-review"** is active for this MR's pipeline, **cancel** it first.
122
151
 
123
- 2) If \`$CI_PIPELINE_ID\` is **not** available, or jobs for this MR cannot be listed with available MCP calls:
124
- - Post a short MR note stating you are proceeding but **cannot verify/cancel** a running \`agent-review\` job due to missing capabilities.
152
+ **Procedure (MCP-only):**
153
+ 1) Resolve the MR IID from the event (target URL or text) and run **Resolve MR Pipeline** to get \`mr_pipeline_id\`.
154
+ 2) If \`mr_pipeline_id\` is available:
155
+ - \`list_pipeline_jobs({ projectId: $CI_PROJECT_ID, pipelineId: mr_pipeline_id })\`.
156
+ - For any job with \`status\` in \`["running","pending"]\` and \`name\` ending with \`"agent-review"\`, call:
157
+ - \`cancel_pipeline_job({ projectId: $CI_PROJECT_ID, jobId })\`.
158
+ - Proceed immediately after issuing cancellations (do not wait).
159
+ 3) If the pipeline cannot be resolved:
160
+ - Post a short MR note stating you are proceeding but **cannot verify/cancel** a running \`agent-review\` job due to missing pipeline context.
125
161
  - Proceed with review.
126
162
 
127
163
  **Notes:**
128
164
  - Keep this guard **idempotent** (safe to run multiple times).
129
- - This guard only applies to **event-triggered** flows that decide to act on an **existing MR**.
165
+ - Only applies to **event-triggered** flows that act on an **existing MR**.
130
166
  `;
131
167
  const reviewOnDemandFromEvents = () => `
132
168
  ## Review-on-Demand (from events)
133
169
  If the issue/note text **asks for a review** (case-insensitive tokens like: "review", "please review", "PTAL", "needs review", "can you look at", "LGTM?"), then:
134
170
 
135
- 1) **Check for pipeline review job**
136
- - List jobs for the current pipeline \`$CI_PIPELINE_ID\` via \`list_pipeline_jobs\`.
137
- - If any job has \`status = "manual"\` **and** its \`name\` ends with "agent-review":
138
- - Trigger it via \`play_pipeline_job({ projectId: $CI_PROJECT_ID, jobId })\`.
139
- - Post a short comment confirming you triggered the review job (sanitize).
140
- - **Stop** further review actions.
141
-
142
- 2) **If no such job exists, resolve which MR to review**:
171
+ 1) **Resolve which MR to review**:
143
172
  - If the event target is an MR → use its \`iid\`.
144
173
  - Else, parse the text for MR references in order:
145
174
  - \`!<iid>\` (e.g., \`!123\`)
@@ -147,32 +176,47 @@ If the issue/note text **asks for a review** (case-insensitive tokens like: "rev
147
176
  - full GitLab MR URL
148
177
  - If no MR can be resolved, reply with a brief comment asking the user to reference an MR (sanitize) and **stop**.
149
178
 
150
- 3) **Single-Runner Guard (cancel any running "agent-review" job)** // NEW: Single-runner guard
151
- - Execute the **Single-Runner Guard** steps above **before** MR Review Mode.
179
+ 2) **Find the MR's pipeline** (do **not** use \`$CI_PIPELINE_ID\` from the event):
180
+ - Execute **Resolve MR Pipeline** to obtain \`mr_pipeline_id\`.
181
+
182
+ 3) **If a manual "agent-review" job exists on the MR pipeline, trigger it**
183
+ - If \`mr_pipeline_id\` is available:
184
+ - \`list_pipeline_jobs({ projectId: $CI_PROJECT_ID, pipelineId: mr_pipeline_id })\`.
185
+ - If any job has \`status = "manual"\` **and** its \`name\` ends with "agent-review":
186
+ - Trigger via \`play_pipeline_job({ projectId: $CI_PROJECT_ID, jobId })\`.
187
+ - **Conversations Intake**: run the section above to determine **where** to post the confirmation (prefer replying in the same thread that requested review).
188
+ - Post a short comment confirming you triggered the review job (sanitize).
189
+ - **Stop** further review actions.
190
+
191
+ 4) **Single-Runner Guard**
192
+ - If no manual job was triggered, execute the **Single-Runner Guard** (it will cancel any running/pending \`agent-review\` jobs on the MR pipeline) before MR Review Mode.
152
193
 
153
- 4) **Enter MR Review Mode**: execute the **MR Review Bundle** below with the resolved \`mr_iid\`.
194
+ 5) **Enter MR Review Mode**: execute the **MR Review Bundle** below with the resolved \`mr_iid\`.
154
195
  `;
155
196
  /** Regular event workflow for non-review work */
156
197
  const eventWorkflow = ({ agentUserName }) => `
157
198
  ## High-Reliability Workflow (sequence + postconditions)
158
199
  Follow this order for any change work:
159
200
 
201
+ 0) **Conversations Intake (MANDATORY)**:
202
+ - For MR targets: call \`mr_discussions\` and apply the rules in **Conversations Intake & Threading**.
203
+ - For issue targets: attempt to load notes if supported; otherwise rely on event context and post one concise note acknowledging the limitation.
204
+
160
205
  1) **Acknowledge** with a short comment on the issue/MR thread (\`create_note\`), **unless the last actor is you**.
161
206
  2) **Discover default branch** (e.g., "main") — infer from repo/MR context if needed.
162
207
  3) **Create a working branch** from default (stable name, e.g., \`fix/issue-<iid>-<slug>\` or \`feat/issue-<iid>-<slug>\`) via \`create_branch\`.
163
208
  4) **Write changes → commit → push to remote branch** via \`push_files\` (or \`create_or_update_file\`).
164
209
  5) **Verify push landed**:
165
- - Fetch latest state (optional: \`get_file_contents\`/log) and capture a short SHA from the branch head if exposed by the host.
166
- - Compare default vs \`source_branch\` via \`get_branch_diffs({ from: "<default>", to: "<source>" })\` and ensure there are diffs.
210
+ - Fetch latest state and ensure diffs via \`get_branch_diffs({ from: "<default>", to: "<source>" })\`.
167
211
  6) **Create or update MR** ONLY if there is a non-empty diff via \`create_merge_request\`.
168
212
  - Include \`Closes #<issue_iid>\` in MR description when applicable.
169
213
  - **Assign the MR to yourself**: \`assigneeUsernames: ["${agentUserName}"]\`.
170
- 7) **Follow-up comment** with branch name, any commit short SHA you can obtain, files changed count (approx by diffs), and MR link via \`create_note\`, **unless the last actor is you**.
214
+ 7) **Follow-up comment** with branch name, any commit short SHA you can obtain, files changed count (approx by diffs), and MR link via \`create_note\`, **unless the last actor is you**. Place this **in the relevant conversation thread** (see Intake rules).
171
215
  8) **If verification fails**:
172
216
  - Do NOT create the MR.
173
217
  - Comment the exact failure and retry once with a fresh branch name. If still failing, comment and stop.
174
218
 
175
- For Q&A-only (no code changes), just post a concise, helpful answer on the same issue/MR (sanitize first).
219
+ For Q&A-only (no code changes), run **Conversations Intake** first, then post a single concise, helpful answer **in the correct thread** (sanitize).
176
220
  `;
177
221
  /* ---------- MR-review specific (shared with both prompts) ---------- */
178
222
  const mrScope = ({ agentUserName }) => `
@@ -189,7 +233,7 @@ Follow this sequence with verification at each step:
189
233
  1) **Collect context**
190
234
  - Get MR metadata via \`get_merge_request({ projectId: $CI_PROJECT_ID, mergeRequestIid })\`.
191
235
  - Fetch the full changeset/diffs via \`get_merge_request_diffs\` (or \`list_merge_request_diffs\`) and open discussions via \`mr_discussions\`.
192
- - Read existing notes to avoid duplication.
236
+ - **Conversations Intake**: analyze discussions to find latest human notes, detect replies to the agent, and decide between inline reply vs updating your prior note.
193
237
 
194
238
  2) **Code review**
195
239
  - Identify required changes (bugs, tests, style, security, perf, docs).
@@ -203,33 +247,24 @@ Follow this sequence with verification at each step:
203
247
  - Apply minimal, safe changes; keep commits small and clear.
204
248
  - **Push** to the MR's **source branch** via \`push_files\` (or \`create_or_update_file\`).
205
249
  - **Verify push landed** using \`get_branch_diffs({ from: "<target_branch>", to: "<source_branch>" })\` and ensure there are diffs.
206
- - Post a follow-up MR note summarizing what changed and why (sanitize).
250
+ - Post a follow-up MR note summarizing what changed and why, **in the appropriate thread** (sanitize).
207
251
  `;
208
252
  const ciInspection = () => `
209
- 4) **CI jobs (current pipeline focus: diagnose first, retry only when useful)**
210
- - Inspect jobs for the **current pipeline**: \`$CI_PIPELINE_ID\` via \`list_pipeline_jobs\`.
211
- - Consider **only** jobs with \`status = "failed"\` and \`allow_failure = false\`.
212
- - For each such job:
213
- 1. Retrieve details (id, name, stage, status, allow_failure, web_url).
214
- 2. Fetch job output via \`get_pipeline_job_output({ projectId: $CI_PROJECT_ID, pipelineId: $CI_PIPELINE_ID, jobId })\`.
215
- 3. **Classify the failure**:
216
- - **Code-related (do not retry):** compiler/type/lint/test/build script errors.
217
- - **Likely transient (may retry):** network/timeouts/infra/cache/artifacts/5xx/429/etc.
218
- 4. **Decision**:
219
- - If \`will_push_changes = true\`:
220
- - **Do not retry** current pipeline (upcoming push will trigger a new one).
221
- - Post an MR note: brief diagnosis per failed job; note a new pipeline will validate the fix (sanitize).
222
- - If \`will_push_changes = false\`:
223
- - If transient \`retry_pipeline_job({ projectId: $CI_PROJECT_ID, jobId })\` (or \`retry_pipeline\` if job-level retry not available).
224
- Post a note stating you retried and why (sanitize).
225
- - If code-related ⇒ do not retry; post a note with diagnosis and suggested fix (sanitize).
226
- - Retry-once policy: at most **one** retry per job in this run.
227
-
228
- 5) **Assign human reviewer if ready**
229
- - If discussions are resolved and blocking CI issues are addressed or clearly triaged, request review from a recent active human contributor (not you), if supported by your environment.
230
-
231
- 6) **Stdout summary**
232
- - Print concise summary: branch used, files changed count (approx by diffs), discussions resolved/left, **blocking failed jobs (names + stages)** with classification (code vs transient), which jobs were retried (if any), and requested reviewers.
253
+ 4) **CI jobs (diagnose only; no job retries)**
254
+ - Prefer the **MR pipeline** (not the event pipeline).
255
+ - If you have \`mr_pipeline_id\` (from **Resolve MR Pipeline**):
256
+ - \`list_pipeline_jobs({ projectId: $CI_PROJECT_ID, pipelineId: mr_pipeline_id })\`.
257
+ - Consider **only** jobs with \`status = "failed"\` and \`allow_failure = false\`.
258
+ - For each such job:
259
+ 1. Retrieve details (id, name, stage, status, allow_failure, web_url).
260
+ 2. Fetch job output via \`get_pipeline_job_output({ projectId: $CI_PROJECT_ID, pipelineId: mr_pipeline_id, jobId })\`.
261
+ 3. **Classify the failure**:
262
+ - **Code-related:** compiler/type/lint/test/build script errors. Provide minimal fix in your review/changes. Do **not** retry.
263
+ - **Likely transient / infra:** network/timeouts/cache/artifacts/5xx/429/runner issues. Do **not** retry here; note likely cause and suggest CI-level retry/backoff if appropriate.
264
+ 4. **Decision**:
265
+ - If \`will_push_changes = true\`: do **not** retry; note that the new pipeline from your push will validate fixes.
266
+ - If \`will_push_changes = false\`: do **not** retry; post diagnosis and next steps (or request human input for infra issues).
267
+ - If \`mr_pipeline_id\` is not available, you may skip CI analysis or post a short note explaining the missing pipeline context.
233
268
  `;
234
269
  const outputDisciplineMR = ({ agentUserName }) => `
235
270
  ## Output Discipline (MR)
@@ -258,10 +293,12 @@ $(cat $TRIGGER_PAYLOAD)
258
293
  ${identity(ctx)}
259
294
  ${goldenRules(ctx)}
260
295
  ${selfMentionGuard(ctx)}
296
+ ${conversationsIntake(ctx)} <!-- NEW: mandatory before acting -->
261
297
  ${eventSelfParse()}
262
- ${singleRunnerGuard()} <!-- NEW: included so the agent can run it when acting on an existing MR -->
298
+ ${resolveMrPipeline()} <!-- used by review/cancel paths -->
299
+ ${singleRunnerGuard()} <!-- operates on MR pipeline, not event pipeline -->
263
300
  ${reviewOnDemandFromEvents()}
264
- ${mrReviewBundle(ctx)} <!-- Included so the agent can execute it when review intent is true -->
301
+ ${mrReviewBundle(ctx)} <!-- agent can execute when review intent is true -->
265
302
  ${eventWorkflow(ctx)}
266
303
  ${commentGuidelines()}
267
304
  ${mcpOnly()}
@@ -281,6 +318,7 @@ description: $CI_MERGE_REQUEST_DESCRIPTION
281
318
  ${mrScope(ctx)}
282
319
  ${goldenRules(ctx)}
283
320
  ${selfMentionGuard(ctx)}
321
+ ${conversationsIntake(ctx)} <!-- NEW: always read MR discussions -->
284
322
  ${mrWorkflow()}
285
323
  ${ciInspection()}
286
324
  ${commentGuidelines()}
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../../../../pipeline/src/pipeline/agent/prompts.ts"],"names":[],"mappings":";AAAA,oFAAoF;AACpF,8FAA8F;AAC9F,oGAAoG;;;AAIpG,yCAAyC;AAEzC,MAAM,MAAM,GAAG,GAAG,EAAE,CAAC;;;CAGpB,CAAC;AAEF,MAAM,QAAQ,GAAG,CAAC,EAAE,aAAa,EAAO,EAAE,EAAE,CAAC;;6BAEhB,aAAa;CACzC,CAAC;AAEF,MAAM,WAAW,GAAG,CAAC,EAAE,aAAa,EAAO,EAAE,EAAE,CAAC;;;;8BAIlB,aAAa;;;;;;CAM1C,CAAC;AAEF,MAAM,gBAAgB,GAAG,CAAC,EAAE,aAAa,EAAO,EAAE,EAAE,CAAC;;;;;qCAKhB,aAAa;;;;;;yDAMO,aAAa;;CAErE,CAAC;AAEF,MAAM,iBAAiB,GAAG,GAAG,EAAE,CAAC;;;;;;;;CAQ/B,CAAC;AAEF,8EAA8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Ac,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC;;;EAGnC,OAAO,CAAC,GAAG,CAAC;EACZ,UAAU,EAAE;EACZ,YAAY,EAAE;CACf,CAAC;AAEF,2CAA2C;AAEpC,MAAM,cAAc,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC;;;EAG1C,MAAM,EAAE;;;;;;EAMR,QAAQ,CAAC,GAAG,CAAC;EACb,WAAW,CAAC,GAAG,CAAC;EAChB,gBAAgB,CAAC,GAAG,CAAC;EACrB,mBAAmB,CAAC,GAAG,CAAC;EACxB,cAAc,EAAE;EAChB,iBAAiB,EAAE;EACnB,iBAAiB,EAAE;EACnB,wBAAwB,EAAE;EAC1B,cAAc,CAAC,GAAG,CAAC;EACnB,aAAa,CAAC,GAAG,CAAC;EAClB,iBAAiB,EAAE;EACnB,OAAO,EAAE;EACT,gBAAgB,CAAC,GAAG,CAAC;CACtB,CAAC;AAtBW,QAAA,cAAc,kBAsBzB;AAEK,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAE,EAAE,CAAC;;;EAGjD,MAAM,EAAE;;;;;;;EAOR,OAAO,CAAC,GAAG,CAAC;EACZ,WAAW,CAAC,GAAG,CAAC;EAChB,gBAAgB,CAAC,GAAG,CAAC;EACrB,mBAAmB,CAAC,GAAG,CAAC;EACxB,UAAU,EAAE;EACZ,YAAY,EAAE;EACd,iBAAiB,EAAE;EACnB,OAAO,EAAE;EACT,kBAAkB,CAAC,GAAG,CAAC;CACxB,CAAC;AAnBW,QAAA,qBAAqB,yBAmBhC"}
@@ -2,10 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.callClaude = exports.baseSetupScript = exports.createBaseAgentJob = void 0;
4
4
  const bashEscape_1 = require("../../bash/bashEscape");
5
+ const runner_1 = require("../../runner");
5
6
  const createBaseAgentJob = (context) => ({
6
7
  stage: "agents",
7
8
  envMode: "none",
8
- image: "node:24-alpine3.21",
9
+ // image: "node:24-alpine3.21",
10
+ image: (0, runner_1.getRunnerImage)("agent-claude"),
9
11
  variables: {
10
12
  MAX_MCP_OUTPUT_TOKENS: "75000",
11
13
  GITLAB_PERSONAL_ACCESS_TOKEN: "$AGENT_GITLAB_PERSONAL_ACCESS_TOKEN", // TODO: we don't have global secret keys to configure yet
@@ -14,9 +16,10 @@ const createBaseAgentJob = (context) => ({
14
16
  });
15
17
  exports.createBaseAgentJob = createBaseAgentJob;
16
18
  exports.baseSetupScript = [
17
- "apk update",
18
- "apk add --no-cache git curl bash",
19
- "npm install -g @anthropic-ai/claude-code",
19
+ // these are done in the image already
20
+ // "apk update",
21
+ // "apk add --no-cache git curl bash",
22
+ //"npm install -g @anthropic-ai/claude-code",
20
23
  "claude mcp add gitlab --env GITLAB_PERSONAL_ACCESS_TOKEN=$GITLAB_PERSONAL_ACCESS_TOKEN --env GITLAB_API_URL=$GITLAB_API_URL --env USE_PIPELINE='true' -- npx -y @zereight/mcp-gitlab",
21
24
  ];
22
25
  const callClaude = ({ prompt }) => {
@@ -1 +1 @@
1
- {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../../pipeline/src/pipeline/agent/shared.ts"],"names":[],"mappings":";;;AAAA,sDAI+B;AAGxB,MAAM,kBAAkB,GAAG,CAChC,OAAqB,EAC4B,EAAE,CAAC,CAAC;IACrD,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,MAAM;IACf,KAAK,EAAE,oBAAoB;IAC3B,SAAS,EAAE;QACT,qBAAqB,EAAE,OAAO;QAC9B,4BAA4B,EAAE,qCAAqC,EAAE,0DAA0D;QAC/H,cAAc,EAAE,gBAAgB;KACjC;CACF,CAAC,CAAC;AAXU,QAAA,kBAAkB,sBAW5B;AAEU,QAAA,eAAe,GAAG;IAC7B,YAAY;IACZ,kCAAkC;IAClC,0CAA0C;IAC1C,sLAAsL;CACvL,CAAC;AAEK,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAsB,EAAE,EAAE;IAC3D,OAAO;QACL,kBAAkB,IAAA,2BAAc,EAC9B,IAAA,+BAAkB,EAAC,IAAA,4BAAe,EAAC,MAAM,CAAC,CAAC,CAC5C,GAAG;QACJ,mBAAmB;QACnB,wJAAwJ;KACzJ,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,UAAU,cAQrB"}
1
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../../pipeline/src/pipeline/agent/shared.ts"],"names":[],"mappings":";;;AAAA,sDAI+B;AAC/B,yCAA8C;AAGvC,MAAM,kBAAkB,GAAG,CAChC,OAAqB,EAC4B,EAAE,CAAC,CAAC;IACrD,KAAK,EAAE,QAAQ;IACf,OAAO,EAAE,MAAM;IACf,+BAA+B;IAC/B,KAAK,EAAE,IAAA,uBAAc,EAAC,cAAc,CAAC;IACrC,SAAS,EAAE;QACT,qBAAqB,EAAE,OAAO;QAC9B,4BAA4B,EAAE,qCAAqC,EAAE,0DAA0D;QAC/H,cAAc,EAAE,gBAAgB;KACjC;CACF,CAAC,CAAC;AAZU,QAAA,kBAAkB,sBAY5B;AAEU,QAAA,eAAe,GAAG;IAC7B,sCAAsC;IACtC,gBAAgB;IAChB,sCAAsC;IACtC,6CAA6C;IAC7C,sLAAsL;CACvL,CAAC;AAEK,MAAM,UAAU,GAAG,CAAC,EAAE,MAAM,EAAsB,EAAE,EAAE;IAC3D,OAAO;QACL,kBAAkB,IAAA,2BAAc,EAC9B,IAAA,+BAAkB,EAAC,IAAA,4BAAe,EAAC,MAAM,CAAC,CAAC,CAC5C,GAAG;QACJ,mBAAmB;QACnB,wJAAwJ;KACzJ,CAAC;AACJ,CAAC,CAAC;AARW,QAAA,UAAU,cAQrB"}
@@ -1,2 +1,2 @@
1
- export type RunnerImageName = "jobs-default" | "jobs-meteor" | "jobs-testing-chrome" | "kubernetes" | "docker-build" | "gcloud" | "semantic-release";
1
+ export type RunnerImageName = "jobs-default" | "jobs-meteor" | "jobs-testing-chrome" | "kubernetes" | "docker-build" | "gcloud" | "semantic-release" | "agent-claude";
2
2
  export declare const getRunnerImage: (imageName: RunnerImageName) => string;
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../pipeline/src/runner/index.ts"],"names":[],"mappings":";;;AAAA,4CAAmE;AAU5D,MAAM,cAAc,GAAG,CAAC,SAA0B,EAAE,EAAE,CAC3D,2BAAe,GAAG,GAAG,GAAG,SAAS,GAAG,GAAG,GAAG,8BAAkB,CAAC;AADlD,QAAA,cAAc,kBACoC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../pipeline/src/runner/index.ts"],"names":[],"mappings":";;;AAAA,4CAAmE;AAW5D,MAAM,cAAc,GAAG,CAAC,SAA0B,EAAE,EAAE,CAC3D,2BAAe,GAAG,GAAG,GAAG,SAAS,GAAG,GAAG,GAAG,8BAAkB,CAAC;AADlD,QAAA,cAAc,kBACoC"}