openwork-agent 1.0.0

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 (46) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +436 -0
  3. package/package.json +78 -0
  4. package/src/core/TechDetector.js +351 -0
  5. package/src/generators/ProjectGenerator.js +1241 -0
  6. package/src/generators/ProjectGeneratorExtensions.js +14 -0
  7. package/src/generators/TemplateMethods.js +402 -0
  8. package/src/generators/index.js +5 -0
  9. package/src/index.js +152 -0
  10. package/src/main.js +8 -0
  11. package/src/templates/common/README.md.hbs +358 -0
  12. package/src/templates/docker/index.js +518 -0
  13. package/src/templates/docker.js +58 -0
  14. package/src/templates/go/basic/api/routes/user.go.hbs +138 -0
  15. package/src/templates/go/basic/config/config.go.hbs +54 -0
  16. package/src/templates/go/basic/go.mod.hbs +8 -0
  17. package/src/templates/go/basic/main.go.hbs +70 -0
  18. package/src/templates/go/basic/models/user.go.hbs +69 -0
  19. package/src/templates/go/basic/services/user_service.go.hbs +173 -0
  20. package/src/templates/java/basic/src/main/java/com/{{snakeCase projectName}}/{{projectName}}/controller/UserController.java.hbs +91 -0
  21. package/src/templates/java/basic/src/main/java/com/{{snakeCase projectName}}/{{projectName}}/dto/ApiResponse.java.hbs +40 -0
  22. package/src/templates/java/basic/src/main/java/com/{{snakeCase projectName}}/{{projectName}}/model/User.java.hbs +102 -0
  23. package/src/templates/java/basic/src/main/java/com/{{snakeCase projectName}}/{{projectName}}/repository/UserRepository.java.hbs +20 -0
  24. package/src/templates/java/basic/src/main/java/com/{{snakeCase projectName}}/{{projectName}}/service/UserService.java.hbs +65 -0
  25. package/src/templates/java/basic/src/main/java/com/{{snakeCase projectName}}/{{projectName}}/{{pascalCase projectName}}Application.java.hbs +16 -0
  26. package/src/templates/node/basic/src/config/database.ts.hbs +18 -0
  27. package/src/templates/node/basic/src/controllers/UserController.ts.hbs +98 -0
  28. package/src/templates/node/basic/src/index.ts.hbs +45 -0
  29. package/src/templates/node/basic/src/middleware/errorHandler.ts.hbs +33 -0
  30. package/src/templates/node/basic/src/routes/index.ts.hbs +42 -0
  31. package/src/templates/node/basic/src/types/index.ts.hbs +18 -0
  32. package/src/templates/python/basic/config/database.py.hbs +36 -0
  33. package/src/templates/python/basic/main.py.hbs +58 -0
  34. package/src/templates/python/basic/middleware/error_handler.py.hbs +41 -0
  35. package/src/templates/python/basic/models/user.py.hbs +40 -0
  36. package/src/templates/python/basic/routes/__init__.py.hbs +12 -0
  37. package/src/templates/python/basic/routes/users.py.hbs +64 -0
  38. package/src/templates/rust/basic/Cargo.toml.hbs +39 -0
  39. package/src/templates/rust/basic/src/config/database.rs.hbs +27 -0
  40. package/src/templates/rust/basic/src/handlers/user.rs.hbs +130 -0
  41. package/src/templates/rust/basic/src/handlers/user_routes.rs.hbs +15 -0
  42. package/src/templates/rust/basic/src/main.rs.hbs +53 -0
  43. package/src/templates/rust/basic/src/models/mod.rs.hbs +79 -0
  44. package/src/templates/rust/basic/src/schema.rs.hbs +10 -0
  45. package/src/utils/FileManager.js +186 -0
  46. package/src/utils/Templates.js +231 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Manoj Sharma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,436 @@
