agent-nuvira 1.30.0 → 1.32.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.
Files changed (35) hide show
  1. package/README.md +11 -1
  2. package/dist/agents/agents/gitlab-agent.d.ts +73 -0
  3. package/dist/agents/agents/gitlab-agent.d.ts.map +1 -0
  4. package/dist/agents/agents/gitlab-agent.js +449 -0
  5. package/dist/agents/agents/gitlab-agent.js.map +1 -0
  6. package/dist/agents/agents/gitlab-api-client.d.ts +230 -0
  7. package/dist/agents/agents/gitlab-api-client.d.ts.map +1 -0
  8. package/dist/agents/agents/gitlab-api-client.js +290 -0
  9. package/dist/agents/agents/gitlab-api-client.js.map +1 -0
  10. package/dist/agents/agents/planner.js +1 -1
  11. package/dist/agents/agents/planner.js.map +1 -1
  12. package/dist/agents/agents/pr-review-agent.d.ts +68 -0
  13. package/dist/agents/agents/pr-review-agent.d.ts.map +1 -0
  14. package/dist/agents/agents/pr-review-agent.js +504 -0
  15. package/dist/agents/agents/pr-review-agent.js.map +1 -0
  16. package/dist/agents/module-registry.d.ts.map +1 -1
  17. package/dist/agents/module-registry.js +14 -0
  18. package/dist/agents/module-registry.js.map +1 -1
  19. package/dist/editing/edit.d.ts +24 -11
  20. package/dist/editing/edit.d.ts.map +1 -1
  21. package/dist/editing/edit.js +184 -114
  22. package/dist/editing/edit.js.map +1 -1
  23. package/dist/editing/transform.d.ts +97 -0
  24. package/dist/editing/transform.d.ts.map +1 -0
  25. package/dist/editing/transform.js +312 -0
  26. package/dist/editing/transform.js.map +1 -0
  27. package/dist/editing/ts-adapter.d.ts +70 -0
  28. package/dist/editing/ts-adapter.d.ts.map +1 -0
  29. package/dist/editing/ts-adapter.js +367 -0
  30. package/dist/editing/ts-adapter.js.map +1 -0
  31. package/dist/test.d.ts +2 -0
  32. package/dist/test.d.ts.map +1 -0
  33. package/dist/test.js +3 -0
  34. package/dist/test.js.map +1 -0
  35. package/package.json +1 -1
package/README.md CHANGED
@@ -1337,7 +1337,7 @@ npx tsc --noEmit
1337
1337
 
1338
1338
  ## Roadmap
1339
1339
 
1340
- **Phases 1–3 (25 phases) are complete.** Phase 4 (Industry Standards & Autonomous Polish) is in progress. See [UPGRADE_ROADMAP.md](./UPGRADE_ROADMAP.md) for the full implementation journey.
1340
+ **Phases 1–11 are complete** from Foundation (Phase 0) through TS Compiler API-Aware Structural Editing (Phase 11). See [UPGRADE_ROADMAP.md](./UPGRADE_ROADMAP.md) for the full implementation journey.
1341
1341
 
1342
1342
  > 📊 **Architecture, strategy & contribution materials:** [ARCHITECTURE.md](./ARCHITECTURE.md) — Modular execution engine design with 7 module specifications, extensibility/observability systems, and phased migration plan. [ARCHITECTURE_DIAGRAMS.md](./ARCHITECTURE_DIAGRAMS.md) — Mermaid-rendered versions of all architecture diagrams (Module Architecture, Extensibility, Safe Execution, Data Flow, Observability Bus). [PRODUCT_STRATEGY.md](./PRODUCT_STRATEGY.md) — Competitive landscape, positioning map, OKR framework, and risk register. [PITCH_DECK.md](./PITCH_DECK.md) — 10-slide investor presentation outline with talking points and data. [CONTRIBUTING.md](./CONTRIBUTING.md) — Quick-reference contributor guide with docs map, dev setup, and contribution workflow.
1343
1343
 
@@ -1401,6 +1401,11 @@ npx tsc --noEmit
1401
1401
  | 10.2 | PhaseExecutionEngine — multi-goal project scopes with save/resume across restarts | ✅ Complete (v1.29.0) |
1402
1402
  | 10.3 | `buff publish` — 5-phase pipeline: tests → version → git → npm → GitHub release | ✅ Complete (v1.29.0) |
