@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,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createCliTelemetry = createCliTelemetry;
|
|
4
|
-
const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
|
|
5
|
-
const traceSinkConsole_1 = require("./traceSinkConsole");
|
|
6
|
-
function readBool(value, defaultValue) {
|
|
7
|
-
if (value == null)
|
|
8
|
-
return defaultValue;
|
|
9
|
-
if (value === '1')
|
|
10
|
-
return true;
|
|
11
|
-
if (value === '0')
|
|
12
|
-
return false;
|
|
13
|
-
return value.toLowerCase() === 'true';
|
|
14
|
-
}
|
|
15
|
-
function createCliTelemetry() {
|
|
16
|
-
const enabled = readBool(process.env.TELEMETRY_ENABLED, true);
|
|
17
|
-
const verbose = readBool(process.env.TELEMETRY_VERBOSE, readBool(process.env.DEBUG, false));
|
|
18
|
-
const level = (process.env.TELEMETRY_LEVEL ?? (verbose ? 'debug' : 'info'));
|
|
19
|
-
const telemetry = {
|
|
20
|
-
enabled,
|
|
21
|
-
level,
|
|
22
|
-
persistToState: false,
|
|
23
|
-
includePrompts: false,
|
|
24
|
-
maxPayloadChars: 4000,
|
|
25
|
-
maxEvents: 200,
|
|
26
|
-
};
|
|
27
|
-
const consoleSink = new traceSinkConsole_1.ConsoleTraceSink({ verbose });
|
|
28
|
-
const trace = new frame_agent_sdk_1.MultiplexTraceSink([consoleSink]);
|
|
29
|
-
return { trace, telemetry, verbose };
|
|
30
|
-
}
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatTraceEventForTerminal = formatTraceEventForTerminal;
|
|
4
|
-
const FLOW_LABELS = {
|
|
5
|
-
'planner-flow': 'Agente-Planner',
|
|
6
|
-
'implementer-flow': 'Agente-Executor',
|
|
7
|
-
};
|
|
8
|
-
function getAgentLabel(event) {
|
|
9
|
-
const flowId = event.flow?.id;
|
|
10
|
-
if (flowId && FLOW_LABELS[flowId])
|
|
11
|
-
return FLOW_LABELS[flowId];
|
|
12
|
-
const agentLabel = event.agent?.label;
|
|
13
|
-
if (agentLabel && agentLabel.trim().length > 0)
|
|
14
|
-
return agentLabel;
|
|
15
|
-
const agentId = event.agent?.id;
|
|
16
|
-
if (agentId && agentId.trim().length > 0)
|
|
17
|
-
return `[${agentId}]`;
|
|
18
|
-
return 'Agente';
|
|
19
|
-
}
|
|
20
|
-
function safeJson(value) {
|
|
21
|
-
try {
|
|
22
|
-
return JSON.stringify(value ?? {});
|
|
23
|
-
}
|
|
24
|
-
catch {
|
|
25
|
-
return '{}';
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
function formatTraceEventForTerminal(event, opts) {
|
|
29
|
-
const verbose = Boolean(opts?.verbose);
|
|
30
|
-
const label = getAgentLabel(event);
|
|
31
|
-
if (event.type === 'tool_detected') {
|
|
32
|
-
const thought = typeof event.data?.thoughtPreview === 'string' ? event.data.thoughtPreview : undefined;
|
|
33
|
-
const toolName = event.tool?.name ?? 'unknown_tool';
|
|
34
|
-
const params = event.tool?.params;
|
|
35
|
-
if (toolName === 'final_answer') {
|
|
36
|
-
return ['', `${label}:`, ` - Action: final_answer = ${safeJson(params)}`, ''];
|
|
37
|
-
}
|
|
38
|
-
if (toolName === 'ask_user') {
|
|
39
|
-
const question = params?.question;
|
|
40
|
-
if (typeof question === 'string' && question.trim().length > 0) {
|
|
41
|
-
return ['', `${label}:`, ` Pergunta: ${question}`, ''];
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return [
|
|
45
|
-
'',
|
|
46
|
-
`${label}:`,
|
|
47
|
-
` Thought: ${thought && thought.trim().length > 0 ? thought : `Executando ferramenta ${toolName}`}`,
|
|
48
|
-
` - Action: ${toolName} = ${safeJson(params)}`,
|
|
49
|
-
'',
|
|
50
|
-
];
|
|
51
|
-
}
|
|
52
|
-
if (event.type === 'tool_execution_failed') {
|
|
53
|
-
const toolName = event.tool?.name ?? 'unknown_tool';
|
|
54
|
-
const message = event.message ?? 'Unknown error';
|
|
55
|
-
return [
|
|
56
|
-
'',
|
|
57
|
-
`${label}:`,
|
|
58
|
-
` Tool error: ${toolName}`,
|
|
59
|
-
` Message: ${message}`,
|
|
60
|
-
'',
|
|
61
|
-
];
|
|
62
|
-
}
|
|
63
|
-
if (verbose && (event.type === 'tool_execution_finished' || event.type === 'tool_execution_started')) {
|
|
64
|
-
const toolName = event.tool?.name ?? 'unknown_tool';
|
|
65
|
-
const duration = event.timing?.durationMs;
|
|
66
|
-
const patchOpsCount = typeof event.data?.patchOpsCount === 'number' ? event.data.patchOpsCount : undefined;
|
|
67
|
-
const metadataKeys = Array.isArray(event.data?.metadataKeys) ? event.data?.metadataKeys : undefined;
|
|
68
|
-
const parts = [
|
|
69
|
-
`[telemetry] ${label} ${event.type} tool=${toolName}`,
|
|
70
|
-
duration != null ? `durationMs=${duration}` : undefined,
|
|
71
|
-
patchOpsCount != null ? `patchOps=${patchOpsCount}` : undefined,
|
|
72
|
-
metadataKeys && metadataKeys.length ? `metadataKeys=${metadataKeys.join(',')}` : undefined,
|
|
73
|
-
].filter(Boolean);
|
|
74
|
-
return [parts.join(' ')];
|
|
75
|
-
}
|
|
76
|
-
if (verbose && (event.type === 'llm_request_started' || event.type === 'llm_request_finished' || event.type === 'llm_request_failed')) {
|
|
77
|
-
const model = event.llm?.model ?? 'unknown';
|
|
78
|
-
const duration = event.timing?.durationMs;
|
|
79
|
-
const finishReason = event.llm?.finishReason;
|
|
80
|
-
const usage = event.llm?.usage?.total;
|
|
81
|
-
const parts = [
|
|
82
|
-
`[telemetry] ${label} ${event.type} model=${model}`,
|
|
83
|
-
duration != null ? `durationMs=${duration}` : undefined,
|
|
84
|
-
usage != null ? `tokens=${usage}` : undefined,
|
|
85
|
-
finishReason ? `finish=${finishReason}` : undefined,
|
|
86
|
-
].filter(Boolean);
|
|
87
|
-
return [parts.join(' ')];
|
|
88
|
-
}
|
|
89
|
-
return [];
|
|
90
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ConsoleTraceSink = void 0;
|
|
4
|
-
const traceEventFormatter_1 = require("./traceEventFormatter");
|
|
5
|
-
class ConsoleTraceSink {
|
|
6
|
-
constructor(opts) {
|
|
7
|
-
this.opts = opts ?? {};
|
|
8
|
-
this.stdoutFd = process.stdout.fd;
|
|
9
|
-
}
|
|
10
|
-
emit(event) {
|
|
11
|
-
const lines = (0, traceEventFormatter_1.formatTraceEventForTerminal)(event, this.opts);
|
|
12
|
-
for (const line of lines) {
|
|
13
|
-
process.stdout.write(line + '\n');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
exports.ConsoleTraceSink = ConsoleTraceSink;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("dotenv/config");
|
|
4
|
-
const autonomous_1 = require("../../cli/commands/autonomous");
|
|
5
|
-
function assert(condition, message) {
|
|
6
|
-
if (!condition)
|
|
7
|
-
throw new Error(`ASSERTION FAILED: ${message}`);
|
|
8
|
-
}
|
|
9
|
-
async function main() {
|
|
10
|
-
process.env.DEBUG = process.env.DEBUG ?? 'false';
|
|
11
|
-
process.env.TELEMETRY_ENABLED = 'true';
|
|
12
|
-
process.env.TELEMETRY_VERBOSE = 'false';
|
|
13
|
-
process.env.TELEMETRY_LEVEL = 'info';
|
|
14
|
-
process.env.EXCLUDED_TOOLS = ['terminal', 'file_create', 'file_edit', 'toDoIst'].join(',');
|
|
15
|
-
const out = await (0, autonomous_1.processAutonomousInput)('apenas diga OK usando final_answer', { verbose: false });
|
|
16
|
-
assert(out.trim() === 'OK', `expected output OK, got: ${out}`);
|
|
17
|
-
console.log('[OK] telemetry-autonomous');
|
|
18
|
-
}
|
|
19
|
-
main().catch((err) => {
|
|
20
|
-
console.error('[FAIL] telemetry-autonomous');
|
|
21
|
-
console.error(err);
|
|
22
|
-
process.exitCode = 1;
|
|
23
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
require("dotenv/config");
|
|
4
|
-
const multi_agent_1 = require("../../cli/commands/multi-agent");
|
|
5
|
-
function assert(condition, message) {
|
|
6
|
-
if (!condition)
|
|
7
|
-
throw new Error(`ASSERTION FAILED: ${message}`);
|
|
8
|
-
}
|
|
9
|
-
async function main() {
|
|
10
|
-
process.env.DEBUG = process.env.DEBUG ?? 'false';
|
|
11
|
-
process.env.TELEMETRY_ENABLED = 'true';
|
|
12
|
-
process.env.TELEMETRY_VERBOSE = 'true';
|
|
13
|
-
process.env.TELEMETRY_LEVEL = 'info';
|
|
14
|
-
process.env.EXCLUDED_TOOLS = [
|
|
15
|
-
'terminal',
|
|
16
|
-
'file_create',
|
|
17
|
-
'file_edit',
|
|
18
|
-
'toDoIst',
|
|
19
|
-
'search',
|
|
20
|
-
'file_read',
|
|
21
|
-
'file_outline',
|
|
22
|
-
'list_directory',
|
|
23
|
-
'enable_skill',
|
|
24
|
-
'list_skills',
|
|
25
|
-
].join(',');
|
|
26
|
-
const captured = [];
|
|
27
|
-
const originalLog = console.log;
|
|
28
|
-
console.log = (...args) => {
|
|
29
|
-
captured.push(args.map((a) => (typeof a === 'string' ? a : JSON.stringify(a))).join(' '));
|
|
30
|
-
originalLog(...args);
|
|
31
|
-
};
|
|
32
|
-
try {
|
|
33
|
-
const out = await (0, multi_agent_1.processMultiAgentInput)("[teste telemetria] Supervisor: chame call_flow planner-flow. Planner: responda usando final_answer com answer exatamente 'PLAN-OK'. Nao use outras tools. Depois Supervisor: chame call_flow implementer-flow. Implementer: responda usando final_answer com answer exatamente 'EXEC-OK'. Nao use outras tools. Por fim Supervisor: responda final_answer com answer exatamente 'SUP-OK'.", { verbose: false });
|
|
34
|
-
assert(typeof out === 'string' && out.trim().length > 0, 'expected non-empty output');
|
|
35
|
-
assert(out.trim() === 'SUP-OK', `expected output SUP-OK, got: ${out}`);
|
|
36
|
-
const text = captured.join('\n');
|
|
37
|
-
assert(text.includes('Agente-Supervisor'), 'expected telemetry to include Agente-Supervisor');
|
|
38
|
-
assert(text.includes('Agente-Planner'), 'expected telemetry to include Agente-Planner');
|
|
39
|
-
assert(text.includes('Agente-Executor'), 'expected telemetry to include Agente-Executor');
|
|
40
|
-
console.log('[OK] telemetry-multi-agent');
|
|
41
|
-
}
|
|
42
|
-
finally {
|
|
43
|
-
console.log = originalLog;
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
main().catch((err) => {
|
|
47
|
-
console.error('[FAIL] telemetry-multi-agent');
|
|
48
|
-
console.error(err);
|
|
49
|
-
process.exitCode = 1;
|
|
50
|
-
});
|
|
@@ -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
|
-
const fs = __importStar(require("fs"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
const loader_1 = require("../../agent-runtime/context/project-rules/loader");
|
|
39
|
-
console.log('=== Teste de Carregamento Dinâmico de AGENTS.md ===\n');
|
|
40
|
-
const tempDir1 = path.join(process.cwd(), 'test-dir-1');
|
|
41
|
-
const tempDir2 = path.join(process.cwd(), 'test-dir-2');
|
|
42
|
-
if (!fs.existsSync(tempDir1)) {
|
|
43
|
-
fs.mkdirSync(tempDir1, { recursive: true });
|
|
44
|
-
}
|
|
45
|
-
if (!fs.existsSync(tempDir2)) {
|
|
46
|
-
fs.mkdirSync(tempDir2, { recursive: true });
|
|
47
|
-
}
|
|
48
|
-
const agentsMd1 = path.join(tempDir1, 'AGENTS.md');
|
|
49
|
-
const agentsMd2 = path.join(tempDir2, 'AGENTS.md');
|
|
50
|
-
fs.writeFileSync(agentsMd1, '# Rules for Dir 1\n\nThis is dir 1 rules.\n');
|
|
51
|
-
fs.writeFileSync(agentsMd2, '# Rules for Dir 2\n\nThis is dir 2 rules.\n');
|
|
52
|
-
console.log('Diretórios de teste criados:');
|
|
53
|
-
console.log(' Dir 1:', tempDir1);
|
|
54
|
-
console.log(' Dir 2:', tempDir2);
|
|
55
|
-
console.log('\n--- Teste 1: Carregar de tempDir1 ---');
|
|
56
|
-
const originalCwd = process.cwd();
|
|
57
|
-
process.chdir(tempDir1);
|
|
58
|
-
const rules1 = loader_1.loadProjectRules.load();
|
|
59
|
-
console.log('process.cwd():', process.cwd());
|
|
60
|
-
console.log('Source:', rules1.source);
|
|
61
|
-
console.log('Path:', rules1.path);
|
|
62
|
-
console.log('Content preview:', rules1.content.substring(0, 50) + '...');
|
|
63
|
-
if (rules1.content.includes('dir 1 rules')) {
|
|
64
|
-
console.log('✓ Carregou regras corretas do diretório 1');
|
|
65
|
-
}
|
|
66
|
-
else {
|
|
67
|
-
console.log('✗ Erro: não carregou as regras corretas');
|
|
68
|
-
}
|
|
69
|
-
console.log('\n--- Teste 2: Carregar de tempDir2 ---');
|
|
70
|
-
process.chdir(tempDir2);
|
|
71
|
-
const rules2 = loader_1.loadProjectRules.load();
|
|
72
|
-
console.log('process.cwd():', process.cwd());
|
|
73
|
-
console.log('Source:', rules2.source);
|
|
74
|
-
console.log('Path:', rules2.path);
|
|
75
|
-
console.log('Content preview:', rules2.content.substring(0, 50) + '...');
|
|
76
|
-
if (rules2.content.includes('dir 2 rules')) {
|
|
77
|
-
console.log('✓ Carregou regras corretas do diretório 2');
|
|
78
|
-
}
|
|
79
|
-
else {
|
|
80
|
-
console.log('✗ Erro: não carregou as regras corretas');
|
|
81
|
-
}
|
|
82
|
-
console.log('\n--- Teste 3: Voltar ao diretório original ---');
|
|
83
|
-
process.chdir(originalCwd);
|
|
84
|
-
const rules3 = loader_1.loadProjectRules.load();
|
|
85
|
-
console.log('process.cwd():', process.cwd());
|
|
86
|
-
console.log('Source:', rules3.source);
|
|
87
|
-
console.log('Path:', rules3.path);
|
|
88
|
-
if (rules3.source === 'code-dir') {
|
|
89
|
-
console.log('✓ Voltou a carregar do diretório original');
|
|
90
|
-
}
|
|
91
|
-
else {
|
|
92
|
-
console.log('✗ Erro: não voltou ao diretório original');
|
|
93
|
-
}
|
|
94
|
-
console.log('\n=== Limpeza ===');
|
|
95
|
-
process.chdir(originalCwd);
|
|
96
|
-
if (fs.existsSync(tempDir1)) {
|
|
97
|
-
fs.rmSync(tempDir1, { recursive: true, force: true });
|
|
98
|
-
console.log('Diretório removido:', tempDir1);
|
|
99
|
-
}
|
|
100
|
-
if (fs.existsSync(tempDir2)) {
|
|
101
|
-
fs.rmSync(tempDir2, { recursive: true, force: true });
|
|
102
|
-
console.log('Diretório removido:', tempDir2);
|
|
103
|
-
}
|
|
104
|
-
console.log('\n=== Testes concluídos ===');
|
|
@@ -1,125 +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
|
-
const fs = __importStar(require("fs"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
const agentParser_1 = require("../../agent-runtime/registry/agentParser");
|
|
39
|
-
console.log('=== Teste de Injeção de AGENTS.md no Prompt ===\n');
|
|
40
|
-
const testAgentPath = path.join(process.cwd(), 'test-agent.md');
|
|
41
|
-
const testAgentContent = `---
|
|
42
|
-
name: test-agent
|
|
43
|
-
type: main-agent
|
|
44
|
-
description: Agente de teste
|
|
45
|
-
tools: [search, file_read, final_answer]
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
# Test Agent
|
|
49
|
-
|
|
50
|
-
You are a test agent.
|
|
51
|
-
`;
|
|
52
|
-
fs.writeFileSync(testAgentPath, testAgentContent);
|
|
53
|
-
console.log('Agente de teste criado:', testAgentPath);
|
|
54
|
-
console.log('\n--- Teste 1: Agente com useProjectRules: true (default) ---');
|
|
55
|
-
const metadata1 = (0, agentParser_1.parseAgentFile)(testAgentPath);
|
|
56
|
-
if (metadata1) {
|
|
57
|
-
console.log('useProjectRules:', metadata1.useProjectRules);
|
|
58
|
-
console.log('✓ useProjectRules default é true');
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
console.log('✗ Erro ao parsear agente');
|
|
62
|
-
}
|
|
63
|
-
console.log('\n--- Teste 2: Agente com useProjectRules: false ---');
|
|
64
|
-
const testAgentContent2 = `---
|
|
65
|
-
name: test-agent-2
|
|
66
|
-
type: main-agent
|
|
67
|
-
description: Agente de teste 2
|
|
68
|
-
tools: [search, file_read, final_answer]
|
|
69
|
-
useProjectRules: false
|
|
70
|
-
---
|
|
71
|
-
|
|
72
|
-
# Test Agent 2
|
|
73
|
-
|
|
74
|
-
You are a test agent without project rules.
|
|
75
|
-
`;
|
|
76
|
-
const testAgentPath2 = path.join(process.cwd(), 'test-agent-2.md');
|
|
77
|
-
fs.writeFileSync(testAgentPath2, testAgentContent2);
|
|
78
|
-
const metadata2 = (0, agentParser_1.parseAgentFile)(testAgentPath2);
|
|
79
|
-
if (metadata2) {
|
|
80
|
-
console.log('useProjectRules:', metadata2.useProjectRules);
|
|
81
|
-
if (metadata2.useProjectRules === false) {
|
|
82
|
-
console.log('✓ useProjectRules: false configurado corretamente');
|
|
83
|
-
}
|
|
84
|
-
else {
|
|
85
|
-
console.log('✗ useProjectRules deveria ser false');
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
console.log('✗ Erro ao parsear agente');
|
|
90
|
-
}
|
|
91
|
-
console.log('\n--- Teste 3: Verificar AGENTS.md ---');
|
|
92
|
-
const codeDirAgentsMd = path.join(process.cwd(), '.code', 'AGENTS.md');
|
|
93
|
-
const rootAgentsMd = path.join(process.cwd(), 'AGENTS.md');
|
|
94
|
-
if (fs.existsSync(codeDirAgentsMd)) {
|
|
95
|
-
console.log('✓ .code/AGENTS.md encontrado');
|
|
96
|
-
const content = fs.readFileSync(codeDirAgentsMd, 'utf-8');
|
|
97
|
-
console.log('Conteúdo length:', content.length);
|
|
98
|
-
console.log('Preview:', content.substring(0, 100) + '...');
|
|
99
|
-
}
|
|
100
|
-
else if (fs.existsSync(rootAgentsMd)) {
|
|
101
|
-
console.log('✓ AGENTS.md na raiz encontrado');
|
|
102
|
-
const content = fs.readFileSync(rootAgentsMd, 'utf-8');
|
|
103
|
-
console.log('Conteúdo length:', content.length);
|
|
104
|
-
console.log('Preview:', content.substring(0, 100) + '...');
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
console.log('✗ Nenhum AGENTS.md encontrado');
|
|
108
|
-
}
|
|
109
|
-
console.log('\n--- Teste 4: Verificar estrutura de IAgentMetadata ---');
|
|
110
|
-
if (metadata1) {
|
|
111
|
-
const hasUseProjectRules = 'useProjectRules' in metadata1;
|
|
112
|
-
console.log('Campo useProjectRules existe:', hasUseProjectRules);
|
|
113
|
-
console.log('Tipo de useProjectRules:', typeof metadata1.useProjectRules);
|
|
114
|
-
console.log('Valor de useProjectRules:', metadata1.useProjectRules);
|
|
115
|
-
}
|
|
116
|
-
console.log('\n=== Limpeza ===');
|
|
117
|
-
if (fs.existsSync(testAgentPath)) {
|
|
118
|
-
fs.unlinkSync(testAgentPath);
|
|
119
|
-
console.log('Arquivo removido:', testAgentPath);
|
|
120
|
-
}
|
|
121
|
-
if (fs.existsSync(testAgentPath2)) {
|
|
122
|
-
fs.unlinkSync(testAgentPath2);
|
|
123
|
-
console.log('Arquivo removido:', testAgentPath2);
|
|
124
|
-
}
|
|
125
|
-
console.log('\n=== Testes concluídos ===');
|
|
@@ -1,71 +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
|
-
const fs = __importStar(require("fs"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
const loader_1 = require("../../agent-runtime/context/project-rules/loader");
|
|
39
|
-
console.log('=== Teste do Loader de AGENTS.md ===\n');
|
|
40
|
-
console.log('Teste 1: Carregar AGENTS.md do projeto atual');
|
|
41
|
-
const projectRules = loader_1.loadProjectRules.load();
|
|
42
|
-
console.log('Source:', projectRules.source);
|
|
43
|
-
console.log('Path:', projectRules.path);
|
|
44
|
-
console.log('Content length:', projectRules.content.length);
|
|
45
|
-
console.log('Content preview:', projectRules.content.substring(0, 100) + '...\n');
|
|
46
|
-
console.log('Teste 2: Criar arquivo temporário AGENTS.md na raiz');
|
|
47
|
-
const tempPath = path.join(process.cwd(), 'AGENTS.md.test');
|
|
48
|
-
fs.writeFileSync(tempPath, '# Test Rules\n\nThis is a test rule file.\n');
|
|
49
|
-
console.log('Arquivo temporário criado:', tempPath);
|
|
50
|
-
console.log('\nTeste 3: Carregar de diretório específico');
|
|
51
|
-
const dirContent = loader_1.loadProjectRules.loadFromDirectory(process.cwd());
|
|
52
|
-
console.log('Content from directory:', dirContent.substring(0, 100) + '...');
|
|
53
|
-
console.log('\nTeste 4: Verificar prioridade');
|
|
54
|
-
if (projectRules.source === 'code-dir') {
|
|
55
|
-
console.log('✓ Prioridade correta: .code/AGENTS.md carregado');
|
|
56
|
-
}
|
|
57
|
-
else if (projectRules.source === 'root') {
|
|
58
|
-
console.log('✓ Prioridade correta: AGENTS.md na raiz carregado');
|
|
59
|
-
}
|
|
60
|
-
else {
|
|
61
|
-
console.log('✗ Nenhum AGENTS.md encontrado');
|
|
62
|
-
}
|
|
63
|
-
console.log('\nTeste 5: Carregar de diretório sem AGENTS.md');
|
|
64
|
-
const emptyDirContent = loader_1.loadProjectRules.loadFromDirectory(path.join(process.cwd(), 'node_modules'));
|
|
65
|
-
console.log('Content from empty dir:', emptyDirContent === '' ? '(vazio)' : emptyDirContent);
|
|
66
|
-
console.log('\n=== Limpeza ===');
|
|
67
|
-
if (fs.existsSync(tempPath)) {
|
|
68
|
-
fs.unlinkSync(tempPath);
|
|
69
|
-
console.log('Arquivo temporário removido:', tempPath);
|
|
70
|
-
}
|
|
71
|
-
console.log('\n=== Testes concluídos ===');
|
|
@@ -1,121 +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
|
-
const fs = __importStar(require("fs"));
|
|
37
|
-
const path = __importStar(require("path"));
|
|
38
|
-
const loader_1 = require("../../agent-runtime/context/project-rules/loader");
|
|
39
|
-
console.log('=== Teste de Prioridade de AGENTS.md ===\n');
|
|
40
|
-
const tempDir = path.join(process.cwd(), 'test-agents-md-temp');
|
|
41
|
-
const codeDir = path.join(tempDir, '.code');
|
|
42
|
-
const codeDirAgentsMd = path.join(codeDir, 'AGENTS.md');
|
|
43
|
-
const rootAgentsMd = path.join(tempDir, 'AGENTS.md');
|
|
44
|
-
if (!fs.existsSync(tempDir)) {
|
|
45
|
-
fs.mkdirSync(tempDir, { recursive: true });
|
|
46
|
-
}
|
|
47
|
-
if (!fs.existsSync(codeDir)) {
|
|
48
|
-
fs.mkdirSync(codeDir, { recursive: true });
|
|
49
|
-
}
|
|
50
|
-
console.log('--- Teste 1: Apenas AGENTS.md na raiz ---');
|
|
51
|
-
fs.writeFileSync(rootAgentsMd, '# Root Rules\n\nThese are root rules.\n');
|
|
52
|
-
console.log('Arquivo criado:', rootAgentsMd);
|
|
53
|
-
const originalCwd = process.cwd();
|
|
54
|
-
process.chdir(tempDir);
|
|
55
|
-
const rules1 = loader_1.loadProjectRules.load();
|
|
56
|
-
console.log('Source:', rules1.source);
|
|
57
|
-
console.log('Path:', rules1.path);
|
|
58
|
-
if (rules1.source === 'root') {
|
|
59
|
-
console.log('✓ Prioridade correta: AGENTS.md na raiz carregado');
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
console.log('✗ Erro: deveria carregar da raiz');
|
|
63
|
-
}
|
|
64
|
-
console.log('\n--- Teste 2: Ambos .code/AGENTS.md e AGENTS.md na raiz ---');
|
|
65
|
-
fs.writeFileSync(codeDirAgentsMd, '# Code Dir Rules\n\nThese are .code/ rules.\n');
|
|
66
|
-
console.log('Arquivo criado:', codeDirAgentsMd);
|
|
67
|
-
const rules2 = loader_1.loadProjectRules.load();
|
|
68
|
-
console.log('Source:', rules2.source);
|
|
69
|
-
console.log('Path:', rules2.path);
|
|
70
|
-
if (rules2.source === 'code-dir') {
|
|
71
|
-
console.log('✓ Prioridade correta: .code/AGENTS.md carregado (prioridade 1)');
|
|
72
|
-
}
|
|
73
|
-
else {
|
|
74
|
-
console.log('✗ Erro: deveria carregar de .code/');
|
|
75
|
-
}
|
|
76
|
-
console.log('\n--- Teste 3: Apenas .code/AGENTS.md ---');
|
|
77
|
-
if (fs.existsSync(rootAgentsMd)) {
|
|
78
|
-
fs.unlinkSync(rootAgentsMd);
|
|
79
|
-
console.log('Arquivo removido:', rootAgentsMd);
|
|
80
|
-
}
|
|
81
|
-
const rules3 = loader_1.loadProjectRules.load();
|
|
82
|
-
console.log('Source:', rules3.source);
|
|
83
|
-
console.log('Path:', rules3.path);
|
|
84
|
-
if (rules3.source === 'code-dir') {
|
|
85
|
-
console.log('✓ Prioridade correta: .code/AGENTS.md carregado');
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
console.log('✗ Erro: deveria carregar de .code/');
|
|
89
|
-
}
|
|
90
|
-
console.log('\n--- Teste 4: Nenhum AGENTS.md ---');
|
|
91
|
-
if (fs.existsSync(codeDirAgentsMd)) {
|
|
92
|
-
fs.unlinkSync(codeDirAgentsMd);
|
|
93
|
-
console.log('Arquivo removido:', codeDirAgentsMd);
|
|
94
|
-
}
|
|
95
|
-
const rules4 = loader_1.loadProjectRules.load();
|
|
96
|
-
console.log('Source:', rules4.source);
|
|
97
|
-
console.log('Path:', rules4.path);
|
|
98
|
-
console.log('Content length:', rules4.content.length);
|
|
99
|
-
if (rules4.source === 'none' && rules4.content === '') {
|
|
100
|
-
console.log('✓ Comportamento correto: nenhum arquivo encontrado, retorna vazio');
|
|
101
|
-
}
|
|
102
|
-
else {
|
|
103
|
-
console.log('✗ Erro: deveria retornar source: none e content vazio');
|
|
104
|
-
}
|
|
105
|
-
console.log('\n--- Teste 5: loadFromDirectory ---');
|
|
106
|
-
fs.writeFileSync(codeDirAgentsMd, '# Code Dir Rules\n\nThese are .code/ rules.\n');
|
|
107
|
-
const dirContent = loader_1.loadProjectRules.loadFromDirectory(codeDir);
|
|
108
|
-
console.log('Content from directory:', dirContent.substring(0, 50) + '...');
|
|
109
|
-
if (dirContent.includes('Code Dir Rules')) {
|
|
110
|
-
console.log('✓ loadFromDirectory carregou corretamente');
|
|
111
|
-
}
|
|
112
|
-
else {
|
|
113
|
-
console.log('✗ Erro ao carregar de diretório');
|
|
114
|
-
}
|
|
115
|
-
process.chdir(originalCwd);
|
|
116
|
-
console.log('\n=== Limpeza ===');
|
|
117
|
-
if (fs.existsSync(tempDir)) {
|
|
118
|
-
fs.rmSync(tempDir, { recursive: true, force: true });
|
|
119
|
-
console.log('Diretório temporário removido:', tempDir);
|
|
120
|
-
}
|
|
121
|
-
console.log('\n=== Testes concluídos ===');
|