agent-master-devsecops 3.9.0 → 5.1.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 (82) hide show
  1. package/README.md +205 -371
  2. package/agents/AGENT_DEVSECOPS.md +32 -417
  3. package/agents/AGENT_INFRA.md +31 -0
  4. package/agents/AGENT_ORCHESTRATOR.md +39 -264
  5. package/agents/AGENT_QA.md +58 -186
  6. package/agents/AGENT_SCRUM.md +23 -190
  7. package/agents/AGENT_SRE.md +22 -173
  8. package/agents/AGENT_UIUX.md +26 -162
  9. package/docs/ARCHITECTURE.md +152 -148
  10. package/docs/CALCULATIONS.md +17 -17
  11. package/docs/CHANGELOG.md +112 -49
  12. package/docs/ENGINEERING_RULES.md +56 -252
  13. package/docs/IDEAS.md +17 -17
  14. package/docs/LOCAL_BACKLOG.md +20 -0
  15. package/docs/STATE.md +111 -43
  16. package/docs/playbooks/PLAYBOOK_CIRCUIT_BREAKER_LLM.md +58 -58
  17. package/docs/playbooks/PLAYBOOK_OPENTELEMETRY_TRACING.md +58 -58
  18. package/package.json +59 -47
  19. package/scripts/auditors/a11y_auditor.js +462 -0
  20. package/scripts/auditors/code_quality_auditor.js +444 -0
  21. package/scripts/auditors/contract_test_validator.js +396 -0
  22. package/scripts/auditors/eval_harness.js +213 -0
  23. package/scripts/auditors/git_hygiene_linter.js +391 -0
  24. package/scripts/auditors/pr_reviewer.js +627 -0
  25. package/scripts/auditors/sast_scanner.js +442 -0
  26. package/scripts/auditors/sca_dependency_auditor.js +673 -0
  27. package/scripts/{bootstrap_cli.js → bin/bootstrap_cli.js} +597 -468
  28. package/scripts/bin/domain_idea_miner.js +658 -0
  29. package/scripts/bin/smart_onboarding.js +905 -0
  30. package/scripts/{web_inspector.js → bin/web_inspector.js} +578 -355
  31. package/scripts/core/architecture_advisor.js +378 -0
  32. package/scripts/core/ast_skeletonizer.js +413 -0
  33. package/scripts/core/autonomous_remediation_engine.js +305 -0
  34. package/scripts/{circuit_breaker.js → core/circuit_breaker.js} +546 -330
  35. package/scripts/core/context_compressor.js +237 -0
  36. package/scripts/core/fast_feature_scaffold.js +840 -0
  37. package/scripts/core/hot_state_cache.js +238 -0
  38. package/scripts/core/knowledge_gateway.js +888 -0
  39. package/scripts/{magic_prompt_generator.js → core/magic_prompt_generator.js} +250 -205
  40. package/scripts/{multi_agent_orchestrator.js → core/multi_agent_orchestrator.js} +421 -258
  41. package/scripts/{otel_tracer.js → core/otel_tracer.js} +335 -228
  42. package/scripts/{perf_benchmark.js → core/perf_benchmark.js} +212 -153
  43. package/scripts/core/sarif_engine.js +299 -0
  44. package/scripts/{sre_remediation_engine.js → core/sre_remediation_engine.js} +236 -174
  45. package/scripts/{universal_packager.js → core/universal_packager.js} +357 -313
  46. package/scripts/integrations/atlassian_client.js +600 -0
  47. package/scripts/integrations/atlassian_sync_action.js +576 -0
  48. package/scripts/integrations/confluence_sync.js +684 -0
  49. package/scripts/integrations/credentials_guard.js +500 -0
  50. package/scripts/integrations/jira_manager.js +722 -0
  51. package/scripts/mcp/handlers/atlassian_handlers.js +300 -0
  52. package/scripts/mcp/handlers/core_handlers.js +419 -0
  53. package/scripts/mcp/handlers/qa_handlers.js +502 -0
  54. package/scripts/mcp/handlers/rules_handlers.js +379 -0
  55. package/scripts/mcp/handlers/scaffold_handlers.js +334 -0
  56. package/scripts/mcp/handlers/sre_handlers.js +443 -0
  57. package/scripts/mcp/resources_registry.js +453 -0
  58. package/scripts/mcp/server.js +408 -0
  59. package/scripts/mcp/tool_handlers.js +444 -0
  60. package/scripts/mcp/tools_registry.js +1123 -0
  61. package/scripts/mcp_server.js +236 -1884
  62. package/.cursorignore +0 -23
  63. package/agents/compact/AGENT_ORCHESTRATOR_COMPACTO.md +0 -53
  64. package/scripts/a11y_auditor.js +0 -187
  65. package/scripts/ast_skeletonizer.js +0 -220
  66. package/scripts/atlassian_client.js +0 -238
  67. package/scripts/atlassian_sync_action.js +0 -269
  68. package/scripts/code_quality_auditor.js +0 -142
  69. package/scripts/confluence_sync.js +0 -337
  70. package/scripts/context_compressor.js +0 -139
  71. package/scripts/contract_test_validator.js +0 -166
  72. package/scripts/credentials_guard.js +0 -216
  73. package/scripts/domain_idea_miner.js +0 -364
  74. package/scripts/eval_harness.js +0 -100
  75. package/scripts/fast_feature_scaffold.js +0 -338
  76. package/scripts/git_hygiene_linter.js +0 -186
  77. package/scripts/hot_state_cache.js +0 -95
  78. package/scripts/jira_manager.js +0 -408
  79. package/scripts/pr_reviewer.js +0 -373
  80. package/scripts/sast_scanner.js +0 -180
  81. package/scripts/sca_dependency_auditor.js +0 -167
  82. package/scripts/smart_onboarding.js +0 -610
