codeninja 3.1.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.
- package/README.md +13 -1
- 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 +219 -83
- 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 +97 -21
- package/ide/antigravity/.agents/workflows/codeninja-audit.md +112 -16
- package/ide/antigravity/.agents/workflows/codeninja-db-create.md +135 -9
- package/ide/antigravity/.agents/workflows/codeninja-db-drop.md +107 -9
- package/ide/antigravity/.agents/workflows/codeninja-db-index.md +100 -9
- package/ide/antigravity/.agents/workflows/codeninja-db-modify.md +162 -9
- package/ide/antigravity/.agents/workflows/codeninja-db-seed.md +102 -8
- package/ide/antigravity/.agents/workflows/codeninja-db-sync.md +105 -11
- package/ide/antigravity/.agents/workflows/codeninja-debug.md +94 -10
- package/ide/antigravity/.agents/workflows/codeninja-design.md +61 -14
- package/ide/antigravity/.agents/workflows/codeninja-explain.md +59 -9
- package/ide/antigravity/.agents/workflows/codeninja-init.md +518 -21
- package/ide/antigravity/.agents/workflows/codeninja-integrate-api.md +451 -9
- package/ide/antigravity/.agents/workflows/codeninja-modularize.md +332 -9
- package/ide/antigravity/.agents/workflows/codeninja-optimize.md +124 -11
- package/ide/antigravity/.agents/workflows/codeninja-refactor.md +69 -16
- package/ide/antigravity/.agents/workflows/codeninja-review.md +85 -10
- package/ide/antigravity/.agents/workflows/codeninja-sync.md +957 -16
- package/ide/antigravity/.agents/workflows/codeninja-test.md +40 -13
- package/ide/antigravity/.agents/workflows/codeninja-validate-page.md +546 -9
- 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 +40 -38
- package/ide/cursor/.cursor/rules/02-mcp-and-context.mdc +47 -31
- package/ide/cursor/.cursor/rules/03-api-builder.mdc +30 -58
- 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 +69 -270
- 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 -87
- package/ide/cursor/.cursor/rules/05-reactjs.mdc +0 -83
- package/ide/cursor/.cursor/rules/06-code-intelligence.mdc +0 -112
|
@@ -1,12 +1,96 @@
|
|
|
1
|
+
This workflow runs when user invokes /codeninja:debug
|
|
2
|
+
|
|
1
3
|
---
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
type: workflow
|
|
5
|
+
name: debug
|
|
6
|
+
description: >
|
|
7
|
+
Diagnose and fix bugs using full project context — DB schema, middleware
|
|
8
|
+
chain, service config, and established patterns. Traces the exact failure
|
|
9
|
+
path and produces a concrete fix.
|
|
6
10
|
---
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
# Workflow: @debug / /codeninja:debug
|
|
13
|
+
|
|
14
|
+
## Goal
|
|
15
|
+
Find the root cause of a bug and produce a concrete fix using actual project
|
|
16
|
+
context. Never guess — trace the real code path.
|
|
17
|
+
|
|
18
|
+
## Rules
|
|
19
|
+
- Trace the full request path before concluding anything
|
|
20
|
+
- Cross-reference context.db.schema before assuming a DB mismatch
|
|
21
|
+
- Check middleware chain order before assuming an auth issue
|
|
22
|
+
- One question at a time when gathering information
|
|
23
|
+
|
|
24
|
+
---
|
|
25
|
+
|
|
26
|
+
## Step-by-Step Execution
|
|
27
|
+
|
|
28
|
+
### Step 1 — Gather Error Information
|
|
29
|
+
Ask (one at a time if not already provided):
|
|
30
|
+
1. "Paste the full error message and stack trace."
|
|
31
|
+
2. "Which endpoint or operation triggered it? (e.g., POST /v1/scores/submit)"
|
|
32
|
+
3. "What did you expect to happen vs what actually happened?"
|
|
33
|
+
4. "What changed recently before this error appeared?"
|
|
34
|
+
|
|
35
|
+
### Step 2 — Load Context
|
|
36
|
+
1. Call `context_read` — load services, DB schema, project config
|
|
37
|
+
2. Call `fs_read` on the relevant route.js
|
|
38
|
+
3. Call `fs_read` on the relevant _model.js
|
|
39
|
+
4. Call `fs_exists` on the migration file for any table mentioned in the error
|
|
40
|
+
|
|
41
|
+
### Step 3 — Trace the Failure Path
|
|
42
|
+
|
|
43
|
+
Walk the request lifecycle in order:
|
|
44
|
+
```
|
|
45
|
+
Request received
|
|
46
|
+
→ Language middleware (extracts Accept-Language)
|
|
47
|
+
→ API key middleware (validates api-key header)
|
|
48
|
+
→ Auth middleware (validates JWT, if protected)
|
|
49
|
+
→ Validation (validatorjs schema)
|
|
50
|
+
→ Route handler (calls model)
|
|
51
|
+
→ Model function (executes query)
|
|
52
|
+
→ Database (pg pool)
|
|
53
|
+
→ Response formatter
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Mark the exact step where the error occurs.
|
|
57
|
+
|
|
58
|
+
### Step 4 — Check Common Root Causes
|
|
59
|
+
|
|
60
|
+
| Symptom | Check |
|
|
61
|
+
|---|---|
|
|
62
|
+
| `column does not exist` | context.db.schema vs actual column names in model.js |
|
|
63
|
+
| `undefined is not a function` | wrong import path or missing export in model |
|
|
64
|
+
| `Cannot read property of undefined` | missing null check after DB query returns 0 rows |
|
|
65
|
+
| `401 Unauthorized` | middleware order — apiKey middleware applied? header name correct? |
|
|
66
|
+
| `500 Internal Server Error` | missing try/catch around async DB call |
|
|
67
|
+
| `Wrong number of rows` | missing dedup query, RANK vs DENSE_RANK, missing WHERE clause |
|
|
68
|
+
| `Migration not applied` | table exists in code but not in DB — run migration |
|
|
69
|
+
| Stale context data | context.db.schema out of date — suggest /codeninja:db:sync |
|
|
70
|
+
|
|
71
|
+
### Step 5 — Produce Fix
|
|
72
|
+
|
|
73
|
+
```
|
|
74
|
+
Root cause: [one sentence — be precise]
|
|
75
|
+
|
|
76
|
+
Fix:
|
|
77
|
+
File: path/to/file.js
|
|
78
|
+
|
|
79
|
+
Before:
|
|
80
|
+
[the buggy code]
|
|
81
|
+
|
|
82
|
+
After:
|
|
83
|
+
[the corrected code]
|
|
84
|
+
|
|
85
|
+
Why this fixes it: [one sentence]
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
If multiple files need changes, show each one in order.
|
|
89
|
+
|
|
90
|
+
### Step 6 — Verify Plan
|
|
91
|
+
"Before I apply this fix, confirm: does this match what you're seeing?
|
|
92
|
+
Once confirmed, I'll make the changes."
|
|
93
|
+
|
|
94
|
+
### Step 7 — Prevent Recurrence
|
|
95
|
+
After fixing: suggest one guard that prevents this class of bug in the future.
|
|
96
|
+
(e.g., a missing index, an added null check helper, a context convention)
|
|
@@ -1,21 +1,68 @@
|
|
|
1
|
+
This workflow runs when user invokes /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.
|
|
1
10
|
---
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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
|
+
|
|
6
23
|
---
|
|
7
24
|
|
|
8
|
-
|
|
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`
|
|
9
34
|
|
|
10
|
-
|
|
35
|
+
3. Run task: `ask-design-description`
|
|
36
|
+
- Free text: what should this feature do?
|
|
37
|
+
- Stores: `context.current_design.description`
|
|
11
38
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
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
|
+
---
|
|
15
57
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
|
19
64
|
|
|
20
|
-
|
|
21
|
-
|
|
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`
|
|
@@ -1,11 +1,61 @@
|
|
|
1
|
+
This workflow runs when user invokes /codeninja:explain
|
|
2
|
+
|
|
1
3
|
---
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
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.
|
|
6
9
|
---
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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?"
|