@ericnunes/frame-code-cli 0.0.2 → 0.0.5

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 (73) hide show
  1. package/dist/agent-runtime/index.js +0 -1
  2. package/dist/agent-runtime/registry/AgentRegistry.js +108 -36
  3. package/dist/agent-runtime/registry/index.js +1 -11
  4. package/dist/app/cli.js +3 -5
  5. package/dist/cli/commands/autonomous.js +15 -12
  6. package/dist/cli/commands/interactive.js +71 -149
  7. package/dist/cli/commands/memory.js +247 -76
  8. package/dist/content/agents/README.md +36 -32
  9. package/dist/content/agents/architect.md +1 -1
  10. package/dist/content/agents/builder.md +10 -14
  11. package/dist/content/agents/code-agent.md +1 -95
  12. package/dist/index.js +0 -6
  13. package/dist/infrastructure/config/config.js +40 -0
  14. package/dist/infrastructure/telemetry/cliTelemetry.js +39 -0
  15. package/dist/tools/index.js +0 -2
  16. package/dist/tools/registry/ToolInitializer.js +15 -55
  17. package/dist/tools/registry/index.js +1 -7
  18. package/package.json +11 -23
  19. package/dist/agent-runtime/AgentFacade.js +0 -33
  20. package/dist/agent-runtime/context/hooks/compressionHook.js +0 -56
  21. package/dist/agent-runtime/context/hooks/index.js +0 -5
  22. package/dist/agent-runtime/context/project-rules/loader.js +0 -72
  23. package/dist/agent-runtime/context/system-prompts/index.js +0 -5
  24. package/dist/agent-runtime/context/system-prompts/loader.js +0 -88
  25. package/dist/agent-runtime/flows/templates/ReactAgentFlow.js +0 -49
  26. package/dist/agent-runtime/registry/agentParser.js +0 -515
  27. package/dist/agent-runtime/registry/enums/agentType.enum.js +0 -8
  28. package/dist/agent-runtime/registry/interfaces/agentDependencies.interface.js +0 -2
  29. package/dist/agent-runtime/registry/interfaces/agentRegistry.interface.js +0 -2
  30. package/dist/app/bootstrap.js +0 -22
  31. package/dist/app/index.js +0 -9
  32. package/dist/cli/commands/index.js +0 -11
  33. package/dist/cli/commands/multi-agent.js +0 -131
  34. package/dist/cli/index.js +0 -18
  35. package/dist/cli/input/images/imageInput.js +0 -77
  36. package/dist/cli/input/images/readImageAttachment.js +0 -56
  37. package/dist/cli/input/index.js +0 -14
  38. package/dist/infrastructure/compression/CompressionManager.js +0 -315
  39. package/dist/infrastructure/compression/LLMCompressionService.js +0 -211
  40. package/dist/infrastructure/compression/index.js +0 -11
  41. package/dist/infrastructure/compression/promptBuilder.js +0 -132
  42. package/dist/infrastructure/config/agentConfig.interface.js +0 -2
  43. package/dist/infrastructure/config/agentConfig.js +0 -134
  44. package/dist/infrastructure/logging/index.js +0 -5
  45. package/dist/infrastructure/logging/logger.interface.js +0 -2
  46. package/dist/infrastructure/logging/raw-output-logger.js +0 -35
  47. package/dist/infrastructure/skills/index.js +0 -5
  48. package/dist/infrastructure/skills/loader.js +0 -104
  49. package/dist/infrastructure/telemetry/index.js +0 -9
  50. package/dist/infrastructure/telemetry/telemetry.interface.js +0 -2
  51. package/dist/infrastructure/telemetry/telemetryConfig.js +0 -30
  52. package/dist/infrastructure/telemetry/traceEventFormatter.js +0 -90
  53. package/dist/infrastructure/telemetry/traceSinkConsole.js +0 -17
  54. package/dist/scripts/_validate/telemetry-autonomous.js +0 -23
  55. package/dist/scripts/_validate/telemetry-multi-agent.js +0 -50
  56. package/dist/scripts/_validate/test-agents-md-dynamic-dir.js +0 -104
  57. package/dist/scripts/_validate/test-agents-md-injection.js +0 -125
  58. package/dist/scripts/_validate/test-agents-md-loader.js +0 -71
  59. package/dist/scripts/_validate/test-agents-md-priority.js +0 -121
  60. package/dist/scripts/_validate/test-chrome-mcp-agent.js +0 -89
  61. package/dist/tools/mcp/discoverer.js +0 -95
  62. package/dist/tools/mcp/index.js +0 -9
  63. package/dist/tools/mcp/loader.js +0 -36
  64. package/dist/tools/mcp/mcpConfig.interface.js +0 -2
  65. package/dist/tools/mcp/mcpMetadata.js +0 -2
  66. package/dist/tools/mcp/register.js +0 -269
  67. package/dist/tools/native/capabilities.js +0 -155
  68. package/dist/tools/native/file-outline.js +0 -301
  69. package/dist/tools/native/index.js +0 -20
  70. package/dist/tools/native/list-directory.js +0 -148
  71. package/dist/tools/native/read-image.js +0 -140
  72. package/dist/tools/registry/toolFilter.js +0 -52
  73. package/dist/tools/registry/toolRegistry.interface.js +0 -2
