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.
Files changed (111) hide show
  1. package/README.md +13 -1
  2. package/agent/database-agent.md +24 -1
  3. package/agent/nodejs-agent.md +79 -0
  4. package/cli.js +27 -7
  5. package/commands/audit.workflow.md +4 -1
  6. package/commands/db-create-table.workflow.md +1 -1
  7. package/commands/initialize-project.workflow.md +21 -0
  8. package/ide/antigravity/.agents/personas/database-architect.md +431 -153
  9. package/ide/antigravity/.agents/personas/global-orchestrator.md +219 -83
  10. package/ide/antigravity/.agents/personas/nodejs-backend.md +368 -133
  11. package/ide/antigravity/.agents/personas/reactjs-frontend.md +182 -101
  12. package/ide/antigravity/.agents/skills/api-builder/SKILL.md +58 -0
  13. package/ide/antigravity/.agents/skills/code-intelligence/SKILL.md +22 -0
  14. package/ide/antigravity/.agents/skills/database/SKILL.md +32 -0
  15. package/ide/antigravity/.agents/skills/mcp-and-context/SKILL.md +76 -82
  16. package/ide/antigravity/.agents/skills/reactjs/SKILL.md +36 -0
  17. package/ide/antigravity/.agents/workflows/codeninja-api.md +97 -21
  18. package/ide/antigravity/.agents/workflows/codeninja-audit.md +112 -16
  19. package/ide/antigravity/.agents/workflows/codeninja-db-create.md +135 -9
  20. package/ide/antigravity/.agents/workflows/codeninja-db-drop.md +107 -9
  21. package/ide/antigravity/.agents/workflows/codeninja-db-index.md +100 -9
  22. package/ide/antigravity/.agents/workflows/codeninja-db-modify.md +162 -9
  23. package/ide/antigravity/.agents/workflows/codeninja-db-seed.md +102 -8
  24. package/ide/antigravity/.agents/workflows/codeninja-db-sync.md +105 -11
  25. package/ide/antigravity/.agents/workflows/codeninja-debug.md +94 -10
  26. package/ide/antigravity/.agents/workflows/codeninja-design.md +61 -14
  27. package/ide/antigravity/.agents/workflows/codeninja-explain.md +59 -9
  28. package/ide/antigravity/.agents/workflows/codeninja-init.md +518 -21
  29. package/ide/antigravity/.agents/workflows/codeninja-integrate-api.md +451 -9
  30. package/ide/antigravity/.agents/workflows/codeninja-modularize.md +332 -9
  31. package/ide/antigravity/.agents/workflows/codeninja-optimize.md +124 -11
  32. package/ide/antigravity/.agents/workflows/codeninja-refactor.md +69 -16
  33. package/ide/antigravity/.agents/workflows/codeninja-review.md +85 -10
  34. package/ide/antigravity/.agents/workflows/codeninja-sync.md +957 -16
  35. package/ide/antigravity/.agents/workflows/codeninja-test.md +40 -13
  36. package/ide/antigravity/.agents/workflows/codeninja-validate-page.md +546 -9
  37. package/ide/claude-code/.claude/CLAUDE.md +99 -0
  38. package/ide/claude-code/.claude/agents/database-agent.md +535 -0
  39. package/ide/claude-code/.claude/agents/nodejs-agent.md +493 -0
  40. package/ide/claude-code/.claude/agents/reactjs-agent.md +267 -0
  41. package/ide/claude-code/.claude/commands/codeninja-api.md +104 -0
  42. package/ide/claude-code/.claude/commands/codeninja-audit.md +119 -0
  43. package/ide/claude-code/.claude/commands/codeninja-db-create.md +138 -0
  44. package/ide/claude-code/.claude/commands/codeninja-db-drop.md +109 -0
  45. package/ide/claude-code/.claude/commands/codeninja-db-index.md +103 -0
  46. package/ide/claude-code/.claude/commands/codeninja-db-modify.md +165 -0
  47. package/ide/claude-code/.claude/commands/codeninja-db-seed.md +104 -0
  48. package/ide/claude-code/.claude/commands/codeninja-db-sync.md +106 -0
  49. package/ide/claude-code/.claude/commands/codeninja-debug.md +99 -0
  50. package/ide/claude-code/.claude/commands/codeninja-design.md +68 -0
  51. package/ide/claude-code/.claude/commands/codeninja-explain.md +61 -0
  52. package/ide/claude-code/.claude/commands/codeninja-init.md +529 -0
  53. package/ide/claude-code/.claude/commands/codeninja-integrate-api.md +453 -0
  54. package/ide/claude-code/.claude/commands/codeninja-modularize.md +334 -0
  55. package/ide/claude-code/.claude/commands/codeninja-optimize.md +129 -0
  56. package/ide/claude-code/.claude/commands/codeninja-refactor.md +76 -0
  57. package/ide/claude-code/.claude/commands/codeninja-review.md +87 -0
  58. package/ide/claude-code/.claude/commands/codeninja-sync.md +964 -0
  59. package/ide/claude-code/.claude/commands/codeninja-test.md +45 -0
  60. package/ide/claude-code/.claude/commands/codeninja-validate-page.md +548 -0
  61. package/ide/cursor/.cursor/rules/01-global-orchestrator.mdc +40 -38
  62. package/ide/cursor/.cursor/rules/02-mcp-and-context.mdc +47 -31
  63. package/ide/cursor/.cursor/rules/03-api-builder.mdc +30 -58
  64. package/ide/cursor/.cursor/rules/04-nodejs-generation.mdc +58 -0
  65. package/ide/cursor/.cursor/rules/05-database.mdc +54 -0
  66. package/ide/cursor/.cursor/rules/06-reactjs.mdc +36 -0
  67. package/ide/cursor/.cursor/rules/07-reactjs-generation.mdc +49 -0
  68. package/ide/cursor/.cursor/rules/08-code-intelligence.mdc +56 -0
  69. package/ide/cursor/.cursor/rules/09-workflow-steps.mdc +53 -0
  70. package/ide/vscode/.github/copilot-instructions.md +69 -270
  71. package/ide/vscode/.vscode/instructions/code-intelligence.instructions.md +58 -0
  72. package/ide/vscode/.vscode/instructions/database.instructions.md +55 -0
  73. package/ide/vscode/.vscode/instructions/nodejs.instructions.md +77 -0
  74. package/ide/vscode/.vscode/instructions/reactjs.instructions.md +42 -0
  75. package/package.json +2 -2
  76. package/tasks/ask-hashing-library.task.md +31 -0
  77. package/tasks/ask-language-type.task.md +26 -0
  78. package/tasks/ask-new-module-name.task.md +13 -0
  79. package/tasks/ask-new-service-name.task.md +13 -0
  80. package/tasks/ask-old-module-name.task.md +15 -0
  81. package/tasks/ask-old-service-name.task.md +13 -0
  82. package/tasks/ask-orm-type.task.md +26 -0
  83. package/tasks/collect-seed-data.task.md +19 -0
  84. package/tasks/generate-app.task.md +42 -0
  85. package/tasks/generate-common.task.md +13 -0
  86. package/tasks/generate-constants.task.md +13 -0
  87. package/tasks/generate-database.task.md +32 -0
  88. package/tasks/generate-encryption.task.md +28 -0
  89. package/tasks/generate-fast-defaults.task.md +7 -0
  90. package/tasks/generate-hashing.task.md +180 -0
  91. package/tasks/generate-headerValidator.task.md +13 -0
  92. package/tasks/generate-ioRedis.task.md +20 -0
  93. package/tasks/generate-language-en.task.md +12 -0
  94. package/tasks/generate-logging.task.md +12 -0
  95. package/tasks/generate-model.task.md +74 -6
  96. package/tasks/generate-notification.task.md +12 -0
  97. package/tasks/generate-package-json.task.md +69 -0
  98. package/tasks/generate-prisma-client.task.md +56 -0
  99. package/tasks/generate-prisma-schema.task.md +71 -0
  100. package/tasks/generate-rateLimiter.task.md +20 -0
  101. package/tasks/generate-readme.task.md +24 -0
  102. package/tasks/generate-response.task.md +27 -0
  103. package/tasks/generate-route-manager.task.md +32 -0
  104. package/tasks/generate-route.task.md +37 -0
  105. package/tasks/generate-swagger.task.md +8 -0
  106. package/tasks/generate-template.task.md +12 -0
  107. package/tasks/generate-tsconfig.task.md +38 -0
  108. package/tasks/generate-validator.task.md +31 -0
  109. package/ide/cursor/.cursor/rules/04-database.mdc +0 -87
  110. package/ide/cursor/.cursor/rules/05-reactjs.mdc +0 -83
  111. 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