1403
1403
  | 10.4 | `buff phase` — create/execute/resume/status/list scopes with credential management | ✅ Complete (v1.29.0) |
1404
+ | **Phase 11: TS Compiler API-Aware Structural Editing** | | |
1405
+ | 11.1 | TS Compiler API Wrapper (`ts-adapter.ts`) — parse, find nodes, validate syntax via real TS parser | ✅ Complete (v1.31.0) |
1406
+ | 11.2 | Structural Transformations (`transform.ts`) — rename, extract, inline, add param, change signature | ✅ Complete (v1.31.0) |
1407
+ | 11.3 | Two-Tier Editing Engine (`edit.ts` rewrite) — TS API-first, regex fallback for all 7 operations | ✅ Complete (v1.31.0) |
1408
+ | 11.4 | Phase 11 Tests — 66 tests (40 ts-adapter + 26 transform), all passing | ✅ Complete (v1.31.0) |
1404
1409
 
1405
1410
  ---
1406
1411
 
@@ -1436,6 +1441,8 @@ npx tsc --noEmit
1436
1441
  | **v1.26.0** | Aug 2026 | Phase 9 — SafeExecutionLayer module (file validation, Docker sandbox, safe LLM calls) + 32 new tests (23 SafeExec + 9 Verify Bus) |
1437
1442
  | **v1.27.0** | Aug 2026 | Website + SVG — Phase 9 SafeExecutionLayer, phase progress 9/9, 2,207 tests |
1438
1443
  | **v1.29.0** | Sep 2026 | Phase 10 — Autonomous publish + phase-wise execution (CredentialStore, PhaseEngine, `buff publish`, `buff phase`, git push, npm auth) + 86 new tests |
1444
+ | **v1.30.0** | Sep 2026 | Phase 10 tests + docs — 80 unit tests (CredentialStore + PhaseExecutionEngine), README/Product_Guide/website updated with Phase 10 progress |
1445
+ | **v1.31.0** | Sep 2026 | Phase 11 — TS Compiler API-Aware Structural Editing (ts-adapter.ts, transform.ts, edit.ts rewrite, 66 new tests), proper parser-level accuracy for TS/JS edits |
1439
1446
 
1440
1447
  ---
1441
1448
 
@@ -1530,6 +1537,9 @@ npx tsc --noEmit
1530
1537
  | **PhaseExecutionEngine (Phase 10)** | Multi-goal project scope execution — sequential phase execution with save/resume across restarts, credential management, progress tracking |
1531
1538
  | **`buff publish` (Phase 10)** | Autonomous 5-phase publish pipeline — test verification → version bump → git commit/tag/push → npm build/publish → GitHub release |
1532
1539
  | **`buff phase` (Phase 10)** | Phase-wise project execution CLI — create/execute/resume/status/list/delete scopes with interactive pauses and credential collection |
1540
+ | **TS Compiler API Wrapper (Phase 11)** | Proper TypeScript Compiler API integration — parser-level accuracy with parseSourceFile, findStructuralNodes, validateTSSyntax, replaceNodeText, and insertAt |
1541
+ | **Structural Transformations (Phase 11)** | Real code transformations — renameSymbol, extractFunction, inlineFunction, addParameter, changeSignature with NLP-based detection |
1542
+ | **Two-Tier Editing Engine (Phase 11)** | All 7 edit operations try TS Compiler API first (for TS/JS), fall back to regex (for Python/Go/Rust) — AST-aware `tryFindNodeTS()` helper |
1533
1543
 
1534
1544
  ### Agent Catalog — 15 Agent Roles & Management
1535
1545
  | Agent/Component | Type | Description |
