nurosys-agents 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 (106) hide show
  1. package/.agent/INSTRUCTIONS.md +82 -0
  2. package/.agent/README.md +483 -0
  3. package/.agent/backend/skills/architect/SKILL.md +436 -0
  4. package/.agent/backend/skills/auth-and-permissions/SKILL.md +168 -0
  5. package/.agent/backend/skills/brainstorm/SKILL.md +127 -0
  6. package/.agent/backend/skills/code-reviewer/SKILL.md +324 -0
  7. package/.agent/backend/skills/create-blueprint/SKILL.md +650 -0
  8. package/.agent/backend/skills/debug-issue/SKILL.md +53 -0
  9. package/.agent/backend/skills/explore-codebase/SKILL.md +45 -0
  10. package/.agent/backend/skills/quick-execute/SKILL.md +99 -0
  11. package/.agent/backend/skills/refactor-safely/SKILL.md +46 -0
  12. package/.agent/backend/skills/security-assessment/SKILL.md +174 -0
  13. package/.agent/backend/workflows/module-runner.claude.md +226 -0
  14. package/.agent/backend/workflows/module-runner.codex.md +155 -0
  15. package/.agent/backend/workflows/module-runner.cursor.md +212 -0
  16. package/.agent/frontend/skills/architect/SKILL.md +644 -0
  17. package/.agent/frontend/skills/auth-and-permissions/SKILL.md +43 -0
  18. package/.agent/frontend/skills/create-blueprint/SKILL.md +635 -0
  19. package/.agent/frontend/skills/debug-issue/SKILL.md +28 -0
  20. package/.agent/frontend/skills/explore-codebase/SKILL.md +29 -0
  21. package/.agent/frontend/skills/feature-workflow/SKILL.md +61 -0
  22. package/.agent/frontend/skills/react-quality-review/SKILL.md +126 -0
  23. package/.agent/frontend/skills/react-quality-review/examples.md +24 -0
  24. package/.agent/frontend/skills/react-quality-review/rules/_sections.md +26 -0
  25. package/.agent/frontend/skills/react-quality-review/rules/_template.md +28 -0
  26. package/.agent/frontend/skills/react-quality-review/rules/advanced-event-handler-refs.md +55 -0
  27. package/.agent/frontend/skills/react-quality-review/rules/advanced-init-once.md +42 -0
  28. package/.agent/frontend/skills/react-quality-review/rules/react-rules-calling.md +66 -0
  29. package/.agent/frontend/skills/react-quality-review/rules/react-rules-hooks.md +91 -0
  30. package/.agent/frontend/skills/react-quality-review/rules/react-rules-purity.md +121 -0
  31. package/.agent/frontend/skills/react-quality-review/rules/rendering-activity.md +26 -0
  32. package/.agent/frontend/skills/react-quality-review/rules/rendering-conditional-render.md +40 -0
  33. package/.agent/frontend/skills/react-quality-review/rules/rendering-content-visibility.md +38 -0
  34. package/.agent/frontend/skills/react-quality-review/rules/rendering-hoist-jsx.md +46 -0
  35. package/.agent/frontend/skills/react-quality-review/rules/rendering-usetransition-loading.md +75 -0
  36. package/.agent/frontend/skills/react-quality-review/rules/rerender-defer-reads.md +39 -0
  37. package/.agent/frontend/skills/react-quality-review/rules/rerender-dependencies.md +45 -0
  38. package/.agent/frontend/skills/react-quality-review/rules/rerender-derived-state-no-effect.md +40 -0
  39. package/.agent/frontend/skills/react-quality-review/rules/rerender-derived-state.md +29 -0
  40. package/.agent/frontend/skills/react-quality-review/rules/rerender-functional-setstate.md +74 -0
  41. package/.agent/frontend/skills/react-quality-review/rules/rerender-lazy-state-init.md +58 -0
  42. package/.agent/frontend/skills/react-quality-review/rules/rerender-memo-with-default-value.md +38 -0
  43. package/.agent/frontend/skills/react-quality-review/rules/rerender-memo.md +44 -0
  44. package/.agent/frontend/skills/react-quality-review/rules/rerender-move-effect-to-event.md +45 -0
  45. package/.agent/frontend/skills/react-quality-review/rules/rerender-no-inline-components.md +82 -0
  46. package/.agent/frontend/skills/react-quality-review/rules/rerender-simple-expression-in-memo.md +35 -0
  47. package/.agent/frontend/skills/react-quality-review/rules/rerender-transitions.md +40 -0
  48. package/.agent/frontend/skills/react-quality-review/rules/rerender-use-ref-transient-values.md +73 -0
  49. package/.agent/frontend/skills/refactor-safely/SKILL.md +29 -0
  50. package/.agent/frontend/skills/vuexy-component-guide/SKILL.md +369 -0
  51. package/.agent/frontend/skills/vuexy-component-guide/examples.md +662 -0
  52. package/.agent/frontend/skills/vuexy-component-guide/reference.md +1036 -0
  53. package/.agent/frontend/workflows/build-feature-react.workflow.md +82 -0
  54. package/.agent/frontend/workflows/feature-module-runner.md +101 -0
  55. package/.agent/monolith/skills/architect/SKILL.md +648 -0
  56. package/.agent/monolith/skills/auth-and-permissions/SKILL.md +43 -0
  57. package/.agent/monolith/skills/code-reviewer/SKILL.md +281 -0
  58. package/.agent/monolith/skills/create-blueprint/SKILL.md +635 -0
  59. package/.agent/monolith/skills/debug-issue/SKILL.md +28 -0
  60. package/.agent/monolith/skills/explore-codebase/SKILL.md +29 -0
  61. package/.agent/monolith/skills/feature-workflow/SKILL.md +61 -0
  62. package/.agent/monolith/skills/react-quality-review/SKILL.md +126 -0
  63. package/.agent/monolith/skills/react-quality-review/examples.md +24 -0
  64. package/.agent/monolith/skills/react-quality-review/rules/_sections.md +26 -0
  65. package/.agent/monolith/skills/react-quality-review/rules/_template.md +28 -0
  66. package/.agent/monolith/skills/react-quality-review/rules/advanced-event-handler-refs.md +55 -0
  67. package/.agent/monolith/skills/react-quality-review/rules/advanced-init-once.md +42 -0
  68. package/.agent/monolith/skills/react-quality-review/rules/react-rules-calling.md +66 -0
  69. package/.agent/monolith/skills/react-quality-review/rules/react-rules-hooks.md +91 -0
  70. package/.agent/monolith/skills/react-quality-review/rules/react-rules-purity.md +121 -0
  71. package/.agent/monolith/skills/react-quality-review/rules/rendering-activity.md +26 -0
  72. package/.agent/monolith/skills/react-quality-review/rules/rendering-conditional-render.md +40 -0
  73. package/.agent/monolith/skills/react-quality-review/rules/rendering-content-visibility.md +38 -0
  74. package/.agent/monolith/skills/react-quality-review/rules/rendering-hoist-jsx.md +46 -0
  75. package/.agent/monolith/skills/react-quality-review/rules/rendering-usetransition-loading.md +75 -0
  76. package/.agent/monolith/skills/react-quality-review/rules/rerender-defer-reads.md +39 -0
  77. package/.agent/monolith/skills/react-quality-review/rules/rerender-dependencies.md +45 -0
  78. package/.agent/monolith/skills/react-quality-review/rules/rerender-derived-state-no-effect.md +40 -0
  79. package/.agent/monolith/skills/react-quality-review/rules/rerender-derived-state.md +29 -0
  80. package/.agent/monolith/skills/react-quality-review/rules/rerender-functional-setstate.md +74 -0
  81. package/.agent/monolith/skills/react-quality-review/rules/rerender-lazy-state-init.md +58 -0
  82. package/.agent/monolith/skills/react-quality-review/rules/rerender-memo-with-default-value.md +38 -0
  83. package/.agent/monolith/skills/react-quality-review/rules/rerender-memo.md +44 -0
  84. package/.agent/monolith/skills/react-quality-review/rules/rerender-move-effect-to-event.md +45 -0
  85. package/.agent/monolith/skills/react-quality-review/rules/rerender-no-inline-components.md +82 -0
  86. package/.agent/monolith/skills/react-quality-review/rules/rerender-simple-expression-in-memo.md +35 -0
  87. package/.agent/monolith/skills/react-quality-review/rules/rerender-transitions.md +40 -0
  88. package/.agent/monolith/skills/react-quality-review/rules/rerender-use-ref-transient-values.md +73 -0
  89. package/.agent/monolith/skills/refactor-safely/SKILL.md +29 -0
  90. package/.agent/monolith/skills/vuexy-component-guide/SKILL.md +369 -0
  91. package/.agent/monolith/skills/vuexy-component-guide/examples.md +662 -0
  92. package/.agent/monolith/skills/vuexy-component-guide/reference.md +1036 -0
  93. package/.agent/monolith/workflows/add-new-api-feature-module.md +63 -0
  94. package/.agent/monolith/workflows/backend-quality-review.md +27 -0
  95. package/.agent/monolith/workflows/build-feature-backend.workflow.md +91 -0
  96. package/.agent/monolith/workflows/build-feature-react.workflow.md +82 -0
  97. package/.agent/monolith/workflows/feature-module-runner.md +97 -0
  98. package/.agent/templates/FEATURE_PLAN.md +42 -0
  99. package/.agent/templates/MODULE.md +45 -0
  100. package/.agent/templates/REVIEW_REPORT.md +44 -0
  101. package/.agent/templates/SECURITY_REPORT.md +70 -0
  102. package/.agent/templates/TEST_PLAN.md +49 -0
  103. package/README.md +131 -0
  104. package/package.json +42 -0
  105. package/scripts/setup-rules.js +224 -0
  106. package/scripts/setup.js +518 -0
