agcel 1.0.1
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/workflows/api-gen.md +59 -0
- package/.agent/workflows/architect.md +44 -0
- package/.agent/workflows/brainstorm.md +223 -0
- package/.agent/workflows/build.md +38 -0
- package/.agent/workflows/changelog.md +51 -0
- package/.agent/workflows/checkpoint.md +138 -0
- package/.agent/workflows/commit.md +223 -0
- package/.agent/workflows/debug.md +57 -0
- package/.agent/workflows/deploy.md +76 -0
- package/.agent/workflows/doc.md +247 -0
- package/.agent/workflows/execute-plan.md +225 -0
- package/.agent/workflows/feature.md +255 -0
- package/.agent/workflows/fix.md +323 -0
- package/.agent/workflows/help.md +63 -0
- package/.agent/workflows/index.md +148 -0
- package/.agent/workflows/load.md +112 -0
- package/.agent/workflows/mode.md +170 -0
- package/.agent/workflows/optimize.md +53 -0
- package/.agent/workflows/plan.md +337 -0
- package/.agent/workflows/pr.md +74 -0
- package/.agent/workflows/product-plan.md +36 -0
- package/.agent/workflows/production-deploy.md +39 -0
- package/.agent/workflows/refactor.md +63 -0
- package/.agent/workflows/research.md +116 -0
- package/.agent/workflows/review.md +344 -0
- package/.agent/workflows/security-scan.md +56 -0
- package/.agent/workflows/ship.md +221 -0
- package/.agent/workflows/spawn.md +177 -0
- package/.agent/workflows/status.md +59 -0
- package/.agent/workflows/tdd.md +139 -0
- package/.agent/workflows/test.md +340 -0
- package/.agent/workflows/verify.md +35 -0
- package/LICENSE +21 -0
- package/README.md +67 -0
- package/dist/commands/init.js +142 -0
- package/dist/commands/install.js +98 -0
- package/dist/commands/list.js +49 -0
- package/dist/commands/restart.js +17 -0
- package/dist/commands/start.js +41 -0
- package/dist/commands/status.js +24 -0
- package/dist/commands/stop.js +29 -0
- package/dist/commands/uninstall.js +78 -0
- package/dist/index.js +58 -0
- package/dist/server/index.js +174 -0
- package/dist/utils/index.js +63 -0
- package/package.json +54 -0
- package/skills/api-security-best-practices/SKILL.md +291 -0
- package/skills/api-security-best-practices/references/examples.md +617 -0
- package/skills/architecture/SKILL.md +59 -0
- package/skills/architecture/context-discovery.md +43 -0
- package/skills/architecture/examples.md +94 -0
- package/skills/architecture/pattern-selection.md +68 -0
- package/skills/architecture/patterns-reference.md +50 -0
- package/skills/architecture/trade-off-analysis.md +77 -0
- package/skills/aws-serverless/SKILL.md +327 -0
- package/skills/brainstorming/SKILL.md +234 -0
- package/skills/c4-context/SKILL.md +154 -0
- package/skills/ci-cd-engineer/SKILL.md +50 -0
- package/skills/code-auditing/SKILL.md +55 -0
- package/skills/copywriting/SKILL.md +248 -0
- package/skills/database-engineer/SKILL.md +47 -0
- package/skills/doc-coauthoring/SKILL.md +379 -0
- package/skills/docker-expert/SKILL.md +412 -0
- package/skills/langgraph/SKILL.md +291 -0
- package/skills/postgresql/SKILL.md +73 -0
- package/skills/pricing-strategy/SKILL.md +360 -0
- package/skills/product-manager/SKILL.md +57 -0
- package/skills/prompt-engineer/README.md +659 -0
- package/skills/prompt-engineer/SKILL.md +256 -0
- package/skills/python-patterns/SKILL.md +445 -0
- package/skills/qa-engineer/SKILL.md +42 -0
- package/skills/rag-engineer/SKILL.md +94 -0
- package/skills/react-patterns/SKILL.md +202 -0
- package/skills/secure-refactoring/SKILL.md +54 -0
- package/skills/security-documentation/SKILL.md +53 -0
- package/skills/senior-architect/SKILL.md +213 -0
- package/skills/senior-architect/references/architecture_patterns.md +103 -0
- package/skills/senior-architect/references/system_design_workflows.md +103 -0
- package/skills/senior-architect/references/tech_decision_guide.md +103 -0
- package/skills/senior-architect/scripts/architecture_diagram_generator.py +114 -0
- package/skills/senior-architect/scripts/dependency_analyzer.py +114 -0
- package/skills/senior-architect/scripts/project_architect.py +114 -0
- package/skills/seo-audit/SKILL.md +491 -0
- package/skills/sql-injection-testing/SKILL.md +452 -0
- package/skills/test-driven-development/SKILL.md +375 -0
- package/skills/test-driven-development/testing-anti-patterns.md +299 -0
- package/skills/test-fixing/SKILL.md +123 -0
- package/skills/testing-patterns/SKILL.md +263 -0
- package/skills/typescript-expert/SKILL.md +202 -0
- package/skills/typescript-expert/references/advanced-topics.md +252 -0
- package/skills/typescript-expert/references/tsconfig-strict.json +92 -0
- package/skills/typescript-expert/references/typescript-cheatsheet.md +383 -0
- package/skills/typescript-expert/references/utility-types.ts +335 -0
- package/skills/typescript-expert/scripts/ts_diagnostic.py +203 -0
- package/skills/ui-ux-designer/SKILL.md +46 -0
- package/skills/vercel-deployment/SKILL.md +83 -0
- package/skills/vulnerability-scanner/SKILL.md +280 -0
- package/skills/vulnerability-scanner/checklists.md +121 -0
- package/skills/vulnerability-scanner/scripts/security_scan.py +458 -0
- package/skills/writing-plans/SKILL.md +120 -0
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
# TypeScript Advanced Topics
|
|
2
|
+
|
|
3
|
+
## 1. Advanced Type System Expertise
|
|
4
|
+
|
|
5
|
+
### Type-Level Programming Patterns
|
|
6
|
+
|
|
7
|
+
**Branded Types for Domain Modeling**
|
|
8
|
+
```typescript
|
|
9
|
+
// Create nominal types to prevent primitive obsession
|
|
10
|
+
type Brand<K, T> = K & { __brand: T };
|
|
11
|
+
type UserId = Brand<string, 'UserId'>;
|
|
12
|
+
type OrderId = Brand<string, 'OrderId'>;
|
|
13
|
+
|
|
14
|
+
// Prevents accidental mixing of domain primitives
|
|
15
|
+
function processOrder(orderId: OrderId, userId: UserId) { }
|
|
16
|
+
```
|
|
17
|
+
- Use for: Critical domain primitives, API boundaries, currency/units
|
|
18
|
+
- Resource: https://egghead.io/blog/using-branded-types-in-typescript
|
|
19
|
+
|
|
20
|
+
**Advanced Conditional Types**
|
|
21
|
+
```typescript
|
|
22
|
+
// Recursive type manipulation
|
|
23
|
+
type DeepReadonly<T> = T extends (...args: any[]) => any
|
|
24
|
+
? T
|
|
25
|
+
: T extends object
|
|
26
|
+
? { readonly [K in keyof T]: DeepReadonly<T[K]> }
|
|
27
|
+
: T;
|
|
28
|
+
|
|
29
|
+
// Template literal type magic
|
|
30
|
+
type PropEventSource<Type> = {
|
|
31
|
+
on<Key extends string & keyof Type>
|
|
32
|
+
(eventName: `${Key}Changed`, callback: (newValue: Type[Key]) => void): void;
|
|
33
|
+
};
|
|
34
|
+
```
|
|
35
|
+
- Use for: Library APIs, type-safe event systems, compile-time validation
|
|
36
|
+
- Watch for: Type instantiation depth errors (limit recursion to 10 levels)
|
|
37
|
+
|
|
38
|
+
**Type Inference Techniques**
|
|
39
|
+
```typescript
|
|
40
|
+
// Use 'satisfies' for constraint validation (TS 5.0+)
|
|
41
|
+
const config = {
|
|
42
|
+
api: "https://api.example.com",
|
|
43
|
+
timeout: 5000
|
|
44
|
+
} satisfies Record<string, string | number>;
|
|
45
|
+
// Preserves literal types while ensuring constraints
|
|
46
|
+
|
|
47
|
+
// Const assertions for maximum inference
|
|
48
|
+
const routes = ['/home', '/about', '/contact'] as const;
|
|
49
|
+
type Route = typeof routes[number]; // '/home' | '/about' | '/contact'
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### Performance Optimization Strategies
|
|
53
|
+
|
|
54
|
+
**Type Checking Performance**
|
|
55
|
+
```bash
|
|
56
|
+
# Diagnose slow type checking
|
|
57
|
+
npx tsc --extendedDiagnostics --incremental false | grep -E "Check time|Files:|Lines:|Nodes:"
|
|
58
|
+
|
|
59
|
+
# Common fixes for "Type instantiation is excessively deep"
|
|
60
|
+
# 1. Replace type intersections with interfaces
|
|
61
|
+
# 2. Split large union types (>100 members)
|
|
62
|
+
# 3. Avoid circular generic constraints
|
|
63
|
+
# 4. Use type aliases to break recursion
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Build Performance Patterns**
|
|
67
|
+
- Enable `skipLibCheck: true` for library type checking only (often significantly improves performance on large projects, but avoid masking app typing issues)
|
|
68
|
+
- Use `incremental: true` with `.tsbuildinfo` cache
|
|
69
|
+
- Configure `include`/`exclude` precisely
|
|
70
|
+
- For monorepos: Use project references with `composite: true`
|
|
71
|
+
|
|
72
|
+
## 2. Real-World Problem Resolution
|
|
73
|
+
|
|
74
|
+
### Complex Error Patterns
|
|
75
|
+
|
|
76
|
+
**"The inferred type of X cannot be named"**
|
|
77
|
+
- Cause: Missing type export or circular dependency
|
|
78
|
+
- Fix priority:
|
|
79
|
+
1. Export the required type explicitly
|
|
80
|
+
2. Use `ReturnType<typeof function>` helper
|
|
81
|
+
3. Break circular dependencies with type-only imports
|
|
82
|
+
- Resource: https://github.com/microsoft/TypeScript/issues/47663
|
|
83
|
+
|
|
84
|
+
**Missing type declarations**
|
|
85
|
+
- Quick fix with ambient declarations:
|
|
86
|
+
```typescript
|
|
87
|
+
// types/ambient.d.ts
|
|
88
|
+
declare module 'some-untyped-package' {
|
|
89
|
+
const value: unknown;
|
|
90
|
+
export default value;
|
|
91
|
+
export = value; // if CJS interop is needed
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
- For more details: [Declaration Files Guide](https://www.typescriptlang.org/docs/handbook/declaration-files/introduction.html)
|
|
95
|
+
|
|
96
|
+
**"Excessive stack depth comparing types"**
|
|
97
|
+
- Cause: Circular or deeply recursive types
|
|
98
|
+
- Fix priority:
|
|
99
|
+
1. Limit recursion depth with conditional types
|
|
100
|
+
2. Use `interface` extends instead of type intersection
|
|
101
|
+
3. Simplify generic constraints
|
|
102
|
+
```typescript
|
|
103
|
+
// Bad: Infinite recursion
|
|
104
|
+
type InfiniteArray<T> = T | InfiniteArray<T>[];
|
|
105
|
+
|
|
106
|
+
// Good: Limited recursion
|
|
107
|
+
type NestedArray<T, D extends number = 5> =
|
|
108
|
+
D extends 0 ? T : T | NestedArray<T, [-1, 0, 1, 2, 3, 4][D]>[];
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
**Module Resolution Mysteries**
|
|
112
|
+
- "Cannot find module" despite file existing:
|
|
113
|
+
1. Check `moduleResolution` matches your bundler
|
|
114
|
+
2. Verify `baseUrl` and `paths` alignment
|
|
115
|
+
3. For monorepos: Ensure workspace protocol (workspace:*)
|
|
116
|
+
4. Try clearing cache: `rm -rf node_modules/.cache .tsbuildinfo`
|
|
117
|
+
|
|
118
|
+
**Path Mapping at Runtime**
|
|
119
|
+
- TypeScript paths only work at compile time, not runtime
|
|
120
|
+
- Node.js runtime solutions:
|
|
121
|
+
- ts-node: Use `ts-node -r tsconfig-paths/register`
|
|
122
|
+
- Node ESM: Use loader alternatives or avoid TS paths at runtime
|
|
123
|
+
- Production: Pre-compile with resolved paths
|
|
124
|
+
|
|
125
|
+
### Migration Expertise
|
|
126
|
+
|
|
127
|
+
**JavaScript to TypeScript Migration**
|
|
128
|
+
```bash
|
|
129
|
+
# Incremental migration strategy
|
|
130
|
+
# 1. Enable allowJs and checkJs (merge into existing tsconfig.json):
|
|
131
|
+
# Add to existing tsconfig.json:
|
|
132
|
+
# {
|
|
133
|
+
# "compilerOptions": {
|
|
134
|
+
# "allowJs": true,
|
|
135
|
+
# "checkJs": true
|
|
136
|
+
# }
|
|
137
|
+
# }
|
|
138
|
+
|
|
139
|
+
# 2. Rename files gradually (.js → .ts)
|
|
140
|
+
# 3. Add types file by file using AI assistance
|
|
141
|
+
# 4. Enable strict mode features one by one
|
|
142
|
+
|
|
143
|
+
# Automated helpers (if installed/needed)
|
|
144
|
+
command -v ts-migrate >/dev/null 2>&1 && npx ts-migrate migrate . --sources 'src/**/*.js'
|
|
145
|
+
command -v typesync >/dev/null 2>&1 && npx typesync # Install missing @types packages
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
**Tool Migration Decisions**
|
|
149
|
+
|
|
150
|
+
| From | To | When | Migration Effort |
|
|
151
|
+
|------|-----|------|-----------------|
|
|
152
|
+
| ESLint + Prettier | Biome | Need much faster speed, okay with fewer rules | Low (1 day) |
|
|
153
|
+
| TSC for linting | Type-check only | Have 100+ files, need faster feedback | Medium (2-3 days) |
|
|
154
|
+
| Lerna | Nx/Turborepo | Need caching, parallel builds | High (1 week) |
|
|
155
|
+
| CJS | ESM | Node 18+, modern tooling | High (varies) |
|
|
156
|
+
|
|
157
|
+
### Monorepo Management
|
|
158
|
+
|
|
159
|
+
**Nx vs Turborepo Decision Matrix**
|
|
160
|
+
- Choose **Turborepo** if: Simple structure, need speed, <20 packages
|
|
161
|
+
- Choose **Nx** if: Complex dependencies, need visualization, plugins required
|
|
162
|
+
- Performance: Nx often performs better on large monorepos (>50 packages)
|
|
163
|
+
|
|
164
|
+
**TypeScript Monorepo Configuration**
|
|
165
|
+
```json
|
|
166
|
+
// Root tsconfig.json
|
|
167
|
+
{
|
|
168
|
+
"references": [
|
|
169
|
+
{ "path": "./packages/core" },
|
|
170
|
+
{ "path": "./packages/ui" },
|
|
171
|
+
{ "path": "./apps/web" }
|
|
172
|
+
],
|
|
173
|
+
"compilerOptions": {
|
|
174
|
+
"composite": true,
|
|
175
|
+
"declaration": true,
|
|
176
|
+
"declarationMap": true
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
## 3. Modern Tooling Expertise
|
|
182
|
+
|
|
183
|
+
### Biome vs ESLint
|
|
184
|
+
|
|
185
|
+
**Use Biome when:**
|
|
186
|
+
- Speed is critical (often faster than traditional setups)
|
|
187
|
+
- Want single tool for lint + format
|
|
188
|
+
- TypeScript-first project
|
|
189
|
+
- Okay with 64 TS rules vs 100+ in typescript-eslint
|
|
190
|
+
|
|
191
|
+
**Stay with ESLint when:**
|
|
192
|
+
- Need specific rules/plugins
|
|
193
|
+
- Have complex custom rules
|
|
194
|
+
- Working with Vue/Angular (limited Biome support)
|
|
195
|
+
- Need type-aware linting (Biome doesn't have this yet)
|
|
196
|
+
|
|
197
|
+
### Type Testing Strategies
|
|
198
|
+
|
|
199
|
+
**Vitest Type Testing (Recommended)**
|
|
200
|
+
```typescript
|
|
201
|
+
// in avatar.test-d.ts
|
|
202
|
+
import { expectTypeOf } from 'vitest'
|
|
203
|
+
import type { Avatar } from './avatar'
|
|
204
|
+
|
|
205
|
+
test('Avatar props are correctly typed', () => {
|
|
206
|
+
expectTypeOf<Avatar>().toHaveProperty('size')
|
|
207
|
+
expectTypeOf<Avatar['size']>().toEqualTypeOf<'sm' | 'md' | 'lg'>()
|
|
208
|
+
})
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
**When to Test Types:**
|
|
212
|
+
- Publishing libraries
|
|
213
|
+
- Complex generic functions
|
|
214
|
+
- Type-level utilities
|
|
215
|
+
- API contracts
|
|
216
|
+
|
|
217
|
+
## 4. Debugging Mastery
|
|
218
|
+
|
|
219
|
+
### CLI Debugging Tools
|
|
220
|
+
```bash
|
|
221
|
+
# Debug TypeScript files directly (if tools installed)
|
|
222
|
+
command -v tsx >/dev/null 2>&1 && npx tsx --inspect src/file.ts
|
|
223
|
+
command -v ts-node >/dev/null 2>&1 && npx ts-node --inspect-brk src/file.ts
|
|
224
|
+
|
|
225
|
+
# Trace module resolution issues
|
|
226
|
+
npx tsc --traceResolution > resolution.log 2>&1
|
|
227
|
+
grep "Module resolution" resolution.log
|
|
228
|
+
|
|
229
|
+
# Debug type checking performance (use --incremental false for clean trace)
|
|
230
|
+
npx tsc --generateTrace trace --incremental false
|
|
231
|
+
# Analyze trace (if installed)
|
|
232
|
+
command -v @typescript/analyze-trace >/dev/null 2>&1 && npx @typescript/analyze-trace trace
|
|
233
|
+
|
|
234
|
+
# Memory usage analysis
|
|
235
|
+
node --max-old-space-size=8192 node_modules/typescript/lib/tsc.js
|
|
236
|
+
```
|
|
237
|
+
|
|
238
|
+
### Custom Error Classes
|
|
239
|
+
```typescript
|
|
240
|
+
// Proper error class with stack preservation
|
|
241
|
+
class DomainError extends Error {
|
|
242
|
+
constructor(
|
|
243
|
+
message: string,
|
|
244
|
+
public code: string,
|
|
245
|
+
public statusCode: number
|
|
246
|
+
) {
|
|
247
|
+
super(message);
|
|
248
|
+
this.name = 'DomainError';
|
|
249
|
+
Error.captureStackTrace(this, this.constructor);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
```
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json.schemastore.org/tsconfig",
|
|
3
|
+
"display": "Strict TypeScript 5.x",
|
|
4
|
+
"compilerOptions": {
|
|
5
|
+
// =========================================================================
|
|
6
|
+
// STRICTNESS (Maximum Type Safety)
|
|
7
|
+
// =========================================================================
|
|
8
|
+
"strict": true,
|
|
9
|
+
"noUncheckedIndexedAccess": true,
|
|
10
|
+
"noImplicitOverride": true,
|
|
11
|
+
"noPropertyAccessFromIndexSignature": true,
|
|
12
|
+
"exactOptionalPropertyTypes": true,
|
|
13
|
+
"noFallthroughCasesInSwitch": true,
|
|
14
|
+
"forceConsistentCasingInFileNames": true,
|
|
15
|
+
// =========================================================================
|
|
16
|
+
// MODULE SYSTEM (Modern ESM)
|
|
17
|
+
// =========================================================================
|
|
18
|
+
"module": "ESNext",
|
|
19
|
+
"moduleResolution": "bundler",
|
|
20
|
+
"resolveJsonModule": true,
|
|
21
|
+
"esModuleInterop": true,
|
|
22
|
+
"allowSyntheticDefaultImports": true,
|
|
23
|
+
"isolatedModules": true,
|
|
24
|
+
"verbatimModuleSyntax": true,
|
|
25
|
+
// =========================================================================
|
|
26
|
+
// OUTPUT
|
|
27
|
+
// =========================================================================
|
|
28
|
+
"target": "ES2022",
|
|
29
|
+
"lib": [
|
|
30
|
+
"ES2022",
|
|
31
|
+
"DOM",
|
|
32
|
+
"DOM.Iterable"
|
|
33
|
+
],
|
|
34
|
+
"declaration": true,
|
|
35
|
+
"declarationMap": true,
|
|
36
|
+
"sourceMap": true,
|
|
37
|
+
// =========================================================================
|
|
38
|
+
// PERFORMANCE
|
|
39
|
+
// =========================================================================
|
|
40
|
+
"skipLibCheck": true,
|
|
41
|
+
"incremental": true,
|
|
42
|
+
// =========================================================================
|
|
43
|
+
// PATH ALIASES
|
|
44
|
+
// =========================================================================
|
|
45
|
+
"baseUrl": ".",
|
|
46
|
+
"paths": {
|
|
47
|
+
"@/*": [
|
|
48
|
+
"./src/*"
|
|
49
|
+
],
|
|
50
|
+
"@/components/*": [
|
|
51
|
+
"./src/components/*"
|
|
52
|
+
],
|
|
53
|
+
"@/lib/*": [
|
|
54
|
+
"./src/lib/*"
|
|
55
|
+
],
|
|
56
|
+
"@/types/*": [
|
|
57
|
+
"./src/types/*"
|
|
58
|
+
],
|
|
59
|
+
"@/utils/*": [
|
|
60
|
+
"./src/utils/*"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
// =========================================================================
|
|
64
|
+
// JSX (for React projects)
|
|
65
|
+
// =========================================================================
|
|
66
|
+
// "jsx": "react-jsx",
|
|
67
|
+
// =========================================================================
|
|
68
|
+
// EMIT
|
|
69
|
+
// =========================================================================
|
|
70
|
+
"noEmit": true, // Let bundler handle emit
|
|
71
|
+
// "outDir": "./dist",
|
|
72
|
+
// "rootDir": "./src",
|
|
73
|
+
// =========================================================================
|
|
74
|
+
// DECORATORS (if needed)
|
|
75
|
+
// =========================================================================
|
|
76
|
+
// "experimentalDecorators": true,
|
|
77
|
+
// "emitDecoratorMetadata": true
|
|
78
|
+
},
|
|
79
|
+
"include": [
|
|
80
|
+
"src/**/*.ts",
|
|
81
|
+
"src/**/*.tsx",
|
|
82
|
+
"src/**/*.d.ts"
|
|
83
|
+
],
|
|
84
|
+
"exclude": [
|
|
85
|
+
"node_modules",
|
|
86
|
+
"dist",
|
|
87
|
+
"build",
|
|
88
|
+
"coverage",
|
|
89
|
+
"**/*.test.ts",
|
|
90
|
+
"**/*.spec.ts"
|
|
91
|
+
]
|
|
92
|
+
}
|