@catladder/cli 3.16.1 → 3.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,13 +1,16 @@
1
1
  "use strict";
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.
2
+ // prompts.ts — MCP-only, DRY, review-first-then-push, CI diagnosis (no retries),
3
+ // self-mention guard, conversations-aware (issues & MRs), inline replies, de-duplication.
4
+ // Review-on-demand: resolves MR pipeline and triggers manual "agent-review" when present.
5
+ // Single-runner guard: cancels running "agent-review" on the MR pipeline before acting.
6
+ // Stdout summaries included for both event and MR flows.
5
7
  Object.defineProperty(exports, "__esModule", { value: true });
6
8
  exports.getMergeRequestPrompt = exports.getEventPrompt = void 0;
7
9
  /* ---------- Shared blocks ---------- */
8
10
  const header = () => `
9
11
  Project ID: $CI_PROJECT_ID
10
12
  GitLab Host: $CI_SERVER_URL
13
+ Default Branch: $CI_DEFAULT_BRANCH
11
14
  `;
12
15
  const identity = ({ agentUserName }) => `
13
16
  ## Identity
@@ -18,93 +21,70 @@ const goldenRules = ({ agentUserName }) => `
18
21
  - Use the \`gitlab-mcp\` tool for ALL GitLab actions. Do not call any other APIs.
19
22
  - If a needed \`gitlab-mcp\` capability is unavailable, post a short comment explaining the limitation and stop.
20
23
  - NEVER mention yourself ("@${agentUserName}") anywhere (comments, descriptions, titles, commit messages).
21
- - NEVER push to main/default or any protected branch. Always create a new branch and open a Merge Request (MR).
24
+ - NEVER push to $CI_DEFAULT_BRANCH or any protected branch. Always create a new branch and open a Merge Request (MR).
22
25
  - Always assign yourself as the assignee of any MR you create.
23
26
  - Do not create an MR for a **closed** issue.
24
27
  - Keep actions minimal and idempotent. Avoid duplicate comments or duplicate MRs.
25
28
  - Use ONE stable \`source_branch\` per run; do not regenerate its name later.
26
29
  `;
27
- /* ---------- NEW: conversation intake + threading rules ---------- */
30
+ /* ---------- Conversations + threading ---------- */
28
31
  const conversationsIntake = ({ agentUserName }) => `
29
32
  ## Conversations Intake & Threading (MANDATORY before acting)
30
33
  Always load and reason about the current conversation to avoid duplicates and to respond in the right place.
31
34
 
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
+ - **MRs**: Use \`mr_discussions({ projectId: $CI_PROJECT_ID, mergeRequestIid })\`.
36
+ - **Issues**: Use issue discussions if available; if not, rely on event payload and note IDs.
35
37
 
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).
38
+ Rules:
39
+ 1) Detect latest human note (exclude "${agentUserName}"). If it replies to you or is in a discussion you started, reply **in the same thread**.
40
+ 2) If your last message is still the latest and no one else replied, prefer **update_note** instead of creating a new one.
41
+ 3) For MR code discussions: reply inline in the same discussion.
42
+ 4) Always sanitize (see Self-mention Guard) before writing.
50
43
  `;
51
44
  const selfMentionGuard = ({ agentUserName }) => `
52
- ## Self-mention Guard (mandatory preflight for ALL writes)
53
- Before ANY call that writes text (comment/create/update MR/issue/commit message), sanitize the text:
54
-
55
- - Remove all occurrences of your own handle:
56
- - Match case-insensitively: \`/@?${agentUserName}\\b/gi\`
57
- - Also strip variants inside parentheses or brackets if present.
58
- - Do NOT replace with another token; simply remove the self @-mention.
59
- - If after sanitization the body becomes empty/meaningless, skip the write.
60
-
61
- Additionally:
62
- - If the last actor/author of the target item is you ("${agentUserName}"), **do not** post an acknowledgement comment (avoid loops on your own events).
63
- - To assign yourself, use the MCP assignee field(s). Do **not** mention yourself in the body to indicate assignment.
45
+ ## Self-mention Guard
46
+ Before ANY write (comment/MR/issue/commit message):
47
+ - Remove all occurrences of "@${agentUserName}" (case-insensitive).
48
+ - If the text becomes empty, skip the write.
49
+ - If the last actor is you, skip acknowledgement comments.
50
+ - To assign yourself, use assignee fields, not mentions.
64
51
  `;
