@jigyasudham/veto 0.8.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 (198) hide show
  1. package/.claude/settings.local.json +9 -0
  2. package/README.md +190 -0
  3. package/dist/adapters/claude.js +57 -0
  4. package/dist/adapters/codex.js +58 -0
  5. package/dist/adapters/gemini.js +58 -0
  6. package/dist/adapters/index.js +156 -0
  7. package/dist/agents/development/api.js +116 -0
  8. package/dist/agents/development/backend.js +82 -0
  9. package/dist/agents/development/coder.js +207 -0
  10. package/dist/agents/development/database.js +81 -0
  11. package/dist/agents/development/debugger.js +234 -0
  12. package/dist/agents/development/devops.js +84 -0
  13. package/dist/agents/development/frontend.js +83 -0
  14. package/dist/agents/development/migration.js +141 -0
  15. package/dist/agents/development/performance.js +142 -0
  16. package/dist/agents/development/refactor.js +85 -0
  17. package/dist/agents/development/reviewer.js +260 -0
  18. package/dist/agents/development/tester.js +143 -0
  19. package/dist/agents/executor.js +144 -0
  20. package/dist/agents/memory/context-manager.js +167 -0
  21. package/dist/agents/memory/decision-logger.js +157 -0
  22. package/dist/agents/memory/knowledge-base.js +120 -0
  23. package/dist/agents/memory/pattern-learner.js +140 -0
  24. package/dist/agents/memory/project-mapper.js +114 -0
  25. package/dist/agents/quality/accessibility.js +89 -0
  26. package/dist/agents/quality/code-quality.js +109 -0
  27. package/dist/agents/quality/compatibility.js +55 -0
  28. package/dist/agents/quality/documentation.js +95 -0
  29. package/dist/agents/quality/error-handling.js +87 -0
  30. package/dist/agents/research/competitor-analyzer.js +44 -0
  31. package/dist/agents/research/cost-analyzer.js +51 -0
  32. package/dist/agents/research/estimator.js +57 -0
  33. package/dist/agents/research/ethics-bias.js +111 -0
  34. package/dist/agents/research/researcher.js +112 -0
  35. package/dist/agents/research/risk-assessor.js +61 -0
  36. package/dist/agents/research/tech-advisor.js +52 -0
  37. package/dist/agents/security/auth.js +269 -0
  38. package/dist/agents/security/dependency-audit.js +273 -0
  39. package/dist/agents/security/penetration.js +245 -0
  40. package/dist/agents/security/privacy.js +259 -0
  41. package/dist/agents/security/scanner.js +288 -0
  42. package/dist/agents/security/secrets.js +212 -0
  43. package/dist/agents/types.js +2 -0
  44. package/dist/agents/workflow/automation.js +56 -0
  45. package/dist/agents/workflow/file-manager.js +49 -0
  46. package/dist/agents/workflow/git-agent.js +52 -0
  47. package/dist/agents/workflow/reporter.js +48 -0
  48. package/dist/agents/workflow/search-agent.js +39 -0
  49. package/dist/agents/workflow/task-coordinator.js +40 -0
  50. package/dist/agents/workflow/task-planner.js +46 -0
  51. package/dist/cli.js +132 -0
  52. package/dist/council/decision-engine.js +136 -0
  53. package/dist/council/devil-advocate.js +106 -0
  54. package/dist/council/index.js +37 -0
  55. package/dist/council/lead-developer.js +108 -0
  56. package/dist/council/legal-compliance.js +142 -0
  57. package/dist/council/product-manager.js +92 -0
  58. package/dist/council/security.js +162 -0
  59. package/dist/council/system-architect.js +122 -0
  60. package/dist/council/types.js +2 -0
  61. package/dist/council/ux-designer.js +109 -0
  62. package/dist/memory/local.js +182 -0
  63. package/dist/memory/schema.js +116 -0
  64. package/dist/memory/sync.js +199 -0
  65. package/dist/router/complexity-scorer.js +78 -0
  66. package/dist/router/context-compressor.js +58 -0
  67. package/dist/router/index.js +29 -0
  68. package/dist/router/learning-updater.js +186 -0
  69. package/dist/router/model-selector.js +51 -0
  70. package/dist/router/rate-monitor.js +73 -0
  71. package/dist/server.js +949 -0
  72. package/dist/skills/development/skill-api-design.js +313 -0
  73. package/dist/skills/development/skill-auth.js +255 -0
  74. package/dist/skills/development/skill-ci-cd.js +2 -0
  75. package/dist/skills/development/skill-crud.js +193 -0
  76. package/dist/skills/development/skill-db-schema.js +2 -0
  77. package/dist/skills/development/skill-docker.js +2 -0
  78. package/dist/skills/development/skill-env-setup.js +2 -0
  79. package/dist/skills/development/skill-scaffold.js +299 -0
  80. package/dist/skills/intelligence/skill-complexity-score.js +66 -0
  81. package/dist/skills/intelligence/skill-cost-track.js +36 -0
  82. package/dist/skills/intelligence/skill-learning-loop.js +66 -0
  83. package/dist/skills/intelligence/skill-pattern-detect.js +35 -0
  84. package/dist/skills/intelligence/skill-rate-watch.js +58 -0
  85. package/dist/skills/memory/skill-context-compress.js +82 -0
  86. package/dist/skills/memory/skill-cross-sync.js +88 -0
  87. package/dist/skills/memory/skill-decision-log.js +103 -0
  88. package/dist/skills/memory/skill-session-restore.js +44 -0
  89. package/dist/skills/memory/skill-session-save.js +78 -0
  90. package/dist/skills/quality/skill-accessibility.js +2 -0
  91. package/dist/skills/quality/skill-code-review.js +60 -0
  92. package/dist/skills/quality/skill-docs-gen.js +2 -0
  93. package/dist/skills/quality/skill-perf-audit.js +2 -0
  94. package/dist/skills/quality/skill-security-scan.js +67 -0
  95. package/dist/skills/quality/skill-test-suite.js +274 -0
  96. package/dist/skills/workflow/skill-deploy.js +2 -0
  97. package/dist/skills/workflow/skill-git-workflow.js +2 -0
  98. package/dist/skills/workflow/skill-rollback.js +2 -0
  99. package/dist/skills/workflow/skill-task-breakdown.js +2 -0
  100. package/package.json +30 -0
  101. package/src/adapters/claude.ts +70 -0
  102. package/src/adapters/codex.ts +71 -0
  103. package/src/adapters/gemini.ts +71 -0
  104. package/src/adapters/index.ts +217 -0
  105. package/src/agents/development/api.ts +120 -0
  106. package/src/agents/development/backend.ts +85 -0
  107. package/src/agents/development/coder.ts +213 -0
  108. package/src/agents/development/database.ts +83 -0
  109. package/src/agents/development/debugger.ts +238 -0
  110. package/src/agents/development/devops.ts +86 -0
  111. package/src/agents/development/frontend.ts +85 -0
  112. package/src/agents/development/migration.ts +144 -0
  113. package/src/agents/development/performance.ts +144 -0
  114. package/src/agents/development/refactor.ts +86 -0
  115. package/src/agents/development/reviewer.ts +268 -0
  116. package/src/agents/development/tester.ts +151 -0
  117. package/src/agents/executor.ts +158 -0
  118. package/src/agents/memory/context-manager.ts +171 -0
  119. package/src/agents/memory/decision-logger.ts +160 -0
  120. package/src/agents/memory/knowledge-base.ts +124 -0
  121. package/src/agents/memory/pattern-learner.ts +143 -0
  122. package/src/agents/memory/project-mapper.ts +118 -0
  123. package/src/agents/quality/accessibility.ts +99 -0
  124. package/src/agents/quality/code-quality.ts +115 -0
  125. package/src/agents/quality/compatibility.ts +58 -0
  126. package/src/agents/quality/documentation.ts +105 -0
  127. package/src/agents/quality/error-handling.ts +96 -0
  128. package/src/agents/research/competitor-analyzer.ts +45 -0
  129. package/src/agents/research/cost-analyzer.ts +54 -0
  130. package/src/agents/research/estimator.ts +60 -0
  131. package/src/agents/research/ethics-bias.ts +113 -0
  132. package/src/agents/research/researcher.ts +114 -0
  133. package/src/agents/research/risk-assessor.ts +63 -0
  134. package/src/agents/research/tech-advisor.ts +55 -0
  135. package/src/agents/security/auth.ts +287 -0
  136. package/src/agents/security/dependency-audit.ts +337 -0
  137. package/src/agents/security/penetration.ts +262 -0
  138. package/src/agents/security/privacy.ts +285 -0
  139. package/src/agents/security/scanner.ts +322 -0
  140. package/src/agents/security/secrets.ts +249 -0
  141. package/src/agents/types.ts +66 -0
  142. package/src/agents/workflow/automation.ts +59 -0
  143. package/src/agents/workflow/file-manager.ts +52 -0
  144. package/src/agents/workflow/git-agent.ts +55 -0
  145. package/src/agents/workflow/reporter.ts +51 -0
  146. package/src/agents/workflow/search-agent.ts +40 -0
  147. package/src/agents/workflow/task-coordinator.ts +41 -0
  148. package/src/agents/workflow/task-planner.ts +47 -0
  149. package/src/cli.ts +143 -0
  150. package/src/council/decision-engine.ts +171 -0
  151. package/src/council/devil-advocate.ts +116 -0
  152. package/src/council/index.ts +44 -0
  153. package/src/council/lead-developer.ts +118 -0
  154. package/src/council/legal-compliance.ts +152 -0
  155. package/src/council/product-manager.ts +102 -0
  156. package/src/council/security.ts +172 -0
  157. package/src/council/system-architect.ts +132 -0
  158. package/src/council/types.ts +33 -0
  159. package/src/council/ux-designer.ts +121 -0
  160. package/src/memory/local.ts +305 -0
  161. package/src/memory/schema.ts +174 -0
  162. package/src/memory/sync.ts +274 -0
  163. package/src/router/complexity-scorer.ts +96 -0
  164. package/src/router/context-compressor.ts +74 -0
  165. package/src/router/index.ts +60 -0
  166. package/src/router/learning-updater.ts +271 -0
  167. package/src/router/model-selector.ts +83 -0
  168. package/src/router/rate-monitor.ts +103 -0
  169. package/src/server.ts +1038 -0
  170. package/src/skills/development/skill-api-design.ts +329 -0
  171. package/src/skills/development/skill-auth.ts +271 -0
  172. package/src/skills/development/skill-ci-cd.ts +0 -0
  173. package/src/skills/development/skill-crud.ts +209 -0
  174. package/src/skills/development/skill-db-schema.ts +0 -0
  175. package/src/skills/development/skill-docker.ts +0 -0
  176. package/src/skills/development/skill-env-setup.ts +0 -0
  177. package/src/skills/development/skill-scaffold.ts +323 -0
  178. package/src/skills/intelligence/skill-complexity-score.ts +69 -0
  179. package/src/skills/intelligence/skill-cost-track.ts +39 -0
  180. package/src/skills/intelligence/skill-learning-loop.ts +69 -0
  181. package/src/skills/intelligence/skill-pattern-detect.ts +38 -0
  182. package/src/skills/intelligence/skill-rate-watch.ts +61 -0
  183. package/src/skills/memory/skill-context-compress.ts +98 -0
  184. package/src/skills/memory/skill-cross-sync.ts +104 -0
  185. package/src/skills/memory/skill-decision-log.ts +119 -0
  186. package/src/skills/memory/skill-session-restore.ts +59 -0
  187. package/src/skills/memory/skill-session-save.ts +94 -0
  188. package/src/skills/quality/skill-accessibility.ts +0 -0
  189. package/src/skills/quality/skill-code-review.ts +84 -0
  190. package/src/skills/quality/skill-docs-gen.ts +0 -0
  191. package/src/skills/quality/skill-perf-audit.ts +0 -0
  192. package/src/skills/quality/skill-security-scan.ts +91 -0
  193. package/src/skills/quality/skill-test-suite.ts +290 -0
  194. package/src/skills/workflow/skill-deploy.ts +0 -0
  195. package/src/skills/workflow/skill-git-workflow.ts +0 -0
  196. package/src/skills/workflow/skill-rollback.ts +0 -0
  197. package/src/skills/workflow/skill-task-breakdown.ts +0 -0
  198. package/tsconfig.json +20 -0
