codeninja 2.0.0 → 3.1.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 (46) hide show
  1. package/README.md +122 -251
  2. package/agent/global-agent.md +8 -0
  3. package/cli.js +248 -223
  4. package/commands/debug.workflow.md +94 -0
  5. package/commands/explain.workflow.md +59 -0
  6. package/commands/optimize.workflow.md +124 -0
  7. package/commands/review.workflow.md +85 -0
  8. package/ide/antigravity/.agents/personas/database-architect.md +249 -0
  9. package/ide/antigravity/.agents/personas/global-orchestrator.md +125 -0
  10. package/ide/antigravity/.agents/personas/nodejs-backend.md +250 -0
  11. package/ide/antigravity/.agents/personas/reactjs-frontend.md +179 -0
  12. package/ide/antigravity/.agents/skills/api-builder/SKILL.md +179 -0
  13. package/ide/antigravity/.agents/skills/code-intelligence/SKILL.md +184 -0
  14. package/ide/antigravity/.agents/skills/database/SKILL.md +165 -0
  15. package/ide/antigravity/.agents/skills/mcp-and-context/SKILL.md +111 -0
  16. package/ide/antigravity/.agents/skills/reactjs/SKILL.md +211 -0
  17. package/ide/antigravity/.agents/workflows/codeninja-api.md +28 -0
  18. package/ide/antigravity/.agents/workflows/codeninja-audit.md +23 -0
  19. package/ide/antigravity/.agents/workflows/codeninja-db-create.md +11 -0
  20. package/ide/antigravity/.agents/workflows/codeninja-db-drop.md +11 -0
  21. package/ide/antigravity/.agents/workflows/codeninja-db-index.md +11 -0
  22. package/ide/antigravity/.agents/workflows/codeninja-db-modify.md +11 -0
  23. package/ide/antigravity/.agents/workflows/codeninja-db-seed.md +10 -0
  24. package/ide/antigravity/.agents/workflows/codeninja-db-sync.md +12 -0
  25. package/ide/antigravity/.agents/workflows/codeninja-debug.md +12 -0
  26. package/ide/antigravity/.agents/workflows/codeninja-design.md +21 -0
  27. package/ide/antigravity/.agents/workflows/codeninja-explain.md +11 -0
  28. package/ide/antigravity/.agents/workflows/codeninja-init.md +29 -0
  29. package/ide/antigravity/.agents/workflows/codeninja-integrate-api.md +11 -0
  30. package/ide/antigravity/.agents/workflows/codeninja-modularize.md +11 -0
  31. package/ide/antigravity/.agents/workflows/codeninja-optimize.md +13 -0
  32. package/ide/antigravity/.agents/workflows/codeninja-refactor.md +23 -0
  33. package/ide/antigravity/.agents/workflows/codeninja-review.md +12 -0
  34. package/ide/antigravity/.agents/workflows/codeninja-sync.md +23 -0
  35. package/ide/antigravity/.agents/workflows/codeninja-test.md +19 -0
  36. package/ide/antigravity/.agents/workflows/codeninja-validate-page.md +11 -0
  37. package/ide/cursor/.cursor/mcp.json +8 -0
  38. package/ide/cursor/.cursor/rules/01-global-orchestrator.mdc +60 -0
  39. package/ide/cursor/.cursor/rules/02-mcp-and-context.mdc +38 -0
  40. package/ide/cursor/.cursor/rules/03-api-builder.mdc +74 -0
  41. package/ide/cursor/.cursor/rules/04-database.mdc +87 -0
  42. package/ide/cursor/.cursor/rules/05-reactjs.mdc +83 -0
  43. package/ide/cursor/.cursor/rules/06-code-intelligence.mdc +112 -0
  44. package/ide/vscode/.github/copilot-instructions.md +285 -0
  45. package/ide/vscode/.vscode/mcp.json +9 -0
  46. package/package.json +24 -23
package/README.md CHANGED
@@ -1,293 +1,164 @@
1
- # Code Ninja Agent System
1
+ # codeninja
2
2
 
3
- AI-powered agentic scaffolding and development assistant for your project.
3
+ AI agent scaffolding system for Node.js, React, and PostgreSQL projects.
4
+
5
+ **v3.0** — IDE-aware installer. Automatically sets up the right agent structure
6
+ for Antigravity, Cursor, or VS Code / GitHub Copilot.
4
7
 
5
8
  ---
6
9
 
7
- ## Folder Structure
10
+ ## Install
8
11
 
