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,205 +1,250 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* scripts/magic_prompt_generator.js
|
|
4
|
-
*
|
|
5
|
-
* Magic Prompt Generator & Web Bookmarklet (AGDEV-27 /
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
- modo:
|
|
41
|
-
- modo:
|
|
42
|
-
- modo:
|
|
43
|
-
- modo:
|
|
44
|
-
- modo:
|
|
45
|
-
- modo:
|
|
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
|
-
|
|
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, '<').replace(/>/g, '>')}</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%
|
|
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
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
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, '<').replace(/>/g, '>')}</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
|
+
};
|