@ericnunes/frame-code-cli 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/LICENSE +139 -0
  2. package/README.md +196 -0
  3. package/dist/agent-runtime/AgentFacade.js +33 -0
  4. package/dist/agent-runtime/context/hooks/compressionHook.js +56 -0
  5. package/dist/agent-runtime/context/hooks/index.js +5 -0
  6. package/dist/agent-runtime/context/project-rules/loader.js +72 -0
  7. package/dist/agent-runtime/context/system-prompts/index.js +5 -0
  8. package/dist/agent-runtime/context/system-prompts/loader.js +88 -0
  9. package/dist/agent-runtime/flows/templates/ReactAgentFlow.js +49 -0
  10. package/dist/agent-runtime/index.js +18 -0
  11. package/dist/agent-runtime/registry/AgentRegistry.js +93 -0
  12. package/dist/agent-runtime/registry/agentParser.js +515 -0
  13. package/dist/agent-runtime/registry/enums/agentType.enum.js +8 -0
  14. package/dist/agent-runtime/registry/index.js +20 -0
  15. package/dist/agent-runtime/registry/initialization.js +53 -0
  16. package/dist/agent-runtime/registry/interfaces/agentDependencies.interface.js +2 -0
  17. package/dist/agent-runtime/registry/interfaces/agentMetadata.interface.js +2 -0
  18. package/dist/agent-runtime/registry/interfaces/agentRegistry.interface.js +2 -0
  19. package/dist/app/bootstrap.js +22 -0
  20. package/dist/app/cli.js +31 -0
  21. package/dist/app/index.js +9 -0
  22. package/dist/cli/commands/autonomous.js +181 -0
  23. package/dist/cli/commands/index.js +11 -0
  24. package/dist/cli/commands/interactive.js +172 -0
  25. package/dist/cli/commands/memory.js +149 -0
  26. package/dist/cli/commands/multi-agent.js +131 -0
  27. package/dist/cli/index.js +18 -0
  28. package/dist/cli/input/images/attachments.js +173 -0
  29. package/dist/cli/input/images/imageInput.js +77 -0
  30. package/dist/cli/input/images/readImageAttachment.js +56 -0
  31. package/dist/cli/input/index.js +14 -0
  32. package/dist/cli/input/reader.js +26 -0
  33. package/dist/content/agents/README.md +324 -0
  34. package/dist/content/agents/architect.md +95 -0
  35. package/dist/content/agents/builder.md +85 -0
  36. package/dist/content/agents/code-agent.md +123 -0
  37. package/dist/content/agents/supervisor.md +63 -0
  38. package/dist/index.js +25 -0
  39. package/dist/infrastructure/compression/CompressionManager.js +315 -0
  40. package/dist/infrastructure/compression/LLMCompressionService.js +211 -0
  41. package/dist/infrastructure/compression/index.js +11 -0
  42. package/dist/infrastructure/compression/promptBuilder.js +132 -0
  43. package/dist/infrastructure/config/agentConfig.interface.js +2 -0
  44. package/dist/infrastructure/config/agentConfig.js +134 -0
  45. package/dist/infrastructure/config/config.interface.js +2 -0
  46. package/dist/infrastructure/config/config.js +112 -0
  47. package/dist/infrastructure/config/index.js +6 -0
  48. package/dist/infrastructure/logging/index.js +5 -0
  49. package/dist/infrastructure/logging/logger.interface.js +2 -0
  50. package/dist/infrastructure/logging/logger.js +33 -0
  51. package/dist/infrastructure/logging/raw-output-logger.js +35 -0
  52. package/dist/infrastructure/skills/index.js +5 -0
  53. package/dist/infrastructure/skills/loader.js +104 -0
  54. package/dist/infrastructure/telemetry/index.js +9 -0
  55. package/dist/infrastructure/telemetry/telemetry.interface.js +2 -0
  56. package/dist/infrastructure/telemetry/telemetryConfig.js +30 -0
  57. package/dist/infrastructure/telemetry/traceEventFormatter.js +90 -0
  58. package/dist/infrastructure/telemetry/traceSinkConsole.js +17 -0
  59. package/dist/scripts/_validate/telemetry-autonomous.js +23 -0
  60. package/dist/scripts/_validate/telemetry-multi-agent.js +50 -0
  61. package/dist/scripts/_validate/test-agents-md-dynamic-dir.js +104 -0
  62. package/dist/scripts/_validate/test-agents-md-injection.js +125 -0
  63. package/dist/scripts/_validate/test-agents-md-loader.js +71 -0
  64. package/dist/scripts/_validate/test-agents-md-priority.js +121 -0
  65. package/dist/scripts/_validate/test-chrome-mcp-agent.js +89 -0
  66. package/dist/tools/index.js +19 -0
  67. package/dist/tools/mcp/discoverer.js +95 -0
  68. package/dist/tools/mcp/index.js +9 -0
  69. package/dist/tools/mcp/loader.js +36 -0
  70. package/dist/tools/mcp/mcpConfig.interface.js +2 -0
  71. package/dist/tools/mcp/mcpMetadata.js +2 -0
  72. package/dist/tools/mcp/register.js +269 -0
  73. package/dist/tools/native/capabilities.js +155 -0
  74. package/dist/tools/native/file-outline.js +301 -0
  75. package/dist/tools/native/index.js +20 -0
  76. package/dist/tools/native/list-directory.js +148 -0
  77. package/dist/tools/native/read-image.js +140 -0
  78. package/dist/tools/registry/ToolInitializer.js +62 -0
  79. package/dist/tools/registry/index.js +11 -0
  80. package/dist/tools/registry/toolFilter.js +52 -0
  81. package/dist/tools/registry/toolRegistry.interface.js +2 -0
  82. package/package.json +81 -0