12
+ ```bash
13
+ npx codeninja init
9
14
  ```
10
- .codeninja/agent/
11
- global-agent.md ← Master orchestrator
12
- nodejs-agent.md ← NodeJS backend expert
13
- reactjs-agent.md ← ReactJS frontend expert
14
- database-agent.md ← Database architect (PostgreSQL / MySQL / MongoDB)
15
- designs/ ← @design output files (auto-created)
16
-
17
- .codeninja/commands/
18
- initialize-project.workflow.md
19
- create-api.workflow.md
20
- design.workflow.md
21
- audit.workflow.md
22
- test.workflow.md
23
- refactor.workflow.md
24
- sync.workflow.md
25
- modularize.workflow.md
26
- validate-page.workflow.md
27
- integrate-api.workflow.md
28
- db-create-table.workflow.md
29
- db-modify-table.workflow.md
30
- db-add-index.workflow.md
31
- db-drop-table.workflow.md
32
- db-seed.workflow.md
33
- db-sync.workflow.md
34
-
35
- .codeninja/tasks/
36
- ── Project Info ──────────────────────────────
37
- ask-project-info-doc.task.md
38
- ask-project-scope-of-work.task.md
39
- ask-project-figma.task.md
40
-
41
- ── Repository & Init ─────────────────────────
42
- detect-repository-state.task.md
43
- ask-project-type.task.md
44
- ask-service-name.task.md
45
- ask-service-port.task.md
46
- ask-service-description.task.md
47
- ask-package-name.task.md
48
- ask-package-author.task.md
49
- ask-api-key.task.md
50
- ask-encryption-key.task.md
51
- ask-encryption-iv.task.md
52
- ask-redis-host.task.md
53
- ask-redis-port.task.md
54
- ask-redis-config.task.md
55
- show-init-summary.task.md
56
- ask-client-type.task.md
57
- ask-encrypted-transport.task.md
58
- ask-supported-languages.task.md
59
- ask-init-mode.task.md
60
- generate-fast-defaults.task.md
61
-
62
- ── Database Config ───────────────────────────
63
- ask-database-type.task.md
64
- ask-database-name.task.md
65
- ask-database-host.task.md
66
- ask-database-port.task.md
67
- ask-database-user.task.md
68
- ask-database-config.task.md
69
-
70
- ── Database Table Operations ─────────────────
71
- ask-table-purpose.task.md
72
- ask-table-name.task.md
73
- ask-table-file-number.task.md
74
- ask-table-needs-status.task.md
75
- ask-table-needs-soft-delete.task.md
76
- ask-table-indexes.task.md
77
- ask-table-seed-data.task.md
78
- show-db-table-summary.task.md
79
-
80
- ── Column Operations ─────────────────────────
81
- ask-column-name.task.md
82
- ask-column-type.task.md
83
- ask-column-is-enum.task.md
84
- ask-column-enum-values.task.md
85
- ask-column-position.task.md
86
- ask-old-column-name.task.md
87
- ask-new-column-name.task.md
88
- ask-modify-operation.task.md
89
-
90
- ── Index Operations ──────────────────────────
91
- ask-index-columns.task.md
92
- ask-index-sort-order.task.md
93
- ask-index-type.task.md
94
- ask-index-file-placement.task.md
95
-
96
- ── Seed Data ─────────────────────────────────
97
- ask-seed-rows-count.task.md
98
- ask-seed-row-values.task.md
99
-
100
- ── API & Module Operations ───────────────────
101
- ask-target-service.task.md
102
- ask-react-target-service.task.md
103
- ask-module-name.task.md
104
- ask-http-method.task.md
105
- ask-route-path.task.md
106
- ask-route-description.task.md
107
- ask-primary-table.task.md
108
- ask-requires-auth.task.md
109
- ask-api-version.task.md
110
-
111
- ── ReactJS Page Operations ───────────────────
112
- ask-page-path.task.md
113
- ask-modularize-scope.task.md
114
- ask-validation-library.task.md
115
- ask-api-integration-scope.task.md
116
-
117
- ── Design & Refactor ─────────────────────────
118
- ask-design-target.task.md
119
- ask-feature-name.task.md
120
- ask-design-description.task.md
121
- ask-refactor-type.task.md
122
- ask-table-name.task.md
123
- ask-new-table-name.task.md
124
-
125
- ── Test ──────────────────────────────────────
126
- ask-test-type.task.md
127
-
128
- ── Output & Context ──────────────────────────
129
- write-context.task.md
130
- show-final-summary.task.md
131
-
132
- ── Utilities Generation ──────────────────────────────
133
- generate-encryption.task.md
134
- generate-response.task.md
135
- generate-validator.task.md
136
- generate-headerValidator.task.md
137
- generate-logging.task.md
138
- generate-app.task.md
139
- generate-rateLimiter.task.md
140
- generate-route-manager.task.md
141
- generate-constants.task.md
142
- generate-database.task.md
143
- generate-template.task.md
144
- generate-language-en.task.md
145
- generate-ioRedis.task.md
146
- generate-notification.task.md
147
- generate-common.task.md
148
- generate-route.task.md
149
- generate-model.task.md
150
- generate-enc-dec-html.task.md
151
- generate-enc-dec-php.task.md
152
- generate-package-json.task.md
153
- generate-readme.task.md
154
- generate-gitignore.task.md
155
- generate-swagger.task.md
156
-
157
- ── System Tables ─────────────────────────
158
- generate-tbl-user-deviceinfo.task.md
159
-
160
- .codeninja/context/
161
- context.json ← Shared memory for all agents (auto-managed)
15
+
16
+ Auto-detects your IDE. Force a specific one with `--ide`:
17
+
18
+ ```bash
19
+ npx codeninja init --ide=antigravity # Google Antigravity IDE
20
+ npx codeninja init --ide=cursor # Cursor
21
+ npx codeninja init --ide=vscode # VS Code + GitHub Copilot
22
+ npx codeninja init --ide=all # All three
162
23
  ```
