@musashishao/agent-kit 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/.agent/.shared/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/.shared/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/.shared/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/.shared/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/jetpack-compose.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/.shared/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/.shared/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/.shared/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/.shared/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/.shared/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/.shared/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/core.py +258 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/design_system.py +487 -0
- package/.agent/.shared/ui-ux-pro-max/scripts/search.py +76 -0
- package/.agent/ARCHITECTURE.md +225 -0
- package/.agent/CONTEXT.md +229 -0
- package/.agent/FEATURE_ROADMAP.md +435 -0
- package/.agent/PROMPT_TEMPLATES.md +261 -0
- package/.agent/agents/backend-specialist.md +263 -0
- package/.agent/agents/database-architect.md +226 -0
- package/.agent/agents/debugger.md +225 -0
- package/.agent/agents/devops-engineer.md +242 -0
- package/.agent/agents/documentation-writer.md +104 -0
- package/.agent/agents/explorer-agent.md +73 -0
- package/.agent/agents/frontend-specialist.md +556 -0
- package/.agent/agents/game-developer.md +162 -0
- package/.agent/agents/mobile-developer.md +377 -0
- package/.agent/agents/orchestrator.md +416 -0
- package/.agent/agents/penetration-tester.md +188 -0
- package/.agent/agents/performance-optimizer.md +187 -0
- package/.agent/agents/project-planner.md +403 -0
- package/.agent/agents/security-auditor.md +170 -0
- package/.agent/agents/seo-specialist.md +111 -0
- package/.agent/agents/test-engineer.md +158 -0
- package/.agent/rules/GEMINI.md +251 -0
- package/.agent/skills/api-patterns/SKILL.md +81 -0
- package/.agent/skills/api-patterns/api-style.md +42 -0
- package/.agent/skills/api-patterns/auth.md +24 -0
- package/.agent/skills/api-patterns/documentation.md +26 -0
- package/.agent/skills/api-patterns/graphql.md +41 -0
- package/.agent/skills/api-patterns/rate-limiting.md +31 -0
- package/.agent/skills/api-patterns/response.md +37 -0
- package/.agent/skills/api-patterns/rest.md +40 -0
- package/.agent/skills/api-patterns/scripts/api_validator.py +211 -0
- package/.agent/skills/api-patterns/security-testing.md +122 -0
- package/.agent/skills/api-patterns/trpc.md +41 -0
- package/.agent/skills/api-patterns/versioning.md +22 -0
- package/.agent/skills/app-builder/SKILL.md +75 -0
- package/.agent/skills/app-builder/agent-coordination.md +71 -0
- package/.agent/skills/app-builder/feature-building.md +53 -0
- package/.agent/skills/app-builder/project-detection.md +34 -0
- package/.agent/skills/app-builder/scaffolding.md +118 -0
- package/.agent/skills/app-builder/tech-stack.md +40 -0
- package/.agent/skills/app-builder/templates/SKILL.md +39 -0
- package/.agent/skills/app-builder/templates/astro-static/TEMPLATE.md +76 -0
- package/.agent/skills/app-builder/templates/chrome-extension/TEMPLATE.md +92 -0
- package/.agent/skills/app-builder/templates/cli-tool/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/electron-desktop/TEMPLATE.md +88 -0
- package/.agent/skills/app-builder/templates/express-api/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/flutter-app/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/monorepo-turborepo/TEMPLATE.md +90 -0
- package/.agent/skills/app-builder/templates/nextjs-fullstack/TEMPLATE.md +82 -0
- package/.agent/skills/app-builder/templates/nextjs-saas/TEMPLATE.md +100 -0
- package/.agent/skills/app-builder/templates/nextjs-static/TEMPLATE.md +106 -0
- package/.agent/skills/app-builder/templates/nuxt-app/TEMPLATE.md +101 -0
- package/.agent/skills/app-builder/templates/python-fastapi/TEMPLATE.md +83 -0
- package/.agent/skills/app-builder/templates/react-native-app/TEMPLATE.md +93 -0
- package/.agent/skills/architecture/SKILL.md +55 -0
- package/.agent/skills/architecture/context-discovery.md +43 -0
- package/.agent/skills/architecture/examples.md +94 -0
- package/.agent/skills/architecture/pattern-selection.md +68 -0
- package/.agent/skills/architecture/patterns-reference.md +50 -0
- package/.agent/skills/architecture/trade-off-analysis.md +77 -0
- package/.agent/skills/bash-linux/SKILL.md +199 -0
- package/.agent/skills/behavioral-modes/SKILL.md +242 -0
- package/.agent/skills/brainstorming/SKILL.md +163 -0
- package/.agent/skills/brainstorming/dynamic-questioning.md +350 -0
- package/.agent/skills/clean-code/SKILL.md +201 -0
- package/.agent/skills/code-review-checklist/SKILL.md +109 -0
- package/.agent/skills/database-design/SKILL.md +52 -0
- package/.agent/skills/database-design/database-selection.md +43 -0
- package/.agent/skills/database-design/indexing.md +39 -0
- package/.agent/skills/database-design/migrations.md +48 -0
- package/.agent/skills/database-design/optimization.md +36 -0
- package/.agent/skills/database-design/orm-selection.md +30 -0
- package/.agent/skills/database-design/schema-design.md +56 -0
- package/.agent/skills/database-design/scripts/schema_validator.py +172 -0
- package/.agent/skills/deployment-procedures/SKILL.md +241 -0
- package/.agent/skills/doc.md +177 -0
- package/.agent/skills/docker-expert/SKILL.md +409 -0
- package/.agent/skills/documentation-templates/SKILL.md +194 -0
- package/.agent/skills/frontend-design/SKILL.md +396 -0
- package/.agent/skills/frontend-design/animation-guide.md +331 -0
- package/.agent/skills/frontend-design/color-system.md +311 -0
- package/.agent/skills/frontend-design/decision-trees.md +418 -0
- package/.agent/skills/frontend-design/motion-graphics.md +306 -0
- package/.agent/skills/frontend-design/scripts/accessibility_checker.py +183 -0
- package/.agent/skills/frontend-design/scripts/ux_audit.py +722 -0
- package/.agent/skills/frontend-design/typography-system.md +345 -0
- package/.agent/skills/frontend-design/ux-psychology.md +541 -0
- package/.agent/skills/frontend-design/visual-effects.md +383 -0
- package/.agent/skills/game-development/2d-games/SKILL.md +119 -0
- package/.agent/skills/game-development/3d-games/SKILL.md +135 -0
- package/.agent/skills/game-development/SKILL.md +167 -0
- package/.agent/skills/game-development/game-art/SKILL.md +185 -0
- package/.agent/skills/game-development/game-audio/SKILL.md +190 -0
- package/.agent/skills/game-development/game-design/SKILL.md +129 -0
- package/.agent/skills/game-development/mobile-games/SKILL.md +108 -0
- package/.agent/skills/game-development/multiplayer/SKILL.md +132 -0
- package/.agent/skills/game-development/pc-games/SKILL.md +144 -0
- package/.agent/skills/game-development/vr-ar/SKILL.md +123 -0
- package/.agent/skills/game-development/web-games/SKILL.md +150 -0
- package/.agent/skills/geo-fundamentals/SKILL.md +156 -0
- package/.agent/skills/geo-fundamentals/scripts/geo_checker.py +289 -0
- package/.agent/skills/i18n-localization/SKILL.md +154 -0
- package/.agent/skills/i18n-localization/scripts/i18n_checker.py +241 -0
- package/.agent/skills/lint-and-validate/SKILL.md +45 -0
- package/.agent/skills/lint-and-validate/scripts/lint_runner.py +172 -0
- package/.agent/skills/lint-and-validate/scripts/type_coverage.py +173 -0
- package/.agent/skills/mcp-builder/SKILL.md +176 -0
- package/.agent/skills/mobile-design/SKILL.md +394 -0
- package/.agent/skills/mobile-design/decision-trees.md +516 -0
- package/.agent/skills/mobile-design/mobile-backend.md +491 -0
- package/.agent/skills/mobile-design/mobile-color-system.md +420 -0
- package/.agent/skills/mobile-design/mobile-debugging.md +122 -0
- package/.agent/skills/mobile-design/mobile-design-thinking.md +357 -0
- package/.agent/skills/mobile-design/mobile-navigation.md +458 -0
- package/.agent/skills/mobile-design/mobile-performance.md +767 -0
- package/.agent/skills/mobile-design/mobile-testing.md +356 -0
- package/.agent/skills/mobile-design/mobile-typography.md +433 -0
- package/.agent/skills/mobile-design/platform-android.md +666 -0
- package/.agent/skills/mobile-design/platform-ios.md +561 -0
- package/.agent/skills/mobile-design/scripts/mobile_audit.py +670 -0
- package/.agent/skills/mobile-design/touch-psychology.md +537 -0
- package/.agent/skills/nestjs-expert/SKILL.md +552 -0
- package/.agent/skills/nextjs-best-practices/SKILL.md +203 -0
- package/.agent/skills/nodejs-best-practices/SKILL.md +333 -0
- package/.agent/skills/parallel-agents/SKILL.md +175 -0
- package/.agent/skills/performance-profiling/SKILL.md +143 -0
- package/.agent/skills/performance-profiling/scripts/lighthouse_audit.py +76 -0
- package/.agent/skills/plan-writing/SKILL.md +152 -0
- package/.agent/skills/powershell-windows/SKILL.md +167 -0
- package/.agent/skills/prisma-expert/SKILL.md +355 -0
- package/.agent/skills/python-patterns/SKILL.md +441 -0
- package/.agent/skills/react-patterns/SKILL.md +198 -0
- package/.agent/skills/red-team-tactics/SKILL.md +199 -0
- package/.agent/skills/seo-fundamentals/SKILL.md +129 -0
- package/.agent/skills/seo-fundamentals/scripts/seo_checker.py +219 -0
- package/.agent/skills/server-management/SKILL.md +161 -0
- package/.agent/skills/systematic-debugging/SKILL.md +109 -0
- package/.agent/skills/tailwind-patterns/SKILL.md +269 -0
- package/.agent/skills/tdd-workflow/SKILL.md +149 -0
- package/.agent/skills/testing-patterns/SKILL.md +178 -0
- package/.agent/skills/testing-patterns/scripts/test_runner.py +219 -0
- package/.agent/skills/typescript-expert/SKILL.md +429 -0
- package/.agent/skills/typescript-expert/references/tsconfig-strict.json +92 -0
- package/.agent/skills/typescript-expert/references/typescript-cheatsheet.md +383 -0
- package/.agent/skills/typescript-expert/references/utility-types.ts +335 -0
- package/.agent/skills/typescript-expert/scripts/ts_diagnostic.py +203 -0
- package/.agent/skills/ui-ux-pro-max/SKILL.md +351 -0
- package/.agent/skills/ui-ux-pro-max/data/charts.csv +26 -0
- package/.agent/skills/ui-ux-pro-max/data/colors.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/icons.csv +101 -0
- package/.agent/skills/ui-ux-pro-max/data/landing.csv +31 -0
- package/.agent/skills/ui-ux-pro-max/data/products.csv +97 -0
- package/.agent/skills/ui-ux-pro-max/data/prompts.csv +24 -0
- package/.agent/skills/ui-ux-pro-max/data/react-performance.csv +45 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/flutter.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/html-tailwind.csv +56 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nextjs.csv +53 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nuxt-ui.csv +51 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/nuxtjs.csv +59 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react-native.csv +52 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/react.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/shadcn.csv +61 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/svelte.csv +54 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/swiftui.csv +51 -0
- package/.agent/skills/ui-ux-pro-max/data/stacks/vue.csv +50 -0
- package/.agent/skills/ui-ux-pro-max/data/styles.csv +59 -0
- package/.agent/skills/ui-ux-pro-max/data/typography.csv +58 -0
- package/.agent/skills/ui-ux-pro-max/data/ui-reasoning.csv +101 -0
- package/.agent/skills/ui-ux-pro-max/data/ux-guidelines.csv +100 -0
- package/.agent/skills/ui-ux-pro-max/data/web-interface.csv +31 -0
- package/.agent/skills/ui-ux-pro-max/scripts/core.py +257 -0
- package/.agent/skills/ui-ux-pro-max/scripts/design_system.py +487 -0
- package/.agent/skills/ui-ux-pro-max/scripts/search.py +76 -0
- package/.agent/skills/vulnerability-scanner/SKILL.md +276 -0
- package/.agent/skills/vulnerability-scanner/checklists.md +121 -0
- package/.agent/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/.agent/skills/webapp-testing/SKILL.md +187 -0
- package/.agent/skills/webapp-testing/scripts/playwright_runner.py +173 -0
- package/.agent/workflows/brainstorm.md +113 -0
- package/.agent/workflows/create.md +59 -0
- package/.agent/workflows/debug.md +103 -0
- package/.agent/workflows/deploy.md +176 -0
- package/.agent/workflows/enhance.md +63 -0
- package/.agent/workflows/orchestrate.md +237 -0
- package/.agent/workflows/plan.md +89 -0
- package/.agent/workflows/preview.md +80 -0
- package/.agent/workflows/status.md +86 -0
- package/.agent/workflows/test.md +144 -0
- package/.agent/workflows/ui-ux-pro-max.md +231 -0
- package/LICENSE +21 -0
- package/README.md +101 -0
- package/bin/cli.js +235 -0
- package/index.js +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
Test Runner - Unified test execution and coverage reporting
|
|
4
|
+
Runs tests and generates coverage report based on project type.
|
|
5
|
+
|
|
6
|
+
Usage:
|
|
7
|
+
python test_runner.py <project_path> [--coverage]
|
|
8
|
+
|
|
9
|
+
Supports:
|
|
10
|
+
- Node.js: npm test, jest, vitest
|
|
11
|
+
- Python: pytest, unittest
|
|
12
|
+
"""
|
|
13
|
+
|
|
14
|
+
import subprocess
|
|
15
|
+
import sys
|
|
16
|
+
import json
|
|
17
|
+
from pathlib import Path
|
|
18
|
+
from datetime import datetime
|
|
19
|
+
|
|
20
|
+
# Fix Windows console encoding
|
|
21
|
+
try:
|
|
22
|
+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
23
|
+
except:
|
|
24
|
+
pass
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def detect_test_framework(project_path: Path) -> dict:
|
|
28
|
+
"""Detect test framework and commands."""
|
|
29
|
+
result = {
|
|
30
|
+
"type": "unknown",
|
|
31
|
+
"framework": None,
|
|
32
|
+
"cmd": None,
|
|
33
|
+
"coverage_cmd": None
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
# Node.js project
|
|
37
|
+
package_json = project_path / "package.json"
|
|
38
|
+
if package_json.exists():
|
|
39
|
+
result["type"] = "node"
|
|
40
|
+
try:
|
|
41
|
+
pkg = json.loads(package_json.read_text(encoding='utf-8'))
|
|
42
|
+
scripts = pkg.get("scripts", {})
|
|
43
|
+
deps = {**pkg.get("dependencies", {}), **pkg.get("devDependencies", {})}
|
|
44
|
+
|
|
45
|
+
# Check for test script
|
|
46
|
+
if "test" in scripts:
|
|
47
|
+
result["framework"] = "npm test"
|
|
48
|
+
result["cmd"] = ["npm", "test"]
|
|
49
|
+
|
|
50
|
+
# Try to detect specific framework for coverage
|
|
51
|
+
if "vitest" in deps:
|
|
52
|
+
result["framework"] = "vitest"
|
|
53
|
+
result["coverage_cmd"] = ["npx", "vitest", "run", "--coverage"]
|
|
54
|
+
elif "jest" in deps:
|
|
55
|
+
result["framework"] = "jest"
|
|
56
|
+
result["coverage_cmd"] = ["npx", "jest", "--coverage"]
|
|
57
|
+
elif "vitest" in deps:
|
|
58
|
+
result["framework"] = "vitest"
|
|
59
|
+
result["cmd"] = ["npx", "vitest", "run"]
|
|
60
|
+
result["coverage_cmd"] = ["npx", "vitest", "run", "--coverage"]
|
|
61
|
+
elif "jest" in deps:
|
|
62
|
+
result["framework"] = "jest"
|
|
63
|
+
result["cmd"] = ["npx", "jest"]
|
|
64
|
+
result["coverage_cmd"] = ["npx", "jest", "--coverage"]
|
|
65
|
+
|
|
66
|
+
except:
|
|
67
|
+
pass
|
|
68
|
+
|
|
69
|
+
# Python project
|
|
70
|
+
if (project_path / "pyproject.toml").exists() or (project_path / "requirements.txt").exists():
|
|
71
|
+
result["type"] = "python"
|
|
72
|
+
result["framework"] = "pytest"
|
|
73
|
+
result["cmd"] = ["python", "-m", "pytest", "-v"]
|
|
74
|
+
result["coverage_cmd"] = ["python", "-m", "pytest", "--cov", "--cov-report=term-missing"]
|
|
75
|
+
|
|
76
|
+
return result
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
def run_tests(cmd: list, cwd: Path) -> dict:
|
|
80
|
+
"""Run tests and return results."""
|
|
81
|
+
result = {
|
|
82
|
+
"passed": False,
|
|
83
|
+
"output": "",
|
|
84
|
+
"error": "",
|
|
85
|
+
"tests_run": 0,
|
|
86
|
+
"tests_passed": 0,
|
|
87
|
+
"tests_failed": 0
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
try:
|
|
91
|
+
proc = subprocess.run(
|
|
92
|
+
cmd,
|
|
93
|
+
cwd=str(cwd),
|
|
94
|
+
capture_output=True,
|
|
95
|
+
text=True,
|
|
96
|
+
encoding='utf-8',
|
|
97
|
+
errors='replace',
|
|
98
|
+
timeout=300 # 5 min timeout for tests
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
result["output"] = proc.stdout[:3000] if proc.stdout else ""
|
|
102
|
+
result["error"] = proc.stderr[:500] if proc.stderr else ""
|
|
103
|
+
result["passed"] = proc.returncode == 0
|
|
104
|
+
|
|
105
|
+
# Try to parse test counts from output
|
|
106
|
+
output = proc.stdout or ""
|
|
107
|
+
|
|
108
|
+
# Jest/Vitest pattern: "Tests: X passed, Y failed, Z total"
|
|
109
|
+
if "passed" in output.lower() and "failed" in output.lower():
|
|
110
|
+
import re
|
|
111
|
+
match = re.search(r'(\d+)\s+passed', output, re.IGNORECASE)
|
|
112
|
+
if match:
|
|
113
|
+
result["tests_passed"] = int(match.group(1))
|
|
114
|
+
match = re.search(r'(\d+)\s+failed', output, re.IGNORECASE)
|
|
115
|
+
if match:
|
|
116
|
+
result["tests_failed"] = int(match.group(1))
|
|
117
|
+
result["tests_run"] = result["tests_passed"] + result["tests_failed"]
|
|
118
|
+
|
|
119
|
+
# Pytest pattern: "X passed, Y failed"
|
|
120
|
+
if "pytest" in str(cmd):
|
|
121
|
+
import re
|
|
122
|
+
match = re.search(r'(\d+)\s+passed', output)
|
|
123
|
+
if match:
|
|
124
|
+
result["tests_passed"] = int(match.group(1))
|
|
125
|
+
match = re.search(r'(\d+)\s+failed', output)
|
|
126
|
+
if match:
|
|
127
|
+
result["tests_failed"] = int(match.group(1))
|
|
128
|
+
result["tests_run"] = result["tests_passed"] + result["tests_failed"]
|
|
129
|
+
|
|
130
|
+
except FileNotFoundError:
|
|
131
|
+
result["error"] = f"Command not found: {cmd[0]}"
|
|
132
|
+
except subprocess.TimeoutExpired:
|
|
133
|
+
result["error"] = "Timeout after 300s"
|
|
134
|
+
except Exception as e:
|
|
135
|
+
result["error"] = str(e)
|
|
136
|
+
|
|
137
|
+
return result
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def main():
|
|
141
|
+
project_path = Path(sys.argv[1] if len(sys.argv) > 1 else ".").resolve()
|
|
142
|
+
with_coverage = "--coverage" in sys.argv
|
|
143
|
+
|
|
144
|
+
print(f"\n{'='*60}")
|
|
145
|
+
print(f"[TEST RUNNER] Unified Test Execution")
|
|
146
|
+
print(f"{'='*60}")
|
|
147
|
+
print(f"Project: {project_path}")
|
|
148
|
+
print(f"Coverage: {'enabled' if with_coverage else 'disabled'}")
|
|
149
|
+
print(f"Time: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}")
|
|
150
|
+
|
|
151
|
+
# Detect test framework
|
|
152
|
+
test_info = detect_test_framework(project_path)
|
|
153
|
+
print(f"Type: {test_info['type']}")
|
|
154
|
+
print(f"Framework: {test_info['framework']}")
|
|
155
|
+
print("-"*60)
|
|
156
|
+
|
|
157
|
+
if not test_info["cmd"]:
|
|
158
|
+
print("No test framework found for this project.")
|
|
159
|
+
output = {
|
|
160
|
+
"script": "test_runner",
|
|
161
|
+
"project": str(project_path),
|
|
162
|
+
"type": test_info["type"],
|
|
163
|
+
"framework": None,
|
|
164
|
+
"passed": True,
|
|
165
|
+
"message": "No tests configured"
|
|
166
|
+
}
|
|
167
|
+
print(json.dumps(output, indent=2))
|
|
168
|
+
sys.exit(0)
|
|
169
|
+
|
|
170
|
+
# Choose command
|
|
171
|
+
cmd = test_info["coverage_cmd"] if with_coverage and test_info["coverage_cmd"] else test_info["cmd"]
|
|
172
|
+
|
|
173
|
+
print(f"Running: {' '.join(cmd)}")
|
|
174
|
+
print("-"*60)
|
|
175
|
+
|
|
176
|
+
# Run tests
|
|
177
|
+
result = run_tests(cmd, project_path)
|
|
178
|
+
|
|
179
|
+
# Print output (truncated)
|
|
180
|
+
if result["output"]:
|
|
181
|
+
lines = result["output"].split("\n")
|
|
182
|
+
for line in lines[:30]:
|
|
183
|
+
print(line)
|
|
184
|
+
if len(lines) > 30:
|
|
185
|
+
print(f"... ({len(lines) - 30} more lines)")
|
|
186
|
+
|
|
187
|
+
# Summary
|
|
188
|
+
print("\n" + "="*60)
|
|
189
|
+
print("SUMMARY")
|
|
190
|
+
print("="*60)
|
|
191
|
+
|
|
192
|
+
if result["passed"]:
|
|
193
|
+
print("[PASS] All tests passed")
|
|
194
|
+
else:
|
|
195
|
+
print("[FAIL] Some tests failed")
|
|
196
|
+
if result["error"]:
|
|
197
|
+
print(f"Error: {result['error'][:200]}")
|
|
198
|
+
|
|
199
|
+
if result["tests_run"] > 0:
|
|
200
|
+
print(f"Tests: {result['tests_run']} total, {result['tests_passed']} passed, {result['tests_failed']} failed")
|
|
201
|
+
|
|
202
|
+
output = {
|
|
203
|
+
"script": "test_runner",
|
|
204
|
+
"project": str(project_path),
|
|
205
|
+
"type": test_info["type"],
|
|
206
|
+
"framework": test_info["framework"],
|
|
207
|
+
"tests_run": result["tests_run"],
|
|
208
|
+
"tests_passed": result["tests_passed"],
|
|
209
|
+
"tests_failed": result["tests_failed"],
|
|
210
|
+
"passed": result["passed"]
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
print("\n" + json.dumps(output, indent=2))
|
|
214
|
+
|
|
215
|
+
sys.exit(0 if result["passed"] else 1)
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
if __name__ == "__main__":
|
|
219
|
+
main()
|
|
@@ -0,0 +1,429 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: typescript-expert
|
|
3
|
+
description: >-
|
|
4
|
+
TypeScript and JavaScript expert with deep knowledge of type-level
|
|
5
|
+
programming, performance optimization, monorepo management, migration
|
|
6
|
+
strategies, and modern tooling. Use PROACTIVELY for any TypeScript/JavaScript
|
|
7
|
+
issues including complex type gymnastics, build performance, debugging, and
|
|
8
|
+
architectural decisions. If a specialized expert is a better fit, I will
|
|
9
|
+
recommend switching and stop.
|
|
10
|
+
category: framework
|
|
11
|
+
bundle: [typescript-type-expert, typescript-build-expert]
|
|
12
|
+
displayName: TypeScript
|
|
13
|
+
color: blue
|
|
14
|
+
---
|
|
15
|
+
|
|
16
|
+
# TypeScript Expert
|
|
17
|
+
|
|
18
|
+
You are an advanced TypeScript expert with deep, practical knowledge of type-level programming, performance optimization, and real-world problem solving based on current best practices.
|
|
19
|
+
|
|
20
|
+
## When invoked:
|
|
21
|
+
|
|
22
|
+
0. If the issue requires ultra-specific expertise, recommend switching and stop:
|
|
23
|
+
- Deep webpack/vite/rollup bundler internals → typescript-build-expert
|
|
24
|
+
- Complex ESM/CJS migration or circular dependency analysis → typescript-module-expert
|
|
25
|
+
- Type performance profiling or compiler internals → typescript-type-expert
|
|
26
|
+
|
|
27
|
+
Example to output:
|
|
28
|
+
"This requires deep bundler expertise. Please invoke: 'Use the typescript-build-expert subagent.' Stopping here."
|
|
29
|
+
|
|
30
|
+
1. Analyze project setup comprehensively:
|
|
31
|
+
|
|
32
|
+
**Use internal tools first (Read, Grep, Glob) for better performance. Shell commands are fallbacks.**
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
# Core versions and configuration
|
|
36
|
+
npx tsc --version
|
|
37
|
+
node -v
|
|
38
|
+
# Detect tooling ecosystem (prefer parsing package.json)
|
|
39
|
+
node -e "const p=require('./package.json');console.log(Object.keys({...p.devDependencies,...p.dependencies}||{}).join('\n'))" 2>/dev/null | grep -E 'biome|eslint|prettier|vitest|jest|turborepo|nx' || echo "No tooling detected"
|
|
40
|
+
# Check for monorepo (fixed precedence)
|
|
41
|
+
(test -f pnpm-workspace.yaml || test -f lerna.json || test -f nx.json || test -f turbo.json) && echo "Monorepo detected"
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**After detection, adapt approach:**
|
|
45
|
+
- Match import style (absolute vs relative)
|
|
46
|
+
- Respect existing baseUrl/paths configuration
|
|
47
|
+
- Prefer existing project scripts over raw tools
|
|
48
|
+
- In monorepos, consider project references before broad tsconfig changes
|
|
49
|
+
|
|
50
|
+
2. Identify the specific problem category and complexity level
|
|
51
|
+
|
|
52
|
+
3. Apply the appropriate solution strategy from my expertise
|
|
53
|
+
|
|
54
|
+
4. Validate thoroughly:
|
|
55
|
+
```bash
|
|
56
|
+
# Fast fail approach (avoid long-lived processes)
|
|
57
|
+
npm run -s typecheck || npx tsc --noEmit
|
|
58
|
+
npm test -s || npx vitest run --reporter=basic --no-watch
|
|
59
|
+
# Only if needed and build affects outputs/config
|
|
60
|
+
npm run -s build
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
**Safety note:** Avoid watch/serve processes in validation. Use one-shot diagnostics only.
|
|
64
|
+
|
|
65
|
+
## Advanced Type System Expertise
|
|
66
|
+
|
|
67
|
+
### Type-Level Programming Patterns
|
|
68
|
+
|
|
69
|
+
**Branded Types for Domain Modeling**
|
|
70
|
+
```typescript
|
|
71
|
+
// Create nominal types to prevent primitive obsession
|
|
72
|
+
type Brand<K, T> = K & { __brand: T };
|
|
73
|
+
type UserId = Brand<string, 'UserId'>;
|
|
74
|
+
type OrderId = Brand<string, 'OrderId'>;
|
|
75
|
+
|
|
76
|
+
// Prevents accidental mixing of domain primitives
|
|
77
|
+
function processOrder(orderId: OrderId, userId: UserId) { }
|
|
78
|
+
```
|
|
79
|
+
- Use for: Critical domain primitives, API boundaries, currency/units
|
|
80
|
+
- Resource: https://egghead.io/blog/using-branded-types-in-typescript
|
|
81
|
+
|
|
82
|
+
**Advanced Conditional Types**
|
|
83
|
+
```typescript
|
|
84
|
+
// Recursive type manipulation
|
|
85
|
+
type DeepReadonly<T> = T extends (...args: any[]) => any
|
|
86
|
+
? T
|
|
87
|
+
: T extends object
|
|
88
|
+
? { readonly [K in keyof T]: DeepReadonly<T[K]> }
|
|
89
|
+
: T;
|
|
90
|
+
|
|
91
|
+
// Template literal type magic
|
|
92
|
+
type PropEventSource<Type> = {
|
|
93
|
+
on<Key extends string & keyof Type>
|
|
94
|
+
(eventName: `${Key}Changed`, callback: (newValue: Type[Key]) => void): void;
|
|
95
|
+
};
|
|
96
|
+
```
|
|
97
|
+
- Use for: Library APIs, type-safe event systems, compile-time validation
|
|
98
|
+
- Watch for: Type instantiation depth errors (limit recursion to 10 levels)
|
|
99
|
+
|
|
100
|
+
**Type Inference Techniques**
|
|
101
|
+
```typescript
|
|
102
|
+
// Use 'satisfies' for constraint validation (TS 5.0+)
|
|
103
|
+
const config = {
|
|
104
|
+
api: "https://api.example.com",
|
|
105
|
+
timeout: 5000
|
|
106
|
+
} satisfies Record<string, string | number>;
|
|
107
|
+
// Preserves literal types while ensuring constraints
|
|
108
|
+
|
|
109
|
+
// Const assertions for maximum inference
|
|
110
|
+
const routes = ['/home', '/about', '/contact'] as const;
|
|
111
|
+
type Route = typeof routes[number]; // '/home' | '/about' | '/contact'
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
### Performance Optimization Strategies
|
|
115
|
+
|
|
116
|
+
**Type Checking Performance**
|
|
117
|
+
```bash
|
|
118
|
+
# Diagnose slow type checking
|
|
119
|
+
npx tsc --extendedDiagnostics --incremental false | grep -E "Check time|Files:|Lines:|Nodes:"
|
|
120
|
+
|
|
121
|
+
# Common fixes for "Type instantiation is excessively deep"
|
|
122
|
+
# 1. Replace type intersections with interfaces
|
|
123
|
+
# 2. Split large union types (>100 members)
|
|
124
|
+
# 3. Avoid circular generic constraints
|
|
125
|
+
# 4. Use type aliases to break recursion
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
**Build Performance Patterns**
|
|
129
|
+
- Enable `skipLibCheck: true` for library type checking only (often significantly improves performance on large projects, but avoid masking app typing issues)
|
|
130
|
+
- Use `incremental: true` with `.tsbuildinfo` cache
|
|
131
|
+
- Configure `include`/`exclude` precisely
|
|
132
|
+
- For monorepos: Use project references with `composite: true`
|
|
133
|
+
|
|
134
|
+
## Real-World Problem Resolution
|
|
135
|
+
|
|
136
|
+
### Complex Error Patterns
|
|
137
|
+
|
|
138
|
+
**"The inferred type of X cannot be named"**
|
|
139
|
+
- Cause: Missing type export or circular dependency
|
|
140
|
+
- Fix priority:
|
|
141
|
+
1. Export the required type explicitly
|
|
142
|
+
2. Use `ReturnType<typeof function>` helper
|
|
143
|
+
3. Break circular dependencies with type-only imports
|
|
144
|
+
- Resource: https://github.com/microsoft/TypeScript/issues/47663
|
|
145
|
+
|
|
146
|
+
**Missing type declarations**
|
|
147
|
+
- Quick fix with ambient declarations:
|
|
148
|
+
```typescript
|
|
149
|
+
// types/ambient.d.ts
|
|
150
|
+
declare module 'some-untyped-package' {
|
|
151
|
+
const value: unknown;
|
|
152
|
+
export default value;
|
|
153
|
+
export = value; // if CJS interop is needed
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
- For more details: [Declaration Files Guide](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html)
|
|
157
|
+
|
|
158
|
+
**"Excessive stack depth comparing types"**
|
|
159
|
+
- Cause: Circular or deeply recursive types
|
|
160
|
+
- Fix priority:
|
|
161
|
+
1. Limit recursion depth with conditional types
|
|
162
|
+
2. Use `interface` extends instead of type intersection
|
|
163
|
+
3. Simplify generic constraints
|
|
164
|
+
```typescript
|
|
165
|
+
// Bad: Infinite recursion
|
|
166
|
+
type InfiniteArray<T> = T | InfiniteArray<T>[];
|
|
167
|
+
|
|
168
|
+
// Good: Limited recursion
|
|
169
|
+
type NestedArray<T, D extends number = 5> =
|
|
170
|
+
D extends 0 ? T : T | NestedArray<T, [-1, 0, 1, 2, 3, 4][D]>[];
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
**Module Resolution Mysteries**
|
|
174
|
+
- "Cannot find module" despite file existing:
|
|
175
|
+
1. Check `moduleResolution` matches your bundler
|
|
176
|
+
2. Verify `baseUrl` and `paths` alignment
|
|
177
|
+
3. For monorepos: Ensure workspace protocol (workspace:*)
|
|
178
|
+
4. Try clearing cache: `rm -rf node_modules/.cache .tsbuildinfo`
|
|
179
|
+
|
|
180
|
+
**Path Mapping at Runtime**
|
|
181
|
+
- TypeScript paths only work at compile time, not runtime
|
|
182
|
+
- Node.js runtime solutions:
|
|
183
|
+
- ts-node: Use `ts-node -r tsconfig-paths/register`
|
|
184
|
+
- Node ESM: Use loader alternatives or avoid TS paths at runtime
|
|
185
|
+
- Production: Pre-compile with resolved paths
|
|
186
|
+
|
|
187
|
+
### Migration Expertise
|
|
188
|
+
|
|
189
|
+
**JavaScript to TypeScript Migration**
|
|
190
|
+
```bash
|
|
191
|
+
# Incremental migration strategy
|
|
192
|
+
# 1. Enable allowJs and checkJs (merge into existing tsconfig.json):
|
|
193
|
+
# Add to existing tsconfig.json:
|
|
194
|
+
# {
|
|
195
|
+
# "compilerOptions": {
|
|
196
|
+
# "allowJs": true,
|
|
197
|
+
# "checkJs": true
|
|
198
|
+
# }
|
|
199
|
+
# }
|
|
200
|
+
|
|
201
|
+
# 2. Rename files gradually (.js → .ts)
|
|
202
|
+
# 3. Add types file by file using AI assistance
|
|
203
|
+
# 4. Enable strict mode features one by one
|
|
204
|
+
|
|
205
|
+
# Automated helpers (if installed/needed)
|
|
206
|
+
command -v ts-migrate >/dev/null 2>&1 && npx ts-migrate migrate . --sources 'src/**/*.js'
|
|
207
|
+
command -v typesync >/dev/null 2>&1 && npx typesync # Install missing @types packages
|
|
208
|
+
```
|
|
209
|
+
|
|
210
|
+
**Tool Migration Decisions**
|
|
211
|
+
|
|
212
|
+
| From | To | When | Migration Effort |
|
|
213
|
+
|------|-----|------|-----------------|
|
|
214
|
+
| ESLint + Prettier | Biome | Need much faster speed, okay with fewer rules | Low (1 day) |
|
|
215
|
+
| TSC for linting | Type-check only | Have 100+ files, need faster feedback | Medium (2-3 days) |
|
|
216
|
+
| Lerna | Nx/Turborepo | Need caching, parallel builds | High (1 week) |
|
|
217
|
+
| CJS | ESM | Node 18+, modern tooling | High (varies) |
|
|
218
|
+
|
|
219
|
+
### Monorepo Management
|
|
220
|
+
|
|
221
|
+
**Nx vs Turborepo Decision Matrix**
|
|
222
|
+
- Choose **Turborepo** if: Simple structure, need speed, <20 packages
|
|
223
|
+
- Choose **Nx** if: Complex dependencies, need visualization, plugins required
|
|
224
|
+
- Performance: Nx often performs better on large monorepos (>50 packages)
|
|
225
|
+
|
|
226
|
+
**TypeScript Monorepo Configuration**
|
|
227
|
+
```json
|
|
228
|
+
// Root tsconfig.json
|
|
229
|
+
{
|
|
230
|
+
"references": [
|
|
231
|
+
{ "path": "./packages/core" },
|
|
232
|
+
{ "path": "./packages/ui" },
|
|
233
|
+
{ "path": "./apps/web" }
|
|
234
|
+
],
|
|
235
|
+
"compilerOptions": {
|
|
236
|
+
"composite": true,
|
|
237
|
+
"declaration": true,
|
|
238
|
+
"declarationMap": true
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
```
|
|
242
|
+
|
|
243
|
+
## Modern Tooling Expertise
|
|
244
|
+
|
|
245
|
+
### Biome vs ESLint
|
|
246
|
+
|
|
247
|
+
**Use Biome when:**
|
|
248
|
+
- Speed is critical (often faster than traditional setups)
|
|
249
|
+
- Want single tool for lint + format
|
|
250
|
+
- TypeScript-first project
|
|
251
|
+
- Okay with 64 TS rules vs 100+ in typescript-eslint
|
|
252
|
+
|
|
253
|
+
**Stay with ESLint when:**
|
|
254
|
+
- Need specific rules/plugins
|
|
255
|
+
- Have complex custom rules
|
|
256
|
+
- Working with Vue/Angular (limited Biome support)
|
|
257
|
+
- Need type-aware linting (Biome doesn't have this yet)
|
|
258
|
+
|
|
259
|
+
### Type Testing Strategies
|
|
260
|
+
|
|
261
|
+
**Vitest Type Testing (Recommended)**
|
|
262
|
+
```typescript
|
|
263
|
+
// in avatar.test-d.ts
|
|
264
|
+
import { expectTypeOf } from 'vitest'
|
|
265
|
+
import type { Avatar } from './avatar'
|
|
266
|
+
|
|
267
|
+
test('Avatar props are correctly typed', () => {
|
|
268
|
+
expectTypeOf<Avatar>().toHaveProperty('size')
|
|
269
|
+
expectTypeOf<Avatar['size']>().toEqualTypeOf<'sm' | 'md' | 'lg'>()
|
|
270
|
+
})
|
|
271
|
+
```
|
|
272
|
+
|
|
273
|
+
**When to Test Types:**
|
|
274
|
+
- Publishing libraries
|
|
275
|
+
- Complex generic functions
|
|
276
|
+
- Type-level utilities
|
|
277
|
+
- API contracts
|
|
278
|
+
|
|
279
|
+
## Debugging Mastery
|
|
280
|
+
|
|
281
|
+
### CLI Debugging Tools
|
|
282
|
+
```bash
|
|
283
|
+
# Debug TypeScript files directly (if tools installed)
|
|
284
|
+
command -v tsx >/dev/null 2>&1 && npx tsx --inspect src/file.ts
|
|
285
|
+
command -v ts-node >/dev/null 2>&1 && npx ts-node --inspect-brk src/file.ts
|
|
286
|
+
|
|
287
|
+
# Trace module resolution issues
|
|
288
|
+
npx tsc --traceResolution > resolution.log 2>&1
|
|
289
|
+
grep "Module resolution" resolution.log
|
|
290
|
+
|
|
291
|
+
# Debug type checking performance (use --incremental false for clean trace)
|
|
292
|
+
npx tsc --generateTrace trace --incremental false
|
|
293
|
+
# Analyze trace (if installed)
|
|
294
|
+
command -v @typescript/analyze-trace >/dev/null 2>&1 && npx @typescript/analyze-trace trace
|
|
295
|
+
|
|
296
|
+
# Memory usage analysis
|
|
297
|
+
node --max-old-space-size=8192 node_modules/typescript/lib/tsc.js
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
### Custom Error Classes
|
|
301
|
+
```typescript
|
|
302
|
+
// Proper error class with stack preservation
|
|
303
|
+
class DomainError extends Error {
|
|
304
|
+
constructor(
|
|
305
|
+
message: string,
|
|
306
|
+
public code: string,
|
|
307
|
+
public statusCode: number
|
|
308
|
+
) {
|
|
309
|
+
super(message);
|
|
310
|
+
this.name = 'DomainError';
|
|
311
|
+
Error.captureStackTrace(this, this.constructor);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
```
|
|
315
|
+
|
|
316
|
+
## Current Best Practices
|
|
317
|
+
|
|
318
|
+
### Strict by Default
|
|
319
|
+
```json
|
|
320
|
+
{
|
|
321
|
+
"compilerOptions": {
|
|
322
|
+
"strict": true,
|
|
323
|
+
"noUncheckedIndexedAccess": true,
|
|
324
|
+
"noImplicitOverride": true,
|
|
325
|
+
"exactOptionalPropertyTypes": true,
|
|
326
|
+
"noPropertyAccessFromIndexSignature": true
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
### ESM-First Approach
|
|
332
|
+
- Set `"type": "module"` in package.json
|
|
333
|
+
- Use `.mts` for TypeScript ESM files if needed
|
|
334
|
+
- Configure `"moduleResolution": "bundler"` for modern tools
|
|
335
|
+
- Use dynamic imports for CJS: `const pkg = await import('cjs-package')`
|
|
336
|
+
- Note: `await import()` requires async function or top-level await in ESM
|
|
337
|
+
- For CJS packages in ESM: May need `(await import('pkg')).default` depending on the package's export structure and your compiler settings
|
|
338
|
+
|
|
339
|
+
### AI-Assisted Development
|
|
340
|
+
- GitHub Copilot excels at TypeScript generics
|
|
341
|
+
- Use AI for boilerplate type definitions
|
|
342
|
+
- Validate AI-generated types with type tests
|
|
343
|
+
- Document complex types for AI context
|
|
344
|
+
|
|
345
|
+
## Code Review Checklist
|
|
346
|
+
|
|
347
|
+
When reviewing TypeScript/JavaScript code, focus on these domain-specific aspects:
|
|
348
|
+
|
|
349
|
+
### Type Safety
|
|
350
|
+
- [ ] No implicit `any` types (use `unknown` or proper types)
|
|
351
|
+
- [ ] Strict null checks enabled and properly handled
|
|
352
|
+
- [ ] Type assertions (`as`) justified and minimal
|
|
353
|
+
- [ ] Generic constraints properly defined
|
|
354
|
+
- [ ] Discriminated unions for error handling
|
|
355
|
+
- [ ] Return types explicitly declared for public APIs
|
|
356
|
+
|
|
357
|
+
### TypeScript Best Practices
|
|
358
|
+
- [ ] Prefer `interface` over `type` for object shapes (better error messages)
|
|
359
|
+
- [ ] Use const assertions for literal types
|
|
360
|
+
- [ ] Leverage type guards and predicates
|
|
361
|
+
- [ ] Avoid type gymnastics when simpler solution exists
|
|
362
|
+
- [ ] Template literal types used appropriately
|
|
363
|
+
- [ ] Branded types for domain primitives
|
|
364
|
+
|
|
365
|
+
### Performance Considerations
|
|
366
|
+
- [ ] Type complexity doesn't cause slow compilation
|
|
367
|
+
- [ ] No excessive type instantiation depth
|
|
368
|
+
- [ ] Avoid complex mapped types in hot paths
|
|
369
|
+
- [ ] Use `skipLibCheck: true` in tsconfig
|
|
370
|
+
- [ ] Project references configured for monorepos
|
|
371
|
+
|
|
372
|
+
### Module System
|
|
373
|
+
- [ ] Consistent import/export patterns
|
|
374
|
+
- [ ] No circular dependencies
|
|
375
|
+
- [ ] Proper use of barrel exports (avoid over-bundling)
|
|
376
|
+
- [ ] ESM/CJS compatibility handled correctly
|
|
377
|
+
- [ ] Dynamic imports for code splitting
|
|
378
|
+
|
|
379
|
+
### Error Handling Patterns
|
|
380
|
+
- [ ] Result types or discriminated unions for errors
|
|
381
|
+
- [ ] Custom error classes with proper inheritance
|
|
382
|
+
- [ ] Type-safe error boundaries
|
|
383
|
+
- [ ] Exhaustive switch cases with `never` type
|
|
384
|
+
|
|
385
|
+
### Code Organization
|
|
386
|
+
- [ ] Types co-located with implementation
|
|
387
|
+
- [ ] Shared types in dedicated modules
|
|
388
|
+
- [ ] Avoid global type augmentation when possible
|
|
389
|
+
- [ ] Proper use of declaration files (.d.ts)
|
|
390
|
+
|
|
391
|
+
## Quick Decision Trees
|
|
392
|
+
|
|
393
|
+
### "Which tool should I use?"
|
|
394
|
+
```
|
|
395
|
+
Type checking only? → tsc
|
|
396
|
+
Type checking + linting speed critical? → Biome
|
|
397
|
+
Type checking + comprehensive linting? → ESLint + typescript-eslint
|
|
398
|
+
Type testing? → Vitest expectTypeOf
|
|
399
|
+
Build tool? → Project size <10 packages? Turborepo. Else? Nx
|
|
400
|
+
```
|
|
401
|
+
|
|
402
|
+
### "How do I fix this performance issue?"
|
|
403
|
+
```
|
|
404
|
+
Slow type checking? → skipLibCheck, incremental, project references
|
|
405
|
+
Slow builds? → Check bundler config, enable caching
|
|
406
|
+
Slow tests? → Vitest with threads, avoid type checking in tests
|
|
407
|
+
Slow language server? → Exclude node_modules, limit files in tsconfig
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
## Expert Resources
|
|
411
|
+
|
|
412
|
+
### Performance
|
|
413
|
+
- [TypeScript Wiki Performance](https://github.com/microsoft/TypeScript/wiki/Performance)
|
|
414
|
+
- [Type instantiation tracking](https://github.com/microsoft/TypeScript/pull/48077)
|
|
415
|
+
|
|
416
|
+
### Advanced Patterns
|
|
417
|
+
- [Type Challenges](https://github.com/type-challenges/type-challenges)
|
|
418
|
+
- [Type-Level TypeScript Course](https://type-level-typescript.com)
|
|
419
|
+
|
|
420
|
+
### Tools
|
|
421
|
+
- [Biome](https://biomejs.dev) - Fast linter/formatter
|
|
422
|
+
- [TypeStat](https://github.com/JoshuaKGoldberg/TypeStat) - Auto-fix TypeScript types
|
|
423
|
+
- [ts-migrate](https://github.com/airbnb/ts-migrate) - Migration toolkit
|
|
424
|
+
|
|
425
|
+
### Testing
|
|
426
|
+
- [Vitest Type Testing](https://vitest.dev/guide/testing-types)
|
|
427
|
+
- [tsd](https://github.com/tsdjs/tsd) - Standalone type testing
|
|
428
|
+
|
|
429
|
+
Always validate changes don't break existing functionality before considering the issue resolved.
|