codeninja 2.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 (140) hide show
  1. package/.gitattributes +11 -0
  2. package/README.md +293 -0
  3. package/agent/database-agent.md +504 -0
  4. package/agent/designs/README.md +10 -0
  5. package/agent/global-agent.md +236 -0
  6. package/agent/nodejs-agent.md +406 -0
  7. package/agent/reactjs-agent.md +260 -0
  8. package/cli.js +352 -0
  9. package/commands/audit.workflow.md +111 -0
  10. package/commands/create-api.workflow.md +99 -0
  11. package/commands/db-add-index.workflow.md +97 -0
  12. package/commands/db-create-table.workflow.md +132 -0
  13. package/commands/db-drop-table.workflow.md +103 -0
  14. package/commands/db-modify-table.workflow.md +159 -0
  15. package/commands/db-seed.workflow.md +99 -0
  16. package/commands/db-sync.workflow.md +100 -0
  17. package/commands/design.workflow.md +66 -0
  18. package/commands/initialize-project.workflow.md +500 -0
  19. package/commands/integrate-api.workflow.md +448 -0
  20. package/commands/modularize.workflow.md +329 -0
  21. package/commands/refactor.workflow.md +70 -0
  22. package/commands/sync.workflow.md +962 -0
  23. package/commands/test.workflow.md +40 -0
  24. package/commands/validate-page.workflow.md +543 -0
  25. package/mcp-server.js +842 -0
  26. package/package.json +24 -0
  27. package/tasks/README.md +283 -0
  28. package/tasks/add-health-route.task.md +103 -0
  29. package/tasks/ask-api-integration-scope.task.md +34 -0
  30. package/tasks/ask-api-key.task.md +23 -0
  31. package/tasks/ask-api-version.task.md +28 -0
  32. package/tasks/ask-client-type.task.md +24 -0
  33. package/tasks/ask-column-enum-values.task.md +51 -0
  34. package/tasks/ask-column-is-enum.task.md +39 -0
  35. package/tasks/ask-column-name.task.md +39 -0
  36. package/tasks/ask-column-position.task.md +39 -0
  37. package/tasks/ask-column-type.task.md +59 -0
  38. package/tasks/ask-database-config.task.md +66 -0
  39. package/tasks/ask-database-host.task.md +16 -0
  40. package/tasks/ask-database-name.task.md +18 -0
  41. package/tasks/ask-database-port.task.md +23 -0
  42. package/tasks/ask-database-type.task.md +30 -0
  43. package/tasks/ask-database-user.task.md +14 -0
  44. package/tasks/ask-design-description.task.md +16 -0
  45. package/tasks/ask-design-target.task.md +24 -0
  46. package/tasks/ask-encrypted-transport.task.md +25 -0
  47. package/tasks/ask-encryption-iv.task.md +23 -0
  48. package/tasks/ask-encryption-key.task.md +23 -0
  49. package/tasks/ask-feature-name.task.md +20 -0
  50. package/tasks/ask-http-method.task.md +21 -0
  51. package/tasks/ask-index-columns.task.md +46 -0
  52. package/tasks/ask-index-file-placement.task.md +33 -0
  53. package/tasks/ask-index-sort-order.task.md +37 -0
  54. package/tasks/ask-index-type.task.md +42 -0
  55. package/tasks/ask-init-mode.task.md +28 -0
  56. package/tasks/ask-linked-service.task.md +57 -0
  57. package/tasks/ask-modify-operation.task.md +36 -0
  58. package/tasks/ask-modularize-scope.task.md +31 -0
  59. package/tasks/ask-module-name.task.md +30 -0
  60. package/tasks/ask-new-column-name.task.md +21 -0
  61. package/tasks/ask-new-table-name.task.md +22 -0
  62. package/tasks/ask-old-column-name.task.md +22 -0
  63. package/tasks/ask-package-author.task.md +16 -0
  64. package/tasks/ask-package-name.task.md +23 -0
  65. package/tasks/ask-page-path.task.md +40 -0
  66. package/tasks/ask-primary-table.task.md +30 -0
  67. package/tasks/ask-project-figma.task.md +71 -0
  68. package/tasks/ask-project-info-doc.task.md +57 -0
  69. package/tasks/ask-project-scope-of-work.task.md +57 -0
  70. package/tasks/ask-project-type.task.md +24 -0
  71. package/tasks/ask-react-target-service.task.md +32 -0
  72. package/tasks/ask-redis-config.task.md +42 -0
  73. package/tasks/ask-redis-host.task.md +16 -0
  74. package/tasks/ask-redis-port.task.md +18 -0
  75. package/tasks/ask-refactor-type.task.md +26 -0
  76. package/tasks/ask-requires-auth.task.md +22 -0
  77. package/tasks/ask-response-mode.task.md +38 -0
  78. package/tasks/ask-route-description.task.md +20 -0
  79. package/tasks/ask-route-path.task.md +29 -0
  80. package/tasks/ask-seed-row-values.task.md +42 -0
  81. package/tasks/ask-seed-rows-count.task.md +22 -0
  82. package/tasks/ask-service-description.task.md +16 -0
  83. package/tasks/ask-service-name.task.md +27 -0
  84. package/tasks/ask-service-port.task.md +24 -0
  85. package/tasks/ask-supported-languages.task.md +40 -0
  86. package/tasks/ask-table-file-number.task.md +36 -0
  87. package/tasks/ask-table-indexes.task.md +47 -0
  88. package/tasks/ask-table-name.task.md +32 -0
  89. package/tasks/ask-table-needs-soft-delete.task.md +29 -0
  90. package/tasks/ask-table-needs-status.task.md +30 -0
  91. package/tasks/ask-table-purpose.task.md +28 -0
  92. package/tasks/ask-table-seed-data.task.md +44 -0
  93. package/tasks/ask-target-service.task.md +32 -0
  94. package/tasks/ask-test-type.task.md +20 -0
  95. package/tasks/ask-validation-library.task.md +38 -0
  96. package/tasks/detect-repository-state.task.md +92 -0
  97. package/tasks/generate-app.task.md +146 -0
  98. package/tasks/generate-common.task.md +330 -0
  99. package/tasks/generate-constants.task.md +123 -0
  100. package/tasks/generate-database.task.md +168 -0
  101. package/tasks/generate-docker-compose.task.md +298 -0
  102. package/tasks/generate-dockerfile.task.md +126 -0
  103. package/tasks/generate-dockerignore.task.md +123 -0
  104. package/tasks/generate-enc-dec-html.task.md +127 -0
  105. package/tasks/generate-enc-dec-php.task.md +145 -0
  106. package/tasks/generate-encryption.task.md +159 -0
  107. package/tasks/generate-fast-defaults.task.md +68 -0
  108. package/tasks/generate-gitignore.task.md +79 -0
  109. package/tasks/generate-headerValidator.task.md +377 -0
  110. package/tasks/generate-ide-configs.task.md +114 -0
  111. package/tasks/generate-ioRedis.task.md +120 -0
  112. package/tasks/generate-language-en.task.md +155 -0
  113. package/tasks/generate-logging.task.md +257 -0
  114. package/tasks/generate-model.task.md +180 -0
  115. package/tasks/generate-notification.task.md +251 -0
  116. package/tasks/generate-package-json.task.md +114 -0
  117. package/tasks/generate-rateLimiter.task.md +125 -0
  118. package/tasks/generate-react-api-client.task.md +169 -0
  119. package/tasks/generate-react-api-handler.task.md +102 -0
  120. package/tasks/generate-react-app-jsx.task.md +56 -0
  121. package/tasks/generate-react-dockerfile.task.md +175 -0
  122. package/tasks/generate-react-env.task.md +58 -0
  123. package/tasks/generate-react-gitignore.task.md +49 -0
  124. package/tasks/generate-react-htaccess.task.md +54 -0
  125. package/tasks/generate-react-index-html.task.md +53 -0
  126. package/tasks/generate-react-index-jsx.task.md +51 -0
  127. package/tasks/generate-react-package-json.task.md +77 -0
  128. package/tasks/generate-react-welcome-page.task.md +71 -0
  129. package/tasks/generate-readme.task.md +160 -0
  130. package/tasks/generate-response.task.md +202 -0
  131. package/tasks/generate-route-manager.task.md +173 -0
  132. package/tasks/generate-route.task.md +203 -0
  133. package/tasks/generate-swagger.task.md +290 -0
  134. package/tasks/generate-tbl-user-deviceinfo.task.md +75 -0
  135. package/tasks/generate-template.task.md +129 -0
  136. package/tasks/generate-validator.task.md +122 -0
  137. package/tasks/show-db-table-summary.task.md +66 -0
  138. package/tasks/show-final-summary.task.md +108 -0
  139. package/tasks/show-init-summary.task.md +257 -0
  140. package/tasks/write-context.task.md +314 -0
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "codeninja",
3
+ "version": "2.0.0",
4
+ "description": "AI agent scaffolding system — NodeJS, ReactJS, and database projects",
5
+ "private": false,
6
+ "bin": {
7
+ "codeninja": "cli.js"
8
+ },
9
+ "files": [
10
+ ".gitattributes",
11
+ "cli.js",
12
+ "mcp-server.js",
13
+ "agent/",
14
+ "commands/",
15
+ "tasks/",
16
+ "README.md"
17
+ ],
18
+ "dependencies": {
19
+ "@modelcontextprotocol/sdk": "^1.0.0"
20
+ },
21
+ "engines": {
22
+ "node": ">=18.0.0"
23
+ }
24
+ }
@@ -0,0 +1,283 @@
1
+ # Code Ninja Agent System
2
+
3
+ AI-powered agentic scaffolding and development assistant for your project.
4
+
5
+ ---
6
+
7
+ ## Folder Structure
8
+
9
+ ```
10
+ .codeninja/agent/
11
+ global-agent.md ← Master orchestrator
12
+ nodejs-agent.md ← NodeJS backend expert
13
+ reactjs-agent.md ← ReactJS frontend expert
14
+ database-agent.md ← Database architect (PostgreSQL / MySQL / MongoDB)
15
+ designs/ ← @design output files (auto-created)
16
+
17
+ .codeninja/commands/
18
+ initialize-project.workflow.md
19
+ create-api.workflow.md
20
+ design.workflow.md
21
+ audit.workflow.md
22
+ test.workflow.md
23
+ refactor.workflow.md
24
+ sync.workflow.md
25
+ db-create-table.workflow.md
26
+ db-modify-table.workflow.md
27
+ db-add-index.workflow.md
28
+ db-drop-table.workflow.md
29
+ db-seed.workflow.md
30
+ db-sync.workflow.md
31
+
32
+ .codeninja/tasks/
33
+ ── Project Info ──────────────────────────────
34
+ ask-project-info-doc.task.md
35
+ ask-project-scope-of-work.task.md
36
+ ask-project-figma.task.md
37
+
38
+ ── Repository & Init ─────────────────────────
39
+ detect-repository-state.task.md
40
+ ask-project-type.task.md
41
+ ask-service-name.task.md
42
+ ask-service-port.task.md
43
+ ask-service-description.task.md
44
+ ask-package-name.task.md
45
+ ask-package-author.task.md
46
+ ask-api-key.task.md
47
+ ask-encryption-key.task.md
48
+ ask-encryption-iv.task.md
49
+ ask-redis-host.task.md
50
+ ask-redis-port.task.md
51
+ ask-redis-config.task.md
52
+ show-init-summary.task.md
53
+ ask-client-type.task.md
54
+ ask-encrypted-transport.task.md
55
+ ask-supported-languages.task.md
56
+ ask-init-mode.task.md
57
+ generate-fast-defaults.task.md
58
+
59
+ ── Database Config ───────────────────────────
60
+ ask-database-type.task.md
61
+ ask-database-name.task.md
62
+ ask-database-host.task.md
63
+ ask-database-port.task.md
64
+ ask-database-user.task.md
65
+ ask-database-config.task.md
66
+
67
+ ── Database Table Operations ─────────────────
68
+ ask-table-purpose.task.md
69
+ ask-table-name.task.md
70
+ ask-table-file-number.task.md
71
+ ask-table-needs-status.task.md
72
+ ask-table-needs-soft-delete.task.md
73
+ ask-table-indexes.task.md
74
+ ask-table-seed-data.task.md
75
+ show-db-table-summary.task.md
76
+
77
+ ── Column Operations ─────────────────────────
78
+ ask-column-name.task.md
79
+ ask-column-type.task.md
80
+ ask-column-is-enum.task.md
81
+ ask-column-enum-values.task.md
82
+ ask-column-position.task.md
83
+ ask-old-column-name.task.md
84
+ ask-new-column-name.task.md
85
+ ask-modify-operation.task.md
86
+
87
+ ── Index Operations ──────────────────────────
88
+ ask-index-columns.task.md
89
+ ask-index-sort-order.task.md
90
+ ask-index-type.task.md
91
+ ask-index-file-placement.task.md
92
+
93
+ ── Seed Data ─────────────────────────────────
94
+ ask-seed-rows-count.task.md
95
+ ask-seed-row-values.task.md
96
+
97
+ ── API & Module Operations ───────────────────
98
+ ask-target-service.task.md
99
+ ask-module-name.task.md
100
+ ask-http-method.task.md
101
+ ask-route-path.task.md
102
+ ask-route-description.task.md
103
+ ask-primary-table.task.md
104
+ ask-requires-auth.task.md
105
+ ask-api-version.task.md
106
+
107
+ ── Design & Refactor ─────────────────────────
108
+ ask-design-target.task.md
109
+ ask-feature-name.task.md
110
+ ask-design-description.task.md
111
+ ask-refactor-type.task.md
112
+ ask-table-name.task.md
113
+ ask-new-table-name.task.md
114
+
115
+ ── Test ──────────────────────────────────────
116
+ ask-test-type.task.md
117
+
118
+ ── Output & Context ──────────────────────────
119
+ write-context.task.md
120
+ show-final-summary.task.md
121
+
122
+ ── Utilities Generation ──────────────────────────────
123
+ generate-encryption.task.md
124
+ generate-response.task.md
125
+ generate-validator.task.md
126
+ generate-headerValidator.task.md
127
+ generate-logging.task.md
128
+ generate-app.task.md
129
+ generate-rateLimiter.task.md
130
+ generate-route-manager.task.md
131
+ generate-constants.task.md
132
+ generate-database.task.md
133
+ generate-template.task.md
134
+ generate-language-en.task.md
135
+ generate-ioRedis.task.md
136
+ generate-notification.task.md
137
+ generate-common.task.md
138
+ generate-route.task.md
139
+ generate-model.task.md
140
+ generate-enc-dec-html.task.md
141
+ generate-enc-dec-php.task.md
142
+ generate-package-json.task.md
143
+ generate-readme.task.md
144
+ generate-gitignore.task.md
145
+ generate-swagger.task.md
146
+
147
+ ── System Tables ─────────────────────────
148
+ generate-tbl-user-deviceinfo.task.md
149
+
150
+ .codeninja/context/
151
+ context.json ← Shared memory for all agents (auto-managed)
152
+ ```
153
+
154
+ ---
155
+
156
+ ## Available Commands
157
+
158
+ ### Project Initialization
159
+ | Command | Description |
160
+ |---|---|
161
+ | `@initialize-project` | Bootstrap a new NodeJS service, ReactJS app, or database |
162
+
163
+ ### API & Service Development
164
+ | Command | Description |
165
+ |---|---|
166
+ | `@create-api` | Add a new API module to an existing service |
167
+ | `@design` | Plan a feature or schema before writing code |
168
+ | `@audit` | Review a service for security, quality, and consistency |
169
+ | `@test` | Generate or run tests for a module |
170
+ | `@refactor` | Rename or restructure code with full change tracking |
171
+ | `@sync` | Scan the entire repo and rebuild context.json |
172
+
173
+ ### Database Commands
174
+ | Command | Description |
175
+ |---|---|
176
+ | `@db:create-table` | Design and generate a new table following all conventions |
177
+ | `@db:modify-table` | Add/rename/drop a column via ALTER migration file |
178
+ | `@db:add-index` | Add a new index to an existing table |
179
+ | `@db:drop-table` | Generate a DROP migration and clean up context |
180
+ | `@db:seed` | Add or update seed data for a table |
181
+ | `@db:sync` | Scan migration files and rebuild context.db.schema |
182
+
183
+ ---
184
+
185
+ ## How It Works
186
+
187
+ 1. **You run a command** — e.g. `@initialize-project`
188
+ 2. **Global agent activates** — reads `.codeninja/context/context.json` for full awareness
189
+ 3. **Project info is collected first (once)** — document, SOW, Figma link → builds project summary
190
+ 4. **Workflow runs** — routes to the right agent (NodeJS, ReactJS, Database)
191
+ 5. **Tasks execute one at a time** — each asks exactly one question
192
+ 6. **Single confirmation** — you approve the summary once, then all files are generated
193
+ 7. **Context is updated** — every action recorded in `context.json`
194
+
195
+ ---
196
+
197
+ ## Key Design Principles
198
+
199
+ ### One Question Per Task
200
+ Every `ask-*` task collects exactly one value. No multi-field forms.
201
+
202
+ ### Single Confirmation Per Operation
203
+ After collecting all required values, a summary is shown once.
204
+ You confirm once → everything generates. No per-file prompts.
205
+
206
+ ### Context is the Brain
207
+ `.codeninja/context/context.json` is the shared memory for all agents.
208
+ - Every service, route, table, column, and change is stored here
209
+ - All agents read it before making any decision
210
+ - The `change_log` gives a full history of every structural change
211
+
212
+ ### Database First
213
+ During `@initialize-project`, the database folder is always scaffolded
214
+ before any application service code. This ensures NodeJS services are
215
+ generated with accurate DB config and column awareness.
216
+
217
+ ### Project Info Awareness
218
+ When you provide a project document, SOW, or Figma link during initialization,
219
+ the agent extracts entities, features, and tech preferences. Every subsequent
220
+ command uses this context to make smarter suggestions.
221
+
222
+ ---
223
+
224
+ ## Database File Convention
225
+
226
+ Every table follows this structure:
227
+ ```
228
+ database/
229
+ <db_type>/
230
+ migrations/
231
+ 1-setup-tbl-<name>.sql ← One file per table, numbered
232
+ 2-setup-tbl-<name>.sql
233
+ ...
234
+ 111-setup-database-indexes.sql ← Shared indexes, always last
235
+ seeds/
236
+ <table>_seed.sql ← Standalone seed files
237
+ create-schema.sql ← Auto-generated runner (do not edit)
238
+ setup-database.sh ← Linux/Mac setup script
239
+ setup-database.ps1 ← Windows setup script
240
+ reset-database.sh ← Dev-only full reset (dangerous)
241
+ README.md
242
+ ```
243
+
244
+ ### Running the Database
245
+ ```bash
246
+ # Linux/Mac — creates DB and runs all migrations
247
+ cd database/<db_type>
248
+ bash setup-database.sh
249
+
250
+ # Windows
251
+ cd database/<db_type>
252
+ .\setup-database.ps1
253
+ ```
254
+
255
+ ---
256
+
257
+ ## Multi-Service Projects
258
+
259
+ Each service gets its own entry in `context.services`:
260
+ ```json
261
+ {
262
+ "services": {
263
+ "auth": { "type": "nodejs", "port": 1001 },
264
+ "ledger": { "type": "nodejs", "port": 1002 },
265
+ "frontend":{ "type": "reactjs", "port": 3000 }
266
+ }
267
+ }
268
+ ```
269
+
270
+ All services share the same `context.db` — they reference the same database
271
+ schema and the same table/column names.
272
+
273
+ ---
274
+
275
+ ## Getting Started
276
+
277
+ 1. Run `@initialize-project`
278
+ 2. Answer Phase 0 questions (project doc, SOW, Figma) — once per repo
279
+ 3. Choose project type (NodeJS, ReactJS, Database)
280
+ 4. Configure database
281
+ 5. Name your service and configure it
282
+ 6. Confirm once → everything is generated
283
+ 7. Run `@db:create-table` to start adding your first table
@@ -0,0 +1,103 @@
1
+ ---
2
+ type: task
3
+ name: add-health-route
4
+ agent: nodejs-agent
5
+ ---
6
+
7
+ # Add Health Check Route
8
+
9
+ ## Purpose
10
+ Adds a `/health` endpoint to the default service module for Docker health checks
11
+ and monitoring systems. This should be added during the route generation in Wave 4.
12
+
13
+ ---
14
+
15
+ ## Implementation
16
+
17
+ When generating the default module's `route.js` file in `modules/v1/<ServiceName>/route.js`,
18
+ add this health check route:
19
+
20
+ ```javascript
21
+ /**
22
+ * Health check endpoint for container orchestration and monitoring.
23
+ *
24
+ * @param {Object} req - Express request object.
25
+ * @param {Object} res - Express response object.
26
+ */
27
+ router.get('/health', (req, res) => {
28
+ res.status(200).json({
29
+ status: 'healthy',
30
+ timestamp: new Date().toISOString(),
31
+ service: process.env.npm_package_name || 'unknown',
32
+ uptime: process.uptime()
33
+ });
34
+ });
35
+ ```
36
+
37
+ ---
38
+
39
+ ## Location in File
40
+
41
+ Place this route FIRST in the route.js file, before any other routes.
42
+ This ensures health checks work even if other routes have issues.
43
+
44
+ ---
45
+
46
+ ## Response Format
47
+
48
+ ```json
49
+ {
50
+ "status": "healthy",
51
+ "timestamp": "2024-03-20T10:30:45.123Z",
52
+ "service": "auth",
53
+ "uptime": 12345.678
54
+ }
55
+ ```
56
+
57
+ ---
58
+
59
+ ## Security Note
60
+
61
+ - This endpoint is PUBLIC (no authentication required)
62
+ - Does not expose sensitive information
63
+ - Returns only service health status and basic metadata
64
+ - Safe to be called by Docker, Kubernetes, load balancers, etc.
65
+
66
+ ---
67
+
68
+ ## Integration with Dockerfile
69
+
70
+ The Dockerfile health check uses this endpoint:
71
+ ```dockerfile
72
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=40s --retries=3 \
73
+ CMD node -e "require('http').get('http://localhost:{port}/api/v1/{module}/health', (r) => process.exit(r.statusCode === 200 ? 0 : 1))"
74
+ ```
75
+
76
+ Where:
77
+ - `{port}` is the service port
78
+ - `{module}` is the lowercase module name (e.g., "auth")
79
+
80
+ ---
81
+
82
+ ## Context Registration
83
+
84
+ Add this route to context during initialization:
85
+
86
+ ```javascript
87
+ context.api_routes.push({
88
+ service: context.current_init.service_name,
89
+ method: 'GET',
90
+ path: `/api/v1/${moduleName.toLowerCase()}/health`,
91
+ auth: 'none',
92
+ description: 'Health check endpoint'
93
+ });
94
+ ```
95
+
96
+ ---
97
+
98
+ ## Notes
99
+
100
+ - Always returns 200 status when service is running
101
+ - Can be extended later to check database connectivity, Redis, etc.
102
+ - Used by Docker, Kubernetes, AWS ECS, load balancers
103
+ - Should be the first route registered (top of the file)
@@ -0,0 +1,34 @@
1
+ ---
2
+ type: task
3
+ name: ask-api-integration-scope
4
+ ---
5
+
6
+ Read `context.current_action.page_path` — the target page already set.
7
+
8
+ Ask the user exactly this question:
9
+
10
+ "What would you like to integrate on this page?"
11
+
12
+ Present options:
13
+ 1. All forms and actions — wire up every form submit and every
14
+ button action on the page to an API call
15
+ 2. A specific form or action — I'll describe which one
16
+
17
+ Wait for user selection.
18
+
19
+ Store result in: `context.current_action.api_integration_scope`
20
+ - Option 1 → "all"
21
+ - Option 2 → "specific"
22
+
23
+ If option 2 (specific):
24
+ Ask the user exactly this question:
25
+
26
+ "Describe the form or action you want to integrate.
27
+ Example: 'the login form', 'the delete button in the user card',
28
+ 'the search filter submit'"
29
+
30
+ Wait for user input.
31
+ Store result in: `context.current_action.api_integration_target`
32
+
33
+ Do not ask any other question in this task beyond the scope and
34
+ optional description questions above.
@@ -0,0 +1,23 @@
1
+ ---
2
+ type: task
3
+ name: ask-api-key
4
+ ---
5
+
6
+ Generate a secure suggested value: random 32-character alphanumeric string.
7
+
8
+ Ask the user exactly this question:
9
+
10
+ "Enter the API key for this service (used in x-api-key header)."
11
+
12
+ Show: "Suggested (auto-generated): [generated_value]"
13
+ Show: "Press enter to use the suggested value, or type your own."
14
+
15
+ If user presses enter without input → use the generated value.
16
+
17
+ Validate:
18
+ - Minimum 16 characters
19
+ - No spaces
20
+
21
+ Store result in: `context.current_init.api_key`
22
+
23
+ Do not ask any other question in this task.
@@ -0,0 +1,28 @@
1
+ ---
2
+ type: task
3
+ name: ask-api-version
4
+ ---
5
+
6
+ Read service name from context — check in this order:
7
+ 1. `context.current_api.service_name`
8
+ 2. `context.current_action.service_name`
9
+ Use whichever is populated.
10
+ Read `context.services[<resolved_service_name>].versions` if available.
11
+
12
+ If only v1 exists (most common case):
13
+ Inform user: "Using API version: v1"
14
+ Store automatically: `context.current_api.version = "v1"`
15
+ Return without asking.
16
+
17
+ If multiple versions exist OR user is adding a new version:
18
+ Ask the user exactly this question:
19
+
20
+ "Which API version will this endpoint belong to?"
21
+
22
+ List existing versions and add option for new version.
23
+
24
+ Wait for user selection.
25
+
26
+ Store result in: `context.current_api.version`
27
+
28
+ Do not ask any other question in this task.
@@ -0,0 +1,24 @@
1
+ ---
2
+ type: task
3
+ name: ask-client-type
4
+ ---
5
+
6
+ Ask the user exactly this question:
7
+
8
+ "Who will be consuming this API?"
9
+
10
+ Present options:
11
+ 1. ReactJS web frontend — uses crypto-js for encryption
12
+ 2. Mobile / desktop app — uses cryptlib for encryption
13
+
14
+ Wait for user selection.
15
+
16
+ Store result in: `context.current_init.client_type`
17
+ - Option 1 → "reactjs"
18
+ - Option 2 → "app"
19
+
20
+ This value determines:
21
+ - Which encryption library is used in utilities/encryption.js
22
+ - Whether enc_dec.html or enc_dec.php is generated
23
+
24
+ Do not ask any other question in this task.
@@ -0,0 +1,51 @@
1
+ ---
2
+ type: task
3
+ name: ask-column-enum-values
4
+ ---
5
+
6
+ Read the last column in `context.current_db.columns`.
7
+ Let col = that column.
8
+
9
+ Ask the user exactly this question:
10
+
11
+ "Enter the allowed values for '[col_name]', separated by commas."
12
+
13
+ Example input: I, S, L
14
+ Example input: Pending, Running, Completed
15
+ Example input: 0, 1
16
+
17
+ Wait for user input.
18
+
19
+ Parse the input into a list of values.
20
+ Trim whitespace from each value.
21
+
22
+ Ask the user exactly this question:
23
+
24
+ "Now provide a short label for each value (for the COMMENT)."
25
+
26
+ Show each value and ask for its label:
27
+ "What does '[value]' mean?"
28
+
29
+ Example:
30
+ 'I' → Intraday
31
+ 'S' → Short Term
32
+ 'L' → Long Term
33
+
34
+ Collect one label per value (one at a time).
35
+
36
+ Build the COMMENT string:
37
+ Format: '[value1] = [label1], [value2] = [label2], ...'
38
+ Example: 'I = Intraday, S = Short Term, L = Long Term'
39
+
40
+ Store results in `context.current_db.columns[last]`:
41
+ - `check_values`: ["I", "S", "L"]
42
+ - `check_comment`: "I = Intraday, S = Short Term, L = Long Term"
43
+ - `default_value`: first value in the list (user can override)
44
+
45
+ Also ask:
46
+ "What should the DEFAULT value be for this column?"
47
+ Show options: [list of allowed values]
48
+
49
+ Store: `context.current_db.columns[last].default_value`
50
+
51
+ Do not ask any other question in this task after collecting all labels and default.
@@ -0,0 +1,39 @@
1
+ ---
2
+ type: task
3
+ name: ask-column-is-enum
4
+ ---
5
+
6
+ Read the last column in `context.current_db.columns`.
7
+ Let col = that column.
8
+
9
+ Skip this task automatically if:
10
+ - Column type is BOOLEAN
11
+ - Column type is TIMESTAMPTZ
12
+ - Column type is JSON
13
+ - Column name ends in `_id`
14
+ - Column name ends in `_at`
15
+
16
+ Otherwise:
17
+
18
+ Ask the user exactly this question:
19
+
20
+ "Does column '[col_name]' have a fixed set of allowed values?"
21
+
22
+ Example: trade_type can only be 'I', 'S', or 'L'
23
+ Example: status can only be 0 or 1
24
+
25
+ Present options:
26
+ 1. Yes — add a CHECK constraint with allowed values
27
+ 2. No — any valid value is allowed
28
+
29
+ Wait for user selection.
30
+
31
+ If No:
32
+ Store: `context.current_db.columns[last].is_enum = false`
33
+ Return.
34
+
35
+ If Yes:
36
+ Store: `context.current_db.columns[last].is_enum = true`
37
+ → Immediately run task: `ask-column-enum-values`
38
+
39
+ Do not ask any other question in this task.
@@ -0,0 +1,39 @@
1
+ ---
2
+ type: task
3
+ name: ask-column-name
4
+ ---
5
+
6
+ Read `context.current_db.columns` to show columns collected so far.
7
+
8
+ If columns already exist, display them:
9
+ "Columns defined so far:
10
+ [n]. [col_name] — [type]
11
+ ..."
12
+
13
+ Agent suggests next column based on `context.current_db.table_purpose`
14
+ and common patterns. For example:
15
+ - User tables → suggest: first_name, last_name, email, phone, password, profile_image
16
+ - Bot tables → suggest: user_id, bot_name, symbol, strategy, status
17
+ - Notification tables → suggest: user_id, content, is_read
18
+
19
+ Show suggestion if available:
20
+ "Suggested next column: [suggestion] (press enter to use, or type your own)"
21
+
22
+ Ask the user exactly this question:
23
+
24
+ "Enter the next column name (or type 'done' to finish adding columns)."
25
+
26
+ Wait for user input.
27
+
28
+ Validate:
29
+ - Must be lowercase snake_case
30
+ - No spaces or camelCase
31
+ - Must not already exist in `context.current_db.columns`
32
+ - If 'done' → end column collection loop
33
+
34
+ If input is camelCase (e.g. 'userId') → auto-convert to snake_case ('user_id')
35
+ and inform the user: "Converted to snake_case: user_id"
36
+
37
+ Store result in: new entry appended to `context.current_db.columns[]`
38
+
39
+ Do not ask any other question in this task.
@@ -0,0 +1,39 @@
1
+ ---
2
+ type: task
3
+ name: ask-column-position
4
+ ---
5
+
6
+ Read `context.current_db.table_name` and `context.db.schema.tables[<table>].columns`
7
+ to list the current columns in order.
8
+
9
+ Display current column order:
10
+ "Current columns in '[table_name]':
11
+ 1. id
12
+ 2. user_id
13
+ 3. email
14
+ 4. created_at
15
+ ..."
16
+
17
+ Read `context.db.type`.
18
+
19
+ If db_type == "mysql":
20
+ Show: "MySQL supports AFTER <col> — the column will be physically placed
21
+ after '[selected_column]' in the table."
22
+
23
+ If db_type == "postgresql":
24
+ Show: "Note: In PostgreSQL, ADD COLUMN always appends to the end physically.
25
+ The position here is for documentation only."
26
+
27
+ If db_type == "mongodb":
28
+ Skip this task entirely — MongoDB documents have no fixed column order.
29
+ Store: `context.current_db.new_column_after = null`
30
+ Return.
31
+
32
+ Present: numbered list of current columns
33
+ Add option: "End of table (default)"
34
+
35
+ Wait for user selection.
36
+
37
+ Store result in: `context.current_db.new_column_after`
38
+
39
+ Do not ask any other question in this task.