@@ -0,0 +1,63 @@
1
+ # Workflow: Add a new API feature module
2
+
3
+ When you need a new set of endpoints — e.g. a new resource or integration — add a feature module under `src/apis/` and wire it in ApisModule.
4
+
5
+ ## Prerequisites
6
+
7
+ - Feature is clearly scoped (routes, DTOs, one or more services).
8
+ - You know whether it needs auth (Guardian), RBAC (CanPermissionsGuard + permission), and which Core/Common services it will use.
9
+ - Read `project-memory/repo-map.md` for the full module inventory and reusable components registry.
10
+
11
+ ## Module placement rules
12
+
13
+ - **New API feature**: Create a folder under `src/apis/` and register in `apis.module.ts`.
14
+ - **New shared service used by APIs**: Prefer `src/common/` (app-level) or a new lib under `libs/` if reusable across projects.
15
+ - **New core capability** (guard, auth, config, datasource): Under `src/core/`. Export from CoreModule.
16
+
17
+ ### Do / Don't
18
+
19
+ - **Do**: Add new feature modules under `src/apis/` and register in ApisModule.
20
+ - **Do**: Use existing CoreModule exports for auth, config, logger.
21
+ - **Do**: Use `@can/common`, `@can/aws`, `@can/notification`, `@can/state-machine` path aliases for lib imports.
22
+ - **Don't**: Create circular dependencies between CoreModule and ApisModule.
23
+ - **Don't**: Put API controllers in CoreModule; keep Core for auth, config, datasource, user, logger.
24
+ - **Don't**: Duplicate services that already exist in the Reusable Components Registry (`project-memory/repo-map.md`).
25
+
26
+ ## Steps
27
+
28
+ 1. **Create feature folder under src/apis/**
29
+ - Example: `src/apis/my-feature/`.
30
+ - Add: `my-feature.module.ts`, `my-feature.controller.ts`, `my-feature.service.ts`, and as needed: DTOs (`*.dto.ts`), model, repository (if DB), or types.
31
+
32
+ 2. **Implement module**
33
+ - In `my-feature.module.ts`: Import only what you need (e.g. SharedModule, or specific modules for Redis/Cache/Guardian). Declare controller and providers (service, etc.). Export service if other API modules need it.
34
+ - Controller: Define routes, apply guards (`CanAuthGuard`, `CanPermissionsGuard`), `@CanPermissions` if needed, and use `@CurrentUser()` for UserContext when required.
35
+ - Service: Put business logic here; call Core or Common services via dependency injection. Do not put SQL or auth logic in the controller.
36
+
37
+ 3. **Register in ApisModule**
38
+ - Open `src/apis/apis.module.ts`.
39
+ - Add `import { MyFeatureModule } from './my-feature/my-feature.module';` and add `MyFeatureModule` to the `imports` array.
40
+
41
+ 4. **Register DB model (if applicable)**
42
+ - Add the model to `src/include.models.ts`.
43
+
44
+ 5. **Routes and prefix**
45
+ - Global prefix is `/v1` (set in main.ts). Controller path (e.g. `@Controller('my-feature')`) gives `/v1/my-feature/...`. Document in Swagger via existing Swagger setup if desired.
46
+
47
+ 6. **Tests**
48
+ - Add unit tests for service (and controller if complex) in `*.spec.ts` next to the implementation. Use existing Jest config (roots: src, libs; moduleNameMapper for @can/*).
49
+ - Optionally add e2e in `test/` with `*.e2e-spec.ts` and jest-e2e.json.
50
+
51
+ 7. **Documentation**
52
+ - Update `project-memory/repo-map.md` under `src/apis/` table with the new feature path and role.
53
+ - Add or link API usage docs (e.g. in api-documentation/ or README) for the new routes.
54
+
55
+ ## References
56
+
57
+ - `.agent/skills/auth-and-permissions/SKILL.md` — when the module touches auth-sensitive surfaces
58
+ - `project-memory/constitution.md` — non-negotiables and project structure rules
59
+ - `project-memory/repo-map.md` — module inventory and reusable components
60
+
61
+ ## Out of scope
62
+
63
+ - Changing CoreModule or auth contract; consume them as-is unless there's a clear requirement to extend.
@@ -0,0 +1,27 @@
1
+ ---
2
+ name: backend-quality-review
3
+ description: Post-implementation backend quality gate. Runs after implementation is complete, before merge/PR, or when the user asks for a backend quality review. Delegates to the code-reviewer skill for the full structured review.
4
+ ---
5
+
6
+ You are running a post-implementation backend quality gate for this Node/NestJS codebase.
7
+
8
+ ## When invoked
9
+
10
+ Use this workflow when:
11
+ - Implementation of a feature module or milestone is complete.
12
+ - User asks for a backend quality review, quality gate, or pre-merge check.
13
+ - End of a feature-module-runner workflow cycle.
14
+
15
+ ## What to do
16
+
17
+ Execute the full review defined in `.agent/skills/code-reviewer/SKILL.md`.
18
+
19
+ Follow all six phases in that skill exactly:
20
+ 1. Understand the change surface (git diff, graph tools, infer feature/milestone).
21
+ 2. Load all project-memory context docs.
22
+ 3. Review changed code against all checklist categories.
23
+ 4. Determine the output location for the report.
24
+ 5. Write the structured review report.
25
+ 6. Report findings inline to the user.
26
+
27
+ No steps in this workflow supersede or replace the skill — run it in full.
@@ -0,0 +1,91 @@
1
+ # Workflow: Build Backend Feature (Gated)
2
+
3
+ Orchestrates backend feature delivery with mandatory plan approval, implementation, quality review, and tests.
4
+
5
+ ## Hard rule
6
+
7
+ - **No code changes before plan approval.**
8
+ - In Phase 1, produce the plan file and **stop**.
9
+ - Do not edit `src/`, `libs/`, configs, or tests until explicit approval is received.
10
+
11
+ ## Prerequisites
12
+
13
+ - Feature request/scope is available.
14
+ - Repository has `project-memory/quality-playbook.md`.
15
+
16
+ ## Phase 1 — Plan Only (Approval Gate)
17
+
18
+ 1. **Read context (mandatory)**
19
+ - Read `project-memory/constitution.md`.
20
+ - Read `project-memory/repo-map.md`.
21
+ - Identify touched modules, auth/validation impact, and risk areas.
22
+
23
+ 2. **Prepare plan template source**
24
+ - Use `.agent/templates/FEATURE_PLAN.md`.
25
+
26
+ 3. **Generate plan**
27
+ - Create `documentation/plans/FEATURE_PLAN_BACKEND.md` using the template above.
28
+ - Include: scope, touched modules/files, auth/validation impacts, risks, rollout notes, and verification outline.
29
+
30
+ 4. **Stop and wait**
31
+ - Return for approval with the plan path.
32
+ - **Do not implement anything** before approval.
33
+
34
+ ## Phase 2 — Implement (Post-Approval Only)
35
+
36
+ 1. Implement exactly the approved plan.
37
+ 2. Keep changes minimal and scoped to planned files.
38
+ 3. Apply backend guardrails from:
39
+ - `project-memory/quality-playbook.md`
40
+ - `project-memory/auth-model.md` for auth-sensitive paths.
41
+
42
+ ## Phase 3 — Backend Quality Review
43
+
44
+ 1. **Identify changed files** — Run `git diff` or list files touched in this feature/module.
45
+ 2. **Read the playbook** — Open `project-memory/quality-playbook.md` and build a checklist from its categories for the changed files.
46
+ 3. **Apply checks** — For each changed file, validate against all applicable playbook categories:
47
+ - Async & errors: no unhandled promise rejections, no swallowed async failures, consistent error envelopes.
48
+ - Input validation at controller boundaries (DTOs/pipes).
49
+ - Auth/authz: ownership/tenant checks beyond guard-level auth.
50
+ - Timeouts/retries for outbound calls (HTTP/DB/cache/external APIs).
51
+ - No blocking sync on hot paths; pagination/limits on list endpoints.
52
+ - No secrets/PII in logs; no hardcoded secrets or raw `process.env` in feature logic.
53
+ - DI/module boundaries, controller/service layering, response contracts, test adequacy.
54
+ - Record only concrete findings tied to actual code paths.
55
+ 4. **Write review report** — Create `documentation/reports/REVIEW_REPORT_BACKEND.md` using `.agent/templates/REVIEW_REPORT.md`. Include: findings table (severity, impact, proposed fix, files), required fixes, optional refactors, pass/fail by category.
56
+ 5. **Propose minimal refactors** — For each finding, provide the smallest safe fix with rationale, diff scope, exact file paths, and verification notes.
57
+ 6. Apply agreed fixes before proceeding.
58
+
59
+ ## Phase 4 — Test Plan + Tests
60
+
61
+ 1. **Create test plan**
62
+ - Create `documentation/plans/TEST_PLAN_BACKEND.md`.
63
+ - Use `.agent/templates/TEST_PLAN.md`.
64
+ 2. **Implement tests**
65
+ - Add/update unit and/or e2e tests per plan.
66
+ 3. **Run test commands (if present)**
67
+ - `npm run test`
68
+ - `npm run test:e2e`
69
+ - `npm run test:cov` (optional when needed)
70
+ 4. Capture pass/fail outcomes and unresolved gaps in the review report.
71
+
72
+ ## Phase 5 — Documentation Update
73
+
74
+ 1. **Create or update `MODULE.md`**
75
+ - In the feature module directory (e.g. `src/apis/{feature-name}/MODULE.md`).
76
+ - Use `.agent/templates/MODULE.md` as the template.
77
+ - Document: purpose, files, exports, DI dependencies, DB models, reusable patterns.
78
+ 2. **Update `project-memory/repo-map.md`**
79
+ - Add a one-line entry in the `src/apis/` table with `MODULE.md` column marked ✅.
80
+ - If the module introduced any reusable service/pattern, add it to the **Reusable Components Registry**.
81
+
82
+ ## Deliverables
83
+
84
+ - `documentation/plans/FEATURE_PLAN_BACKEND.md` (approval-gated)
85
+ - Implementation changes (post-approval)
86
+ - `documentation/reports/REVIEW_REPORT_BACKEND.md`
87
+ - `documentation/plans/TEST_PLAN_BACKEND.md`
88
+ - Test updates + command results
89
+ - `src/apis/{feature-name}/MODULE.md`
90
+ - Updated `project-memory/repo-map.md`
91
+
@@ -0,0 +1,82 @@
1
+ ---
2
+ name: build-feature
3
+ description: Strict end-to-end feature workflow with mandatory plan approval, implementation, quality review, and testing.
4
+ strict_mode: true
5
+ owner: agent
6
+ references:
7
+ - project-memory/constitution.md
8
+ - project-memory/repo-map.md
9
+ - project-memory/auth-model.md
10
+ - project-memory/quality-playbook.md
11
+ - project-memory/core-memory.md
12
+ - .agent/skills/feature-workflow/SKILL.md
13
+ - .agent/skills/auth-and-permissions/SKILL.md
14
+ - .agent/skills/react-quality-review/SKILL.md
15
+ - .agent/templates/FEATURE_PLAN.md
16
+ - .agent/templates/REVIEW_REPORT.md
17
+ - .agent/templates/TEST_PLAN.md
18
+ outputs:
19
+ - Documentation/plans/FEATURE_PLAN.md (or Documentation/features/<feature_name>/ when running a named feature)
20
+ - Documentation/reports/REVIEW_REPORT.md
21
+ - Documentation/plans/TEST_PLAN.md (or Documentation/features/<feature_name>/ when running a named feature)
22
+ ---
23
+
24
+ # Build Feature Workflow (Strict)
25
+
26
+ ## Non-negotiable gate
27
+
28
+ - Always load and follow `project-memory/constitution.md`.
29
+ - Always read `project-memory/quality-playbook.md`.
30
+ - Always read and maintain `project-memory/core-memory.md`.
31
+ - **No coding before plan approval.**
32
+ - Required artifacts:
33
+ - Feature plan: `Documentation/features/<feature_name>/FEATURE_PLAN.md` or `Documentation/plans/FEATURE_PLAN.md`
34
+ - Review report: `Documentation/reports/REVIEW_REPORT.md`
35
+ - Test plan: `Documentation/features/<feature_name>/TEST_PLAN.md` or `Documentation/plans/TEST_PLAN.md`
36
+
37
+ ## Steps
38
+
39
+ 1. **Load foundation docs**
40
+ - Read `project-memory/constitution.md`, `project-memory/repo-map.md`, and `project-memory/auth-model.md`.
41
+ - Confirm constraints relevant to the request.
42
+
43
+ 2. **Run feature workflow skill and create plan**
44
+ - Use `.agent/skills/feature-workflow/SKILL.md`.
45
+ - Generate the feature plan in `Documentation/features/<feature_name>/FEATURE_PLAN.md` or `Documentation/plans/FEATURE_PLAN.md` from `.agent/templates/FEATURE_PLAN.md`.
46
+
47
+ 3. **Approval checkpoint (hard stop)**
48
+ - Present plan and stop for explicit approval.
49
+ - Do not modify implementation files before approval.
50
+
51
+ 4. **Implement after approval**
52
+ - Execute the approved file touch list in order.
53
+ - Keep pages thin and move logic into `src/views/**`, hooks, and services.
54
+
55
+ 5. **Conditional auth-and-permissions pass**
56
+ - Run `.agent/skills/auth-and-permissions/SKILL.md` when touching:
57
+ - `src/contexts/authContext.tsx`
58
+ - `src/utils/auth.ts`
59
+ - `src/configs/authConfig.ts`
60
+ - `src/types/auth.ts`
61
+ - protected pages under `src/app/[lang]/(dashboard)/(private)/**`
62
+ - auth-sensitive API routes under `src/app/api/**`
63
+
64
+ 6. **Run quality review and produce report**
65
+ - Run `.agent/skills/react-quality-review/SKILL.md`.
66
+ - Create `Documentation/reports/REVIEW_REPORT.md` from `.agent/templates/REVIEW_REPORT.md`.
67
+ - Apply required refactors from findings.
68
+
69
+ 7. **Generate and execute test plan**
70
+ - Create the test plan in `Documentation/features/<feature_name>/TEST_PLAN.md` or `Documentation/plans/TEST_PLAN.md` from `.agent/templates/TEST_PLAN.md`.
71
+ - Add/update relevant tests (unit/integration/manual).
72
+
73
+ 8. **Run test commands**
74
+ - Run available scripts (`npm run test`, `npm run lint`, feature-specific tests).
75
+ - Record command outcomes in the test plan file (Documentation/plans or Documentation/features/<feature_name>/).
76
+
77
+ 9. **Update core memory**
78
+ - Append the completed module or feature summary to `project-memory/core-memory.md`.
79
+ - Include files changed, decisions made, tests run, and follow-up notes for future work.
80
+
81
+ 10. **Final output**
82
+ - Return summary of files changed, verification steps, and test results.
@@ -0,0 +1,97 @@
1
+ ---
2
+ description: Executes a SINGLE module from a feature folder. Implements, tests, reviews, fixes, and updates docs for that one module only. Invoked per-module by the orchestrator script (scripts/run-feature-modules.sh).
3
+ ---
4
+
5
+ You are a single-module runner. You execute **exactly one module** of a multi-module feature. The orchestrator script (`scripts/run-feature-modules.sh`) handles sequencing — your job is the full lifecycle for the module number you are given.
6
+
7
+ **Orchestrator gate:** After each module’s Cursor agent session completes successfully, the script runs `npm run build` and `npm run test` before launching the next module. If that gate fails, fix the tree and resume from the same module number. Each agent invocation uses `--model auto` (do not change the script to a fixed model for those sessions).
8
+
9
+ ## Input (provided in prompt)
10
+
11
+ - **Feature folder** — e.g. `documentation/features/categories_and_amazon_catalog`
12
+ - **Feature name** — derived from folder, e.g. `categories_and_amazon_catalog`
13
+ - **Module number** — e.g. `1`
14
+ - **Module file** — path to the module prompt, e.g. `documentation/features/.../..._MODULE_1_MODEL_LAYER.md`
15
+
16
+ ---
17
+
18
+ ## Setup — Read foundational docs
19
+
20
+ Read these files first. They provide the rules and patterns you must follow.
21
+
22
+ | File | Why |
23
+ |------|-----|
24
+ | `project-memory/constitution.md` | Non-negotiable safety rules |
25
+ | `project-memory/quality-playbook.md` | Review checklist categories |
26
+ | `project-memory/core-memory.md` | Feature history and prior decisions |
27
+ | `.agent/workflows/build-feature-backend.workflow.md` | Implementation lifecycle phases |
28
+ | `.agent/workflows/add-new-api-feature-module.md` | Module placement rules |
29
+
30
+ ---
31
+
32
+ ## Step A — Implement
33
+
34
+ 1. **Read the module prompt file** (the path is given in your input).
35
+ 2. The prompt contains curated repo-map context and the full module specification. Follow it.
36
+ 3. **Generate the feature plan** per `build-feature-backend.workflow.md` Phase 1, saving to `documentation/plans/FEATURE_PLAN_BACKEND_<feature_name>_M<N>.md`.
37
+ 4. **Self-approve the plan and implement.** The master plan was already user-approved. Do not stop for human approval. Proceed directly to Phase 2.
38
+ 5. Follow `add-new-api-feature-module.md` for module placement and Do/Don't rules.
39
+
40
+ ## Step B — Verify
41
+
42
+ Run these checks after implementation. Fix issues before finishing.
43
+
44
+ 1. **Run tests**
45
+ - Scope to the feature area if possible (e.g. `npm run test -- --testPathPattern=<feature-name>`).
46
+ - Otherwise run `npm run test`.
47
+ - Note any failures.
48
+
49
+ 2. **Quality review**
50
+ - Identify changed files (`git diff --name-only`).
51
+ - Apply `quality-playbook.md` checks to changed files.
52
+ - Write review report to `documentation/reports/REVIEW_REPORT_BACKEND_<feature_name>_M<N>.md` using `.agent/templates/REVIEW_REPORT.md`.
53
+ - Save a copy as `documentation/features/<feature_name>/REVIEW_MODULE_<N>.md`.
54
+
55
+ 3. **Fix and re-verify**
56
+ - If the review has **required fixes** or tests failed, implement fixes.
57
+ - Re-run tests. If fixes touched reviewed code, re-check against the playbook.
58
+ - Repeat until tests pass and no required findings remain.
59
+ - If a fix cannot be resolved after two attempts, report the issue clearly and **exit with failure** so the orchestrator knows to stop.
60
+
61
+ ## Step C — Record
62
+
63
+ 1. **Save test documentation**
64
+ - Ensure `documentation/features/<feature_name>/tests/` exists.
65
+ - Create or update `MODULE_<N>_tests.md` with: test file paths, run commands, coverage summary.
66
+
67
+ 2. **Create or update MODULE.md**
68
+ - In the feature module directory (`src/apis/<feature-name>/MODULE.md`), using `.agent/templates/MODULE.md`.
69
+
70
+ 3. **Update repo-map**
71
+ - Add/update the module entry in `project-memory/repo-map.md` → `src/apis/` table (set MODULE.md column to ✅).
72
+ - If a new reusable service or pattern was introduced, add it to the Reusable Components Registry.
73
+
74
+ 4. **Update core-memory**
75
+ - Update `project-memory/core-memory.md` feature progress table:
76
+ - `<feature_name>: Module <N> completed (<brief description>); next: Module <N+1>.`
77
+ - If this is the last module, mark the feature as complete.
78
+
79
+ ---
80
+
81
+ ## Output
82
+
83
+ When done, print a summary with:
84
+
85
+ - What was implemented (key files created/modified)
86
+ - Test results (pass/fail, coverage)
87
+ - Review outcomes (findings, fixes applied)
88
+ - Any remaining issues or deferred work
89
+
90
+ ---
91
+
92
+ ## Do not
93
+
94
+ - Implement more than one module. You handle exactly the module number given.
95
+ - Skip Step B (verify). Always test, review, fix, and update docs.
96
+ - Stop for human confirmation. Self-approve and proceed autonomously.
97
+ - Create unnecessary files outside the scope of this module.
@@ -0,0 +1,42 @@
1
+ # FEATURE_PLAN (Backend)
2
+
3
+ ## 1) Overview
4
+ - **Feature name**:
5
+ - **Goal / user impact**:
6
+ - **Relevant paths**: [e.g. src/apis/sample/, src/core/auth/, src/apis/apis.module.ts]
7
+ - **Out of scope**:
8
+
9
+ ## 2) API Contract
10
+ - **Endpoint(s)**:
11
+ - **Method(s)**:
12
+ - **Request schema / DTO**:
13
+ - **Response schema**:
14
+ - **Backward compatibility notes**:
15
+
16
+ ## 3) Validation & Authorization
17
+ - **Input validation (body/query/params)**:
18
+ - **Auth guard(s)**:
19
+ - **Permission check(s)**:
20
+ - **Resource ownership / tenant scoping**:
21
+
22
+ ## 4) Data Access & Side Effects
23
+ - **Read/write path**:
24
+ - **Models/repositories/services touched**:
25
+ - **External dependencies (DB/Redis/API)**:
26
+ - **Migration/config changes**:
27
+
28
+ ## 5) Performance & Reliability
29
+ - **Expected query/load impact**:
30
+ - **Caching strategy**:
31
+ - **Timeout/retry strategy**:
32
+ - **Failure handling**:
33
+
34
+ ## 6) Rollout & Rollback
35
+ - **Rollout plan**:
36
+ - **Rollback trigger**:
37
+ - **Rollback steps**:
38
+
39
+ ## 7) Verification
40
+ - **Review checklist refs**: `project-memory/quality-playbook.md`
41
+ - **Auth model refs**: `project-memory/auth-model.md`
42
+ - **Test plan file**: `documentation/plans/TEST_PLAN_BACKEND.md`
@@ -0,0 +1,45 @@
1
+ # MODULE.md Template
2
+
3
+ > Place this file in the root of each feature module: `src/apis/{feature-name}/MODULE.md`
4
+
5
+ ## {Feature Name}
6
+
7
+ **Purpose**: One-sentence description of what this module does.
8
+
9
+ **Module file**: `{feature-name}.module.ts`
10
+
11
+ ### Files
12
+
13
+ | File | Role |
14
+ |------|------|
15
+ | `{feature-name}.controller.ts` | HTTP endpoints |
16
+ | `{feature-name}.service.ts` | Business logic |
17
+ | `{feature-name}.repository.ts` | Data access (Sequelize model injection) |
18
+ | `{feature-name}.model.ts` | DB model definition |
19
+ | `{feature-name}.dto.ts` | Request/response validation |
20
+
21
+ ### Exports (injectable by other modules)
22
+
23
+ | Service | Used by |
24
+ |---------|---------|
25
+ | `{FeatureName}Service` | (list consuming modules, or "internal only") |
26
+
27
+ ### DI Dependencies
28
+
29
+ | Injected | From |
30
+ |----------|------|
31
+ | (list injected services) | (source module) |
32
+
33
+ ### DB Models
34
+
35
+ | Model | Table | Registered in `include.models.ts` |
36
+ |-------|-------|-----------------------------------|
37
+ | (model name) | (table name) | ✅ / ❌ |
38
+
39
+ ### Reusable Patterns
40
+
41
+ > If this module introduced a pattern or service that other modules should reuse, describe it here and ensure it's listed in `project-memory/repo-map.md` → Reusable Components Registry.
42
+
43
+ ### Notes
44
+
45
+ - Any gotchas, edge cases, or design decisions worth calling out.
@@ -0,0 +1,44 @@
1
+ # REVIEW_REPORT (Backend)
2
+
3
+ ## 1) Change Summary
4
+ - **Scope reviewed**:
5
+ - **Files reviewed**:
6
+ - **Overall status**: Pass / Pass with fixes / Blocked
7
+
8
+ ## 2) Findings
9
+
10
+ | Severity | Finding | Why it matters | Proposed fix | Files |
11
+ |---|---|---|---|---|
12
+ | High/Med/Low | | | | |
13
+ | High/Med/Low | | | | |
14
+
15
+ ## 3) Required Fixes Before Merge
16
+ - [ ] Fix 1:
17
+ - [ ] Fix 2:
18
+
19
+ ## 4) Optional Refactors
20
+ - [ ] Refactor 1:
21
+ - [ ] Refactor 2:
22
+
23
+ ## 5) Validation of Core Areas
24
+ - [ ] API contract unchanged or versioned
25
+ - [ ] Input validation present
26
+ - [ ] Authz/tenant/resource checks present
27
+ - [ ] Error handling consistent
28
+ - [ ] No secret leakage / unsafe logs
29
+ - [ ] Performance risks reviewed
30
+ - [ ] Changes stay within the right module (see `project-memory/repo-map.md`). No circular imports.
31
+ - [ ] If a new API feature: new module under `src/apis/` and registered in `ApisModule`.
32
+ - [ ] `project-memory/repo-map.md` updated if new modules or notable paths were added.
33
+
34
+ ## 6) Tests
35
+ - **Tests added/updated**:
36
+ - **Commands run**:
37
+ - `npm run test`
38
+ - `npm run test:e2e`
39
+ - **Result**: Pass / Fail / Partial
40
+ - **Known gaps**:
41
+
42
+ ## 7) Final Recommendation
43
+ - **Decision**: Approve / Request changes / Block
44
+ - **Notes**:
@@ -0,0 +1,70 @@
1
+ # SECURITY_ASSESSMENT_<YYYY-MM-DD>
2
+
3
+ ## 1) Scope
4
+ - **Audit target**: Full codebase / Changed files (branch <name>) / Path <path>
5
+ - **Files audited**:
6
+ - **Auth model reference**: `project-memory/auth-model.md` (read at <timestamp>)
7
+ - **Overall verdict**: Clean / Findings — fix before merge / Blocked
8
+
9
+ ## 2) Findings
10
+
11
+ | Severity | Category | Finding | Why it matters | Proposed fix | Files |
12
+ |---|---|---|---|---|---|
13
+ | CRITICAL / HIGH / MEDIUM / LOW | Auth / Input / Injection / Deps / Data Exposure / Crypto / Secrets / Other | | | | |
14
+
15
+ **Severity definitions:**
16
+ - **CRITICAL** — Exploitable now in production; data loss, auth bypass, RCE, or unauthorized cross-tenant access.
17
+ - **HIGH** — Real risk that requires specific conditions to exploit; missing guard on a sensitive endpoint, injection vector behind auth, vulnerable dep with known exploit in current usage.
18
+ - **MEDIUM** — Defense-in-depth gap; weakens posture but no immediate exploit path. Missing rate limit on auth endpoint, verbose error responses, weak validation.
19
+ - **LOW** — Hygiene issue; would not be exploitable on its own but flagged for cleanup.
20
+
21
+ ## 3) Auth Audit
22
+ - [ ] Every protected endpoint has the correct guard/middleware (per `auth-model.md`)
23
+ - [ ] Current-user / tenant context correctly threaded through call stack
24
+ - [ ] Ownership scoping enforced in queries (filtered by user/tenant where required)
25
+ - [ ] No auth logic in service/repository layer (controllers only)
26
+ - [ ] Session/JWT handling matches `auth-model.md` (issuance, expiry, refresh, revocation)
27
+
28
+ ## 4) Input Surface Audit
29
+ - [ ] All controllers/routes validate input at the boundary (DTO + validation pipe, or equivalent)
30
+ - [ ] No raw `req.body` flowing into queries or services
31
+ - [ ] User-supplied IDs are not trusted — auth context drives ownership filters
32
+ - [ ] No unsafe deserialization (raw JSON.parse on external input → typed object without validation)
33
+ - [ ] File uploads (if any): MIME type, size, and content validated server-side
34
+
35
+ ## 5) Injection Audit
36
+ - [ ] SQL: All queries parameterized; no string concatenation of user input
37
+ - [ ] ORM: No `Sequelize.literal` / `raw()` / `$queryRaw` carrying unescaped input
38
+ - [ ] Shell: No `exec` / `spawn` with user-controlled arguments
39
+ - [ ] Template injection: No user input passed to template engines without escape
40
+
41
+ ## 6) Dependency Audit
42
+ - [ ] Ran `npm audit` (or equivalent) — record output summary
43
+ - [ ] No dependencies pinned to known-vulnerable versions
44
+ - [ ] No deprecated/abandoned dependencies in security-critical paths (auth, crypto, parsing)
45
+ - [ ] Dependency added in this change: justified and from a reputable source
46
+
47
+ ## 7) Data Exposure Audit
48
+ - [ ] No PII in application logs (per constitution rules)
49
+ - [ ] No secrets in logs or error responses
50
+ - [ ] API responses do not over-fetch (sensitive fields explicitly excluded)
51
+ - [ ] Sensitive fields masked when surfaced to admin UIs (e.g. last-4 of card, partial email)
52
+ - [ ] No stack traces returned to clients in production
53
+
54
+ ## 8) Crypto & Secrets
55
+ - [ ] Passwords hashed with a current algorithm (bcrypt/argon2 with appropriate cost)
56
+ - [ ] JWTs signed with strong algorithm (HS256+ with rotated secret, or RS256/ES256)
57
+ - [ ] Secrets loaded from environment / secret manager; never committed
58
+ - [ ] TLS enforced on all external HTTP calls (no plain `http://` to internal services that handle auth)
59
+
60
+ ## 9) Required Fixes Before Merge
61
+ - [ ] Fix 1: (CRITICAL/HIGH only)
62
+ - [ ] Fix 2:
63
+
64
+ ## 10) Recommended Hardening (Non-blocking)
65
+ - [ ] Item 1: (MEDIUM/LOW)
66
+ - [ ] Item 2:
67
+
68
+ ## 11) Final Recommendation
69
+ - **Decision**: Approve / Request changes / Block merge
70
+ - **Notes**:
@@ -0,0 +1,49 @@
1
+ # TEST_PLAN (Backend)
2
+
3
+ ## 1) Scope
4
+ - **Feature / PR**:
5
+ - **Risks to cover**:
6
+
7
+ ## 2) Unit Tests
8
+ - **Jest config**: Roots `src/` and `libs/`; `*.spec.ts`; moduleNameMapper for `@can/aws`, `@can/common`, `@can/notification`, `@can/state-machine`.
9
+ - **Targets (services/utils/pipes/guards)**:
10
+ - **Cases**:
11
+ - [ ] Happy path
12
+ - [ ] Validation failure
13
+ - [ ] Authz failure
14
+ - [ ] Error path
15
+
16
+ ## 3) Integration Tests
17
+ - **Targets (module + DB/cache/external boundary)**:
18
+ - **Cases**:
19
+ - [ ] Contract wiring (controller -> service -> data)
20
+ - [ ] Permission/tenant filters applied
21
+ - [ ] Cache behavior (hit/miss/skip)
22
+
23
+ ## 4) E2E Tests
24
+ - **Config**: `test/jest-e2e.json`; `testRegex`: `.e2e-spec.ts$`; same moduleNameMapper.
25
+ - **Endpoints covered**:
26
+ - **Cases**:
27
+ - [ ] Success response contract
28
+ - [ ] 4xx/5xx behavior
29
+ - [ ] Unauthorized/forbidden access
30
+
31
+ ## 5) Mocks & Test Data
32
+ - **What is mocked**:
33
+ - **What is real**:
34
+ - **Fixture strategy**:
35
+
36
+ ## 6) Failure Paths
37
+ - [ ] Upstream timeout/error
38
+ - [ ] Invalid payload/type mismatch
39
+ - [ ] Dependency unavailable (DB/Redis/API)
40
+
41
+ ## 7) Commands & Exit Criteria
42
+ - **Commands**:
43
+ - `npm run test`
44
+ - `npm run test:e2e`
45
+ - `npm run test:cov` (optional)
46
+ - **Exit criteria**:
47
+ - [ ] Critical paths passing
48
+ - [ ] Failure paths covered
49
+ - [ ] No regression in existing tests