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,102 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-api-handler
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # File: src/api/apiHandler.js
8
+
9
+ ## Purpose
10
+ Registry of all API call functions for this frontend service. Every
11
+ function maps to one backend route. This is the only file in the frontend
12
+ that knows API endpoint paths. All functions return Axios promises —
13
+ no try/catch, no response shaping, no decryption here. All of that is
14
+ handled upstream in `apiClient.js`.
15
+
16
+ ---
17
+
18
+ ## Dependencies to Import
19
+
20
+ - `{ axiosClient }` from `"./apiClient"` — the shared Axios instance
21
+
22
+ No other imports at scaffold time. If session saving is needed in a
23
+ specific handler (e.g. after login), import `saveWebSession` from the
24
+ pages common layer — but only add that import when generating a login
25
+ handler specifically.
26
+
27
+ ---
28
+
29
+ ## Function Generation Rules
30
+
31
+ ### At scaffold time (initialize-project)
32
+ Read `context.api_routes` filtered by `context.current_init.linked_service`.
33
+ For each registered route, generate one exported async function.
34
+
35
+ If no routes exist yet in context (fresh backend), generate only a
36
+ scaffold comment block noting that functions will be added as routes
37
+ are created via `@create-api`.
38
+
39
+ ### When a new route is added via @create-api
40
+ Append one new exported function to this file. Never rewrite the whole
41
+ file — surgical append only.
42
+
43
+ ---
44
+
45
+ ## Function Signature Patterns
46
+
47
+ ### Simple endpoint (no session, no device info)
48
+ The function accepts a single `data` parameter and passes it straight
49
+ to the endpoint. This pattern is used for most standard API calls like
50
+ listing, detail, update, delete operations.
51
+
52
+ ### Auth / Login endpoint
53
+ The function destructures specific fields from its parameter
54
+ (e.g. `{ email, password }`) and builds an explicit payload object.
55
+ This is because the login payload requires additional fields that the
56
+ UI layer does not provide — for example, device information collected
57
+ from a utility function `collectDeviceInfo()` imported from the pages
58
+ layer. After a successful login (response code === 1), the handler
59
+ calls `saveWebSession(res.data)` to persist the session token before
60
+ returning the response.
61
+
62
+ ### Session-aware endpoints
63
+ For endpoints that require the user to be logged in, no special handling
64
+ is needed in the handler — the session token is injected automatically
65
+ by the request interceptor in `apiClient.js`. The handler function
66
+ looks identical to a simple endpoint.
67
+
68
+ ---
69
+
70
+ ## At Scaffold Time — Starter Function Set
71
+
72
+ Generate starter functions for any routes already registered in
73
+ `context.api_routes` for the linked service.
74
+
75
+ If the linked service has no routes yet, generate this file with just
76
+ the import line and a single comment:
77
+
78
+ ```
79
+ // API handler functions will be added here as routes are created.
80
+ // Use @create-api to scaffold a new route, then run @sync to update
81
+ // this file.
82
+ ```
83
+
84
+ ---
85
+
86
+ ## Export Style
87
+
88
+ Each function is a named export using the `export async function` syntax.
89
+ No default export. No barrel index. The calling component imports exactly
90
+ what it needs:
91
+
92
+ `import { webLogin, getHomeStats } from "../../api/apiHandler"`
93
+
94
+ ---
95
+
96
+ ## What This File Does NOT Do
97
+
98
+ - Does not import crypto-js or do any encryption/decryption
99
+ - Does not read localStorage or manage tokens — that is apiClient.js
100
+ - Does not handle errors — errors propagate to the calling component
101
+ - Does not contain any JSX or React imports
102
+ - Does not define any utility functions — only API call wrappers
@@ -0,0 +1,56 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-app-jsx
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # File: src/App.jsx
8
+
9
+ ## Purpose
10
+ The React Router root component. Defines the client-side routing tree
11
+ for the entire application. All pages are registered here. This is the
12
+ only file that imports page components for routing purposes.
13
+
14
+ ---
15
+
16
+ ## Dependencies to Import
17
+
18
+ - `{ BrowserRouter, Routes, Route }` from `"react-router-dom"`
19
+ - `Welcome` from `"./pages/Welcome"` — the default landing page
20
+
21
+ ---
22
+
23
+ ## Structure
24
+
25
+ A single default-exported functional component named `App`.
26
+
27
+ Inside the component, render:
28
+ - `BrowserRouter` as the outermost wrapper
29
+ - `Routes` inside it
30
+ - A single `Route` with `path="/"` rendering `<Welcome />`
31
+
32
+ Additional routes are added here as new pages are scaffolded via
33
+ `@create-api` or future page generation commands.
34
+
35
+ ---
36
+
37
+ ## JSDoc Comment
38
+
39
+ Include a JSDoc block above the component:
40
+ - Description: "Root router component. Defines all client-side routes."
41
+ - No params, no returns needed for a component
42
+
43
+ ---
44
+
45
+ ## Export
46
+
47
+ Default export: `export default App`
48
+
49
+ ---
50
+
51
+ ## What This File Does NOT Do
52
+
53
+ - Does not contain any business logic
54
+ - Does not import API handler functions
55
+ - Does not manage any state
56
+ - Does not define layouts or navigation — those belong in components/layout/
@@ -0,0 +1,175 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-dockerfile
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # File: Dockerfile
8
+
9
+ ## Purpose
10
+ Generates a multi-stage production-ready Dockerfile for the ReactJS service.
11
+ Builds the React app and serves it via nginx with proper SPA routing support.
12
+
13
+ ---
14
+
15
+ ## Template
16
+
17
+ ```dockerfile
18
+ # Stage 1: Build the React application
19
+ FROM node:18-alpine AS builder
20
+
21
+ WORKDIR /app
22
+
23
+ # Copy package files
24
+ COPY package*.json ./
25
+
26
+ # Install dependencies
27
+ RUN npm ci
28
+
29
+ # Copy application code
30
+ COPY . .
31
+
32
+ # Build production bundle
33
+ RUN npm run build
34
+
35
+ # Stage 2: Production nginx server
36
+ FROM nginx:alpine
37
+
38
+ # Copy custom nginx config for SPA routing
39
+ COPY nginx.conf /etc/nginx/conf.d/default.conf
40
+
41
+ # Copy built assets from builder stage
42
+ COPY --from=builder /app/build /usr/share/nginx/html
43
+
44
+ # Expose port 80
45
+ EXPOSE 80
46
+
47
+ # Health check
48
+ HEALTHCHECK --interval=30s --timeout=3s --start-period=10s --retries=3 \
49
+ CMD wget --quiet --tries=1 --spider http://localhost:80/ || exit 1
50
+
51
+ # Start nginx
52
+ CMD ["nginx", "-g", "daemon off;"]
53
+ ```
54
+
55
+ ---
56
+
57
+ ## Companion File: nginx.conf
58
+
59
+ Also generate `<service_name>/nginx.conf`:
60
+
61
+ ```nginx
62
+ server {
63
+ listen 80;
64
+ server_name localhost;
65
+ root /usr/share/nginx/html;
66
+ index index.html;
67
+
68
+ # Gzip compression
69
+ gzip on;
70
+ gzip_vary on;
71
+ gzip_min_length 1024;
72
+ gzip_types text/plain text/css text/xml text/javascript application/javascript application/json application/xml+rss;
73
+
74
+ # Security headers
75
+ add_header X-Frame-Options "SAMEORIGIN" always;
76
+ add_header X-Content-Type-Options "nosniff" always;
77
+ add_header X-XSS-Protection "1; mode=block" always;
78
+ add_header Referrer-Policy "no-referrer-when-downgrade" always;
79
+
80
+ # Cache static assets
81
+ location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
82
+ expires 1y;
83
+ add_header Cache-Control "public, immutable";
84
+ }
85
+
86
+ # SPA routing - send all requests to index.html
87
+ location / {
88
+ try_files $uri $uri/ /index.html;
89
+ }
90
+
91
+ # API proxy (optional - if backend on same host)
92
+ # location /api {
93
+ # proxy_pass http://backend:3000;
94
+ # proxy_http_version 1.1;
95
+ # proxy_set_header Upgrade $http_upgrade;
96
+ # proxy_set_header Connection 'upgrade';
97
+ # proxy_set_header Host $host;
98
+ # proxy_cache_bypass $http_upgrade;
99
+ # }
100
+ }
101
+ ```
102
+
103
+ ---
104
+
105
+ ## File Locations
106
+
107
+ - Write Dockerfile to: `<service_name>/Dockerfile`
108
+ - Write nginx.conf to: `<service_name>/nginx.conf`
109
+
110
+ ---
111
+
112
+ ## Dependencies
113
+
114
+ - Requires `package.json` to exist (Wave 1)
115
+ - Requires `src/` directory and all React components (Wave 3)
116
+ - Can be generated in Wave 4 (post-completion)
117
+
118
+ ---
119
+
120
+ ## What This Dockerfile Does
121
+
122
+ 1. **Multi-stage build** — discards build tools, only keeps compiled assets
123
+ 2. **Nginx Alpine** — minimal production web server (~25MB total image)
124
+ 3. **SPA routing** — all routes fallback to index.html for React Router
125
+ 4. **Gzip compression** — reduces bandwidth usage
126
+ 5. **Security headers** — XSS, clickjacking, MIME-sniffing protection
127
+ 6. **Static asset caching** — 1 year cache for JS/CSS/images
128
+ 7. **Health check** — container orchestration support
129
+
130
+ ---
131
+
132
+ ## Build Arguments (optional enhancement)
133
+
134
+ For advanced builds, support build-time environment variables:
135
+
136
+ ```dockerfile
137
+ # In Stage 1, before RUN npm run build
138
+ ARG REACT_APP_BASE_URL
139
+ ARG REACT_APP_API_KEY
140
+ ARG REACT_APP_KEY
141
+ ARG REACT_APP_IV
142
+ ```
143
+
144
+ This allows building different images for different environments
145
+ without changing .env files.
146
+
147
+ ---
148
+
149
+ ## Notes
150
+
151
+ - Final image size: ~25-35MB (nginx + compiled React bundle)
152
+ - Build time: 2-5 minutes depending on app size
153
+ - The build/ directory from `npm run build` is what gets served
154
+ - nginx handles all HTTP concerns (compression, caching, routing)
155
+ - No Node.js runtime in production image (only build stage)
156
+
157
+ ---
158
+
159
+ ## Security Features
160
+
161
+ - No source code in final image (only compiled bundle)
162
+ - Runs as nginx user (non-root)
163
+ - Security headers prevent common attacks
164
+ - No unnecessary packages or tools in production image
165
+
166
+ ---
167
+
168
+ ## Production Considerations
169
+
170
+ For production, consider:
171
+ 1. Add SSL/TLS configuration to nginx.conf
172
+ 2. Use multi-stage build args for different environments
173
+ 3. Add CSP (Content Security Policy) headers
174
+ 4. Configure nginx access/error logs
175
+ 5. Add rate limiting to nginx
@@ -0,0 +1,58 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-env
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # File: .env and .env.example
8
+
9
+ ## Purpose
10
+ Environment variables for the ReactJS service. All values are inherited
11
+ from the linked backend service — none are typed by the user.
12
+ `.env` is gitignored. `.env.example` is committed with all values blanked
13
+ so other developers know what variables are required.
14
+
15
+ ---
16
+
17
+ ## .env Contents
18
+
19
+ ```
20
+ REACT_APP_BASE_URL=http://localhost:<linked_service_port>/api/v1/
21
+ REACT_APP_API_KEY=<context.current_init.api_key>
22
+ REACT_APP_KEY=<context.current_init.encryption_key>
23
+ REACT_APP_IV=<context.current_init.encryption_iv>
24
+ ```
25
+
26
+ Values are read from:
27
+ - `REACT_APP_BASE_URL` — constructed from `context.current_init.linked_service_port`
28
+ - `REACT_APP_API_KEY` — from `context.current_init.api_key`
29
+ (inherited from `context.services[linked_service].api_key`)
30
+ - `REACT_APP_KEY` — from `context.current_init.encryption_key`
31
+ (inherited from `context.services[linked_service].encryption_key`)
32
+ - `REACT_APP_IV` — from `context.current_init.encryption_iv`
33
+ (inherited from `context.services[linked_service].encryption_iv`)
34
+
35
+ Never ask the user for these values. They are always inherited.
36
+
37
+ ---
38
+
39
+ ## .env.example Contents
40
+
41
+ Same four keys, all values set to empty string:
42
+
43
+ ```
44
+ REACT_APP_BASE_URL=
45
+ REACT_APP_API_KEY=
46
+ REACT_APP_KEY=
47
+ REACT_APP_IV=
48
+ ```
49
+
50
+ ---
51
+
52
+ ## What This File Does NOT Do
53
+
54
+ - Does not include any other environment variables at scaffold time
55
+ - Does not use VITE_ prefix — this project uses Create React App
56
+ (REACT_APP_ prefix)
57
+ - Does not expose any backend secrets beyond what is already required
58
+ to run the frontend
@@ -0,0 +1,49 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-gitignore
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # File: .gitignore
8
+
9
+ ## Purpose
10
+ Defines which files Git should never track for this ReactJS service.
11
+ Generated once during `@initialize-project`.
12
+
13
+ ---
14
+
15
+ ## Contents
16
+
17
+ ### Dependencies
18
+ - `node_modules/`
19
+
20
+ ### Environment variables (sensitive — never commit)
21
+ - `.env`
22
+ - `.env.local`
23
+ - `.env.*.local`
24
+
25
+ ### Build output
26
+ - `build/`
27
+
28
+ ### OS files
29
+ - `.DS_Store`
30
+ - `Thumbs.db`
31
+
32
+ ### IDE files
33
+ - `.vscode/`
34
+ - `.idea/`
35
+ - `*.swp`
36
+ - `*.swo`
37
+
38
+ ### Create React App debug logs
39
+ - `npm-debug.log*`
40
+ - `yarn-debug.log*`
41
+ - `yarn-error.log*`
42
+
43
+ ---
44
+
45
+ ## What This File Does NOT Do
46
+
47
+ - Does not ignore `.env.example` — that file is committed intentionally
48
+ - Does not ignore `public/assets/` — static assets are committed
49
+ - Does not ignore `src/` — all source code is committed
@@ -0,0 +1,54 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-htaccess
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # Files: .htaccess (root) and public/.htaccess
8
+
9
+ ## Purpose
10
+ Apache server configuration for SPA (Single Page Application) routing.
11
+ React Router handles all client-side navigation, but Apache serves files
12
+ from disk. Without these rules, refreshing any non-root URL returns a 404
13
+ because the file does not exist on disk — only `index.html` does.
14
+
15
+ Two files are generated — one at the service root and one inside `public/`.
16
+ This covers both server configurations: where Apache's document root points
17
+ to the project root, and where it points to the `public/` folder.
18
+
19
+ ---
20
+
21
+ ## Root-level .htaccess
22
+
23
+ Purpose: handles routing when Apache's document root is the project root.
24
+ Rewrites all non-file, non-directory requests to `public/index.html`.
25
+
26
+ Rules to include:
27
+ - Enable the rewrite engine
28
+ - Set rewrite base to `/`
29
+ - If the request is not a real file and not a real directory,
30
+ rewrite the request to `public/index.html` internally
31
+
32
+ ---
33
+
34
+ ## public/.htaccess
35
+
36
+ Purpose: handles routing when Apache's document root is the `public/`
37
+ folder (more common in shared hosting and cPanel environments).
38
+ Rewrites all non-file, non-directory requests to `index.html`.
39
+
40
+ Rules to include:
41
+ - Enable the rewrite engine
42
+ - Set rewrite base to `/`
43
+ - If the request is not a real file and not a real directory,
44
+ rewrite the request to `index.html` internally
45
+
46
+ ---
47
+
48
+ ## What These Files Do NOT Do
49
+
50
+ - Do not configure SSL or HTTPS redirects — that is server-level config
51
+ - Do not set cache headers — that is handled at the CDN or server level
52
+ - Do not restrict access to any directory
53
+ - Do not apply to Nginx — a separate `nginx.conf` would be needed
54
+ (out of scope for scaffold)
@@ -0,0 +1,53 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-index-html
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # File: public/index.html
8
+
9
+ ## Purpose
10
+ The single HTML shell for the entire React application. This is the only
11
+ HTML file in the project. It mounts the React app into the `#root` div.
12
+ All page content is rendered by React from `src/index.jsx` onward.
13
+
14
+ ---
15
+
16
+ ## Structure
17
+
18
+ Standard HTML5 document with the following elements:
19
+
20
+ ### `<head>`
21
+ - `charset` meta tag: UTF-8
22
+ - `viewport` meta tag: width=device-width, initial-scale=1
23
+ - `theme-color` meta tag: a neutral default (e.g. `#000000`)
24
+ - `<title>` — from `context.current_init.service_name` in title case
25
+ - Link tag for `%PUBLIC_URL%/favicon.ico`
26
+ - Link tag for `%PUBLIC_URL%/assets/css/style.css` — the global
27
+ stylesheet in the assets folder
28
+
29
+ ### `<body>`
30
+ - A `<noscript>` tag with a message: "You need to enable JavaScript to
31
+ run this app."
32
+ - A `<div id="root"></div>` — this is the React mount point
33
+
34
+ No other scripts or stylesheets. React injects its bundle via
35
+ `react-scripts` at build time.
36
+
37
+ ---
38
+
39
+ ## %PUBLIC_URL% Usage
40
+
41
+ All paths to public assets use the `%PUBLIC_URL%` prefix provided by
42
+ Create React App. This ensures correct paths in both development and
43
+ production builds regardless of the deployment subdirectory.
44
+
45
+ ---
46
+
47
+ ## What This File Does NOT Do
48
+
49
+ - Does not import React directly — that is handled by `src/index.jsx`
50
+ - Does not include any inline JavaScript
51
+ - Does not include CDN links for external libraries — all dependencies
52
+ go through npm in `package.json`
53
+ - Does not include any page content — all content is rendered by React
@@ -0,0 +1,51 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-index-jsx
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # File: src/index.jsx
8
+
9
+ ## Purpose
10
+ The JavaScript entry point for the React application. This is the file
11
+ that `react-scripts` targets when bundling. It mounts the React app
12
+ into the `#root` div defined in `public/index.html`.
13
+
14
+ ---
15
+
16
+ ## Dependencies to Import
17
+
18
+ - `React` from `"react"` — required for JSX in React 17 and below;
19
+ included for compatibility even though React 18 does not require it
20
+ in most cases
21
+ - `{ createRoot }` from `"react-dom/client"` — React 18 concurrent root
22
+ - `App` from `"./App"` — the router root component
23
+
24
+ ---
25
+
26
+ ## Structure
27
+
28
+ Read the `#root` DOM element via `document.getElementById('root')`.
29
+ Call `createRoot(rootElement)` to create a React 18 concurrent root.
30
+ Call `.render(<App />)` on it.
31
+
32
+ No `React.StrictMode` wrapper at scaffold time — the developer adds
33
+ it if needed. Strict mode causes double-renders in development which
34
+ can be confusing when debugging API calls.
35
+
36
+ ---
37
+
38
+ ## Export
39
+
40
+ No exports. This file is the entry point — it is never imported by
41
+ another file.
42
+
43
+ ---
44
+
45
+ ## What This File Does NOT Do
46
+
47
+ - Does not import global CSS — styles are linked in `public/index.html`
48
+ via the `public/assets/css/style.css` link tag
49
+ - Does not configure any providers (Redux, Context) at scaffold time —
50
+ those are added as the project grows
51
+ - Does not contain any business logic
@@ -0,0 +1,77 @@
1
+ ---
2
+ type: task
3
+ name: generate-react-package-json
4
+ agent: reactjs-agent
5
+ ---
6
+
7
+ # File: package.json
8
+
9
+ ## Purpose
10
+ Defines the React project metadata and all dependencies. Generated once
11
+ during `@initialize-project` for a ReactJS service. Uses context values
12
+ for name, description, and author. Includes only packages that are
13
+ actually used in the generated file set — no extras.
14
+
15
+ ---
16
+
17
+ ## Metadata Fields
18
+
19
+ - `name` — from `context.current_init.service_name`
20
+ - `version` — `"1.0.0"`
21
+ - `description` — from `context.current_init.description`
22
+ - `private` — `true`
23
+ - `author` — from `context.current_init.author` (may be empty string)
24
+
25
+ ---
26
+
27
+ ## Scripts
28
+
29
+ - `start` — `react-scripts start`
30
+ - `build` — `react-scripts build`
31
+ - `test` — `react-scripts test`
32
+ - `eject` — `react-scripts eject`
33
+ - `docker:build` — `docker build -t <service_name>:latest .`
34
+ - `docker:run` — `docker run -p 80:80 <service_name>:latest`
35
+ - `docker:stop` — `docker stop $(docker ps -q --filter ancestor=<service_name>:latest)`
36
+
37
+ Replace `<service_name>` with `context.current_init.service_name`.
38
+
39
+ ---
40
+
41
+ ## Dependencies
42
+
43
+ Always include:
44
+ - `react` — core React library
45
+ - `react-dom` — DOM renderer
46
+ - `react-router-dom` — client-side routing (v6)
47
+ - `react-scripts` — Create React App build toolchain
48
+ - `axios` — HTTP client used in apiClient.js
49
+ - `crypto-js` — AES-256-CBC encryption matching the linked backend
50
+
51
+ No other dependencies. Do not add UI libraries, state management
52
+ libraries, or form libraries by default. The developer adds those
53
+ as needed.
54
+
55
+ ---
56
+
57
+ ## Dev Dependencies
58
+
59
+ None required at scaffold time. The developer adds testing libraries
60
+ when they set up tests.
61
+
62
+ ---
63
+
64
+ ## Browserslist
65
+
66
+ Include the standard Create React App browserslist config:
67
+ - Production: `>0.2%`, `not dead`, `not op_mini all`
68
+ - Development: `last 1 chrome version`, `last 1 firefox version`,
69
+ `last 1 safari version`
70
+
71
+ ---
72
+
73
+ ## What This File Does NOT Do
74
+
75
+ - Does not pin exact versions — uses `^` caret ranges
76
+ - Does not include TypeScript configuration
77
+ - Does not configure Jest in package.json