duoops 0.1.4 → 0.1.7

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
@@ -27,18 +27,6 @@ DuoOps is a developer-focused CLI and Web Portal designed to make GitLab CI/CD p
27
27
 
28
28
  ### Installation
29
29
 
30
- #### Install from npm (recommended)
31
-
32
- ```bash
33
- # Install the published CLI globally
34
- npm install -g duoops
35
-
36
- # Verify the binary is available
37
- duoops --help
38
- ```
39
-
40
- #### Install from source (development)
41
-
42
30
  ```bash
43
31
  # Clone the repository
44
32
  git clone https://github.com/youneslaaroussi/duoops.git
@@ -146,35 +134,6 @@ duoops portal
146
134
 
147
135
  Open your browser to `http://localhost:3000`.
148
136
 
149
- ### 6. Runner Utilities
150
-
151
- Once you've provisioned a runner with `duoops init`, you can inspect and manage it directly from the CLI:
152
-
153
- ```bash
154
- # Tail the runner's systemd logs (defaults to gitlab-runner service)
155
- duoops runner:logs --lines 300
156
-
157
- # Reinstall the DuoOps CLI on the VM (uses the current CLI version by default)
158
- duoops runner:reinstall-duoops --version 0.1.0
159
- ```
160
-
161
- ### 7. Use the GitLab CI Component
162
-
163
- Instead of copying `.duoops/measure-component.yml` into every project, you can reference the published component directly:
164
-
165
- ```yaml
166
- include:
167
- - component: gitlab.com/youneslaaroussi/duoops/templates/duoops-measure-component@v0.1.0
168
- inputs:
169
- gcp_project_id: "my-project"
170
- gcp_instance_id: "1234567890123456789"
171
- gcp_zone: "us-central1-a"
172
- machine_type: "e2-standard-4"
173
- tags: ["gcp"]
174
- ```
175
-
176
- Make sure your runner already has DuoOps installed (the provisioning flow handles this) and that `GCP_SA_KEY_BASE64` plus any optional BigQuery variables are set in the project’s CI/CD settings. Pin to a version tag (`@v0.1.0`) and update when you’re ready to adopt new behavior.
177
-
178
137
  ## 🛠️ Development
179
138
 
180
139
  ### Project Structure
@@ -198,20 +157,6 @@ pnpm build
198
157
 
199
158
  This compiles the TypeScript CLI and builds the React frontend, copying assets to the `dist/` directory.
200
159
 
201
- ## 📦 Publishing to npm
202
-
203
- 1. Update `package.json` with the release version you want to publish.
204
- 2. Run the checks: `pnpm test` (this runs lint afterwards) to ensure the CLI and portal build cleanly.
205
- 3. Inspect the publish payload locally with `pnpm pack` (this runs the `prepack` script, which now builds the CLI, portal, and Oclif manifest automatically). Untar the generated `.tgz` if you want to double-check the contents.
206
- 4. When you're satisfied, publish the package: `pnpm publish --access public`.
207
-
208
- ## 📦 Publishing the CI Component
209
-
210
- 1. Update `templates/duoops-measure-component.yml` and commit the changes.
211
- 2. Let the `.gitlab-ci.yml` validation job pass (runs automatically on MRs, default branch, and tags).
212
- 3. Tag the repository (e.g., `git tag v0.1.0 && git push origin v0.1.0`). Consumers reference the component with the tag via the snippet above.
213
- 4. Update release notes/README with the new component version so teams know what changed.
214
-
215
160
  ## 📄 License
216
161
 
217
162
  MIT
@@ -1,7 +1,7 @@
1
1
  import { Command } from '@oclif/core';