@@ -1,408 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * scripts/jira_manager.js
4
- *
5
- * Gerenciador Unificado do Jira: Padronização de Kanban, WIP Limits, Sprints e Time-Tracking.
6
- * Consolida o controle de fluxo ágil dos 3 Kanbans canônicos ("A fazer", "Em andamento", "Concluído")
7
- * com o registro automatizado de worklogs e timetracking durante o ciclo de desenvolvimento.
8
- *
9
- * Governança: Tríade Git + Jira + Confluence (Regra 11 e AGENT_SCRUM).
10
- */
11
-
12
- 'use strict';
13
-
14
- const fs = require('node:fs');
15
- const path = require('node:path');
16
-
17
- const {
18
- getAtlassianCredentials,
19
- requestAtlassian,
20
- getGitMetadata
21
- } = require('./atlassian_client.js');
22
-
23
- // ==========================================
24
- // 1. KANBAN CANÔNICO & PADRONIZAÇÃO DE QUADRO
25
- // ==========================================
26
-
27
- const CANONICAL_KANBANS = Object.freeze({
28
- TODO: 'A fazer',
29
- IN_PROGRESS: 'Em andamento',
30
- DONE: 'Concluído'
31
- });
32
-
33
- const CANONICAL_COLUMNS_LIST = [
34
- CANONICAL_KANBANS.TODO,
35
- CANONICAL_KANBANS.IN_PROGRESS,
36
- CANONICAL_KANBANS.DONE
37
- ];
38
-
39
- /**
40
- * Sanitiza o summary de um card do Jira, removendo chaves redundantes do título.
41
- * Exemplo: "[PROJ-123] Deploy de Produção" -> "Deploy de Produção"
42
- */
43
- function sanitizeIssueSummary(summary = '') {
44
- if (!summary) return '';
45
- return summary.replace(/^\s*\[[A-Z]{2,10}-\d+\]\s*[:-]?\s*/i, '').trim();
46
- }
47
-
48
- /**
49
- * Valida o limite de trabalho em progresso (WIP Limit).
50
- */
51
- function checkWipLimit(inProgressCount = 0, maxWip = 2) {
52
- return {
53
- inProgressCount,
54
- maxWip,
55
- isSaturated: inProgressCount >= maxWip,
56
- canPullNewTask: inProgressCount < maxWip,
57
- alertMessage: inProgressCount >= maxWip
58
- ? `WIP SATURADO: ${inProgressCount} tarefas ativas em andamento (limite máximo: ${maxWip}). Conclua tarefas antes de puxar novas.`
59
- : null
60
- };
61
- }
62
-
63
- /**
64
- * Mapeia qualquer status ou nome de coluna legado do Jira para uma das 3 colunas canônicas.
65
- */
66
- function resolveCanonicalColumn(statusName = '', statusCategory = '') {
67
- const normName = String(statusName).trim().toLowerCase();
68
- const normCat = String(statusCategory).trim().toLowerCase();
69
-
70
- // 1. Concluído / Done
71
- if (
72
- normName.includes('concl') ||
73
- normName.includes('done') ||
74
- normName.includes('finaliz') ||
75
- normName.includes('resolv') ||
76
- normCat.includes('conclu') ||
77
- normCat.includes('done') ||
78
- normCat.includes('complete')
79
- ) {
80
- return CANONICAL_KANBANS.DONE;
81
- }
82
-
83
- // 2. Em andamento / In Progress
84
- if (
85
- normName.includes('andamento') ||
86
- normName.includes('progress') ||
87
- normName.includes('desenvolv') ||
88
- normName.includes('análise') ||
89
- normName.includes('analise') ||
90
- normCat.includes('andamento') ||
91
- normCat.includes('progress') ||
92
- normCat.includes('indeterminate')
93
- ) {
94
- return CANONICAL_KANBANS.IN_PROGRESS;
95
- }
96
-
97
- // 3. A fazer / To Do / Backlog
98
- return CANONICAL_KANBANS.TODO;
99
- }
100
-
101
- /**
102
- * Normaliza e consolida as colunas de uma configuração de Board do Jira para os 3 Kanbans padrão.
103
- */
104
- function standardizeBoardColumns(boardConfig = {}) {
105
- const rawColumns = (boardConfig && boardConfig.columnConfig && boardConfig.columnConfig.columns) || [];
106
-
107
- const standardized = {
108
- canonicalColumns: [...CANONICAL_COLUMNS_LIST],
109
- columns: [
110
- { name: CANONICAL_KANBANS.TODO, statuses: [] },
111
- { name: CANONICAL_KANBANS.IN_PROGRESS, statuses: [] },
112
- { name: CANONICAL_KANBANS.DONE, statuses: [] }
113
- ],
114
- remappedCount: 0
115
- };
116
-
117
- const todoCol = standardized.columns[0];
118
- const inProgCol = standardized.columns[1];
119
- const doneCol = standardized.columns[2];
120
-
121
- for (const col of rawColumns) {
122
- const canonicalTarget = resolveCanonicalColumn(col.name);
123
- const statuses = col.statuses || [];
124
-
125
- if (canonicalTarget === CANONICAL_KANBANS.DONE) {
126
- doneCol.statuses.push(...statuses);
127
- } else if (canonicalTarget === CANONICAL_KANBANS.IN_PROGRESS) {
128
- inProgCol.statuses.push(...statuses);
129
- } else {
130
- todoCol.statuses.push(...statuses);
131
- }
132
-
133
- if (col.name !== canonicalTarget) {
134
- standardized.remappedCount++;
135
- }
136
- }
137
-
138
- return standardized;
139
- }
140
-
141
- /**
142
- * Constrói a consulta JQL padronizada para uma das 3 colunas canônicas no Jira.
143
- */
144
- function buildCanonicalJql(projectKey, canonicalColumn) {
145
- if (!projectKey) throw new Error('projectKey é obrigatório para construir JQL.');
146
-
147
- switch (canonicalColumn) {
148
- case CANONICAL_KANBANS.TODO:
149
- return `project = "${projectKey}" AND statusCategory in ("To Do", "Undefined") ORDER BY rank ASC, created ASC`;
150
- case CANONICAL_KANBANS.IN_PROGRESS:
151
- return `project = "${projectKey}" AND statusCategory in ("In Progress") ORDER BY rank ASC, updated DESC`;
152
- case CANONICAL_KANBANS.DONE:
153
- return `project = "${projectKey}" AND statusCategory in ("Done") ORDER BY updated DESC`;
154
- default:
155
- throw new Error(`Coluna desconhecida: "${canonicalColumn}". Use: ${CANONICAL_COLUMNS_LIST.join(', ')}`);
156
- }
157
- }
158
-
159
- /**
160
- * Valida se há pelo menos um sprint ativo na esteira para evitar "quadro de sprints ativo vazio".
161
- */
162
- function validateSprintHealth(sprints = []) {
163
- const activeSprints = sprints.filter(s => s.state === 'active');
164
- const futureSprints = sprints.filter(s => s.state === 'future');
165
- const closedSprints = sprints.filter(s => s.state === 'closed');
166
-
167
- return {
168
- totalSprints: sprints.length,
169
- activeCount: activeSprints.length,
170
- futureCount: futureSprints.length,
171
- closedCount: closedSprints.length,
172
- hasActiveSprint: activeSprints.length > 0,
173
- warning: activeSprints.length === 0
174
- ? 'ALERTA DE FLUXO: Nenhuma sprint está ativa no Jira. A tela de Sprints Ativos ficará em branco até que uma sprint seja iniciada.'
175
- : null
176
- };
177
- }
178
-
179
- /**
180
- * Avalia candidato do backlog com base no contexto do projeto (Regra 14).
181
- */
182
- function evaluateFullDevCandidate(candidate, projectContext = {}) {
183
- const { title = '', description = '' } = candidate;
184
- const { stack = 'generic', domain = 'general' } = projectContext;
185
-
186
- const text = `${title} ${description}`.toLowerCase();
187
- const evaluation = {
188
- valid: true,
189
- candidateTitle: sanitizeIssueSummary(title),
190
- reasons: [],
191
- recommendedAction: 'PROCEED_TO_IN_PROGRESS'
192
- };
193
-
194
- const overengineeringKeywords = ['blockchain', 'smart contract', 'quantum computing', 'microservices mesh'];
195
- const matchedOver = overengineeringKeywords.filter(k => text.includes(k));
196
- if (matchedOver.length > 0 && !String(domain).toLowerCase().includes('crypto')) {
197
- evaluation.valid = false;
198
- evaluation.reasons.push(`Overengineering ou desconexão com domínio (${domain}): detectado [${matchedOver.join(', ')}]`);
199
- evaluation.recommendedAction = 'DROP_OR_REJECT';
200
- }
201
-
202
- if (text.includes('kubernetes') && (stack.includes('cli') || stack.includes('desktop'))) {
203
- evaluation.valid = false;
204
- evaluation.reasons.push(`Incompatibilidade com stack (${stack}): infraestrutura desproporcional`);
205
- evaluation.recommendedAction = 'DROP_OR_REJECT';
206
- }
207
-
208
- return evaluation;
209
- }
210
-
211
- /**
212
- * Orquestra o ciclo do Modo Full Developer baseado nos 3 Kanbans canônicos.
213
- */
214
- function processFullDevPipeline(tasks = [], projectContext = {}, maxWip = 2) {
215
- const todoTasks = tasks.filter(t => resolveCanonicalColumn(t.status || t.statusName, t.statusCategory) === CANONICAL_KANBANS.TODO);
216
- const inProgressTasks = tasks.filter(t => resolveCanonicalColumn(t.status || t.statusName, t.statusCategory) === CANONICAL_KANBANS.IN_PROGRESS);
217
- const doneTasks = tasks.filter(t => resolveCanonicalColumn(t.status || t.statusName, t.statusCategory) === CANONICAL_KANBANS.DONE);
218
-
219
- const wipStatus = checkWipLimit(inProgressTasks.length, maxWip);
220
-
221
- const results = {
222
- totalTasks: tasks.length,
223
- counts: {
224
- todo: todoTasks.length,
225
- inProgress: inProgressTasks.length,
226
- done: doneTasks.length
227
- },
228
- wipStatus,
229
- activeTask: inProgressTasks[0] || null,
230
- activeTasks: inProgressTasks,
231
- nextApprovedTask: null,
232
- rejectedTasks: [],
233
- lifecyclePlan: []
234
- };
235
-
236
- if (wipStatus.isSaturated) {
237
- results.lifecyclePlan.push({
238
- step: 'CONCLUDE_ACTIVE_TASKS',
239
- message: wipStatus.alertMessage
240
- });
241
- return results;
242
- }
243
-
244
- for (const candidate of todoTasks) {
245
- const evalRes = evaluateFullDevCandidate(candidate, projectContext);
246
- if (evalRes.valid && !results.nextApprovedTask) {
247
- results.nextApprovedTask = candidate;
248
- results.lifecyclePlan.push({
249
- step: 'TRANSITION_AND_START',
250
- taskKey: candidate.key || candidate.id,
251
- cleanSummary: evalRes.candidateTitle,
252
- from: CANONICAL_KANBANS.TODO,
253
- to: CANONICAL_KANBANS.IN_PROGRESS,
254
- message: 'Ideia/tarefa aprovada pelo filtro de sanidade (Regra 14). Transicionar para "Em andamento" e iniciar ciclo.'
255
- });
256
- } else if (!evalRes.valid) {
257
- results.rejectedTasks.push({
258
- taskKey: candidate.key || candidate.id,
259
- reasons: evalRes.reasons
260
- });
261
- }
262
- }
263
-
264
- return results;
265
- }
266
-
267
- // ==========================================
268
- // 2. TIME TRACKING & WORKLOGS
269
- // ==========================================
270
-
271
- function extractIssueKeys(text) {
272
- if (!text) return [];
273
- const matches = text.match(/\b[A-Z]{2,10}-\d+\b/g) || [];
274
- return [...new Set(matches.map(k => k.toUpperCase()))];
275
- }
276
-
277
- async function getExistingWorklogs(credentials, issueKey) {
278
- const res = await requestAtlassian(credentials, 'GET', `/rest/api/3/issue/${issueKey}/worklog`);
279
- if (res.status === 200 && res.body?.worklogs) {
280
- return res.body.worklogs;
281
- }
282
- return [];
283
- }
284
-
285
- async function logWorkTime(credentials, issueKey, timeSpentSeconds, commentText) {
286
- const startedTime = new Date().toISOString().replace('Z', '+0000');
287
- const payload = {
288
- timeSpentSeconds,
289
- started: startedTime,
290
- comment: {
291
- type: 'doc',
292
- version: 1,
293
- content: [
294
- {
295
- type: 'paragraph',
296
- content: [{ type: 'text', text: commentText }]
297
- }
298
- ]
299
- }
300
- };
301
-
302
- return requestAtlassian(credentials, 'POST', `/rest/api/3/issue/${issueKey}/worklog`, payload);
303
- }
304
-
305
- async function ensureInProgress(credentials, issueKey) {
306
- try {
307
- const issueRes = await requestAtlassian(credentials, 'GET', `/rest/api/3/issue/${issueKey}?fields=status`);
308
- if (issueRes.status === 200 && issueRes.body?.fields?.status) {
309
- const currentStatus = issueRes.body.fields.status.name.toLowerCase();
310
- if (currentStatus.includes('backlog') || currentStatus.includes('fazer') || currentStatus.includes('to do')) {
311
- await requestAtlassian(credentials, 'POST', `/rest/api/3/issue/${issueKey}/transitions`, {
312
- transition: { id: '31' }
313
- });
314
- console.log(`[Jira Manager] 🔄 Card ${issueKey} transicionado para "Em andamento".`);
315
- }
316
- }
317
- } catch (err) {
318
- console.warn(`[Jira Manager] Aviso ao checar status de ${issueKey}:`, err.message);
319
- }
320
- }
321
-
322
- async function trackIssueTime(credentials, key, gitMeta) {
323
- await ensureInProgress(credentials, key);
324
-
325
- const existing = await getExistingWorklogs(credentials, key);
326
- const tag = `[commit:${gitMeta.shortSha}]`;
327
- const alreadyLogged = existing.some(wl => {
328
- const text = JSON.stringify(wl.comment || {});
329
- return text.includes(tag);
330
- });
331
-
332
- if (alreadyLogged) {
333
- console.log(`[Jira Manager] ℹ Tempo já registrado anteriormente para o commit ${gitMeta.shortSha} no card ${key}.`);
334
- return { key, status: 'already_logged' };
335
- }
336
-
337
- const timeSpentSeconds = 900; // 15 minutos padrão
338
- const comment = `Tempo de andamento registrado automaticamente via esteira de CI/CD.\nAutor: ${gitMeta.authorName || 'DevSecOps Bot'}\nCommit: ${gitMeta.shortSha} (${gitMeta.commitMessage.split('\n')[0]})\n${tag}`;
339
-
340
- const res = await logWorkTime(credentials, key, timeSpentSeconds, comment);
341
- if (res.status === 201) {
342
- console.log(`[Jira Manager] ✅ 15m de andamento registrados no Jira para ${key} (Commit ${gitMeta.shortSha}).`);
343
- return { key, status: 'logged', timeSpentSeconds };
344
- } else {
345
- console.warn(`[Jira Manager] ⚠️ Falha ao registrar tempo para ${key}: HTTP ${res.status}`);
346
- return { key, status: 'failed', code: res.status };
347
- }
348
- }
349
-
350
- async function runTimeTracking() {
351
- console.log('--- Início da Execução do Jira Time Tracking Automático ---');
352
- const credentials = getAtlassianCredentials();
353
- if (!credentials.isConfigured) {
354
- console.log('[Jira Manager] ℹ Credenciais Atlassian não configuradas. Pulando registro de tempo.');
355
- return;
356
- }
357
-
358
- const gitMeta = getGitMetadata();
359
- const keys = [
360
- ...extractIssueKeys(gitMeta.branch),
361
- ...extractIssueKeys(gitMeta.commitMessage)
362
- ];
363
-
364
- const uniqueKeys = [...new Set(keys)];
365
- if (uniqueKeys.length === 0) {
366
- console.log('[Jira Manager] ℹ Nenhuma chave Jira identificada na branch ou mensagem de commit.');
367
- return;
368
- }
369
-
370
- console.log(`[Jira Manager] Chaves detectadas: ${uniqueKeys.join(', ')}`);
371
- for (const key of uniqueKeys) {
372
- try {
373
- await trackIssueTime(credentials, key, gitMeta);
374
- } catch (err) {
375
- console.error(`[Jira Manager] ❌ Erro ao processar tempo para ${key}:`, err.message);
376
- }
377
- }
378
- }
379
-
380
- if (require.main === module) {
381
- const args = process.argv.slice(2);
382
- if (args.includes('--track')) {
383
- runTimeTracking().catch(console.error);
384
- } else {
385
- console.log('Jira Manager operacional. Use --track para executar apontamento de horas.');
386
- }
387
- }
388
-
389
- module.exports = {
390
- // Kanban
391
- CANONICAL_KANBANS,
392
- CANONICAL_COLUMNS_LIST,
393
- sanitizeIssueSummary,
394
- checkWipLimit,
395
- resolveCanonicalColumn,
396
- standardizeBoardColumns,
397
- buildCanonicalJql,
398
- validateSprintHealth,
399
- evaluateFullDevCandidate,
400
- processFullDevPipeline,
401
- // Time Tracking
402
- extractIssueKeys,
403
- getExistingWorklogs,
404
- logWorkTime,
405
- ensureInProgress,
406
- trackIssueTime,
407
- runTimeTracking
408
- };