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
@@ -0,0 +1,500 @@
1
+ ---
2
+ type: workflow
3
+ name: initialize-project
4
+ description: >
5
+ Interactive bootstrap workflow for a new service. Collects project
6
+ information first, then service details one value at a time, then scaffolds
7
+ database folder and service baseline. Single confirmation before generation —
8
+ no per-file prompts after that.
9
+ ---
10
+
11
+ # Workflow: @initialize-project
12
+
13
+ ## Goal
14
+ Scaffold a new service (NodeJS API, ReactJS frontend, or Database-only) with
15
+ full context recorded in `.codeninja/context/context.json`.
16
+
17
+ ## Rules
18
+ - Phase 0 runs ONCE per repository — skip entirely if `context.project_info` already populated.
19
+ - Confirm the full summary ONCE before creating any file.
20
+ - After confirmation → generate ALL files using wave structure, no further per-file prompts.
21
+ - Always scaffold database folder at REPOSITORY ROOT before any service
22
+ code. The database/ folder is always at the same level as service
23
+ folders, never inside one.
24
+ - After completion → run task: `write-context` then task: `show-final-summary`
25
+
26
+ ## Init Mode Rules
27
+ - Fast mode: ask only essential questions. Auto-generate all technical
28
+ config silently. Show everything in summary for review.
29
+ - Manual mode: ask every value individually, one at a time.
30
+ - In BOTH modes: the summary shows ALL values and ALL are editable
31
+ before confirmation. Fast mode is not a shortcut around review —
32
+ it is a shortcut around data entry.
33
+ - Auto-generated security values (api_key, encryption_key) are
34
+ cryptographically random and production-safe.
35
+ encryption_iv is always the first 16 characters of encryption_key —
36
+ never randomly generated independently.
37
+ The user does not need to provide them unless they have specific
38
+ requirements.
39
+
40
+ ---
41
+
42
+ ## Step-by-Step Execution
43
+
44
+ ---
45
+
46
+ ### Phase 0 — Project Information (runs ONCE per repo)
47
+
48
+ Check `context.project_info` — if already populated, skip Phase 0 entirely.
49
+
50
+ 0a. Run task: `ask-project-info-doc`
51
+ Stores: `context.project_info.has_doc`, `.doc_url` or `.doc_content`, `.from_doc`
52
+
53
+ 0b. Run task: `ask-project-scope-of-work`
54
+ Stores: `context.project_info.has_sow`, `.sow_url` or `.sow_content`, `.from_sow`
55
+
56
+ 0c. Run task: `ask-project-figma`
57
+ Stores: `context.project_info.has_figma`, `.figma_url`, `.from_figma`
58
+
59
+ After all three tasks:
60
+ Agent synthesizes all collected information and builds:
61
+ `context.project_info.summary` — 150–200 word plain text summary including:
62
+ - What the project does
63
+ - Key features identified
64
+ - Entities/modules detected
65
+ - Tech preferences mentioned
66
+ - Third-party integrations noted
67
+
68
+ `context.project_info.detected_entities[]` — flat list of data entities found
69
+ Example: ["users", "admins", "bots", "orders", "products"]
70
+
71
+ Agent uses this summary for ALL remaining suggestions in this and future workflows.
72
+
73
+ ---
74
+
75
+ ### Phase 1 — Project Type
76
+
77
+ 0. Run task: `ask-init-mode`
78
+ - Stores: `context.current_init.init_mode`
79
+ - Values: "fast" | "manual"
80
+
81
+ 1. Run task: `ask-project-type`
82
+ - Stores: `context.current_init.project_type`
83
+ - Valid values: `nodejs`, `reactjs`, `database-only`
84
+
85
+ 1b. If `project_type == nodejs`:
86
+ - Run task: `ask-client-type`
87
+ Stores: `context.current_init.client_type`
88
+
89
+ - Run task: `ask-encrypted-transport`
90
+ Stores: `context.current_init.encrypted_transport`
91
+
92
+ - Run task: `ask-supported-languages`
93
+ Stores: `context.current_init.supported_languages[]`
94
+
95
+ 2. If `project_type == reactjs`:
96
+ - Run task: `ask-linked-service`
97
+ This enforces the backend requirement. If no NodeJS service exists,
98
+ the task aborts the workflow with instructions. Otherwise it:
99
+ - Stores: `context.current_init.linked_service`
100
+ - Stores: `context.current_init.linked_service_port`
101
+ - Inherits and stores: `encryption_key`, `encryption_iv`, `api_key`
102
+ from the selected backend service into `context.current_init`
103
+ - Skip Phase 2 (no DB questions for frontend)
104
+ - Skip Phase 4 (no package author/name questions — handled by fast defaults)
105
+ - Skip Phase 5 (no api-key, encryption-key, redis questions — inherited
106
+ from linked backend, never asked from user)
107
+ - Jump directly to Phase 3 (service identity)
108
+
109
+ 3. If `project_type == nodejs` or `database-only`:
110
+ - Continue to Phase 2
111
+
112
+ ---
113
+
114
+ ### Phase 2 — Database (for nodejs and database-only)
115
+
116
+ 4. Run task: `ask-database-type`
117
+ - If `context.db.type` already exists → inform user and ask:
118
+ use existing or configure new?
119
+ - Stores: `context.db.type`
120
+
121
+ 5. If `init_mode == "manual"`:
122
+ Run task: `ask-database-config`
123
+ - Collects: name, host, port, user in one grouped display
124
+ - Stores: `context.db.name`, `context.db.host`,
125
+ `context.db.port`, `context.db.user`
126
+
127
+ If `init_mode == "fast"`:
128
+ Run task: `ask-database-name`
129
+ - Stores: `context.db.name`
130
+ Run task: `ask-database-user`
131
+ - Stores: `context.db.user`
132
+ (host and port will be auto-populated by generate-fast-defaults)
133
+
134
+ 9. Delegate to `database-agent` — generate database folder at the
135
+ REPOSITORY ROOT — not inside the service folder.
136
+ The database/ directory is always a sibling of service folders,
137
+ never a child. All services share the same database directory.
138
+
139
+ Path anchor: all paths below are relative to repository root.
140
+
141
+ ## Database Folder Existence Check (CRITICAL)
142
+
143
+ Before generating ANY database files, check whether
144
+ `<repo_root>/database/<db_type>/` already exists on disk.
145
+
146
+ ### If database folder does NOT exist → generate everything:
147
+ - <repo_root>/database/<db_type>/migrations/ (empty, ready for table files)
148
+ - <repo_root>/database/<db_type>/create-schema.sql (header only)
149
+ - <repo_root>/database/<db_type>/setup-database.sh (Linux/Mac runner)
150
+ - <repo_root>/database/<db_type>/setup-database.ps1 (Windows runner)
151
+ - <repo_root>/database/<db_type>/reset-database.sh (dev-only reset)
152
+ - <repo_root>/database/<db_type>/seeds/ (empty with .gitkeep)
153
+ - <repo_root>/database/README.md
154
+
155
+ Then run task: generate-tbl-user-deviceinfo
156
+ (only for nodejs projects — not database-only)
157
+
158
+ ### If database folder ALREADY exists → skip folder generation entirely:
159
+ Inform user:
160
+ "Database folder already exists at database/<db_type>/. Skipping
161
+ folder generation — your existing migrations are untouched."
162
+
163
+ Then check: does `database/<db_type>/migrations/1-setup-tbl-user-deviceinfo.sql`
164
+ already exist on disk?
165
+ - If YES → skip generate-tbl-user-deviceinfo entirely.
166
+ Inform user: "tbl_user_deviceinfo migration already exists. Skipping."
167
+ - If NO AND project_type == nodejs → run task: generate-tbl-user-deviceinfo.
168
+ This handles the case where database-only was initialized first
169
+ and the NodeJS system table was never created.
170
+ - If NO AND project_type == database-only → skip. This table is
171
+ not needed for database-only projects.
172
+
173
+ 10. Inform user:
174
+ "Database folder initialized. You can now run @db:create-table
175
+ to add your first table, or continue to scaffold your service below."
176
+
177
+ 11. If `project_type == database-only`:
178
+ - Skip Phases 3–5 entirely
179
+ - Jump directly to Phase 6 (confirmation and final summary)
180
+
181
+ ---
182
+
183
+ ### Phase 3 — Service Identity
184
+
185
+ 12. Run task: `ask-service-name`
186
+ - Must be unique across `context.services`
187
+ - Agent suggests name from `context.project_info.detected_entities`
188
+ if relevant
189
+ - Stores: `context.current_init.service_name`
190
+
191
+ 13. If `init_mode == "manual"`:
192
+ Run task: `ask-service-port`
193
+ - Must not conflict with existing ports in `context.services`
194
+ - Stores: `context.current_init.port`
195
+
196
+ 14. Run task: `ask-service-description`
197
+ - Stores: `context.current_init.description`
198
+
199
+ ---
200
+
201
+ ### Phase 4 — Package Info (nodejs only, manual mode only — skipped for reactjs)
202
+
203
+ 15. If `init_mode == "manual"`:
204
+ Run task: `ask-package-name`
205
+ - Default: service_name
206
+ - Stores: `context.current_init.package_name`
207
+
208
+ 16. If `init_mode == "manual"`:
209
+ Run task: `ask-package-author`
210
+ - Stores: `context.current_init.author`
211
+
212
+ ---
213
+
214
+ ### Phase 5 — Runtime Config (nodejs only — skipped entirely for reactjs)
215
+
216
+ 17. If `init_mode == "manual"`:
217
+ Run task: `ask-api-key`
218
+ - Auto-generate suggestion (32 chars)
219
+ - Stores: `context.current_init.api_key`
220
+
221
+ 18. If `init_mode == "manual"`:
222
+ Run task: `ask-encryption-key`
223
+ - Enforce exactly 32 characters
224
+ - Auto-generate suggestion
225
+ - Stores: `context.current_init.encryption_key`
226
+
227
+ 19. If `init_mode == "manual"`:
228
+ Run task: `ask-encryption-iv`
229
+ - Enforce exactly 16 characters
230
+ - Auto-generate suggestion
231
+ - Stores: `context.current_init.encryption_iv`
232
+
233
+ Note: KEY and IV are always generated regardless of encrypted_transport
234
+ value. They are used for password encryption even when transport is
235
+ not encrypted.
236
+
237
+ 20. If `init_mode == "manual"`:
238
+ Run task: `ask-redis-config`
239
+ - Collects: host and port in one grouped display
240
+ - Stores: `context.current_init.redis_host`,
241
+ `context.current_init.redis_port`
242
+ (If init_mode == "fast" → handled by generate-fast-defaults)
243
+
244
+ ---
245
+
246
+ ### Phase 5b — Auto-populate Defaults (fast mode, nodejs only)
247
+
248
+ Run task: `generate-fast-defaults`
249
+ - Condition: only runs if `context.current_init.init_mode == "fast"`
250
+ AND `context.current_init.project_type == "nodejs"`
251
+ - For `project_type == "reactjs"` → skip entirely. All security values
252
+ were already inherited from the linked backend in ask-linked-service.
253
+ Only port and package defaults need auto-filling — see step 13.
254
+ - Silently sets all values not yet in context.current_init
255
+ - No output, no questions — values appear in summary
256
+ - See task description for full list of what is auto-generated
257
+
258
+ ---
259
+
260
+ ### Phase 6 — Single Confirmation, Then Generate Everything
261
+
262
+ 22. Run task: `show-init-summary`
263
+ - Runs pre-generation validation before displaying anything
264
+ - Resolves any BLOCKERs interactively before showing the summary
265
+ - Displays all collected values with auto-generated markers
266
+ - Shows any non-blocking WARNINGs
267
+ - Shows the 5-wave generation plan
268
+ - Asks ONE question: "Confirm and generate all files?
269
+ (yes / no / change a value)"
270
+ - If yes → proceed immediately to step 23 — NO further confirmations
271
+ - If no → abort, nothing created
272
+ - If change → re-run that specific ask-* task → re-validate →
273
+ return to show-init-summary
274
+
275
+ 23. Branch on `context.current_init.project_type`:
276
+
277
+ ---
278
+
279
+ ## IF project_type == "nodejs"
280
+
281
+ Read `.codeninja/agent/nodejs-agent.md`.
282
+ Execute ALL generation steps below directly as the nodejs-agent.
283
+ Do NOT proceed to step 24 until every file listed in Waves 1–5
284
+ has been confirmed written to disk.
285
+
286
+ Pass values into generation:
287
+ - Full `context.current_init` + `context.db`
288
+ - `context.current_init.client_type`
289
+ - `context.current_init.encrypted_transport`
290
+ - `context.current_init.supported_languages`
291
+
292
+ Generation rules:
293
+ - Do NOT pause between waves
294
+ - Do NOT ask for confirmation on individual files or folders
295
+ - Do NOT skip any file — every file listed in every wave is required
296
+ - ALL paths below are relative to <service_name>/ — NOT repo root
297
+ - Step 24 MUST NOT run until ALL 5 waves are complete
298
+
299
+ ## COMPLETION GATE (nodejs)
300
+ Before proceeding to step 24, verify these files exist on disk:
301
+ - <service_name>/app.js
302
+ - <service_name>/modules/v1/route_manager.js
303
+ - <service_name>/modules/v1/<ServiceName>/route.js
304
+ - <service_name>/modules/v1/<ServiceName>/<service>_model.js
305
+ - <service_name>/document/v1/swagger_doc.json
306
+ If any of these are missing → generate them now before continuing.
307
+ Only proceed to step 24 when ALL are confirmed present.
308
+
309
+ ## Generation Wave Structure (nodejs)
310
+
311
+ ### Why waves exist
312
+ All files within a wave share zero generation-time dependencies on
313
+ each other — they all read only from context.current_init and
314
+ context.db which are fully loaded before Wave 1 begins.
315
+ Waves only exist where one file must know the output of another
316
+ file before it can be written correctly.
317
+
318
+ ### Wave 1 — Foundation (no dependencies, generate all simultaneously)
319
+ These files depend only on context values. None depend on each other.
320
+
321
+ - package.json → task: generate-package-json
322
+ - .env and .env.example → from context.current_init values
323
+ - .gitignore → task: generate-gitignore
324
+ - README.md → task: generate-readme
325
+ - config/constants.js → task: generate-constants
326
+ - config/template.js → task: generate-template
327
+ - logger/logging.js → task: generate-logging
328
+ - utilities/encryption.js → task: generate-encryption
329
+ - languages/<lang>.js for each in supported_languages[] → task: generate-language-en
330
+ - enc_dec.html OR enc_dec.php (based on client_type) → task: generate-enc-dec-html or generate-enc-dec-php
331
+ - <service_name>/pem/ directory with .gitkeep
332
+ - <service_name>/images/ directory with .gitkeep
333
+ - <service_name>/logger/logs/ directory with .gitkeep
334
+
335
+ ### Wave 2 — Infrastructure (depend on Wave 1 context, not on Wave 1 files)
336
+ These files reference logging.js and encryption.js at runtime but
337
+ their generation only needs context values — they can be written
338
+ while Wave 1 is still completing.
339
+
340
+ - config/database.js → task: generate-database
341
+ - utilities/ioRedis.js → task: generate-ioRedis
342
+ - utilities/response.js → task: generate-response
343
+
344
+ ### Wave 3 — Service Layer (depend on Wave 2 context)
345
+ These files reference database, ioRedis, and response at runtime.
346
+ Generation needs only context values.
347
+
348
+ - config/common.js → task: generate-common
349
+ - utilities/validator.js → task: generate-validator
350
+ - utilities/notification.js → task: generate-notification
351
+ - middleware/rateLimiter.js → task: generate-rateLimiter
352
+
353
+ ### Wave 4 — Middleware and Business Layer
354
+ headerValidator references encryption, response, ioRedis, and
355
+ all language files — all of which are complete by now.
356
+ route.js and model.js reference common, database, encryption,
357
+ response, validator — all complete by now.
358
+ swagger_doc.json skeleton needs no other generated files.
359
+ All four can be written simultaneously.
360
+
361
+ - middleware/headerValidator.js → task: generate-headerValidator
362
+ - modules/v1/<ServiceName>/route.js → task: generate-route
363
+ - modules/v1/<ServiceName>/<service>_model.js → task: generate-model
364
+ - document/v1/swagger_doc.json (skeleton) → task: generate-swagger (Mode 1)
365
+
366
+ ### Wave 5 — Orchestration Layer (must come last)
367
+ route_manager.js must know which module routes exist so it can
368
+ register them. It reads the module list from context.current_init
369
+ and the route files from Wave 4.
370
+ app.js must know the route_manager path.
371
+ Both depend on Wave 4 completing first. They can be written
372
+ simultaneously with each other.
373
+
374
+ - modules/v1/route_manager.js → task: generate-route-manager
375
+ - app.js → task: generate-app
376
+
377
+ ### Wave 6 — Docker Containerization (post-completion)
378
+ These files depend on the complete service being functional.
379
+ Can be written simultaneously.
380
+
381
+ - Dockerfile → task: generate-dockerfile
382
+ - .dockerignore → task: generate-dockerignore
383
+
384
+ ---
385
+
386
+ ## IF project_type == "reactjs"
387
+
388
+ Read `.codeninja/agent/reactjs-agent.md`.
389
+ Execute ALL generation steps below directly as the reactjs-agent.
390
+ Do NOT proceed to step 24 until every file listed in Waves 1–3
391
+ has been confirmed written to disk.
392
+
393
+ Pass values into generation:
394
+ - Full `context.current_init` including `linked_service`,
395
+ `linked_service_port`, `encryption_key`, `encryption_iv`, `api_key`
396
+
397
+ Generation rules:
398
+ - Do NOT pause between waves
399
+ - Do NOT ask for confirmation on individual files
400
+ - Do NOT skip any file — every file listed is required
401
+ - ALL paths are relative to <service_name>/ — NOT repo root
402
+ - Step 24 MUST NOT run until ALL 3 waves are complete
403
+
404
+ ## COMPLETION GATE (reactjs)
405
+ Before proceeding to step 24, verify these files exist on disk:
406
+ - <service_name>/public/index.html
407
+ - <service_name>/src/api/apiClient.js
408
+ - <service_name>/src/api/apiHandler.js
409
+ - <service_name>/src/App.jsx
410
+ - <service_name>/src/index.jsx
411
+ - <service_name>/.env
412
+ If any are missing → generate them now before continuing.
413
+ Only proceed to step 24 when ALL are confirmed present.
414
+
415
+ ## Generation Wave Structure (reactjs)
416
+
417
+ ### Wave 1 — Foundation (no dependencies)
418
+ All depend only on context values.
419
+
420
+ - package.json → task: generate-react-package-json
421
+ - .env and .env.example → task: generate-react-env
422
+ (values inherited from linked backend — no user input)
423
+ - .gitignore → task: generate-react-gitignore
424
+ - README.md → task: generate-readme
425
+ (agent adapts content for ReactJS: no Redis, no DB setup,
426
+ shows npm start instead of node app.js)
427
+ - public/index.html → task: generate-react-index-html
428
+ - public/assets/css/style.css → empty file with a reset comment
429
+ - public/robots.txt → standard disallow-all scaffold default
430
+ - public/favicon.ico → placeholder note (developer replaces)
431
+ - .htaccess (root) → task: generate-react-htaccess
432
+ - public/.htaccess → task: generate-react-htaccess
433
+
434
+ ### Wave 2 — API Layer
435
+ apiClient.js depends on .env values being defined (Wave 1).
436
+ apiHandler.js depends on apiClient.js being available.
437
+ Both can be written simultaneously since apiHandler only imports
438
+ from apiClient by reference — it does not read apiClient's content.
439
+
440
+ - src/api/apiClient.js → task: generate-react-api-client
441
+ - src/api/apiHandler.js → task: generate-react-api-handler
442
+
443
+ ### Wave 3 — Application Shell (must come last)
444
+ App.jsx must know which page components exist to import them.
445
+ index.jsx must import App.
446
+ Welcome page can be written alongside App.jsx since App only
447
+ imports it by reference.
448
+
449
+ - src/pages/Welcome/index.jsx → task: generate-react-welcome-page
450
+ - src/pages/Welcome/Welcome.module.css → task: generate-react-welcome-page
451
+ - src/App.jsx → task: generate-react-app-jsx
452
+ - src/index.jsx → task: generate-react-index-jsx
453
+ - src/components/ → create empty directory with .gitkeep
454
+
455
+ ### Wave 4 — Docker Containerization (post-completion)
456
+ These files depend on the complete React app being functional.
457
+ Can be written simultaneously.
458
+
459
+ - Dockerfile → task: generate-react-dockerfile
460
+ - nginx.conf → task: generate-react-dockerfile (same task generates both)
461
+ - .dockerignore → task: generate-dockerignore (reuse NodeJS task, adapted for React)
462
+
463
+ 23b. Run task: `generate-ide-configs`
464
+ - Condition: only on the FIRST @initialize-project run in this repo
465
+ (check: was context.initialized_at empty before this run started?)
466
+ - Writes: `.vscode/mcp.json` (VS Code)
467
+ - Writes: `.cursor/mcp.json` (Cursor)
468
+ - Prints: Claude Desktop config snippet for the user to add manually
469
+ - Skip silently if either config file already exists
470
+ - Do NOT block on the Claude Desktop step — it is print-only
471
+
472
+ 23c. Run task: `generate-docker-compose`
473
+ - Condition: ALWAYS run on every @initialize-project
474
+ - If docker-compose.yml does NOT exist at repo root → generate complete file
475
+ - If docker-compose.yml DOES exist → update it by adding the new service
476
+ - Also generate/update .env.docker and .env.docker.example at repo root
477
+ - Location: <repository_root>/docker-compose.yml (NOT inside service folder)
478
+
479
+ 24. Run task: `write-context`
480
+ - Set `project_name` = `context.current_init.service_name`
481
+ (top-level key — required for context.json to be valid)
482
+ - Set `initialized_at` = ISO now (top-level — first service init)
483
+ - Set `last_command` = "initialize-project"
484
+ - Append new service to `context.services[<service_name>]`
485
+ with all values from `context.current_init`
486
+ - For reactjs services: also store `linked_service` and
487
+ `linked_service_port` in the service entry so future commands
488
+ know which backend this frontend is bound to
489
+ - Update `context.project_info` with `initialized_at` timestamp
490
+ - Clear `context.current_init`
491
+
492
+ 25. Run task: `show-final-summary`
493
+ - Read `.codeninja/tasks/show-final-summary.task.md`
494
+ - List all files created in Waves 1–5
495
+ - Show startup commands
496
+ - Offer next steps: @db:create-table, @create-api, @design
497
+
498
+ NOTE: show-final-summary only runs AFTER step 24 (write-context)
499
+ completes successfully. Never show the final summary before
500
+ context.json has been written.