163
24
 
164
25
  ---
165
26
 
166
- ## Available Commands
27
+ ## What gets installed
167
28
 
168
- ### Project Initialization
169
- | Command | Description |
170
- |---|---|
171
- | `@initialize-project` | Bootstrap a new NodeJS service, ReactJS app, or database |
29
+ ### Core (all IDEs)
172
30
 
173
- ### API & Service Development
174
- | Command | Description |
175
- |---|---|
176
- | `@create-api` | Add a new API module to an existing service |
177
- | `@design` | Plan a feature or schema before writing code |
178
- | `@audit` | Review a service for security, quality, and consistency |
179
- | `@test` | Generate or run tests for a module |
180
- | `@refactor` | Rename or restructure code with full change tracking |
181
- | `@sync` | Scan the entire repo and rebuild context.json |
182
-
183
- ### Database Commands
184
- | Command | Description |
185
- |---|---|
186
- | `@db:create-table` | Design and generate a new table following all conventions |
187
- | `@db:modify-table` | Add/rename/drop a column via ALTER migration file |
188
- | `@db:add-index` | Add a new index to an existing table |
189
- | `@db:drop-table` | Generate a DROP migration and clean up context |
190
- | `@db:seed` | Add or update seed data for a table |
191
- | `@db:sync` | Scan migration files and rebuild context.db.schema |
31
+ ```
32
+ .codeninja/
33
+ ├── agent/ ← Agent personas (global, nodejs, reactjs, database)
34
+ ├── commands/ ← Workflow files (one per slash command)
35
+ ├── tasks/ ← Atomic task files referenced by workflows
36
+ ├── context/ ← context.json (project memory, gitignored)
37
+ └── mcp-server.js ← MCP server (context_read, context_write, tools)
38
+ ```
192
39
 
193
- ---
40
+ ### Antigravity IDE
41
+
42
+ ```
43
+ .agents/
44
+ ├── rules/
45
+ │ └── codeninja-persona.md ← Senior architect persona (auto-loaded)
46
+ ├── skills/
47
+ │ └── codeninja/
48
+ │ └── SKILL.md ← Technical standards (auto-loaded)
49
+ └── workflows/
50
+ └── codeninja-*.md ← One file per /codeninja:* slash command
51
+ ```
194
52
 
195
- ## How It Works
53
+ ### Cursor
196
54
 
