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,205 +1,250 @@
1
- #!/usr/bin/env node
2
- /**
3
- * scripts/magic_prompt_generator.js
4
- *
5
- * Magic Prompt Generator & Web Bookmarklet (AGDEV-27 / I-13).
6
- * Gera prompt autocontido de ativação instantânea (< 900 tokens) e bookmarklet
7
- * web para injeção em 1 clique no ChatGPT, Claude.ai, Gemini e DeepSeek Web.
8
- */
9
-
10
- const fs = require('node:fs');
11
- const path = require('node:path');
12
-
13
- class MagicPromptGenerator {
14
- constructor(baseDir = path.resolve(__dirname, '..')) {
15
- this.baseDir = baseDir;
16
- }
17
-
18
- generateMagicPrompt(target = 'generic') {
19
- const prompt = `=== AGENT ORCHESTRATOR & SUÍTE MULTI-AGENTE (UNIVERSAL INSTANT ACTIVATION) ===
20
- [DIRECTIVE]: You are now running the canonical Agent Suite (Orchestrator, DevSecOps, QA, Scrum, SRE & UI/UX). Assume 100% adherence to the rules below for all responses:
21
-
22
- [THE 14 GOLDEN ENGINEERING RULES & RULE 15 INVIOLABILITY]:
23
- 1. TDD First: Write/verify unit tests BEFORE modifying production code.
24
- 2. Branch by Card & Strict Commit: Dedicated branch <TICKET>. Commit strictly [<TICKET>] - <Ação em português>. Conventional Commits e commits sem ticket banidos.
25
- 3. Formal PR & CI: Every merge requires a formal Pull Request with 100% green CI checks.
26
- 4. Zero Secrets (TruffleHog): Never commit credentials, .env files, private keys or tokens.
27
- 5. DevSecOps OWASP: Strictly prevent CWE-78 (Cmd Injection), CWE-79 (XSS), CWE-89 (SQLi), CWE-116, CWE-1333 (ReDoS).
28
- 6. Native Telemetry: Expose standard Prometheus metrics /metrics (CPU, RSS, Heap, latency).
29
- 7. Dual-Layer Output Protocol: Keep chat output concise, short bullet points separated by a DOUBLE BLANK LINE (\\n\\n) with clickable markdown links. Externalize 15-section dense reports to tickets/ADRs.
30
- 8. Central Knowledge: Record architectural decisions in ADRs. Keep project documentation living and 100% faithful to production.
31
- 9. Issue Tracker: Move card to 'In progress' before starting; close with dense technical summary.
32
- 10. Zero Assumptions: Clarify ambiguities or inspect code before proposing solutions.
33
- 11. Doc Integrity: Preserve existing docstrings, comments and public API contracts.
34
- 12. Operational Safety: Never execute destructive unconfirmed commands (rm -rf, hard reset).
35
- 13. Cold Review (AGENT_QA.md): Independently audit diffs with cold skepticism; provide breaking tests.
36
- 14. Ideation Sanity Filter: Every suggested idea in docs/IDEAS.md must strictly match the project's actual stack, domain, and architecture.
37
- 15. Rule 15 Inviolability: Zero silent failures. Requirements and credentials (GitHub CLI, Jira, Confluence) are mandatory.
38
-
39
- [OPERATIONAL MODES]:
40
- - modo: orchestrator (central coordination, triage and multi-agent dispatch)
41
- - modo: devsecops (secure, robust code, clean architecture and CI/CD)
42
- - modo: qa (adversarial cold review, bug hunting and breaking tests)
43
- - modo: scrum (Kaizen/PDCA continuous improvement without overengineering)
44
- - modo: sre (SRE, telemetry, incident diagnosis and self-healing)
45
- - modo: uiux (design system, accessibility WCAG 2.1 AA, UX ergonomics, design tokens)
46
- - modo: full-dev (autonomous sequential idea implementation loop)
47
-
48
- [ACTIVATION ACKNOWLEDGEMENT]:
49
- Acknowledge activation with a 2-line executive greeting:
50
- "⚡ Suíte Multi-Agente universalmente ativada e pronta para qualquer demanda.
51
- Informe a stack e solicite credenciais Atlassian (Jira/Confluence) e GitHub CLI se for nova máquina ou projeto."`;
52
-
53
- return prompt;
54
- }
55
-
56
- generateBookmarklet() {
57
- const rawPrompt = this.generateMagicPrompt();
58
- const encodedPrompt = JSON.stringify(rawPrompt);
59
-
60
- // Bookmarklet inline seguro que detecta o campo de chat e copia para o clipboard
61
- const script = `javascript:(function(){
62
- var promptText = ${encodedPrompt};
63
-
64
- if (navigator.clipboard && navigator.clipboard.writeText) {
65
- navigator.clipboard.writeText(promptText).then(function() {
66
- showToast("⚡ Suíte Multi-Agente copiada! Cole (Ctrl+V) no chat da IA.");
67
- }).catch(function() {
68
- fallbackPrompt(promptText);
69
- });
70
- } else {
71
- fallbackPrompt(promptText);
72
- }
73
-
74
- var inputEl = document.querySelector('#prompt-textarea') ||
75
- document.querySelector('div[contenteditable="true"]') ||
76
- document.querySelector('textarea');
77
- if (inputEl) {
78
- if (inputEl.tagName === 'TEXTAREA') {
79
- inputEl.value = promptText;
80
- inputEl.dispatchEvent(new Event('input', { bubbles: true }));
81
- } else if (inputEl.isContentEditable) {
82
- inputEl.innerText = promptText;
83
- inputEl.dispatchEvent(new Event('input', { bubbles: true }));
84
- }
85
- }
86
-
87
- function showToast(msg) {
88
- var toast = document.createElement('div');
89
- toast.innerText = msg;
90
- toast.style.position = 'fixed';
91
- toast.style.top = '20px';
92
- toast.style.right = '20px';
93
- toast.style.backgroundColor = '#0f172a';
94
- toast.style.color = '#38bdf8';
95
- toast.style.padding = '14px 20px';
96
- toast.style.borderRadius = '8px';
97
- toast.style.boxShadow = '0 10px 25px rgba(0,0,0,0.5)';
98
- toast.style.zIndex = '999999';
99
- toast.style.fontFamily = 'system-ui, sans-serif';
100
- toast.style.fontSize = '14px';
101
- toast.style.border = '1px solid #38bdf8';
102
- document.body.appendChild(toast);
103
- setTimeout(function() { toast.remove(); }, 3500);
104
- }
105
-
106
- function fallbackPrompt(text) {
107
- window.prompt("Copie o Magic Prompt abaixo:", text);
108
- }
109
- })();`.replace(/\n\s*/g, '');
110
-
111
- return script;
112
- }
113
-
114
- estimateTokens(text) {
115
- // Estimativa canônica de ~4 caracteres por token
116
- return Math.ceil(text.length / 4);
117
- }
118
-
119
- exportArtifacts(targetDir = path.join(this.baseDir, 'dist', 'magic_prompt'), options = {}) {
120
- const dryRun = Boolean(options.dryRun);
121
- const magicPrompt = this.generateMagicPrompt();
122
- const bookmarklet = this.generateBookmarklet();
123
- const tokens = this.estimateTokens(magicPrompt);
124
-
125
- const htmlContent = `<!DOCTYPE html>
126
- <html lang="pt-BR">
127
- <head>
128
- <meta charset="UTF-8">
129
- <title>Suíte Multi-Agente — Magic Prompt & Bookmarklet</title>
130
- <style>
131
- body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #f8fafc; padding: 40px; line-height: 1.6; }
132
- .card { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 24px; max-width: 800px; margin: 0 auto 30px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
133
- h1 { color: #38bdf8; margin-top: 0; }
134
- pre { background: #090d16; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 13px; color: #cbd5e1; border: 1px solid #1e293b; }
135
- .btn { display: inline-block; background: #0284c7; color: white; padding: 12px 20px; border-radius: 8px; text-decoration: none; font-weight: bold; cursor: grab; }
136
- .btn:hover { background: #0369a1; }
137
- </style>
138
- </head>
139
- <body>
140
- <div class="card">
141
- <h1>⚡ Suíte Multi-Agente — Ativação Instantânea</h1>
142
- <p>Arraste o botão abaixo para a sua <strong>Barra de Favoritos</strong> do navegador. Ao clicar nele em qualquer aba do ChatGPT, Claude, Gemini ou DeepSeek, a suíte de agentes será ativada instantaneamente!</p>
143
- <p style="margin: 30px 0;">
144
- <a class="btn" href="${bookmarklet}">⚡ Ativar Suíte Multi-Agente</a>
145
- </p>
146
- <small style="color: #94a3b8;">Dica: você também pode clicar com o botão direito e selecionar "Adicionar aos favoritos".</small>
147
- </div>
148
-
149
- <div class="card">
150
- <h2>📋 Magic Prompt (Cópia Manual — ~${tokens} tokens)</h2>
151
- <pre id="promptText">${magicPrompt.replace(/</g, '&lt;').replace(/>/g, '&gt;')}</pre>
152
- </div>
153
- </body>
154
- </html>`;
155
-
156
- const mdContent = `# ⚡ Magic Prompt — Ativação Instantânea da Suíte Multi-Agente
157
-
158
- Copie o bloco abaixo e cole como primeira mensagem em **qualquer LLM** (ChatGPT, Claude.ai, Gemini, DeepSeek Web, Ollama ou LeChat) para assumir imediatamente 100% das 14 regras de engenharia:
159
-
160
- \`\`\`text
161
- ${magicPrompt}
162
- \`\`\`
163
-
164
- ---
165
- *Orçamento semântico: ~${tokens} tokens (limite de 1.000 tokens respeitado com 100% de conformidade).*
166
- `;
167
-
168
- const files = [
169
- { path: path.join(targetDir, 'MAGIC_PROMPT.md'), content: mdContent },
170
- { path: path.join(targetDir, 'bookmarklet.html'), content: htmlContent }
171
- ];
172
-
173
- if (!dryRun) {
174
- if (!fs.existsSync(targetDir)) fs.mkdirSync(targetDir, { recursive: true });
175
- files.forEach(f => fs.writeFileSync(f.path, f.content, 'utf8'));
176
- }
177
-
178
- return {
179
- status: 'SUCCESS',
180
- targetDir,
181
- tokens,
182
- dryRun,
183
- filesCount: files.length,
184
- files: files.map(f => f.path),
185
- magicPrompt,
186
- bookmarklet
187
- };
188
- }
189
- }
190
-
191
- if (require.main === module) {
192
- const generator = new MagicPromptGenerator();
193
- const res = generator.exportArtifacts();
194
- console.log('\n============================================================');
195
- console.log('⚡ Magic Prompt Generator & Web Bookmarklet (AGDEV-27)');
196
- console.log('============================================================\n');
197
- console.log(`✅ Arquivos exportados com sucesso em: ${res.targetDir}`);
198
- console.log(`📊 Orçamento de Tokens Estimado: ~${res.tokens} tokens (< 1.000 tokens)`);
199
- console.log(`📄 Arquivos gerados:`, res.files.join(', '));
200
- console.log('\nO bookmarklet HTML e o MAGIC_PROMPT.md estão prontos para uso!\n');
201
- }
202
-
203
- module.exports = {
204
- MagicPromptGenerator
205
- };
1
+ #!/usr/bin/env node
2
+ /**
3
+ * scripts/core/magic_prompt_generator.js
4
+ *
5
+ * Magic Prompt Generator & Web Bookmarklet (AGDEV-27 / v5.1.0 Enterprise).
6
+ * Gera prompt autocontido de ativação instantânea (< 900 tokens) e bookmarklet
7
+ * web para injeção em 1 clique no ChatGPT, Claude.ai, Gemini e DeepSeek Web.
8
+ * Em conformidade estrita com os 10 Princípios Canônicos de Engenharia e Tríplice Registro.
9
+ */
10
+
11
+ 'use strict';
12
+
13
+ const fs = require('node:fs');
14
+ const path = require('node:path');
15
+ const { createSarifReport } = require('./sarif_engine.js');
16
+
17
+ class MagicPromptGenerator {
18
+ constructor(baseDir = path.resolve(__dirname, '../..')) {
19
+ this.baseDir = baseDir;
20
+ }
21
+
22
+ generateMagicPrompt(target = 'generic') {
23
+ const prompt = `=== AGENT ORCHESTRATOR & SUÍTE MULTI-AGENTE (UNIVERSAL INSTANT ACTIVATION) ===
24
+ [DIRECTIVE]: You are now running the canonical Agent Suite (Orchestrator, DevSecOps, QA, Scrum, SRE, UI/UX & Infra Engineer). Assume 100% adherence to the 10 Canonical Engineering Principles (v5.1 Enterprise) and rules below:
25
+
26
+ [THE 14 GOLDEN ENGINEERING RULES & 10 CANONICAL PRINCIPLES]:
27
+ 1. Code Quality & Clean Architecture: DRY, defensive programming, explicit contracts and typed interfaces.
28
+ 2. DevSecOps Shift-Left: Immune to OWASP Top 10 (CWE-78, CWE-79, CWE-89, CWE-1333 ReDoS); zero secrets in commits.
29
+ 3. Triple Ledger Traceability: Dedicated branch per ticket (<TICKET>), formatted commits, Kanban sync and ADRs.
30
+ 4. TDD & Strict DoD: Automated tests (unit, integration, regression) written before/alongside implementation.
31
+ 5. Exception Handling & Resilience: No empty catches; graceful circuit breaking and resilient fallbacks.
32
+ 6. Observabilidade & SRE: Prometheus metrics (/metrics), process telemetry and W3C TraceContext headers.
33
+ 7. Value Engineering & Anti-Overengineering: Proportionate solutions without accidental complexity or premature microservices.
34
+ 8. Requirements Engineering & Invariant Acceptance Criteria: BDD Given-When-Then criteria remain immutable unless explicitly approved.
35
+ 9. Justified Technical Decision (Anti-Hype & ADRs): Formal trade-off evaluation documented in Confluence/Markdown ADRs.
36
+ 10. Continuous Kaizen: Root cause analysis on any defect; prevent recurrent regression autonomously.
37
+
38
+ [OPERATIONAL MODES]:
39
+ - modo: orchestrator (central coordination, triage and multi-agent dispatch)
40
+ - modo: devsecops (secure, robust code, clean architecture and CI/CD)
41
+ - modo: qa (adversarial cold review, bug hunting and breaking tests)
42
+ - modo: scrum (Kaizen/PDCA continuous improvement without overengineering)
43
+ - modo: sre (SRE, telemetry, incident diagnosis and self-healing)
44
+ - modo: uiux (design system, accessibility WCAG 2.1 AA, UX ergonomics, design tokens)
45
+ - modo: infra (real networking, containers, Docker, Cloudflare Tunnel and CI/CD)
46
+ - modo: full-dev (autonomous sequential idea implementation loop)
47
+
48
+ [ACTIVATION ACKNOWLEDGEMENT]:
49
+ Acknowledge activation with a 2-line executive greeting:
50
+ "⚡ Suíte Multi-Agente universalmente ativada e pronta para qualquer demanda.
51
+ Informe a stack e solicite credenciais Atlassian (Jira/Confluence) e GitHub CLI se for nova máquina ou projeto."`;
52
+
53
+ return prompt;
54
+ }
55
+
56
+ generateBookmarklet() {
57
+ const rawPrompt = this.generateMagicPrompt();
58
+ const encodedPrompt = JSON.stringify(rawPrompt);
59
+
60
+ // Bookmarklet inline seguro que detecta o campo de chat e copia para o clipboard
61
+ const script = `javascript:(function(){
62
+ var promptText = ${encodedPrompt};
63
+
64
+ if (navigator.clipboard && navigator.clipboard.writeText) {
65
+ navigator.clipboard.writeText(promptText).then(function() {
66
+ showToast("⚡ Suíte Multi-Agente copiada! Cole (Ctrl+V) no chat da IA.");
67
+ }).catch(function() {
68
+ fallbackPrompt(promptText);
69
+ });
70
+ } else {
71
+ fallbackPrompt(promptText);
72
+ }
73
+
74
+ var inputEl = document.querySelector('#prompt-textarea') ||
75
+ document.querySelector('div[contenteditable="true"]') ||
76
+ document.querySelector('textarea');
77
+ if (inputEl) {
78
+ if (inputEl.tagName === 'TEXTAREA') {
79
+ inputEl.value = promptText;
80
+ inputEl.dispatchEvent(new Event('input', { bubbles: true }));
81
+ } else if (inputEl.isContentEditable) {
82
+ inputEl.innerText = promptText;
83
+ inputEl.dispatchEvent(new Event('input', { bubbles: true }));
84
+ }
85
+ }
86
+
87
+ function showToast(msg) {
88
+ var toast = document.createElement('div');
89
+ toast.innerText = msg;
90
+ toast.style.position = 'fixed';
91
+ toast.style.top = '20px';
92
+ toast.style.right = '20px';
93
+ toast.style.backgroundColor = '#0f172a';
94
+ toast.style.color = '#38bdf8';
95
+ toast.style.padding = '14px 20px';
96
+ toast.style.borderRadius = '8px';
97
+ toast.style.boxShadow = '0 10px 25px rgba(0,0,0,0.5)';
98
+ toast.style.zIndex = '999999';
99
+ toast.style.fontFamily = 'system-ui, sans-serif';
100
+ toast.style.fontSize = '14px';
101
+ toast.style.border = '1px solid #38bdf8';
102
+ document.body.appendChild(toast);
103
+ setTimeout(function() { toast.remove(); }, 3500);
104
+ }
105
+
106
+ function fallbackPrompt(text) {
107
+ window.prompt("Copie o Magic Prompt abaixo:", text);
108
+ }
109
+ })();`.replace(/\n\s*/g, '');
110
+
111
+ return script;
112
+ }
113
+
114
+ estimateTokens(text = '') {
115
+ if (!text || typeof text !== 'string') return 0;
116
+ return Math.ceil(text.length / 4);
117
+ }
118
+
119
+ exportArtifacts(targetDir = path.join(this.baseDir, 'dist', 'magic_prompt'), options = {}) {
120
+ const dryRun = Boolean(options.dryRun);
121
+ const magicPrompt = this.generateMagicPrompt();
122
+ const bookmarklet = this.generateBookmarklet();
123
+ const tokens = this.estimateTokens(magicPrompt);
124
+
125
+ const htmlContent = `<!DOCTYPE html>
126
+ <html lang="pt-BR">
127
+ <head>
128
+ <meta charset="UTF-8">
129
+ <title>Suíte Multi-Agente — Magic Prompt & Bookmarklet</title>
130
+ <style>
131
+ body { font-family: system-ui, -apple-system, sans-serif; background: #0f172a; color: #f8fafc; padding: 40px; line-height: 1.6; }
132
+ .card { background: #1e293b; border: 1px solid #334155; border-radius: 12px; padding: 24px; max-width: 800px; margin: 0 auto 30px; box-shadow: 0 10px 25px rgba(0,0,0,0.3); }
133
+ h1 { color: #38bdf8; margin-top: 0; }
134
+ pre { background: #090d16; padding: 16px; border-radius: 8px; overflow-x: auto; font-size: 13px; color: #cbd5e1; border: 1px solid #1e293b; }
135
+ .btn { display: inline-block; background: #0284c7; color: white; padding: 12px 20px; border-radius: 8px; text-decoration: none; font-weight: bold; cursor: grab; }
136
+ .btn:hover { background: #0369a1; }
137
+ </style>
138
+ </head>
139
+ <body>
140
+ <div class="card">
141
+ <h1>⚡ Suíte Multi-Agente — Ativação Instantânea</h1>
142
+ <p>Arraste o botão abaixo para a sua <strong>Barra de Favoritos</strong> do navegador. Ao clicar nele em qualquer aba do ChatGPT, Claude, Gemini ou DeepSeek, a suíte de agentes será ativada instantaneamente!</p>
143
+ <p style="margin: 30px 0;">
144
+ <a class="btn" href="${bookmarklet}">⚡ Ativar Suíte Multi-Agente</a>
145
+ </p>
146
+ <small style="color: #94a3b8;">Dica: você também pode clicar com o botão direito e selecionar "Adicionar aos favoritos".</small>
147
+ </div>
148
+
149
+ <div class="card">
150
+ <h2>📋 Magic Prompt (Cópia Manual — ~${tokens} tokens)</h2>
151
+ <pre id="promptText">${magicPrompt.replace(/</g, '&lt;').replace(/>/g, '&gt;')}</pre>
152
+ </div>
153
+ </body>
154
+ </html>`;
155
+
156
+ const mdContent = `# ⚡ Magic Prompt — Ativação Instantânea da Suíte Multi-Agente
157
+
158
+ Copie o bloco abaixo e cole como primeira mensagem em **qualquer LLM** (ChatGPT, Claude.ai, Gemini, DeepSeek Web, Ollama ou LeChat) para assumir imediatamente 100% dos 10 Princípios Canônicos de Engenharia:
159
+
160
+ \`\`\`text
161
+ ${magicPrompt}
162
+ \`\`\`
163
+
164
+ ---
165
+ *Orçamento semântico: ~${tokens} tokens (limite estrito de 1.000 tokens respeitado com 100% de conformidade).*
166
+ `;
167
+
168
+ const files = [
169
+ { path: path.join(targetDir, 'MAGIC_PROMPT.md'), content: mdContent },
170
+ { path: path.join(targetDir, 'bookmarklet.html'), content: htmlContent }
171
+ ];
172
+
173
+ if (!dryRun) {
174
+ if (!fs.existsSync(targetDir)) fs.mkdirSync(targetDir, { recursive: true });
175
+ files.forEach(f => fs.writeFileSync(f.path, f.content, 'utf8'));
176
+ }
177
+
178
+ return {
179
+ status: 'SUCCESS',
180
+ targetDir,
181
+ tokens,
182
+ dryRun,
183
+ filesCount: files.length,
184
+ files: files.map(f => f.path),
185
+ magicPrompt,
186
+ bookmarklet
187
+ };
188
+ }
189
+
190
+ auditToSarif() {
191
+ const magicPrompt = this.generateMagicPrompt();
192
+ const tokens = this.estimateTokens(magicPrompt);
193
+ const findings = [];
194
+
195
+ if (tokens > 1000) {
196
+ findings.push({
197
+ ruleId: 'RULE-MAGIC-001',
198
+ name: 'MagicPromptBudgetExceeded',
199
+ severity: 'WARNING',
200
+ message: `O Magic Prompt excedeu o teto estrito de 1.000 tokens (atual: ${tokens} tokens).`,
201
+ remediation: 'Mantenha o prompt enxuto e hiper-focado.'
202
+ });
203
+ }
204
+
205
+ return createSarifReport({
206
+ toolName: 'agent-master-magic-prompt-generator',
207
+ rules: [
208
+ {
209
+ id: 'RULE-MAGIC-001',
210
+ name: 'MagicPromptBudgetExceeded',
211
+ description: 'Valida se o Magic Prompt cabe no orçamento estrito de < 1.000 tokens',
212
+ severity: 'MEDIUM',
213
+ cwe: 'CWE-400'
214
+ }
215
+ ],
216
+ findings,
217
+ properties: {
218
+ tokens,
219
+ underBudget: tokens <= 1000
220
+ }
221
+ });
222
+ }
223
+
224
+ formatReport() {
225
+ const prompt = this.generateMagicPrompt();
226
+ const tokens = this.estimateTokens(prompt);
227
+ return [
228
+ '### Relatório do Gerador de Magic Prompt & Bookmarklet',
229
+ `- **Tokens:** ~${tokens} tokens (< 1.000 tokens)`,
230
+ `- **Bookmarklet:** Gerado com injeção automática e fallback`,
231
+ `- **Conformidade:** 10 Princípios Canônicos Universais (v5.1)`
232
+ ].join('\n');
233
+ }
234
+ }
235
+
236
+ if (require.main === module) {
237
+ const generator = new MagicPromptGenerator();
238
+ const res = generator.exportArtifacts();
239
+ console.log('\n============================================================');
240
+ console.log('⚡ Magic Prompt Generator & Web Bookmarklet (AGDEV-27)');
241
+ console.log('============================================================\n');
242
+ console.log(`✅ Arquivos exportados com sucesso em: ${res.targetDir}`);
243
+ console.log(`📊 Orçamento de Tokens Estimado: ~${res.tokens} tokens (< 1.000 tokens)`);
244
+ console.log(`📄 Arquivos gerados:`, res.files.join(', '));
245
+ console.log('\nO bookmarklet HTML e o MAGIC_PROMPT.md estão prontos para uso!\n');
246
+ }
247
+
248
+ module.exports = {
249
+ MagicPromptGenerator
250
+ };