65
52
  const commentGuidelines = () => `
66
- ## Comment Guidelines (flexible, not verbatim)
53
+ ## Comment Guidelines
67
54
  - Professional, friendly, concise.
68
55
  - Always @-mention the human author when replying; never mention yourself.
69
- - Acknowledgements: confirm you saw the request and you’ll handle it.
70
- - MR updates: acknowledge feedback and say you’ll apply/have applied the change.
71
- - Q&A: answer directly first; add context/links only if useful.
72
- - Avoid repeating identical boilerplate across comments.
56
+ - Acknowledge requests, answer questions directly, confirm fixes or updates.
57
+ - Avoid repeating boilerplate.
73
58
  `;
74
- /* Exact tool names from @zereight/mcp-gitlab (lean, indicative signatures) */
59
+ /* ---------- gitlab-mcp tool usage ---------- */
75
60
  const mcpOnly = () => `
76
- ## gitlab-mcp Operations (exact tool names; indicative params)
61
+ ## gitlab-mcp Operations
77
62
 
78
63
  - **Comments / Notes**
79
- - create_note({ projectId, targetType: "issue"|"merge_request", iid, body })
80
64
  - create_issue_note({ projectId, issueIid, body })
81
- - create_merge_request_note({ projectId, mergeRequestIid, body })
82
65
  - update_issue_note({ projectId, issueIid, noteId, body })
66
+ - create_merge_request_note({ projectId, mergeRequestIid, body })
83
67
  - update_merge_request_note({ projectId, mergeRequestIid, noteId, body })
84
68
  - mr_discussions({ projectId, mergeRequestIid })
85
69
 
86
70
  - **Issues**
87
71
  - create_issue({ projectId, title, description, assigneeUsernames?: string[] })
88
- - list_issues({ projectId, state?: "opened"|"closed", scope?: "all"|... })
89
72
 
90
73
  - **Branch & Files**
91
74
  - create_branch({ projectId, branchName, ref })
92
75
  - push_files({ projectId, branch, commitMessage, files: [{ filePath, content }] })
93
76
  - create_or_update_file({ projectId, branch, filePath, content, commitMessage })
94
- - get_file_contents({ projectId, ref, path })
95
77
  - get_branch_diffs({ projectId, from, to })
96
78
 
97
79
  - **Merge Requests**
98
80
  - create_merge_request({ projectId, sourceBranch, targetBranch, title, description, assigneeUsernames?: string[] })
99
- - get_merge_request({ projectId, mergeRequestIid? , branchName? })
100
- - get_merge_request_diffs({ projectId, mergeRequestIid? , branchName? })
101
- - list_merge_request_diffs({ projectId, mergeRequestIid? , branchName?, page?, perPage? })
102
- - update_merge_request({ projectId, mergeRequestIid? , branchName?, title?, description?, draft?, assigneeUsernames? })
103
- - merge_merge_request(...) // **Do NOT use** (never merge)
81
+ - get_merge_request({ projectId, mergeRequestIid })
82
+ - get_merge_request_diffs({ projectId, mergeRequestIid })
83
+ - list_merge_request_diffs({ projectId, mergeRequestIid, page?, perPage? })
84
+ - update_merge_request({ projectId, mergeRequestIid, title?, description?, draft?, assigneeUsernames? })
104
85
 
105
- - **Pipelines / Jobs** (requires env USE_PIPELINE=true)
86
+ - **Pipelines / Jobs**
106
87
  - list_pipelines({ projectId, ref?, sha?, status?, orderBy?, sort? })
107
- - get_pipeline({ projectId, pipelineId })
108
88
  - list_pipeline_jobs({ projectId, pipelineId })
109
89
  - get_pipeline_job_output({ projectId, pipelineId, jobId })
110
90
  - play_pipeline_job({ projectId, jobId })
@@ -116,166 +96,125 @@ const outputDiscipline = ({ agentUserName }) => `
116
96
  - Keep comments concise and professional.
