@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.
- package/dist/agent-runtime/index.js +0 -1
- package/dist/agent-runtime/registry/AgentRegistry.js +108 -36
- package/dist/agent-runtime/registry/index.js +1 -11
- package/dist/app/cli.js +3 -5
- package/dist/cli/commands/autonomous.js +15 -12
- package/dist/cli/commands/interactive.js +71 -149
- package/dist/cli/commands/memory.js +247 -76
- package/dist/content/agents/README.md +36 -32
- package/dist/content/agents/architect.md +1 -1
- package/dist/content/agents/builder.md +10 -14
- package/dist/content/agents/code-agent.md +1 -95
- package/dist/index.js +0 -6
- package/dist/infrastructure/config/config.js +40 -0
- package/dist/infrastructure/telemetry/cliTelemetry.js +39 -0
- package/dist/tools/index.js +0 -2
- package/dist/tools/registry/ToolInitializer.js +15 -55
- package/dist/tools/registry/index.js +1 -7
- package/package.json +11 -23
- package/dist/agent-runtime/AgentFacade.js +0 -33
- package/dist/agent-runtime/context/hooks/compressionHook.js +0 -56
- package/dist/agent-runtime/context/hooks/index.js +0 -5
- package/dist/agent-runtime/context/project-rules/loader.js +0 -72
- package/dist/agent-runtime/context/system-prompts/index.js +0 -5
- package/dist/agent-runtime/context/system-prompts/loader.js +0 -88
- package/dist/agent-runtime/flows/templates/ReactAgentFlow.js +0 -49
- package/dist/agent-runtime/registry/agentParser.js +0 -515
- package/dist/agent-runtime/registry/enums/agentType.enum.js +0 -8
- package/dist/agent-runtime/registry/interfaces/agentDependencies.interface.js +0 -2
- package/dist/agent-runtime/registry/interfaces/agentRegistry.interface.js +0 -2
- package/dist/app/bootstrap.js +0 -22
- package/dist/app/index.js +0 -9
- package/dist/cli/commands/index.js +0 -11
- package/dist/cli/commands/multi-agent.js +0 -131
- package/dist/cli/index.js +0 -18
- package/dist/cli/input/images/imageInput.js +0 -77
- package/dist/cli/input/images/readImageAttachment.js +0 -56
- package/dist/cli/input/index.js +0 -14
- package/dist/infrastructure/compression/CompressionManager.js +0 -315
- package/dist/infrastructure/compression/LLMCompressionService.js +0 -211
- package/dist/infrastructure/compression/index.js +0 -11
- package/dist/infrastructure/compression/promptBuilder.js +0 -132
- package/dist/infrastructure/config/agentConfig.interface.js +0 -2
- package/dist/infrastructure/config/agentConfig.js +0 -134
- package/dist/infrastructure/logging/index.js +0 -5
- package/dist/infrastructure/logging/logger.interface.js +0 -2
- package/dist/infrastructure/logging/raw-output-logger.js +0 -35
- package/dist/infrastructure/skills/index.js +0 -5
- package/dist/infrastructure/skills/loader.js +0 -104
- package/dist/infrastructure/telemetry/index.js +0 -9
- package/dist/infrastructure/telemetry/telemetry.interface.js +0 -2
- package/dist/infrastructure/telemetry/telemetryConfig.js +0 -30
- package/dist/infrastructure/telemetry/traceEventFormatter.js +0 -90
- package/dist/infrastructure/telemetry/traceSinkConsole.js +0 -17
- package/dist/scripts/_validate/telemetry-autonomous.js +0 -23
- package/dist/scripts/_validate/telemetry-multi-agent.js +0 -50
- package/dist/scripts/_validate/test-agents-md-dynamic-dir.js +0 -104
- package/dist/scripts/_validate/test-agents-md-injection.js +0 -125
- package/dist/scripts/_validate/test-agents-md-loader.js +0 -71
- package/dist/scripts/_validate/test-agents-md-priority.js +0 -121
- package/dist/scripts/_validate/test-chrome-mcp-agent.js +0 -89
- package/dist/tools/mcp/discoverer.js +0 -95
- package/dist/tools/mcp/index.js +0 -9
- package/dist/tools/mcp/loader.js +0 -36
- package/dist/tools/mcp/mcpConfig.interface.js +0 -2
- package/dist/tools/mcp/mcpMetadata.js +0 -2
- package/dist/tools/mcp/register.js +0 -269
- package/dist/tools/native/capabilities.js +0 -155
- package/dist/tools/native/file-outline.js +0 -301
- package/dist/tools/native/index.js +0 -20
- package/dist/tools/native/list-directory.js +0 -148
- package/dist/tools/native/read-image.js +0 -140
- package/dist/tools/registry/toolFilter.js +0 -52
- package/dist/tools/registry/toolRegistry.interface.js +0 -2
|
@@ -1,211 +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.LLMCompressionService = void 0;
|
|
37
|
-
const logger_1 = require("../logging/logger");
|
|
38
|
-
const config_1 = require("../config");
|
|
39
|
-
class LLMCompressionService {
|
|
40
|
-
constructor(llmConfig) {
|
|
41
|
-
if (llmConfig) {
|
|
42
|
-
this.llmConfig = llmConfig;
|
|
43
|
-
this.modelName = llmConfig.model;
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
const config = (0, config_1.loadConfigSync)();
|
|
47
|
-
this.llmConfig = {
|
|
48
|
-
model: config.defaults?.model || 'gpt-4o-mini',
|
|
49
|
-
provider: config.provider,
|
|
50
|
-
apiKey: config.apiKey,
|
|
51
|
-
baseUrl: config.baseURL,
|
|
52
|
-
defaults: {
|
|
53
|
-
maxTokens: config.defaults?.maxTokens,
|
|
54
|
-
temperature: config.defaults?.temperature,
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
this.modelName = this.llmConfig.model;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
async compressInitial(context) {
|
|
61
|
-
const prompt = this.buildInitialCompressionPrompt(context);
|
|
62
|
-
logger_1.logger.info('[LLMCompressionService] Iniciando compressão inicial');
|
|
63
|
-
logger_1.logger.debug(`[LLMCompressionService] Contexto tem ${context.length} caracteres`);
|
|
64
|
-
try {
|
|
65
|
-
const result = await this.callLLM(prompt);
|
|
66
|
-
logger_1.logger.info('[LLMCompressionService] Compressão inicial concluída');
|
|
67
|
-
return result;
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
logger_1.logger.error('[LLMCompressionService] Erro na compressão inicial:', error);
|
|
71
|
-
throw new Error(`Falha na compressão inicial: ${error instanceof Error ? error.message : 'Erro desconhecido'}`);
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
async compressIncremental(compressoes, newContext) {
|
|
75
|
-
const compressionCount = compressoes.length + 1;
|
|
76
|
-
const prompt = this.buildIncrementalCompressionPrompt(compressoes, newContext, compressionCount);
|
|
77
|
-
logger_1.logger.info(`[LLMCompressionService] Iniciando compressão incremental #${compressionCount}`);
|
|
78
|
-
logger_1.logger.debug(`[LLMCompressionService] Baseado em ${compressoes.length} compressões anteriores`);
|
|
79
|
-
try {
|
|
80
|
-
const result = await this.callLLM(prompt);
|
|
81
|
-
logger_1.logger.info(`[LLMCompressionService] Compressão incremental #${compressionCount} concluída`);
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
catch (error) {
|
|
85
|
-
logger_1.logger.error(`[LLMCompressionService] Erro na compressão incremental #${compressionCount}:`, error);
|
|
86
|
-
throw new Error(`Falha na compressão incremental: ${error instanceof Error ? error.message : 'Erro desconhecido'}`);
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
async mergeCompressions(comp1, comp2) {
|
|
90
|
-
const prompt = this.buildMergeCompressionPrompt(comp1, comp2);
|
|
91
|
-
logger_1.logger.info('[LLMCompressionService] Iniciando mesclagem de compressões');
|
|
92
|
-
try {
|
|
93
|
-
const result = await this.callLLM(prompt);
|
|
94
|
-
logger_1.logger.info('[LLMCompressionService] Mesclagem de compressões concluída');
|
|
95
|
-
return result;
|
|
96
|
-
}
|
|
97
|
-
catch (error) {
|
|
98
|
-
logger_1.logger.error('[LLMCompressionService] Erro na mesclagem de compressões:', error);
|
|
99
|
-
throw new Error(`Falha na mesclagem de compressões: ${error instanceof Error ? error.message : 'Erro desconhecido'}`);
|
|
100
|
-
}
|
|
101
|
-
}
|
|
102
|
-
buildInitialCompressionPrompt(context) {
|
|
103
|
-
return `Você é um especialista em sumarizar conversas de desenvolvimento.
|
|
104
|
-
|
|
105
|
-
Comprima este contexto completo em uma sumarização concisa:
|
|
106
|
-
${context}
|
|
107
|
-
|
|
108
|
-
Formato obrigatório: "COMPRESSÃO 1: [sua sumarização]"
|
|
109
|
-
|
|
110
|
-
Preserve:
|
|
111
|
-
- Objetivos principais do projeto/sessão
|
|
112
|
-
- Contexto técnico essencial
|
|
113
|
-
- Primeiras decisões ou requisitos
|
|
114
|
-
- Arquivos ou tecnologias mencionadas
|
|
115
|
-
|
|
116
|
-
Priorize:
|
|
117
|
-
- Informações técnicas importantes sobre código, arquivos e decisões
|
|
118
|
-
- Requisitos e objetivos definidos
|
|
119
|
-
- Problemas e soluções identificados
|
|
120
|
-
|
|
121
|
-
Responda APENAS com a compressão no formato especificado, sem comentários adicionais.`;
|
|
122
|
-
}
|
|
123
|
-
buildIncrementalCompressionPrompt(compressoes, newContext, compressionNumber) {
|
|
124
|
-
const compressoesText = compressoes
|
|
125
|
-
.map((comp, index) => `COMPRESSÃO ${index + 1}: ${comp}`)
|
|
126
|
-
.join('\n');
|
|
127
|
-
return `Você está gerenciando o contexto acumulado de uma longa conversa de desenvolvimento.
|
|
128
|
-
|
|
129
|
-
Compressões anteriores acumuladas:
|
|
130
|
-
${compressoesText}
|
|
131
|
-
|
|
132
|
-
Novo contexto recente:
|
|
133
|
-
${newContext}
|
|
134
|
-
|
|
135
|
-
Crie uma nova compressão que INTEGRE TODAS as informações anteriores com o novo contexto.
|
|
136
|
-
|
|
137
|
-
Formato obrigatório: "COMPRESSÃO ${compressionNumber}: [nova sumarização integrada]"
|
|
138
|
-
|
|
139
|
-
Mantenha:
|
|
140
|
-
- Progresso acumulado do projeto
|
|
141
|
-
- Decisões importantes de todas as etapas
|
|
142
|
-
- Problemas resolvidos e pendências
|
|
143
|
-
- Continuidade do contexto técnico
|
|
144
|
-
|
|
145
|
-
Priorize:
|
|
146
|
-
- Informações técnicas importantes sobre código, arquivos e decisões
|
|
147
|
-
- Requisitos e objetivos definidos
|
|
148
|
-
- Problemas e soluções identificados
|
|
149
|
-
|
|
150
|
-
Responda APENAS com a compressão no formato especificado, sem comentários adicionais.`;
|
|
151
|
-
}
|
|
152
|
-
buildMergeCompressionPrompt(comp1, comp2) {
|
|
153
|
-
return `Mescla estas duas compressões antigas em uma única sumarização coesa:
|
|
154
|
-
|
|
155
|
-
COMPRESSÃO A: ${comp1}
|
|
156
|
-
COMPRESSÃO B: ${comp2}
|
|
157
|
-
|
|
158
|
-
Crie uma nova compressão combinada (máx 400 tokens) que preserve o essencial de ambas.
|
|
159
|
-
Formato: "COMPRESSÃO COMBINADA: [sumarização unificada]"
|
|
160
|
-
|
|
161
|
-
Responda APENAS com a compressão combinada no formato especificado, sem comentários adicionais.`;
|
|
162
|
-
}
|
|
163
|
-
async callLLM(prompt) {
|
|
164
|
-
const { OpenAI } = await Promise.resolve().then(() => __importStar(require('openai')));
|
|
165
|
-
const openai = new OpenAI({
|
|
166
|
-
apiKey: this.llmConfig.apiKey,
|
|
167
|
-
baseURL: this.llmConfig.baseUrl,
|
|
168
|
-
});
|
|
169
|
-
const config = (0, config_1.loadConfigSync)();
|
|
170
|
-
const maxTokens = config.compression?.maxTokens || 500;
|
|
171
|
-
try {
|
|
172
|
-
const response = await openai.chat.completions.create({
|
|
173
|
-
model: this.modelName,
|
|
174
|
-
messages: [
|
|
175
|
-
{
|
|
176
|
-
role: 'user',
|
|
177
|
-
content: prompt
|
|
178
|
-
}
|
|
179
|
-
],
|
|
180
|
-
max_tokens: maxTokens,
|
|
181
|
-
temperature: 0.3,
|
|
182
|
-
});
|
|
183
|
-
const content = response.choices[0]?.message?.content?.trim();
|
|
184
|
-
if (!content) {
|
|
185
|
-
throw new Error('Resposta vazia do LLM');
|
|
186
|
-
}
|
|
187
|
-
if (!content.includes('COMPRESSÃO')) {
|
|
188
|
-
logger_1.logger.warn('[LLMCompressionService] Formato da resposta não parece válido:', content);
|
|
189
|
-
}
|
|
190
|
-
return content;
|
|
191
|
-
}
|
|
192
|
-
catch (error) {
|
|
193
|
-
logger_1.logger.error('[LLMCompressionService] Erro na chamada ao LLM:', error);
|
|
194
|
-
throw error;
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
isConfigured() {
|
|
198
|
-
return !!(this.llmConfig.apiKey && this.llmConfig.model);
|
|
199
|
-
}
|
|
200
|
-
getConfigInfo() {
|
|
201
|
-
return {
|
|
202
|
-
model: this.modelName,
|
|
203
|
-
provider: this.llmConfig.provider,
|
|
204
|
-
hasApiKey: !!this.llmConfig.apiKey,
|
|
205
|
-
hasBaseUrl: !!this.llmConfig.baseUrl,
|
|
206
|
-
maxTokens: this.llmConfig.defaults?.maxTokens,
|
|
207
|
-
temperature: this.llmConfig.defaults?.temperature,
|
|
208
|
-
};
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
exports.LLMCompressionService = LLMCompressionService;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCompressionPromptConfig = exports.createDefaultPromptConfig = exports.CLIPromptBuilder = exports.LLMCompressionService = exports.CompressionManager = void 0;
|
|
4
|
-
var CompressionManager_1 = require("./CompressionManager");
|
|
5
|
-
Object.defineProperty(exports, "CompressionManager", { enumerable: true, get: function () { return CompressionManager_1.CompressionManager; } });
|
|
6
|
-
var LLMCompressionService_1 = require("./LLMCompressionService");
|
|
7
|
-
Object.defineProperty(exports, "LLMCompressionService", { enumerable: true, get: function () { return LLMCompressionService_1.LLMCompressionService; } });
|
|
8
|
-
var promptBuilder_1 = require("./promptBuilder");
|
|
9
|
-
Object.defineProperty(exports, "CLIPromptBuilder", { enumerable: true, get: function () { return promptBuilder_1.CLIPromptBuilder; } });
|
|
10
|
-
Object.defineProperty(exports, "createDefaultPromptConfig", { enumerable: true, get: function () { return promptBuilder_1.createDefaultPromptConfig; } });
|
|
11
|
-
Object.defineProperty(exports, "createCompressionPromptConfig", { enumerable: true, get: function () { return promptBuilder_1.createCompressionPromptConfig; } });
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLIPromptBuilder = void 0;
|
|
4
|
-
exports.createDefaultPromptConfig = createDefaultPromptConfig;
|
|
5
|
-
exports.createCompressionPromptConfig = createCompressionPromptConfig;
|
|
6
|
-
const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
|
|
7
|
-
const logger_1 = require("../logging/logger");
|
|
8
|
-
class CLIPromptBuilder {
|
|
9
|
-
static formatCompressionContext(compressionHistory) {
|
|
10
|
-
return [
|
|
11
|
-
'---',
|
|
12
|
-
'',
|
|
13
|
-
'## Context History',
|
|
14
|
-
'',
|
|
15
|
-
'O contexto anterior desta sessão foi comprimido para preservar informações importantes:',
|
|
16
|
-
'',
|
|
17
|
-
compressionHistory.trim(),
|
|
18
|
-
'',
|
|
19
|
-
'Use este contexto histórico para entender o que já foi discutido e continuar a conversa de forma coerente.'
|
|
20
|
-
].join('\n');
|
|
21
|
-
}
|
|
22
|
-
static buildSystemPrompt(config) {
|
|
23
|
-
const { mode, agentInfo, additionalInstructions, compressionHistory, tools, toolNames, taskList } = config;
|
|
24
|
-
let finalAdditionalInstructions = additionalInstructions || '';
|
|
25
|
-
if (compressionHistory && compressionHistory.trim().length > 0) {
|
|
26
|
-
const formattedCompressionContext = this.formatCompressionContext(compressionHistory);
|
|
27
|
-
if (finalAdditionalInstructions.trim().length > 0) {
|
|
28
|
-
finalAdditionalInstructions = finalAdditionalInstructions + '\n\n' + formattedCompressionContext;
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
finalAdditionalInstructions = formattedCompressionContext;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return frame_agent_sdk_1.PromptBuilder.buildSystemPrompt({
|
|
35
|
-
mode,
|
|
36
|
-
agentInfo,
|
|
37
|
-
additionalInstructions: finalAdditionalInstructions,
|
|
38
|
-
tools,
|
|
39
|
-
toolNames,
|
|
40
|
-
taskList
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
static buildSystemPromptWithCompression(mode, agentInfo, compressionHistory, options) {
|
|
44
|
-
return this.buildSystemPrompt({
|
|
45
|
-
mode,
|
|
46
|
-
agentInfo,
|
|
47
|
-
compressionHistory,
|
|
48
|
-
...options
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
static addCompressionToPrompt(existingPrompt, compressionHistory) {
|
|
52
|
-
if (!compressionHistory || compressionHistory.trim().length === 0) {
|
|
53
|
-
return existingPrompt;
|
|
54
|
-
}
|
|
55
|
-
const compressionSection = [
|
|
56
|
-
'---',
|
|
57
|
-
'',
|
|
58
|
-
'## Context History',
|
|
59
|
-
'',
|
|
60
|
-
compressionHistory.trim()
|
|
61
|
-
].join('\n');
|
|
62
|
-
const additionalInstructionsIndex = existingPrompt.indexOf('## Additional Instructions');
|
|
63
|
-
if (additionalInstructionsIndex > -1) {
|
|
64
|
-
const before = existingPrompt.substring(0, additionalInstructionsIndex);
|
|
65
|
-
const after = existingPrompt.substring(additionalInstructionsIndex);
|
|
66
|
-
return before + compressionSection + '\n\n' + after;
|
|
67
|
-
}
|
|
68
|
-
else {
|
|
69
|
-
return existingPrompt + '\n\n' + compressionSection;
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
static removeCompressionFromPrompt(prompt) {
|
|
73
|
-
const compressionSectionStart = prompt.indexOf('## Context History');
|
|
74
|
-
if (compressionSectionStart === -1) {
|
|
75
|
-
return prompt;
|
|
76
|
-
}
|
|
77
|
-
const compressionSectionContent = prompt.substring(compressionSectionStart);
|
|
78
|
-
const nextSectionIndex = compressionSectionContent.indexOf('\n---', 3);
|
|
79
|
-
if (nextSectionIndex > -1) {
|
|
80
|
-
const before = prompt.substring(0, compressionSectionStart);
|
|
81
|
-
const after = compressionSectionContent.substring(nextSectionIndex + 4);
|
|
82
|
-
return before + after;
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
return prompt.substring(0, compressionSectionStart).trim();
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
static hasCompressionContext(prompt) {
|
|
89
|
-
return prompt.includes('## Context History');
|
|
90
|
-
}
|
|
91
|
-
static extractCompressionContext(prompt) {
|
|
92
|
-
const compressionSectionStart = prompt.indexOf('## Context History');
|
|
93
|
-
if (compressionSectionStart === -1) {
|
|
94
|
-
return null;
|
|
95
|
-
}
|
|
96
|
-
const compressionSectionContent = prompt.substring(compressionSectionStart + '## Context History'.length);
|
|
97
|
-
const endOfSectionIndex = compressionSectionContent.indexOf('\n---');
|
|
98
|
-
if (endOfSectionIndex > -1) {
|
|
99
|
-
return compressionSectionContent.substring(1, endOfSectionIndex).trim();
|
|
100
|
-
}
|
|
101
|
-
else {
|
|
102
|
-
return compressionSectionContent.substring(1).trim();
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
static buildDebugPrompt(config) {
|
|
106
|
-
const prompt = this.buildSystemPrompt(config);
|
|
107
|
-
logger_1.logger.debug('[CLIPromptBuilder] Prompt construído:', {
|
|
108
|
-
mode: config.mode,
|
|
109
|
-
hasCompression: !!config.compressionHistory,
|
|
110
|
-
hasAdditionalInstructions: !!config.additionalInstructions,
|
|
111
|
-
hasTools: !!(config.tools || config.toolNames),
|
|
112
|
-
promptLength: prompt.length
|
|
113
|
-
});
|
|
114
|
-
return prompt;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.CLIPromptBuilder = CLIPromptBuilder;
|
|
118
|
-
function createDefaultPromptConfig(mode, agentInfo, additionalInstructions) {
|
|
119
|
-
return {
|
|
120
|
-
mode,
|
|
121
|
-
agentInfo,
|
|
122
|
-
additionalInstructions
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
function createCompressionPromptConfig(mode, agentInfo, compressionHistory, additionalInstructions) {
|
|
126
|
-
return {
|
|
127
|
-
mode,
|
|
128
|
-
agentInfo,
|
|
129
|
-
additionalInstructions,
|
|
130
|
-
compressionHistory
|
|
131
|
-
};
|
|
132
|
-
}
|
|
@@ -1,134 +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.loadAgentConfig = loadAgentConfig;
|
|
37
|
-
exports.clearConfigCache = clearConfigCache;
|
|
38
|
-
exports.reloadConfig = reloadConfig;
|
|
39
|
-
const fs = __importStar(require("fs"));
|
|
40
|
-
const path = __importStar(require("path"));
|
|
41
|
-
const logger_1 = require("../../infrastructure/logging/logger");
|
|
42
|
-
let configFileCache = null;
|
|
43
|
-
const ENV_VAR_REGEX = /\$\{([^}:]+)(?::-([^}]*))?\}/g;
|
|
44
|
-
function substituteEnvVars(value) {
|
|
45
|
-
if (typeof value !== 'string') {
|
|
46
|
-
return value;
|
|
47
|
-
}
|
|
48
|
-
return value.replace(ENV_VAR_REGEX, (_match, varName, defaultValue) => {
|
|
49
|
-
const envValue = process.env[varName];
|
|
50
|
-
if (envValue !== undefined) {
|
|
51
|
-
return envValue;
|
|
52
|
-
}
|
|
53
|
-
if (defaultValue !== undefined) {
|
|
54
|
-
return defaultValue;
|
|
55
|
-
}
|
|
56
|
-
return '';
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
|
-
function toNumberIfPossible(value) {
|
|
60
|
-
if (typeof value === 'string') {
|
|
61
|
-
const trimmed = value.trim();
|
|
62
|
-
if (/^-?\d+\.?\d*$/.test(trimmed)) {
|
|
63
|
-
return parseFloat(trimmed);
|
|
64
|
-
}
|
|
65
|
-
if (trimmed === 'true')
|
|
66
|
-
return true;
|
|
67
|
-
if (trimmed === 'false')
|
|
68
|
-
return false;
|
|
69
|
-
}
|
|
70
|
-
return value;
|
|
71
|
-
}
|
|
72
|
-
function substituteEnvVarsRecursive(config) {
|
|
73
|
-
if (typeof config === 'string') {
|
|
74
|
-
const substituted = substituteEnvVars(config);
|
|
75
|
-
return toNumberIfPossible(substituted);
|
|
76
|
-
}
|
|
77
|
-
if (Array.isArray(config)) {
|
|
78
|
-
return config.map(item => substituteEnvVarsRecursive(item));
|
|
79
|
-
}
|
|
80
|
-
if (config !== null && typeof config === 'object') {
|
|
81
|
-
const result = {};
|
|
82
|
-
for (const [key, value] of Object.entries(config)) {
|
|
83
|
-
result[key] = substituteEnvVarsRecursive(value);
|
|
84
|
-
}
|
|
85
|
-
return result;
|
|
86
|
-
}
|
|
87
|
-
return config;
|
|
88
|
-
}
|
|
89
|
-
function loadConfigFile() {
|
|
90
|
-
if (configFileCache !== null) {
|
|
91
|
-
return configFileCache;
|
|
92
|
-
}
|
|
93
|
-
const configPath = path.join(process.cwd(), '.code', 'config.json');
|
|
94
|
-
if (!fs.existsSync(configPath)) {
|
|
95
|
-
logger_1.logger.debug('[agentConfig] Arquivo .code/config.json não encontrado, usando apenas ENV');
|
|
96
|
-
return null;
|
|
97
|
-
}
|
|
98
|
-
try {
|
|
99
|
-
const content = fs.readFileSync(configPath, 'utf-8');
|
|
100
|
-
const parsed = JSON.parse(content);
|
|
101
|
-
configFileCache = parsed;
|
|
102
|
-
logger_1.logger.debug('[agentConfig] Arquivo .code/config.json carregado com sucesso');
|
|
103
|
-
return parsed;
|
|
104
|
-
}
|
|
105
|
-
catch (error) {
|
|
106
|
-
logger_1.logger.error('[agentConfig] Erro ao carregar .code/config.json:', error);
|
|
107
|
-
return null;
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
function loadAgentConfig(agentName) {
|
|
111
|
-
const configFile = loadConfigFile();
|
|
112
|
-
if (!configFile) {
|
|
113
|
-
return {
|
|
114
|
-
fromConfigFile: false
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
const agentSpecific = configFile.agents?.[agentName];
|
|
118
|
-
const merged = {
|
|
119
|
-
...(configFile.defaults || {}),
|
|
120
|
-
...(agentSpecific || {})
|
|
121
|
-
};
|
|
122
|
-
const resolved = substituteEnvVarsRecursive(merged);
|
|
123
|
-
return {
|
|
124
|
-
...resolved,
|
|
125
|
-
fromConfigFile: true
|
|
126
|
-
};
|
|
127
|
-
}
|
|
128
|
-
function clearConfigCache() {
|
|
129
|
-
configFileCache = null;
|
|
130
|
-
}
|
|
131
|
-
function reloadConfig() {
|
|
132
|
-
clearConfigCache();
|
|
133
|
-
loadConfigFile();
|
|
134
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isRawLlmOutputEnabled = isRawLlmOutputEnabled;
|
|
4
|
-
exports.logRawLlmOutput = logRawLlmOutput;
|
|
5
|
-
exports.instrumentGraphForRawLlmOutput = instrumentGraphForRawLlmOutput;
|
|
6
|
-
function envTruthy(value) {
|
|
7
|
-
if (!value)
|
|
8
|
-
return false;
|
|
9
|
-
const normalized = value.trim().toLowerCase();
|
|
10
|
-
return normalized === '1' || normalized === 'true' || normalized === 'yes' || normalized === 'on';
|
|
11
|
-
}
|
|
12
|
-
function isRawLlmOutputEnabled() {
|
|
13
|
-
return envTruthy(process.env.DEBUG_LLM_RAW_OUTPUT) || envTruthy(process.env.DEBUG_LLM_RAW);
|
|
14
|
-
}
|
|
15
|
-
function logRawLlmOutput(agentLabel, output) {
|
|
16
|
-
const header = `[LLM_RAW][${agentLabel}] (${output.length} chars)`;
|
|
17
|
-
console.log(`\n${header}\n${output}\n`);
|
|
18
|
-
}
|
|
19
|
-
function instrumentGraphForRawLlmOutput(graph, agentLabel) {
|
|
20
|
-
if (!isRawLlmOutputEnabled())
|
|
21
|
-
return graph;
|
|
22
|
-
const nodeId = 'agent';
|
|
23
|
-
const original = graph.nodes?.[nodeId];
|
|
24
|
-
if (!original)
|
|
25
|
-
return graph;
|
|
26
|
-
graph.nodes[nodeId] = async (state, engine) => {
|
|
27
|
-
const result = await original(state, engine);
|
|
28
|
-
const output = result?.lastModelOutput;
|
|
29
|
-
if (typeof output === 'string' && output.length > 0) {
|
|
30
|
-
logRawLlmOutput(agentLabel, output);
|
|
31
|
-
}
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
return graph;
|
|
35
|
-
}
|
|
@@ -1,104 +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.SkillLoader = void 0;
|
|
37
|
-
const fs = __importStar(require("fs"));
|
|
38
|
-
const path = __importStar(require("path"));
|
|
39
|
-
class SkillLoader {
|
|
40
|
-
constructor(skillsDir) {
|
|
41
|
-
this.skillsDir = skillsDir || path.join(process.cwd(), '.code');
|
|
42
|
-
}
|
|
43
|
-
parseSkillFile(filePath) {
|
|
44
|
-
try {
|
|
45
|
-
const content = fs.readFileSync(filePath, 'utf-8');
|
|
46
|
-
const lines = content.split('\n');
|
|
47
|
-
if (lines[0].trim() !== '---')
|
|
48
|
-
return null;
|
|
49
|
-
const frontmatter = {};
|
|
50
|
-
let i = 1;
|
|
51
|
-
for (; i < lines.length; i++) {
|
|
52
|
-
if (lines[i].trim() === '---')
|
|
53
|
-
break;
|
|
54
|
-
const [key, ...valueParts] = lines[i].split(':');
|
|
55
|
-
if (key && valueParts.length > 0) {
|
|
56
|
-
const value = valueParts.join(':').trim();
|
|
57
|
-
const cleanValue = value.replace(/^['"]|['"]$/g, '');
|
|
58
|
-
if (value.startsWith('[') && value.endsWith(']')) {
|
|
59
|
-
frontmatter[key.trim()] = value.slice(1, -1).split(',').map(s => s.trim().replace(/^['"]|['"]$/g, ''));
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
frontmatter[key.trim()] = cleanValue;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
}
|
|
66
|
-
if (!frontmatter.name)
|
|
67
|
-
return null;
|
|
68
|
-
return {
|
|
69
|
-
name: frontmatter.name,
|
|
70
|
-
description: frontmatter.description || '',
|
|
71
|
-
keywords: frontmatter.keywords || [],
|
|
72
|
-
path: filePath.replace(/\\/g, '/')
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
console.error(`Erro ao ler skill ${filePath}:`, e);
|
|
77
|
-
return null;
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
loadAllSkills() {
|
|
81
|
-
const skills = [];
|
|
82
|
-
if (!fs.existsSync(this.skillsDir))
|
|
83
|
-
return skills;
|
|
84
|
-
const entries = fs.readdirSync(this.skillsDir, { withFileTypes: true });
|
|
85
|
-
for (const entry of entries) {
|
|
86
|
-
if (entry.isDirectory()) {
|
|
87
|
-
const skillPath = path.join(this.skillsDir, entry.name, 'SKILL.md');
|
|
88
|
-
if (fs.existsSync(skillPath)) {
|
|
89
|
-
const skill = this.parseSkillFile(skillPath);
|
|
90
|
-
if (skill)
|
|
91
|
-
skills.push(skill);
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
else if (entry.name.endsWith('.md')) {
|
|
95
|
-
const skillPath = path.join(this.skillsDir, entry.name);
|
|
96
|
-
const skill = this.parseSkillFile(skillPath);
|
|
97
|
-
if (skill)
|
|
98
|
-
skills.push(skill);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
return skills;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
exports.SkillLoader = SkillLoader;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatTraceEventForTerminal = exports.ConsoleTraceSink = exports.createCliTelemetry = void 0;
|
|
4
|
-
var telemetryConfig_1 = require("./telemetryConfig");
|
|
5
|
-
Object.defineProperty(exports, "createCliTelemetry", { enumerable: true, get: function () { return telemetryConfig_1.createCliTelemetry; } });
|
|
6
|
-
var traceSinkConsole_1 = require("./traceSinkConsole");
|
|
7
|
-
Object.defineProperty(exports, "ConsoleTraceSink", { enumerable: true, get: function () { return traceSinkConsole_1.ConsoleTraceSink; } });
|
|
8
|
-
var traceEventFormatter_1 = require("./traceEventFormatter");
|
|
9
|
-
Object.defineProperty(exports, "formatTraceEventForTerminal", { enumerable: true, get: function () { return traceEventFormatter_1.formatTraceEventForTerminal; } });
|