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
@@ -0,0 +1,358 @@
1
+ # {{pascalCase projectName}}
2
+
3
+ {{description}}
4
+
5
+ ## 🚀 Features
6
+
7
+ - ✅ RESTful API
8
+ - ✅ Database integration with {{database}}
9
+ - ✅ Input validation
10
+ - ✅ Error handling
11
+ - ✅ CORS support
12
+ - ✅ Logging
13
+ - ✅ Health check endpoint
14
+ {{#if includeDocker}}
15
+ - ✅ Docker support
16
+ {{/if}}
17
+ {{#if includeTests}}
18
+ - ✅ Unit tests
19
+ {{/if}}
20
+
21
+ ## 🛠️ Technology Stack
22
+
23
+ - **Framework**: {{#if framework}}{{framework}}{{else}}{{technology}}{{/if}}
24
+ - **Database**: {{#if database}}{{database}}{{else}}None{{/if}}
25
+ - **Language**: {{technology}}
26
+ - **Platform**: Cross-platform
27
+
28
+ ## 📋 Prerequisites
29
+
30
+ {{#if (eq technology "node")}}
31
+ - Node.js >= 14.0.0
32
+ - npm or yarn
33
+ {{/if}}
34
+ {{#if (eq technology "python")}}
35
+ - Python >= 3.8
36
+ - pip
37
+ {{/if}}
38
+ {{#if (eq technology "java")}}
39
+ - Java >= 8
40
+ - Maven >= 3.6
41
+ {{/if}}
42
+ {{#if (eq technology "go")}}
43
+ - Go >= 1.19
44
+ {{/if}}
45
+ {{#if (eq technology "rust")}}
46
+ - Rust >= 1.70
47
+ - Cargo
48
+ {{/if}}
49
+ {{#if (eq technology "php")}}
50
+ - PHP >= 7.4
51
+ - Composer
52
+ {{/if}}
53
+ {{#if database}}
54
+ - {{database}} database
55
+ {{/if}}
56
+
57
+ ## 🚀 Quick Start
58
+
59
+ ### 1. Clone the repository
60
+
61
+ \`\`\`bash
62
+ git clone <repository-url>
63
+ cd {{projectName}}
64
+ \`\`\`
65
+
66
+ ### 2. Install dependencies
67
+
68
+ {{#if (eq technology "node")}}
69
+ \`\`\`bash
70
+ npm install
71
+ # or
72
+ yarn install
73
+ \`\`\`
74
+ {{/if}}
75
+ {{#if (eq technology "python")}}
76
+ \`\`\`bash
77
+ python -m venv venv
78
+ source venv/bin/activate # On Windows: venv\\Scripts\\activate
79
+ pip install -r requirements.txt
80
+ \`\`\`
81
+ {{/if}}
82
+ {{#if (eq technology "java")}}
83
+ \`\`\`bash
84
+ mvn clean install
85
+ \`\`\`
86
+ {{/if}}
87
+ {{#if (eq technology "go")}}
88
+ \`\`\`bash
89
+ go mod download
90
+ \`\`\`
91
+ {{/if}}
92
+ {{#if (eq technology "rust")}}
93
+ \`\`\`bash
94
+ cargo build
95
+ \`\`\`
96
+ {{/if}}
97
+ {{#if (eq technology "php")}}
98
+ \`\`\`bash
99
+ composer install
100
+ \`\`\`
101
+ {{/if}}
102
+
103
+ ### 3. Environment setup
104
+
105
+ \`\`\`bash
106
+ cp .env.example .env
107
+ # Edit .env with your configuration
108
+ \`\`\`
109
+
110
+ ### 4. Run the application
111
+
112
+ {{#if (eq technology "node")}}
113
+ \`\`\`bash
114
+ # Development mode
115
+ npm run dev
116
+
117
+ # Production mode
118
+ npm start
119
+ \`\`\`
120
+ {{/if}}
121
+ {{#if (eq technology "python")}}
122
+ \`\`\`bash
123
+ uvicorn main:app --reload
124
+ # or
125
+ python main.py
126
+ \`\`\`
127
+ {{/if}}
128
+ {{#if (eq technology "java")}}
129
+ \`\`\`bash
130
+ mvn spring-boot:run
131
+ \`\`\`
132
+ {{/if}}
133
+ {{#if (eq technology "go")}}
134
+ \`\`\`bash
135
+ go run main.go
136
+ \`\`\`
137
+ {{/if}}
138
+ {{#if (eq technology "rust")}}
139
+ \`\`\`bash
140
+ cargo run
141
+ \`\`\`
142
+ {{/if}}
143
+ {{#if (eq technology "php")}}
144
+ \`\`\`bash
145
+ php artisan serve
146
+ \`\`\`
147
+ {{/if}}
148
+
149
+ ### 5. Health check
150
+
151
+ Visit \`\`\`http://localhost:3000/health\`\`\` to verify the API is running.
152
+
153
+ ## 📡 API Documentation
154
+
155
+ ### Base URL
156
+ \`\`\`
157
+ http://localhost:3000/api
158
+ \`\`\`
159
+
160
+ ### Endpoints
161
+
162
+ #### Users
163
+
164
+ | Method | Endpoint | Description |
165
+ |--------|----------|-------------|
166
+ | GET | `/users` | Get all users |
167
+ | GET | `/users/:id` | Get user by ID |
168
+ | POST | `/users` | Create new user |
169
+ | PUT | `/users/:id` | Update user |
170
+ | DELETE | `/users/:id` | Delete user |
171
+
172
+ #### Health Check
173
+
174
+ | Method | Endpoint | Description |
175
+ |--------|----------|-------------|
176
+ | GET | `/health` | Check API status |
177
+
178
+ ### Example Request
179
+
180
+ \`\`\`bash
181
+ # Create a new user
182
+ curl -X POST http://localhost:3000/api/users \\
183
+ -H "Content-Type: application/json" \\
184
+ -d '{
185
+ "name": "John Doe",
186
+ "email": "john@example.com",
187
+ "age": 30
188
+ }'
189
+ \`\`\`
190
+
191
+ ## 🧪 Testing
192
+
193
+ {{#if includeTests}}
194
+ \`\`\`bash
195
+ {{#if (eq technology "node")}}
196
+ npm test
197
+ {{/if}}
198
+ {{#if (eq technology "python")}}
199
+ pytest
200
+ {{/if}}
201
+ {{#if (eq technology "java")}}
202
+ mvn test
203
+ {{/if}}
204
+ {{#if (eq technology "go")}}
205
+ go test ./...
206
+ {{/if}}
207
+ {{#if (eq technology "rust")}}
208
+ cargo test
209
+ {{/if}}
210
+ {{#if (eq technology "php")}}
211
+ composer test
212
+ {{/if}}
213
+ \`\`\`
214
+ {{else}}
215
+ Tests are not included in this template. To add tests, create a test directory and set up your testing framework.
216
+ {{/if}}
217
+
218
+ ## 🐳 Docker
219
+
220
+ {{#if includeDocker}}
221
+ ### Using Docker Compose
222
+
223
+ \`\`\`bash
224
+ docker-compose up -d
225
+ \`\`\`
226
+
227
+ ### Building the Docker image
228
+
229
+ \`\`\`bash
230
+ docker build -t {{projectName}} .
231
+ docker run -p 3000:3000 {{projectName}}
232
+ \`\`\`
233
+ {{else}}
234
+ Docker support was not included. To add Docker, create a Dockerfile and docker-compose.yml.
235
+ {{/if}}
236
+
237
+ ## 📁 Project Structure
238
+
239
+ \`\`\`
240
+ {{projectName}}/
241
+ ├── src/ # Source code
242
+ │ ├── controllers/ # Route controllers
243
+ │ ├── models/ # Data models
244
+ │ ├── routes/ # API routes
245
+ │ ├── middleware/ # Express middleware
246
+ │ ├── services/ # Business logic
247
+ │ ├── utils/ # Utility functions
248
+ │ └── config/ # Configuration files
249
+ {{#if (eq technology "node")}}
250
+ ├── tests/ # Test files
251
+ ├── docs/ # Documentation
252
+ ├── package.json # Node.js dependencies
253
+ ├── tsconfig.json # TypeScript configuration
254
+ {{/if}}
255
+ {{#if (eq technology "python")}}
256
+ ├── tests/ # Test files
257
+ ├── requirements.txt # Python dependencies
258
+ ├── setup.py # Package setup
259
+ {{/if}}
260
+ {{#if (eq technology "java")}}
261
+ ├── src/main/java/ # Java source code
262
+ ├── src/test/java/ # Test files
263
+ ├── pom.xml # Maven configuration
264
+ {{/if}}
265
+ {{#if (eq technology "go")}}
266
+ ├── internal/ # Internal packages
267
+ ├── pkg/ # Public packages
268
+ ├── cmd/ # Main applications
269
+ ├── api/ # API definitions
270
+ ├── go.mod # Go modules
271
+ {{/if}}
272
+ {{#if (eq technology "rust")}}
273
+ ├── src/ # Source code
274
+ ├── tests/ # Integration tests
275
+ ├── Cargo.toml # Cargo configuration
276
+ {{/if}}
277
+ {{#if (eq technology "php")}}
278
+ ├── app/ # Application code
279
+ ├── database/migrations/ # Database migrations
280
+ ├── routes/ # API routes
281
+ ├── composer.json # PHP dependencies
282
+ {{/if}}
283
+ ├── .env.example # Environment template
284
+ ├── .gitignore # Git ignore file
285
+ ├── README.md # This file
286
+ {{#if includeDocker}}
287
+ ├── Dockerfile # Docker configuration
288
+ ├── docker-compose.yml # Docker Compose
289
+ {{/if}}
290
+ └── ... # Other files
291
+ \`\`\`
292
+
293
+ ## 🔧 Configuration
294
+
295
+ The application can be configured using environment variables. Copy \`.env.example\` to \`.env\` and modify the values as needed.
296
+
297
+ ### Environment Variables
298
+
299
+ | Variable | Description | Default |
300
+ |----------|-------------|---------|
301
+ | PORT | Server port | 3000 |
302
+ | DATABASE_URL | Database connection string | - |
303
+ | DB_NAME | Database name | {{projectName}} |
304
+ | JWT_SECRET | JWT secret key | - |
305
+ | CORS_ORIGINS | Allowed CORS origins | * |
306
+
307
+ ## 🚀 Deployment
308
+
309
+ ### Heroku
310
+
311
+ \`\`\`bash
312
+ heroku create your-app-name
313
+ git push heroku main
314
+ \`\`\`
315
+
316
+ ### Vercel
317
+
318
+ \`\`\`bash
319
+ npm i -g vercel
320
+ vercel --prod
321
+ \`\`\`
322
+
323
+ ### Railway
324
+
325
+ \`\`\`bash
326
+ railway login
327
+ railway init
328
+ railway up
329
+ \`\`\`
330
+
331
+ ## 🤝 Contributing
332
+
333
+ 1. Fork the repository
334
+ 2. Create a feature branch (\`git checkout -b feature/amazing-feature\`)
335
+ 3. Commit your changes (\`git commit -m 'Add some amazing feature'\`)
336
+ 4. Push to the branch (\`git push origin feature/amazing-feature\`)
337
+ 5. Open a Pull Request
338
+
339
+ ## 📝 License
340
+
341
+ This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.
342
+
343
+ ## 🙏 Acknowledgments
344
+
345
+ - Built with ❤️ using [OpenWork Agent](https://github.com/your-repo/openwork-agent)
346
+ - Thanks to all the amazing open-source libraries that made this possible
347
+
348
+ ## 📞 Support
349
+
350
+ If you have any questions or need help, please:
351
+
352
+ 1. Check the documentation
353
+ 2. Search existing issues
354
+ 3. Create a new issue with detailed information
355
+
356
+ ---
357
+
358
+ **Built with ❤️ by OpenWork Agent**