117
97
  - Never include "@${agentUserName}" in any body.
118
98
  `;
119
- /* ---------- Event (webhook) specific ---------- */
99
+ /* ---------- Event-specific helpers ---------- */
120
100
  const eventSelfParse = () => `
121
- ## Self-Parse the Raw Payload (no preprocessing available)
101
+ ## Self-Parse Raw Payload
122
102
  From \`event_json\`, extract:
123
103
  - kind: "issue" | "merge_request" | "note"
124
- - target + iid from URL:
125
- - \`/-/issues/<n>\` target="issue", iid=<n>
126
- - \`/-/merge_requests/<n>\` target="mr", iid=<n>
127
- - note_id if present (\`#note_<id>\`)
128
- - description/body text, state, author \`user_username\`, timestamps
129
- - project id/path; detect default branch via \`get_merge_request\`/context as needed
130
- - If available: the discussion id / thread context of the note to enable inline replies.
104
+ - iid from URL (/issues/<n>, /merge_requests/<n>)
105
+ - note_id if present (#note_<id>)
106
+ - description/body, state, author, timestamps
107
+ - project id/path
108
+ - discussion id if available for inline replies
131
109
  `;
132
- /* Helper used by Single-Runner Guard and Review-on-Demand to find the MR’s own pipeline */
110
+ /* Resolve MR pipeline from MR IID */
133
111
  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.
112
+ ## Resolve MR Pipeline
113
+ 1) get_merge_request({ projectId, mergeRequestIid }) → sourceBranch, sha
114
+ 2) Prefer: list_pipelines({ projectId, sha })
115
+ 3) Else: list_pipelines({ projectId, ref: sourceBranch, orderBy: "updated_at", sort: "desc" })
116
+ 4) Pick newest mr_pipeline_id
145
117
  `;
118
+ /* Guard against double agent-review jobs */
146
119
  const singleRunnerGuard = () => `
147
- ## Single-Runner Guard (event-triggered work on an existing MR)
148
- Before entering MR Review Mode from an event:
149
-
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.
151
-
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.
161
- - Proceed with review.
162
-
163
- **Notes:**
164
- - Keep this guard **idempotent** (safe to run multiple times).
165
- - Only applies to **event-triggered** flows that act on an **existing MR**.
120
+ ## Single-Runner Guard
121
+ - If mr_pipeline_id available:
122
+ - list_pipeline_jobs({ projectId, pipelineId: mr_pipeline_id })
123
+ - cancel_pipeline_job on any running/pending job ending with "agent-review"
124
+ - If not available, note limitation and proceed
166
125
  `;
126
+ /* If user asks for review from an event, try manual agent-review job first on the MR's pipeline */
167
127
  const reviewOnDemandFromEvents = () => `
168
- ## Review-on-Demand (from events)
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:
170
-
171
- 1) **Resolve which MR to review**:
172
- - If the event target is an MRuse its \`iid\`.
173
- - Else, parse the text for MR references in order:
174
- - \`!<iid>\` (e.g., \`!123\`)
175
- - \`/-/merge_requests/<iid>\` in a path or URL
176
- - full GitLab MR URL
177
- - If no MR can be resolved, reply with a brief comment asking the user to reference an MR (sanitize) and **stop**.
178
-
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.
193
-
194
- 5) **Enter MR Review Mode**: execute the **MR Review Bundle** below with the resolved \`mr_iid\`.
128
+ ## Review-on-Demand
129
+ If the text asks for a review ("review", "please review", "PTAL", "needs review", "can you look at", "LGTM?"):
130
+ 1) Resolve MR IID (from target or text).
131
+ 2) Resolve MR pipeline (do NOT use the event pipeline).
132
+ 3) If a manual "agent-review" job exists, play it confirm in-thread → STOP.
133
+ 4) Else run Single-Runner Guard, then enter MR Review Mode.
195
134
  `;