@@ -16,106 +16,12 @@ additionalInstructions: |
16
16
  2. **Integridade de Dados**: Você trata o sistema de arquivos do projeto atual como sagrado. Jamais destrói para consertar.
17
17
  3. **Metodologia Científica**: Você planeja, executa, mede e, se falhar, ajusta a hipótese (estratégia) em vez de forçar a mesma solução.
18
18
 
19
- ## O Algoritmo de Execução (State Machine)
20
- A cada turno, você deve avaliar seu estado atual e escolher o caminho lógico. Você alterna chapéus entre "Arquiteto" e "Engenheiro".
21
-
22
- ### 1. ESTADO: Aquisição de Contexto (Exploração)
23
- **Quando:** No início da missão ou se você não sabe a estrutura de arquivos necessária para a tarefa atual.
24
-
25
- **Ação:**
26
- * Use `list_directory` ou `search` para mapear a base de código.
27
- * **Regra:** Jamais crie um plano baseado em alucinação. Olhe os arquivos primeiro, planeje depois.
28
-
29
- ### 2. ESTADO: Engenharia de Especificação (O Planejador)
30
- **Quando:** Você tem contexto, mas a lista de tarefas está vazia ou a solicitação do usuário é complexa/vaga.
31
-
32
- **Ação:**
33
- * **Decomposição Atômica (Task Decomposer):** Não aceite tarefas vagas como "Fazer o Login". Quebre em passos executáveis:
34
- 1. "Criar Interface Auth"
35
- 2. "Implementar Serviço de Login"
36
- 3. "Escrever Testes Unitários"
37
- * **Critério de Sucesso:** Cada tarefa deve ter um resultado verificável (um arquivo criado, um teste passando).
38
- * **Execução:** Use `toDoIst` -> `add` para registrar esse plano detalhado antes de escrever qualquer código.
39
-
40
- ### 3. ESTADO: Execução Focada (Deep Work)
41
- **Quando:** Existe uma tarefa `pending` ou `in_progress` e o plano está claro.
42
-
43
- **Ação:**
44
- 1. Selecione a **primeira** tarefa pendente. Mude para `in_progress`.
45
- 2. Execute a ferramenta técnica (`file_write`, `file_edit`, `terminal`, etc).
46
- 3. **Gestão de Memória (Anti-Loop):** Antes de ler um arquivo (`file_read`), verifique o histórico do chat.
47
- * Se o conteúdo já foi exibido anteriormente: **NÃO LEIA DE NOVO**. Use o contexto.
48
- * Se é novo: Leia.
49
-
50
- ### 4. ESTADO: Garantia de Qualidade (O Avaliador)
51
- **Quando:** Você acabou de executar uma ação técnica.
52
-
53
- **Ação:**
54
- * **Auto-Crítica (Evaluator Loop):** Analise a `Observation`. O resultado está tecnicamente perfeito?
55
- * *Sim:* Tenho evidências (logs/leitura). Use `toDoIst` -> `update_status` para `completed`.
56
- * *Não/Parcial:* O código tem erro de sintaxe? O teste falhou? **NÃO** marque como completo.
57
- * **Correção Imediata:** Se falhou, use `toDoIst` -> `add` para criar uma subtarefa de correção (ex: "Corrigir erro de tipagem na linha 20") e execute-a no próximo turno.
58
-
59
- ### 5. ESTADO: Finalização
60
- **Quando:** Todas as tarefas estão `completed`.
61
-
62
- **Ação:** Use `final_answer` para entregar o trabalho.
63
-
64
19
  ## Regras de Ouro
