codeninja 3.2.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 +202 -85
  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 +76 -83
  18. package/ide/antigravity/.agents/workflows/codeninja-audit.md +82 -44
  19. package/ide/antigravity/.agents/workflows/codeninja-db-create.md +107 -94
  20. package/ide/antigravity/.agents/workflows/codeninja-db-drop.md +89 -67
  21. package/ide/antigravity/.agents/workflows/codeninja-db-index.md +86 -54
  22. package/ide/antigravity/.agents/workflows/codeninja-db-modify.md +126 -68
  23. package/ide/antigravity/.agents/workflows/codeninja-db-seed.md +87 -59
  24. package/ide/antigravity/.agents/workflows/codeninja-db-sync.md +77 -41
  25. package/ide/antigravity/.agents/workflows/codeninja-debug.md +35 -21
  26. package/ide/antigravity/.agents/workflows/codeninja-design.md +49 -35
  27. package/ide/antigravity/.agents/workflows/codeninja-explain.md +41 -20
  28. package/ide/antigravity/.agents/workflows/codeninja-init.md +479 -289
  29. package/ide/antigravity/.agents/workflows/codeninja-integrate-api.md +253 -136
  30. package/ide/antigravity/.agents/workflows/codeninja-modularize.md +250 -132
  31. package/ide/antigravity/.agents/workflows/codeninja-optimize.md +71 -29
  32. package/ide/antigravity/.agents/workflows/codeninja-refactor.md +50 -42
  33. package/ide/antigravity/.agents/workflows/codeninja-review.md +38 -21
  34. package/ide/antigravity/.agents/workflows/codeninja-sync.md +922 -141
  35. package/ide/antigravity/.agents/workflows/codeninja-test.md +34 -49
  36. package/ide/antigravity/.agents/workflows/codeninja-validate-page.md +449 -151
  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 +12 -13
  62. package/ide/cursor/.cursor/rules/02-mcp-and-context.mdc +47 -31
  63. package/ide/cursor/.cursor/rules/03-api-builder.mdc +32 -110
  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 +67 -382
  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 -90
  110. package/ide/cursor/.cursor/rules/05-reactjs.mdc +0 -147
  111. package/ide/cursor/.cursor/rules/06-code-intelligence.mdc +0 -112
@@ -1,68 +1,76 @@
1
+ This workflow runs when user invokes /codeninja:refactor
2
+
1
3
  ---
2
- slash_command: /codeninja:refactor
3
- personas: [global-orchestrator, nodejs-backend, database-architect]
4
- skills: [mcp-and-context, api-builder, database, code-intelligence]
5
- description: Rename or restructure code with full context tracking.
4
+ type: workflow
5
+ name: refactor
6
+ description: >
7
+ Rename, restructure, or improve existing code. Always records changes in
8
+ context.change_log so all agents remain aware of the history.
6
9
  ---
7
10
 
8
- # /codeninja:refactor
11
+ # Workflow: @refactor
12
+
13
+ ## Goal
14
+ Make a controlled change to existing code with full traceability in context.
9
15
 
10
- ## Before Running
11
- 1. Call `context_read`
12
- 2. Call `context_check_stale`
16
+ ## Rules
17
+ - Every rename is recorded in `context.change_log`
18
+ - DB column renames generate a migration file
19
+ - Never delete the old name from change_log
13
20
 
14
- ## Execution — Full Step-by-Step
21
+ ---
15
22
 
16
- **Step 1.** Ask: "What type of refactor?"
17
- 1. Rename a DB column
18
- 2. Rename a service
19
- 3. Rename a table
20
- 4. Rename a module
21
- 5. Restructure files
22
- - Store: `context.current_refactor.type`
23
+ ## Step-by-Step Execution
23
24
 
24
- **Step 2.** Ask: "Which service?" (if applicable — skip for DB-only refactors)
25
+ 1. Run task: `ask-refactor-type`
26
+ - Options: rename DB column, rename service, rename module, restructure files
27
+ - Stores: `context.current_refactor.type`
25
28
 
26
- ---
29
+ 2. Run task: `ask-target-service` (if applicable)
27
30
 