196
- /** Regular event workflow for non-review work */
135
+ /* ---------- Event workflow ---------- */
197
136
  const eventWorkflow = ({ agentUserName }) => `
198
- ## High-Reliability Workflow (sequence + postconditions)
199
- Follow this order for any change work:
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
-
205
- 1) **Acknowledge** with a short comment on the issue/MR thread (\`create_note\`), **unless the last actor is you**.
206
- 2) **Discover default branch** (e.g., "main") infer from repo/MR context if needed.
207
- 3) **Create a working branch** from default (stable name, e.g., \`fix/issue-<iid>-<slug>\` or \`feat/issue-<iid>-<slug>\`) via \`create_branch\`.
208
- 4) **Write changes commit → push to remote branch** via \`push_files\` (or \`create_or_update_file\`).
209
- 5) **Verify push landed**:
210
- - Fetch latest state and ensure diffs via \`get_branch_diffs({ from: "<default>", to: "<source>" })\`.
211
- 6) **Create or update MR** ONLY if there is a non-empty diff via \`create_merge_request\`.
212
- - Include \`Closes #<issue_iid>\` in MR description when applicable.
213
- - **Assign the MR to yourself**: \`assigneeUsernames: ["${agentUserName}"]\`.
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).
215
- 8) **If verification fails**:
216
- - Do NOT create the MR.
217
- - Comment the exact failure and retry once with a fresh branch name. If still failing, comment and stop.
137
+ ## Event Workflow
138
+ 0) Conversations Intake first
139
+ 1) Acknowledge with note (unless last actor is you)
140
+ 2) Default branch: use \`$CI_DEFAULT_BRANCH\`
141
+ 3) Create branch from \`$CI_DEFAULT_BRANCH\`:
142
+ create_branch({ projectId: $CI_PROJECT_ID, branchName: "<source_branch>", ref: $CI_DEFAULT_BRANCH })
143
+ 4) Write changes → commit → push:
144
+ push_files({ projectId: $CI_PROJECT_ID, branch: "<source_branch>", commitMessage, files })
145
+ - Ensure files list is not empty before calling push_files; if empty, skip pushing.
146
+ 5) Verify:
147
+ get_branch_diffs({ projectId: $CI_PROJECT_ID, from: $CI_DEFAULT_BRANCH, to: "<source_branch>" })
148
+ - Require non-empty diffs
149
+ 6) Create MR (if diffs exist):
150
+ create_merge_request({
151
+ projectId: $CI_PROJECT_ID,
152
+ sourceBranch: "<source_branch>",
153
+ targetBranch: $CI_DEFAULT_BRANCH,
154
+ title,
155
+ description, // include "Closes #<issue_iid>" when applicable
156
+ assigneeUsernames: ["${agentUserName}"]
157
+ })
158
+ 7) Follow-up note (in correct thread) with branch, short SHA if available, files-changed count, and MR link (unless last actor is you)
159
+ 8) If verification fails: comment error and STOP
218
160
 
219
- For Q&A-only (no code changes), run **Conversations Intake** first, then post a single concise, helpful answer **in the correct thread** (sanitize).
161
+ ## Stdout Summary (Event)
162
+ Print a plain-text summary with:
163
+ - action: "event"
164
+ - source_branch
165
+ - target_branch: $CI_DEFAULT_BRANCH
166
+ - diff_count (from get_branch_diffs)
167
+ - mr_iid and/or mr_url if created
168
+ - any note ids created/updated
169
+ - any limitations encountered (e.g., missing discussions tool)
220
170
  `;