1
+ # OpenWork Agent
2
+
3
+ <div align="center">
4
+
5
+ ![OpenWork Agent Logo](https://img.shields.io/badge/OpenWork-Agent-blue?style=for-the-badge&logo=code)
6
+ ![NPM Version](https://img.shields.io/npm/v/openwork-agent?style=for-the-badge&logo=npm)
7
+ ![License](https://img.shields.io/npm/l/openwork-agent?style=for-the-badge&logo=open-source-initiative)
8
+ ![Downloads](https://img.shields.io/npm/dt/openwork-agent?style=for-the-badge&logo=npm)
9
+
10
+ **AI-powered backend code generator for any technology stack**
11
+
12
+ Create complete backend projects with just a few commands! πŸš€
13
+
14
+ [Install](#-installation) β€’ [Quick Start](#-quick-start) β€’ [Documentation](#-documentation) β€’ [Contributing](#-contributing)
15
+
16
+ </div>
17
+
18
+ ---
19
+
20
+ ## ✨ Features
21
+
22
+ - 🌍 **Multiple Technologies**: Node.js, Python, Java, Go, Rust, PHP, and more
23
+ - 🎯 **Popular Frameworks**: Express, FastAPI, Spring Boot, Gin, Actix, Laravel, etc.
24
+ - πŸ—„οΈ **Database Support**: MongoDB, PostgreSQL, MySQL, SQLite, Redis
25
+ - 🐳 **Docker Support**: Automatic Dockerfile and docker-compose generation
26
+ - πŸš€ **CI/CD Ready**: GitHub Actions workflow generation
27
+ - πŸ’¬ **Interactive Mode**: Guided project setup with prompts
28
+ - πŸ“‹ **Template System**: Customizable templates for any stack
29
+ - πŸ” **Technology Detection**: Analyze existing projects
30
+ - πŸ›‘οΈ **Best Practices**: Security, logging, error handling, CORS
31
+
32
+ ## πŸ“¦ Installation
33
+
34
+ ### Global Installation (Recommended)
35
+
36
+ ```bash
37
+ npm install -g openwork-agent
38
+ ```
39
+
40
+ ### Local Installation
41
+
42
+ ```bash
43
+ npm install openwork-agent
44
+ ```
45
+
46
+ ### Using Yarn
47
+
48
+ ```bash
49
+ yarn global add openwork-agent
50
+ ```
51
+
52
+ ### Using pnpm
53
+
54
+ ```bash
55
+ pnpm add -g openwork-agent
56
+ ```
57
+
58
+ ## πŸš€ Quick Start
59
+
60
+ ### 1. Create a New Project (Interactive Mode)
61
+
62
+ ```bash
63
+ openwork-agent create my-awesome-api
64
+ ```
65
+
66
+ ### 2. Create with Specific Technology
67
+
68
+ ```bash
69
+ openwork-agent create my-fastapi-app --tech python --framework fastapi --database postgresql
70
+ ```
71
+
72
+ ### 3. Create with Docker and Tests
73
+
74
+ ```bash
75
+ openwork-agent create my-enterprise-app --tech node --framework express --database mongodb --docker --tests
76
+ ```
77
+
78
+ ### 4. List Available Templates
79
+
80
+ ```bash
81
+ openwork-agent templates
82
+ ```
83
+
84
+ ### 5. Analyze Existing Project
85
+
86
+ ```bash
87
+ cd existing-project
88
+ openwork-agent analyze
89
+ ```
90
+
91
+ ## πŸ“‹ Supported Technologies
92
+
93
+ ### JavaScript/Node.js
94
+ - **Frameworks**: Express.js, NestJS, Fastify, Koa, Hapi
95
+ - **Databases**: MongoDB (Mongoose), PostgreSQL, MySQL, SQLite
96
+ - **Features**: TypeScript, JWT auth, validation, testing
97
+
98
+ ### Python
99
+ - **Frameworks**: FastAPI, Django, Flask, Tornado, AioHTTP
100
+ - **Databases**: MongoDB (Motor), PostgreSQL (asyncpg), MySQL, SQLite
101
+ - **Features**: Pydantic validation, async/await, Swagger docs
102
+
103
+ ### Java
104
+ - **Frameworks**: Spring Boot, Quarkus, Micronaut, Vert.x
105
+ - **Databases**: MongoDB, PostgreSQL, MySQL, Oracle
106
+ - **Features**: Spring Data, REST controllers, JPA, testing
107
+
108
+ ### Go
109
+ - **Frameworks**: Gin, Echo, Fiber, Chi, Gorilla Mux
110
+ - **Databases**: MongoDB, PostgreSQL, MySQL, SQLite
111
+ - **Features**: Structured logging, middleware, validation
112
+
113
+ ### Rust
114
+ - **Frameworks**: Actix-web, Rocket, Warp, Axum
115
+ - **Databases**: PostgreSQL, SQLite
116
+ - **Features**: Diesel ORM, async, error handling
117
+
118
+ ### PHP
119
+ - **Frameworks**: Laravel, Symfony, Slim
120
+ - **Databases**: MySQL, PostgreSQL, SQLite
121
+ - **Features**: Eloquent ORM, middleware, routing
122
+
123
+ ## πŸ“– Usage Examples
124
+
125
+ ### Node.js with Express and MongoDB
126
+
127
+ ```bash
128
+ openwork-agent create blog-api --tech node --framework express --database mongodb --docker
129
+ ```
130
+
131
+ **Generated:**
132
+ - Express.js server with TypeScript
133
+ - MongoDB integration with Mongoose
134
+ - User CRUD operations
135
+ - Docker setup
136
+ - JWT authentication
137
+ - Error handling middleware
138
+
139
+ ### Python FastAPI with PostgreSQL
140
+
141
+ ```bash
142
+ openwork-agent create data-api --tech python --framework fastapi --database postgresql --tests
143
+ ```
144
+
145
+ **Generated:**
146
+ - FastAPI application
147
+ - PostgreSQL integration
148
+ - Pydantic models
149
+ - Async database operations
150
+ - API documentation (Swagger)
151
+ - Unit tests with pytest
152
+
153
+ ### Java Spring Boot Microservice
154
+
155
+ ```bash
156
+ openwork-agent create user-service --tech java --framework spring --database mysql --ci
157
+ ```
158
+
159
+ **Generated:**
160
+ - Spring Boot application
161
+ - MySQL integration with JPA
162
+ - REST controllers
163
+ - Service layer
164
+ - Unit tests with JUnit
165
+ - GitHub Actions workflow
166
+
167
+ ### Go Gin Web Service
168
+
169
+ ```bash
170
+ openwork-agent create go-api --tech go --framework gin --database postgresql --docker
171
+ ```
172
+
173
+ **Generated:**
174
+ - Gin web framework setup
175
+ - PostgreSQL with GORM
176
+ - Structured logging
177
+ - Configuration management
178
+ - Docker multi-stage build
179
+
180
+ ## πŸ—‚οΈ Project Structure
181
+
182
+ Generated projects follow best practices:
183
+
184
+ ```
185
+ my-project/
186
+ β”œβ”€β”€ src/ # Source code
187
+ β”‚ β”œβ”€β”€ controllers/ # Route controllers
188
+ β”‚ β”œβ”€β”€ models/ # Data models
189
+ β”‚ β”œβ”€β”€ routes/ # API routes
190
+ β”‚ β”œβ”€β”€ middleware/ # Middleware
191
+ β”‚ β”œβ”€β”€ services/ # Business logic
192
+ β”‚ β”œβ”€β”€ utils/ # Utilities
193
+ β”‚ └── config/ # Configuration
194
+ β”œβ”€β”€ tests/ # Test files
195
+ β”œβ”€β”€ docs/ # Documentation
196
+ β”œβ”€β”€ Dockerfile # Docker configuration
197
+ β”œβ”€β”€ docker-compose.yml # Development environment
198
+ β”œβ”€β”€ .github/workflows/ # CI/CD workflows
199
+ β”œβ”€β”€ package.json # Dependencies
200
+ β”œβ”€β”€ .env.example # Environment template
201
+ └── README.md # Project documentation
202
+ ```
203
+
204
+ ## πŸ”§ Configuration
205
+
206
+ ### CLI Options
207
+
208
+ ```bash
209
+ Options:
210
+ -t, --tech <technology> Specify technology (node, python, java, go, rust, php)
211
+ -d, --database <database> Specify database (mongodb, postgresql, mysql, sqlite, redis)
212
+ -f, --framework <framework> Specify framework (express, fastapi, spring, gin, etc.)
213
+ --template <template> Use specific template
214
+ --no-interactive Skip interactive prompts
215
+ --docker Include Docker configuration
216
+ --tests Include test setup
217
+ --ci Include CI/CD configuration
218
+ ```
219
+
220
+ ### Environment Variables
221
+
222
+ ```bash
223
+ # Server
224
+ PORT=3000
225
+ NODE_ENV=development
226
+
227
+ # Database
228
+ DATABASE_URL=mongodb://localhost:27017/myapp
229
+ DB_NAME=myapp
230
+
231
+ # Security
232
+ JWT_SECRET=your-secret-key
233
+ CORS_ORIGINS=http://localhost:3000
234
+
235
+ # Logging
236
+ LOG_LEVEL=info
237
+ ```
238
+
239
+ ## πŸ“‘ API Endpoints
240
+
241
+ Every generated project includes these standard endpoints:
242
+
243
+ ### Health Check
244
+ ```http
245
+ GET /health
246
+ ```
247
+
248
+ ### User Management
249
+ ```http
250
+ GET /api/users # Get all users
251
+ GET /api/users/:id # Get user by ID
252
+ POST /api/users # Create new user
253
+ PUT /api/users/:id # Update user
254
+ DELETE /api/users/:id # Delete user
255
+ ```
256
+
257
+ ## 🐳 Docker Support
258
+
259
+ Generated projects include:
260
+
261
+ ### Multi-stage Dockerfile
262
+ Optimized for production builds with security best practices.
263
+
264
+ ### Docker Compose
265
+ Complete development environment with database and services.
266
+
267
+ ### Example docker-compose.yml
268
+ ```yaml
269
+ version: '3.8'
270
+ services:
271
+ api:
272
+ build: .
273
+ ports:
274
+ - "3000:3000"
275
+ depends_on:
276
+ - mongodb
277
+ environment:
278
+ - DATABASE_URL=mongodb://mongodb:27017/myapp
279
+
280
+ mongodb:
281
+ image: mongo:7.0
282
+ ports:
283
+ - "27017:27017"
284
+ volumes:
285
+ - mongodb_data:/data/db
286
+
287
+ volumes:
288
+ mongodb_data:
289
+ ```
290
+
291
+ ## πŸ§ͺ Testing
292
+
293
+ Generated projects include comprehensive test setups:
294
+
295
+ ### Node.js
296
+ ```bash
297
+ npm test # Run tests
298
+ npm run test:watch # Watch mode
299
+ npm run test:coverage # Coverage report
300
+ ```
301
+
302
+ ### Python
303
+ ```bash
304
+ pytest # Run tests
305
+ pytest --cov # Coverage report
306
+ pytest -v # Verbose output
307
+ ```
308
+
309
+ ### Java
310
+ ```bash
311
+ mvn test # Run tests
312
+ mvn verify # Run with integration tests
313
+ ```
314
+
315
+ ### Go
316
+ ```bash
317
+ go test ./... # Run all tests
318
+ go test -v ./... # Verbose output
319
+ go test -cover ./... # Coverage report
320
+ ```
321
+
322
+ ### Rust
323
+ ```bash
324
+ cargo test # Run tests
325
+ cargo test -- --nocapture # Verbose output
326
+ ```
327
+
328
+ ## πŸ”’ Security Features
329
+
330
+ - **Input Validation**: Comprehensive validation using appropriate libraries
331
+ - **SQL Injection Prevention**: ORM usage with parameterized queries
332
+ - **XSS Protection**: Content Security Policy and input sanitization
333
+ - **CORS Configuration**: Proper CORS setup for APIs
334
+ - **Security Headers**: Helmet.js (Node.js) or equivalent
335
+ - **JWT Authentication**: Secure token-based authentication
336
+ - **Rate Limiting**: Built-in rate limiting support
337
+
338
+ ## πŸ“ˆ Performance Features
339
+
340
+ - **Connection Pooling**: Database connection management
341
+ - **Caching**: Redis integration support
342
+ - **Async Operations**: Full async/await support where applicable
343
+ - **Compression**: Gzip/Brotli compression
344
+ - **Error Handling**: Comprehensive error handling and logging
345
+ - **Health Checks**: Application health monitoring
346
+
347
+ ## πŸš€ Deployment
348
+
349
+ ### Heroku
350
+ ```bash
351
+ heroku create your-app-name
352
+ git push heroku main
353
+ ```
354
+
355
+ ### Vercel
356
+ ```bash
357
+ npm i -g vercel
358
+ vercel --prod
359
+ ```
360
+
361
+ ### Railway
362
+ ```bash
363
+ railway login
364
+ railway init
365
+ railway up
366
+ ```
367
+
368
+ ### AWS
369
+ ```bash
370
+ # Using Docker
371
+ docker build -t my-app .
372
+ docker run -p 3000:3000 my-app
373
+ ```
374
+
375
+ ## 🀝 Contributing
376
+
377
+ We welcome contributions! Please see our [Contributing Guide](CONTRIBUTING.md) for details.
378
+
379
+ ### Development Setup
380
+
381
+ ```bash
382
+ git clone https://github.com/openwork-agent/openwork-agent.git
383
+ cd openwork-agent
384
+ npm install
385
+ npm test
386
+ npm link
387
+ ```
388
+
389
+ ### Adding New Templates
390
+
391
+ 1. Create template files in `src/templates/{technology}/`
392
+ 2. Add framework support in `TechDetector.js`
393
+ 3. Update configuration in generators
394
+ 4. Add tests and documentation
395
+
396
+ ## πŸ“ License
397
+
398
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
399
+
400
+ ## πŸ™ Acknowledgments
401
+
402
+ - Built with ❀️ for the developer community
403
+ - Thanks to all the amazing open-source projects
404
+ - Inspired by the need for rapid backend development
405
+
406
+ ## πŸ“ž Support
407
+
408
+ - πŸ“§ Email: [manoj.sharma@example.com](mailto:manoj.sharma@example.com)
409
+ - πŸ’Ό LinkedIn: [Manoj Sharma](https://linkedin.com/in/manoj-sharma)
410
+ - πŸ› Issues: [GitHub Issues](https://github.com/manoj1234-ms/openwork-agent/issues)
411
+ - πŸ“– Documentation: [GitHub README](https://github.com/manoj1234-ms/openwork-agent#readme)
412
+
413
+ ## πŸ—ΊοΈ Roadmap
414
+
415
+ - [ ] GraphQL template support
416
+ - [ ] Frontend template generation
417
+ - [ ] Microservice templates
418
+ - [ ] Real-time features (WebSocket)
419
+ - [ ] Advanced authentication patterns
420
+ - [ ] Monitoring and observability
421
+ - [ ] Cloud deployment templates
422
+ - [ ] Template marketplace
423
+
424
+ ---
425
+
426
+ <div align="center">
427
+
428
+ **⭐ Star this repo if it helped you!**
429
+
430
+ Built with ❀️ by [Manoj Sharma](https://github.com/manoj1234-ms)
431
+
432
+ [![GitHub stars](https://img.shields.io/github/stars/openwork-agent/openwork-agent?style=social)](https://github.com/openwork-agent/openwork-agent)
433
+ [![GitHub forks](https://img.shields.io/github/forks/openwork-agent/openwork-agent?style=social)](https://github.com/openwork-agent/openwork-agent)
434
+ [![GitHub issues](https://img.shields.io/github/issues/openwork-agent/openwork-agent)](https://github.com/openwork-agent/openwork-agent/issues)
435
+
436
+ </div>
package/package.json ADDED
@@ -0,0 +1,78 @@
1
+ {
2
+ "name": "openwork-agent",
3
+ "version": "1.0.0",
4
+ "description": "AI-powered backend code generator for any technology stack. Create complete backend projects with just a few commands!",
5
+ "main": "src/index.js",
6
+ "files": [
7
+ "bin/",
8
+ "src/",
9
+ "templates/",
10
+ "README.md",
11
+ "LICENSE"
12
+ ],
13
+ "scripts": {
14
+ "start": "node src/index.js",
15
+ "dev": "node src/index.js",
16
+ "test": "jest",
17
+ "lint": "eslint src/**/*.js",
18
+ "prepare": "echo 'Package ready for publishing'"
19
+ },
20
+ "keywords": [
21
+ "generator",
22
+ "backend",
23
+ "api",
24
+ "scaffold",
25
+ "cli",
26
+ "nodejs",
27
+ "python",
28
+ "java",
29
+ "go",
30
+ "rust",
31
+ "typescript",
32
+ "mern",
33
+ "mean",
34
+ "fullstack",
35
+ "starter",
36
+ "boilerplate",
37
+ "template",
38
+ "code-generator",
39
+ "automation",
40
+ "developer-tools"
41
+ ],
42
+ "author": {
43
+ "name": "Manoj Sharma",
44
+ "email": "manoj.sharma@example.com",
45
+ "url": "https://github.com/manoj1234-ms"
46
+ },
47
+ "repository": {
48
+ "type": "git",
49
+ "url": "git+https://github.com/manoj1234-ms/openwork-agent.git"
50
+ },
51
+ "bugs": {
52
+ "url": "https://github.com/manoj1234-ms/openwork-agent/issues"
53
+ },
54
+ "homepage": "https://github.com/manoj1234-ms/openwork-agent#readme",
55
+ "license": "MIT",
56
+ "dependencies": {
57
+ "chalk": "^4.1.2",
58
+ "commander": "^11.0.0",
59
+ "fs-extra": "^11.1.1",
60
+ "handlebars": "^4.7.8",
61
+ "inquirer": "^9.2.0",
62
+ "ora": "^5.4.1",
63
+ "semver": "^7.5.4",
64
+ "which": "^4.0.0",
65
+ "yaml": "^2.3.1"
66
+ },
67
+ "devDependencies": {
68
+ "@babel/core": "^7.28.6",
69
+ "@babel/preset-env": "^7.28.6",
70
+ "babel-jest": "^30.2.0",
71
+ "dotenv": "^17.2.3",
72
+ "eslint": "^8.42.0",
73
+ "jest": "^29.5.0"
74
+ },
75
+ "engines": {
76
+ "node": ">=14.0.0"
77
+ }
78
+ }