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