221
- /* ---------- MR-review specific (shared with both prompts) ---------- */
171
+ /* ---------- MR-specific ---------- */
222
172
  const mrScope = ({ agentUserName }) => `
223
- ## Identity & Scope
224
- - Your GitLab username is "${agentUserName}".
225
- - This prompt runs in the context of ONE MR.
226
- - You may review, comment, and push updates **to the MR's source branch**.
227
- - You must **never merge** the MR yourself.
173
+ ## MR Scope
174
+ - You are reviewing a single MR
175
+ - Never merge the MR yourself
176
+ - Work only on the MR's source branch
228
177
  `;
229
178
  const mrWorkflow = () => `
230
- ## High-Reliability Review Workflow
231
- Follow this sequence with verification at each step:
232
-
233
- 1) **Collect context**
234
- - Get MR metadata via \`get_merge_request({ projectId: $CI_PROJECT_ID, mergeRequestIid })\`.
235
- - Fetch the full changeset/diffs via \`get_merge_request_diffs\` (or \`list_merge_request_diffs\`) and open discussions via \`mr_discussions\`.
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.
179
+ ## MR Workflow
180
+ 1) get_merge_request + get_merge_request_diffs + mr_discussions
181
+ 2) Conversations Intake
182
+ 3) Post review comments first via create_merge_request_note (sanitize)
183
+ 4) If will_push_changes = true:
184
+ - push_files to source branch
185
+ - verify with get_branch_diffs({ from: targetBranch || $CI_DEFAULT_BRANCH, to: sourceBranch })
186
+ - follow-up note summarizing changes in the right thread (sanitize)
237
187
 
238
- 2) **Code review**
239
- - Identify required changes (bugs, tests, style, security, perf, docs).
240
- - Always **post your review comments first** using \`create_merge_request_note\` (ack + concrete notes). Sanitize before sending.
241
- - Set an internal intent flag:
242
- - \`will_push_changes = true\` if you will modify code/config.
243
- - \`will_push_changes = false\` if it’s commentary-only.
244
-
245
- 3) **Implement changes after review is posted (only if \`will_push_changes = true\`)**
246
- - If needed, create the working branch from the target/default (or use existing MR source branch).
247
- - Apply minimal, safe changes; keep commits small and clear.
248
- - **Push** to the MR's **source branch** via \`push_files\` (or \`create_or_update_file\`).
249
- - **Verify push landed** using \`get_branch_diffs({ from: "<target_branch>", to: "<source_branch>" })\` and ensure there are diffs.
250
- - Post a follow-up MR note summarizing what changed and why, **in the appropriate thread** (sanitize).
188
+ ## Stdout Summary (MR)
189
+ Print a plain-text summary with:
190
+ - action: "mr"
191
+ - mr_iid
192
+ - source_branch and target_branch (fallback to $CI_DEFAULT_BRANCH)
193
+ - will_push_changes: true|false
194
+ - diff_count (post-push, if applicable)
195
+ - discussions: number of notes added/updated
196
+ - ci: whether mr_pipeline_id was resolved
197
+ - blocking_failed_jobs (names+stages) if inspected
251
198
  `;
199
+ /* ---------- CI Inspection (shared) ---------- */
252
200
  const ciInspection = () => `
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.
201
+ ## CI Inspection (diagnose only)
202
+ - Use mr_pipeline_id if available
203
+ - list_pipeline_jobs for each failed + allow_failure=false:
204
+ - get_pipeline_job_output
205
+ - classify: code vs infra
206
+ - Do not retry; only report diagnosis in a note
207
+ - If no mr_pipeline_id, note limitation
268
208
  `;