@@ -0,0 +1,140 @@
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.readImageTool = void 0;
37
+ const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
38
+ const fs_1 = require("fs");
39
+ const path = __importStar(require("path"));
40
+ const crypto_1 = require("crypto");
41
+ class ReadImageParamsSchema {
42
+ }
43
+ ReadImageParamsSchema.schemaProperties = {
44
+ source: 'string',
45
+ 'path?': 'string',
46
+ 'region?': 'object',
47
+ 'detail?': 'string',
48
+ 'maxBytes?': 'number',
49
+ };
50
+ function inferMimeType(filePath) {
51
+ const ext = path.extname(filePath).toLowerCase();
52
+ switch (ext) {
53
+ case '.png':
54
+ return 'image/png';
55
+ case '.jpg':
56
+ case '.jpeg':
57
+ return 'image/jpeg';
58
+ case '.webp':
59
+ return 'image/webp';
60
+ case '.gif':
61
+ return 'image/gif';
62
+ case '.bmp':
63
+ return 'image/bmp';
64
+ default:
65
+ return 'application/octet-stream';
66
+ }
67
+ }
68
+ function toSafeAbsolutePath(inputPath) {
69
+ return path.isAbsolute(inputPath) ? inputPath : path.resolve(process.cwd(), inputPath);
70
+ }
71
+ exports.readImageTool = new class extends frame_agent_sdk_1.ToolBase {
72
+ constructor() {
73
+ super(...arguments);
74
+ this.name = 'read_image';
75
+ this.description = 'Read an image from the host environment. This tool only returns a safe reference + metadata; the host attaches the image to the next LLM call.';
76
+ this.parameterSchema = ReadImageParamsSchema;
77
+ }
78
+ async execute(params) {
79
+ if (params.source !== 'path') {
80
+ return {
81
+ observation: `Unsupported source "${params.source}". Only "path" is supported in frame-code-cli.`,
82
+ metadata: {
83
+ readImage: {
84
+ path: '',
85
+ mimeType: '',
86
+ bytes: 0,
87
+ detail: params.detail,
88
+ },
89
+ },
90
+ };
91
+ }
92
+ const rawPath = params.path?.trim();
93
+ if (!rawPath) {
94
+ return {
95
+ observation: 'Missing required param: path (when source="path").',
96
+ metadata: {
97
+ readImage: {
98
+ path: '',
99
+ mimeType: '',
100
+ bytes: 0,
101
+ detail: params.detail,
102
+ },
103
+ },
104
+ };
105
+ }
106
+ const absolutePath = toSafeAbsolutePath(rawPath);
107
+ const stat = await fs_1.promises.stat(absolutePath);
108
+ const bytes = stat.size;
109
+ const maxBytes = Number.isFinite(params.maxBytes) ? Math.max(1, Number(params.maxBytes)) : 12 * 1024 * 1024;
110
+ if (bytes > maxBytes) {
111
+ return {
112
+ observation: `Image too large (${bytes} bytes). Max allowed is ${maxBytes} bytes.`,
113
+ metadata: {
114
+ readImage: {
115
+ path: absolutePath,
116
+ mimeType: inferMimeType(absolutePath),
117
+ bytes,
118
+ detail: params.detail,
119
+ },
120
+ },
121
+ };
122
+ }
123
+ const buffer = await fs_1.promises.readFile(absolutePath);
124
+ const hash = (0, crypto_1.createHash)('sha256').update(buffer).digest('hex');
125
+ const mimeType = inferMimeType(absolutePath);
126
+ const detail = params.detail;
127
+ return {
128
+ observation: `Image loaded. path="${absolutePath}", mimeType="${mimeType}", bytes=${bytes}, sha256=${hash.slice(0, 12)}…`,
129
+ metadata: {
130
+ readImage: {
131
+ path: absolutePath,
132
+ mimeType,
133
+ bytes,
134
+ detail,
135
+ hash,
136
+ },
137
+ },
138
+ };
139
+ }
140
+ }();
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.toolRegistry = void 0;
4
+ exports.initializeTools = initializeTools;
5
+ const frame_agent_sdk_1 = require("@ericnunes/frame-agent-sdk");
6
+ Object.defineProperty(exports, "toolRegistry", { enumerable: true, get: function () { return frame_agent_sdk_1.toolRegistry; } });
7
+ const native_1 = require("../native");
8
+ const register_1 = require("../mcp/register");
9
+ const logger_1 = require("../../infrastructure/logging/logger");
10
+ const config_1 = require("../../infrastructure/config");
11
+ const toolFilter_1 = require("./toolFilter");
12
+ let toolsInitialized = false;
13
+ async function initializeTools(options) {
14
+ if (toolsInitialized) {
15
+ return;
16
+ }
17
+ (0, config_1.loadConfigSync)();
18
+ const filterConfig = (() => {
19
+ const base = (0, toolFilter_1.getToolFilterConfig)();
20
+ if (typeof options?.allowAskUser === 'boolean') {
21
+ return { ...base, allowAskUser: options.allowAskUser };
22
+ }
23
+ return base;
24
+ })();
25
+ const allTools = [
26
+ native_1.searchTool,
27
+ native_1.listDirectoryTool,
28
+ native_1.readImageTool,
29
+ native_1.fileCreateTool,
30
+ native_1.fileEditTool,
31
+ native_1.fileReadTool,
32
+ native_1.terminalTool,
33
+ native_1.sleepTool,
34
+ native_1.fileOutlineTool,
35
+ native_1.listCapabilitiesTool,
36
+ native_1.enableCapabilityTool,
37
+ native_1.toDoIstTool,
38
+ new frame_agent_sdk_1.FinalAnswerTool(),
39
+ new frame_agent_sdk_1.CallFlowTool(new frame_agent_sdk_1.FlowRunnerImpl(new frame_agent_sdk_1.FlowRegistryImpl(), {}))
40
+ ];
41
+ if (filterConfig.allowAskUser) {
42
+ allTools.push(new frame_agent_sdk_1.AskUserTool());
43
+ }
44
+ const filteredTools = allTools.filter(tool => (0, toolFilter_1.shouldIncludeTool)(tool, filterConfig));
45
+ filteredTools.forEach(tool => {
46
+ try {
47
+ frame_agent_sdk_1.toolRegistry.register(tool);
48
+ }
49
+ catch (error) {
50
+ logger_1.logger.warn(`Falha ao registrar ferramenta ${tool.name}:`, error);
51
+ }
52
+ });
53
+ if (filterConfig.mcpToolsEnabled) {
54
+ try {
55
+ await (0, register_1.registerMcpTools)();
56
+ }
57
+ catch (err) {
58
+ logger_1.logger.error('Erro ao registrar MCP tools:', err);
59
+ }
60
+ }
61
+ toolsInitialized = true;
62
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getToolFilterConfig = exports.filterToolsByPolicy = exports.filterTools = exports.shouldIncludeTool = exports.toolRegistry = exports.initializeTools = void 0;
4
+ var ToolInitializer_1 = require("./ToolInitializer");
5
+ Object.defineProperty(exports, "initializeTools", { enumerable: true, get: function () { return ToolInitializer_1.initializeTools; } });
6
+ Object.defineProperty(exports, "toolRegistry", { enumerable: true, get: function () { return ToolInitializer_1.toolRegistry; } });
7
+ var toolFilter_1 = require("./toolFilter");
8
+ Object.defineProperty(exports, "shouldIncludeTool", { enumerable: true, get: function () { return toolFilter_1.shouldIncludeTool; } });
9
+ Object.defineProperty(exports, "filterTools", { enumerable: true, get: function () { return toolFilter_1.filterTools; } });
10
+ Object.defineProperty(exports, "filterToolsByPolicy", { enumerable: true, get: function () { return toolFilter_1.filterToolsByPolicy; } });
11
+ Object.defineProperty(exports, "getToolFilterConfig", { enumerable: true, get: function () { return toolFilter_1.getToolFilterConfig; } });
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getToolFilterConfig = getToolFilterConfig;
4
+ exports.shouldIncludeTool = shouldIncludeTool;
5
+ exports.filterTools = filterTools;
6
+ exports.filterToolsByPolicy = filterToolsByPolicy;
7
+ function getToolFilterConfig() {
8
+ const mode = process.env.AGENT_MODE === 'autonomous' ? 'autonomous' : 'interactive';
9
+ return {
10
+ mode,
11
+ mcpToolsEnabled: process.env.MCP_TOOLS_ENABLED !== 'false',
12
+ excludedTools: getExcludedToolsList(),
13
+ allowAskUser: mode !== 'autonomous'
14
+ };
15
+ }
16
+ function getExcludedToolsList() {
17
+ const excluded = process.env.EXCLUDED_TOOLS || '';
18
+ return excluded.split(',').map(tool => tool.trim()).filter(tool => tool.length > 0);
19
+ }
20
+ function shouldIncludeTool(tool, config) {
21
+ if (config.excludedTools.includes(tool.name)) {
22
+ return false;
23
+ }
24
+ if (!config.allowAskUser && (tool.name === 'ask_user' || tool.name === 'askUser')) {
25
+ return false;
26
+ }
27
+ if (!config.mcpToolsEnabled && tool.name.startsWith('mcp_')) {
28
+ return false;
29
+ }
30
+ if (tool.name === 'approval') {
31
+ return false;
32
+ }
33
+ return true;
34
+ }
35
+ function filterTools(tools, config) {
36
+ const filterConfig = config || getToolFilterConfig();
37
+ return tools.filter(tool => shouldIncludeTool(tool, filterConfig));
38
+ }
39
+ function filterToolsByPolicy(tools, policy, config) {
40
+ const base = filterTools(tools, config);
41
+ const allow = policy?.allow?.filter(Boolean);
42
+ const deny = policy?.deny?.filter(Boolean);
43
+ if (allow && allow.length > 0) {
44
+ const allowSet = new Set(allow);
45
+ return base.filter((tool) => allowSet.has(tool.name));
46
+ }
47
+ if (deny && deny.length > 0) {
48
+ const denySet = new Set(deny);
49
+ return base.filter((tool) => !denySet.has(tool.name));
50
+ }
51
+ return base;
52
+ }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,81 @@
1
+ {
2
+ "name": "@ericnunes/frame-code-cli",
3
+ "version": "0.0.1",
4
+ "description": "CLI para interagir com agentes de codificação criados com o frame-agent-sdk",
5
+ "main": "dist/index.js",
6
+ "bin": {
7
+ "frame-code": "dist/index.js"
8
+ },
9
+ "repository": {
10
+ "type": "git",
11
+ "url": "git+https://github.com/ericnunes/frame-code-cli.git"
12
+ },
13
+ "bugs": {
14
+ "url": "https://github.com/ericnunes/frame-code-cli/issues"
15
+ },
16
+ "homepage": "https://github.com/ericnunes/frame-code-cli#readme",
17
+ "files": [
18
+ "dist",
19
+ "README.md",
20
+ "LICENSE"
21
+ ],
22
+ "publishConfig": {
23
+ "access": "public"
24
+ },
25
+ "scripts": {
26
+ "build": "tsc && npm run copy:agents",
27
+ "copy:agents": "npx cpy \"src/content/agents/*.md\" \"dist/content/agents\"",
28
+ "dev": "ts-node src/index.ts",
29
+ "start": "node dist/index.js",
30
+ "autonomous": "node dist/index.js autonomous",
31
+ "multi-agent": "node dist/index.js multi-agent",
32
+ "test:mcp": "ts-node scripts/test-mcp.ts",
33
+ "interactive": "chmod +x src/scripts/capture-logs.sh && src/scripts/capture-logs.sh npm run dev interactive",
34
+ "dev:logs": "bash src/scripts/capture-logs.sh npm run dev interactive",
35
+ "dev:start": "npm run dev interactive",
36
+ "log:view": "tail -f server.log",
37
+ "log:clear": "rm -f server.log",
38
+ "log:stats": "ls -la server.log",
39
+ "clean": "rm -rf dist"
40
+ },
41
+ "keywords": [
42
+ "cli",
43
+ "agent",
44
+ "ai",
45
+ "framework"
46
+ ],
47
+ "author": "Eric Nunes",
48
+ "license": "SEE LICENSE IN LICENSE",
49
+ "dependencies": {
50
+ "@ericnunes/frame-agent-sdk": "^0.0.3",
51
+ "@modelcontextprotocol/sdk": "^1.23.0",
52
+ "@typescript-eslint/typescript-estree": "^8.48.0",
53
+ "chalk": "^5.6.2",
54
+ "commander": "^14.0.1",
55
+ "dotenv": "^17.2.3",
56
+ "eventsource": "^4.1.0",
57
+ "fast-diff": "^1.3.0",
58
+ "glob": "^11.0.3",
59
+ "inquirer": "^12.9.6",
60
+ "openai": "^6.10.0",
61
+ "tree-kill": "^1.2.2"
62
+ },
63
+ "devDependencies": {
64
+ "@types/dotenv": "^6.1.1",
65
+ "@types/node": "^24.7.0",
66
+ "cpy-cli": "^6.0.0",
67
+ "nodemon": "^3.1.11",
68
+ "ts-node": "^10.9.2",
69
+ "ts-node-dev": "^2.0.0",
70
+ "tsconfig-paths": "^4.2.0",
71
+ "typescript": "^5.9.2"
72
+ },
73
+ "engines": {
74
+ "node": ">=18.0.0"
75
+ },
76
+ "directories": {
77
+ "doc": "docs",
78
+ "example": "examples"
79
+ },
80
+ "types": "./dist/index.d.ts"
81
+ }