28
- ### If "Rename DB column":
29
- - Ask: "Which table?" (list from context)
30
- - Ask: "Which column to rename?" (list current columns)
31
- - Ask: "New column name?" (snake_case)
32
- - Delegate to database-agent:
33
- - Generate ALTER TABLE migration file
31
+ 3. Based on refactor type:
32
+
33
+ ### rename DB column
34
+ - Run task: `ask-table-name`
35
+ - Run task: `ask-old-column-name`
36
+ - Run task: `ask-new-column-name`
37
+ - Delegate to `database-agent`:
38
+ - Generate ALTER TABLE migration
34
39
  - Update `context.db.schema.tables[<table>].columns`
35
40
  - Append to `context.db.schema.change_log`
36
- - Delegate to nodejs-agent:
41
+ - Delegate to `nodejs-agent`:
37
42
  - Find all references to old column name in service files
38
43
  - Update model queries
39
44
  - Update swagger_doc.json
40
45
 
41
- ### If "Rename service":
42
- - Ask: "Current service name?" (list from context)
43
- - Ask: "New service name?"
46
+ ### rename service
47
+ - Run task: `ask-old-service-name`
48
+ - Run task: `ask-new-service-name`
44
49
  - Update `context.services` key
45
50
  - Append to `context.change_log`
46
51
 
47
- ### If "Rename table":
48
- - Ask: "Which table?" (list from context)
49
- - Ask: "New table name?" (must start with tbl_, snake_case)
50
- - Delegate to database-agent:
52
+ ### rename table
53
+ - Run task: `ask-table-name`
54
+ - Run task: `ask-new-table-name`
55
+ - Delegate to `database-agent`:
51
56
  - Generate ALTER migration: `RENAME TABLE <old> TO <new>`
52
57
  - Update `context.db.schema.tables` key
53
- - Append to `context.db.schema.change_log`: `{ type: "table_renamed", from: "<old>", to: "<new>" }`
54
- - Delegate to nodejs-agent:
58
+ - Append to `context.db.schema.change_log`:
59
+ `{ type: "table_renamed", from: "<old>", to: "<new>", migration_file: "..." }`
60
+ - Delegate to `nodejs-agent`:
55
61
  - Find all references to old table name in model files
56
62
  - Update queries in all affected services
57
63
  - Append to top-level `context.change_log`
58
64
 
59
- ### If "Rename module":
60
- - Ask: "Current module name?"
61
- - Ask: "New module name?"
62
- - Delegate to nodejs-agent → rename files and update route_manager
65
+ ### rename module
66
+ - Run task: `ask-old-module-name`
67
+ - Run task: `ask-new-module-name`
68
+ - Delegate to `nodejs-agent` → rename files and update route_manager
63
69
 
64
- ---
70
+ 4. Confirm: "Apply refactor? (yes/no)"
71
+
72
+ > **Multi-agent:** Delegate to `database-architect` (DB refactors) or `nodejs-backend` (service/module refactors) via Task invocation for parallel execution.
73
+ > Read `.codeninja/tasks/` before applying each change.
65
74
 
66
- **Confirm:** "Apply refactor? (yes/no)"
67
- If yes make all changes → call `context_write` → call `context_clear_scratchpad` ["current_refactor"]
68
- Show final summary.
75
+ 5. If yes → make changes → run task: `write-context`
76
+ 6. Run task: `show-final-summary`
@@ -1,29 +1,42 @@
1
+ This workflow runs when user invokes /codeninja:review
2
+
1
3
  ---
2
- slash_command: /codeninja:review
3
- personas: [global-orchestrator, nodejs-backend]
4
- skills: [mcp-and-context, api-builder, code-intelligence]
5
- description: Deep code review with severity-ranked findings and concrete fixes.
4
+ type: workflow
5
+ name: review
6
+ description: >
7
+ Deep code review of any file or module — security, architecture, naming
8
+ conventions, and alignment with project patterns. Outputs severity-ranked
9
+ findings with exact fixes.
6
10
  ---
7
11
 
