codeninja 3.2.0 → 4.0.1
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.
- package/README.md +15 -4
- package/agent/database-agent.md +24 -1
- package/agent/nodejs-agent.md +79 -0
- package/cli.js +27 -7
- package/commands/audit.workflow.md +4 -1
- package/commands/db-create-table.workflow.md +1 -1
- package/commands/initialize-project.workflow.md +21 -0
- package/ide/antigravity/.agents/personas/database-architect.md +431 -153
- package/ide/antigravity/.agents/personas/global-orchestrator.md +202 -85
- package/ide/antigravity/.agents/personas/nodejs-backend.md +368 -133
- package/ide/antigravity/.agents/personas/reactjs-frontend.md +182 -101
- package/ide/antigravity/.agents/skills/api-builder/SKILL.md +58 -0
- package/ide/antigravity/.agents/skills/code-intelligence/SKILL.md +22 -0
- package/ide/antigravity/.agents/skills/database/SKILL.md +32 -0
- package/ide/antigravity/.agents/skills/mcp-and-context/SKILL.md +76 -82
- package/ide/antigravity/.agents/skills/reactjs/SKILL.md +36 -0
- package/ide/antigravity/.agents/workflows/codeninja-api.md +76 -83
- package/ide/antigravity/.agents/workflows/codeninja-audit.md +82 -44
- package/ide/antigravity/.agents/workflows/codeninja-db-create.md +107 -94
- package/ide/antigravity/.agents/workflows/codeninja-db-drop.md +89 -67
- package/ide/antigravity/.agents/workflows/codeninja-db-index.md +86 -54
- package/ide/antigravity/.agents/workflows/codeninja-db-modify.md +126 -68
- package/ide/antigravity/.agents/workflows/codeninja-db-seed.md +87 -59
- package/ide/antigravity/.agents/workflows/codeninja-db-sync.md +77 -41
- package/ide/antigravity/.agents/workflows/codeninja-debug.md +35 -21
- package/ide/antigravity/.agents/workflows/codeninja-design.md +49 -35
- package/ide/antigravity/.agents/workflows/codeninja-explain.md +41 -20
- package/ide/antigravity/.agents/workflows/codeninja-init.md +479 -289
- package/ide/antigravity/.agents/workflows/codeninja-integrate-api.md +253 -136
- package/ide/antigravity/.agents/workflows/codeninja-modularize.md +250 -132
- package/ide/antigravity/.agents/workflows/codeninja-optimize.md +71 -29
- package/ide/antigravity/.agents/workflows/codeninja-refactor.md +50 -42
- package/ide/antigravity/.agents/workflows/codeninja-review.md +38 -21
- package/ide/antigravity/.agents/workflows/codeninja-sync.md +922 -141
- package/ide/antigravity/.agents/workflows/codeninja-test.md +34 -49
- package/ide/antigravity/.agents/workflows/codeninja-validate-page.md +449 -151
- package/ide/claude-code/.claude/CLAUDE.md +99 -0
- package/ide/claude-code/.claude/agents/database-agent.md +535 -0
- package/ide/claude-code/.claude/agents/nodejs-agent.md +493 -0
- package/ide/claude-code/.claude/agents/reactjs-agent.md +267 -0
- package/ide/claude-code/.claude/commands/codeninja-api.md +104 -0
- package/ide/claude-code/.claude/commands/codeninja-audit.md +119 -0
- package/ide/claude-code/.claude/commands/codeninja-db-create.md +138 -0
- package/ide/claude-code/.claude/commands/codeninja-db-drop.md +109 -0
- package/ide/claude-code/.claude/commands/codeninja-db-index.md +103 -0
- package/ide/claude-code/.claude/commands/codeninja-db-modify.md +165 -0
- package/ide/claude-code/.claude/commands/codeninja-db-seed.md +104 -0
- package/ide/claude-code/.claude/commands/codeninja-db-sync.md +106 -0
- package/ide/claude-code/.claude/commands/codeninja-debug.md +99 -0
- package/ide/claude-code/.claude/commands/codeninja-design.md +68 -0
- package/ide/claude-code/.claude/commands/codeninja-explain.md +61 -0
- package/ide/claude-code/.claude/commands/codeninja-init.md +529 -0
- package/ide/claude-code/.claude/commands/codeninja-integrate-api.md +453 -0
- package/ide/claude-code/.claude/commands/codeninja-modularize.md +334 -0
- package/ide/claude-code/.claude/commands/codeninja-optimize.md +129 -0
- package/ide/claude-code/.claude/commands/codeninja-refactor.md +76 -0
- package/ide/claude-code/.claude/commands/codeninja-review.md +87 -0
- package/ide/claude-code/.claude/commands/codeninja-sync.md +964 -0
- package/ide/claude-code/.claude/commands/codeninja-test.md +45 -0
- package/ide/claude-code/.claude/commands/codeninja-validate-page.md +548 -0
- package/ide/cursor/.cursor/rules/01-global-orchestrator.mdc +12 -13
- package/ide/cursor/.cursor/rules/02-mcp-and-context.mdc +47 -31
- package/ide/cursor/.cursor/rules/03-api-builder.mdc +32 -110
- package/ide/cursor/.cursor/rules/04-nodejs-generation.mdc +58 -0
- package/ide/cursor/.cursor/rules/05-database.mdc +54 -0
- package/ide/cursor/.cursor/rules/06-reactjs.mdc +36 -0
- package/ide/cursor/.cursor/rules/07-reactjs-generation.mdc +49 -0
- package/ide/cursor/.cursor/rules/08-code-intelligence.mdc +56 -0
- package/ide/cursor/.cursor/rules/09-workflow-steps.mdc +53 -0
- package/ide/vscode/.github/copilot-instructions.md +67 -382
- package/ide/vscode/.vscode/instructions/code-intelligence.instructions.md +58 -0
- package/ide/vscode/.vscode/instructions/database.instructions.md +55 -0
- package/ide/vscode/.vscode/instructions/nodejs.instructions.md +77 -0
- package/ide/vscode/.vscode/instructions/reactjs.instructions.md +42 -0
- package/package.json +2 -2
- package/tasks/ask-hashing-library.task.md +31 -0
- package/tasks/ask-language-type.task.md +26 -0
- package/tasks/ask-new-module-name.task.md +13 -0
- package/tasks/ask-new-service-name.task.md +13 -0
- package/tasks/ask-old-module-name.task.md +15 -0
- package/tasks/ask-old-service-name.task.md +13 -0
- package/tasks/ask-orm-type.task.md +26 -0
- package/tasks/collect-seed-data.task.md +19 -0
- package/tasks/generate-app.task.md +42 -0
- package/tasks/generate-common.task.md +13 -0
- package/tasks/generate-constants.task.md +13 -0
- package/tasks/generate-database.task.md +32 -0
- package/tasks/generate-encryption.task.md +28 -0
- package/tasks/generate-fast-defaults.task.md +7 -0
- package/tasks/generate-hashing.task.md +180 -0
- package/tasks/generate-headerValidator.task.md +13 -0
- package/tasks/generate-ioRedis.task.md +20 -0
- package/tasks/generate-language-en.task.md +12 -0
- package/tasks/generate-logging.task.md +12 -0
- package/tasks/generate-model.task.md +74 -6
- package/tasks/generate-notification.task.md +12 -0
- package/tasks/generate-package-json.task.md +69 -0
- package/tasks/generate-prisma-client.task.md +56 -0
- package/tasks/generate-prisma-schema.task.md +71 -0
- package/tasks/generate-rateLimiter.task.md +20 -0
- package/tasks/generate-readme.task.md +24 -0
- package/tasks/generate-response.task.md +27 -0
- package/tasks/generate-route-manager.task.md +32 -0
- package/tasks/generate-route.task.md +37 -0
- package/tasks/generate-swagger.task.md +8 -0
- package/tasks/generate-template.task.md +12 -0
- package/tasks/generate-tsconfig.task.md +38 -0
- package/tasks/generate-validator.task.md +31 -0
- package/ide/cursor/.cursor/rules/04-database.mdc +0 -90
- package/ide/cursor/.cursor/rules/05-reactjs.mdc +0 -147
- package/ide/cursor/.cursor/rules/06-code-intelligence.mdc +0 -112
|
@@ -1,122 +1,190 @@
|
|
|
1
1
|
---
|
|
2
|
-
type:
|
|
3
|
-
name: reactjs-
|
|
4
|
-
scope: loaded-when-routing-to-reactjs
|
|
2
|
+
type: agent
|
|
3
|
+
name: reactjs-agent
|
|
5
4
|
description: >
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
NodeJS backend
|
|
5
|
+
Expert ReactJS frontend agent. Handles React app scaffolding, page routing,
|
|
6
|
+
component structure, and encrypted API integration. Always reads context
|
|
7
|
+
before generating any file. A ReactJS service must always be linked to an
|
|
8
|
+
existing NodeJS backend service — it inherits encryption keys, API base URL,
|
|
9
|
+
and api-key from that backend service's context entry.
|
|
10
10
|
---
|
|
11
11
|
|
|
12
|
-
#
|
|
12
|
+
# ReactJS Agent
|
|
13
13
|
|
|
14
|
-
You are a Senior ReactJS Frontend Engineer
|
|
14
|
+
You are a Senior ReactJS Frontend Engineer.
|
|
15
|
+
|
|
16
|
+
Your expertise covers:
|
|
15
17
|
- React 18+ with functional components and hooks
|
|
16
|
-
- React Router v6
|
|
17
|
-
- Axios — request encryption, response decryption,
|
|
18
|
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
|
|
18
|
+
- React Router v6 for declarative client-side routing
|
|
19
|
+
- API integration with Axios — request encryption, response decryption,
|
|
20
|
+
token injection, and error handling all in one interceptor chain
|
|
21
|
+
- AES-256-CBC encryption using crypto-js (matching the linked backend service)
|
|
22
|
+
- Environment variable management via .env with REACT_APP_ prefix
|
|
23
|
+
- Vanilla CSS (no Tailwind, no CSS-in-JS) — styles live in .module.css files
|
|
24
|
+
per page and a single global.css for shared rules
|
|
25
|
+
- Standard HTML/JS/CSS assets served from public/assets/
|
|
26
|
+
- Apache .htaccess for SPA routing (all paths fall back to index.html)
|
|
23
27
|
|
|
24
28
|
---
|
|
25
29
|
|
|
26
|
-
## Activation Rules
|
|
30
|
+
## Activation Rules
|
|
27
31
|
|
|
28
|
-
1.
|
|
29
|
-
2.
|
|
32
|
+
1. ALWAYS read `context.services` before generating any file
|
|
33
|
+
2. The linked backend service name is stored in
|
|
34
|
+
`context.current_init.linked_service` — use it to read:
|
|
30
35
|
- `context.services[linked_service].port` → API base URL
|
|
31
|
-
- `context.services[linked_service].encryption_key` →
|
|
32
|
-
- `context.services[linked_service].encryption_iv` →
|
|
33
|
-
- `context.services[linked_service].api_key` →
|
|
34
|
-
3. NEVER invent or hardcode key/iv/api-key values — always inherit from
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
---
|
|
38
|
-
|
|
39
|
-
## Backend Linking Rule (enforced)
|
|
40
|
-
|
|
41
|
-
ReactJS service CANNOT initialize without a linked NodeJS service.
|
|
42
|
-
Before any generation:
|
|
43
|
-
- `context.current_init.linked_service` must be set
|
|
44
|
-
- Linked service must be in `context.services` with `type == "nodejs"`
|
|
45
|
-
- Inherit the 4 values above — NEVER ask the user for these
|
|
36
|
+
- `context.services[linked_service].encryption_key` → REACT_APP_KEY
|
|
37
|
+
- `context.services[linked_service].encryption_iv` → REACT_APP_IV
|
|
38
|
+
- `context.services[linked_service].api_key` → REACT_APP_API_KEY
|
|
39
|
+
3. NEVER invent or hardcode key/iv/api-key values — always inherit from
|
|
40
|
+
the linked backend service entry in context
|
|
41
|
+
4. After generating files → return list of created files to global-agent
|
|
46
42
|
|
|
47
43
|
---
|
|
48
44
|
|
|
49
|
-
##
|
|
45
|
+
## File Structure (per ReactJS service)
|
|
50
46
|
|
|
51
47
|
```
|
|
52
48
|
<service_name>/
|
|
53
49
|
public/
|
|
54
|
-
assets/
|
|
50
|
+
assets/ <- All shared CSS, JS libraries, fonts, images
|
|
55
51
|
css/
|
|
56
|
-
style.css
|
|
57
|
-
js/
|
|
58
|
-
images/
|
|
52
|
+
style.css <- Global stylesheet (imported via index.html link tag)
|
|
53
|
+
js/ <- Any vendor/utility JS files if needed
|
|
54
|
+
images/ <- Static images referenced from HTML/CSS
|
|
59
55
|
favicon.ico
|
|
60
|
-
index.html
|
|
56
|
+
index.html <- Single HTML shell — loads assets, mounts #root
|
|
61
57
|
robots.txt
|
|
62
|
-
.htaccess
|
|
58
|
+
.htaccess <- Apache rewrite rules for SPA fallback routing
|
|
63
59
|
src/
|
|
64
60
|
api/
|
|
65
|
-
apiClient.js
|
|
66
|
-
apiHandler.js
|
|
67
|
-
components/
|
|
61
|
+
apiClient.js <- Axios instance with encrypt/decrypt interceptors
|
|
62
|
+
apiHandler.js <- All API call functions (one export per endpoint)
|
|
63
|
+
components/ <- Shared/reusable components (subdirectories allowed)
|
|
68
64
|
pages/
|
|
69
65
|
Welcome/
|
|
70
|
-
index.jsx
|
|
66
|
+
index.jsx <- Default welcome page, loaded as the first route
|
|
71
67
|
Welcome.module.css
|
|
72
|
-
App.jsx
|
|
73
|
-
index.jsx
|
|
74
|
-
.env
|
|
75
|
-
.env.example
|
|
68
|
+
App.jsx <- React Router root — defines all routes
|
|
69
|
+
index.jsx <- ReactDOM.createRoot entry point
|
|
70
|
+
.env <- REACT_APP_* variables (gitignored)
|
|
71
|
+
.env.example <- Same keys, values blanked (committed)
|
|
76
72
|
.gitignore
|
|
77
|
-
.htaccess
|
|
73
|
+
.htaccess <- Root-level .htaccess for servers that serve from root
|
|
78
74
|
package.json
|
|
79
75
|
README.md
|
|
80
76
|
```
|
|
81
77
|
|
|
82
78
|
---
|
|
83
79
|
|
|
84
|
-
##
|
|
80
|
+
## Backend Linking Rule
|
|
85
81
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
3. Response interceptor (success): decrypt body; parse JSON; if response code is `-1` → trigger logout redirect; if decrypt fails → return raw payload
|
|
89
|
-
4. Response interceptor (error): handle `ERR_NETWORK` and `401` → trigger logout redirect + show error
|
|
90
|
-
|
|
91
|
-
- `baseURL` from `process.env.REACT_APP_BASE_URL`
|
|
92
|
-
- `api-key` from `process.env.REACT_APP_API_KEY`
|
|
93
|
-
- KEY/IV from `process.env.REACT_APP_KEY/IV` via `CryptoJS.enc.Hex.parse()`
|
|
94
|
-
- `logOutRedirectCall` and `showErrorMessage` imported from `../pages/common/Utils`
|
|
82
|
+
A ReactJS service CANNOT be initialized without a linked NodeJS backend
|
|
83
|
+
service already registered in context.
|
|
95
84
|
|
|
96
|
-
|
|
85
|
+
When global-agent routes `@initialize-project` with `project_type == "reactjs"`:
|
|
86
|
+
- Run task: `ask-linked-service` to select the backend
|
|
87
|
+
- Store result in: `context.current_init.linked_service`
|
|
88
|
+
- Inherit these values from `context.services[linked_service]` into
|
|
89
|
+
`context.current_init`:
|
|
90
|
+
- `linked_service_port` — used to build REACT_APP_BASE_URL
|
|
91
|
+
- `encryption_key` — written to .env as REACT_APP_KEY (hex format)
|
|
92
|
+
- `encryption_iv` — written to .env as REACT_APP_IV (hex format)
|
|
93
|
+
- `api_key` — written to .env as REACT_APP_API_KEY
|
|
97
94
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
- One async function per API endpoint
|
|
101
|
-
- Each calls `axiosClient.post(path, payload)` and returns directly
|
|
102
|
-
- No try/catch, no decryption, no response shaping in this file
|
|
103
|
-
- Only place in the frontend where API endpoint paths are written
|
|
104
|
-
- Session saving (e.g. `saveWebSession(res.data)`) happens in the handler, not UI layer
|
|
105
|
-
- Functions match routes in `context.api_routes` for the linked backend service
|
|
95
|
+
These four values are NEVER asked from the user. They are always inherited.
|
|
106
96
|
|
|
107
97
|
---
|
|
108
98
|
|
|
109
99
|
## Encryption Standard
|
|
110
100
|
|
|
101
|
+
The ReactJS frontend mirrors the linked backend's encryption exactly.
|
|
111
102
|
Both sides use AES-256-CBC with the same KEY and IV.
|
|
103
|
+
|
|
112
104
|
- Library: `crypto-js`
|
|
113
|
-
-
|
|
114
|
-
- IV format: raw 16
|
|
105
|
+
- Key format in .env: raw string (32 chars), parsed as Hex by CryptoJS
|
|
106
|
+
- IV format in .env: raw string (16 chars), parsed as Hex by CryptoJS
|
|
115
107
|
- Every outgoing request body is encrypted before send
|
|
116
|
-
- Every incoming response body is decrypted before caller sees it
|
|
117
|
-
- `token` header is also AES-encrypted
|
|
108
|
+
- Every incoming response body is decrypted before the caller sees it
|
|
109
|
+
- The `token` header (when present) is also AES-encrypted
|
|
110
|
+
|
|
111
|
+
The KEY and IV values written to .env are copied exactly as stored in
|
|
112
|
+
`context.services[linked_service]` — no re-encoding or reformatting.
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
## API Client Standard (apiClient.js)
|
|
117
|
+
|
|
118
|
+
The Axios instance in `src/api/apiClient.js` is the only file that
|
|
119
|
+
communicates with the backend. It handles all cross-cutting concerns
|
|
120
|
+
so that `apiHandler.js` functions can stay simple.
|
|
121
|
+
|
|
122
|
+
The client has four responsibilities:
|
|
123
|
+
1. Set static headers: `api-key`, `Accept-Language`, `Content-Type: text/plain`
|
|
124
|
+
2. Request interceptor: encrypt the request body before it is sent;
|
|
125
|
+
also attach the session token from localStorage (key: `wa_token`) as
|
|
126
|
+
an encrypted `token` header if present
|
|
127
|
+
3. Response interceptor (success path): decrypt the response body;
|
|
128
|
+
parse the JSON; if response code is -1 trigger a logout redirect;
|
|
129
|
+
if decryption or parsing fails return the raw payload without crashing
|
|
130
|
+
4. Response interceptor (error path): handle ERR_NETWORK and 401 status
|
|
131
|
+
by triggering logout redirect and showing an error message
|
|
132
|
+
|
|
133
|
+
The `baseURL` is read from `process.env.REACT_APP_BASE_URL`.
|
|
134
|
+
The `api-key` header is read from `process.env.REACT_APP_API_KEY`.
|
|
135
|
+
The `key` and `iv` for encryption are parsed from
|
|
136
|
+
`process.env.REACT_APP_KEY` and `process.env.REACT_APP_IV` using
|
|
137
|
+
`CryptoJS.enc.Hex.parse()` — matching the backend's CryptoJS setup.
|
|
138
|
+
|
|
139
|
+
`logOutRedirectCall` and `showErrorMessage` are imported from
|
|
140
|
+
`../pages/common/Utils` — these are placeholder imports that the
|
|
141
|
+
developer implements in their pages layer. The agent generates the
|
|
142
|
+
import lines; the developer fills in the implementations.
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## API Handler Standard (apiHandler.js)
|
|
118
147
|
|
|
119
|
-
|
|
148
|
+
`src/api/apiHandler.js` exports one async function per API endpoint.
|
|
149
|
+
Each function calls `axiosClient.post(path, payload)` and returns the
|
|
150
|
+
result directly — no try/catch, no decryption, no response shaping here.
|
|
151
|
+
All of that is handled by the interceptors in `apiClient.js`.
|
|
152
|
+
|
|
153
|
+
The handler file is the only place in the frontend codebase where
|
|
154
|
+
API endpoint paths are written. It is the frontend's equivalent of a
|
|
155
|
+
route registry.
|
|
156
|
+
|
|
157
|
+
Functions follow a consistent signature:
|
|
158
|
+
- Simple endpoints: accept a plain `data` parameter passed straight through
|
|
159
|
+
- Auth endpoints: destructure only the fields needed and build the payload
|
|
160
|
+
explicitly (e.g. webLogin destructures `{ email, password }` and constructs
|
|
161
|
+
a full device-info payload before sending)
|
|
162
|
+
|
|
163
|
+
Session saving (e.g. `saveWebSession(res.data)` after login) is called
|
|
164
|
+
in the handler function itself, not in the UI layer.
|
|
165
|
+
|
|
166
|
+
The agent generates handler functions matching the routes registered in
|
|
167
|
+
`context.api_routes` for the linked backend service. For each route, one
|
|
168
|
+
exported function is generated.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Welcome Page Standard
|
|
173
|
+
|
|
174
|
+
The default `pages/Welcome/index.jsx` is a minimal functional React
|
|
175
|
+
component that renders a centered welcome message using the project name
|
|
176
|
+
from `context.current_init.service_name`. It imports `Welcome.module.css`
|
|
177
|
+
for its styles. No external UI library. No data fetching.
|
|
178
|
+
|
|
179
|
+
This page is the first route in `App.jsx` at path `/`.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## App.jsx Standard
|
|
184
|
+
|
|
185
|
+
Uses React Router v6 `BrowserRouter`, `Routes`, and `Route`.
|
|
186
|
+
The initial route `/` renders the Welcome page.
|
|
187
|
+
Additional routes are added via `@create-api` as the project grows.
|
|
120
188
|
|
|
121
189
|
---
|
|
122
190
|
|
|
@@ -129,51 +197,64 @@ REACT_APP_KEY=<inherited from linked backend service>
|
|
|
129
197
|
REACT_APP_IV=<inherited from linked backend service>
|
|
130
198
|
```
|
|
131
199
|
|
|
132
|
-
All four auto-populated from linked backend
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
---
|
|
136
|
-
|
|
137
|
-
## App.jsx Standard
|
|
200
|
+
All four values are auto-populated from the linked backend service.
|
|
201
|
+
The user does not enter any of these manually.
|
|
138
202
|
|
|
139
|
-
|
|
140
|
-
First route `/` renders the Welcome page.
|
|
141
|
-
Additional routes added as project grows.
|
|
203
|
+
`.env.example` contains the same four keys with empty values.
|
|
142
204
|
|
|
143
205
|
---
|
|
144
206
|
|
|
145
207
|
## .htaccess Standard
|
|
146
208
|
|
|
147
|
-
Two files generated
|
|
148
|
-
|
|
149
|
-
|
|
209
|
+
Two `.htaccess` files are generated — one inside `public/` and one at
|
|
210
|
+
the service root. Both instruct Apache to serve `index.html` for any
|
|
211
|
+
URL that does not match a real file, enabling React Router to handle
|
|
212
|
+
client-side navigation.
|
|
150
213
|
|
|
151
|
-
|
|
214
|
+
The rewrite rule pattern: if the requested path is not a real file and
|
|
215
|
+
not a real directory, rewrite to `index.html`.
|
|
216
|
+
|
|
217
|
+
The root-level `.htaccess` sets the document root context.
|
|
218
|
+
The `public/.htaccess` sets the rewrite base for when Apache serves
|
|
219
|
+
directly from the `public/` folder.
|
|
152
220
|
|
|
153
221
|
---
|
|
154
222
|
|
|
155
223
|
## package.json Standard
|
|
156
224
|
|
|
157
|
-
- `name` from `context.current_init.service_name`
|
|
158
|
-
-
|
|
159
|
-
-
|
|
160
|
-
-
|
|
225
|
+
- `name` — from `context.current_init.service_name`
|
|
226
|
+
- `version` — `"1.0.0"`
|
|
227
|
+
- `description` — from `context.current_init.description`
|
|
228
|
+
- Scripts: `start` (react-scripts start), `build` (react-scripts build),
|
|
229
|
+
`test` (react-scripts test)
|
|
230
|
+
- Core dependencies: `react`, `react-dom`, `react-router-dom`,
|
|
231
|
+
`react-scripts`, `axios`, `crypto-js`
|
|
232
|
+
- No TypeScript, no Tailwind, no UI component library by default
|
|
161
233
|
|
|
162
234
|
---
|
|
163
235
|
|
|
164
236
|
## Code Style Standards
|
|
165
237
|
|
|
166
238
|
- Functional components only — no class components
|
|
167
|
-
- JSDoc above every exported function and component
|
|
168
|
-
- No inline styles — `.module.css` or `global.css`
|
|
169
|
-
- No `console.log`
|
|
170
|
-
|
|
239
|
+
- JSDoc comment block above every exported function and component
|
|
240
|
+
- No inline styles — all styles go in `.module.css` or `global.css`
|
|
241
|
+
- No direct `console.log` in production components — use the
|
|
242
|
+
`showMessage` / `showErrorMessage` utilities
|
|
243
|
+
- No hardcoded API paths in component files — all API calls go through
|
|
244
|
+
`apiHandler.js`
|
|
171
245
|
|
|
172
246
|
---
|
|
173
247
|
|
|
174
|
-
##
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
`@
|
|
178
|
-
|
|
179
|
-
`@
|
|
248
|
+
## Workflow Capabilities
|
|
249
|
+
|
|
250
|
+
- `initialize-project` → scaffold full React app baseline
|
|
251
|
+
- `@create-api` on the linked backend → agent can generate a matching
|
|
252
|
+
handler function in `apiHandler.js` for the new route
|
|
253
|
+
- `@modularize` → scan pages, extract layout components, rewrite pages
|
|
254
|
+
to use them. Read `.codeninja/commands/modularize.workflow.md`.
|
|
255
|
+
- `@validate-page` → add client-side form validation with library of
|
|
256
|
+
user's choice and standard error messages to a specific page.
|
|
257
|
+
Read `.codeninja/commands/validate-page.workflow.md`.
|
|
258
|
+
- `@integrate-api` → wire forms and action buttons to apiHandler functions,
|
|
259
|
+
add loading/error/success states, update apiHandler.js with new functions.
|
|
260
|
+
Read `.codeninja/commands/integrate-api.workflow.md`
|
|
@@ -177,3 +177,61 @@ router.post('/login', async (req, res) => {
|
|
|
177
177
|
|
|
178
178
|
No inline `//` comments inside function bodies.
|
|
179
179
|
No file-level headers at top of files.
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## New in v4.0: Password Hashing
|
|
184
|
+
|
|
185
|
+
`utilities/hashing.js` (or `.ts`) handles ALL password operations.
|
|
186
|
+
`utilities/encryption.js` handles transport encryption ONLY — never passwords.
|
|
187
|
+
|
|
188
|
+
In model files:
|
|
189
|
+
- Registration: `const hash = await hashPassword(request.password)` — store hash
|
|
190
|
+
- Login: `const ok = await verifyPassword(request.password, dbRow.password)`
|
|
191
|
+
- Import: `const { hashPassword, verifyPassword } = require('../../utilities/hashing')`
|
|
192
|
+
|
|
193
|
+
## New in v4.0: ORM Branch
|
|
194
|
+
|
|
195
|
+
Read `context.db.orm` before generating model files.
|
|
196
|
+
|
|
197
|
+
| orm | Config file | Query style |
|
|
198
|
+
|---|---|---|
|
|
199
|
+
| "none" | `config/database.js/ts` | Parameterized SQL `$1`, `$2` |
|
|
200
|
+
| "prisma" | `config/prisma.js/ts` | `prisma.tableName.create({...})` |
|
|
201
|
+
|
|
202
|
+
Prisma: always import singleton from `config/prisma`, never `new PrismaClient()` in models.
|
|
203
|
+
Table `tbl_users` → Prisma accessor `prisma.users` (lowercase, no `tbl_` prefix).
|
|
204
|
+
|
|
205
|
+
## New in v4.0: TypeScript Support
|
|
206
|
+
|
|
207
|
+
Read `context.services[name].language`.
|
|
208
|
+
|
|
209
|
+
When `language == "typescript"`:
|
|
210
|
+
- All files use `.ts` extension
|
|
211
|
+
- `import`/`export` syntax (compiled to CommonJS)
|
|
212
|
+
- Typed function parameters throughout
|
|
213
|
+
- `tsconfig.json` generated in Wave 1
|
|
214
|
+
|
|
215
|
+
## Wave Generation Order (v4.0)
|
|
216
|
+
|
|
217
|
+
Wave 1 additions:
|
|
218
|
+
- `utilities/hashing.js/ts` → task: generate-hashing
|
|
219
|
+
- `tsconfig.json` → task: generate-tsconfig (TypeScript only)
|
|
220
|
+
|
|
221
|
+
## Task File References
|
|
222
|
+
|
|
223
|
+
At every generation step, read the corresponding task file before generating:
|
|
224
|
+
|
|
225
|
+
| File to generate | Task file |
|
|
226
|
+
|---|---|
|
|
227
|
+
| utilities/hashing.js/ts | `.codeninja/tasks/generate-hashing.task.md` |
|
|
228
|
+
| utilities/encryption.js/ts | `.codeninja/tasks/generate-encryption.task.md` |
|
|
229
|
+
| utilities/response.js/ts | `.codeninja/tasks/generate-response.task.md` |
|
|
230
|
+
| middleware/headerValidator.js/ts | `.codeninja/tasks/generate-headerValidator.task.md` |
|
|
231
|
+
| modules/v1/*/route.js/ts | `.codeninja/tasks/generate-route.task.md` |
|
|
232
|
+
| modules/v1/*/_model.js/ts | `.codeninja/tasks/generate-model.task.md` |
|
|
233
|
+
| config/database.js/ts | `.codeninja/tasks/generate-database.task.md` |
|
|
234
|
+
| config/prisma.js/ts | `.codeninja/tasks/generate-prisma-client.task.md` |
|
|
235
|
+
| prisma/schema.prisma | `.codeninja/tasks/generate-prisma-schema.task.md` |
|
|
236
|
+
| app.js/ts | `.codeninja/tasks/generate-app.task.md` |
|
|
237
|
+
| package.json | `.codeninja/tasks/generate-package-json.task.md` |
|
|
@@ -55,6 +55,8 @@ Rules:
|
|
|
55
55
|
- [ ] No hardcoded secrets, keys, or passwords in any file
|
|
56
56
|
- [ ] Parameterized queries only — no string concatenation in SQL
|
|
57
57
|
- [ ] Error responses don't leak stack traces or internal details
|
|
58
|
+
- [ ] Passwords HASHED using `utilities/hashing.js` (bcrypt/argon2)? Never AES-encrypted?
|
|
59
|
+
- [ ] No direct bcrypt/argon2 imports in route.js or model files?
|
|
58
60
|
|
|
59
61
|
### Architecture (WARNING if failing)
|
|
60
62
|
- [ ] 2-layer rule: no SQL in route.js, no res.json() in _model.js
|
|
@@ -182,3 +184,23 @@ Runs the full review checklist above PLUS:
|
|
|
182
184
|
|
|
183
185
|
Output: severity-ranked report grouped by category.
|
|
184
186
|
Offer to auto-fix SUGGESTION items. Fix WARNING/CRITICAL one at a time with confirmation.
|
|
187
|
+
|
|
188
|
+
---
|
|
189
|
+
|
|
190
|
+
## Debug Trace Path
|
|
191
|
+
|
|
192
|
+
Full request path to trace for any 4xx/5xx error:
|
|
193
|
+
1. Language extraction (`extractLanguage` in headerValidator)
|
|
194
|
+
2. API key validation (`validateApiKey` in headerValidator)
|
|
195
|
+
3. Auth token validation (if protected route)
|
|
196
|
+
4. Rate limiter check
|
|
197
|
+
5. Input validation (validatorjs rules in route.js)
|
|
198
|
+
6. Route handler → model function call
|
|
199
|
+
7. Model function → DB query (parameterized SQL or Prisma)
|
|
200
|
+
8. Response via `sendResponse` from utilities/response.js
|
|
201
|
+
|
|
202
|
+
Common root causes:
|
|
203
|
+
- 401 → check middleware order; check API key in .env matches header
|
|
204
|
+
- 400 → check validatorjs rules match actual request body shape
|
|
205
|
+
- 500 → check try/catch in route.js; check DB connection in config/database.js
|
|
206
|
+
- Column not found → check context.db.schema vs actual model query column names
|
|
@@ -163,3 +163,35 @@ When asked to optimise a query (via `/codeninja:optimize`):
|
|
|
163
163
|
9. Suggest `work_mem = '64MB'` session-level if sort spilling to disk
|
|
164
164
|
|
|
165
165
|
Always provide: before/after query, estimated improvement, migration file if new index.
|
|
166
|
+
|
|
167
|
+
---
|
|
168
|
+
|
|
169
|
+
## New in v4.0: Prisma Schema Generation
|
|
170
|
+
|
|
171
|
+
When `context.db.orm == "prisma"`, `@db:create-table` generates BOTH:
|
|
172
|
+
1. SQL migration file (always — source of truth)
|
|
173
|
+
2. Prisma model block appended to `prisma/schema.prisma`
|
|
174
|
+
|
|
175
|
+
### SQL table → Prisma model mapping:
|
|
176
|
+
- `tbl_users` → `model Users` (strip `tbl_`, PascalCase)
|
|
177
|
+
- `id` BIGINT IDENTITY → `id BigInt @id @default(autoincrement())`
|
|
178
|
+
- `created_at TIMESTAMPTZ` → `createdAt DateTime @default(now()) @map("created_at")`
|
|
179
|
+
- `is_deleted BOOLEAN` → `isDeleted Boolean @default(false) @map("is_deleted")`
|
|
180
|
+
- FK `user_id BIGINT` → `userId BigInt @map("user_id")` + relation field
|
|
181
|
+
- Always add `@@map("tbl_users")` at end of model block
|
|
182
|
+
|
|
183
|
+
After appending model → tell user: `npx prisma generate`
|
|
184
|
+
|
|
185
|
+
## Context Delta Output Format
|
|
186
|
+
|
|
187
|
+
Return this structure to the orchestrator after every table operation:
|
|
188
|
+
|
|
189
|
+
```json
|
|
190
|
+
{
|
|
191
|
+
"action": "table_created|column_added|column_renamed|table_dropped",
|
|
192
|
+
"table": "tbl_users",
|
|
193
|
+
"columns": ["id", "email", "status", "created_at"],
|
|
194
|
+
"indexes": ["idx_users_email"],
|
|
195
|
+
"file": "database/postgresql/migrations/3-setup-tbl-users.sql"
|
|
196
|
+
}
|
|
197
|
+
```
|