197
- 1. **You run a command** — e.g. `@initialize-project`
198
- 2. **Global agent activates** — reads `.codeninja/context/context.json` for full awareness
199
- 3. **Project info is collected first (once)** — document, SOW, Figma link → builds project summary
200
- 4. **Workflow runs** routes to the right agent (NodeJS, ReactJS, Database)
201
- 5. **Tasks execute one at a time** — each asks exactly one question
202
- 6. **Single confirmation** — you approve the summary once, then all files are generated
203
- 7. **Context is updated** — every action recorded in `context.json`
55
+ ```
56
+ .cursor/
57
+ ├── rules/
58
+ │ └── codeninja.mdc ← Project rules (auto-loaded for all files)
59
+ └── mcp.json ← MCP server config
60
+ ```
61
+
62
+ ### VS Code / GitHub Copilot
63
+
64
+ ```
65
+ .github/
66
+ └── copilot-instructions.md ← Copilot context (auto-loaded in Agent Mode)
67
+ .vscode/
68
+ └── mcp.json ← MCP server config (uses workspaceFolder)
69
+ ```
204
70
 
205
71
  ---
206
72
 
207
- ## Key Design Principles
73
+ ## Available commands
208
74
 
209
- ### One Question Per Task
210
- Every `ask-*` task collects exactly one value. No multi-field forms.
75
+ ### Project and service
211
76
 
212
- ### Single Confirmation Per Operation
213
- After collecting all required values, a summary is shown once.
214
- You confirm once everything generates. No per-file prompts.
77
+ | Command | Description |
78
+ |---|---|
79
+ | `/codeninja:init` | Bootstrap a new Node.js service, React app, or database |
80
+ | `/codeninja:api` | Add a new API endpoint (full 5-step SOP) |
81
+ | `/codeninja:design` | Plan a feature before coding |
82
+ | `/codeninja:audit` | Security and quality review |
83
+ | `/codeninja:test` | Generate Jest + Supertest tests |
84
+ | `/codeninja:refactor` | Rename with full context tracking |
85
+ | `/codeninja:sync` | Scan repo and rebuild context |
215
86
 
216
- ### Context is the Brain
217
- `.codeninja/context/context.json` is the shared memory for all agents.
218
- - Every service, route, table, column, and change is stored here
219
- - All agents read it before making any decision
220
- - The `change_log` gives a full history of every structural change
87
+ ### Code intelligence (new in v3)
221
88
 
222
- ### Database First
223
- During `@initialize-project`, the database folder is always scaffolded
224
- before any application service code. This ensures NodeJS services are
225
- generated with accurate DB config and column awareness.
89
+ | Command | Description |
90
+ |---|---|
91
+ | `/codeninja:explain` | Explain any file, function, or pattern with full context |
92
+ | `/codeninja:review` | Code review severity-ranked findings with exact fixes |
93
+ | `/codeninja:debug` | Diagnose a bug by tracing the actual code path |
94
+ | `/codeninja:optimize` | Find performance bottlenecks with concrete fixes and impact |
226
95
 
227
- ### Project Info Awareness
228
- When you provide a project document, SOW, or Figma link during initialization,
229
- the agent extracts entities, features, and tech preferences. Every subsequent
230
- command uses this context to make smarter suggestions.
96
+ ### Database
231
97
 
232
- ---
98
+ | Command | Description |
99
+ |---|---|
100
+ | `/codeninja:db:create` | Design and generate a new table with migration |
101
+ | `/codeninja:db:modify` | Add, rename, or drop a column |
102
+ | `/codeninja:db:index` | Add a new index |
103
+ | `/codeninja:db:drop` | Drop a table with migration file |
104
+ | `/codeninja:db:seed` | Add seed data |
105
+ | `/codeninja:db:sync` | Rebuild DB schema in context |
233
106
 
234
- ## Database File Convention
107
+ ### React
235
108
 
236
- Every table follows this structure:
237
- ```
238
- database/
239
- <db_type>/
240
- migrations/
241
- 1-setup-tbl-<name>.sql ← One file per table, numbered
242
- 2-setup-tbl-<name>.sql
243
- ...
244
- 111-setup-database-indexes.sql ← Shared indexes, always last
245
- seeds/
246
- <table>_seed.sql ← Standalone seed files
247
- create-schema.sql ← Auto-generated runner (do not edit)
248
- setup-database.sh ← Linux/Mac setup script
249
- setup-database.ps1 ← Windows setup script
250
- reset-database.sh ← Dev-only full reset (dangerous)
251
- README.md
252
- ```
109
+ | Command | Description |
110
+ |---|---|
111
+ | `@modularize` | Extract layout blocks into reusable components |
112
+ | `@validate-page` | Add client-side form validation |
113
+ | `@integrate-api` | Wire forms to API handler functions |
253
114
 