@@ -0,0 +1,73 @@
1
+ /**
2
+ * GitLab Agent — Manages GitLab operations via the GitLab API.
3
+ *
4
+ * Capabilities:
5
+ * - Create merge requests with title, description, labels
6
+ * - Comment on merge requests (code review inline + summary)
7
+ * - Create and comment on issues
8
+ * - List merge requests/issues for triage
9
+ * - Check pipeline status
10
+ * - Auto-merge approved MRs
11
+ *
12
+ * Uses the existing GitAgent for local git operations (branch, commit, push)
13
+ * and delegates remote GitLab operations (MR, issues, comments) to the API client.
14
+ *
15
+ * Requires: GITLAB_TOKEN env var or explicit token.
16
+ *
17
+ * Usage in task plans:
18
+ * ```json
19
+ * { "id": "step-mr", "description": "Create merge request for fix-login branch", "agentType": "gitlab", "dependsOn": ["step-commit"] }
20
+ * ```
21
+ */
22
+ import { Agent, type AgentContext, type AgentResult } from '../agent.js';
23
+ import type { LLMCallFn } from '../agent.js';
24
+ import { GitLabAPIClient } from './gitlab-api-client.js';
25
+ /**
26
+ * GitLab Agent — Handles GitLab operations for the multi-agent pipeline.
27
+ */
28
+ export declare class GitLabAgent extends Agent {
29
+ readonly name = "GitLab";
30
+ readonly description = "Manages GitLab operations (MR, issues, comments, pipelines)";
31
+ private client;
32
+ constructor(client?: GitLabAPIClient);
33
+ execute(context: AgentContext, _callLLM: LLMCallFn): Promise<AgentResult>;
34
+ private detectOperation;
35
+ /**
36
+ * Resolve the GitLab project ID from the context or task description.
37
+ * Checks: task description → context metadata → git remote
38
+ */
39
+ private resolveProjectId;
40
+ /** Discover accessible GitLab projects */
41
+ private discoverProjects;
42
+ /** Create a merge request */
43
+ private createMergeRequest;
44
+ /** List merge requests */
45
+ private listMergeRequests;
46
+ /** Comment on a merge request */
47
+ private commentOnMR;
48
+ /** Merge a merge request */
49
+ private mergeMR;
50
+ /** Create an issue */
51
+ private createIssue;
52
+ /** List issues */
53
+ private listIssues;
54
+ /** Comment on an issue */
55
+ private commentOnIssue;
56
+ /** Check pipeline status */
57
+ private checkPipelineStatus;
58
+ /** Detect a branch name from the task description */
59
+ private detectBranch;
60
+ /** Detect the target branch from the task description */
61
+ private detectTargetBranch;
62
+ /** Generate an MR title from the description and goal */
63
+ private generateMRTitle;
64
+ /** Generate an MR description from the goal */
65
+ private generateMRDescription;
66
+ /** Extract MR number from description: "!42" or "MR 42" or "merge request 42" */
67
+ private extractMRNumber;
68
+ /** Extract issue number from description: "#42" or "issue 42" */
69
+ private extractIssueNumber;
70
+ /** Extract comment text from description */
71
+ private extractCommentText;
72
+ }
73
+ //# sourceMappingURL=gitlab-agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitlab-agent.d.ts","sourceRoot":"","sources":["../../../src/agents/agents/gitlab-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,YAAY,EAAE,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AACzE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAUzD;;GAEG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,QAAQ,CAAC,IAAI,YAAY;IACzB,QAAQ,CAAC,WAAW,iEAAiE;IAErF,OAAO,CAAC,MAAM,CAAkB;gBAEpB,MAAM,CAAC,EAAE,eAAe;IAK9B,OAAO,CAAC,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,GAAG,OAAO,CAAC,WAAW,CAAC;IAgD/E,OAAO,CAAC,eAAe;IA2CvB;;;OAGG;YACW,gBAAgB;IA8C9B,0CAA0C;YAC5B,gBAAgB;IAkB9B,6BAA6B;YACf,kBAAkB;IAsDhC,0BAA0B;YACZ,iBAAiB;IA0B/B,iCAAiC;YACnB,WAAW;IA0BzB,4BAA4B;YACd,OAAO;IAuBrB,sBAAsB;YACR,WAAW;IA8BzB,kBAAkB;YACJ,UAAU;IAwBxB,0BAA0B;YACZ,cAAc;IAoB5B,4BAA4B;YACd,mBAAmB;IAuCjC,qDAAqD;IACrD,OAAO,CAAC,YAAY;IAepB,yDAAyD;IACzD,OAAO,CAAC,kBAAkB;IAK1B,yDAAyD;IACzD,OAAO,CAAC,eAAe;IAUvB,+CAA+C;IAC/C,OAAO,CAAC,qBAAqB;IAY7B,iFAAiF;IACjF,OAAO,CAAC,eAAe;IAevB,iEAAiE;IACjE,OAAO,CAAC,kBAAkB;IAc1B,4CAA4C;IAC5C,OAAO,CAAC,kBAAkB;CAc3B"}
@@ -0,0 +1,449 @@
1
+ /**
2
+ * GitLab Agent — Manages GitLab operations via the GitLab API.
3
+ *
4
+ * Capabilities:
5
+ * - Create merge requests with title, description, labels
6
+ * - Comment on merge requests (code review inline + summary)
7
+ * - Create and comment on issues
8
+ * - List merge requests/issues for triage
9
+ * - Check pipeline status
10
+ * - Auto-merge approved MRs
11
+ *
12
+ * Uses the existing GitAgent for local git operations (branch, commit, push)
13
+ * and delegates remote GitLab operations (MR, issues, comments) to the API client.
14
+ *
15
+ * Requires: GITLAB_TOKEN env var or explicit token.
16
+ *
17
+ * Usage in task plans:
18
+ * ```json
19
+ * { "id": "step-mr", "description": "Create merge request for fix-login branch", "agentType": "gitlab", "dependsOn": ["step-commit"] }
20
+ * ```
21
+ */
22
+ import { Agent } from '../agent.js';
23
+ import { GitLabAPIClient } from './gitlab-api-client.js';
24
+ // ─── Agent ──────────────────────────────────────────────────────────────────
25
+ /**
26
+ * GitLab Agent — Handles GitLab operations for the multi-agent pipeline.
27
+ */
28
+ export class GitLabAgent extends Agent {
29
+ name = 'GitLab';
30
+ description = 'Manages GitLab operations (MR, issues, comments, pipelines)';
31
+ client;
32
+ constructor(client) {
33
+ super();
34
+ this.client = client ?? new GitLabAPIClient();
35
+ }
36
+ async execute(context, _callLLM) {
37
+ try {
38
+ // Check if GitLab is configured
39
+ if (!this.client.hasToken()) {
40
+ return {
41
+ success: false,
42
+ summary: 'GitLab not configured',
43
+ error: 'Set GITLAB_TOKEN environment variable to use the GitLab agent',
44
+ };
45
+ }
46
+ const taskDesc = context.taskPlan.find((s) => s.agentType === 'gitlab' && s.status === 'running')?.description || context.goal;
47
+ const operation = this.detectOperation(taskDesc);
48
+ const projectId = await this.resolveProjectId(context);
49
+ switch (operation) {
50
+ case 'discover':
51
+ return this.discoverProjects();
52
+ case 'mr-create':
53
+ return this.createMergeRequest(context, taskDesc, projectId);
54
+ case 'mr-list':
55
+ return this.listMergeRequests(projectId, taskDesc);
56
+ case 'mr-comment':
57
+ return this.commentOnMR(context, taskDesc, projectId);
58
+ case 'mr-merge':
59
+ return this.mergeMR(projectId, taskDesc);
60
+ case 'issue-create':
61
+ return this.createIssue(context, taskDesc, projectId);
62
+ case 'issue-list':
63
+ return this.listIssues(projectId, taskDesc);
64
+ case 'issue-comment':
65
+ return this.commentOnIssue(context, taskDesc, projectId);
66
+ case 'pipeline-status':
67
+ return this.checkPipelineStatus(projectId, taskDesc);
68
+ default:
69
+ return this.createMergeRequest(context, taskDesc, projectId);
70
+ }
71
+ }
72
+ catch (err) {
73
+ const msg = err instanceof Error ? err.message : String(err);
74
+ return { success: false, summary: 'GitLab operation failed', error: msg };
75
+ }
76
+ }
77
+ // ─── Operation Detection ──────────────────────────────────────────────────
78
+ detectOperation(description) {
79
+ const lower = description.toLowerCase();
80
+ // Discover projects
81
+ if (lower.includes('discover') || lower.includes('list project') || lower.includes('find project'))
82
+ return 'discover';
83
+ // MR operations — use word-based matching for robustness
84
+ // Split into words for more accurate intent detection
85
+ const words = lower.split(/[\s,;:!?]+/);
86
+ const hasMr = words.some(w => w === 'mr' || w === 'mrs' || w === 'merge' || w === 'merges');
87
+ const hasMergeRequest = lower.includes('merge request') || lower.includes('merge requests');
88
+ // 'create' + 'mr'/'merge request'
89
+ if ((lower.includes('create') || lower.includes('new')) && (hasMr || hasMergeRequest))
90
+ return 'mr-create';
91
+ // 'list'/'show'/'open' + 'mr'/'merge request'
92
+ if ((lower.includes('list') || lower.includes('show') || lower.includes('open')) && (hasMr || hasMergeRequest))
93
+ return 'mr-list';
94
+ // 'merge'/'accept'/'approve' as verb + 'mr'/'merge request'
95
+ // Check if 'merge' appears as a separate word (not in 'merge request')
96
+ const mergeAsVerb = words.includes('merge') || words.includes('merged') || words.includes('merging');
97
+ if ((mergeAsVerb || lower.includes('accept') || lower.includes('approve')) && (hasMr || hasMergeRequest))
98
+ return 'mr-merge';
99
+ // 'comment'/'review' + 'mr'/'merge request'
100
+ if ((lower.includes('comment') || lower.includes('review') || lower.includes('note')) && (hasMr || hasMergeRequest))
101
+ return 'mr-comment';
102
+ // Catch-all for other mr-related descriptions
103
+ if (hasMr || hasMergeRequest)
104
+ return 'mr-create';
105
+ // Issue operations
106
+ if (lower.includes('create issue') || lower.includes('new issue'))
107
+ return 'issue-create';
108
+ if (lower.includes('comment') && lower.includes('issue'))
109
+ return 'issue-comment';
110
+ if (lower.includes('list issue') || lower.includes('open issue') || lower.includes('show issue'))
111
+ return 'issue-list';
112
+ // Pipeline
113
+ if (lower.includes('pipeline') || lower.includes('ci') || lower.includes('build status'))
114
+ return 'pipeline-status';
115
+ // Default
116
+ return 'mr-create';
117
+ }
118
+ // ─── Project Resolution ───────────────────────────────────────────────────
119
+ /**
120
+ * Resolve the GitLab project ID from the context or task description.
121
+ * Checks: task description → context metadata → git remote
122
+ */
123
+ async resolveProjectId(context) {
124
+ // Check context metadata for a pre-resolved project ID
125
+ const metaId = context.metadata?.gitlabProjectId;
126
+ if (typeof metaId === 'number')
127
+ return metaId;
128
+ if (typeof metaId === 'string' && /^\d+$/.test(metaId))
129
+ return Number(metaId);
130
+ // Check for a project path in metadata (e.g., "my-org/my-project")
131
+ const metaPath = context.metadata?.gitlabProjectPath;
132
+ if (typeof metaPath === 'string') {
133
+ try {
134
+ const project = await this.client.getProject(metaPath);
135
+ return project.id;
136
+ }
137
+ catch {
138
+ // Fall through
139
+ }
140
+ }
141
+ // Try to extract from the git remote
142
+ try {
143
+ const { execSync } = await import('node:child_process');
144
+ const remote = execSync('git remote get-url origin 2>&1', {
145
+ timeout: 10_000,
146
+ encoding: 'utf-8',
147
+ stdio: 'pipe',
148
+ }).trim();
149
+ // Parse gitlab.com URLs: git@gitlab.com:org/repo.git or https://gitlab.com/org/repo.git
150
+ const match = remote.match(/gitlab\.com[/:]([^/]+\/[^/.]+?)(?:\.git)?$/);
151
+ if (match) {
152
+ const projectPath = match[1];
153
+ try {
154
+ const project = await this.client.getProject(projectPath);
155
+ return project.id;
156
+ }
157
+ catch {
158
+ // Fall through
159
+ }
160
+ }
161
+ }
162
+ catch {
163
+ // Fall through
164
+ }
165
+ return null;
166
+ }
167
+ // ─── Operations ───────────────────────────────────────────────────────────
168
+ /** Discover accessible GitLab projects */
169
+ async discoverProjects() {
170
+ const projects = await this.client.listProjects({ membership: true });
171
+ if (projects.length === 0) {
172
+ return { success: true, summary: 'No GitLab projects found' };
173
+ }
174
+ const details = projects.map((p) => ` • ${p.nameWithNamespace} (id: ${p.id}) — ${p.webUrl}`).join('\n');
175
+ return {
176
+ success: true,
177
+ summary: `Found ${projects.length} GitLab project(s)`,
178
+ details,
179
+ };
180
+ }
181
+ /** Create a merge request */
182
+ async createMergeRequest(context, description, projectId) {
183
+ // Detect branch name from context or description
184
+ const sourceBranch = this.detectBranch(description) || context.metadata?.gitlabSourceBranch || '';
185
+ const targetBranch = this.detectTargetBranch(description) || context.metadata?.gitlabTargetBranch || 'main';
186
+ if (!sourceBranch) {
187
+ return {
188
+ success: false,
189
+ summary: 'Could not determine source branch',
190
+ error: 'Specify the branch name in the task description (e.g., "Create MR for branch fix/login")',
191
+ };
192
+ }
193
+ // Generate title and description from the goal
194
+ const title = this.generateMRTitle(description, context.goal);
195
+ const desc = this.generateMRDescription(description, context.goal);
196
+ const options = {
197
+ title,
198
+ description: desc,
199
+ sourceBranch,
200
+ targetBranch,
201
+ draft: description.toLowerCase().includes('draft') || description.toLowerCase().includes('wip'),
202
+ removeSourceBranch: description.toLowerCase().includes('delete branch') || description.toLowerCase().includes('remove branch'),
203
+ squash: description.toLowerCase().includes('squash'),
204
+ };
205
+ // Extract labels if mentioned
206
+ const labelMatch = description.match(/labels?\s*[:\s]+([a-zA-Z0-9_,\s-]+)/i);
207
+ if (labelMatch) {
208
+ options.labels = labelMatch[1].split(/[, ]+/).filter(Boolean);
209
+ }
210
+ if (projectId) {
211
+ const mr = await this.client.createMergeRequest(projectId, options);
212
+ return {
213
+ success: true,
214
+ summary: `Created MR #${mr.iid}: ${mr.title}`,
215
+ details: mr.webUrl,
216
+ };
217
+ }
218
+ // No project resolved — try to create via GitLab API using path from git remote
219
+ return {
220
+ success: false,
221
+ summary: 'Could not resolve GitLab project',
222
+ error: 'Ensure the git remote points to GitLab or set gitlabProjectId in context metadata',
223
+ };
224
+ }
225
+ /** List merge requests */
226
+ async listMergeRequests(projectId, description) {
227
+ const state = description.includes('merged') ? 'merged'
228
+ : description.includes('closed') ? 'closed'
229
+ : 'opened';
230
+ if (!projectId) {
231
+ return { success: false, summary: 'No GitLab project resolved', error: 'Set git remote or gitlabProjectId' };
232
+ }
233
+ const mrs = await this.client.listMergeRequests(projectId, { state });
234
+ if (mrs.length === 0) {
235
+ return { success: true, summary: `No ${state} merge requests found` };
236
+ }
237
+ const details = mrs.map((mr) => ` • !${mr.iid} ${mr.title} (${mr.sourceBranch} → ${mr.targetBranch}) — ${mr.state}`).join('\n');
238
+ return {
239
+ success: true,
240
+ summary: `Found ${mrs.length} ${state} merge request(s)`,
241
+ details,
242
+ };
243
+ }
244
+ /** Comment on a merge request */
245
+ async commentOnMR(context, description, projectId) {
246
+ const mrIid = this.extractMRNumber(description);
247
+ if (!projectId || !mrIid) {
248
+ return {
249
+ success: false,
250
+ summary: 'MR ID and project required',
251
+ error: 'Specify the MR number (e.g., "Comment on MR !42: LGTM")',
252
+ };
253
+ }
254
+ // Use context summary as comment if available, otherwise extract from description
255
+ const commentText = this.extractCommentText(description) || 'Reviewed by agent-nuvira.';
256
+ const note = await this.client.createMRNote(projectId, mrIid, commentText);
257
+ return {
258
+ success: true,
259
+ summary: `Commented on MR !${mrIid}`,
260
+ details: `Note #${note.id}: ${commentText.slice(0, 100)}${commentText.length > 100 ? '...' : ''}`,
261
+ };
262
+ }
263
+ /** Merge a merge request */
264
+ async mergeMR(projectId, description) {
265
+ const mrIid = this.extractMRNumber(description);
266
+ if (!projectId || !mrIid) {
267
+ return {
268
+ success: false,
269
+ summary: 'MR ID and project required',
270
+ error: 'Specify the MR number (e.g., "Merge MR !42")',
271
+ };
272
+ }
273
+ const mr = await this.client.mergeMergeRequest(projectId, mrIid, {
274
+ squash: description.toLowerCase().includes('squash'),
275
+ shouldRemoveSourceBranch: description.toLowerCase().includes('delete branch'),
276
+ });
277
+ return {
278
+ success: true,
279
+ summary: `Merged MR !${mrIid}: ${mr.title}`,
280
+ details: mr.webUrl,
281
+ };
282
+ }
283
+ /** Create an issue */
284
+ async createIssue(context, description, projectId) {
285
+ const title = this.generateMRTitle(description, context.goal);
286
+ const desc = this.generateMRDescription(description, context.goal);
287
+ const options = {
288
+ title,
289
+ description: desc,
290
+ };
291
+ const labelMatch = description.match(/labels?\s*[:\s]+([a-zA-Z0-9_,\s-]+)/i);
292
+ if (labelMatch) {
293
+ options.labels = labelMatch[1].split(/[, ]+/).filter(Boolean);
294
+ }
295
+ if (!projectId) {
296
+ return { success: false, summary: 'No GitLab project resolved', error: 'Set git remote or gitlabProjectId' };
297
+ }
298
+ const issue = await this.client.createIssue(projectId, options);
299
+ return {
300
+ success: true,
301
+ summary: `Created issue #${issue.iid}: ${issue.title}`,
302
+ details: issue.webUrl,
303
+ };
304
+ }
305
+ /** List issues */
306
+ async listIssues(projectId, description) {
307
+ const state = description.includes('closed') ? 'closed' : 'opened';
308
+ if (!projectId) {
309
+ return { success: false, summary: 'No GitLab project resolved', error: 'Set git remote or gitlabProjectId' };
310
+ }
311
+ const issues = await this.client.listIssues(projectId, { state });
312
+ if (issues.length === 0) {
313
+ return { success: true, summary: `No ${state} issues found` };
314
+ }
315
+ const details = issues.map((issue) => ` • #${issue.iid} ${issue.title} (${issue.labels.length > 0 ? issue.labels.join(', ') : 'no labels'})`).join('\n');
316
+ return {
317
+ success: true,
318
+ summary: `Found ${issues.length} ${state} issue(s)`,
319
+ details,
320
+ };
321
+ }
322
+ /** Comment on an issue */
323
+ async commentOnIssue(context, description, projectId) {
324
+ const issueIid = this.extractIssueNumber(description);
325
+ if (!projectId || !issueIid) {
326
+ return { success: false, summary: 'Issue ID and project required', error: 'Specify issue number' };
327
+ }
328
+ const commentText = this.extractCommentText(description) || 'Reviewed by agent-nuvira.';
329
+ await this.client.createIssueNote(projectId, issueIid, commentText);
330
+ return {
331
+ success: true,
332
+ summary: `Commented on issue #${issueIid}`,
333
+ };
334
+ }
335
+ /** Check pipeline status */
336
+ async checkPipelineStatus(projectId, _description) {
337
+ if (!projectId) {
338
+ return { success: false, summary: 'No GitLab project resolved', error: 'Set git remote or gitlabProjectId' };
339
+ }
340
+ // Try to get the current branch
341
+ let ref;
342
+ try {
343
+ const { execSync } = await import('node:child_process');
344
+ ref = execSync('git rev-parse --abbrev-ref HEAD', {
345
+ timeout: 10_000,
346
+ encoding: 'utf-8',
347
+ stdio: 'pipe',
348
+ }).trim();
349
+ }
350
+ catch {
351
+ // No branch found
352
+ }
353
+ const pipelines = await this.client.listPipelines(projectId, { ref, perPage: 5 });
354
+ if (pipelines.length === 0) {
355
+ return { success: true, summary: 'No pipelines found for this branch' };
356
+ }
357
+ const latest = pipelines[0];
358
+ const details = pipelines.map((p) => ` • Pipeline #${p.id} — ${p.status} (${p.ref})`).join('\n');
359
+ const statusText = latest.status === 'success' ? 'passing' : latest.status === 'failed' ? 'failing' : latest.status;
360
+ return {
361
+ success: true,
362
+ summary: `Pipeline #${latest.id}: ${statusText}`,
363
+ details,
364
+ };
365
+ }
366
+ // ─── Private Helpers ──────────────────────────────────────────────────
367
+ /** Detect a branch name from the task description */
368
+ detectBranch(description) {
369
+ // Look for branch-like patterns: feat/xxx, fix/xxx, branch: xxx
370
+ const branchPatterns = [
371
+ /(?:branch|from)\s*[:\s]+([a-zA-Z0-9_\/-]+)/i,
372
+ /(?:feat|fix|chore|refactor|docs|style|test|ci|perf)\/[a-zA-Z0-9_-]+/,
373
+ ];
374
+ for (const pattern of branchPatterns) {
375
+ const match = description.match(pattern);
376
+ if (match)
377
+ return match[1] || match[0];
378
+ }
379
+ return undefined;
380
+ }
381
+ /** Detect the target branch from the task description */
382
+ detectTargetBranch(description) {
383
+ const match = description.match(/(?:into|target|to|against)\s*[:\s]+([a-zA-Z0-9_\/-]+)/i);
384
+ return match ? match[1] : 'main';
385
+ }
386
+ /** Generate an MR title from the description and goal */
387
+ generateMRTitle(description, goal) {
388
+ // Try to find a quoted title
389
+ const quoted = description.match(/["'„]([^"'„]+)["'“]/);
390
+ if (quoted)
391
+ return quoted[1].trim();
392
+ // Use a reasonable prefix + goal summary
393
+ const goalSummary = goal.length > 80 ? goal.slice(0, 77) + '...' : goal;
394
+ return goalSummary;
395
+ }
396
+ /** Generate an MR description from the goal */
397
+ generateMRDescription(description, goal) {
398
+ const lines = [];
399
+ lines.push('## Summary');
400
+ lines.push('');
401
+ lines.push(goal);
402
+ lines.push('');
403
+ lines.push('---');
404
+ lines.push('Created by agent-nuvira 🤖');
405
+ return lines.join('\n');
406
+ }
407
+ /** Extract MR number from description: "!42" or "MR 42" or "merge request 42" */
408
+ extractMRNumber(description) {
409
+ const patterns = [
410
+ /!(\d+)/,
411
+ /MR\s*#?(\d+)/i,
412
+ /merge request\s*#?(\d+)/i,
413
+ ];
414
+ for (const pattern of patterns) {
415
+ const match = description.match(pattern);
416
+ if (match)
417
+ return parseInt(match[1], 10);
418
+ }
419
+ return null;
420
+ }
421
+ /** Extract issue number from description: "#42" or "issue 42" */
422
+ extractIssueNumber(description) {
423
+ const patterns = [
424
+ /#(\d+)/,
425
+ /issue\s*#?(\d+)/i,
426
+ ];
427
+ for (const pattern of patterns) {
428
+ const match = description.match(pattern);
429
+ if (match)
430
+ return parseInt(match[1], 10);
431
+ }
432
+ return null;
433
+ }
434
+ /** Extract comment text from description */
435
+ extractCommentText(description) {
436
+ // Look for text after "say", "comment", "message"
437
+ const patterns = [
438
+ /(?:say|comment|message)\s*[:\s]+["'„]([^"'„]+)["'“]/i,
439
+ /(?:say|comment|message)\s*[:\s]+([^"]+)$/i,
440
+ ];
441
+ for (const pattern of patterns) {
442
+ const match = description.match(pattern);
443
+ if (match)
444
+ return match[1].trim();
445
+ }
446
+ return undefined;
447
+ }
448
+ }
449
+ //# sourceMappingURL=gitlab-agent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"gitlab-agent.js","sourceRoot":"","sources":["../../../src/agents/agents/gitlab-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,OAAO,EAAE,KAAK,EAAuC,MAAM,aAAa,CAAC;AAEzE,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAQzD,+EAA+E;AAE/E;;GAEG;AACH,MAAM,OAAO,WAAY,SAAQ,KAAK;IAC3B,IAAI,GAAG,QAAQ,CAAC;IAChB,WAAW,GAAG,6DAA6D,CAAC;IAE7E,MAAM,CAAkB;IAEhC,YAAY,MAAwB;QAClC,KAAK,EAAE,CAAC;QACR,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;IAChD,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAqB,EAAE,QAAmB;QACtD,IAAI,CAAC;YACH,gCAAgC;YAChC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EAAE,CAAC;gBAC5B,OAAO;oBACL,OAAO,EAAE,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