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
@@ -0,0 +1,238 @@
1
+ /**
2
+ * scripts/hot_state_cache.js
3
+ *
4
+ * Cache de Alta Velocidade em Memória para Governança e Estado do Sistema (AGENT_SRE / AGENT_ORCHESTRATOR).
5
+ * Elimina a latência de I/O de processos filhos no Windows (execFileSync para 'git' e 'gh auth status')
6
+ * através de memorização com TTL (Time-To-Live).
7
+ *
8
+ * Reduz a latência de checagens repetitivas de ~600ms para < 0.01ms por invocação.
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ const { createSarifReport } = require('./sarif_engine.js');
14
+
15
+ class HotStateCache {
16
+ constructor(options = 30000) {
17
+ if (typeof options === 'number') {
18
+ this.defaultTtlMs = options;
19
+ this.storagePath = null;
20
+ this.persistOnSet = false;
21
+ } else {
22
+ this.defaultTtlMs = options.defaultTtlMs || 30000;
23
+ this.storagePath = options.storagePath || null;
24
+ this.persistOnSet = options.persistOnSet !== false;
25
+ }
26
+
27
+ this.cache = new Map();
28
+ this.hits = 0;
29
+ this.misses = 0;
30
+
31
+ if (this.storagePath) {
32
+ this._loadFromDisk();
33
+ }
34
+ }
35
+
36
+ _loadFromDisk() {
37
+ try {
38
+ const fs = require('node:fs');
39
+ if (fs.existsSync(this.storagePath)) {
40
+ const raw = fs.readFileSync(this.storagePath, 'utf8');
41
+ const parsed = JSON.parse(raw);
42
+ const now = Date.now();
43
+ if (Array.isArray(parsed)) {
44
+ for (const item of parsed) {
45
+ if (item && item.key && item.expiresAt > now) {
46
+ this.cache.set(item.key, {
47
+ value: item.value,
48
+ expiresAt: item.expiresAt,
49
+ cachedAt: item.cachedAt || now
50
+ });
51
+ }
52
+ }
53
+ }
54
+ }
55
+ } catch (_err) {
56
+ this.cache.clear();
57
+ }
58
+ }
59
+
60
+ _saveToDisk() {
61
+ if (!this.storagePath) return;
62
+ try {
63
+ const fs = require('node:fs');
64
+ const path = require('node:path');
65
+ const dir = path.dirname(this.storagePath);
66
+ if (!fs.existsSync(dir)) {
67
+ fs.mkdirSync(dir, { recursive: true });
68
+ }
69
+
70
+ const now = Date.now();
71
+ const exportList = [];
72
+ for (const [key, entry] of this.cache.entries()) {
73
+ if (entry.expiresAt > now) {
74
+ exportList.push({
75
+ key,
76
+ value: entry.value,
77
+ expiresAt: entry.expiresAt,
78
+ cachedAt: entry.cachedAt
79
+ });
80
+ }
81
+ }
82
+
83
+ fs.writeFileSync(this.storagePath, JSON.stringify(exportList, null, 2), 'utf8');
84
+ } catch (_err) {
85
+ void _err;
86
+ }
87
+ }
88
+
89
+ persist() {
90
+ this._saveToDisk();
91
+ }
92
+
93
+ get(key) {
94
+ const entry = this.cache.get(key);
95
+ if (!entry) {
96
+ this.misses++;
97
+ return null;
98
+ }
99
+
100
+ if (Date.now() > entry.expiresAt) {
101
+ this.cache.delete(key);
102
+ if (this.storagePath && this.persistOnSet) {
103
+ this._saveToDisk();
104
+ }
105
+ this.misses++;
106
+ return null;
107
+ }
108
+
109
+ this.hits++;
110
+ return entry.value;
111
+ }
112
+
113
+ set(key, value, ttlMs = this.defaultTtlMs) {
114
+ this.cache.set(key, {
115
+ value,
116
+ expiresAt: Date.now() + ttlMs,
117
+ cachedAt: Date.now()
118
+ });
119
+
120
+ if (this.storagePath && this.persistOnSet) {
121
+ this._saveToDisk();
122
+ }
123
+
124
+ return value;
125
+ }
126
+
127
+ wrap(key, fn, ttlMs = this.defaultTtlMs) {
128
+ const cached = this.get(key);
129
+ if (cached !== null) {
130
+ return cached;
131
+ }
132
+
133
+ const value = fn();
134
+ return this.set(key, value, ttlMs);
135
+ }
136
+
137
+ async wrapAsync(key, asyncFn, ttlMs = this.defaultTtlMs) {
138
+ const cached = this.get(key);
139
+ if (cached !== null) {
140
+ return cached;
141
+ }
142
+
143
+ const value = await asyncFn();
144
+ return this.set(key, value, ttlMs);
145
+ }
146
+
147
+ invalidate(key) {
148
+ const deleted = this.cache.delete(key);
149
+ if (deleted && this.storagePath && this.persistOnSet) {
150
+ this._saveToDisk();
151
+ }
152
+ return deleted;
153
+ }
154
+
155
+ clear() {
156
+ this.cache.clear();
157
+ this.hits = 0;
158
+ this.misses = 0;
159
+ if (this.storagePath && this.persistOnSet) {
160
+ this._saveToDisk();
161
+ }
162
+ }
163
+
164
+ getMetrics() {
165
+ const total = this.hits + this.misses;
166
+ const hitRatio = total > 0 ? Number(((this.hits / total) * 100).toFixed(1)) : 0;
167
+ return {
168
+ activeEntries: this.cache.size,
169
+ hits: this.hits,
170
+ misses: this.misses,
171
+ hitRatioPercent: hitRatio
172
+ };
173
+ }
174
+
175
+ auditToSarif() {
176
+ const metrics = this.getMetrics();
177
+ const findings = [];
178
+
179
+ if (metrics.activeEntries > 5000) {
180
+ findings.push({
181
+ ruleId: 'RULE-CACHE-001',
182
+ name: 'HighCacheMemoryFootprint',
183
+ severity: 'WARNING',
184
+ message: `O cache atingiu ${metrics.activeEntries} entradas ativas em memória.`,
185
+ remediation: 'Considere invocar .clear() ou reduzir o TTL.'
186
+ });
187
+ }
188
+
189
+ return createSarifReport({
190
+ toolName: 'agent-master-hot-state-cache',
191
+ rules: [
192
+ {
193
+ id: 'RULE-CACHE-001',
194
+ name: 'HighCacheMemoryFootprint',
195
+ description: 'Monitora a saturação e volume de entradas em memória do cache rápido',
196
+ severity: 'MEDIUM',
197
+ cwe: 'CWE-400'
198
+ }
199
+ ],
200
+ findings,
201
+ properties: {
202
+ activeEntries: metrics.activeEntries,
203
+ hitRatioPercent: metrics.hitRatioPercent
204
+ }
205
+ });
206
+ }
207
+
208
+ formatReport() {
209
+ const m = this.getMetrics();
210
+ return [
211
+ '### Relatório de Telemetria — Hot State Cache',
212
+ `- **Entradas Ativas:** ${m.activeEntries}`,
213
+ `- **Hits:** ${m.hits}`,
214
+ `- **Misses:** ${m.misses}`,
215
+ `- **Taxa de Hit:** **${m.hitRatioPercent}%**`,
216
+ `- **Persistência em Disco:** ${this.storagePath ? 'Ativada' : 'Volátil (Memória)'}`
217
+ ].join('\n');
218
+ }
219
+
220
+ static auditToSarif() {
221
+ return globalStateCache.auditToSarif();
222
+ }
223
+
224
+ static formatReport() {
225
+ return globalStateCache.formatReport();
226
+ }
227
+ }
228
+
229
+ // Instância global singleton para o ciclo de vida do agente
230
+ const globalStateCache = new HotStateCache();
231
+
232
+ module.exports = {
233
+ HotStateCache,
234
+ globalStateCache,
235
+ auditToSarif: () => globalStateCache.auditToSarif(),
236
+ formatReport: () => globalStateCache.formatReport()
237
+ };
238
+