8
- # /codeninja:review
12
+ # Workflow: @review / /codeninja:review
9
13
 
10
- ## Before Running
11
- 1. Call `context_read`
12
- 2. Call `context_check_stale`
14
+ ## Goal
15
+ Produce a structured code review that finds real issues using actual project
16
+ context — not generic best practices. Every finding references the real file
17
+ and line, and every fix is concrete code, not advice.
18
+
19
+ ## Rules
20
+ - Read the actual file before reviewing it
21
+ - Cross-reference `context.db.schema` for table/column accuracy
22
+ - Compare against 1–2 existing modules to check pattern consistency
23
+ - Never flag something as an issue if it's the established pattern in this project
24
+
25
+ ---
13
26
 
14
- ## Execution — Full Step-by-Step
27
+ ## Step-by-Step Execution
15
28
 
16
29
  ### Step 1 — Identify Target
17
- If not specified, ask: "Which file or module would you like reviewed?"
30
+ If not specified, ask: "Which file or module would you like me to review?"
18
31
 
19
32
  ### Step 2 — Load Context
20
- 1. Call `fs_read` on the target file
21
- 2. Read 1–2 similar modules from `context.services[<service>].modules` for pattern comparison
22
- 3. Cross-reference `context.db.schema` for table/column accuracy
33
+ 1. Call `context_read`
34
+ 2. Call `fs_read` on the target file
35
+ 3. Read 1–2 similar modules from `context.services[<service>].modules` for comparison
23
36
 
24
37
  ### Step 3 — Run Review Checklist
25
38
 
26
- #### Security (CRITICAL if failing)
39
+ #### Security (flag as CRITICAL if failing)
27
40
  - [ ] All POST/PUT/PATCH routes have validatorjs input validation
28
41
  - [ ] API key middleware applied before any route logic
29
42
  - [ ] JWT auth middleware present on protected routes
@@ -31,20 +44,20 @@ If not specified, ask: "Which file or module would you like reviewed?"
31
44
  - [ ] Parameterized queries only — no string concatenation in SQL
32
45
  - [ ] Error responses don't leak stack traces or internal details
33
46
 
34
- #### Architecture (WARNING if failing)
47
+ #### Architecture (flag as WARNING if failing)
35
48
  - [ ] 2-layer rule: no SQL in route.js, no res.json() in model.js
36
49
  - [ ] route_manager.js registration matches route file
37
50
  - [ ] swagger_doc.json has entry for this endpoint
38
51
  - [ ] All user-facing strings in languages/en.js — none hardcoded in route.js
39
52
 
40
- #### Code Quality (SUGGESTION if failing)
53
+ #### Code Quality (flag as SUGGESTION if failing)
41
54
  - [ ] JSDoc on every exported function
42
55
  - [ ] No unused variables or dead imports
43
56
  - [ ] No console.log — project logger used instead
44
57
  - [ ] Async functions have try/catch blocks
45
58
  - [ ] SELECT * not used — explicit column list
46
59
 
47
- #### Database (WARNING if failing)
60
+ #### Database (flag as WARNING if failing)
48
61
  - [ ] Column names match context.db.schema exactly (snake_case)
49
62
  - [ ] Foreign key columns indexed
50
63
  - [ ] Transactions used where multiple writes occur together
@@ -62,9 +75,13 @@ After: the corrected code
62
75
  Why: one sentence explanation
63
76
  ```
64
77
 
65
- End with: `Review complete: X critical · Y warnings · Z suggestions`
78
+ End with summary line:
79
+ ```
80
+ Review complete: X critical · Y warnings · Z suggestions
81
+ ```
66
82
 
67
83
  ### Step 5 — Offer Auto-Fix
68
- "Would you like me to apply any of these fixes?
69
- - SUGGESTION-level: apply all at once
70
- - WARNING/CRITICAL: one at a time, confirm each"
84
+ "Would you like me to apply any of these fixes? I'll confirm each change before writing."
85
+
86
+ For SUGGESTION-level items: offer to apply all at once.
87
+ For WARNING/CRITICAL items: apply one at a time, confirm each.