|
| 1 | +""" |
| 2 | +Express configuration presets for common project types |
| 3 | +""" |
| 4 | + |
| 5 | +from typing import Dict, Any, Optional |
| 6 | + |
| 7 | +# Express configurations for common project types |
| 8 | +EXPRESS_CONFIGS = { |
| 9 | + "react-typescript": { |
| 10 | + "patterns": ["react", "typescript", "tsx", "jsx"], |
| 11 | + "roles": {"default": "dev", "specialized": ["frontend", "code-reviewer"]}, |
| 12 | + "github_integration": {"issue_to_task": True, "pr_reviews": True}, |
| 13 | + "build_validation": ["npm test", "npm run build"], |
| 14 | + "suggested_tasks": [ |
| 15 | + { |
| 16 | + "title": "Set up component testing with React Testing Library", |
| 17 | + "labels": ["conductor:task", "testing", "frontend"], |
| 18 | + }, |
| 19 | + { |
| 20 | + "title": "Add Storybook for component development", |
| 21 | + "labels": ["conductor:task", "enhancement", "frontend"], |
| 22 | + }, |
| 23 | + { |
| 24 | + "title": "Configure ESLint and Prettier", |
| 25 | + "labels": ["conductor:task", "code-quality", "dev-experience"], |
| 26 | + }, |
| 27 | + ], |
| 28 | + }, |
| 29 | + "python-fastapi": { |
| 30 | + "patterns": ["fastapi", "python", "uvicorn", "pydantic"], |
| 31 | + "roles": {"default": "dev", "specialized": ["backend", "code-reviewer"]}, |
| 32 | + "github_integration": {"issue_to_task": True, "pr_reviews": True}, |
| 33 | + "build_validation": ["pytest", "black --check ."], |
| 34 | + "suggested_tasks": [ |
| 35 | + { |
| 36 | + "title": "Add API documentation with OpenAPI", |
| 37 | + "labels": ["conductor:task", "documentation", "backend"], |
| 38 | + }, |
| 39 | + { |
| 40 | + "title": "Set up database migrations with Alembic", |
| 41 | + "labels": ["conductor:task", "database", "backend"], |
| 42 | + }, |
| 43 | + { |
| 44 | + "title": "Add integration tests for endpoints", |
| 45 | + "labels": ["conductor:task", "testing", "backend"], |
| 46 | + }, |
| 47 | + ], |
| 48 | + }, |
| 49 | + "nextjs-fullstack": { |
| 50 | + "patterns": ["next", "react", "vercel"], |
| 51 | + "roles": { |
| 52 | + "default": "dev", |
| 53 | + "specialized": ["frontend", "backend", "code-reviewer"], |
| 54 | + }, |
| 55 | + "github_integration": {"issue_to_task": True, "pr_reviews": True}, |
| 56 | + "build_validation": ["npm test", "npm run build", "npm run lint"], |
| 57 | + "suggested_tasks": [ |
| 58 | + { |
| 59 | + "title": "Set up authentication with NextAuth.js", |
| 60 | + "labels": ["conductor:task", "auth", "fullstack"], |
| 61 | + }, |
| 62 | + { |
| 63 | + "title": "Configure Prisma for database access", |
| 64 | + "labels": ["conductor:task", "database", "backend"], |
| 65 | + }, |
| 66 | + { |
| 67 | + "title": "Add E2E tests with Playwright", |
| 68 | + "labels": ["conductor:task", "testing", "e2e"], |
| 69 | + }, |
| 70 | + ], |
| 71 | + }, |
| 72 | + "vue-javascript": { |
| 73 | + "patterns": ["vue", "nuxt", "vite"], |
| 74 | + "roles": {"default": "dev", "specialized": ["frontend", "code-reviewer"]}, |
| 75 | + "github_integration": {"issue_to_task": True, "pr_reviews": True}, |
| 76 | + "build_validation": ["npm test", "npm run build"], |
| 77 | + "suggested_tasks": [ |
| 78 | + { |
| 79 | + "title": "Set up Pinia for state management", |
| 80 | + "labels": ["conductor:task", "state-management", "frontend"], |
| 81 | + }, |
| 82 | + { |
| 83 | + "title": "Add component testing with Vitest", |
| 84 | + "labels": ["conductor:task", "testing", "frontend"], |
| 85 | + }, |
| 86 | + { |
| 87 | + "title": "Configure Vue Router for navigation", |
| 88 | + "labels": ["conductor:task", "routing", "frontend"], |
| 89 | + }, |
| 90 | + ], |
| 91 | + }, |
| 92 | + "python-django": { |
| 93 | + "patterns": ["django", "python", "wsgi"], |
| 94 | + "roles": {"default": "dev", "specialized": ["backend", "code-reviewer"]}, |
| 95 | + "github_integration": {"issue_to_task": True, "pr_reviews": True}, |
| 96 | + "build_validation": ["python manage.py test", "black --check ."], |
| 97 | + "suggested_tasks": [ |
| 98 | + { |
| 99 | + "title": "Set up Django REST framework", |
| 100 | + "labels": ["conductor:task", "api", "backend"], |
| 101 | + }, |
| 102 | + { |
| 103 | + "title": "Configure Celery for async tasks", |
| 104 | + "labels": ["conductor:task", "async", "backend"], |
| 105 | + }, |
| 106 | + { |
| 107 | + "title": "Add Django Debug Toolbar", |
| 108 | + "labels": ["conductor:task", "dev-experience", "backend"], |
| 109 | + }, |
| 110 | + ], |
| 111 | + }, |
| 112 | + "go-microservices": { |
| 113 | + "patterns": ["go", "gin", "fiber", "echo"], |
| 114 | + "roles": {"default": "dev", "specialized": ["backend", "code-reviewer"]}, |
| 115 | + "github_integration": {"issue_to_task": True, "pr_reviews": True}, |
| 116 | + "build_validation": ["go test ./...", "go build"], |
| 117 | + "suggested_tasks": [ |
| 118 | + { |
| 119 | + "title": "Set up structured logging with zerolog", |
| 120 | + "labels": ["conductor:task", "observability", "backend"], |
| 121 | + }, |
| 122 | + { |
| 123 | + "title": "Add OpenTelemetry instrumentation", |
| 124 | + "labels": ["conductor:task", "observability", "backend"], |
| 125 | + }, |
| 126 | + { |
| 127 | + "title": "Create Dockerfile and docker-compose", |
| 128 | + "labels": ["conductor:task", "devops", "containers"], |
| 129 | + }, |
| 130 | + ], |
| 131 | + }, |
| 132 | + "rust-cli": { |
| 133 | + "patterns": ["rust", "cargo", "clap"], |
| 134 | + "roles": {"default": "dev", "specialized": ["backend", "code-reviewer"]}, |
| 135 | + "github_integration": {"issue_to_task": True, "pr_reviews": True}, |
| 136 | + "build_validation": ["cargo test", "cargo build --release"], |
| 137 | + "suggested_tasks": [ |
| 138 | + { |
| 139 | + "title": "Add comprehensive CLI tests", |
| 140 | + "labels": ["conductor:task", "testing", "cli"], |
| 141 | + }, |
| 142 | + { |
| 143 | + "title": "Set up GitHub release workflow", |
| 144 | + "labels": ["conductor:task", "ci-cd", "devops"], |
| 145 | + }, |
| 146 | + { |
| 147 | + "title": "Add shell completion generation", |
| 148 | + "labels": ["conductor:task", "enhancement", "cli"], |
| 149 | + }, |
| 150 | + ], |
| 151 | + }, |
| 152 | + "mobile-react-native": { |
| 153 | + "patterns": ["react-native", "expo", "ios", "android"], |
| 154 | + "roles": {"default": "dev", "specialized": ["mobile", "code-reviewer"]}, |
| 155 | + "github_integration": {"issue_to_task": True, "pr_reviews": True}, |
| 156 | + "build_validation": ["npm test", "npm run lint"], |
| 157 | + "suggested_tasks": [ |
| 158 | + { |
| 159 | + "title": "Set up Detox for E2E testing", |
| 160 | + "labels": ["conductor:task", "testing", "mobile"], |
| 161 | + }, |
| 162 | + { |
| 163 | + "title": "Configure push notifications", |
| 164 | + "labels": ["conductor:task", "feature", "mobile"], |
| 165 | + }, |
| 166 | + { |
| 167 | + "title": "Add crash reporting with Sentry", |
| 168 | + "labels": ["conductor:task", "monitoring", "mobile"], |
| 169 | + }, |
| 170 | + ], |
| 171 | + }, |
| 172 | +} |
| 173 | + |
| 174 | + |
| 175 | +def get_express_config(stack_info: Dict[str, Any]) -> Optional[Dict[str, Any]]: |
| 176 | + """Match detected stack to express config""" |
| 177 | + # Use the primary stack from summary if available |
| 178 | + if stack_info.get("summary", {}).get("primary_stack"): |
| 179 | + stack_name = stack_info["summary"]["primary_stack"] |
| 180 | + if stack_name in EXPRESS_CONFIGS: |
| 181 | + return EXPRESS_CONFIGS[stack_name] |
| 182 | + |
| 183 | + # Otherwise try pattern matching |
| 184 | + detected_items = set() |
| 185 | + detected_items.update(stack_info.get("frameworks", [])) |
| 186 | + detected_items.update(stack_info.get("summary", {}).get("languages", [])) |
| 187 | + detected_items.update(stack_info.get("summary", {}).get("tools", [])) |
| 188 | + |
| 189 | + # Add items from modern tools |
| 190 | + modern = stack_info.get("modern_tools", {}) |
| 191 | + if modern.get("framework"): |
| 192 | + detected_items.add(modern["framework"]) |
| 193 | + if modern.get("build_tool"): |
| 194 | + detected_items.add(modern["build_tool"]) |
| 195 | + |
| 196 | + # Find best match |
| 197 | + best_match = None |
| 198 | + best_score = 0 |
| 199 | + |
| 200 | + for stack_name, config in EXPRESS_CONFIGS.items(): |
| 201 | + score = len(detected_items.intersection(config["patterns"])) |
| 202 | + if score > best_score: |
| 203 | + best_match = stack_name |
| 204 | + best_score = score |
| 205 | + |
| 206 | + return EXPRESS_CONFIGS.get(best_match) if best_match and best_score > 0 else None |
0 commit comments