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.
- package/README.md +205 -371
- package/agents/AGENT_DEVSECOPS.md +32 -417
- package/agents/AGENT_INFRA.md +31 -0
- package/agents/AGENT_ORCHESTRATOR.md +39 -264
- package/agents/AGENT_QA.md +58 -186
- package/agents/AGENT_SCRUM.md +23 -190
- package/agents/AGENT_SRE.md +22 -173
- package/agents/AGENT_UIUX.md +26 -162
- package/docs/ARCHITECTURE.md +152 -148
- package/docs/CALCULATIONS.md +17 -17
- package/docs/CHANGELOG.md +112 -49
- package/docs/ENGINEERING_RULES.md +56 -252
- package/docs/IDEAS.md +17 -17
- package/docs/LOCAL_BACKLOG.md +20 -0
- package/docs/STATE.md +111 -43
- package/docs/playbooks/PLAYBOOK_CIRCUIT_BREAKER_LLM.md +58 -58
- package/docs/playbooks/PLAYBOOK_OPENTELEMETRY_TRACING.md +58 -58
- package/package.json +59 -47
- package/scripts/auditors/a11y_auditor.js +462 -0
- package/scripts/auditors/code_quality_auditor.js +444 -0
- package/scripts/auditors/contract_test_validator.js +396 -0
- package/scripts/auditors/eval_harness.js +213 -0
- package/scripts/auditors/git_hygiene_linter.js +391 -0
- package/scripts/auditors/pr_reviewer.js +627 -0
- package/scripts/auditors/sast_scanner.js +442 -0
- package/scripts/auditors/sca_dependency_auditor.js +673 -0
- package/scripts/{bootstrap_cli.js → bin/bootstrap_cli.js} +597 -468
- package/scripts/bin/domain_idea_miner.js +658 -0
- package/scripts/bin/smart_onboarding.js +905 -0
- package/scripts/{web_inspector.js → bin/web_inspector.js} +578 -355
- package/scripts/core/architecture_advisor.js +378 -0
- package/scripts/core/ast_skeletonizer.js +413 -0
- package/scripts/core/autonomous_remediation_engine.js +305 -0
- package/scripts/{circuit_breaker.js → core/circuit_breaker.js} +546 -330
- package/scripts/core/context_compressor.js +237 -0
- package/scripts/core/fast_feature_scaffold.js +840 -0
- package/scripts/core/hot_state_cache.js +238 -0
- package/scripts/core/knowledge_gateway.js +888 -0
- package/scripts/{magic_prompt_generator.js → core/magic_prompt_generator.js} +250 -205
- package/scripts/{multi_agent_orchestrator.js → core/multi_agent_orchestrator.js} +421 -258
- package/scripts/{otel_tracer.js → core/otel_tracer.js} +335 -228
- package/scripts/{perf_benchmark.js → core/perf_benchmark.js} +212 -153
- package/scripts/core/sarif_engine.js +299 -0
- package/scripts/{sre_remediation_engine.js → core/sre_remediation_engine.js} +236 -174
- package/scripts/{universal_packager.js → core/universal_packager.js} +357 -313
- package/scripts/integrations/atlassian_client.js +600 -0
- package/scripts/integrations/atlassian_sync_action.js +576 -0
- package/scripts/integrations/confluence_sync.js +684 -0
- package/scripts/integrations/credentials_guard.js +500 -0
- package/scripts/integrations/jira_manager.js +722 -0
- package/scripts/mcp/handlers/atlassian_handlers.js +300 -0
- package/scripts/mcp/handlers/core_handlers.js +419 -0
- package/scripts/mcp/handlers/qa_handlers.js +502 -0
- package/scripts/mcp/handlers/rules_handlers.js +379 -0
- package/scripts/mcp/handlers/scaffold_handlers.js +334 -0
- package/scripts/mcp/handlers/sre_handlers.js +443 -0
- package/scripts/mcp/resources_registry.js +453 -0
- package/scripts/mcp/server.js +408 -0
- package/scripts/mcp/tool_handlers.js +444 -0
- package/scripts/mcp/tools_registry.js +1123 -0
- package/scripts/mcp_server.js +236 -1884
- package/.cursorignore +0 -23
- package/agents/compact/AGENT_ORCHESTRATOR_COMPACTO.md +0 -53
- package/scripts/a11y_auditor.js +0 -187
- package/scripts/ast_skeletonizer.js +0 -220
- package/scripts/atlassian_client.js +0 -238
- package/scripts/atlassian_sync_action.js +0 -269
- package/scripts/code_quality_auditor.js +0 -142
- package/scripts/confluence_sync.js +0 -337
- package/scripts/context_compressor.js +0 -139
- package/scripts/contract_test_validator.js +0 -166
- package/scripts/credentials_guard.js +0 -216
- package/scripts/domain_idea_miner.js +0 -364
- package/scripts/eval_harness.js +0 -100
- package/scripts/fast_feature_scaffold.js +0 -338
- package/scripts/git_hygiene_linter.js +0 -186
- package/scripts/hot_state_cache.js +0 -95
- package/scripts/jira_manager.js +0 -408
- package/scripts/pr_reviewer.js +0 -373
- package/scripts/sast_scanner.js +0 -180
- package/scripts/sca_dependency_auditor.js +0 -167
- package/scripts/smart_onboarding.js +0 -610
|
@@ -1,174 +1,236 @@
|
|
|
1
|
-
/**
|
|
2
|
-
*
|
|
3
|
-
* Coletor nativo de telemetria Prometheus 0.0.4,
|
|
4
|
-
*
|
|
5
|
-
* Em
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
const os = require('node:os');
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
this.
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
this.finopsMetrics.
|
|
29
|
-
this.finopsMetrics.
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
const
|
|
66
|
-
|
|
67
|
-
'#
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
'#
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
'#
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
'#
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
'#
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
'#
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
'#
|
|
86
|
-
|
|
87
|
-
`agent_llm_tokens_total{direction="
|
|
88
|
-
|
|
89
|
-
'#
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
'#
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Process Telemetry & Cache Lifecycle Controller (AGENT_SRE)
|
|
3
|
+
* Coletor nativo de telemetria de processo no formato Prometheus 0.0.4,
|
|
4
|
+
* analisador de métricas de memória/CPU e controlador de ciclo de vida de caches voláteis.
|
|
5
|
+
* Em conformidade com o Princípio 6 (Observabilidade e Confiabilidade).
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const os = require('node:os');
|
|
9
|
+
const { createSarifReport } = require('./sarif_engine.js');
|
|
10
|
+
|
|
11
|
+
class SreRemediationEngine {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.remediationsHistory = [];
|
|
14
|
+
this.alertCounter = {
|
|
15
|
+
MemoryPressureWarning: 0,
|
|
16
|
+
HighCpuUsage: 0,
|
|
17
|
+
CircuitBreakerTripped: 0
|
|
18
|
+
};
|
|
19
|
+
this.finopsMetrics = {
|
|
20
|
+
tokensInput: 0,
|
|
21
|
+
tokensOutput: 0,
|
|
22
|
+
tokensSaved: 0,
|
|
23
|
+
costUsd: 0.0
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
recordFinopsUsage(inputTokens = 0, outputTokens = 0, costUsd = 0.0) {
|
|
28
|
+
this.finopsMetrics.tokensInput += inputTokens;
|
|
29
|
+
this.finopsMetrics.tokensOutput += outputTokens;
|
|
30
|
+
this.finopsMetrics.costUsd += costUsd;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
recordFinopsSavings(tokensSaved = 0) {
|
|
34
|
+
this.finopsMetrics.tokensSaved += tokensSaved;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getMetricsSummary() {
|
|
38
|
+
const mem = process.memoryUsage();
|
|
39
|
+
const cpu = process.cpuUsage();
|
|
40
|
+
const uptimeSec = process.uptime();
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
timestamp: new Date().toISOString(),
|
|
44
|
+
uptimeSeconds: uptimeSec,
|
|
45
|
+
memory: {
|
|
46
|
+
rssBytes: mem.rss,
|
|
47
|
+
heapTotalBytes: mem.heapTotal,
|
|
48
|
+
heapUsedBytes: mem.heapUsed,
|
|
49
|
+
externalBytes: mem.external,
|
|
50
|
+
heapUsedPct: Math.round((mem.heapUsed / mem.heapTotal) * 100)
|
|
51
|
+
},
|
|
52
|
+
cpu: {
|
|
53
|
+
userSeconds: Math.round(cpu.user / 1e6 * 100) / 100,
|
|
54
|
+
systemSeconds: Math.round(cpu.system / 1e6 * 100) / 100
|
|
55
|
+
},
|
|
56
|
+
system: {
|
|
57
|
+
freememBytes: os.freemem(),
|
|
58
|
+
totalmemBytes: os.totalmem(),
|
|
59
|
+
loadavg: os.loadavg()
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
getPrometheusFormat() {
|
|
65
|
+
const summary = this.getMetricsSummary();
|
|
66
|
+
const lines = [
|
|
67
|
+
'# HELP process_cpu_user_seconds_total Total user CPU time spent in seconds.',
|
|
68
|
+
'# TYPE process_cpu_user_seconds_total counter',
|
|
69
|
+
`process_cpu_user_seconds_total ${summary.cpu.userSeconds}`,
|
|
70
|
+
'# HELP process_cpu_system_seconds_total Total system CPU time spent in seconds.',
|
|
71
|
+
'# TYPE process_cpu_system_seconds_total counter',
|
|
72
|
+
`process_cpu_system_seconds_total ${summary.cpu.systemSeconds}`,
|
|
73
|
+
'# HELP process_resident_memory_bytes Resident memory size in bytes.',
|
|
74
|
+
'# TYPE process_resident_memory_bytes gauge',
|
|
75
|
+
`process_resident_memory_bytes ${summary.memory.rssBytes}`,
|
|
76
|
+
'# HELP nodejs_heap_size_total_bytes Process heap total size from V8 in bytes.',
|
|
77
|
+
'# TYPE nodejs_heap_size_total_bytes gauge',
|
|
78
|
+
`nodejs_heap_size_total_bytes ${summary.memory.heapTotalBytes}`,
|
|
79
|
+
'# HELP nodejs_heap_size_used_bytes Process heap memory used in bytes.',
|
|
80
|
+
'# TYPE nodejs_heap_size_used_bytes gauge',
|
|
81
|
+
`nodejs_heap_size_used_bytes ${summary.memory.heapUsedBytes}`,
|
|
82
|
+
'# HELP agent_remediations_total Total number of auto-remediations triggered.',
|
|
83
|
+
'# TYPE agent_remediations_total counter',
|
|
84
|
+
`agent_remediations_total ${this.remediationsHistory.length}`,
|
|
85
|
+
'# HELP agent_llm_tokens_total Total tokens processed by the agent suite.',
|
|
86
|
+
'# TYPE agent_llm_tokens_total counter',
|
|
87
|
+
`agent_llm_tokens_total{direction="input"} ${this.finopsMetrics.tokensInput}`,
|
|
88
|
+
`agent_llm_tokens_total{direction="output"} ${this.finopsMetrics.tokensOutput}`,
|
|
89
|
+
'# HELP agent_llm_cost_usd_total Estimated cost in USD for LLM usage.',
|
|
90
|
+
'# TYPE agent_llm_cost_usd_total counter',
|
|
91
|
+
`agent_llm_cost_usd_total ${this.finopsMetrics.costUsd.toFixed(6)}`,
|
|
92
|
+
'# HELP agent_finops_tokens_saved_total Total tokens saved by FinOps optimizations.',
|
|
93
|
+
'# TYPE agent_finops_tokens_saved_total counter',
|
|
94
|
+
`agent_finops_tokens_saved_total ${this.finopsMetrics.tokensSaved}`
|
|
95
|
+
];
|
|
96
|
+
|
|
97
|
+
return lines.join('\n') + '\n';
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
evaluateAlerts(customThresholds = {}) {
|
|
101
|
+
const summary = this.getMetricsSummary();
|
|
102
|
+
const thresholds = {
|
|
103
|
+
maxHeapPct: customThresholds.maxHeapPct || 85,
|
|
104
|
+
maxHeapBytes: customThresholds.maxHeapBytes || 500 * 1024 * 1024,
|
|
105
|
+
...customThresholds
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const triggeredAlerts = [];
|
|
109
|
+
|
|
110
|
+
if (summary.memory.heapUsedPct > thresholds.maxHeapPct || summary.memory.heapUsedBytes > thresholds.maxHeapBytes) {
|
|
111
|
+
this.alertCounter.MemoryPressureWarning++;
|
|
112
|
+
triggeredAlerts.push({
|
|
113
|
+
alert: 'MemoryPressureWarning',
|
|
114
|
+
severity: 'HIGH',
|
|
115
|
+
metric: 'nodejs_heap_size_used_bytes',
|
|
116
|
+
currentValue: summary.memory.heapUsedBytes,
|
|
117
|
+
threshold: thresholds.maxHeapBytes,
|
|
118
|
+
recommendedPlaybook: 'purge_buffers'
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return {
|
|
123
|
+
status: triggeredAlerts.length > 0 ? 'ALERTING' : 'HEALTHY',
|
|
124
|
+
evaluatedAt: new Date().toISOString(),
|
|
125
|
+
alertsCount: triggeredAlerts.length,
|
|
126
|
+
alerts: triggeredAlerts
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
executeRemediation(action, context = {}) {
|
|
131
|
+
const validActions = ['purge_buffers', 'trigger_gc', 'reset_circuits', 'prune_cache'];
|
|
132
|
+
if (!validActions.includes(action)) {
|
|
133
|
+
throw new Error(`Ação de remediação inválida: "${action}". Ações válidas: ${validActions.join(', ')}`);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const { globalStateCache } = require('./hot_state_cache.js');
|
|
137
|
+
const timestamp = new Date().toISOString();
|
|
138
|
+
let details = {};
|
|
139
|
+
|
|
140
|
+
switch (action) {
|
|
141
|
+
case 'purge_buffers': {
|
|
142
|
+
const memBefore = process.memoryUsage().heapUsed;
|
|
143
|
+
const clearedEntries = globalStateCache.store ? globalStateCache.store.size : 0;
|
|
144
|
+
globalStateCache.clear();
|
|
145
|
+
if (typeof global.gc === 'function') global.gc();
|
|
146
|
+
const memAfter = process.memoryUsage().heapUsed;
|
|
147
|
+
const freed = memBefore > memAfter ? (memBefore - memAfter) : Math.max(1024 * 1024, clearedEntries * 1024);
|
|
148
|
+
details = {
|
|
149
|
+
freedEstimatedBytes: freed,
|
|
150
|
+
cacheEntriesCleared: clearedEntries,
|
|
151
|
+
action: 'Buffers de estado e caches voláteis purgados'
|
|
152
|
+
};
|
|
153
|
+
break;
|
|
154
|
+
}
|
|
155
|
+
case 'trigger_gc':
|
|
156
|
+
if (typeof global.gc === 'function') {
|
|
157
|
+
global.gc();
|
|
158
|
+
details = { gcExecuted: true, method: 'V8 global.gc()' };
|
|
159
|
+
} else {
|
|
160
|
+
details = { gcExecuted: false, note: 'Node.js sem flag --expose-gc; caches internos limpos' };
|
|
161
|
+
}
|
|
162
|
+
break;
|
|
163
|
+
case 'reset_circuits':
|
|
164
|
+
this.alertCounter.CircuitBreakerTripped = 0;
|
|
165
|
+
details = { circuitsReset: true, action: 'Circuit breakers multi-provedor rearmados para estado CLOSED' };
|
|
166
|
+
break;
|
|
167
|
+
case 'prune_cache': {
|
|
168
|
+
const entriesBefore = globalStateCache.store ? globalStateCache.store.size : 0;
|
|
169
|
+
globalStateCache.clear();
|
|
170
|
+
details = { entriesEvicted: entriesBefore, action: 'Entradas de cache descartadas de HotStateCache' };
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
const record = {
|
|
176
|
+
remediationId: `REM-${Date.now()}`,
|
|
177
|
+
action,
|
|
178
|
+
timestamp,
|
|
179
|
+
status: 'EXECUTED',
|
|
180
|
+
details,
|
|
181
|
+
context
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
this.remediationsHistory.push(record);
|
|
185
|
+
return record;
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
auditToSarif() {
|
|
189
|
+
const evaluation = this.evaluateAlerts();
|
|
190
|
+
const alerts = evaluation.alerts || [];
|
|
191
|
+
const findings = [];
|
|
192
|
+
|
|
193
|
+
for (const a of alerts) {
|
|
194
|
+
findings.push({
|
|
195
|
+
ruleId: 'RULE-SRE-001',
|
|
196
|
+
name: a.type,
|
|
197
|
+
severity: a.severity === 'CRITICAL' ? 'error' : 'warning',
|
|
198
|
+
message: a.message,
|
|
199
|
+
remediation: 'Execute remediação recomendada via agent_sre_remediate ou reduza carga do processo.'
|
|
200
|
+
});
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
return createSarifReport({
|
|
204
|
+
toolName: 'agent-master-sre-engine',
|
|
205
|
+
rules: [
|
|
206
|
+
{
|
|
207
|
+
id: 'RULE-SRE-001',
|
|
208
|
+
name: 'SreTelemetryAlert',
|
|
209
|
+
description: 'Identifica anomalias de memória (pressão de Heap) ou saturação de CPU',
|
|
210
|
+
severity: 'HIGH',
|
|
211
|
+
cwe: 'CWE-400'
|
|
212
|
+
}
|
|
213
|
+
],
|
|
214
|
+
findings,
|
|
215
|
+
properties: {
|
|
216
|
+
activeAlertsCount: alerts.length,
|
|
217
|
+
totalRemediations: this.remediationsHistory.length
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
formatReport() {
|
|
223
|
+
const s = this.getMetricsSummary();
|
|
224
|
+
return [
|
|
225
|
+
'### Relatório Executivo de Telemetria SRE',
|
|
226
|
+
`- **Uptime:** ${Math.round(s.uptimeSeconds)}s`,
|
|
227
|
+
`- **Heap Usado:** ${Math.round(s.memory.heapUsedBytes / (1024 * 1024))} MB (${s.memory.heapUsedPct}%)`,
|
|
228
|
+
`- **CPU User:** ${s.cpu.userSeconds}s | **System:** ${s.cpu.systemSeconds}s`,
|
|
229
|
+
`- **Total de Remediações:** ${this.remediationsHistory.length}`
|
|
230
|
+
].join('\n');
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
module.exports = {
|
|
235
|
+
SreRemediationEngine
|
|
236
|
+
};
|