2
2
  export default class Ask extends Command {
3
3
  static args: {
4
- question: import("@oclif/core/interfaces").Arg<string, Record<string, unknown>>;
4
+ question: import("@oclif/core/interfaces").Arg<string | undefined, Record<string, unknown>>;
5
5
  };
6
6
  static description: string;
7
7
  run(): Promise<void>;
@@ -1,18 +1,43 @@
1
+ import { search } from '@inquirer/prompts';
1
2
  import { Args, Command } from '@oclif/core';
2
3
  import { runAgent } from '../lib/ai/agent.js';
4
+ import { PROMPT_LIBRARY } from '../lib/ai/prompt-library.js';
3
5
  export default class Ask extends Command {
4
6
  static args = {
5
7
  question: Args.string({
6
8
  description: 'The question to ask the agent',
7
- required: true,
9
+ required: false,
8
10
  }),
9
11
  };
10
12
  static description = 'Ask questions about your CI/CD pipelines, logs, and sustainability';
11
13
  async run() {
12
14
  const { args } = await this.parse(Ask);
15
+ let { question } = args;
16
+ if (!question) {
17
+ question = await search({
18
+ message: 'Select a prompt from the library:',
19
+ async source(term) {
20
+ if (!term) {
21
+ return PROMPT_LIBRARY.map((p) => ({
22
+ description: p.description,
23
+ name: p.title,
24
+ value: p.description, // Passing description as the prompt to the agent
25
+ }));
26
+ }
27
+ return PROMPT_LIBRARY
28
+ .filter((p) => p.title.toLowerCase().includes(term.toLowerCase()) ||
29
+ p.description.toLowerCase().includes(term.toLowerCase()))
30
+ .map((p) => ({
31
+ description: p.description,
32
+ name: p.title,
33
+ value: p.description,
34
+ }));
35
+ },
36
+ });
37
+ }
13
38
  this.log('Thinking...');
14
39
  try {
15
- const response = await runAgent(args.question);
40
+ const response = await runAgent(question);
16
41
  this.log('\n' + response);
17
42
  }
18
43
  catch (error) {
@@ -0,0 +1,13 @@
1
+ /**
2
+ * GitLab Duo Prompt Library
3
+ * Source: https://about.gitlab.com/gitlab-duo/prompt-library/
4
+ */
5
+ export interface PromptTemplate {
6
+ category: string;
7
+ complexity?: 'Advanced' | 'Beginner' | 'Intermediate';
8
+ description: string;
9
+ tags?: string[];
10
+ title: string;
11
+ tool?: string;
12
+ }
13
+ export declare const PROMPT_LIBRARY: PromptTemplate[];
@@ -0,0 +1,335 @@
1
+ /**
2
+ * GitLab Duo Prompt Library
3
+ * Source: https://about.gitlab.com/gitlab-duo/prompt-library/
4
+ */
5
+ export const PROMPT_LIBRARY = [
6
+ {
7
+ category: 'Code Understanding',
8
+ complexity: 'Beginner',
9
+ description: 'Analyze code dependencies and potential impacts before modifying unfamiliar code sections. Essential for preventing breaking changes during refactoring.',
10
+ title: 'Understand Code Before Making Changes',
11
+ tool: 'GitLab Duo',
12
+ },
13
+ {
14
+ category: 'Code Understanding',
15
+ complexity: 'Beginner',
16
+ description: 'Quickly locate all call sites for any method or function across your entire codebase. Invaluable when planning refactoring work.',
17
+ title: 'Trace Function Usage Across Codebase',
18
+ tool: 'GitLab Duo',
19
+ },
20
+ {
21
+ category: 'Code Understanding',
22
+ complexity: 'Beginner',
23
+ description: 'Get clear explanations of complex code or merge requests without manual investigation. Perfect for code reviews and onboarding.',
24
+ title: 'Explain Unfamiliar Code or MR',
25
+ tool: 'GitLab Duo',
26
+ },
27
+ {
28
+ category: 'Code Understanding',
29
+ complexity: 'Beginner',
30
+ description: 'Navigate call graphs to understand how functions interconnect throughout your codebase. Reveals hidden dependencies instantly.',
31
+ title: 'Find Where Functions Are Called',
32
+ tool: 'GitLab Duo',
33
+ },
34
+ {
35
+ category: 'Code Understanding',
36
+ complexity: 'Beginner',
37
+ description: 'Catch up on long-running MRs or issues by getting a summary of key decisions, changes, and action items.',
38
+ title: 'Summarize Recent Changes to MR/Issue',
39
+ tool: 'GitLab Duo',
40
+ },
41
+ {
42
+ category: 'Code Understanding',
43
+ complexity: 'Beginner',
44
+ description: 'Find relevant code sections in unfamiliar projects without knowing the structure. Accelerates exploration of new codebases.',
45
+ title: 'Navigate Large Codebase Quickly',
46
+ tool: 'GitLab Duo',
47
+ },
48
+ {
49
+ category: 'Code Understanding',
50
+ complexity: 'Advanced',
51
+ description: 'Map out class hierarchies and identify which methods are overridden. Critical for understanding object-oriented architectures.',
52
+ title: 'Understand Class Hierarchy and Inheritance',
53
+ tool: 'GitLab Duo',
54
+ },
55
+ {
56
+ category: 'Code Understanding',
57
+ complexity: 'Beginner',
58
+ description: 'Discover how specific patterns are implemented in your existing codebase. Learn from your team\'s established conventions.',
59
+ title: 'Find Code Examples of Patterns',
60
+ tool: 'GitLab Duo',
61
+ },
62
+ {
63
+ category: 'Code Understanding',
64
+ complexity: 'Advanced',
65
+ description: 'Follow data as it moves through multiple components, tracking each transformation step. Essential for debugging data issues.',
66
+ title: 'Understand Data Flow Through System',
67
+ tool: 'GitLab Duo',
68
+ },
69
+ {
70
+ category: 'Code Understanding',
71
+ complexity: 'Advanced',
72
+ description: 'Understand complex database schemas, relationships, and optimization opportunities. Identify performance bottlenecks in your data model.',
73
+ title: 'Analyze Database Schema and Relationships',
74
+ tool: 'GitLab Duo',
75
+ },
76
+ {
77
+ category: 'Code Understanding',
78
+ complexity: 'Beginner',
79
+ description: 'Visualize how different components depend on each other. Understand the blast radius of potential changes.',
80
+ title: 'Map Component Dependencies',
81
+ tool: 'GitLab Duo',
82
+ },
83
+ {
84
+ category: 'Code Understanding',
85
+ complexity: 'Beginner',
86
+ description: 'Decode configuration files and environment setup requirements. Speeds up onboarding and project switching.',
87
+ title: 'Understand Configuration and Environment Setup',
88
+ tool: 'GitLab Duo',
89
+ },
90
+ {
91
+ category: 'Code Understanding',
92
+ complexity: 'Beginner',
93
+ description: 'Document how your system integrates with internal and external APIs. Prevents breaking changes in integrations.',
94
+ title: 'Analyze API Contracts and Integrations',
95
+ tool: 'GitLab Duo',
96
+ },
97
+ {
98
+ category: 'Code Understanding',
99
+ complexity: 'Beginner',
100
+ description: 'Find similar code patterns that could be consolidated into shared utilities. Reduce maintenance burden through DRY principles.',
101
+ title: 'Identify Code Duplication Opportunities',
102
+ tool: 'GitLab Duo',
103
+ },
104
+ {
105
+ category: 'Code Understanding',
106
+ complexity: 'Beginner',
107
+ description: 'Learn how errors are handled throughout your application. Identify inconsistencies and gaps in error handling.',
108
+ title: 'Understand Error Handling Patterns',
109
+ tool: 'GitLab Duo',
110
+ },
111
+ {
112
+ category: 'Code Understanding',
113
+ complexity: 'Beginner',
114
+ description: 'Map authentication flows and permission checks across your system. Essential for security audits and debugging access issues.',
115
+ title: 'Trace Authentication and Authorization Flow',
116
+ tool: 'GitLab Duo',
117
+ },
118
+ {
119
+ category: 'Code Understanding',
120
+ complexity: 'Beginner',
121
+ description: 'Understand asynchronous code, promises, and concurrent operations. Identify potential race conditions before they cause bugs.',
122
+ title: 'Understand Async Operations and Concurrency',
123
+ tool: 'GitLab Duo',
124
+ },
125
+ {
126
+ category: 'Code Review',
127
+ complexity: 'Beginner',
128
+ description: 'Catch logical errors and edge cases that syntax checkers miss. Go beyond linting to find real bugs.',
129
+ title: 'Review MR for Logical Errors',
130
+ tool: 'GitLab Duo',
131
+ },
132
+ {
133
+ category: 'Code Review',
134
+ complexity: 'Beginner',
135
+ description: 'Receive actionable feedback on code quality, performance, and maintainability. Elevate your team\'s coding standards.',
136
+ title: 'Suggest Code Improvements in MR',
137
+ tool: 'GitLab Duo',
138
+ },
139
+ {
140
+ category: 'Code Review',
141
+ complexity: 'Beginner',
142
+ description: 'Ensure code follows team conventions and style guides. Consistent enforcement without tedious manual checks.',
143
+ title: 'Check MR Against Coding Standards',
144
+ tool: 'GitLab Duo',
145
+ },
146
+ {
147
+ category: 'Code Review',
148
+ complexity: 'Intermediate',
149
+ description: 'Identify security vulnerabilities during code review. Catch SQL injection, XSS, and other risks early.',
150
+ title: 'Identify Security Issues in MR',
151
+ tool: 'GitLab Duo',
152
+ },
153
+ {
154
+ category: 'Code Review',
155
+ complexity: 'Beginner',
156
+ description: 'Evaluate if an MR includes adequate tests for new functionality. Identify gaps before they reach production.',
157
+ title: 'Assess MR Test Coverage',
158
+ tool: 'GitLab Duo',
159
+ },
160
+ {
161
+ category: 'Code Review',
162
+ complexity: 'Beginner',
163
+ description: 'Assess how proposed changes will affect system performance. Catch complexity issues and bottlenecks early.',
164
+ title: 'Explain MR Impact on Performance',
165
+ tool: 'GitLab Duo',
166
+ },
167
+ {
168
+ category: 'Code Review',
169
+ complexity: 'Beginner',
170
+ description: 'Auto-generate comprehensive MR descriptions including what changed, testing steps, and related issues.',
171
+ title: 'Generate MR Description',
172
+ tool: 'GitLab Duo',
173
+ },
174
+ {
175
+ category: 'Code Review',
176
+ complexity: 'Beginner',
177
+ description: 'Detect if changes break existing APIs, contracts, or functionality. Prevent downstream breakages.',
178
+ title: 'Identify Breaking Changes in MR',
179
+ tool: 'GitLab Duo',
180
+ },
181
+ {
182
+ category: 'Documentation',
183
+ complexity: 'Beginner',
184
+ description: 'Automatically compile release notes from merged MRs. Group changes by type: features, fixes, breaking changes.',
185
+ title: 'Generate Release Notes from MRs',
186
+ tool: 'GitLab Duo',
187
+ },
188
+ {
189
+ category: 'Documentation',
190
+ complexity: 'Beginner',
191
+ description: 'Convert support tickets into properly formatted, labeled issues. Streamline your support-to-development workflow.',
192
+ title: 'Create Issue from Support Ticket',
193
+ tool: 'GitLab Duo',
194
+ },
195
+ {
196
+ category: 'Code Quality',
197
+ complexity: 'Beginner',
198
+ description: 'Improve code readability with better names, simplified logic, and clearer structure. Make code self-documenting.',
199
+ title: 'Refactor for Better Readability',
200
+ tool: 'GitLab Duo',
201
+ },
202
+ {
203
+ category: 'Code Quality',
204
+ complexity: 'Beginner',
205
+ description: 'Update legacy code to use current language features and best practices. Modernize without breaking functionality.',
206
+ title: 'Modernize Legacy Code',
207
+ tool: 'GitLab Duo',
208
+ },
209
+ {
210
+ category: 'Code Quality',
211
+ complexity: 'Advanced',
212
+ description: 'Break down complex functions into testable, maintainable components. Reduce cognitive load for future developers.',
213
+ title: 'Reduce Code Complexity',
214
+ tool: 'GitLab Duo',
215
+ },
216
+ {
217
+ category: 'Code Quality',
218
+ complexity: 'Beginner',
219
+ description: 'Find and safely remove unused code, deprecated methods, and commented-out blocks. Keep your codebase lean.',
220
+ title: 'Remove Dead Code',
221
+ tool: 'GitLab Duo',
222
+ },
223
+ {
224
+ category: 'Code Quality',
225
+ complexity: 'Beginner',
226
+ description: 'Improve algorithmic efficiency while maintaining correctness. Optimize hot paths for performance gains.',
227
+ title: 'Optimize Algorithm Performance',
228
+ tool: 'GitLab Duo',
229
+ },
230
+ {
231
+ category: 'Code Quality',
232
+ complexity: 'Advanced',
233
+ description: 'Identify and consolidate duplicate code into reusable components. Apply DRY principles systematically.',
234
+ title: 'Consolidate Duplicate Code',
235
+ tool: 'GitLab Duo',
236
+ },
237
+ {
238
+ category: 'Planning & Architecture',
239
+ complexity: 'Intermediate',
240
+ description: 'Define architecture, components, and integration points for new features. Start projects with solid foundations.',
241
+ title: 'Design New Feature Architecture',
242
+ tool: 'GitLab Duo',
243
+ },
244
+ {
245
+ category: 'Testing',
246
+ complexity: 'Beginner',
247
+ description: 'Generate comprehensive unit tests covering happy paths, edge cases, and error conditions automatically.',
248
+ title: 'Generate Unit Tests',
249
+ tool: 'GitLab Duo',
250
+ },
251
+ {
252
+ category: 'Testing',
253
+ complexity: 'Beginner',
254
+ description: 'Create realistic test datasets including valid records, edge cases, and boundary conditions.',
255
+ title: 'Generate Test Data',
256
+ tool: 'GitLab Duo',
257
+ },
258
+ {
259
+ category: 'Testing',
260
+ complexity: 'Beginner',
261
+ description: 'Understand why tests fail, identify root causes, and determine if the code or test needs fixing.',
262
+ title: 'Explain Test Failures',
263
+ tool: 'GitLab Duo',
264
+ },
265
+ {
266
+ category: 'Debugging',
267
+ complexity: 'Beginner',
268
+ description: 'Diagnose CI/CD failures quickly with root cause analysis and fix suggestions.',
269
+ title: 'Debug Failing Pipeline',
270
+ tool: 'GitLab Duo',
271
+ },
272
+ {
273
+ category: 'Debugging',
274
+ complexity: 'Beginner',
275
+ description: 'Rapidly diagnose production incidents with systematic troubleshooting guidance.',
276
+ title: 'Troubleshoot Production Issue',
277
+ tool: 'GitLab Duo',
278
+ },
279
+ {
280
+ category: 'Debugging',
281
+ complexity: 'Advanced',
282
+ description: 'Parse complex stack traces to identify error origins and suggest fixes.',
283
+ title: 'Analyze Stack Trace',
284
+ tool: 'GitLab Duo',
285
+ },
286
+ {
287
+ category: 'Debugging',
288
+ complexity: 'Beginner',
289
+ description: 'Trace bugs from symptoms to root causes. Find where problems actually originate.',
290
+ title: 'Find Root Cause of Bug',
291
+ tool: 'GitLab Duo',
292
+ },
293
+ {
294
+ category: 'Security',
295
+ complexity: 'Intermediate',
296
+ description: 'Triage security scan results by real risk vs false positives. Prioritize remediation effectively.',
297
+ title: 'Analyze Security Scan Results',
298
+ tool: 'Duo Security Analyst',
299
+ },
300
+ {
301
+ category: 'Security',
302
+ complexity: 'Intermediate',
303
+ description: 'Proactive security review for injection vulnerabilities, auth flaws, and data exposure risks.',
304
+ title: 'Review Code for Security Issues',
305
+ tool: 'Duo Security Analyst',
306
+ },
307
+ {
308
+ category: 'DevOps',
309
+ complexity: 'Intermediate',
310
+ description: 'Optimize CI/CD pipelines for speed, security, and reliability. Apply GitLab best practices.',
311
+ title: 'Implement CI/CD Best Practices',
312
+ tool: 'GitLab Duo',
313
+ },
314
+ {
315
+ category: 'Collaboration',
316
+ complexity: 'Beginner',
317
+ description: 'Think through approaches collaboratively. Get challenged on tradeoffs and edge cases you might miss.',
318
+ title: 'AI Pairing Partner for Exploring Approaches',
319
+ tool: 'GitLab Duo',
320
+ },
321
+ {
322
+ category: 'Collaboration',
323
+ complexity: 'Beginner',
324
+ description: 'Explain problems systematically to reveal solutions. Always-available rubber duck debugging partner.',
325
+ title: 'Rubber Duck Debugging with AI',
326
+ tool: 'GitLab Duo',
327
+ },
328
+ {
329
+ category: 'Code Understanding',
330
+ complexity: 'Advanced',
331
+ description: 'Explore unfamiliar codebases conversationally. Understand architecture and key dependencies interactively.',
332
+ title: 'Exploratory Code Understanding',
333
+ tool: 'GitLab Duo',
334
+ },
335
+ ];
@@ -1,11 +1,12 @@
1
1
  import pino from 'pino';
2
- const isDev = process.env.NODE_ENV !== 'production';
3
2
  export const logger = pino({
4
3
  level: process.env.LOG_LEVEL ?? 'info',
5
- ...(isDev && {
6
- transport: {
7
- options: { colorize: true },
8
- target: 'pino-pretty',
4
+ transport: {
5
+ options: {
6
+ colorize: true,
7
+ ignore: 'pid,hostname',
8
+ translateTime: 'SYS:standard',
9
9
  },
10
- }),
10
+ target: 'pino-pretty',
11
+ },
11
12
  });
@@ -46,7 +46,7 @@
46
46
  "question": {
47
47
  "description": "The question to ask the agent",
48
48
  "name": "question",
49
- "required": true
49
+ "required": false
50
50
  }
51
51
  },
52
52
  "description": "Ask questions about your CI/CD pipelines, logs, and sustainability",
@@ -480,5 +480,5 @@
480
480
  ]
481
481
  }
482
482
  },
483
- "version": "0.1.4"
483
+ "version": "0.1.7"
484
484
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "duoops",
3
3
  "description": "Toolset for Explainable and Sustainable CI on Gitlab.",
4
- "version": "0.1.4",
4
+ "version": "0.1.7",
5
5
  "author": "Younes Laaroussi",
6
6
  "bin": {
7
7
  "duoops": "./bin/run.js"
@@ -31,7 +31,8 @@
31
31
  "open": "^11.0.0",
32
32
  "pino": "^10.3.1",
33
33
  "remark-gfm": "^4.0.1",
34
- "zod": "^4.3.6"
34
+ "zod": "^4.3.6",
35
+ "pino-pretty": "^13.1.3"
35
36
  },
36
37
  "devDependencies": {
37
38
  "@eslint/compat": "^1",
@@ -50,7 +51,6 @@
50
51
  "eslint-config-prettier": "^10",
51
52
  "mocha": "^10",
52
53
  "oclif": "^4",
53
- "pino-pretty": "^13.1.3",
54
54
  "shx": "^0.3.3",
55
55
  "ts-node": "^10",
56
56
  "typescript": "^5"
@@ -68,11 +68,14 @@ duoops-measure-analysis:
68
68
  DUOOPS_VERSION: $[[ inputs.duoops_version ]]
69
69
  before_script:
70
70
  - |
71
- if ! command -v duoops &> /dev/null; then
72
- echo "duoops binary not found on runner. Ensure the runner image installs duoops." >&2
73
- exit 1
71
+ if command -v duoops &> /dev/null; then
72
+ echo "duoops already installed"
73
+ else
74
+ apt-get update && apt-get install -y curl
75
+ curl -fsSL https://deb.nodesource.com/setup_20.x | bash -
76
+ apt-get install -y nodejs
77
+ npm install -g duoops@${DUOOPS_VERSION}
74
78
  fi
75
- echo "Using $(duoops --version)"
76
79
  script:
77
80
  - |
78
81
  PROVIDER=${PROVIDER:-$[[ inputs.provider ]]}