@@ -0,0 +1,82 @@
1
+ function detectStyle(task, context) {
2
+ const combined = (task + ' ' + (context ?? '')).toLowerCase();
3
+ if (combined.includes('lambda') || combined.includes('serverless') || combined.includes('function') || combined.includes('faas'))
4
+ return 'serverless';
5
+ if (combined.includes('microservice') || combined.includes('service mesh') || combined.includes('kubernetes') || combined.includes('k8s'))
6
+ return 'microservice';
7
+ if (combined.includes('monolith') || combined.includes('mvc') || combined.includes('express') || combined.includes('nestjs') || combined.includes('rails'))
8
+ return 'monolith';
9
+ return 'general';
10
+ }
11
+ const styleApproach = {
12
+ monolith: 'Organise by feature module (not by layer). Each module owns its Controller → Service → Repository stack. Use dependency injection for testability. Enforce module boundaries — no cross-module direct imports.',
13
+ microservice: 'Define the service boundary around a bounded context. Use async messaging for cross-service communication. Implement the Saga pattern for distributed transactions. Each service owns its data store.',
14
+ serverless: 'Design for stateless execution — no in-memory state between invocations. Use environment variables for config. Cold start budget: keep the handler lean. Use SQS/EventBridge for async operations.',
15
+ general: 'Apply Clean Architecture: Controllers → Use Cases → Domain → Infrastructure. Dependencies point inward. The domain layer has no framework imports. Testable by definition.',
16
+ };
17
+ export function plan(task, context) {
18
+ const style = detectStyle(task, context);
19
+ return {
20
+ agent: 'backend',
21
+ task,
22
+ tier: 3,
23
+ approach: styleApproach[style],
24
+ steps: [
25
+ 'Define the domain model: entities, value objects, and aggregate roots',
26
+ 'Define use cases (application services) — each use case is a single public method',
27
+ 'Design the repository interfaces in the domain layer (no DB imports)',
28
+ 'Implement the controller layer: parse request → call use case → format response',
29
+ 'Implement the service layer: orchestrate domain objects and repositories',
30
+ 'Implement the repository layer: translate domain operations to DB queries',
31
+ 'Wire dependency injection container (manual DI or a framework like tsyringe/inversify)',
32
+ 'Add authentication middleware: verify JWT/session, attach user to request context',
33
+ 'Add authorisation guards: check role/permission on each protected route',
34
+ 'Add request validation middleware: validate body/query against schema before reaching controller',
35
+ 'Implement structured error handling: domain errors → HTTP errors → error middleware',
36
+ 'Add correlation ID middleware: generate and propagate request tracing ID',
37
+ 'Add health check endpoint: /health returns 200 with DB and dependency status',
38
+ 'Configure graceful shutdown: drain in-flight requests before stopping the process',
39
+ 'Write unit tests for each service method with mocked repositories',
40
+ 'Write integration tests for each controller route against a test database',
41
+ ],
42
+ checklist: [
43
+ '[ ] Domain layer has zero framework or DB imports',
44
+ '[ ] Each use case / service method has a single responsibility',
45
+ '[ ] All dependencies injected via constructor — no new SomeDependency() in methods',
46
+ '[ ] Repository interfaces defined in domain, implementations in infrastructure',
47
+ '[ ] Authentication middleware applied to all non-public routes',
48
+ '[ ] Authorisation checked inside the use case — not just at the route level',
49
+ '[ ] Request validation runs before the controller method executes',
50
+ '[ ] All async operations wrapped in try/catch with typed error handling',
51
+ '[ ] Structured logging with correlation ID on every log line',
52
+ '[ ] No sensitive data (passwords, tokens) in log output',
53
+ '[ ] Graceful shutdown implemented — SIGTERM drains in-flight requests',
54
+ '[ ] Health endpoint checks real DB connectivity, not just process liveness',
55
+ '[ ] Environment variables validated at startup — fail fast on missing config',
56
+ '[ ] Connection pools sized appropriately for the expected concurrency',
57
+ '[ ] Unit tests cover all service methods',
58
+ '[ ] Integration tests cover all controller routes',
59
+ ],
60
+ pitfalls: [
61
+ 'Putting business logic in controllers — controllers should only parse input and format output',
62
+ 'Accessing the database directly from controllers — bypasses the service/repository abstraction',
63
+ 'Using global state (singletons with mutable fields) — breaks in clustered/concurrent environments',
64
+ 'Swallowing exceptions in middleware — downstream handlers receive undefined instead of an error',
65
+ 'Not validating environment variables at startup — the service starts, runs for hours, then crashes on first DB access',
66
+ 'Building a distributed monolith — microservices that share a DB defeat the purpose of the architecture',
67
+ 'Forgetting graceful shutdown — in-flight requests are killed on deploy, causing user-visible errors',
68
+ ],
69
+ patterns: [
70
+ 'Clean Architecture (Controllers → Use Cases → Domain → Infrastructure)',
71
+ 'Repository pattern (abstract DB access behind an interface)',
72
+ 'Dependency Injection (constructor injection for testability)',
73
+ 'Middleware chain (Chain of Responsibility for cross-cutting concerns)',
74
+ 'Command / Query Responsibility Segregation (CQRS)',
75
+ 'Domain Events (decouple side effects from core logic)',
76
+ 'Circuit Breaker (for resilient outbound calls)',
77
+ 'Saga pattern (coordinate distributed transactions)',
78
+ ],
79
+ duration_estimate: '1-3 days',
80
+ };
81
+ }
82
+ //# sourceMappingURL=backend.js.map
@@ -0,0 +1,207 @@
1
+ function detectCategory(task) {
2
+ const t = task.toLowerCase();
3
+ if (t.includes('endpoint') || t.includes('route') || t.includes('controller') || t.includes('rest') || t.includes('graphql'))
4
+ return 'api-endpoint';
5
+ if (t.includes('component') || t.includes('ui') || t.includes('button') || t.includes('form') || t.includes('modal') || t.includes('page'))
6
+ return 'ui-component';
7
+ if (t.includes('util') || t.includes('helper') || t.includes('format') || t.includes('parse') || t.includes('transform'))
8
+ return 'utility';
9
+ if (t.includes('service') || t.includes('manager') || t.includes('handler') || t.includes('processor') || t.includes('worker'))
10
+ return 'service';
11
+ return 'general';
12
+ }
13
+ const categoryApproach = {
14
+ 'api-endpoint': 'Design the contract first (request/response types), implement handler with validation, wire middleware chain, write integration tests.',
15
+ 'ui-component': 'Define props interface, sketch component tree, implement stateless core first then add state/effects, ensure accessibility, write render tests.',
16
+ 'utility': 'Write pure functions with explicit input/output types, cover all edge cases including null/undefined/empty, optimise for readability over cleverness.',
17
+ 'service': 'Apply Dependency Injection, define interface before class, implement with repository abstraction, propagate typed errors, add unit tests for each method.',
18
+ 'general': 'Define types first, implement incrementally, handle all error paths explicitly, add JSDoc for public APIs, write tests in parallel with implementation.',
19
+ };
20
+ const categorySteps = {
21
+ 'api-endpoint': [
22
+ 'Define TypeScript interfaces for request body, query params, and response payload',
23
+ 'Write input validation schema (zod or class-validator)',
24
+ 'Stub out the route handler and wire it in the router',
25
+ 'Implement business logic in a dedicated service class',
26
+ 'Add authentication/authorisation middleware as required',
27
+ 'Implement error handling — map domain errors to HTTP status codes',
28
+ 'Add request logging and correlation ID propagation',
29
+ 'Write integration tests hitting the endpoint directly',
30
+ 'Document the endpoint with OpenAPI/JSDoc annotations',
31
+ 'Test error paths: missing fields, invalid types, unauthorised access',
32
+ ],
33
+ 'ui-component': [
34
+ 'Define the Props interface with JSDoc on each prop',
35
+ 'Sketch the component tree — identify sub-components to extract',
36
+ 'Implement the purely presentational render first with hardcoded data',
37
+ 'Replace hardcoded data with props, add PropTypes/TypeScript narrowing',
38
+ 'Add local state and effects only after the static render is correct',
39
+ 'Implement loading and error states',
40
+ 'Add keyboard navigation and ARIA attributes',
41
+ 'Test with screen reader using browser dev tools',
42
+ 'Add responsive CSS — mobile first with breakpoints',
43
+ 'Write render tests covering each significant prop combination',
44
+ ],
45
+ 'utility': [
46
+ 'Write function signature with explicit parameter and return types',
47
+ 'Document expected input/output with JSDoc examples',
48
+ 'Handle null, undefined, and empty inputs explicitly',
49
+ 'Handle boundary conditions (zero, negative, overflow, max-length)',
50
+ 'Implement the happy-path logic',
51
+ 'Add guards and early returns for invalid inputs',
52
+ 'Write unit tests for each distinct input category',
53
+ 'Benchmark if the utility is on a hot path',
54
+ 'Export from an index barrel so imports stay clean',
55
+ ],
56
+ 'service': [
57
+ 'Define the service interface (IMyService) with all public methods',
58
+ 'List constructor dependencies — inject via interface not concrete class',
59
+ 'Write method stubs with return types before implementing',
60
+ 'Implement each method with a single clear responsibility',
61
+ 'Use typed Result or throw typed domain errors — no raw Error strings',
62
+ 'Log structured data (not plain strings) at appropriate log levels',
63
+ 'Write unit tests with mocked dependencies for each method',
64
+ 'Write integration test against a real dependency (DB, API) if applicable',
65
+ 'Document retry / circuit-breaker strategy for external calls',
66
+ 'Add health-check method if the service wraps an external resource',
67
+ ],
68
+ 'general': [
69
+ 'Clarify and write down acceptance criteria before touching code',
70
+ 'Define all TypeScript types/interfaces needed',
71
+ 'Break the work into small independently testable functions',
72
+ 'Implement incrementally — make it work, then make it right',
73
+ 'Handle all error paths explicitly with typed errors',
74
+ 'Add JSDoc to every exported symbol',
75
+ 'Write unit tests alongside implementation',
76
+ 'Run the linter and fix all warnings',
77
+ 'Review the diff for accidental debug code or console.log statements',
78
+ 'Update relevant documentation or README if the public API changes',
79
+ ],
80
+ };
81
+ const categoryChecklist = {
82
+ 'api-endpoint': [
83
+ '[ ] Request DTO fully typed with validation annotations',
84
+ '[ ] Response DTO typed — no raw any or unknown leaking out',
85
+ '[ ] HTTP status codes are semantically correct (201 vs 200, 422 vs 400)',
86
+ '[ ] Auth middleware applied where required',
87
+ '[ ] Rate limiting considered',
88
+ '[ ] Input sanitisation prevents injection',
89
+ '[ ] Async handler wrapped to forward errors to Express error middleware',
90
+ '[ ] Pagination implemented for list endpoints',
91
+ '[ ] Integration test covers 200, 400, 401, 404, 500 paths',
92
+ '[ ] OpenAPI annotation added',
93
+ '[ ] No secrets or PII logged',
94
+ '[ ] Idempotency considered for mutating endpoints',
95
+ ],
96
+ 'ui-component': [
97
+ '[ ] Props interface exported and all props documented',
98
+ '[ ] No inline styles — use CSS modules or styled components',
99
+ '[ ] Loading state renders a skeleton or spinner',
100
+ '[ ] Error state renders a user-friendly message',
101
+ '[ ] Empty state renders a meaningful prompt',
102
+ '[ ] ARIA roles and labels present on interactive elements',
103
+ '[ ] Tab order is logical',
104
+ '[ ] Component is keyboard-operable without mouse',
105
+ '[ ] Works at 320 px (mobile) and 1440 px (desktop)',
106
+ '[ ] No useEffect with missing dependency array entries',
107
+ '[ ] Memoisation applied only where profiling justifies it',
108
+ '[ ] Render test covers loading, error, and data states',
109
+ ],
110
+ 'utility': [
111
+ '[ ] Function is pure — no hidden side effects',
112
+ '[ ] Returns typed result, not any',
113
+ '[ ] Handles null and undefined inputs without throwing',
114
+ '[ ] Handles empty string and empty array inputs',
115
+ '[ ] Handles numeric edge cases (NaN, Infinity, 0, negative)',
116
+ '[ ] Unit test for each distinct input category',
117
+ '[ ] Exported from barrel index',
118
+ '[ ] JSDoc with @param, @returns, and @example',
119
+ ],
120
+ 'service': [
121
+ '[ ] Interface defined before implementation class',
122
+ '[ ] All dependencies injected — no new SomeDependency() in methods',
123
+ '[ ] Each public method has a single responsibility',
124
+ '[ ] Typed errors thrown — no throw new Error("raw string")',
125
+ '[ ] External calls have timeout configured',
126
+ '[ ] Unit tests mock all external dependencies',
127
+ '[ ] Integration test covers the real dependency path',
128
+ '[ ] Logs structured objects, not string concatenation',
129
+ '[ ] No business logic in the constructor',
130
+ '[ ] Service registered in the DI container',
131
+ ],
132
+ 'general': [
133
+ '[ ] Acceptance criteria written before coding',
134
+ '[ ] All types explicit — no implicit any',
135
+ '[ ] All error paths handled',
136
+ '[ ] JSDoc on every exported symbol',
137
+ '[ ] Unit tests written alongside implementation',
138
+ '[ ] No console.log left in committed code',
139
+ '[ ] Linter passes with zero warnings',
140
+ '[ ] No TODO comments without a linked issue number',
141
+ '[ ] Public API is backwards-compatible or version-bumped',
142
+ '[ ] Documentation updated if the public API changed',
143
+ ],
144
+ };
145
+ const categoryPitfalls = {
146
+ 'api-endpoint': [
147
+ 'Forgetting to await async middleware — silently skips auth checks',
148
+ 'Returning 200 for operations that create resources — use 201',
149
+ 'Leaking internal stack traces to the client in production',
150
+ 'Not validating Content-Type header before parsing body',
151
+ 'Using req.body directly without validation — injection risk',
152
+ ],
153
+ 'ui-component': [
154
+ 'Calling setState inside useEffect without a dependency array — infinite loop',
155
+ 'Forgetting key prop on list items — causes subtle reconciliation bugs',
156
+ 'Storing derived data in state instead of computing it on render',
157
+ 'Leaving event listeners without cleanup in useEffect return',
158
+ 'Assuming controlled and uncontrolled prop modes cannot conflict',
159
+ ],
160
+ 'utility': [
161
+ 'Using == instead of === for null checks — misses undefined',
162
+ 'Mutating the input array or object instead of returning a new one',
163
+ 'Assuming parseInt always returns a number — it returns NaN on bad input',
164
+ 'Using Date arithmetic without accounting for timezone offsets',
165
+ ],
166
+ 'service': [
167
+ 'Catching and swallowing errors silently — log and rethrow or return Result',
168
+ 'Doing database work in the constructor — blocks DI container startup',
169
+ 'Sharing mutable state across concurrent requests — use per-request scope',
170
+ 'Not configuring timeout on external HTTP calls — hangs indefinitely',
171
+ ],
172
+ 'general': [
173
+ 'Premature optimisation before profiling — adds complexity with no gain',
174
+ 'Mixing abstraction levels in a single function — extract sub-functions',
175
+ 'Returning null instead of throwing when the contract is violated',
176
+ 'Copy-pasting similar blocks instead of extracting a parameterised function',
177
+ ],
178
+ };
179
+ const categoryPatterns = {
180
+ 'api-endpoint': ['Command pattern', 'Chain of Responsibility (middleware)', 'DTO pattern', 'Repository pattern', 'Decorator pattern (route guards)'],
181
+ 'ui-component': ['Compound component pattern', 'Render props', 'Custom hook extraction', 'Container / Presenter split', 'Controlled component pattern'],
182
+ 'utility': ['Pure function', 'Pipe / compose', 'Guard clause early return', 'Option/Result type', 'Memoisation'],
183
+ 'service': ['Dependency Injection', 'Repository pattern', 'Strategy pattern', 'Result type', 'Façade pattern'],
184
+ 'general': ['Single Responsibility Principle', 'Dependency Inversion', 'Guard clauses', 'Factory function', 'Module pattern'],
185
+ };
186
+ const categoryDuration = {
187
+ 'api-endpoint': '2-4 hours',
188
+ 'ui-component': '3-6 hours',
189
+ 'utility': '1-2 hours',
190
+ 'service': '4-8 hours',
191
+ 'general': '2-4 hours',
192
+ };
193
+ export function plan(task, context) {
194
+ const category = detectCategory(task + ' ' + (context ?? ''));
195
+ return {
196
+ agent: 'coder',
197
+ task,
198
+ tier: 2,
199
+ approach: categoryApproach[category],
200
+ steps: categorySteps[category],
201
+ checklist: categoryChecklist[category],
202
+ pitfalls: categoryPitfalls[category],
203
+ patterns: categoryPatterns[category],
204
+ duration_estimate: categoryDuration[category],
205
+ };
206
+ }
207
+ //# sourceMappingURL=coder.js.map
@@ -0,0 +1,81 @@
1
+ function detectDbType(task, context) {
2
+ const combined = (task + ' ' + (context ?? '')).toLowerCase();
3
+ if (combined.includes('mongo') || combined.includes('document') || combined.includes('dynamodb') || combined.includes('firestore') || combined.includes('nosql'))
4
+ return 'nosql';
5
+ if (combined.includes('timeseries') || combined.includes('influx') || combined.includes('prometheus') || combined.includes('clickhouse') || combined.includes('time series'))
6
+ return 'timeseries';
7
+ if (combined.includes('graph') || combined.includes('neo4j') || combined.includes('relationship'))
8
+ return 'graph';
9
+ if (combined.includes('postgres') || combined.includes('mysql') || combined.includes('sqlite') || combined.includes('sql') || combined.includes('relational'))
10
+ return 'rdbms';
11
+ return 'general';
12
+ }
13
+ const dbApproach = {
14
+ rdbms: 'Design a normalised schema first (3NF), add indexes for every foreign key and frequent filter column, use transactions for multi-table mutations, plan migration scripts with backward compatibility.',
15
+ nosql: 'Design around access patterns — denormalise to serve queries in one round trip. Choose partition keys that distribute load evenly. Model for reads, use references sparingly for writes.',
16
+ timeseries: 'Optimise for append-heavy write patterns. Use time-bucketed partitioning. Compress old data with downsampling. Design queries around time ranges, not individual rows.',
17
+ graph: 'Model entities as nodes and relationships as edges with properties. Index node labels and edge types. Design traversal patterns and bound depth of recursive queries.',
18
+ general: 'Evaluate RDBMS vs NoSQL based on data structure, access patterns, and consistency requirements. Design schema to serve the most frequent query without joins if possible.',
19
+ };
20
+ export function plan(task, context) {
21
+ const dbType = detectDbType(task, context);
22
+ return {
23
+ agent: 'database',
24
+ task,
25
+ tier: 3,
26
+ approach: dbApproach[dbType],
27
+ steps: [
28
+ 'List all entities and their relationships — draw an ER diagram',
29
+ 'Identify the top 5 most frequent query patterns (what will be read most?)',
30
+ 'Design the schema to serve those queries with minimal joins/lookups',
31
+ 'Add primary keys and unique constraints first',
32
+ 'Add foreign key constraints for relational integrity',
33
+ 'Identify every column used in WHERE, ORDER BY, or JOIN — add indexes',
34
+ 'Choose composite index column order by selectivity (most selective first)',
35
+ 'Design the migration script: additive changes first (new tables, new nullable columns)',
36
+ 'Write seed / fixture data for the development environment',
37
+ 'Write query tests that assert on execution plan (EXPLAIN ANALYZE)',
38
+ 'Set up connection pooling with appropriate pool size for the workload',
39
+ 'Configure statement_timeout and lock_timeout to prevent runaway queries',
40
+ 'Plan archival strategy for old data — partitioning or archival table',
41
+ 'Document the schema with comments on each table and non-obvious column',
42
+ ],
43
+ checklist: [
44
+ '[ ] Every table has a primary key',
45
+ '[ ] Foreign keys are declared and indexed',
46
+ '[ ] Every JOIN column on the many-side has an index',
47
+ '[ ] Every column used in frequent WHERE clauses has an index',
48
+ '[ ] No SELECT * in production queries — enumerate columns',
49
+ '[ ] Multi-table mutations wrapped in transactions',
50
+ '[ ] Migrations are reversible (down migration written)',
51
+ '[ ] Migration tested on a copy of production data volume',
52
+ '[ ] Connection pool size calculated: connections = (core_count * 2) + effective_spindle_count',
53
+ '[ ] statement_timeout configured to prevent runaway queries',
54
+ '[ ] EXPLAIN ANALYZE run on all slow query candidates',
55
+ '[ ] Sensitive columns (PII, passwords) identified and encrypted at rest',
56
+ '[ ] Backup and point-in-time recovery tested',
57
+ '[ ] Schema documented with table and column comments',
58
+ ],
59
+ pitfalls: [
60
+ 'Using SELECT * in application queries — sends unnecessary data over the wire and breaks when columns are added/removed',
61
+ 'Forgetting to index foreign keys — causes full table scans on every JOIN',
62
+ 'Storing JSON blobs in relational databases to avoid schema work — kills query performance and integrity',
63
+ 'Not wrapping multi-step mutations in a transaction — leaves the database in a partially updated state on failure',
64
+ 'Using ORM-generated schemas without reviewing the SQL — ORMs frequently generate non-optimal index choices',
65
+ 'Choosing UUID as a clustered primary key in PostgreSQL without understanding write amplification from random page splits',
66
+ 'Ignoring VACUUM in PostgreSQL — table bloat degrades read performance over time',
67
+ 'Testing migrations only on an empty database — schema changes that work on empty DBs may lock production tables for minutes',
68
+ ],
69
+ patterns: [
70
+ 'Repository pattern (abstract DB access behind an interface)',
71
+ 'Unit of Work pattern (group related DB operations into a transaction)',
72
+ 'CQRS (separate read and write models for high-throughput systems)',
73
+ 'Event Sourcing (store events, derive state — for audit-heavy domains)',
74
+ 'Optimistic locking (version column for concurrent update detection)',
75
+ 'Soft delete pattern (deleted_at timestamp instead of hard DELETE)',
76
+ 'Temporal tables (track history of row changes)',
77
+ ],
78
+ duration_estimate: '1-2 days',
79
+ };
80
+ }
81
+ //# sourceMappingURL=database.js.map
@@ -0,0 +1,234 @@
1
+ function detectErrorCategory(task, context) {
2
+ const combined = (task + ' ' + (context ?? '')).toLowerCase();
3
+ if (combined.includes('memory') || combined.includes('leak') || combined.includes('heap') || combined.includes('oom'))
4
+ return 'memory';
5
+ if (combined.includes('slow') || combined.includes('latency') || combined.includes('timeout') || combined.includes('performance'))
6
+ return 'performance';
7
+ if (combined.includes('network') || combined.includes('fetch') || combined.includes('http') || combined.includes('cors') || combined.includes('socket'))
8
+ return 'network';
9
+ if (combined.includes('promise') || combined.includes('async') || combined.includes('await') || combined.includes('callback') || combined.includes('race'))
10
+ return 'async';
11
+ if (combined.includes('type') || combined.includes('undefined') || combined.includes('null') || combined.includes('cannot read'))
12
+ return 'type';
13
+ if (combined.includes('wrong') || combined.includes('incorrect') || combined.includes('unexpected') || combined.includes('logic'))
14
+ return 'logic';
15
+ return 'runtime';
16
+ }
17
+ const categoryApproach = {
18
+ runtime: 'Reproduce reliably → isolate to smallest failing case → read the full stack trace → form one hypothesis → add targeted logging → verify fix does not break other paths.',
19
+ type: 'Trace the data flow from origin to crash site — find where the wrong type enters. Use TypeScript strict mode findings as a guide. Fix the source, not the symptom.',
20
+ async: 'Map the Promise chain or async call graph. Look for missing awaits, race conditions, unhandled rejections, and event-loop blocking. Add sequential logging to trace execution order.',
21
+ performance: 'Measure first — use profiling tools to identify the actual bottleneck before touching code. Focus on the 80/20 hotspot. Validate improvement with benchmarks before and after.',
22
+ network: 'Inspect actual requests in browser DevTools or a proxy (Wireshark/mitmproxy). Verify headers, CORS policy, TLS, DNS, and connection reuse. Distinguish client bugs from server bugs.',
23
+ memory: 'Take heap snapshots before and after suspected operations. Compare retained objects. Look for closures holding large references, event listener accumulation, and growing caches without eviction.',
24
+ logic: 'Write a minimal reproducing test. Step through with a debugger or add assertion-style logging at each decision point. State the expected vs actual output explicitly before investigating.',
25
+ };
26
+ const categorySteps = {
27
+ runtime: [
28
+ 'Read the full stack trace — note the exact file, line number, and error message',
29
+ 'Reproduce the error in isolation — create the smallest possible reproduction',
30
+ 'Check if the error is deterministic or intermittent',
31
+ 'Identify the last working state using git bisect or recent commits',
32
+ 'Form a single specific hypothesis about the root cause',
33
+ 'Add targeted logging around the hypothesis — do NOT log everything',
34
+ 'Verify the hypothesis by temporarily modifying the suspected code',
35
+ 'Fix at the root cause, not at the point where the error surfaces',
36
+ 'Write a regression test that would have caught this bug',
37
+ 'Review related code paths that could have the same defect',
38
+ 'Document the root cause in the fix commit message',
39
+ ],
40
+ type: [
41
+ 'Find the exact line where the TypeError / undefined access occurs',
42
+ 'Trace the variable backwards to where it is assigned',
43
+ 'Check if the data source (API, DB, config) can return null/undefined',
44
+ 'Enable TypeScript strict mode and check for new red squiggles',
45
+ 'Fix the type at the origin — add correct types or validation at the boundary',
46
+ 'Add runtime validation (zod, guard function) at the data entry point',
47
+ 'Remove any type assertions (as Type, as any) that hide the real type',
48
+ 'Test with null, undefined, empty string, and unexpected types',
49
+ 'Add null checks or optional chaining where appropriate',
50
+ 'Write a unit test that exercises the null/undefined path',
51
+ ],
52
+ async: [
53
+ 'Map the full async call graph for the failing operation',
54
+ 'Check every await — ensure no async function is called without await',
55
+ 'Look for missing error propagation — catch blocks that do not rethrow',
56
+ 'Check for race conditions — operations that depend on execution order',
57
+ 'Look for event-loop blocking (synchronous heavy computation in an async context)',
58
+ 'Verify Promise.all vs Promise.allSettled — unhandled rejection vs partial failure',
59
+ 'Add sequential timestamps to log statements to trace actual execution order',
60
+ 'Use AsyncLocalStorage or correlation IDs to trace concurrent requests',
61
+ 'Check for multiple competing setInterval/setTimeout that interfere',
62
+ 'Write a test that exercises the async failure path explicitly',
63
+ ],
64
+ performance: [
65
+ 'Establish a baseline measurement — latency p50/p95/p99, throughput, CPU, memory',
66
+ 'Use a profiler (clinic.js, Chrome DevTools, py-spy) — identify the top hotspot',
67
+ 'Check for N+1 query patterns — count DB queries per request',
68
+ 'Check for synchronous blocking operations in async code',
69
+ 'Review algorithm complexity — O(n²) loops over large datasets',
70
+ 'Check caching — are expensive results being recomputed unnecessarily?',
71
+ 'Profile memory — look for unnecessary object allocation in hot paths',
72
+ 'Fix the single biggest bottleneck and measure again before moving on',
73
+ 'Add performance regression tests (benchmarks) to CI',
74
+ 'Document the performance improvement with before/after numbers',
75
+ ],
76
+ network: [
77
+ 'Capture the raw request and response with browser DevTools or curl',
78
+ 'Check CORS headers — Access-Control-Allow-Origin must match the origin',
79
+ 'Verify the TLS certificate is valid and not expired',
80
+ 'Check DNS resolution — nslookup or dig the hostname',
81
+ 'Verify the correct HTTP method and Content-Type are being sent',
82
+ 'Look for redirect loops (301/302 cycles)',
83
+ 'Check keep-alive and connection pool settings on the client',
84
+ 'Test from multiple networks to distinguish ISP / firewall issues',
85
+ 'Inspect retry logic — are retries causing duplicate side effects?',
86
+ 'Add request/response logging middleware to trace the full exchange',
87
+ ],
88
+ memory: [
89
+ 'Take a heap snapshot before the suspected operation',
90
+ 'Perform the operation that causes the leak',
91
+ 'Take a second heap snapshot and compare with the first',
92
+ 'Identify the object type and retention path in the diff',
93
+ 'Look for event listeners added without removeEventListener',
94
+ 'Check for closures that hold references to large objects',
95
+ 'Review caches and collections that grow without eviction',
96
+ 'Look for circular references that prevent garbage collection',
97
+ 'Fix the retention path and verify with a third heap snapshot',
98
+ 'Add a memory usage metric to monitoring to detect future regressions',
99
+ ],
100
+ logic: [
101
+ 'Write down the exact expected output and the actual output',
102
+ 'Identify the decision points (conditionals, loops, function calls) on the code path',
103
+ 'Write a minimal unit test that reproduces the wrong output',
104
+ 'Step through the code with a debugger, verifying state at each step',
105
+ 'Check boundary conditions: off-by-one errors, inclusive vs exclusive ranges',
106
+ 'Check date/time logic: timezone assumptions, DST transitions, epoch offsets',
107
+ 'Verify sort/comparison functions return correct negative/zero/positive values',
108
+ 'Trace the state mutation — check for accidental shared mutable state',
109
+ 'Fix the logic and run all related tests',
110
+ 'Add an assertion comment explaining the invariant being enforced',
111
+ ],
112
+ };
113
+ const categoryChecklist = {
114
+ runtime: [
115
+ '[ ] Full stack trace captured and read carefully',
116
+ '[ ] Minimal reproduction created',
117
+ '[ ] Root cause identified (not just symptom fixed)',
118
+ '[ ] Fix applied at root cause location',
119
+ '[ ] Regression test written',
120
+ '[ ] Related code paths reviewed for same defect',
121
+ '[ ] Fix verified in the same environment where the bug occurred',
122
+ ],
123
+ type: [
124
+ '[ ] TypeScript strict mode enabled',
125
+ '[ ] No type assertions (as Type) hiding the bug',
126
+ '[ ] Runtime validation added at data boundary',
127
+ '[ ] Null/undefined paths tested explicitly',
128
+ '[ ] No any types introduced to silence the compiler',
129
+ ],
130
+ async: [
131
+ '[ ] Every async call is properly awaited',
132
+ '[ ] Unhandled rejection handler in place',
133
+ '[ ] Race conditions analysed and eliminated',
134
+ '[ ] Error propagation tested in failure paths',
135
+ '[ ] Async test uses proper done/async-await, not callbacks',
136
+ ],
137
+ performance: [
138
+ '[ ] Baseline benchmark recorded before fix',
139
+ '[ ] Fix targets the profiled hotspot, not guesswork',
140
+ '[ ] No N+1 query patterns remain',
141
+ '[ ] Improvement verified with post-fix benchmark',
142
+ '[ ] Performance regression test added to CI',
143
+ ],
144
+ network: [
145
+ '[ ] Raw request/response captured and inspected',
146
+ '[ ] CORS headers correct',
147
+ '[ ] TLS certificate valid',
148
+ '[ ] Retry logic does not cause duplicate side effects',
149
+ '[ ] Error handling for network timeouts in place',
150
+ ],
151
+ memory: [
152
+ '[ ] Heap snapshots taken before and after fix',
153
+ '[ ] All event listeners have corresponding removeEventListener',
154
+ '[ ] Caches have maximum size and eviction policy',
155
+ '[ ] No circular references between large objects',
156
+ '[ ] Memory metric added to monitoring dashboard',
157
+ ],
158
+ logic: [
159
+ '[ ] Expected vs actual output documented',
160
+ '[ ] Minimal reproducing test written before fix',
161
+ '[ ] All boundary conditions tested',
162
+ '[ ] Off-by-one conditions verified',
163
+ '[ ] Shared mutable state eliminated from the bug path',
164
+ ],
165
+ };
166
+ const categoryPitfalls = {
167
+ runtime: [
168
+ 'Fixing the symptom (adding a null check at the crash site) without fixing the root cause (why null got there)',
169
+ 'Changing multiple things at once — makes it impossible to know which change fixed the bug',
170
+ 'Not writing a regression test — the bug will return',
171
+ 'Ignoring the stack trace and guessing at the cause',
172
+ ],
173
+ type: [
174
+ 'Using "as any" or "as Type" to silence TypeScript — masks the real bug',
175
+ 'Checking for null in the wrong place — check where the data enters, not where it crashes',
176
+ 'Conflating undefined (not set) with null (intentionally empty)',
177
+ ],
178
+ async: [
179
+ 'Adding await to a non-Promise — causes subtle bugs when the value becomes a resolved Promise accidentally',
180
+ 'Using Promise.all when one rejection should not cancel the others — use Promise.allSettled',
181
+ 'Catching errors in middleware and not rethrowing — downstream code sees undefined instead of an error',
182
+ ],
183
+ performance: [
184
+ 'Optimising without measuring first — wastes time on non-bottlenecks',
185
+ 'Caching without an eviction strategy — trades performance for a memory leak',
186
+ 'Parallelising I/O without limiting concurrency — causes resource exhaustion',
187
+ ],
188
+ network: [
189
+ 'Debugging CORS on the client — CORS is a server-side configuration problem',
190
+ 'Trusting browser error messages for network issues — use curl/mitmproxy for ground truth',
191
+ 'Ignoring timeout configuration — 30-second default timeouts hide slow endpoint bugs',
192
+ ],
193
+ memory: [
194
+ 'Using WeakMap/WeakRef without understanding the GC implications — not a guaranteed fix',
195
+ 'Adding .off() listeners in cleanup without matching the exact listener reference — listener remains attached',
196
+ 'Assuming garbage collection will clean up large arrays that are still reachable via closure',
197
+ ],
198
+ logic: [
199
+ 'Fixing the wrong layer — UI shows wrong data because the API returns wrong data, not because the UI is broken',
200
+ 'Not isolating the bug with a test before fixing — leads to over-engineering the fix',
201
+ 'Trusting console.log output order in async code — use timestamps',
202
+ ],
203
+ };
204
+ const categoryRootCauses = {
205
+ runtime: ['Null/undefined dereference', 'Index out of bounds', 'Missing module export', 'Incorrect function signature', 'Environment variable not set'],
206
+ type: ['API returning different shape than expected', 'Optional field treated as required', 'Union type not narrowed before use', 'JSON.parse result not validated'],
207
+ async: ['Missing await on async function', 'Unhandled Promise rejection', 'Race condition between concurrent operations', 'Event listener attached multiple times'],
208
+ performance: ['N+1 database query', 'Unbounded loop over large dataset', 'Synchronous blocking in event loop', 'Missing index on queried column', 'Large objects allocated in hot path'],
209
+ network: ['CORS misconfiguration', 'Expired TLS certificate', 'DNS resolution failure', 'Firewall blocking the port', 'Incorrect Content-Type header'],
210
+ memory: ['Event listeners not removed on component unmount', 'Closure retaining large object', 'Unbounded cache', 'Circular reference in object graph'],
211
+ logic: ['Off-by-one error in loop bounds', 'Timezone-naive date comparison', 'Wrong operator precedence', 'Mutating shared state across requests', 'Short-circuit evaluation misunderstood'],
212
+ };
213
+ export function plan(task, context) {
214
+ const category = detectErrorCategory(task, context);
215
+ const rootCauses = categoryRootCauses[category];
216
+ return {
217
+ agent: 'debugger',
218
+ task,
219
+ tier: 2,
220
+ approach: categoryApproach[category],
221
+ steps: categorySteps[category],
222
+ checklist: categoryChecklist[category],
223
+ pitfalls: categoryPitfalls[category],
224
+ patterns: [
225
+ 'Reproduce-Isolate-Fix loop',
226
+ 'Scientific method (hypothesis → test → conclusion)',
227
+ 'Rubber duck debugging',
228
+ 'Binary search debugging (git bisect)',
229
+ ...rootCauses.map(c => `Root cause: ${c}`),
230
+ ],
231
+ duration_estimate: category === 'performance' || category === 'memory' ? '2-6 hours' : '30 minutes - 3 hours',
232
+ };
233
+ }
234
+ //# sourceMappingURL=debugger.js.map