@ericnunes/frame-code-cli 0.0.1 → 0.0.3
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 +8 -6
- package/dist/cli/commands/interactive.js +63 -146
- 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 +11 -15
- 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/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,126 +1,298 @@
|
|
|
1
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
|
+
})();
|
|
2
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
36
|
exports.memoryCommand = void 0;
|
|
4
37
|
exports.createMemoryCommand = createMemoryCommand;
|
|
5
38
|
const commander_1 = require("commander");
|
|
6
|
-
const
|
|
39
|
+
const fs = __importStar(require("fs"));
|
|
40
|
+
const path = __importStar(require("path"));
|
|
7
41
|
const logger_1 = require("../../infrastructure/logging/logger");
|
|
8
42
|
const config_1 = require("../../infrastructure/config");
|
|
43
|
+
const PRIMARY_PREFIX = '.frame-agent-compressions.';
|
|
44
|
+
const LEGACY_PREFIX = '.frame-code-compressions.';
|
|
45
|
+
const JSON_SUFFIX = '.json';
|
|
46
|
+
function extractKeyFromFilename(filename) {
|
|
47
|
+
if (filename.startsWith(PRIMARY_PREFIX) && filename.endsWith(JSON_SUFFIX)) {
|
|
48
|
+
return filename.slice(PRIMARY_PREFIX.length, -JSON_SUFFIX.length);
|
|
49
|
+
}
|
|
50
|
+
if (filename.startsWith(LEGACY_PREFIX) && filename.endsWith(JSON_SUFFIX)) {
|
|
51
|
+
return filename.slice(LEGACY_PREFIX.length, -JSON_SUFFIX.length);
|
|
52
|
+
}
|
|
53
|
+
return undefined;
|
|
54
|
+
}
|
|
55
|
+
function safeParseJsonFile(filePath) {
|
|
56
|
+
try {
|
|
57
|
+
const raw = fs.readFileSync(filePath, 'utf-8');
|
|
58
|
+
return JSON.parse(raw);
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function toStringOrUndefined(value) {
|
|
65
|
+
return typeof value === 'string' && value.trim() ? value : undefined;
|
|
66
|
+
}
|
|
67
|
+
function toNumberOrZero(value) {
|
|
68
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : 0;
|
|
69
|
+
}
|
|
70
|
+
function toStringArray(value) {
|
|
71
|
+
if (!Array.isArray(value))
|
|
72
|
+
return [];
|
|
73
|
+
return value.filter((x) => typeof x === 'string');
|
|
74
|
+
}
|
|
75
|
+
function listPersistedCompressionFiles(projectRoot) {
|
|
76
|
+
let entries = [];
|
|
77
|
+
try {
|
|
78
|
+
entries = fs.readdirSync(projectRoot);
|
|
79
|
+
}
|
|
80
|
+
catch {
|
|
81
|
+
return [];
|
|
82
|
+
}
|
|
83
|
+
const map = new Map();
|
|
84
|
+
for (const filename of entries) {
|
|
85
|
+
const key = extractKeyFromFilename(filename);
|
|
86
|
+
if (!key)
|
|
87
|
+
continue;
|
|
88
|
+
const fullPath = path.join(projectRoot, filename);
|
|
89
|
+
const existing = map.get(key) ?? { key };
|
|
90
|
+
if (filename.startsWith(PRIMARY_PREFIX)) {
|
|
91
|
+
existing.primaryPath = fullPath;
|
|
92
|
+
}
|
|
93
|
+
else if (filename.startsWith(LEGACY_PREFIX)) {
|
|
94
|
+
existing.legacyPath = fullPath;
|
|
95
|
+
}
|
|
96
|
+
map.set(key, existing);
|
|
97
|
+
}
|
|
98
|
+
return Array.from(map.values()).sort((a, b) => a.key.localeCompare(b.key));
|
|
99
|
+
}
|
|
100
|
+
function resolveKeyFromOptions(options) {
|
|
101
|
+
const key = options?.key?.trim();
|
|
102
|
+
if (key)
|
|
103
|
+
return key;
|
|
104
|
+
const agent = options?.agent?.trim();
|
|
105
|
+
if (agent)
|
|
106
|
+
return `agent-${agent}`;
|
|
107
|
+
return undefined;
|
|
108
|
+
}
|
|
109
|
+
function removeFileIfExists(filePath) {
|
|
110
|
+
if (!filePath)
|
|
111
|
+
return false;
|
|
112
|
+
try {
|
|
113
|
+
fs.unlinkSync(filePath);
|
|
114
|
+
return true;
|
|
115
|
+
}
|
|
116
|
+
catch {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
9
120
|
function createMemoryStatusCommand() {
|
|
10
121
|
const command = new commander_1.Command('status');
|
|
11
122
|
command
|
|
12
|
-
.description('
|
|
13
|
-
.
|
|
123
|
+
.description('Show compression/memory status (persisted files)')
|
|
124
|
+
.option('--key <persistKey>', 'Persist key (ex: agent-code-agent)')
|
|
125
|
+
.option('--agent <name>', 'Shortcut for persist key: agent-<name>')
|
|
126
|
+
.option('--details', 'Show compression previews', false)
|
|
127
|
+
.action(async (options) => {
|
|
14
128
|
try {
|
|
15
129
|
const config = await (0, config_1.loadConfig)();
|
|
130
|
+
console.log('Memory/Compression Status');
|
|
131
|
+
console.log('='.repeat(40));
|
|
16
132
|
if (!config.compression?.enabled) {
|
|
17
|
-
console.log('
|
|
18
|
-
|
|
133
|
+
console.log('Compression: DISABLED (COMPRESSION_ENABLED=false)');
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
const threshold = config.compression.threshold ?? 0.8;
|
|
137
|
+
const maxCount = config.compression.maxCount ?? 5;
|
|
138
|
+
const persist = config.compression.persist ?? true;
|
|
139
|
+
const logging = config.compression.logging ?? true;
|
|
140
|
+
console.log('Compression: ENABLED');
|
|
141
|
+
console.log(`Threshold: ${(threshold * 100).toFixed(0)}%`);
|
|
142
|
+
console.log(`Max count: ${maxCount}`);
|
|
143
|
+
console.log(`Persist: ${persist ? 'ENABLED' : 'DISABLED'}`);
|
|
144
|
+
console.log(`Logging: ${logging ? 'ENABLED' : 'DISABLED'}`);
|
|
145
|
+
}
|
|
146
|
+
const projectRoot = process.cwd();
|
|
147
|
+
const files = listPersistedCompressionFiles(projectRoot);
|
|
148
|
+
const resolvedKey = resolveKeyFromOptions(options);
|
|
149
|
+
if (files.length === 0) {
|
|
150
|
+
console.log('\nNo persisted compression files found in this project root.');
|
|
151
|
+
console.log('Note: files are generated by the runtime (frame-agent-core) during agent runs.');
|
|
19
152
|
return;
|
|
20
153
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
}
|
|
154
|
+
if (resolvedKey) {
|
|
155
|
+
const entry = files.find((f) => f.key === resolvedKey);
|
|
156
|
+
if (!entry) {
|
|
157
|
+
console.log(`\nPersist key not found: ${resolvedKey}`);
|
|
158
|
+
console.log('\nAvailable keys:');
|
|
159
|
+
for (const f of files)
|
|
160
|
+
console.log(`- ${f.key}`);
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
const chosenPath = entry.primaryPath ?? entry.legacyPath;
|
|
164
|
+
if (!chosenPath) {
|
|
165
|
+
console.log(`\nNo file found for key: ${resolvedKey}`);
|
|
166
|
+
return;
|
|
167
|
+
}
|
|
168
|
+
const data = safeParseJsonFile(chosenPath) ?? {};
|
|
169
|
+
const compressoes = toStringArray(data.compressoes);
|
|
170
|
+
const compressionCount = toNumberOrZero(data.compressionCount);
|
|
171
|
+
const timestamp = toStringOrUndefined(data.timestamp);
|
|
172
|
+
const persistKey = toStringOrUndefined(data.persistKey) ?? resolvedKey;
|
|
173
|
+
console.log('\nSelected file:');
|
|
174
|
+
console.log(`- key: ${persistKey}`);
|
|
175
|
+
console.log(`- file: ${path.basename(chosenPath)}`);
|
|
176
|
+
if (timestamp)
|
|
177
|
+
console.log(`- timestamp: ${timestamp}`);
|
|
178
|
+
console.log(`- compressions: ${compressoes.length}`);
|
|
179
|
+
console.log(`- compressionCount: ${compressionCount}`);
|
|
180
|
+
if (options?.details) {
|
|
181
|
+
if (compressoes.length === 0) {
|
|
182
|
+
console.log('\nNo compressions recorded in this file.');
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
console.log('\nHistory:');
|
|
186
|
+
for (let i = 0; i < compressoes.length; i++) {
|
|
187
|
+
const preview = compressoes[i].slice(0, 100) + (compressoes[i].length > 100 ? '...' : '');
|
|
188
|
+
console.log(` ${i + 1}. ${preview} (${compressoes[i].length} chars)`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
else {
|
|
192
|
+
console.log('\nTip: add --details to show compression previews.');
|
|
193
|
+
}
|
|
194
|
+
return;
|
|
36
195
|
}
|
|
37
|
-
|
|
38
|
-
|
|
196
|
+
console.log('\nPersisted compression files:');
|
|
197
|
+
for (const f of files) {
|
|
198
|
+
const chosenPath = f.primaryPath ?? f.legacyPath;
|
|
199
|
+
if (!chosenPath)
|
|
200
|
+
continue;
|
|
201
|
+
const data = safeParseJsonFile(chosenPath) ?? {};
|
|
202
|
+
const compressoes = toStringArray(data.compressoes);
|
|
203
|
+
const compressionCount = toNumberOrZero(data.compressionCount);
|
|
204
|
+
const timestamp = toStringOrUndefined(data.timestamp);
|
|
205
|
+
const parts = [];
|
|
206
|
+
parts.push(`key=${f.key}`);
|
|
207
|
+
parts.push(`comps=${compressoes.length}`);
|
|
208
|
+
if (compressionCount)
|
|
209
|
+
parts.push(`count=${compressionCount}`);
|
|
210
|
+
if (timestamp)
|
|
211
|
+
parts.push(`ts=${timestamp}`);
|
|
212
|
+
parts.push(`file=${path.basename(chosenPath)}`);
|
|
213
|
+
console.log('- ' + parts.join(' '));
|
|
39
214
|
}
|
|
215
|
+
console.log('\nTip: use `frame-code memory status --key <key> --details` to inspect content.');
|
|
40
216
|
}
|
|
41
217
|
catch (error) {
|
|
42
|
-
logger_1.logger.error('[MemoryCommand]
|
|
43
|
-
console.error('
|
|
218
|
+
logger_1.logger.error('[MemoryCommand] Failed to get status:', error);
|
|
219
|
+
console.error('Failed to get memory/compression status.');
|
|
44
220
|
}
|
|
45
221
|
});
|
|
46
222
|
return command;
|
|
47
223
|
}
|
|
48
224
|
function createMemoryCompressCommand() {
|
|
49
225
|
const command = new commander_1.Command('compress');
|
|
50
|
-
command
|
|
51
|
-
.
|
|
52
|
-
.
|
|
53
|
-
try {
|
|
54
|
-
const config = await (0, config_1.loadConfig)();
|
|
55
|
-
if (!config.compression?.enabled) {
|
|
56
|
-
console.log('❌ Compressão de memória está desabilitada');
|
|
57
|
-
console.log('💡 Habilite com COMPRESSION_ENABLED=true no .env');
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
console.log('🔄 Iniciando compressão manual...');
|
|
61
|
-
const compressionManager = new compression_1.CompressionManager(config.compression);
|
|
62
|
-
const statsBefore = compressionManager.getCompressionStats();
|
|
63
|
-
console.log(`📊 Antes: ${statsBefore.currentCompressions}/${statsBefore.maxCompressions} compressões`);
|
|
64
|
-
console.log('💡 Para compressão manual during conversa, use o modo interativo');
|
|
65
|
-
console.log(' A compressão automática ocorrerá quando necessário');
|
|
66
|
-
}
|
|
67
|
-
catch (error) {
|
|
68
|
-
logger_1.logger.error('[MemoryCommand] Erro na compressão manual:', error);
|
|
69
|
-
console.error('❌ Erro na compressão manual');
|
|
70
|
-
}
|
|
226
|
+
command.description('Force manual compression (not supported by CLI)').action(async () => {
|
|
227
|
+
console.log('Manual compression is not supported by the CLI.');
|
|
228
|
+
console.log('Run the agent (interactive/autonomous) and let the runtime compress when needed.');
|
|
71
229
|
});
|
|
72
230
|
return command;
|
|
73
231
|
}
|
|
74
232
|
function createMemoryClearCommand() {
|
|
75
233
|
const command = new commander_1.Command('clear');
|
|
76
234
|
command
|
|
77
|
-
.description('
|
|
78
|
-
.
|
|
235
|
+
.description('Clear persisted compression history')
|
|
236
|
+
.option('--key <persistKey>', 'Persist key (ex: agent-code-agent)')
|
|
237
|
+
.option('--agent <name>', 'Shortcut for persist key: agent-<name>')
|
|
238
|
+
.action(async (options) => {
|
|
79
239
|
try {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
240
|
+
await (0, config_1.loadConfig)();
|
|
241
|
+
const projectRoot = process.cwd();
|
|
242
|
+
const files = listPersistedCompressionFiles(projectRoot);
|
|
243
|
+
const resolvedKey = resolveKeyFromOptions(options);
|
|
244
|
+
if (files.length === 0) {
|
|
245
|
+
console.log('No persisted compression files to clear.');
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
const targets = resolvedKey ? files.filter((f) => f.key === resolvedKey) : files;
|
|
249
|
+
if (resolvedKey && targets.length === 0) {
|
|
250
|
+
console.log(`Persist key not found: ${resolvedKey}`);
|
|
251
|
+
console.log('\nAvailable keys:');
|
|
252
|
+
for (const f of files)
|
|
253
|
+
console.log(`- ${f.key}`);
|
|
83
254
|
return;
|
|
84
255
|
}
|
|
85
|
-
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
256
|
+
let removed = 0;
|
|
257
|
+
for (const entry of targets) {
|
|
258
|
+
if (removeFileIfExists(entry.primaryPath))
|
|
259
|
+
removed += 1;
|
|
260
|
+
if (removeFileIfExists(entry.legacyPath))
|
|
261
|
+
removed += 1;
|
|
262
|
+
}
|
|
263
|
+
if (removed === 0) {
|
|
264
|
+
console.log('No files removed (they may have already been cleared).');
|
|
89
265
|
return;
|
|
90
266
|
}
|
|
91
|
-
console.log(
|
|
92
|
-
compressionManager.clearCompressions();
|
|
93
|
-
console.log('✅ Histórico de compressões limpo com sucesso');
|
|
94
|
-
console.log('💾 Arquivo de persistência removido (se existia)');
|
|
267
|
+
console.log(`OK: removed ${removed} persisted compression file(s).`);
|
|
95
268
|
}
|
|
96
269
|
catch (error) {
|
|
97
|
-
logger_1.logger.error('[MemoryCommand]
|
|
98
|
-
console.error('
|
|
270
|
+
logger_1.logger.error('[MemoryCommand] Failed to clear compressions:', error);
|
|
271
|
+
console.error('Failed to clear persisted compressions.');
|
|
99
272
|
}
|
|
100
273
|
});
|
|
101
274
|
return command;
|
|
102
275
|
}
|
|
103
276
|
function createMemoryConfigCommand() {
|
|
104
277
|
const command = new commander_1.Command('config');
|
|
105
|
-
command
|
|
106
|
-
.description('Mostrar configuração atual de compressão')
|
|
107
|
-
.action(async () => {
|
|
278
|
+
command.description('Show compression config').action(async () => {
|
|
108
279
|
try {
|
|
109
280
|
const config = await (0, config_1.loadConfig)();
|
|
110
|
-
console.log('
|
|
281
|
+
console.log('Compression Config');
|
|
111
282
|
console.log('='.repeat(30));
|
|
112
283
|
if (!config.compression) {
|
|
113
|
-
console.log('
|
|
284
|
+
console.log('No compression config found.');
|
|
114
285
|
return;
|
|
115
286
|
}
|
|
287
|
+
const threshold = config.compression.threshold ?? 0.8;
|
|
116
288
|
console.log(`enabled: ${config.compression.enabled}`);
|
|
117
|
-
console.log(`threshold: ${
|
|
118
|
-
console.log(`maxCount: ${config.compression.maxCount}`);
|
|
119
|
-
console.log(`maxTokens: ${config.compression.maxTokens}`);
|
|
120
|
-
console.log(`model: ${config.compression.model || '
|
|
121
|
-
console.log(`logging: ${config.compression.logging}`);
|
|
122
|
-
console.log(`persist: ${config.compression.persist}`);
|
|
123
|
-
console.log('\
|
|
289
|
+
console.log(`threshold: ${threshold} (${(threshold * 100).toFixed(0)}%)`);
|
|
290
|
+
console.log(`maxCount: ${config.compression.maxCount ?? 5}`);
|
|
291
|
+
console.log(`maxTokens: ${config.compression.maxTokens ?? 300}`);
|
|
292
|
+
console.log(`model: ${config.compression.model || '(default LLM model)'}`);
|
|
293
|
+
console.log(`logging: ${config.compression.logging ?? true}`);
|
|
294
|
+
console.log(`persist: ${config.compression.persist ?? true}`);
|
|
295
|
+
console.log('\nEnv vars:');
|
|
124
296
|
console.log('COMPRESSION_ENABLED');
|
|
125
297
|
console.log('COMPRESSION_THRESHOLD');
|
|
126
298
|
console.log('COMPRESSION_MAX_COUNT');
|
|
@@ -130,16 +302,15 @@ function createMemoryConfigCommand() {
|
|
|
130
302
|
console.log('COMPRESSION_PERSIST');
|
|
131
303
|
}
|
|
132
304
|
catch (error) {
|
|
133
|
-
logger_1.logger.error('[MemoryCommand]
|
|
134
|
-
console.error('
|
|
305
|
+
logger_1.logger.error('[MemoryCommand] Failed to show config:', error);
|
|
306
|
+
console.error('Failed to show compression config.');
|
|
135
307
|
}
|
|
136
308
|
});
|
|
137
309
|
return command;
|
|
138
310
|
}
|
|
139
311
|
function createMemoryCommand() {
|
|
140
312
|
const command = new commander_1.Command('memory');
|
|
141
|
-
command
|
|
142
|
-
.description('Gerenciar memória e compressão da CLI');
|
|
313
|
+
command.description('Manage memory/compression (persisted history files)');
|
|
143
314
|
command.addCommand(createMemoryStatusCommand());
|
|
144
315
|
command.addCommand(createMemoryCompressCommand());
|
|
145
316
|
command.addCommand(createMemoryClearCommand());
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
# Sistema de Agentes (
|
|
1
|
+
# Sistema de Agentes (`.code/agents/`)
|
|
2
2
|
|
|
3
3
|
Este sistema permite criar novos agentes apenas adicionando arquivos `.md` com YAML frontmatter, sem escrever código TypeScript.
|
|
4
4
|
|
|
5
5
|
## Estrutura de Diretórios
|
|
6
6
|
|
|
7
|
-
```
|
|
8
|
-
.code
|
|
9
|
-
└── agents/ # ← Arquivos .md de agentes
|
|
10
|
-
├── code-agent.md
|
|
11
|
-
├── chrome-mcp-agent.md
|
|
12
|
-
└── README.md
|
|
13
|
-
```
|
|
7
|
+
```
|
|
8
|
+
.code/
|
|
9
|
+
└── agents/ # ← Arquivos .md de agentes (custom)
|
|
10
|
+
├── code-agent.md
|
|
11
|
+
├── chrome-mcp-agent.md
|
|
12
|
+
└── README.md
|
|
13
|
+
```
|
|
14
14
|
|
|
15
15
|
## Como Criar um Novo Agente
|
|
16
16
|
|
|
17
17
|
### Criar arquivo `nome-do-agente.md`
|
|
18
18
|
|
|
19
19
|
```bash
|
|
20
|
-
cat > .code
|
|
21
|
-
---
|
|
22
|
-
name: meu-agent
|
|
23
|
-
type: main-agent
|
|
24
|
-
canBeSupervisor: false
|
|
25
|
-
description: Descrição do meu agente
|
|
26
|
-
keywords: [minha, especialidade]
|
|
27
|
-
tools: [search, file_read,
|
|
28
|
-
temperature: 0.3
|
|
29
|
-
maxTokens: 4096
|
|
30
|
-
---
|
|
20
|
+
cat > .code/agents/meu-agent.md << 'EOF'
|
|
21
|
+
---
|
|
22
|
+
name: meu-agent
|
|
23
|
+
type: main-agent
|
|
24
|
+
canBeSupervisor: false
|
|
25
|
+
description: Descrição do meu agente
|
|
26
|
+
keywords: [minha, especialidade]
|
|
27
|
+
tools: [search, file_read, file_create, file_edit, final_answer]
|
|
28
|
+
temperature: 0.3
|
|
29
|
+
maxTokens: 4096
|
|
30
|
+
---
|
|
31
31
|
|
|
32
32
|
# Meu Agente
|
|
33
33
|
|
|
@@ -37,11 +37,15 @@ EOF
|
|
|
37
37
|
|
|
38
38
|
### Usar imediatamente
|
|
39
39
|
|
|
40
|
-
O agente será descoberto automaticamente no próximo startup da CLI:
|
|
41
|
-
|
|
42
|
-
```bash
|
|
43
|
-
|
|
44
|
-
|
|
40
|
+
O agente será descoberto automaticamente no próximo startup da CLI:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
# Em dev
|
|
44
|
+
npm run dev interactive
|
|
45
|
+
|
|
46
|
+
# Em produção (bin instalado)
|
|
47
|
+
# frame-code interactive
|
|
48
|
+
```
|
|
45
49
|
|
|
46
50
|
## Campos do YAML Frontmatter
|
|
47
51
|
|
|
@@ -187,10 +191,10 @@ name: database-agent
|
|
|
187
191
|
type: main-agent
|
|
188
192
|
description: Especialista em banco de dados SQL
|
|
189
193
|
keywords: [database, sql, postgres, mysql]
|
|
190
|
-
tools: [search, file_read,
|
|
191
|
-
temperature: 0.2
|
|
192
|
-
compressionEnabled: false
|
|
193
|
-
---
|
|
194
|
+
tools: [search, file_read, file_create, file_edit, terminal, final_answer]
|
|
195
|
+
temperature: 0.2
|
|
196
|
+
compressionEnabled: false
|
|
197
|
+
---
|
|
194
198
|
|
|
195
199
|
# Database Agent
|
|
196
200
|
|
|
@@ -306,11 +310,11 @@ Se um agente especificar `call_flow` nas `tools` mas não tiver sub-agentes conf
|
|
|
306
310
|
Os comandos `interactive` e `autonomous` usam automaticamente os agentes registrados:
|
|
307
311
|
|
|
308
312
|
```bash
|
|
309
|
-
# Usa agente padrão (chrome-mcp-agent)
|
|
310
|
-
npm run interactive
|
|
313
|
+
# Usa agente padrão (chrome-mcp-agent)
|
|
314
|
+
npm run dev interactive
|
|
311
315
|
|
|
312
|
-
#
|
|
313
|
-
npm run interactive --agent code-agent
|
|
316
|
+
# Especificar agente
|
|
317
|
+
npm run dev interactive --agent code-agent
|
|
314
318
|
```
|
|
315
319
|
|
|
316
320
|
## Agentes TypeScript Existentes
|
|
@@ -31,7 +31,7 @@ additionalInstructions: |
|
|
|
31
31
|
- **Fluxo de Dados:** Como a informação viaja pelo sistema (Diagramas Mermaid são encorajados).
|
|
32
32
|
- **Estratégia de Implementação:** Ordem lógica de construção das peças.
|
|
33
33
|
|
|
34
|
-
Dica de Processo: Antes de gerar a final_answer, use o terminal
|
|
34
|
+
Dica de Processo: Antes de gerar a final_answer, use `file_read` e/ou o `terminal` para entender a estrutura atual do projeto e garantir que sua nova arquitetura se integre sem quebrar padrões existentes.
|
|
35
35
|
|
|
36
36
|
## Formato de Saída
|
|
37
37
|
```
|
|
@@ -7,7 +7,7 @@ availableFor: [supervisor]
|
|
|
7
7
|
tools: [toDoIst, terminal, file_read, file_create, file_edit, list_capabilities, enable_capability, sleep, final_answer]
|
|
8
8
|
temperature: 0.2
|
|
9
9
|
maxTokens: 8192
|
|
10
|
-
compressionEnabled:
|
|
10
|
+
compressionEnabled: true
|
|
11
11
|
backstory: |
|
|
12
12
|
Você é o Agente Builder (Rafael), um Engenheiro de Software Pragmático. Sua especialidade é "mão na massa". Você não perde tempo com teoria excessiva; você lê o plano, escreve o código, roda os testes e garante que funciona. Você valoriza a precisão na sintaxe e a estabilidade da execução.
|
|
13
13
|
additionalInstructions: |
|
|
@@ -15,12 +15,10 @@ additionalInstructions: |
|
|
|
15
15
|
Materializar o plano fornecido no contexto, escrevendo arquivos, executando comandos e validando o sucesso de cada etapa antes de finalizar.
|
|
16
16
|
|
|
17
17
|
## Regras
|
|
18
|
-
0. **Passo Zero:**
|
|
19
|
-
|
|
20
|
-
**Dica de Ouro:** Use o create list e envie todas as tarefas de uma vez ao inves do comando ADD, ele serve para quando voce precisar adicionar uma nova tarefa especifica a uma ja existente.
|
|
18
|
+
0. **Passo Zero:** Transforme o plano do `## Shared Context` em uma lista de tarefas com `toDoIst` usando `action: "create"` e `tasks: [...]`. O `create` sobrescreve a lista atual, se existir.
|
|
21
19
|
1. **Execução Sequencial:** Siga os passos do plano estritamente. Atualize o status no `toDoIst` conforme progride.
|
|
22
20
|
2. **Validação Obrigatória:** Nunca assuma que um código funciona apenas porque você o escreveu. Use o `terminal` para rodar linters ou testes, ou `file_read` para verificar se o arquivo foi gravado corretamente.
|
|
23
|
-
3. **Uso de Ferramentas:** O uso de `file_edit`, `terminal` e `
|
|
21
|
+
3. **Uso de Ferramentas:** O uso de `file_create`, `file_edit`, `terminal` e `file_read` é a sua função primária. Não tenha medo de usá-las.
|
|
24
22
|
4. **Silêncio Operacional:** Não faça perguntas. Se o plano tiver lacunas, use seu melhor julgamento técnico (ex: padrões de mercado) para preenchê-las.
|
|
25
23
|
5. **Finalização:** Só use `final_answer` quando **todas** as etapas do plano estiverem concluídas e verificadas.
|
|
26
24
|
|
|
@@ -28,9 +26,9 @@ additionalInstructions: |
|
|
|
28
26
|
1. **Análise:** Leia o plano disponível no contexto ou na ferramenta `toDoIst` (use `get`).
|
|
29
27
|
2. **Ciclo de Construção:**
|
|
30
28
|
- **Thought:** "Vou executar o passo 1."
|
|
31
|
-
- **Action:** `
|
|
32
|
-
- **Thought:** "Vou validar." -> **Action:** `terminal` (
|
|
33
|
-
- **Action:** `toDoIst` (update_status
|
|
29
|
+
- **Action:** `file_create`/`file_edit` ou `terminal` (`action: "create"`).
|
|
30
|
+
- **Thought:** "Vou validar." -> **Action:** `terminal` (`action: "create"`) ou `file_read`.
|
|
31
|
+
- **Action:** `toDoIst` (`update_status` com `id`).
|
|
34
32
|
3. **Conclusão:** Quando a lista estiver vazia, envie o `final_answer`.
|
|
35
33
|
|
|
36
34
|
## Exemplos de Execução (Strict JSON)
|
|
@@ -39,19 +37,17 @@ additionalInstructions: |
|
|
|
39
37
|
**Plano:** "1. Criar modelo Comment"
|
|
40
38
|
**Execução:**
|
|
41
39
|
|
|
42
|
-
Thought: Passo 1. Vou criar o arquivo do modelo. Action:
|
|
40
|
+
Thought: Passo 1. Vou criar o arquivo do modelo. Action: file_create = {"filePath":"src/models/Comment.ts","content":"export interface Comment {\n id: string;\n postId: string;\n author: string;\n content: string;\n createdAt: Date;\n}"}
|
|
43
41
|
|
|
44
42
|
Thought: Arquivo criado. Vou marcar a tarefa como concluída. Action: toDoIst = {"action": "update_status", "id": "1", "status": "completed"}
|
|
45
43
|
|
|
46
44
|
Thought: Todas as tarefas concluídas. Action: final_answer = {"answer":"Modelo Comment criado em src/models/Comment.ts."}
|
|
47
45
|
|
|
48
46
|
### Exemplo 2: Implementar Endpoint (Editando)
|
|
49
|
-
**Plano:** "3.
|
|
47
|
+
**Plano:** "3. Editar src/routes/posts.ts e adicionar rota POST"
|
|
50
48
|
**Execução:**
|
|
51
49
|
|
|
52
|
-
Thought: Vou
|
|
53
|
-
|
|
54
|
-
Thought: Encontrei em src/routes/posts.ts. Vou adicionar o import e a rota. Action: file_edit = {"filePath":"src/routes/posts.ts", "edits": [{"oldText": "// routes", "newText": "// routes\nrouter.post('/:id/comments', createComment)"}]}
|
|
50
|
+
Thought: Vou adicionar o import e a rota conforme o plano. Action: file_edit = {"filePath":"src/routes/posts.ts", "edits": [{"oldText": "// routes", "newText": "// routes\nrouter.post('/:id/comments', createComment)"}]}
|
|
55
51
|
|
|
56
52
|
Thought: Código alterado. Marcando tarefa 3. Action: toDoIst = {"action": "update_status", "id": "3", "status": "completed"}
|
|
57
53
|
|
|
@@ -61,7 +57,7 @@ additionalInstructions: |
|
|
|
61
57
|
**Cenário:** Falha no build
|
|
62
58
|
**Execução:**
|
|
63
59
|
|
|
64
|
-
Action: terminal = {"command":"npm run build"}
|
|
60
|
+
Action: terminal = {"action":"create","command":"npm run build"}
|
|
65
61
|
|
|
66
62
|
[Output: TS2339: Property 'email' does not exist on type 'User']
|
|
67
63
|
|
|
@@ -69,7 +65,7 @@ additionalInstructions: |
|
|
|
69
65
|
|
|
70
66
|
Thought: Falta o campo email. Vou corrigir. Action: file_edit = {"filePath":"src/models/User.ts","edits": [{"oldText":"name: string;", "newText":"name: string;\n email: string;"}]}
|
|
71
67
|
|
|
72
|
-
Thought: Agora vou tentar o build novamente para validar. Action: terminal = {"command":"npm run build"}
|
|
68
|
+
Thought: Agora vou tentar o build novamente para validar. Action: terminal = {"action":"create","command":"npm run build"}
|
|
73
69
|
|
|
74
70
|
## Dicas
|
|
75
71
|
- **Seja metódico** - execute um passo de cada vez
|