65
- 1. **Planeje Antes de Codar:** Jamais comece a gerar código sem uma tarefa clara na `toDoIst`. Se o pedido mudou, atualize a lista primeiro.
20
+ 1. **Planeje Antes de Codar:** Jamais comece a gerar código sem uma tarefa clara na lista de tarefas (`toDoIst`).
66
21
  2. **Atomicidade:** Uma tarefa na lista = Uma ação técnica verificável. Não faça "Analisar e Criar" na mesma task. Quebre em duas.
67
22
  3. **Evidência Obrigatória:** Nunca assuma que um arquivo foi criado só porque você mandou o comando. Se não houve erro, confie. Se houve dúvida, verifique.
68
23
  4. **Resiliência Aditiva:** Se encontrar um erro, **não apague o projeto**. Crie arquivos de correção ou reverta a última mudança específica.
69
24
  5. **Auditoria Constante:** Você é o autor e o auditor. Se o output de um comando `terminal` mostrar erro, sua prioridade máxima se torna consertar esse erro antes de prosseguir.
70
-
71
- ## Estilo de Pensamento e Exemplos
72
-
73
- Para navegar entre os estados, seus `Thoughts` devem ser explícitos sobre onde você está no processo.
74
-
75
- ### Exemplo 1: Estado 1 -> Estado 2 (Exploração para Planejamento)
76
- **Input:** "Crie um script python que some dois números."
77
- **Execução:**
78
-
79
- Thought: [ESTADO: Aquisição de Contexto] Preciso ver onde salvar esse script. Vou listar a raiz.
80
- Action: list_directory = { "directory": "." }
81
-
82
- Observation: [files: main.py, requirements.txt]
83
-
84
- Thought: [ESTADO: Engenharia de Especificação] Já entendi a estrutura. Vou criar o plano de execução no ToDoIst.
85
- Action: toDoIst = { "action": "add", "tasks": ["Criar sum.py com a função", "Criar test_sum.py", "Executar teste"] }
86
-
87
- ### Exemplo 2: Estado 3 (Execução Focada)
88
- **Contexto:** Tarefa "Criar sum.py" está pendente.
89
- **Execução:**
90
-
91
- Thought: [ESTADO: Execução Focada] Vou pegar a tarefa de criar o arquivo e executá-la.
92
- Action: toDoIst = { "action": "update_status", "title": "Criar sum.py com a função", "status": "in_progress" }
93
-
94
- Observation: [Task Updated]
95
-
96
- Thought: Agora vou escrever o código.
97
- Action: file_write = { "filePath": "sum.py", "content": "def sum(a, b):\n return a + b" }
98
-
99
- ### Exemplo 3: Estado 4 (Garantia de Qualidade - O Pulo do Gato)
100
- **Contexto:** Acabou de criar o arquivo.
101
- **Execução:**
102
-
103
- Thought: [ESTADO: Garantia de Qualidade] O arquivo foi escrito, mas preciso provar que funciona antes de marcar como pronto. Vou rodar um teste rápido no terminal.
104
- Action: terminal = { "action": "create", "command": "python -c 'from sum import sum; print(sum(2,3))'" }
105
-
106
- Observation: 5
107
-
108
- Thought: [ESTADO: Garantia de Qualidade] O output foi 5, como esperado. A tarefa está validada.
109
- Action: toDoIst = { "action": "update_status", "title": "Criar sum.py com a função", "status": "completed" }
110
-
111
- ### Exemplo 4: Erro na Qualidade (Auto-Correção)
112
- **Cenário:** O teste falhou.
113
- **Execução:**
114
-
115
- Observation: SyntaxError: invalid syntax
116
-
117
- Thought: [ESTADO: Garantia de Qualidade] O teste falhou. NÃO posso concluir a tarefa. Devo criar uma subtarefa de correção. A
118
- ction: toDoIst = { "action": "add", "tasks": ["Corrigir erro de sintaxe em sum.py"] }
119
25
  ---
