@ericnunes/frame-code-cli 0.0.1
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/LICENSE +139 -0
- package/README.md +196 -0
- package/dist/agent-runtime/AgentFacade.js +33 -0
- package/dist/agent-runtime/context/hooks/compressionHook.js +56 -0
- package/dist/agent-runtime/context/hooks/index.js +5 -0
- package/dist/agent-runtime/context/project-rules/loader.js +72 -0
- package/dist/agent-runtime/context/system-prompts/index.js +5 -0
- package/dist/agent-runtime/context/system-prompts/loader.js +88 -0
- package/dist/agent-runtime/flows/templates/ReactAgentFlow.js +49 -0
- package/dist/agent-runtime/index.js +18 -0
- package/dist/agent-runtime/registry/AgentRegistry.js +93 -0
- package/dist/agent-runtime/registry/agentParser.js +515 -0
- package/dist/agent-runtime/registry/enums/agentType.enum.js +8 -0
- package/dist/agent-runtime/registry/index.js +20 -0
- package/dist/agent-runtime/registry/initialization.js +53 -0
- package/dist/agent-runtime/registry/interfaces/agentDependencies.interface.js +2 -0
- package/dist/agent-runtime/registry/interfaces/agentMetadata.interface.js +2 -0
- package/dist/agent-runtime/registry/interfaces/agentRegistry.interface.js +2 -0
- package/dist/app/bootstrap.js +22 -0
- package/dist/app/cli.js +31 -0
- package/dist/app/index.js +9 -0
- package/dist/cli/commands/autonomous.js +181 -0
- package/dist/cli/commands/index.js +11 -0
- package/dist/cli/commands/interactive.js +172 -0
- package/dist/cli/commands/memory.js +149 -0
- package/dist/cli/commands/multi-agent.js +131 -0
- package/dist/cli/index.js +18 -0
- package/dist/cli/input/images/attachments.js +173 -0
- package/dist/cli/input/images/imageInput.js +77 -0
- package/dist/cli/input/images/readImageAttachment.js +56 -0
- package/dist/cli/input/index.js +14 -0
- package/dist/cli/input/reader.js +26 -0
- package/dist/content/agents/README.md +324 -0
- package/dist/content/agents/architect.md +95 -0
- package/dist/content/agents/builder.md +85 -0
- package/dist/content/agents/code-agent.md +123 -0
- package/dist/content/agents/supervisor.md +63 -0
- package/dist/index.js +25 -0
- package/dist/infrastructure/compression/CompressionManager.js +315 -0
- package/dist/infrastructure/compression/LLMCompressionService.js +211 -0
- package/dist/infrastructure/compression/index.js +11 -0
- package/dist/infrastructure/compression/promptBuilder.js +132 -0
- package/dist/infrastructure/config/agentConfig.interface.js +2 -0
- package/dist/infrastructure/config/agentConfig.js +134 -0
- package/dist/infrastructure/config/config.interface.js +2 -0
- package/dist/infrastructure/config/config.js +112 -0
- package/dist/infrastructure/config/index.js +6 -0
- package/dist/infrastructure/logging/index.js +5 -0
- package/dist/infrastructure/logging/logger.interface.js +2 -0
- package/dist/infrastructure/logging/logger.js +33 -0
- package/dist/infrastructure/logging/raw-output-logger.js +35 -0
- package/dist/infrastructure/skills/index.js +5 -0
- package/dist/infrastructure/skills/loader.js +104 -0
- package/dist/infrastructure/telemetry/index.js +9 -0
- package/dist/infrastructure/telemetry/telemetry.interface.js +2 -0
- package/dist/infrastructure/telemetry/telemetryConfig.js +30 -0
- package/dist/infrastructure/telemetry/traceEventFormatter.js +90 -0
- package/dist/infrastructure/telemetry/traceSinkConsole.js +17 -0
- package/dist/scripts/_validate/telemetry-autonomous.js +23 -0
- package/dist/scripts/_validate/telemetry-multi-agent.js +50 -0
- package/dist/scripts/_validate/test-agents-md-dynamic-dir.js +104 -0
- package/dist/scripts/_validate/test-agents-md-injection.js +125 -0
- package/dist/scripts/_validate/test-agents-md-loader.js +71 -0
- package/dist/scripts/_validate/test-agents-md-priority.js +121 -0
- package/dist/scripts/_validate/test-chrome-mcp-agent.js +89 -0
- package/dist/tools/index.js +19 -0
- package/dist/tools/mcp/discoverer.js +95 -0
- package/dist/tools/mcp/index.js +9 -0
- package/dist/tools/mcp/loader.js +36 -0
- package/dist/tools/mcp/mcpConfig.interface.js +2 -0
- package/dist/tools/mcp/mcpMetadata.js +2 -0
- package/dist/tools/mcp/register.js +269 -0
- package/dist/tools/native/capabilities.js +155 -0
- package/dist/tools/native/file-outline.js +301 -0
- package/dist/tools/native/index.js +20 -0
- package/dist/tools/native/list-directory.js +148 -0
- package/dist/tools/native/read-image.js +140 -0
- package/dist/tools/registry/ToolInitializer.js +62 -0
- package/dist/tools/registry/index.js +11 -0
- package/dist/tools/registry/toolFilter.js +52 -0
- package/dist/tools/registry/toolRegistry.interface.js +2 -0
- package/package.json +81 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
PROPRIETARY SOFTWARE LICENSE
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Eric Nunes. All rights reserved.
|
|
4
|
+
|
|
5
|
+
================================================================================
|
|
6
|
+
FRAME CODE CLI - LICENÇA DE USO RESTRITO
|
|
7
|
+
================================================================================
|
|
8
|
+
|
|
9
|
+
IMPORTANTE: LEIA ATENTAMENTE ANTES DE USAR ESTE SOFTWARE
|
|
10
|
+
|
|
11
|
+
Este software e a documentação associada (coletivamente, o "Software") são
|
|
12
|
+
propriedade exclusiva de Eric Nunes ("Proprietário") e estão
|
|
13
|
+
protegidos por leis de direitos autorais e tratados internacionais.
|
|
14
|
+
|
|
15
|
+
================================================================================
|
|
16
|
+
1. CONCESSÃO DE LICENÇA
|
|
17
|
+
================================================================================
|
|
18
|
+
|
|
19
|
+
Sujeito aos termos e condições desta Licença, o Proprietário concede a você
|
|
20
|
+
uma licença limitada, não exclusiva, intransferível e revogável para:
|
|
21
|
+
|
|
22
|
+
a) USO INTERNO: Usar o Software internamente dentro de sua organização para
|
|
23
|
+
fins de desenvolvimento, teste e operação de sistemas internos.
|
|
24
|
+
|
|
25
|
+
b) USO PESSOAL: Usar o Software para fins pessoais, educacionais e de
|
|
26
|
+
pesquisa não-comercial.
|
|
27
|
+
|
|
28
|
+
c) MODIFICAÇÃO: Modificar o Software para uso interno ou pessoal, desde que
|
|
29
|
+
as modificações permaneçam sob os termos desta Licença.
|
|
30
|
+
|
|
31
|
+
================================================================================
|
|
32
|
+
2. RESTRIÇÕES
|
|
33
|
+
================================================================================
|
|
34
|
+
|
|
35
|
+
Você NÃO PODE, sob nenhuma circunstância:
|
|
36
|
+
|
|
37
|
+
a) COMERCIALIZAÇÃO: Vender, licenciar, sublicenciar, alugar, arrendar ou
|
|
38
|
+
de qualquer forma comercializar o Software ou qualquer produto derivado
|
|
39
|
+
dele.
|
|
40
|
+
|
|
41
|
+
b) REDISTRIBUIÇÃO: Distribuir, publicar, transferir ou disponibilizar o
|
|
42
|
+
Software ou qualquer parte dele a terceiros, exceto conforme expressamente
|
|
43
|
+
permitido nesta Licença.
|
|
44
|
+
|
|
45
|
+
c) PRODUTOS COMERCIAIS: Usar o Software como base para criar, desenvolver ou
|
|
46
|
+
distribuir produtos ou serviços comerciais.
|
|
47
|
+
|
|
48
|
+
d) REMOÇÃO DE AVISOS: Remover, alterar ou obscurecer quaisquer avisos de
|
|
49
|
+
direitos autorais, marcas registradas ou outros avisos de propriedade
|
|
50
|
+
contidos no Software.
|
|
51
|
+
|
|
52
|
+
e) ENGENHARIA REVERSA: Fazer engenharia reversa, descompilar ou desmontar
|
|
53
|
+
o Software, exceto na medida expressamente permitida pela lei aplicável.
|
|
54
|
+
|
|
55
|
+
================================================================================
|
|
56
|
+
3. PROPRIEDADE INTELECTUAL
|
|
57
|
+
================================================================================
|
|
58
|
+
|
|
59
|
+
O Software é licenciado, não vendido. O Proprietário retém todos os direitos,
|
|
60
|
+
títulos e interesses no Software, incluindo todos os direitos de propriedade
|
|
61
|
+
intelectual. Esta Licença não concede a você nenhum direito sobre marcas
|
|
62
|
+
registradas ou marcas de serviço do Proprietário.
|
|
63
|
+
|
|
64
|
+
================================================================================
|
|
65
|
+
4. ISENÇÃO DE GARANTIAS
|
|
66
|
+
================================================================================
|
|
67
|
+
|
|
68
|
+
O SOFTWARE É FORNECIDO "NO ESTADO EM QUE SE ENCONTRA", SEM GARANTIAS DE
|
|
69
|
+
QUALQUER TIPO, EXPRESSAS OU IMPLÍCITAS, INCLUINDO, MAS NÃO SE LIMITANDO A,
|
|
70
|
+
GARANTIAS DE COMERCIALIZAÇÃO, ADEQUAÇÃO A UM PROPÓSITO ESPECÍFICO E
|
|
71
|
+
NÃO VIOLAÇÃO.
|
|
72
|
+
|
|
73
|
+
O Proprietário não garante que o Software:
|
|
74
|
+
- Atenderá aos seus requisitos
|
|
75
|
+
- Operará de forma ininterrupta ou livre de erros
|
|
76
|
+
- Será compatível com outros softwares ou hardwares
|
|
77
|
+
- Será seguro ou livre de vulnerabilidades
|
|
78
|
+
|
|
79
|
+
================================================================================
|
|
80
|
+
5. LIMITAÇÃO DE RESPONSABILIDADE
|
|
81
|
+
================================================================================
|
|
82
|
+
|
|
83
|
+
EM NENHUMA CIRCUNSTÂNCIA O PROPRIETÁRIO SERÁ RESPONSÁVEL POR QUAISQUER DANOS
|
|
84
|
+
DIRETOS, INDIRETOS, INCIDENTAIS, ESPECIAIS, EXEMPLARES OU CONSEQUENCIAIS
|
|
85
|
+
(INCLUINDO, MAS NÃO SE LIMITANDO A, AQUISIÇÃO DE BENS OU SERVIÇOS
|
|
86
|
+
SUBSTITUTOS; PERDA DE USO, DADOS OU LUCROS; OU INTERRUPÇÃO DE NEGÓCIOS)
|
|
87
|
+
DECORRENTES DO USO OU INCAPACIDADE DE USAR O SOFTWARE, MESMO QUE O
|
|
88
|
+
PROPRIETÁRIO TENHA SIDO AVISADO DA POSSIBILIDADE DE TAIS DANOS.
|
|
89
|
+
|
|
90
|
+
================================================================================
|
|
91
|
+
6. RESCISÃO
|
|
92
|
+
================================================================================
|
|
93
|
+
|
|
94
|
+
Esta Licença é efetiva até ser rescindida. Seus direitos sob esta Licença
|
|
95
|
+
serão automaticamente rescindidos sem aviso do Proprietário se você não
|
|
96
|
+
cumprir qualquer termo desta Licença.
|
|
97
|
+
|
|
98
|
+
Após a rescisão, você deve:
|
|
99
|
+
- Cessar imediatamente todo uso do Software
|
|
100
|
+
- Destruir todas as cópias do Software em sua posse ou controle
|
|
101
|
+
|
|
102
|
+
================================================================================
|
|
103
|
+
7. DISPOSIÇÕES GERAIS
|
|
104
|
+
================================================================================
|
|
105
|
+
|
|
106
|
+
a) LEI APLICÁVEL: Esta Licença será regida e interpretada de acordo com as
|
|
107
|
+
leis do Brasil, sem considerar seus conflitos de disposições legais.
|
|
108
|
+
|
|
109
|
+
b) INTEGRALIDADE: Esta Licença constitui o acordo completo entre você e o
|
|
110
|
+
Proprietário em relação ao Software e substitui todos os acordos
|
|
111
|
+
anteriores ou contemporâneos.
|
|
112
|
+
|
|
113
|
+
c) MODIFICAÇÕES: O Proprietário reserva-se o direito de modificar esta
|
|
114
|
+
Licença a qualquer momento. O uso continuado do Software após tais
|
|
115
|
+
modificações constitui sua aceitação da Licença modificada.
|
|
116
|
+
|
|
117
|
+
d) DIVISIBILIDADE: Se qualquer disposição desta Licença for considerada
|
|
118
|
+
inválida ou inexequível, as disposições restantes permanecerão em pleno
|
|
119
|
+
vigor e efeito.
|
|
120
|
+
|
|
121
|
+
================================================================================
|
|
122
|
+
8. CONTATO
|
|
123
|
+
================================================================================
|
|
124
|
+
|
|
125
|
+
Para questões sobre esta Licença ou para solicitar permissões adicionais,
|
|
126
|
+
entre em contato:
|
|
127
|
+
|
|
128
|
+
Eric Nunes
|
|
129
|
+
GitHub: https://github.com/ericnunes/frame-code-cli
|
|
130
|
+
Issues: https://github.com/ericnunes/frame-code-cli/issues
|
|
131
|
+
|
|
132
|
+
================================================================================
|
|
133
|
+
|
|
134
|
+
AO USAR ESTE SOFTWARE, VOCÊ RECONHECE QUE LEU ESTA LICENÇA, COMPREENDEU-A
|
|
135
|
+
E CONCORDA EM ESTAR VINCULADO POR SEUS TERMOS E CONDIÇÕES.
|
|
136
|
+
|
|
137
|
+
SE VOCÊ NÃO CONCORDAR COM ESTES TERMOS, NÃO USE O SOFTWARE.
|
|
138
|
+
|
|
139
|
+
================================================================================
|
package/README.md
ADDED
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
# Frame Code CLI
|
|
2
|
+
|
|
3
|
+
CLI para interagir com agentes de codificação criados com o [`@ericnunes/frame-agent-sdk`](https://www.npmjs.com/package/@ericnunes/frame-agent-sdk).
|
|
4
|
+
|
|
5
|
+
## Requisitos
|
|
6
|
+
|
|
7
|
+
- **Node.js** >= 18.0.0
|
|
8
|
+
- **npm** (ou yarn/pnpm)
|
|
9
|
+
|
|
10
|
+
## Instalação
|
|
11
|
+
|
|
12
|
+
```bash
|
|
13
|
+
npm install -g @ericnunes/frame-code-cli
|
|
14
|
+
```
|
|
15
|
+
|
|
16
|
+
## Configuração
|
|
17
|
+
|
|
18
|
+
Antes de usar o CLI, você precisa configurar as variáveis de ambiente. Crie um arquivo `.env` no diretório onde você vai executar o CLI:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
# Copie o arquivo de exemplo
|
|
22
|
+
cp .env-example .env
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Edite o arquivo `.env` com suas configurações:
|
|
26
|
+
|
|
27
|
+
```env
|
|
28
|
+
# OpenAI API Key (obrigatório)
|
|
29
|
+
OPENAI_API_KEY=your_api_key_here
|
|
30
|
+
|
|
31
|
+
# Modelo a ser usado (opcional, padrão: gpt-4)
|
|
32
|
+
OPENAI_MODEL=gpt-4
|
|
33
|
+
|
|
34
|
+
# Outras configurações opcionais
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Comandos Disponíveis
|
|
38
|
+
|
|
39
|
+
### Help
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
frame-code --help
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Modo Interativo
|
|
46
|
+
|
|
47
|
+
Executa o agente em modo interativo, onde você pode conversar com o agente em tempo real.
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
frame-code interactive
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
### Modo Autônomo
|
|
54
|
+
|
|
55
|
+
Executa o agente em modo autônomo, onde ele trabalha de forma independente em uma tarefa.
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
frame-code autonomous
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Modo Multi-Agente
|
|
62
|
+
|
|
63
|
+
Executa múltiplos agentes trabalhando em colaboração.
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
frame-code multi-agent
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Gerenciar Memória
|
|
70
|
+
|
|
71
|
+
Gerencia a memória do agente (visualizar, limpar, etc.).
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
frame-code memory
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
## Agentes Disponíveis
|
|
78
|
+
|
|
79
|
+
O CLI inclui quatro tipos de agentes pré-configurados:
|
|
80
|
+
|
|
81
|
+
### Architect Agent
|
|
82
|
+
Responsável por planejar e arquitetar soluções de software.
|
|
83
|
+
|
|
84
|
+
### Builder Agent
|
|
85
|
+
Responsável por construir e implementar componentes.
|
|
86
|
+
|
|
87
|
+
### Code Agent
|
|
88
|
+
Responsável por escrever e modificar código.
|
|
89
|
+
|
|
90
|
+
### Supervisor Agent
|
|
91
|
+
Responsável por coordenar e supervisionar outros agentes.
|
|
92
|
+
|
|
93
|
+
## Funcionalidades
|
|
94
|
+
|
|
95
|
+
### Ferramentas Nativas
|
|
96
|
+
|
|
97
|
+
- **Operações de Arquivo**: Ler, criar e editar arquivos
|
|
98
|
+
- **Listagem de Diretórios**: Navegar pela estrutura do projeto
|
|
99
|
+
- **Leitura de Imagens**: Processar e analisar imagens
|
|
100
|
+
- **Geração de Outlines**: Criar estruturas de código
|
|
101
|
+
|
|
102
|
+
### Integração MCP (Model Context Protocol)
|
|
103
|
+
|
|
104
|
+
O CLI suporta integração com servidores MCP, permitindo estender as capacidades dos agentes com ferramentas externas.
|
|
105
|
+
|
|
106
|
+
### Regras do Projeto
|
|
107
|
+
|
|
108
|
+
O CLI carrega automaticamente regras do projeto a partir do arquivo `.code/rules.md`, permitindo que os agentes sigam convenções específicas do seu projeto.
|
|
109
|
+
|
|
110
|
+
### Sistema de Skills
|
|
111
|
+
|
|
112
|
+
Gerenciamento de habilidades personalizadas que podem ser carregadas e usadas pelos agentes.
|
|
113
|
+
|
|
114
|
+
### Telemetria e Logging
|
|
115
|
+
|
|
116
|
+
Infraestrutura completa de telemetria e logging para monitorar e debugar a execução dos agentes.
|
|
117
|
+
|
|
118
|
+
## Exemplos de Uso
|
|
119
|
+
|
|
120
|
+
### Exemplo 1: Modo Interativo
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# Iniciar modo interativo
|
|
124
|
+
frame-code interactive
|
|
125
|
+
|
|
126
|
+
# O agente vai perguntar o que você precisa fazer
|
|
127
|
+
# Você pode descrever a tarefa em linguagem natural
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### Exemplo 2: Modo Autônomo
|
|
131
|
+
|
|
132
|
+
```bash
|
|
133
|
+
# Executar tarefa autônoma
|
|
134
|
+
frame-code autonomous
|
|
135
|
+
|
|
136
|
+
# O agente vai trabalhar de forma independente
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Exemplo 3: Multi-Agente
|
|
140
|
+
|
|
141
|
+
```bash
|
|
142
|
+
# Executar colaboração entre agentes
|
|
143
|
+
frame-code multi-agent
|
|
144
|
+
|
|
145
|
+
# Múltiplos agentes vão trabalhar juntos
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Estrutura de Diretórios
|
|
149
|
+
|
|
150
|
+
O CLI espera a seguinte estrutura de diretórios no seu projeto:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
.
|
|
154
|
+
├── .code/
|
|
155
|
+
│ └── rules.md # Regras do projeto
|
|
156
|
+
├── .env # Variáveis de ambiente
|
|
157
|
+
└── src/ # Código fonte do projeto
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Licença
|
|
161
|
+
|
|
162
|
+
Este software está sob licença proprietária. Veja o arquivo [`LICENSE`](LICENSE) para mais detalhes.
|
|
163
|
+
|
|
164
|
+
- **Permitido**: Uso interno, uso pessoal, modificações para uso interno
|
|
165
|
+
- **Não permitido**: Comercialização, redistribuição, uso em produtos comerciais
|
|
166
|
+
|
|
167
|
+
## Repositório
|
|
168
|
+
|
|
169
|
+
- **GitHub**: https://github.com/ericnunes/frame-code-cli
|
|
170
|
+
- **Issues**: https://github.com/ericnunes/frame-code-cli/issues
|
|
171
|
+
|
|
172
|
+
## Suporte
|
|
173
|
+
|
|
174
|
+
Para questões sobre o uso do CLI ou para relatar bugs, abra uma issue no repositório do GitHub.
|
|
175
|
+
|
|
176
|
+
## Changelog
|
|
177
|
+
|
|
178
|
+
Veja o arquivo [`CHANGELOG.md`](CHANGELOG.md) para informações sobre mudanças em cada versão.
|
|
179
|
+
|
|
180
|
+
## Desenvolvimento
|
|
181
|
+
|
|
182
|
+
Este CLI é construído sobre o [`@ericnunes/frame-agent-sdk`](https://www.npmjs.com/package/@ericnunes/frame-agent-sdk), que fornece a infraestrutura para criar e executar agentes de IA.
|
|
183
|
+
|
|
184
|
+
### Tecnologias
|
|
185
|
+
|
|
186
|
+
- TypeScript
|
|
187
|
+
- Node.js
|
|
188
|
+
- OpenAI API
|
|
189
|
+
- Model Context Protocol (MCP)
|
|
190
|
+
|
|
191
|
+
## Notas Importantes
|
|
192
|
+
|
|
193
|
+
- Este CLI requer uma chave de API da OpenAI (ou provedor compatível)
|
|
194
|
+
- Certifique-se de que o Node.js >= 18.0.0 está instalado
|
|
195
|
+
- O CLI cria arquivos temporários e logs durante a execução
|
|
196
|
+
- A memória do agente pode ser gerenciada através do comando `memory`
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AgentFacade = void 0;
|
|
4
|
+
class AgentFacade {
|
|
5
|
+
constructor(registry) {
|
|
6
|
+
this.registry = registry;
|
|
7
|
+
}
|
|
8
|
+
async createEngine(name, telemetry) {
|
|
9
|
+
return this.registry.createEngine(name, telemetry);
|
|
10
|
+
}
|
|
11
|
+
listAgents() {
|
|
12
|
+
return this.registry.listSummaries();
|
|
13
|
+
}
|
|
14
|
+
getAgent(name) {
|
|
15
|
+
return this.registry.get(name);
|
|
16
|
+
}
|
|
17
|
+
has(name) {
|
|
18
|
+
return this.registry.has(name);
|
|
19
|
+
}
|
|
20
|
+
listByType(type) {
|
|
21
|
+
return this.registry.listByType(type);
|
|
22
|
+
}
|
|
23
|
+
listSupervisors() {
|
|
24
|
+
return this.registry.listSupervisors();
|
|
25
|
+
}
|
|
26
|
+
searchByKeywords(keywords) {
|
|
27
|
+
return this.registry.searchByKeywords(keywords);
|
|
28
|
+
}
|
|
29
|
+
getStats() {
|
|
30
|
+
return this.registry.getStats();
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.AgentFacade = AgentFacade;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCliContextHooks = createCliContextHooks;
|
|
4
|
+
const logger_1 = require("../../../infrastructure/logging/logger");
|
|
5
|
+
function isTokenOverflowError(error) {
|
|
6
|
+
const errorMessage = error.message.toLowerCase();
|
|
7
|
+
const tokenErrorKeywords = [
|
|
8
|
+
'maximum context length',
|
|
9
|
+
'too many tokens',
|
|
10
|
+
'context length exceeded',
|
|
11
|
+
'token limit',
|
|
12
|
+
'maximum tokens',
|
|
13
|
+
'context window',
|
|
14
|
+
'tokens exceed',
|
|
15
|
+
'prompt is too long',
|
|
16
|
+
];
|
|
17
|
+
return tokenErrorKeywords.some((keyword) => errorMessage.includes(keyword));
|
|
18
|
+
}
|
|
19
|
+
function createCliContextHooks(compressionManager, options) {
|
|
20
|
+
if (!compressionManager)
|
|
21
|
+
return undefined;
|
|
22
|
+
const maxRetries = Math.max(0, options?.maxRetries ?? 2);
|
|
23
|
+
return {
|
|
24
|
+
maxRetries,
|
|
25
|
+
isRetryableError: isTokenOverflowError,
|
|
26
|
+
beforeRequest: async ({ attempt, messages }) => {
|
|
27
|
+
try {
|
|
28
|
+
const state = { messages };
|
|
29
|
+
const shouldCompress = await compressionManager.checkProactiveCompression(state);
|
|
30
|
+
if (!shouldCompress)
|
|
31
|
+
return;
|
|
32
|
+
logger_1.logger.info(`[ContextHooks] Compressão proativa (attempt=${attempt})`);
|
|
33
|
+
const next = await compressionManager.performProactiveCompression(state);
|
|
34
|
+
return { messages: next.messages ?? messages };
|
|
35
|
+
}
|
|
36
|
+
catch (error) {
|
|
37
|
+
logger_1.logger.warn('[ContextHooks] Falha na compressão proativa, seguindo sem compressão', error);
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
onError: async ({ attempt, error, messages }) => {
|
|
42
|
+
if (!isTokenOverflowError(error))
|
|
43
|
+
return { retry: false };
|
|
44
|
+
try {
|
|
45
|
+
logger_1.logger.warn(`[ContextHooks] Estouro de tokens detectado (attempt=${attempt}), compressão emergencial e retry`);
|
|
46
|
+
const state = { messages };
|
|
47
|
+
const next = await compressionManager.handleTokenOverflow(error, state);
|
|
48
|
+
return { retry: true, messages: next.messages ?? messages };
|
|
49
|
+
}
|
|
50
|
+
catch (compressionError) {
|
|
51
|
+
logger_1.logger.error('[ContextHooks] Falha na compressão emergencial', compressionError);
|
|
52
|
+
return { retry: false };
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createCliContextHooks = void 0;
|
|
4
|
+
var compressionHook_1 = require("./compressionHook");
|
|
5
|
+
Object.defineProperty(exports, "createCliContextHooks", { enumerable: true, get: function () { return compressionHook_1.createCliContextHooks; } });
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadProjectRules = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const logger_1 = require("../../../infrastructure/logging/logger");
|
|
40
|
+
exports.loadProjectRules = {
|
|
41
|
+
load() {
|
|
42
|
+
const codeDirPath = path.join(process.cwd(), '.code', 'AGENTS.md');
|
|
43
|
+
const rootPath = path.join(process.cwd(), 'AGENTS.md');
|
|
44
|
+
if (fs.existsSync(codeDirPath)) {
|
|
45
|
+
const content = fs.readFileSync(codeDirPath, 'utf-8');
|
|
46
|
+
logger_1.logger.info(`[loadProjectRules] Carregado AGENTS.md de .code/: ${codeDirPath}`);
|
|
47
|
+
return { content, source: 'code-dir', path: codeDirPath };
|
|
48
|
+
}
|
|
49
|
+
if (fs.existsSync(rootPath)) {
|
|
50
|
+
const content = fs.readFileSync(rootPath, 'utf-8');
|
|
51
|
+
logger_1.logger.info(`[loadProjectRules] Carregado AGENTS.md da raiz: ${rootPath}`);
|
|
52
|
+
return { content, source: 'root', path: rootPath };
|
|
53
|
+
}
|
|
54
|
+
logger_1.logger.debug('[loadProjectRules] AGENTS.md não encontrado no projeto');
|
|
55
|
+
return { content: '', source: 'none', path: '' };
|
|
56
|
+
},
|
|
57
|
+
loadFromDirectory(directoryPath) {
|
|
58
|
+
const agentsMdPath = path.join(directoryPath, 'AGENTS.md');
|
|
59
|
+
const claudeMdPath = path.join(directoryPath, 'CLAUDE.md');
|
|
60
|
+
if (fs.existsSync(agentsMdPath)) {
|
|
61
|
+
const content = fs.readFileSync(agentsMdPath, 'utf-8');
|
|
62
|
+
logger_1.logger.debug(`[loadProjectRules] Carregado AGENTS.md de: ${agentsMdPath}`);
|
|
63
|
+
return content;
|
|
64
|
+
}
|
|
65
|
+
if (fs.existsSync(claudeMdPath)) {
|
|
66
|
+
const content = fs.readFileSync(claudeMdPath, 'utf-8');
|
|
67
|
+
logger_1.logger.debug(`[loadProjectRules] Carregado CLAUDE.md de: ${claudeMdPath}`);
|
|
68
|
+
return content;
|
|
69
|
+
}
|
|
70
|
+
return '';
|
|
71
|
+
}
|
|
72
|
+
};
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.loadSystemPrompt = void 0;
|
|
4
|
+
var loader_1 = require("./loader");
|
|
5
|
+
Object.defineProperty(exports, "loadSystemPrompt", { enumerable: true, get: function () { return loader_1.loadSystemPrompt; } });
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
+
exports.loadSystemPrompt = void 0;
|
|
37
|
+
const fs = __importStar(require("fs"));
|
|
38
|
+
const path = __importStar(require("path"));
|
|
39
|
+
const logger_1 = require("../../../infrastructure/logging/logger");
|
|
40
|
+
exports.loadSystemPrompt = {
|
|
41
|
+
loadFileContent(filename, compressionContext) {
|
|
42
|
+
try {
|
|
43
|
+
const possiblePaths = [
|
|
44
|
+
path.join(process.cwd(), 'src', 'prompts', filename),
|
|
45
|
+
path.join(__dirname, '..', 'prompts', filename),
|
|
46
|
+
path.join(__dirname, '..', '..', 'prompts', filename),
|
|
47
|
+
path.join(process.cwd(), 'prompts', filename),
|
|
48
|
+
path.join(__dirname, '..', '..', '..', 'prompts', filename),
|
|
49
|
+
];
|
|
50
|
+
let content = '';
|
|
51
|
+
let foundPath = '';
|
|
52
|
+
for (const promptPath of possiblePaths) {
|
|
53
|
+
if (fs.existsSync(promptPath)) {
|
|
54
|
+
content = fs.readFileSync(promptPath, 'utf-8');
|
|
55
|
+
foundPath = promptPath;
|
|
56
|
+
break;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!content) {
|
|
60
|
+
logger_1.logger.warn(`[loadSystemPrompt] Arquivo não encontrado: ${filename}`);
|
|
61
|
+
logger_1.logger.debug(`[loadSystemPrompt] Caminhos tentados:`, possiblePaths);
|
|
62
|
+
return '';
|
|
63
|
+
}
|
|
64
|
+
logger_1.logger.debug(`[loadSystemPrompt] Carregado de: ${foundPath}`);
|
|
65
|
+
if (compressionContext && compressionContext.trim().length > 0) {
|
|
66
|
+
content += '\n\n---\n\n## Contexto de Compressão\n\n' + compressionContext;
|
|
67
|
+
}
|
|
68
|
+
return content;
|
|
69
|
+
}
|
|
70
|
+
catch (error) {
|
|
71
|
+
logger_1.logger.error(`[loadSystemPrompt] Erro ao carregar ${filename}:`, error);
|
|
72
|
+
return '';
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
listPromptFiles() {
|
|
76
|
+
try {
|
|
77
|
+
const promptsDir = path.join(process.cwd(), 'src', 'prompts');
|
|
78
|
+
if (!fs.existsSync(promptsDir)) {
|
|
79
|
+
return [];
|
|
80
|
+
}
|
|
81
|
+
return fs.readdirSync(promptsDir).filter(f => f.endsWith('.md'));
|
|
82
|
+
}
|
|
83
|
+
catch (error) {
|
|
84
|
+
logger_1.logger.error('[loadSystemPrompt] Erro ao listar arquivos:', error);
|
|
85
|
+
return [];
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.REACT_AGENT_FLOW = void 0;
|
|
4
|
+
const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
|
|
5
|
+
exports.REACT_AGENT_FLOW = {
|
|
6
|
+
entryPoint: 'agent',
|
|
7
|
+
endNodeName: 'end',
|
|
8
|
+
nodes: {
|
|
9
|
+
agent: null,
|
|
10
|
+
validate: (0, frame_agent_sdk_1.createReactValidationNode)(),
|
|
11
|
+
detect: (0, frame_agent_sdk_1.createToolDetectionNode)(),
|
|
12
|
+
execute: (0, frame_agent_sdk_1.createToolExecutorNode)(),
|
|
13
|
+
end: async (state) => ({
|
|
14
|
+
...state,
|
|
15
|
+
status: frame_agent_sdk_1.GraphStatus.FINISHED,
|
|
16
|
+
shouldEnd: true
|
|
17
|
+
})
|
|
18
|
+
},
|
|
19
|
+
edges: {
|
|
20
|
+
agent: 'validate',
|
|
21
|
+
validate: (state) => {
|
|
22
|
+
const validationPassed = state.metadata?.validation?.passed !== false;
|
|
23
|
+
return validationPassed ? 'detect' : 'agent';
|
|
24
|
+
},
|
|
25
|
+
detect: (state) => {
|
|
26
|
+
const validationError = state.metadata?.validation?.error;
|
|
27
|
+
if (validationError) {
|
|
28
|
+
return 'agent';
|
|
29
|
+
}
|
|
30
|
+
const hasToolCall = !!state.lastToolCall;
|
|
31
|
+
if (hasToolCall) {
|
|
32
|
+
const toolName = state.lastToolCall?.toolName;
|
|
33
|
+
if (toolName === 'final_answer' || toolName === 'ask_user') {
|
|
34
|
+
return 'end';
|
|
35
|
+
}
|
|
36
|
+
return 'execute';
|
|
37
|
+
}
|
|
38
|
+
return 'end';
|
|
39
|
+
},
|
|
40
|
+
execute: (state) => {
|
|
41
|
+
const toolName = state.lastToolCall?.toolName;
|
|
42
|
+
if (toolName === 'final_answer' || toolName === 'ask_user') {
|
|
43
|
+
return 'end';
|
|
44
|
+
}
|
|
45
|
+
return 'agent';
|
|
46
|
+
},
|
|
47
|
+
end: 'end'
|
|
48
|
+
}
|
|
49
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./registry"), exports);
|
|
18
|
+
__exportStar(require("./AgentFacade"), exports);
|