cortex-tms 2.1.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/LICENSE +21 -0
- package/README.md +258 -0
- package/bin/cortex-tms.js +34 -0
- package/dist/__tests__/init.test.d.ts +2 -0
- package/dist/__tests__/init.test.d.ts.map +1 -0
- package/dist/__tests__/init.test.js +172 -0
- package/dist/__tests__/init.test.js.map +1 -0
- package/dist/__tests__/utils/temp-dir.d.ts +6 -0
- package/dist/__tests__/utils/temp-dir.d.ts.map +1 -0
- package/dist/__tests__/utils/temp-dir.js +34 -0
- package/dist/__tests__/utils/temp-dir.js.map +1 -0
- package/dist/__tests__/validate.test.d.ts +2 -0
- package/dist/__tests__/validate.test.d.ts.map +1 -0
- package/dist/__tests__/validate.test.js +207 -0
- package/dist/__tests__/validate.test.js.map +1 -0
- package/dist/cli.d.ts +3 -0
- package/dist/cli.d.ts.map +1 -0
- package/dist/cli.js +32 -0
- package/dist/cli.js.map +1 -0
- package/dist/commands/init.d.ts +4 -0
- package/dist/commands/init.d.ts.map +1 -0
- package/dist/commands/init.js +121 -0
- package/dist/commands/init.js.map +1 -0
- package/dist/commands/validate.d.ts +4 -0
- package/dist/commands/validate.d.ts.map +1 -0
- package/dist/commands/validate.js +151 -0
- package/dist/commands/validate.js.map +1 -0
- package/dist/types/cli.d.ts +94 -0
- package/dist/types/cli.d.ts.map +1 -0
- package/dist/types/cli.js +2 -0
- package/dist/types/cli.js.map +1 -0
- package/dist/utils/config.d.ts +13 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +185 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/detection.d.ts +5 -0
- package/dist/utils/detection.d.ts.map +1 -0
- package/dist/utils/detection.js +60 -0
- package/dist/utils/detection.js.map +1 -0
- package/dist/utils/prompts.d.ts +5 -0
- package/dist/utils/prompts.d.ts.map +1 -0
- package/dist/utils/prompts.js +82 -0
- package/dist/utils/prompts.js.map +1 -0
- package/dist/utils/templates.d.ts +14 -0
- package/dist/utils/templates.d.ts.map +1 -0
- package/dist/utils/templates.js +98 -0
- package/dist/utils/templates.js.map +1 -0
- package/dist/utils/validator.d.ts +12 -0
- package/dist/utils/validator.d.ts.map +1 -0
- package/dist/utils/validator.js +241 -0
- package/dist/utils/validator.js.map +1 -0
- package/package.json +69 -0
- package/templates/.github/copilot-instructions.md +28 -0
- package/templates/CLAUDE.md +18 -0
- package/templates/FUTURE-ENHANCEMENTS.md +79 -0
- package/templates/NEXT-TASKS.md +20 -0
- package/templates/README.md +172 -0
- package/templates/docs/archive/v1.0-CHANGELOG.md +0 -0
- package/templates/docs/core/ARCHITECTURE.md +102 -0
- package/templates/docs/core/DECISIONS.md +83 -0
- package/templates/docs/core/DOMAIN-LOGIC.md +8 -0
- package/templates/docs/core/GLOSSARY.md +66 -0
- package/templates/docs/core/PATTERNS.md +55 -0
- package/templates/docs/core/SCHEMA.md +246 -0
- package/templates/docs/core/TROUBLESHOOTING.md +325 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
# Troubleshooting: Known Issues & Solutions
|
|
2
|
+
|
|
3
|
+
<!-- This file documents framework gotchas, common errors, and workarounds. -->
|
|
4
|
+
<!-- Help AI agents avoid known pitfalls by documenting them here. -->
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## 🎯 Purpose
|
|
9
|
+
|
|
10
|
+
This file exists to prevent AI agents from:
|
|
11
|
+
- Implementing patterns that won't work in your framework
|
|
12
|
+
- Making assumptions that contradict framework behavior
|
|
13
|
+
- Wasting time debugging known issues
|
|
14
|
+
|
|
15
|
+
**When to add an entry**: Anytime you encounter a non-obvious error that took more than 30 minutes to debug.
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## 🔴 Critical Issues (Will Break Production)
|
|
20
|
+
|
|
21
|
+
<!-- Issues that cause runtime failures or security vulnerabilities -->
|
|
22
|
+
|
|
23
|
+
### [Issue: e.g., Server Components Can't Use useState]
|
|
24
|
+
|
|
25
|
+
**Framework**: [e.g., Next.js 13+ (App Router)]
|
|
26
|
+
|
|
27
|
+
**Symptom**:
|
|
28
|
+
```
|
|
29
|
+
Error: useState is not a function in Server Components
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
**Cause**: [e.g., Next.js App Router renders components on the server by default. React hooks like `useState` only work in Client Components.]
|
|
33
|
+
|
|
34
|
+
**Solution**:
|
|
35
|
+
```typescript
|
|
36
|
+
// ❌ Bad: Using useState in a Server Component
|
|
37
|
+
export default function Page() {
|
|
38
|
+
const [count, setCount] = useState(0) // ERROR!
|
|
39
|
+
return <div>{count}</div>
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ✅ Good: Add 'use client' directive
|
|
43
|
+
'use client'
|
|
44
|
+
|
|
45
|
+
export default function Page() {
|
|
46
|
+
const [count, setCount] = useState(0) // Works!
|
|
47
|
+
return <div>{count}</div>
|
|
48
|
+
}
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**AI Agent Note**: ⚠️ Before using `useState`, `useEffect`, or any React hook, verify the component has `'use client'` at the top of the file.
|
|
52
|
+
|
|
53
|
+
**Reference**: [Link to Next.js Server Components docs]
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
### [Issue: e.g., Environment Variables Not Available in Browser]
|
|
58
|
+
|
|
59
|
+
**Framework**: [e.g., Next.js, Vite, Create React App]
|
|
60
|
+
|
|
61
|
+
**Symptom**:
|
|
62
|
+
```
|
|
63
|
+
process.env.API_KEY is undefined in the browser
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
**Cause**: [e.g., Only environment variables prefixed with `NEXT_PUBLIC_` are exposed to the browser. Others are server-only.]
|
|
67
|
+
|
|
68
|
+
**Solution**:
|
|
69
|
+
```bash
|
|
70
|
+
# ❌ Bad: Not exposed to browser
|
|
71
|
+
API_KEY=secret123
|
|
72
|
+
|
|
73
|
+
# ✅ Good: Exposed to browser
|
|
74
|
+
NEXT_PUBLIC_API_KEY=public123
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Security Warning**: ⚠️ NEVER prefix secrets with `NEXT_PUBLIC_`. These are exposed in the client bundle.
|
|
78
|
+
|
|
79
|
+
**AI Agent Note**: When generating code that uses `process.env` in the browser, verify the variable name starts with `NEXT_PUBLIC_`.
|
|
80
|
+
|
|
81
|
+
---
|
|
82
|
+
|
|
83
|
+
## 🟡 Common Errors (Will Cause Confusion)
|
|
84
|
+
|
|
85
|
+
<!-- Non-critical issues that are confusing but won't break production -->
|
|
86
|
+
|
|
87
|
+
### [Issue: e.g., Tailwind Styles Not Applying After Config Change]
|
|
88
|
+
|
|
89
|
+
**Framework**: [e.g., Tailwind CSS (JIT Mode)]
|
|
90
|
+
|
|
91
|
+
**Symptom**: Added a custom color in `tailwind.config.js`, but it doesn't work in components.
|
|
92
|
+
|
|
93
|
+
**Cause**: [e.g., Tailwind's JIT compiler caches build output. Config changes require a dev server restart.]
|
|
94
|
+
|
|
95
|
+
**Solution**:
|
|
96
|
+
```bash
|
|
97
|
+
# Stop dev server (Ctrl+C), then restart
|
|
98
|
+
pnpm dev
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
**Workaround**: [e.g., Use Tailwind's `--watch` flag for automatic reloading]
|
|
102
|
+
|
|
103
|
+
**AI Agent Note**: After modifying `tailwind.config.js`, always suggest restarting the dev server.
|
|
104
|
+
|
|
105
|
+
---
|
|
106
|
+
|
|
107
|
+
### [Issue: e.g., TypeScript Can't Find Module After Creating It]
|
|
108
|
+
|
|
109
|
+
**Framework**: [e.g., TypeScript]
|
|
110
|
+
|
|
111
|
+
**Symptom**:
|
|
112
|
+
```
|
|
113
|
+
Cannot find module './myFile' or its corresponding type declarations.
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
**Cause**: [e.g., TypeScript language server cache is stale]
|
|
117
|
+
|
|
118
|
+
**Solution**:
|
|
119
|
+
```
|
|
120
|
+
VS Code: Cmd+Shift+P → "TypeScript: Restart TS Server"
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
**AI Agent Note**: If a newly created file isn't recognized, suggest restarting the TypeScript server.
|
|
124
|
+
|
|
125
|
+
---
|
|
126
|
+
|
|
127
|
+
## 🟢 Framework Gotchas (Non-Obvious Behavior)
|
|
128
|
+
|
|
129
|
+
<!-- Quirks that aren't errors but might surprise developers -->
|
|
130
|
+
|
|
131
|
+
### [Gotcha: e.g., Database Timestamps Use Different Timezone Than App]
|
|
132
|
+
|
|
133
|
+
**Framework**: [e.g., PostgreSQL, Prisma]
|
|
134
|
+
|
|
135
|
+
**Behavior**: [e.g., PostgreSQL `TIMESTAMP` defaults to server timezone, not UTC]
|
|
136
|
+
|
|
137
|
+
**Recommendation**:
|
|
138
|
+
```sql
|
|
139
|
+
-- ❌ Bad: Uses server timezone
|
|
140
|
+
createdAt TIMESTAMP DEFAULT NOW()
|
|
141
|
+
|
|
142
|
+
-- ✅ Good: Explicitly use UTC
|
|
143
|
+
createdAt TIMESTAMPTZ DEFAULT NOW()
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**AI Agent Note**: Always use `TIMESTAMPTZ` (timestamp with time zone) instead of `TIMESTAMP` in PostgreSQL schemas.
|
|
147
|
+
|
|
148
|
+
**Reference**: [See SCHEMA.md for timestamp rules]
|
|
149
|
+
|
|
150
|
+
---
|
|
151
|
+
|
|
152
|
+
### [Gotcha: e.g., Array.map() in JSX Requires Unique Keys]
|
|
153
|
+
|
|
154
|
+
**Framework**: [e.g., React]
|
|
155
|
+
|
|
156
|
+
**Behavior**: React throws a warning if list items don't have unique `key` props.
|
|
157
|
+
|
|
158
|
+
**Recommendation**:
|
|
159
|
+
```typescript
|
|
160
|
+
// ❌ Bad: No key prop
|
|
161
|
+
{users.map(user => <div>{user.name}</div>)}
|
|
162
|
+
|
|
163
|
+
// ✅ Good: Stable, unique key
|
|
164
|
+
{users.map(user => <div key={user.id}>{user.name}</div>)}
|
|
165
|
+
|
|
166
|
+
// ⚠️ Avoid: Using array index (breaks on reorder)
|
|
167
|
+
{users.map((user, index) => <div key={index}>{user.name}</div>)}
|
|
168
|
+
```
|
|
169
|
+
|
|
170
|
+
**AI Agent Note**: When generating `map()` in JSX, always add a `key` prop using a stable ID (not array index).
|
|
171
|
+
|
|
172
|
+
---
|
|
173
|
+
|
|
174
|
+
## 🛠️ Environment Setup Issues
|
|
175
|
+
|
|
176
|
+
<!-- Problems that occur during installation or local development -->
|
|
177
|
+
|
|
178
|
+
### [Issue: e.g., pnpm install fails with EACCES error]
|
|
179
|
+
|
|
180
|
+
**Platform**: [e.g., macOS, Linux]
|
|
181
|
+
|
|
182
|
+
**Symptom**:
|
|
183
|
+
```
|
|
184
|
+
Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules'
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
**Cause**: [e.g., npm/pnpm trying to write to system-protected directory]
|
|
188
|
+
|
|
189
|
+
**Solution**:
|
|
190
|
+
```bash
|
|
191
|
+
# Use a Node version manager (nvm, fnm, volta)
|
|
192
|
+
# Never use sudo with npm/pnpm
|
|
193
|
+
```
|
|
194
|
+
|
|
195
|
+
**AI Agent Note**: If installation fails with EACCES, recommend using a Node version manager instead of `sudo`.
|
|
196
|
+
|
|
197
|
+
---
|
|
198
|
+
|
|
199
|
+
### [Issue: e.g., Port 3000 already in use]
|
|
200
|
+
|
|
201
|
+
**Platform**: [e.g., Any]
|
|
202
|
+
|
|
203
|
+
**Symptom**:
|
|
204
|
+
```
|
|
205
|
+
Error: Port 3000 is already in use
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
**Solution**:
|
|
209
|
+
```bash
|
|
210
|
+
# Option 1: Kill process on port 3000
|
|
211
|
+
lsof -ti:3000 | xargs kill -9
|
|
212
|
+
|
|
213
|
+
# Option 2: Use a different port
|
|
214
|
+
PORT=3001 pnpm dev
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**AI Agent Note**: When dev server fails to start, check if another process is using the port.
|
|
218
|
+
|
|
219
|
+
---
|
|
220
|
+
|
|
221
|
+
## 🐛 AI Agent Common Mistakes
|
|
222
|
+
|
|
223
|
+
<!-- Errors that AI coding assistants frequently make -->
|
|
224
|
+
|
|
225
|
+
### [Mistake: e.g., Hallucinating Non-Existent Imports]
|
|
226
|
+
|
|
227
|
+
**Example**:
|
|
228
|
+
```typescript
|
|
229
|
+
// ❌ AI might generate this (doesn't exist)
|
|
230
|
+
import { useAuth } from '@/lib/auth'
|
|
231
|
+
|
|
232
|
+
// ✅ Correct import (verify in codebase first)
|
|
233
|
+
import { useAuth } from '@/hooks/useAuth'
|
|
234
|
+
```
|
|
235
|
+
|
|
236
|
+
**Prevention**: ⚠️ Before suggesting an import, verify the file/export exists in the project.
|
|
237
|
+
|
|
238
|
+
**Validation**: Use `grep -r "export.*useAuth"` to find the actual export location.
|
|
239
|
+
|
|
240
|
+
---
|
|
241
|
+
|
|
242
|
+
### [Mistake: e.g., Using Deprecated APIs]
|
|
243
|
+
|
|
244
|
+
**Example**:
|
|
245
|
+
```typescript
|
|
246
|
+
// ❌ AI might use deprecated Next.js API
|
|
247
|
+
import { useRouter } from 'next/router' // Pages Router (old)
|
|
248
|
+
|
|
249
|
+
// ✅ Use App Router API (Next.js 13+)
|
|
250
|
+
import { useRouter } from 'next/navigation' // App Router (new)
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
**Prevention**: ⚠️ Check `docs/core/ARCHITECTURE.md` for the framework version before generating code.
|
|
254
|
+
|
|
255
|
+
**Reference**: [See ARCHITECTURE.md for tech stack versions]
|
|
256
|
+
|
|
257
|
+
---
|
|
258
|
+
|
|
259
|
+
### [Mistake: e.g., Not Handling Async Errors in React]
|
|
260
|
+
|
|
261
|
+
**Example**:
|
|
262
|
+
```typescript
|
|
263
|
+
// ❌ Unhandled promise rejection
|
|
264
|
+
async function handleSubmit() {
|
|
265
|
+
await fetch('/api/submit') // No error handling
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// ✅ Proper error handling
|
|
269
|
+
async function handleSubmit() {
|
|
270
|
+
try {
|
|
271
|
+
await fetch('/api/submit')
|
|
272
|
+
} catch (error) {
|
|
273
|
+
console.error('Submit failed:', error)
|
|
274
|
+
// Show user-friendly error message
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
**Prevention**: ⚠️ Always wrap async operations in try/catch blocks.
|
|
280
|
+
|
|
281
|
+
---
|
|
282
|
+
|
|
283
|
+
## 📚 Reference Checklist (For AI Agents)
|
|
284
|
+
|
|
285
|
+
Before implementing a feature, verify:
|
|
286
|
+
|
|
287
|
+
- [ ] Framework version matches `docs/core/ARCHITECTURE.md`
|
|
288
|
+
- [ ] Imports use correct paths (check existing files)
|
|
289
|
+
- [ ] Environment variables use correct prefix (e.g., `NEXT_PUBLIC_`)
|
|
290
|
+
- [ ] Database timestamps use correct type (e.g., `TIMESTAMPTZ`)
|
|
291
|
+
- [ ] React components use `'use client'` when needed
|
|
292
|
+
- [ ] TypeScript types match `docs/core/SCHEMA.md`
|
|
293
|
+
- [ ] Error handling is implemented (no unhandled promises)
|
|
294
|
+
|
|
295
|
+
---
|
|
296
|
+
|
|
297
|
+
## 🔗 Related Documentation
|
|
298
|
+
|
|
299
|
+
- **Architecture**: See `ARCHITECTURE.md` for framework versions
|
|
300
|
+
- **Schema**: See `SCHEMA.md` for database gotchas
|
|
301
|
+
- **Patterns**: See `PATTERNS.md` for anti-patterns
|
|
302
|
+
|
|
303
|
+
---
|
|
304
|
+
|
|
305
|
+
## 📝 How to Document a New Issue
|
|
306
|
+
|
|
307
|
+
When you encounter a new gotcha:
|
|
308
|
+
|
|
309
|
+
1. **Title**: Brief, searchable description (e.g., "useState in Server Components")
|
|
310
|
+
2. **Framework**: Which tool/library this affects
|
|
311
|
+
3. **Symptom**: Exact error message or unexpected behavior
|
|
312
|
+
4. **Cause**: Why this happens
|
|
313
|
+
5. **Solution**: Code example showing fix
|
|
314
|
+
6. **AI Agent Note**: What to check before generating this code
|
|
315
|
+
|
|
316
|
+
**Template**:
|
|
317
|
+
```markdown
|
|
318
|
+
### [Issue: Brief Description]
|
|
319
|
+
|
|
320
|
+
**Framework**: [Tool/Library]
|
|
321
|
+
**Symptom**: [Error message or behavior]
|
|
322
|
+
**Cause**: [Why it happens]
|
|
323
|
+
**Solution**: [Code example]
|
|
324
|
+
**AI Agent Note**: [What to verify]
|
|
325
|
+
```
|