@jigyasudham/veto 0.8.3 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +209 -52
- package/dist/agents/executor.js +36 -3
- package/dist/cli.js +246 -7
- package/dist/context/reader.js +113 -0
- package/dist/council/index.js +3 -1
- package/dist/plugins/loader.js +49 -0
- package/dist/router/index.js +2 -2
- package/dist/router/learning-updater.js +45 -1
- package/dist/server.js +478 -14
- package/dist/watcher/index.js +77 -0
- package/dist/workflow/pipeline.js +64 -0
- package/package.json +12 -3
- package/.claude/settings.local.json +0 -9
- package/src/adapters/claude.ts +0 -70
- package/src/adapters/codex.ts +0 -71
- package/src/adapters/gemini.ts +0 -71
- package/src/adapters/index.ts +0 -217
- package/src/agents/development/api.ts +0 -120
- package/src/agents/development/backend.ts +0 -85
- package/src/agents/development/coder.ts +0 -213
- package/src/agents/development/database.ts +0 -83
- package/src/agents/development/debugger.ts +0 -238
- package/src/agents/development/devops.ts +0 -86
- package/src/agents/development/frontend.ts +0 -85
- package/src/agents/development/migration.ts +0 -144
- package/src/agents/development/performance.ts +0 -144
- package/src/agents/development/refactor.ts +0 -86
- package/src/agents/development/reviewer.ts +0 -268
- package/src/agents/development/tester.ts +0 -151
- package/src/agents/executor.ts +0 -158
- package/src/agents/memory/context-manager.ts +0 -171
- package/src/agents/memory/decision-logger.ts +0 -160
- package/src/agents/memory/knowledge-base.ts +0 -124
- package/src/agents/memory/pattern-learner.ts +0 -143
- package/src/agents/memory/project-mapper.ts +0 -118
- package/src/agents/quality/accessibility.ts +0 -99
- package/src/agents/quality/code-quality.ts +0 -115
- package/src/agents/quality/compatibility.ts +0 -58
- package/src/agents/quality/documentation.ts +0 -105
- package/src/agents/quality/error-handling.ts +0 -96
- package/src/agents/research/competitor-analyzer.ts +0 -45
- package/src/agents/research/cost-analyzer.ts +0 -54
- package/src/agents/research/estimator.ts +0 -60
- package/src/agents/research/ethics-bias.ts +0 -113
- package/src/agents/research/researcher.ts +0 -114
- package/src/agents/research/risk-assessor.ts +0 -63
- package/src/agents/research/tech-advisor.ts +0 -55
- package/src/agents/security/auth.ts +0 -287
- package/src/agents/security/dependency-audit.ts +0 -337
- package/src/agents/security/penetration.ts +0 -262
- package/src/agents/security/privacy.ts +0 -285
- package/src/agents/security/scanner.ts +0 -322
- package/src/agents/security/secrets.ts +0 -249
- package/src/agents/types.ts +0 -66
- package/src/agents/workflow/automation.ts +0 -59
- package/src/agents/workflow/file-manager.ts +0 -52
- package/src/agents/workflow/git-agent.ts +0 -55
- package/src/agents/workflow/reporter.ts +0 -51
- package/src/agents/workflow/search-agent.ts +0 -40
- package/src/agents/workflow/task-coordinator.ts +0 -41
- package/src/agents/workflow/task-planner.ts +0 -47
- package/src/cli.ts +0 -204
- package/src/council/decision-engine.ts +0 -171
- package/src/council/devil-advocate.ts +0 -116
- package/src/council/index.ts +0 -44
- package/src/council/lead-developer.ts +0 -118
- package/src/council/legal-compliance.ts +0 -152
- package/src/council/product-manager.ts +0 -102
- package/src/council/security.ts +0 -172
- package/src/council/system-architect.ts +0 -132
- package/src/council/types.ts +0 -33
- package/src/council/ux-designer.ts +0 -121
- package/src/memory/local.ts +0 -305
- package/src/memory/schema.ts +0 -174
- package/src/memory/sync.ts +0 -274
- package/src/router/complexity-scorer.ts +0 -96
- package/src/router/context-compressor.ts +0 -74
- package/src/router/index.ts +0 -60
- package/src/router/learning-updater.ts +0 -271
- package/src/router/model-selector.ts +0 -83
- package/src/router/rate-monitor.ts +0 -103
- package/src/server.ts +0 -1038
- package/src/skills/development/skill-api-design.ts +0 -329
- package/src/skills/development/skill-auth.ts +0 -271
- package/src/skills/development/skill-ci-cd.ts +0 -0
- package/src/skills/development/skill-crud.ts +0 -209
- package/src/skills/development/skill-db-schema.ts +0 -0
- package/src/skills/development/skill-docker.ts +0 -0
- package/src/skills/development/skill-env-setup.ts +0 -0
- package/src/skills/development/skill-scaffold.ts +0 -323
- package/src/skills/intelligence/skill-complexity-score.ts +0 -69
- package/src/skills/intelligence/skill-cost-track.ts +0 -39
- package/src/skills/intelligence/skill-learning-loop.ts +0 -69
- package/src/skills/intelligence/skill-pattern-detect.ts +0 -38
- package/src/skills/intelligence/skill-rate-watch.ts +0 -61
- package/src/skills/memory/skill-context-compress.ts +0 -98
- package/src/skills/memory/skill-cross-sync.ts +0 -104
- package/src/skills/memory/skill-decision-log.ts +0 -119
- package/src/skills/memory/skill-session-restore.ts +0 -59
- package/src/skills/memory/skill-session-save.ts +0 -94
- package/src/skills/quality/skill-accessibility.ts +0 -0
- package/src/skills/quality/skill-code-review.ts +0 -84
- package/src/skills/quality/skill-docs-gen.ts +0 -0
- package/src/skills/quality/skill-perf-audit.ts +0 -0
- package/src/skills/quality/skill-security-scan.ts +0 -91
- package/src/skills/quality/skill-test-suite.ts +0 -290
- package/src/skills/workflow/skill-deploy.ts +0 -0
- package/src/skills/workflow/skill-git-workflow.ts +0 -0
- package/src/skills/workflow/skill-rollback.ts +0 -0
- package/src/skills/workflow/skill-task-breakdown.ts +0 -0
- package/tsconfig.json +0 -20
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
import { AgentPlan, WorkerAgentType } from '../types.js';
|
|
2
|
-
|
|
3
|
-
type ApiStyle = 'rest' | 'graphql' | 'grpc' | 'general';
|
|
4
|
-
|
|
5
|
-
function detectApiStyle(task: string, context?: string): ApiStyle {
|
|
6
|
-
const combined = (task + ' ' + (context ?? '')).toLowerCase();
|
|
7
|
-
if (combined.includes('graphql') || combined.includes('query') || combined.includes('mutation') || combined.includes('resolver')) return 'graphql';
|
|
8
|
-
if (combined.includes('grpc') || combined.includes('protobuf') || combined.includes('proto')) return 'grpc';
|
|
9
|
-
if (combined.includes('rest') || combined.includes('http') || combined.includes('endpoint') || combined.includes('route')) return 'rest';
|
|
10
|
-
return 'general';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const styleApproach: Record<ApiStyle, string> = {
|
|
14
|
-
rest: 'Design resource-oriented URLs, assign correct HTTP verbs, define request/response DTOs with validation, implement versioning strategy, document with OpenAPI, secure with JWT/OAuth.',
|
|
15
|
-
graphql: 'Define the schema first (SDL-first approach), design resolvers to avoid N+1 (DataLoader), implement mutations with input types, add field-level authorisation, paginate list queries.',
|
|
16
|
-
grpc: 'Write the .proto file first (contract-first), generate server and client stubs, implement unary and streaming RPCs as needed, add interceptors for auth/logging, define error codes.',
|
|
17
|
-
general: 'Choose REST for CRUD resource APIs, GraphQL for flexible client-driven queries, gRPC for high-performance internal services. Design the contract before writing implementation code.',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
const styleSteps: Record<ApiStyle, string[]> = {
|
|
21
|
-
rest: [
|
|
22
|
-
'Identify the resources (nouns) the API exposes — e.g., /users, /orders, /products',
|
|
23
|
-
'Map CRUD operations to HTTP verbs: GET (read), POST (create), PUT/PATCH (update), DELETE',
|
|
24
|
-
'Design the URL structure: /api/v1/resources/{id}/sub-resources',
|
|
25
|
-
'Define the request body DTO with all required and optional fields',
|
|
26
|
-
'Define the response body DTO — never return the raw DB row',
|
|
27
|
-
'Define error response shape: { code, message, details } for all 4xx/5xx',
|
|
28
|
-
'Choose the pagination strategy: cursor-based for large datasets, offset for small',
|
|
29
|
-
'Implement versioning: URL path versioning (/v1/) or header versioning',
|
|
30
|
-
'Secure the endpoint: add authentication middleware and role-based guards',
|
|
31
|
-
'Add rate limiting to prevent abuse',
|
|
32
|
-
'Write OpenAPI/Swagger annotation for each endpoint',
|
|
33
|
-
'Write integration tests covering happy path and all error conditions',
|
|
34
|
-
],
|
|
35
|
-
graphql: [
|
|
36
|
-
'Write the GraphQL schema (SDL) before writing any resolver code',
|
|
37
|
-
'Define types for all entities, input types for mutations, and enums for fixed values',
|
|
38
|
-
'Design query fields with pagination arguments (first, after, last, before)',
|
|
39
|
-
'Implement DataLoader for all one-to-many and many-to-many relations to batch DB queries',
|
|
40
|
-
'Implement resolvers using the service layer — no direct DB queries in resolvers',
|
|
41
|
-
'Add field-level authorisation using resolver guards',
|
|
42
|
-
'Add query depth limiting (max depth 10) and query complexity limits',
|
|
43
|
-
'Implement subscriptions only for truly real-time use cases',
|
|
44
|
-
'Add persisted queries for production performance',
|
|
45
|
-
'Write tests using graphql-tester or supertest against the schema',
|
|
46
|
-
'Document each type and field with SDL description strings',
|
|
47
|
-
],
|
|
48
|
-
grpc: [
|
|
49
|
-
'Write the .proto file defining all messages and services',
|
|
50
|
-
'Generate TypeScript server and client stubs from the proto',
|
|
51
|
-
'Implement each RPC method in the service implementation class',
|
|
52
|
-
'Add server interceptors for authentication, logging, and tracing',
|
|
53
|
-
'Implement unary RPCs for simple request/response patterns',
|
|
54
|
-
'Implement server-streaming for large result sets',
|
|
55
|
-
'Implement bidirectional streaming for real-time communication',
|
|
56
|
-
'Define a standard error model using google.rpc.Status',
|
|
57
|
-
'Add health checking via the gRPC health protocol',
|
|
58
|
-
'Write integration tests using the generated client stubs',
|
|
59
|
-
'Document each service and RPC with proto comments',
|
|
60
|
-
],
|
|
61
|
-
general: [
|
|
62
|
-
'Choose the API style based on use case (REST/GraphQL/gRPC)',
|
|
63
|
-
'Write the API contract (OpenAPI, SDL, or .proto) before implementation',
|
|
64
|
-
'Define all data types for requests and responses',
|
|
65
|
-
'Design error handling and error response shapes',
|
|
66
|
-
'Plan authentication and authorisation strategy',
|
|
67
|
-
'Design versioning strategy',
|
|
68
|
-
'Add rate limiting and throttling',
|
|
69
|
-
'Write API documentation',
|
|
70
|
-
'Write integration tests',
|
|
71
|
-
'Set up monitoring for error rates and latency',
|
|
72
|
-
],
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export function plan(task: string, context?: string): AgentPlan {
|
|
76
|
-
const style = detectApiStyle(task, context);
|
|
77
|
-
|
|
78
|
-
return {
|
|
79
|
-
agent: 'api' as WorkerAgentType,
|
|
80
|
-
task,
|
|
81
|
-
tier: 2,
|
|
82
|
-
approach: styleApproach[style],
|
|
83
|
-
steps: styleSteps[style],
|
|
84
|
-
checklist: [
|
|
85
|
-
'[ ] API contract (OpenAPI/SDL/proto) written before implementation',
|
|
86
|
-
'[ ] All request inputs validated and sanitised',
|
|
87
|
-
'[ ] Response DTOs never expose internal DB columns or secrets',
|
|
88
|
-
'[ ] HTTP status codes semantically correct (201 for creation, 422 for validation errors)',
|
|
89
|
-
'[ ] Authentication required on all non-public endpoints',
|
|
90
|
-
'[ ] Authorisation checked — user can only access their own resources',
|
|
91
|
-
'[ ] Rate limiting applied to prevent abuse',
|
|
92
|
-
'[ ] Pagination implemented for all list endpoints',
|
|
93
|
-
'[ ] Error responses follow a consistent shape with error code and message',
|
|
94
|
-
'[ ] Idempotency key supported on create/update endpoints',
|
|
95
|
-
'[ ] API versioning strategy documented and implemented',
|
|
96
|
-
'[ ] CORS configured correctly for the intended client origins',
|
|
97
|
-
'[ ] No internal error details (stack traces) exposed in production responses',
|
|
98
|
-
'[ ] Integration tests cover 200, 400, 401, 403, 404, 422, 500 paths',
|
|
99
|
-
'[ ] API documentation complete and accurate',
|
|
100
|
-
],
|
|
101
|
-
pitfalls: [
|
|
102
|
-
'Returning 200 OK with an error body — use the correct HTTP status code',
|
|
103
|
-
'Exposing database IDs directly — use UUIDs or opaque tokens to prevent enumeration',
|
|
104
|
-
'Not validating Content-Type — body parsers silently fail on wrong content type',
|
|
105
|
-
'Returning the full DB row in the response — exposes internal fields and breaks encapsulation',
|
|
106
|
-
'Using GET requests for operations with side effects — browsers and caches will replay them',
|
|
107
|
-
'Not implementing idempotency for payment or order endpoints — duplicate requests cause duplicate charges',
|
|
108
|
-
'Omitting pagination on list endpoints — a single request can return millions of rows',
|
|
109
|
-
],
|
|
110
|
-
patterns: [
|
|
111
|
-
'Command pattern (map HTTP requests to command objects)',
|
|
112
|
-
'DTO pattern (request and response data transfer objects)',
|
|
113
|
-
'Decorator pattern (middleware as route decorators)',
|
|
114
|
-
'Repository pattern (abstract data access from controllers)',
|
|
115
|
-
'API Gateway pattern (single entry point with cross-cutting concerns)',
|
|
116
|
-
'Circuit Breaker pattern (for outbound calls to other services)',
|
|
117
|
-
],
|
|
118
|
-
duration_estimate: '4-8 hours',
|
|
119
|
-
};
|
|
120
|
-
}
|
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { AgentPlan, WorkerAgentType } from '../types.js';
|
|
2
|
-
|
|
3
|
-
type BackendStyle = 'monolith' | 'microservice' | 'serverless' | 'general';
|
|
4
|
-
|
|
5
|
-
function detectStyle(task: string, context?: string): BackendStyle {
|
|
6
|
-
const combined = (task + ' ' + (context ?? '')).toLowerCase();
|
|
7
|
-
if (combined.includes('lambda') || combined.includes('serverless') || combined.includes('function') || combined.includes('faas')) return 'serverless';
|
|
8
|
-
if (combined.includes('microservice') || combined.includes('service mesh') || combined.includes('kubernetes') || combined.includes('k8s')) return 'microservice';
|
|
9
|
-
if (combined.includes('monolith') || combined.includes('mvc') || combined.includes('express') || combined.includes('nestjs') || combined.includes('rails')) return 'monolith';
|
|
10
|
-
return 'general';
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const styleApproach: Record<BackendStyle, string> = {
|
|
14
|
-
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.',
|
|
15
|
-
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.',
|
|
16
|
-
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.',
|
|
17
|
-
general: 'Apply Clean Architecture: Controllers → Use Cases → Domain → Infrastructure. Dependencies point inward. The domain layer has no framework imports. Testable by definition.',
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export function plan(task: string, context?: string): AgentPlan {
|
|
21
|
-
const style = detectStyle(task, context);
|
|
22
|
-
|
|
23
|
-
return {
|
|
24
|
-
agent: 'backend' as WorkerAgentType,
|
|
25
|
-
task,
|
|
26
|
-
tier: 3,
|
|
27
|
-
approach: styleApproach[style],
|
|
28
|
-
steps: [
|
|
29
|
-
'Define the domain model: entities, value objects, and aggregate roots',
|
|
30
|
-
'Define use cases (application services) — each use case is a single public method',
|
|
31
|
-
'Design the repository interfaces in the domain layer (no DB imports)',
|
|
32
|
-
'Implement the controller layer: parse request → call use case → format response',
|
|
33
|
-
'Implement the service layer: orchestrate domain objects and repositories',
|
|
34
|
-
'Implement the repository layer: translate domain operations to DB queries',
|
|
35
|
-
'Wire dependency injection container (manual DI or a framework like tsyringe/inversify)',
|
|
36
|
-
'Add authentication middleware: verify JWT/session, attach user to request context',
|
|
37
|
-
'Add authorisation guards: check role/permission on each protected route',
|
|
38
|
-
'Add request validation middleware: validate body/query against schema before reaching controller',
|
|
39
|
-
'Implement structured error handling: domain errors → HTTP errors → error middleware',
|
|
40
|
-
'Add correlation ID middleware: generate and propagate request tracing ID',
|
|
41
|
-
'Add health check endpoint: /health returns 200 with DB and dependency status',
|
|
42
|
-
'Configure graceful shutdown: drain in-flight requests before stopping the process',
|
|
43
|
-
'Write unit tests for each service method with mocked repositories',
|
|
44
|
-
'Write integration tests for each controller route against a test database',
|
|
45
|
-
],
|
|
46
|
-
checklist: [
|
|
47
|
-
'[ ] Domain layer has zero framework or DB imports',
|
|
48
|
-
'[ ] Each use case / service method has a single responsibility',
|
|
49
|
-
'[ ] All dependencies injected via constructor — no new SomeDependency() in methods',
|
|
50
|
-
'[ ] Repository interfaces defined in domain, implementations in infrastructure',
|
|
51
|
-
'[ ] Authentication middleware applied to all non-public routes',
|
|
52
|
-
'[ ] Authorisation checked inside the use case — not just at the route level',
|
|
53
|
-
'[ ] Request validation runs before the controller method executes',
|
|
54
|
-
'[ ] All async operations wrapped in try/catch with typed error handling',
|
|
55
|
-
'[ ] Structured logging with correlation ID on every log line',
|
|
56
|
-
'[ ] No sensitive data (passwords, tokens) in log output',
|
|
57
|
-
'[ ] Graceful shutdown implemented — SIGTERM drains in-flight requests',
|
|
58
|
-
'[ ] Health endpoint checks real DB connectivity, not just process liveness',
|
|
59
|
-
'[ ] Environment variables validated at startup — fail fast on missing config',
|
|
60
|
-
'[ ] Connection pools sized appropriately for the expected concurrency',
|
|
61
|
-
'[ ] Unit tests cover all service methods',
|
|
62
|
-
'[ ] Integration tests cover all controller routes',
|
|
63
|
-
],
|
|
64
|
-
pitfalls: [
|
|
65
|
-
'Putting business logic in controllers — controllers should only parse input and format output',
|
|
66
|
-
'Accessing the database directly from controllers — bypasses the service/repository abstraction',
|
|
67
|
-
'Using global state (singletons with mutable fields) — breaks in clustered/concurrent environments',
|
|
68
|
-
'Swallowing exceptions in middleware — downstream handlers receive undefined instead of an error',
|
|
69
|
-
'Not validating environment variables at startup — the service starts, runs for hours, then crashes on first DB access',
|
|
70
|
-
'Building a distributed monolith — microservices that share a DB defeat the purpose of the architecture',
|
|
71
|
-
'Forgetting graceful shutdown — in-flight requests are killed on deploy, causing user-visible errors',
|
|
72
|
-
],
|
|
73
|
-
patterns: [
|
|
74
|
-
'Clean Architecture (Controllers → Use Cases → Domain → Infrastructure)',
|
|
75
|
-
'Repository pattern (abstract DB access behind an interface)',
|
|
76
|
-
'Dependency Injection (constructor injection for testability)',
|
|
77
|
-
'Middleware chain (Chain of Responsibility for cross-cutting concerns)',
|
|
78
|
-
'Command / Query Responsibility Segregation (CQRS)',
|
|
79
|
-
'Domain Events (decouple side effects from core logic)',
|
|
80
|
-
'Circuit Breaker (for resilient outbound calls)',
|
|
81
|
-
'Saga pattern (coordinate distributed transactions)',
|
|
82
|
-
],
|
|
83
|
-
duration_estimate: '1-3 days',
|
|
84
|
-
};
|
|
85
|
-
}
|
|
@@ -1,213 +0,0 @@
|
|
|
1
|
-
import { AgentPlan, WorkerAgentType } from '../types.js';
|
|
2
|
-
|
|
3
|
-
type TaskCategory = 'api-endpoint' | 'ui-component' | 'utility' | 'service' | 'general';
|
|
4
|
-
|
|
5
|
-
function detectCategory(task: string): TaskCategory {
|
|
6
|
-
const t = task.toLowerCase();
|
|
7
|
-
if (t.includes('endpoint') || t.includes('route') || t.includes('controller') || t.includes('rest') || t.includes('graphql')) return 'api-endpoint';
|
|
8
|
-
if (t.includes('component') || t.includes('ui') || t.includes('button') || t.includes('form') || t.includes('modal') || t.includes('page')) return 'ui-component';
|
|
9
|
-
if (t.includes('util') || t.includes('helper') || t.includes('format') || t.includes('parse') || t.includes('transform')) return 'utility';
|
|
10
|
-
if (t.includes('service') || t.includes('manager') || t.includes('handler') || t.includes('processor') || t.includes('worker')) return 'service';
|
|
11
|
-
return 'general';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const categoryApproach: Record<TaskCategory, string> = {
|
|
15
|
-
'api-endpoint': 'Design the contract first (request/response types), implement handler with validation, wire middleware chain, write integration tests.',
|
|
16
|
-
'ui-component': 'Define props interface, sketch component tree, implement stateless core first then add state/effects, ensure accessibility, write render tests.',
|
|
17
|
-
'utility': 'Write pure functions with explicit input/output types, cover all edge cases including null/undefined/empty, optimise for readability over cleverness.',
|
|
18
|
-
'service': 'Apply Dependency Injection, define interface before class, implement with repository abstraction, propagate typed errors, add unit tests for each method.',
|
|
19
|
-
'general': 'Define types first, implement incrementally, handle all error paths explicitly, add JSDoc for public APIs, write tests in parallel with implementation.',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const categorySteps: Record<TaskCategory, string[]> = {
|
|
23
|
-
'api-endpoint': [
|
|
24
|
-
'Define TypeScript interfaces for request body, query params, and response payload',
|
|
25
|
-
'Write input validation schema (zod or class-validator)',
|
|
26
|
-
'Stub out the route handler and wire it in the router',
|
|
27
|
-
'Implement business logic in a dedicated service class',
|
|
28
|
-
'Add authentication/authorisation middleware as required',
|
|
29
|
-
'Implement error handling — map domain errors to HTTP status codes',
|
|
30
|
-
'Add request logging and correlation ID propagation',
|
|
31
|
-
'Write integration tests hitting the endpoint directly',
|
|
32
|
-
'Document the endpoint with OpenAPI/JSDoc annotations',
|
|
33
|
-
'Test error paths: missing fields, invalid types, unauthorised access',
|
|
34
|
-
],
|
|
35
|
-
'ui-component': [
|
|
36
|
-
'Define the Props interface with JSDoc on each prop',
|
|
37
|
-
'Sketch the component tree — identify sub-components to extract',
|
|
38
|
-
'Implement the purely presentational render first with hardcoded data',
|
|
39
|
-
'Replace hardcoded data with props, add PropTypes/TypeScript narrowing',
|
|
40
|
-
'Add local state and effects only after the static render is correct',
|
|
41
|
-
'Implement loading and error states',
|
|
42
|
-
'Add keyboard navigation and ARIA attributes',
|
|
43
|
-
'Test with screen reader using browser dev tools',
|
|
44
|
-
'Add responsive CSS — mobile first with breakpoints',
|
|
45
|
-
'Write render tests covering each significant prop combination',
|
|
46
|
-
],
|
|
47
|
-
'utility': [
|
|
48
|
-
'Write function signature with explicit parameter and return types',
|
|
49
|
-
'Document expected input/output with JSDoc examples',
|
|
50
|
-
'Handle null, undefined, and empty inputs explicitly',
|
|
51
|
-
'Handle boundary conditions (zero, negative, overflow, max-length)',
|
|
52
|
-
'Implement the happy-path logic',
|
|
53
|
-
'Add guards and early returns for invalid inputs',
|
|
54
|
-
'Write unit tests for each distinct input category',
|
|
55
|
-
'Benchmark if the utility is on a hot path',
|
|
56
|
-
'Export from an index barrel so imports stay clean',
|
|
57
|
-
],
|
|
58
|
-
'service': [
|
|
59
|
-
'Define the service interface (IMyService) with all public methods',
|
|
60
|
-
'List constructor dependencies — inject via interface not concrete class',
|
|
61
|
-
'Write method stubs with return types before implementing',
|
|
62
|
-
'Implement each method with a single clear responsibility',
|
|
63
|
-
'Use typed Result or throw typed domain errors — no raw Error strings',
|
|
64
|
-
'Log structured data (not plain strings) at appropriate log levels',
|
|
65
|
-
'Write unit tests with mocked dependencies for each method',
|
|
66
|
-
'Write integration test against a real dependency (DB, API) if applicable',
|
|
67
|
-
'Document retry / circuit-breaker strategy for external calls',
|
|
68
|
-
'Add health-check method if the service wraps an external resource',
|
|
69
|
-
],
|
|
70
|
-
'general': [
|
|
71
|
-
'Clarify and write down acceptance criteria before touching code',
|
|
72
|
-
'Define all TypeScript types/interfaces needed',
|
|
73
|
-
'Break the work into small independently testable functions',
|
|
74
|
-
'Implement incrementally — make it work, then make it right',
|
|
75
|
-
'Handle all error paths explicitly with typed errors',
|
|
76
|
-
'Add JSDoc to every exported symbol',
|
|
77
|
-
'Write unit tests alongside implementation',
|
|
78
|
-
'Run the linter and fix all warnings',
|
|
79
|
-
'Review the diff for accidental debug code or console.log statements',
|
|
80
|
-
'Update relevant documentation or README if the public API changes',
|
|
81
|
-
],
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const categoryChecklist: Record<TaskCategory, string[]> = {
|
|
85
|
-
'api-endpoint': [
|
|
86
|
-
'[ ] Request DTO fully typed with validation annotations',
|
|
87
|
-
'[ ] Response DTO typed — no raw any or unknown leaking out',
|
|
88
|
-
'[ ] HTTP status codes are semantically correct (201 vs 200, 422 vs 400)',
|
|
89
|
-
'[ ] Auth middleware applied where required',
|
|
90
|
-
'[ ] Rate limiting considered',
|
|
91
|
-
'[ ] Input sanitisation prevents injection',
|
|
92
|
-
'[ ] Async handler wrapped to forward errors to Express error middleware',
|
|
93
|
-
'[ ] Pagination implemented for list endpoints',
|
|
94
|
-
'[ ] Integration test covers 200, 400, 401, 404, 500 paths',
|
|
95
|
-
'[ ] OpenAPI annotation added',
|
|
96
|
-
'[ ] No secrets or PII logged',
|
|
97
|
-
'[ ] Idempotency considered for mutating endpoints',
|
|
98
|
-
],
|
|
99
|
-
'ui-component': [
|
|
100
|
-
'[ ] Props interface exported and all props documented',
|
|
101
|
-
'[ ] No inline styles — use CSS modules or styled components',
|
|
102
|
-
'[ ] Loading state renders a skeleton or spinner',
|
|
103
|
-
'[ ] Error state renders a user-friendly message',
|
|
104
|
-
'[ ] Empty state renders a meaningful prompt',
|
|
105
|
-
'[ ] ARIA roles and labels present on interactive elements',
|
|
106
|
-
'[ ] Tab order is logical',
|
|
107
|
-
'[ ] Component is keyboard-operable without mouse',
|
|
108
|
-
'[ ] Works at 320 px (mobile) and 1440 px (desktop)',
|
|
109
|
-
'[ ] No useEffect with missing dependency array entries',
|
|
110
|
-
'[ ] Memoisation applied only where profiling justifies it',
|
|
111
|
-
'[ ] Render test covers loading, error, and data states',
|
|
112
|
-
],
|
|
113
|
-
'utility': [
|
|
114
|
-
'[ ] Function is pure — no hidden side effects',
|
|
115
|
-
'[ ] Returns typed result, not any',
|
|
116
|
-
'[ ] Handles null and undefined inputs without throwing',
|
|
117
|
-
'[ ] Handles empty string and empty array inputs',
|
|
118
|
-
'[ ] Handles numeric edge cases (NaN, Infinity, 0, negative)',
|
|
119
|
-
'[ ] Unit test for each distinct input category',
|
|
120
|
-
'[ ] Exported from barrel index',
|
|
121
|
-
'[ ] JSDoc with @param, @returns, and @example',
|
|
122
|
-
],
|
|
123
|
-
'service': [
|
|
124
|
-
'[ ] Interface defined before implementation class',
|
|
125
|
-
'[ ] All dependencies injected — no new SomeDependency() in methods',
|
|
126
|
-
'[ ] Each public method has a single responsibility',
|
|
127
|
-
'[ ] Typed errors thrown — no throw new Error("raw string")',
|
|
128
|
-
'[ ] External calls have timeout configured',
|
|
129
|
-
'[ ] Unit tests mock all external dependencies',
|
|
130
|
-
'[ ] Integration test covers the real dependency path',
|
|
131
|
-
'[ ] Logs structured objects, not string concatenation',
|
|
132
|
-
'[ ] No business logic in the constructor',
|
|
133
|
-
'[ ] Service registered in the DI container',
|
|
134
|
-
],
|
|
135
|
-
'general': [
|
|
136
|
-
'[ ] Acceptance criteria written before coding',
|
|
137
|
-
'[ ] All types explicit — no implicit any',
|
|
138
|
-
'[ ] All error paths handled',
|
|
139
|
-
'[ ] JSDoc on every exported symbol',
|
|
140
|
-
'[ ] Unit tests written alongside implementation',
|
|
141
|
-
'[ ] No console.log left in committed code',
|
|
142
|
-
'[ ] Linter passes with zero warnings',
|
|
143
|
-
'[ ] No TODO comments without a linked issue number',
|
|
144
|
-
'[ ] Public API is backwards-compatible or version-bumped',
|
|
145
|
-
'[ ] Documentation updated if the public API changed',
|
|
146
|
-
],
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
const categoryPitfalls: Record<TaskCategory, string[]> = {
|
|
150
|
-
'api-endpoint': [
|
|
151
|
-
'Forgetting to await async middleware — silently skips auth checks',
|
|
152
|
-
'Returning 200 for operations that create resources — use 201',
|
|
153
|
-
'Leaking internal stack traces to the client in production',
|
|
154
|
-
'Not validating Content-Type header before parsing body',
|
|
155
|
-
'Using req.body directly without validation — injection risk',
|
|
156
|
-
],
|
|
157
|
-
'ui-component': [
|
|
158
|
-
'Calling setState inside useEffect without a dependency array — infinite loop',
|
|
159
|
-
'Forgetting key prop on list items — causes subtle reconciliation bugs',
|
|
160
|
-
'Storing derived data in state instead of computing it on render',
|
|
161
|
-
'Leaving event listeners without cleanup in useEffect return',
|
|
162
|
-
'Assuming controlled and uncontrolled prop modes cannot conflict',
|
|
163
|
-
],
|
|
164
|
-
'utility': [
|
|
165
|
-
'Using == instead of === for null checks — misses undefined',
|
|
166
|
-
'Mutating the input array or object instead of returning a new one',
|
|
167
|
-
'Assuming parseInt always returns a number — it returns NaN on bad input',
|
|
168
|
-
'Using Date arithmetic without accounting for timezone offsets',
|
|
169
|
-
],
|
|
170
|
-
'service': [
|
|
171
|
-
'Catching and swallowing errors silently — log and rethrow or return Result',
|
|
172
|
-
'Doing database work in the constructor — blocks DI container startup',
|
|
173
|
-
'Sharing mutable state across concurrent requests — use per-request scope',
|
|
174
|
-
'Not configuring timeout on external HTTP calls — hangs indefinitely',
|
|
175
|
-
],
|
|
176
|
-
'general': [
|
|
177
|
-
'Premature optimisation before profiling — adds complexity with no gain',
|
|
178
|
-
'Mixing abstraction levels in a single function — extract sub-functions',
|
|
179
|
-
'Returning null instead of throwing when the contract is violated',
|
|
180
|
-
'Copy-pasting similar blocks instead of extracting a parameterised function',
|
|
181
|
-
],
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
const categoryPatterns: Record<TaskCategory, string[]> = {
|
|
185
|
-
'api-endpoint': ['Command pattern', 'Chain of Responsibility (middleware)', 'DTO pattern', 'Repository pattern', 'Decorator pattern (route guards)'],
|
|
186
|
-
'ui-component': ['Compound component pattern', 'Render props', 'Custom hook extraction', 'Container / Presenter split', 'Controlled component pattern'],
|
|
187
|
-
'utility': ['Pure function', 'Pipe / compose', 'Guard clause early return', 'Option/Result type', 'Memoisation'],
|
|
188
|
-
'service': ['Dependency Injection', 'Repository pattern', 'Strategy pattern', 'Result type', 'Façade pattern'],
|
|
189
|
-
'general': ['Single Responsibility Principle', 'Dependency Inversion', 'Guard clauses', 'Factory function', 'Module pattern'],
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
const categoryDuration: Record<TaskCategory, string> = {
|
|
193
|
-
'api-endpoint': '2-4 hours',
|
|
194
|
-
'ui-component': '3-6 hours',
|
|
195
|
-
'utility': '1-2 hours',
|
|
196
|
-
'service': '4-8 hours',
|
|
197
|
-
'general': '2-4 hours',
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
export function plan(task: string, context?: string): AgentPlan {
|
|
201
|
-
const category = detectCategory(task + ' ' + (context ?? ''));
|
|
202
|
-
return {
|
|
203
|
-
agent: 'coder' as WorkerAgentType,
|
|
204
|
-
task,
|
|
205
|
-
tier: 2,
|
|
206
|
-
approach: categoryApproach[category],
|
|
207
|
-
steps: categorySteps[category],
|
|
208
|
-
checklist: categoryChecklist[category],
|
|
209
|
-
pitfalls: categoryPitfalls[category],
|
|
210
|
-
patterns: categoryPatterns[category],
|
|
211
|
-
duration_estimate: categoryDuration[category],
|
|
212
|
-
};
|
|
213
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import { AgentPlan, WorkerAgentType } from '../types.js';
|
|
2
|
-
|
|
3
|
-
type DbType = 'rdbms' | 'nosql' | 'timeseries' | 'graph' | 'general';
|
|
4
|
-
|
|
5
|
-
function detectDbType(task: string, context?: string): DbType {
|
|
6
|
-
const combined = (task + ' ' + (context ?? '')).toLowerCase();
|
|
7
|
-
if (combined.includes('mongo') || combined.includes('document') || combined.includes('dynamodb') || combined.includes('firestore') || combined.includes('nosql')) return 'nosql';
|
|
8
|
-
if (combined.includes('timeseries') || combined.includes('influx') || combined.includes('prometheus') || combined.includes('clickhouse') || combined.includes('time series')) return 'timeseries';
|
|
9
|
-
if (combined.includes('graph') || combined.includes('neo4j') || combined.includes('relationship')) return 'graph';
|
|
10
|
-
if (combined.includes('postgres') || combined.includes('mysql') || combined.includes('sqlite') || combined.includes('sql') || combined.includes('relational')) return 'rdbms';
|
|
11
|
-
return 'general';
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
const dbApproach: Record<DbType, string> = {
|
|
15
|
-
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.',
|
|
16
|
-
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.',
|
|
17
|
-
timeseries: 'Optimise for append-heavy write patterns. Use time-bucketed partitioning. Compress old data with downsampling. Design queries around time ranges, not individual rows.',
|
|
18
|
-
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.',
|
|
19
|
-
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.',
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export function plan(task: string, context?: string): AgentPlan {
|
|
23
|
-
const dbType = detectDbType(task, context);
|
|
24
|
-
|
|
25
|
-
return {
|
|
26
|
-
agent: 'database' as WorkerAgentType,
|
|
27
|
-
task,
|
|
28
|
-
tier: 3,
|
|
29
|
-
approach: dbApproach[dbType],
|
|
30
|
-
steps: [
|
|
31
|
-
'List all entities and their relationships — draw an ER diagram',
|
|
32
|
-
'Identify the top 5 most frequent query patterns (what will be read most?)',
|
|
33
|
-
'Design the schema to serve those queries with minimal joins/lookups',
|
|
34
|
-
'Add primary keys and unique constraints first',
|
|
35
|
-
'Add foreign key constraints for relational integrity',
|
|
36
|
-
'Identify every column used in WHERE, ORDER BY, or JOIN — add indexes',
|
|
37
|
-
'Choose composite index column order by selectivity (most selective first)',
|
|
38
|
-
'Design the migration script: additive changes first (new tables, new nullable columns)',
|
|
39
|
-
'Write seed / fixture data for the development environment',
|
|
40
|
-
'Write query tests that assert on execution plan (EXPLAIN ANALYZE)',
|
|
41
|
-
'Set up connection pooling with appropriate pool size for the workload',
|
|
42
|
-
'Configure statement_timeout and lock_timeout to prevent runaway queries',
|
|
43
|
-
'Plan archival strategy for old data — partitioning or archival table',
|
|
44
|
-
'Document the schema with comments on each table and non-obvious column',
|
|
45
|
-
],
|
|
46
|
-
checklist: [
|
|
47
|
-
'[ ] Every table has a primary key',
|
|
48
|
-
'[ ] Foreign keys are declared and indexed',
|
|
49
|
-
'[ ] Every JOIN column on the many-side has an index',
|
|
50
|
-
'[ ] Every column used in frequent WHERE clauses has an index',
|
|
51
|
-
'[ ] No SELECT * in production queries — enumerate columns',
|
|
52
|
-
'[ ] Multi-table mutations wrapped in transactions',
|
|
53
|
-
'[ ] Migrations are reversible (down migration written)',
|
|
54
|
-
'[ ] Migration tested on a copy of production data volume',
|
|
55
|
-
'[ ] Connection pool size calculated: connections = (core_count * 2) + effective_spindle_count',
|
|
56
|
-
'[ ] statement_timeout configured to prevent runaway queries',
|
|
57
|
-
'[ ] EXPLAIN ANALYZE run on all slow query candidates',
|
|
58
|
-
'[ ] Sensitive columns (PII, passwords) identified and encrypted at rest',
|
|
59
|
-
'[ ] Backup and point-in-time recovery tested',
|
|
60
|
-
'[ ] Schema documented with table and column comments',
|
|
61
|
-
],
|
|
62
|
-
pitfalls: [
|
|
63
|
-
'Using SELECT * in application queries — sends unnecessary data over the wire and breaks when columns are added/removed',
|
|
64
|
-
'Forgetting to index foreign keys — causes full table scans on every JOIN',
|
|
65
|
-
'Storing JSON blobs in relational databases to avoid schema work — kills query performance and integrity',
|
|
66
|
-
'Not wrapping multi-step mutations in a transaction — leaves the database in a partially updated state on failure',
|
|
67
|
-
'Using ORM-generated schemas without reviewing the SQL — ORMs frequently generate non-optimal index choices',
|
|
68
|
-
'Choosing UUID as a clustered primary key in PostgreSQL without understanding write amplification from random page splits',
|
|
69
|
-
'Ignoring VACUUM in PostgreSQL — table bloat degrades read performance over time',
|
|
70
|
-
'Testing migrations only on an empty database — schema changes that work on empty DBs may lock production tables for minutes',
|
|
71
|
-
],
|
|
72
|
-
patterns: [
|
|
73
|
-
'Repository pattern (abstract DB access behind an interface)',
|
|
74
|
-
'Unit of Work pattern (group related DB operations into a transaction)',
|
|
75
|
-
'CQRS (separate read and write models for high-throughput systems)',
|
|
76
|
-
'Event Sourcing (store events, derive state — for audit-heavy domains)',
|
|
77
|
-
'Optimistic locking (version column for concurrent update detection)',
|
|
78
|
-
'Soft delete pattern (deleted_at timestamp instead of hard DELETE)',
|
|
79
|
-
'Temporal tables (track history of row changes)',
|
|
80
|
-
],
|
|
81
|
-
duration_estimate: '1-2 days',
|
|
82
|
-
};
|
|
83
|
-
}
|