- slash_command: /codeninja:debug
3
- personas: [global-orchestrator, nodejs-backend]
4
- skills: [mcp-and-context, api-builder, code-intelligence]
5
- description: Diagnose and fix a bug by tracing the actual request code path
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
- # /codeninja:debug
8
- Delegates to: `.codeninja/commands/debug.workflow.md`
9
- Before: `context_read`. Gather: error + stack, endpoint, expected vs actual, recent changes.
10
- Trace full request lifecycle. Find exact failure step.
11
- Output: root cause + before/after fix. Confirm before applying.
12
- Suggest one guard to prevent recurrence.
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
- slash_command: /codeninja:design
3
- personas: [global-orchestrator, nodejs-backend OR database-architect]
4
- skills: [mcp-and-context, api-builder OR database]
5
- description: Plan a feature, API contract, or DB change before writing any code
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
- # /codeninja:design
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
- Delegates to: `.codeninja/commands/design.workflow.md`
35
+ 3. Run task: `ask-design-description`
36
+ - Free text: what should this feature do?
37
+ - Stores: `context.current_design.description`
11
38
 
12
- ## Before Running
13
- 1. Call `context_read` — load full project context
14
- 2. Determine if this is an API design (nodejs-backend + api-builder) or DB design (database-architect + database)
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
- ## Execution
17
- Read and execute `design.workflow.md` step by step.
18
- Produce a written plan before any code is generated. User approves plan before execution begins.
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
- ## After Running
21
- Call `context_write` with design notes stored in `context.current_design`.
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
- slash_command: /codeninja:explain
3
- personas: [global-orchestrator, context-aware]
4
- skills: [mcp-and-context, code-intelligence]
5
- description: Explain any file, function, pattern, or concept with full project context
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
- # /codeninja:explain
8
- Delegates to: `.codeninja/commands/explain.workflow.md`
9
- Before: call `context_read`, `fs_read` on target.
10
- Structure: What it is → How it works → Why this way → Where it connects.
11
- Use real names from context. End with offer to explain further.
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?"