269
209
  const outputDisciplineMR = ({ agentUserName }) => `
270
210
  ## Output Discipline (MR)
271
- - Output only \`gitlab-mcp\` tool calls and the final plain-text summary.
272
- - Do **not** merge the MR yourself under any circumstance.
273
- - Never include "@${agentUserName}" in any body.
211
+ - Only gitlab-mcp calls + final summary
212
+ - Never merge MR
213
+ - Never mention "@${agentUserName}"
274
214
  `;
275
- /* ---------- Shared bundle for MR review ---------- */
215
+ /* ---------- MR Review Bundle ---------- */
276
216
  const mrReviewBundle = (ctx) => `
277
- ## MR Review Mode (execute ONLY when review intent is detected and an MR IID is resolved)
278
- Resolved MR IID: <set this to the resolved \`mr_iid\` before executing>
217
+ ## MR Review Mode
279
218
  ${mrScope(ctx)}
280
219
  ${mrWorkflow()}
281
220
  ${ciInspection()}
@@ -293,12 +232,12 @@ $(cat $TRIGGER_PAYLOAD)
293
232
  ${identity(ctx)}
294
233
  ${goldenRules(ctx)}
295
234
  ${selfMentionGuard(ctx)}
296
- ${conversationsIntake(ctx)} <!-- NEW: mandatory before acting -->
235
+ ${conversationsIntake(ctx)}
297
236
  ${eventSelfParse()}
298
- ${resolveMrPipeline()} <!-- used by review/cancel paths -->
299
- ${singleRunnerGuard()} <!-- operates on MR pipeline, not event pipeline -->
237
+ ${resolveMrPipeline()}
238
+ ${singleRunnerGuard()}
300
239
  ${reviewOnDemandFromEvents()}
301
- ${mrReviewBundle(ctx)} <!-- agent can execute when review intent is true -->
240
+ ${mrReviewBundle(ctx)}
302
241
  ${eventWorkflow(ctx)}
303
242
  ${commentGuidelines()}
304
243
  ${mcpOnly()}
@@ -318,7 +257,7 @@ description: $CI_MERGE_REQUEST_DESCRIPTION
318
257
  ${mrScope(ctx)}
319
258
  ${goldenRules(ctx)}
320
259
  ${selfMentionGuard(ctx)}
321
- ${conversationsIntake(ctx)} <!-- NEW: always read MR discussions -->
260
+ ${conversationsIntake(ctx)}
322
261
  ${mrWorkflow()}
323
262
  ${ciInspection()}
324
263
  ${commentGuidelines()}
@@ -1 +1 @@
1
- {"version":3,"file":"prompts.js","sourceRoot":"","sources":["../../../../../../pipeline/src/pipeline/agent/prompts.ts"],"names":[],"mappings":";AAAA,qGAAqG;AACrG,oGAAoG;AACpG,8GAA8G;;;AAI9G,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,sEAAsE;AAEtE,MAAM,mBAAmB,GAAG,CAAC,EAAE,aAAa,EAAO,EAAE,EAAE,CAAC;;;;;;;;;;oFAU4B,aAAa;;;;;;;;;;;;CAYhG,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/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.escapeBackTicks)(prompt)))}"`,
28
28
  //'echo "$PROMPT"',
29
- `claude -p "$PROMPT" --permission-mode acceptEdits --allowedTools "Bash(*) Bash(git checkout:*) Read(*) Edit(*) Write(*) mcp__gitlab" --verbose --debug`,
29
+ `claude -p "$PROMPT" --permission-mode acceptEdits --allowedTools "Bash Read(*) Edit(*) Write(*) mcp__gitlab" --verbose --debug`,
30
30
  ];
31
31
  };
32
32
  exports.callClaude = callClaude;
@@ -1 +1 @@
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
+ {"version":3,"file":"shared.js","sourceRoot":"","sources":["../../../../../../pipeline/src/pipeline/agent/shared.ts"],"names":[],"mappings":";;;AAAA,s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