overai 1.4.10 → 1.4.13

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/README.md CHANGED
@@ -46,6 +46,30 @@ While tools like **n8n** and **Zapier** are excellent for linear automation (e.g
46
46
  npm install overai
47
47
  ```
48
48
 
49
+ ## ✨ Auto-Coder CLI (Magic Project Generator)
50
+
51
+ Want to build a project instantly? OverAI includes a powerful CLI that can scaffold entire projects (React, Node, Python, etc.) from a single prompt.
52
+
53
+ **Usage:**
54
+
55
+ ```bash
56
+ # 1. Set your API Key (OpenAI, Gemini, or Anthropic)
57
+ export OPENAI_API_KEY=sk-...
58
+ # OR
59
+ export GOOGLE_API_KEY=AIza...
60
+
61
+ # 2. Run the magic command
62
+ npx overai-create "A personal portfolio website with HTML/CSS"
63
+ ```
64
+
65
+ **Options:**
66
+
67
+ * **Auto-Detection**: The CLI automatically picks the best model based on your environment variables.
68
+ * **Force Model**: You can specify a model manually:
69
+ ```bash
70
+ npx overai-create "A snake game in Python" --model google/gemini-2.0-flash-exp
71
+ ```
72
+
49
73
  ---
50
74
 
51
75
  ## ⚡ Quick Start: Gemini Example
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,219 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
4
+ if (k2 === undefined) k2 = k;
5
+ var desc = Object.getOwnPropertyDescriptor(m, k);
6
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
7
+ desc = { enumerable: true, get: function() { return m[k]; } };
8
+ }
9
+ Object.defineProperty(o, k2, desc);
10
+ }) : (function(o, m, k, k2) {
11
+ if (k2 === undefined) k2 = k;
12
+ o[k2] = m[k];
13
+ }));
14
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
15
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
16
+ }) : function(o, v) {
17
+ o["default"] = v;
18
+ });
19
+ var __importStar = (this && this.__importStar) || (function () {
20
+ var ownKeys = function(o) {
21
+ ownKeys = Object.getOwnPropertyNames || function (o) {
22
+ var ar = [];
23
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
24
+ return ar;
25
+ };
26
+ return ownKeys(o);
27
+ };
28
+ return function (mod) {
29
+ if (mod && mod.__esModule) return mod;
30
+ var result = {};
31
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
32
+ __setModuleDefault(result, mod);
33
+ return result;
34
+ };
35
+ })();
36
+ Object.defineProperty(exports, "__esModule", { value: true });
37
+ const index_1 = require("../index");
38
+ const fs = __importStar(require("fs"));
39
+ const path = __importStar(require("path"));
40
+ const child_process_1 = require("child_process");
41
+ const util_1 = require("util");
42
+ const readline = __importStar(require("readline"));
43
+ const execAsync = (0, util_1.promisify)(child_process_1.exec);
44
+ // 1. Define Tools for the Agent
45
+ const fileTools = [
46
+ {
47
+ name: "write_file",
48
+ description: "Write content to a file. Use this to create code files.",
49
+ parameters: {
50
+ type: "object",
51
+ properties: {
52
+ path: { type: "string", description: "File path (relative to current directory)" },
53
+ content: { type: "string", description: "Content to write to the file" }
54
+ },
55
+ required: ["path", "content"]
56
+ },
57
+ execute: async ({ path: filePath, content }) => {
58
+ try {
59
+ const fullPath = path.resolve(process.cwd(), filePath);
60
+ // Ensure directory exists
61
+ const dir = path.dirname(fullPath);
62
+ if (!fs.existsSync(dir)) {
63
+ fs.mkdirSync(dir, { recursive: true });
64
+ }
65
+ fs.writeFileSync(fullPath, content);
66
+ return `✅ File created: ${filePath}`;
67
+ }
68
+ catch (error) {
69
+ return `❌ Error writing file: ${error.message}`;
70
+ }
71
+ }
72
+ },
73
+ {
74
+ name: "run_command",
75
+ description: "Run a shell command. Use this to install dependencies, run tests, etc.",
76
+ parameters: {
77
+ type: "object",
78
+ properties: {
79
+ command: { type: "string", description: "Shell command to execute" }
80
+ },
81
+ required: ["command"]
82
+ },
83
+ execute: async ({ command }) => {
84
+ try {
85
+ console.log(`💻 Executing: ${command}`);
86
+ const { stdout, stderr } = await execAsync(command);
87
+ return `STDOUT:\n${stdout}\n\nSTDERR:\n${stderr}`;
88
+ }
89
+ catch (error) {
90
+ return `❌ Command failed: ${error.message}`;
91
+ }
92
+ }
93
+ },
94
+ {
95
+ name: "read_file",
96
+ description: "Read a file's content.",
97
+ parameters: {
98
+ type: "object",
99
+ properties: {
100
+ path: { type: "string", description: "File path to read" }
101
+ },
102
+ required: ["path"]
103
+ },
104
+ execute: async ({ path: filePath }) => {
105
+ try {
106
+ const content = fs.readFileSync(path.resolve(process.cwd(), filePath), 'utf-8');
107
+ return content;
108
+ }
109
+ catch (error) {
110
+ return `❌ Error reading file: ${error.message}`;
111
+ }
112
+ }
113
+ }
114
+ ];
115
+ const rl = readline.createInterface({
116
+ input: process.stdin,
117
+ output: process.stdout
118
+ });
119
+ async function main() {
120
+ // Model Selection Logic
121
+ let model = "gpt-4o";
122
+ const args = process.argv.slice(2);
123
+ const modelArgIndex = args.indexOf('--model');
124
+ // Handle --model flag
125
+ if (modelArgIndex !== -1 && args[modelArgIndex + 1]) {
126
+ model = args[modelArgIndex + 1];
127
+ args.splice(modelArgIndex, 2); // Remove flag from args so it doesn't become part of the prompt
128
+ }
129
+ else {
130
+ // Auto-detect best available model based on env vars
131
+ if (process.env.OPENAI_API_KEY) {
132
+ model = "gpt-4o";
133
+ }
134
+ else if (process.env.GOOGLE_API_KEY) {
135
+ model = "google/gemini-2.0-flash-exp";
136
+ }
137
+ else if (process.env.ANTHROPIC_API_KEY) {
138
+ model = "anthropic/claude-3-5-sonnet-20240620";
139
+ }
140
+ else {
141
+ console.error("❌ Error: No API Key found.");
142
+ console.error("Please set ONE of the following environment variables:");
143
+ console.error(" export OPENAI_API_KEY=sk-...");
144
+ console.error(" export GOOGLE_API_KEY=AIza...");
145
+ console.error(" export ANTHROPIC_API_KEY=sk-ant-...");
146
+ process.exit(1);
147
+ }
148
+ }
149
+ console.log(`🧠 Using AI Model: \x1b[36m${model}\x1b[0m`);
150
+ // 2. Create the "AutoCoder" Agent
151
+ const coder = new index_1.Agent({
152
+ name: "AutoCoder",
153
+ instructions: `You are an Elite FullStack Software Architect and Engineer.
154
+ Your goal is to scaffold and build fully functional projects based on user requirements.
155
+
156
+ CAPABILITIES:
157
+ - You can create files and directories (write_file).
158
+ - You can run system commands (run_command) like npm, pip, git, etc.
159
+ - You can read files to check content (read_file).
160
+
161
+ PROCESS:
162
+ 1. ANALYZE: Understand the user's request and technology stack (Node, Python, React, etc.).
163
+ 2. PLAN: Decide on the directory structure and necessary files.
164
+ 3. SCAFFOLD: Create the project directory and initialize it (npm init, etc.).
165
+ 4. IMPLEMENT: Create the core files (index.js, main.py, App.tsx, etc.) with working code.
166
+ 5. DEPENDENCIES: Install necessary packages.
167
+ 6. VERIFY: Run a command to prove the project works or builds successfully.
168
+
169
+ RULES:
170
+ - ALWAYS start by creating a new directory for the project to avoid cluttering the root.
171
+ - Be comprehensive: Include README.md, .gitignore, and config files.
172
+ - If something fails, try to fix it or report the specific error.
173
+ - Do not ask for permission for each step, proceed autonomously until completion.`,
174
+ llm: model,
175
+ tools: fileTools
176
+ });
177
+ // 3. Get User Input
178
+ const question = (query) => {
179
+ return new Promise((resolve) => rl.question(query, resolve));
180
+ };
181
+ console.log("\n🚀 **OverAI Auto-Coder** initialized.");
182
+ console.log("I can build any project for you (Node.js, Python, simple websites, scripts...).");
183
+ // If argument provided via CLI, use it. Otherwise ask.
184
+ let userRequest = args.join(" ");
185
+ if (!userRequest.trim()) {
186
+ userRequest = await question("\n🛠️ What project should I build for you? (e.g., 'A weather CLI in Python', 'A React Todo app'): ");
187
+ }
188
+ else {
189
+ console.log(`\n🛠️ Request received: "${userRequest}"`);
190
+ }
191
+ rl.close();
192
+ if (!userRequest.trim()) {
193
+ console.log("❌ No request provided. Exiting.");
194
+ return;
195
+ }
196
+ const task = `
197
+ BUILD REQUEST: "${userRequest}"
198
+
199
+ Execute this request from start to finish.
200
+ 1. Create a suitable folder name based on the request.
201
+ 2. Implement the full solution.
202
+ 3. Verify it runs.
203
+ `;
204
+ // 4. Start OverAI
205
+ const overai = new index_1.OverAI({
206
+ agents: [coder],
207
+ tasks: [task],
208
+ verbose: true
209
+ });
210
+ console.log(`\n🤖 AutoCoder starting task...\n`);
211
+ try {
212
+ await overai.start();
213
+ console.log("\n✅ Mission Complete! Check the created folder.");
214
+ }
215
+ catch (error) {
216
+ console.error("❌ Mission Failed:", error);
217
+ }
218
+ }
219
+ main();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "overai",
3
- "version": "1.4.10",
3
+ "version": "1.4.13",
4
4
  "description": "OverAI TypeScript AI Agents Framework - Build, Deploy, and Monetize AI Agents in Minutes",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -10,7 +10,8 @@
10
10
  "LICENSE"
11
11
  ],
12
12
  "bin": {
13
- "overai": "./dist/cli/index.js"
13
+ "overai": "./dist/cli/index.js",
14
+ "overai-create": "./dist/cli/create.js"
14
15
  },
15
16
  "scripts": {
16
17
  "build": "tsc",