120
26
 
121
27
  # Code Agent (Autonomous & Resilient)
package/dist/index.js CHANGED
@@ -15,11 +15,5 @@ if (!process.env.LC_ALL) {
15
15
  }
16
16
  const logger_1 = require("./infrastructure/logging/logger");
17
17
  logger_1.logger.info('[FrameCodeCLI] Iniciando CLI...');
18
- const agent_runtime_1 = require("./agent-runtime");
19
- (0, agent_runtime_1.initializeAgents)().then((count) => {
20
- logger_1.logger.info(`[FrameCodeCLI] ${count} agentes carregados`);
21
- }).catch((error) => {
22
- logger_1.logger.error('[FrameCodeCLI] Erro ao carregar agentes:', error);
23
- });
24
18
  const cli_1 = require("./app/cli");
25
19
  (0, cli_1.runCli)();
@@ -39,6 +39,38 @@ const dotenv = __importStar(require("dotenv"));
39
39
  const fs_1 = require("fs");
40
40
  const path_1 = require("path");
41
41
  let envLoaded = false;
42
+ function applyCompatEnv() {
43
+ if (!process.env.LLM_PROVIDER && process.env.ORCHESTRATOR_PROVIDER) {
44
+ process.env.LLM_PROVIDER = process.env.ORCHESTRATOR_PROVIDER;
45
+ }
46
+ if (!process.env.LLM_API_KEY && process.env.ORCHESTRATOR_API_KEY) {
47
+ process.env.LLM_API_KEY = process.env.ORCHESTRATOR_API_KEY;
48
+ }
49
+ if (!process.env.LLM_BASE_URL && process.env.ORCHESTRATOR_BASE_URL) {
50
+ process.env.LLM_BASE_URL = process.env.ORCHESTRATOR_BASE_URL;
51
+ }
52
+ if (!process.env.LLM_DEFAULT_MODEL && process.env.ORCHESTRATOR_MODEL) {
53
+ process.env.LLM_DEFAULT_MODEL = process.env.ORCHESTRATOR_MODEL;
54
+ }
55
+ if (!process.env.LLM_MAX_TOKENS && process.env.ORCHESTRATOR_MAX_TOKENS) {
56
+ process.env.LLM_MAX_TOKENS = process.env.ORCHESTRATOR_MAX_TOKENS;
57
+ }
58
+ if (!process.env.LLM_MAX_OUTPUT_TOKENS && process.env.ORCHESTRATOR_MAX_OUTPUT_TOKENS) {
59
+ process.env.LLM_MAX_OUTPUT_TOKENS = process.env.ORCHESTRATOR_MAX_OUTPUT_TOKENS;
60
+ }
61
+ if (!process.env.LLM_VISION_PROVIDER && process.env.VISION_PROVIDER) {
62
+ process.env.LLM_VISION_PROVIDER = process.env.VISION_PROVIDER;
63
+ }
64
+ if (!process.env.LLM_VISION_API_KEY && process.env.VISION_API_KEY) {
65
+ process.env.LLM_VISION_API_KEY = process.env.VISION_API_KEY;
66
+ }
67
+ if (!process.env.LLM_VISION_BASE_URL && process.env.VISION_BASE_URL) {
68
+ process.env.LLM_VISION_BASE_URL = process.env.VISION_BASE_URL;
69
+ }
70
+ if (!process.env.LLM_VISION_MODEL && process.env.VISION_MODEL) {
71
+ process.env.LLM_VISION_MODEL = process.env.VISION_MODEL;
72
+ }
73
+ }
42
74
  function ensureEnvLoaded() {
43
75
  if (envLoaded)
44
76
  return;
@@ -47,6 +79,14 @@ function ensureEnvLoaded() {
47
79
  if ((0, fs_1.existsSync)(localEnvPath)) {
48
80
  dotenv.config({ path: localEnvPath });
49
81
  }
82
+ const envProfile = process.env.ENV_PROFILE || process.env.LLM_ENV_PROFILE;
83
+ if (envProfile === 'chutes') {
84
+ const chutesEnvPath = (0, path_1.join)(process.cwd(), '.env.chutes');
85
+ if ((0, fs_1.existsSync)(chutesEnvPath)) {
86
+ dotenv.config({ path: chutesEnvPath, override: true });
87
+ }
88
+ }
89
+ applyCompatEnv();
50
90
  envLoaded = true;
51
91
  }
52
92
  async function loadConfig() {
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createCliTelemetry = createCliTelemetry;
4
+ const frame_agent_core_1 = require("@ericnunes/frame-agent-core");
5
+ function readBool(value, defaultValue) {
6
+ if (value == null)
7
+ return defaultValue;
8
+ if (value === '1')
9
+ return true;
10
+ if (value === '0')
11
+ return false;
12
+ return value.toLowerCase() === 'true';
13
+ }
14
+ function readInt(value, defaultValue) {
15
+ if (value == null || value.trim().length === 0)
16
+ return defaultValue;
17
+ const parsed = Number.parseInt(value, 10);
18
+ return Number.isFinite(parsed) ? parsed : defaultValue;
19
+ }
20
+ function createCliTelemetry() {
21
+ const includePrompts = readBool(process.env.TELEMETRY_INCLUDE_PROMPTS, false);
22
+ const nativeOpenAIEnabled = readBool(process.env.LANGFUSE_OPENAI_NATIVE_ENABLED ?? process.env.LANGFUSE_NATIVE_OPENAI_ENABLED, true);
23
+ const maxPayloadChars = process.env.TELEMETRY_MAX_PAYLOAD_CHARS != null
24
+ ? readInt(process.env.TELEMETRY_MAX_PAYLOAD_CHARS, 4000)
25
+ : includePrompts
26
+ ? 200000
27
+ : 4000;
28
+ const maxEvents = process.env.TELEMETRY_MAX_EVENTS != null
29
+ ? readInt(process.env.TELEMETRY_MAX_EVENTS, 200)
30
+ : undefined;
31
+ return frame_agent_core_1.telemetry.createDefaultTelemetry({
32
+ includePrompts,
33
+ maxPayloadChars,
34
+ ...(maxEvents != null ? { maxEvents } : {}),
35
+ langfuse: {
36
+ nativeOpenAIEnabled,
37
+ },
38
+ });
39
+ }
@@ -15,5 +15,3 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./registry"), exports);
18
- __exportStar(require("./native"), exports);
19
- __exportStar(require("./mcp"), exports);
@@ -1,62 +1,22 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.toolRegistry = void 0;
4
3
  exports.initializeTools = initializeTools;
5
- const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
6
- Object.defineProperty(exports, "toolRegistry", { enumerable: true, get: function () { return frame_agent_sdk_1.toolRegistry; } });
7
- const native_1 = require("../native");
8
- const register_1 = require("../mcp/register");
9
- const logger_1 = require("../../infrastructure/logging/logger");
4
+ const path_1 = require("path");
10
5
  const config_1 = require("../../infrastructure/config");
11
- const toolFilter_1 = require("./toolFilter");
12
- let toolsInitialized = false;
6
+ function resolveProfile() {
7
+ return process.env.AGENT_MODE === 'autonomous' ? 'ci_headless' : 'developer_exec';
8
+ }
9
+ function resolveExcludedTools() {
10
+ const raw = process.env.EXCLUDED_TOOLS || '';
11
+ return raw
12
+ .split(',')
13
+ .map((t) => t.trim())
14
+ .filter(Boolean);
15
+ }
13
16
  async function initializeTools(options) {
14
- if (toolsInitialized) {
15
- return;
16
- }
17
17
  (0, config_1.loadConfigSync)();
18
- const filterConfig = (() => {
19
- const base = (0, toolFilter_1.getToolFilterConfig)();
20
- if (typeof options?.allowAskUser === 'boolean') {
21
- return { ...base, allowAskUser: options.allowAskUser };
22
- }
23
- return base;
24
- })();
25
- const allTools = [
26
- native_1.searchTool,
27
- native_1.listDirectoryTool,
28
- native_1.readImageTool,
29
- native_1.fileCreateTool,
30
- native_1.fileEditTool,
31
- native_1.fileReadTool,
32
- native_1.terminalTool,
33
- native_1.sleepTool,
34
- native_1.fileOutlineTool,
35
- native_1.listCapabilitiesTool,
36
- native_1.enableCapabilityTool,
37
- native_1.toDoIstTool,
38
- new frame_agent_sdk_1.FinalAnswerTool(),
39
- new frame_agent_sdk_1.CallFlowTool(new frame_agent_sdk_1.FlowRunnerImpl(new frame_agent_sdk_1.FlowRegistryImpl(), {}))
40
- ];
41
- if (filterConfig.allowAskUser) {
42
- allTools.push(new frame_agent_sdk_1.AskUserTool());
43
- }
44
- const filteredTools = allTools.filter(tool => (0, toolFilter_1.shouldIncludeTool)(tool, filterConfig));
45
- filteredTools.forEach(tool => {
46
- try {
47
- frame_agent_sdk_1.toolRegistry.register(tool);
48
- }
49
- catch (error) {
50
- logger_1.logger.warn(`Falha ao registrar ferramenta ${tool.name}:`, error);
51
- }
52
- });
53
- if (filterConfig.mcpToolsEnabled) {
54
- try {
55
- await (0, register_1.registerMcpTools)();
56
- }
57
- catch (err) {
58
- logger_1.logger.error('Erro ao registrar MCP tools:', err);
59
- }
60
- }
61
- toolsInitialized = true;
18
+ void options;
19
+ void resolveProfile;
20
+ void resolveExcludedTools;
21
+ void path_1.resolve;
62
22
  }
@@ -1,11 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getToolFilterConfig = exports.filterToolsByPolicy = exports.filterTools = exports.shouldIncludeTool = exports.toolRegistry = exports.initializeTools = void 0;
3
+ exports.initializeTools = void 0;
4
4
  var ToolInitializer_1 = require("./ToolInitializer");
5
5
  Object.defineProperty(exports, "initializeTools", { enumerable: true, get: function () { return ToolInitializer_1.initializeTools; } });
6
- Object.defineProperty(exports, "toolRegistry", { enumerable: true, get: function () { return ToolInitializer_1.toolRegistry; } });
7
- var toolFilter_1 = require("./toolFilter");
8
- Object.defineProperty(exports, "shouldIncludeTool", { enumerable: true, get: function () { return toolFilter_1.shouldIncludeTool; } });
9
- Object.defineProperty(exports, "filterTools", { enumerable: true, get: function () { return toolFilter_1.filterTools; } });
10
- Object.defineProperty(exports, "filterToolsByPolicy", { enumerable: true, get: function () { return toolFilter_1.filterToolsByPolicy; } });
11
- Object.defineProperty(exports, "getToolFilterConfig", { enumerable: true, get: function () { return toolFilter_1.getToolFilterConfig; } });
package/package.json CHANGED
@@ -1,19 +1,19 @@
1
1
  {
2
2
  "name": "@ericnunes/frame-code-cli",
3
- "version": "0.0.2",
4
- "description": "CLI para interagir com agentes de codificação criados com o frame-agent-sdk",
3
+ "version": "0.0.5",
4
+ "description": "CLI para interagir com agentes (runtime via frame-agent-core)",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
7
7
  "frame-code": "dist/index.js"
8
8
  },
9
9
  "repository": {
10
10
  "type": "git",
11
- "url": "git+https://github.com/ericnunes/frame-code-cli.git"
11
+ "url": "git+https://github.com/ericnunes30/frame-code-cli.git"
12
12
  },
13
13
  "bugs": {
14
- "url": "https://github.com/ericnunes/frame-code-cli/issues"
14
+ "url": "https://github.com/ericnunes30/frame-code-cli/issues"
15
15
  },
16
- "homepage": "https://github.com/ericnunes/frame-code-cli#readme",
16
+ "homepage": "https://github.com/ericnunes30/frame-code-cli#readme",
17
17
  "files": [
18
18
  "dist",
19
19
  "README.md",
@@ -23,20 +23,17 @@
23
23
  "access": "public"
24
24
  },
25
25
  "scripts": {
26
- "build": "tsc && npm run copy:agents",
26
+ "build": "npm run clean && tsc && npm run copy:agents",
27
27
  "copy:agents": "npx cpy \"src/content/agents/*.md\" \"dist/content/agents\"",
28
28
  "dev": "ts-node src/index.ts",
29
29
  "start": "node dist/index.js",
30
30
  "autonomous": "node dist/index.js autonomous",
31
- "multi-agent": "node dist/index.js multi-agent",
32
- "test:mcp": "ts-node scripts/test-mcp.ts",
33
- "interactive": "chmod +x src/scripts/capture-logs.sh && src/scripts/capture-logs.sh npm run dev interactive",
34
- "dev:logs": "bash src/scripts/capture-logs.sh npm run dev interactive",
35
- "dev:start": "npm run dev interactive",
31
+ "interactive": "node dist/index.js interactive",
32
+ "test:core-migration": "ts-node scripts/test-core-migration.ts",
36
33
  "log:view": "tail -f server.log",
37
34
  "log:clear": "rm -f server.log",
38
35
  "log:stats": "ls -la server.log",
39
- "clean": "rm -rf dist"
36
+ "clean": "node -e \"require('fs').rmSync('dist', { recursive: true, force: true })\""
40
37
  },
41
38
  "keywords": [
42
39
  "cli",
@@ -47,18 +44,9 @@
47
44
  "author": "Eric Nunes",
48
45
  "license": "SEE LICENSE IN LICENSE",
49
46
  "dependencies": {
50
- "@ericnunes/frame-agent-sdk": "^0.0.3",
51
- "@modelcontextprotocol/sdk": "^1.23.0",
52
- "@typescript-eslint/typescript-estree": "^8.48.0",
53
- "chalk": "^5.6.2",
47
+ "@ericnunes/frame-agent-core": ">=0.0.5 <0.1.0",
54
48
  "commander": "^14.0.1",
55
- "dotenv": "^17.2.3",
56
- "eventsource": "^4.1.0",
57
- "fast-diff": "^1.3.0",
58
- "glob": "^11.0.3",
59
- "inquirer": "^12.9.6",
60
- "openai": "^6.10.0",
61
- "tree-kill": "^1.2.2"
49
+ "dotenv": "^17.2.3"
62
50
  },
63
51
  "devDependencies": {
64
52
  "@types/dotenv": "^6.1.1",
@@ -1,33 +0,0 @@
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;
@@ -1,56 +0,0 @@
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
- }
@@ -1,5 +0,0 @@
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; } });
@@ -1,72 +0,0 @@
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
- };
@@ -1,5 +0,0 @@
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; } });
@@ -1,88 +0,0 @@
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
- };