254
- ### Running the Database
255
- ```bash
256
- # Linux/Mac — creates DB and runs all migrations
257
- cd database/<db_type>
258
- bash setup-database.sh
115
+ ---
259
116
 
260
- # Windows
261
- cd database/<db_type>
262
- .\setup-database.ps1
263
- ```
117
+ ## Architecture: 5-Step SOP
118
+
119
+ Every new API endpoint follows this order, enforced by the agent:
120
+
121
+ 1. **ROUTING** — register in `route_manager.js` (append only, never rewrite)
122
+ 2. **VALIDATION** — validatorjs schema in `route.js`
123
+ 3. **CONTROLLER** — model call + error boundary in `route.js`
124
+ 4. **MODEL** — parameterized SQL in `_model.js` via shared pg pool
125
+ 5. **LOCALIZE** — all strings in `languages/en.js`, never hardcoded
264
126
 
265
127
  ---
266
128
 
267
- ## Multi-Service Projects
129
+ ## Claude Desktop (manual setup)
130
+
131
+ Add to your Claude Desktop config:
132
+
133
+ - macOS: `~/Library/Application Support/Claude/claude_desktop_config.json`
134
+ - Windows: `%APPDATA%\Claude\claude_desktop_config.json`
135
+ - Linux: `~/.config/claude/claude_desktop_config.json`
268
136
 
269
- Each service gets its own entry in `context.services`:
270
137
  ```json
271
138
  {
272
- "services": {
273
- "auth": { "type": "nodejs", "port": 1001 },
274
- "ledger": { "type": "nodejs", "port": 1002 },
275
- "frontend":{ "type": "reactjs", "port": 3000 }
139
+ "mcpServers": {
140
+ "codeninja": {
141
+ "command": "node",
142
+ "args": ["/absolute/path/to/your/project/.codeninja/mcp-server.js"]
143
+ }
276
144
  }
277
145
  }
278
146
  ```
279
147
 
280
- All services share the same `context.db` — they reference the same database
281
- schema and the same table/column names.
148
+ ---
149
+
150
+ ## Requirements
151
+
152
+ - Node.js 18+
153
+ - npm
282
154
 
283
155
  ---
284
156
 
285
- ## Getting Started
157
+ ## What is new in v3.0
286
158
 
287
- 1. Run `@initialize-project`
288
- 2. Answer Phase 0 questions (project doc, SOW, Figma) once per repo
289
- 3. Choose project type (NodeJS, ReactJS, Database)
290
- 4. Configure database
291
- 5. Name your service and configure it
292
- 6. Confirm once everything is generated
293
- 7. Run `@db:create-table` to start adding your first table
159
+ - **IDE-aware installer** — detects Antigravity, Cursor, or VS Code automatically
160
+ - **Antigravity slash commands** full `.agents/` structure with `/codeninja:*` commands
161
+ - **Cursor rules** `.cursor/rules/codeninja.mdc` auto-loaded for every file
162
+ - **VS Code Copilot** — `.github/copilot-instructions.md` for Agent Mode
163
+ - **4 new commands** `explain`, `review`, `debug`, `optimize`
164
+ - **`--ide` flag** force any IDE or install for all three with `--ide=all`
@@ -92,6 +92,10 @@ When activated, always run these steps in order:
92
92
  | `@test` | Generate or run tests for a module |
93
93
  | `@refactor` | Rename or restructure code with full change tracking |
94
94
  | `@sync` | Scan the entire repo and rebuild context.json |
95
+ | `@explain` | Explain any file, function, or pattern with full context |
96
+ | `@review` | Code review with severity-ranked findings and fixes |
97
+ | `@debug` | Diagnose and fix a bug using the real code path |
98
+ | `@optimize` | Find and fix performance bottlenecks with impact estimates |
95
99
 
96
100
  ### ReactJS Commands
97
101
  | Command | Description |
@@ -145,6 +149,10 @@ repository root. Always use these exact paths — never guess or infer.
145
149
  | `@db:drop-table` | `.codeninja/commands/db-drop-table.workflow.md` |
146
150
  | `@db:seed` | `.codeninja/commands/db-seed.workflow.md` |
147
151
  | `@db:sync` | `.codeninja/commands/db-sync.workflow.md` |
152
+ | `@explain` | `.codeninja/commands/explain.workflow.md` |
153
+ | `@review` | `.codeninja/commands/review.workflow.md` |
154
+ | `@debug` | `.codeninja/commands/debug.workflow.md` |
155
+ | `@optimize` | `.codeninja/commands/optimize.workflow.md` |
148
156
 
149
157
  ## Routing Rules
150
158