@haposoft/cafekit 0.3.2 → 0.3.6
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/bin/install.js +29 -23
- package/package.json +1 -1
- package/src/antigravity/workflows/impact-analysis-output-example.md +313 -0
- package/src/antigravity/workflows/impact-analysis.md +735 -0
- package/src/claude/migration-manifest.json +2 -1
- package/src/common/skills/impact-analysis/SKILL.md +271 -0
- package/src/common/skills/impact-analysis/references/change-detection.md +270 -0
- package/src/common/skills/impact-analysis/references/dependency-scouting.md +337 -0
- package/src/common/skills/impact-analysis/references/edge-case-identification.md +439 -0
- package/src/common/skills/impact-analysis/references/industry-techniques.md +695 -0
- package/src/common/skills/impact-analysis/references/practical-techniques-guide.md +753 -0
- package/src/common/skills/impact-analysis/references/project-detection.md +704 -0
- package/src/common/skills/impact-analysis/references/react-native-customization.md +508 -0
- package/src/common/skills/impact-analysis/references/report-template.md +604 -0
- package/src/common/skills/impact-analysis/references/test-scenario-generation.md +459 -0
- package/src/common/skills/impact-analysis/scripts/README.md +476 -0
- package/src/common/skills/impact-analysis/scripts/ast-analyze.js +403 -0
- package/src/common/skills/impact-analysis/scripts/calculate-risk.js +475 -0
- package/src/common/skills/impact-analysis/scripts/find-dependencies.sh +202 -0
- package/src/common/skills/impact-analysis/scripts/run-analysis.sh +312 -0
|
@@ -0,0 +1,337 @@
|
|
|
1
|
+
# Dependency Scouting - Tìm Files Bị Ảnh Hưởng
|
|
2
|
+
|
|
3
|
+
Phương pháp tìm kiếm và phân tích dependencies để xác định phạm vi tác động.
|
|
4
|
+
|
|
5
|
+
## Scouting Strategies
|
|
6
|
+
|
|
7
|
+
### 1. Import Analysis (Direct Dependencies)
|
|
8
|
+
|
|
9
|
+
Tìm files import code đã sửa:
|
|
10
|
+
|
|
11
|
+
```bash
|
|
12
|
+
# JavaScript/TypeScript
|
|
13
|
+
grep -r "from ['\"].*{module-name}" src/
|
|
14
|
+
grep -r "import.*{module-name}" src/
|
|
15
|
+
grep -r "require(['\"].*{module-name}" src/
|
|
16
|
+
|
|
17
|
+
# Python
|
|
18
|
+
grep -r "from {module} import" src/
|
|
19
|
+
grep -r "import {module}" src/
|
|
20
|
+
|
|
21
|
+
# Go
|
|
22
|
+
grep -r "import.*{package}" .
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
**Example:**
|
|
26
|
+
```bash
|
|
27
|
+
# Changed: src/utils/auth.ts
|
|
28
|
+
# Find who imports it:
|
|
29
|
+
grep -r "from.*utils/auth" src/
|
|
30
|
+
|
|
31
|
+
# Output:
|
|
32
|
+
# src/api/users.ts:import { verifyToken } from '@/utils/auth'
|
|
33
|
+
# src/middleware/auth.ts:import { verifyToken } from '@/utils/auth'
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### 2. Function/Class Usage (Reverse Dependencies)
|
|
37
|
+
|
|
38
|
+
Tìm nơi sử dụng functions/classes:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Function calls
|
|
42
|
+
grep -r "{function-name}(" src/
|
|
43
|
+
|
|
44
|
+
# Class instantiation
|
|
45
|
+
grep -r "new {ClassName}" src/
|
|
46
|
+
|
|
47
|
+
# Method calls
|
|
48
|
+
grep -r "\.{method-name}(" src/
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
**Example:**
|
|
52
|
+
```bash
|
|
53
|
+
# Changed function: validateEmail()
|
|
54
|
+
grep -r "validateEmail(" src/
|
|
55
|
+
|
|
56
|
+
# Output:
|
|
57
|
+
# src/api/auth.ts: if (!validateEmail(email)) {
|
|
58
|
+
# src/components/SignupForm.tsx: const isValid = validateEmail(value)
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### 3. API Endpoint Consumers
|
|
62
|
+
|
|
63
|
+
Nếu sửa backend API, tìm frontend calls:
|
|
64
|
+
|
|
65
|
+
```bash
|
|
66
|
+
# Fetch/Axios calls
|
|
67
|
+
grep -r "fetch.*['\"].*{endpoint}" src/
|
|
68
|
+
grep -r "axios.*['\"].*{endpoint}" src/
|
|
69
|
+
grep -r "api\.{method}.*{endpoint}" src/
|
|
70
|
+
|
|
71
|
+
# API client methods
|
|
72
|
+
grep -r "api\.(get|post|put|delete).*{endpoint}" src/
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
**Example:**
|
|
76
|
+
```bash
|
|
77
|
+
# Changed: POST /api/users
|
|
78
|
+
grep -r "api/users" src/
|
|
79
|
+
|
|
80
|
+
# Output:
|
|
81
|
+
# src/services/userService.ts: return fetch('/api/users', { method: 'POST' })
|
|
82
|
+
# src/hooks/useUsers.ts: const { data } = useSWR('/api/users')
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### 4. Database Dependencies
|
|
86
|
+
|
|
87
|
+
Nếu sửa database schema:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
# Table usage
|
|
91
|
+
grep -r "{table_name}" src/
|
|
92
|
+
|
|
93
|
+
# Column usage
|
|
94
|
+
grep -r "{column_name}" src/
|
|
95
|
+
|
|
96
|
+
# Prisma queries
|
|
97
|
+
grep -r "prisma\.{model}\." src/
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
**Example:**
|
|
101
|
+
```bash
|
|
102
|
+
# Changed: users table, added 'role' column
|
|
103
|
+
grep -r "users\." src/
|
|
104
|
+
grep -r "\.role" src/
|
|
105
|
+
|
|
106
|
+
# Find queries that need updating
|
|
107
|
+
grep -r "prisma.user.findMany" src/
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
### 5. Type/Interface Dependencies
|
|
111
|
+
|
|
112
|
+
Tìm nơi sử dụng types:
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
# TypeScript interfaces
|
|
116
|
+
grep -r ":\s*{TypeName}" src/
|
|
117
|
+
grep -r "as {TypeName}" src/
|
|
118
|
+
grep -r "extends {TypeName}" src/
|
|
119
|
+
|
|
120
|
+
# Type imports
|
|
121
|
+
grep -r "import.*type.*{TypeName}" src/
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
**Example:**
|
|
125
|
+
```bash
|
|
126
|
+
# Changed: User interface
|
|
127
|
+
grep -r ": User" src/
|
|
128
|
+
grep -r "as User" src/
|
|
129
|
+
|
|
130
|
+
# Output:
|
|
131
|
+
# src/api/users.ts: const user: User = await getUser()
|
|
132
|
+
# src/components/UserCard.tsx: props: { user: User }
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## Using /ck:scout for Parallel Scouting
|
|
136
|
+
|
|
137
|
+
Khi có nhiều files thay đổi, sử dụng `/ck:scout` để parallel search:
|
|
138
|
+
|
|
139
|
+
```
|
|
140
|
+
/ck:scout Scout dependencies for changes.
|
|
141
|
+
|
|
142
|
+
Changed files:
|
|
143
|
+
- src/api/auth.ts (authentication logic)
|
|
144
|
+
- src/utils/validation.ts (email validation)
|
|
145
|
+
- prisma/schema.prisma (users table)
|
|
146
|
+
|
|
147
|
+
Find:
|
|
148
|
+
1. Files importing these modules
|
|
149
|
+
2. Functions/classes being used
|
|
150
|
+
3. API endpoints affected
|
|
151
|
+
4. Database queries using changed tables
|
|
152
|
+
5. Frontend components calling changed APIs
|
|
153
|
+
6. Test files covering changed code
|
|
154
|
+
|
|
155
|
+
Focus on:
|
|
156
|
+
- Direct imports (import/require statements)
|
|
157
|
+
- Function calls (grep for function names)
|
|
158
|
+
- Type usage (TypeScript interfaces)
|
|
159
|
+
- Integration points (API calls, DB queries)
|
|
160
|
+
```
|
|
161
|
+
|
|
162
|
+
## Dependency Graph
|
|
163
|
+
|
|
164
|
+
### Build Dependency Map
|
|
165
|
+
|
|
166
|
+
```javascript
|
|
167
|
+
// dependency-map.js
|
|
168
|
+
const dependencies = {
|
|
169
|
+
"src/api/auth.ts": {
|
|
170
|
+
directDeps: [
|
|
171
|
+
"src/utils/validation.ts",
|
|
172
|
+
"src/services/userService.ts"
|
|
173
|
+
],
|
|
174
|
+
reverseDeps: [
|
|
175
|
+
"src/middleware/auth.ts",
|
|
176
|
+
"src/api/users.ts"
|
|
177
|
+
],
|
|
178
|
+
integrationPoints: [
|
|
179
|
+
"POST /api/login",
|
|
180
|
+
"POST /api/register"
|
|
181
|
+
]
|
|
182
|
+
}
|
|
183
|
+
};
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Visualize Impact
|
|
187
|
+
|
|
188
|
+
```
|
|
189
|
+
src/api/auth.ts (CHANGED)
|
|
190
|
+
├── Direct Dependencies (what it uses)
|
|
191
|
+
│ ├── src/utils/validation.ts
|
|
192
|
+
│ └── src/services/userService.ts
|
|
193
|
+
│
|
|
194
|
+
└── Reverse Dependencies (who uses it)
|
|
195
|
+
├── src/middleware/auth.ts
|
|
196
|
+
│ └── src/api/users.ts (affected)
|
|
197
|
+
│ └── src/api/posts.ts (affected)
|
|
198
|
+
└── src/api/profile.ts (affected)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
## Integration Points Analysis
|
|
202
|
+
|
|
203
|
+
### API Endpoints
|
|
204
|
+
|
|
205
|
+
```bash
|
|
206
|
+
# Find route definitions
|
|
207
|
+
grep -r "router\.(get|post|put|delete)" src/api/
|
|
208
|
+
|
|
209
|
+
# Find endpoint usage in frontend
|
|
210
|
+
grep -r "fetch.*api/" src/components/
|
|
211
|
+
grep -r "axios.*api/" src/services/
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
### Event Handlers
|
|
215
|
+
|
|
216
|
+
```bash
|
|
217
|
+
# React event handlers
|
|
218
|
+
grep -r "onClick.*{handler}" src/
|
|
219
|
+
grep -r "onChange.*{handler}" src/
|
|
220
|
+
|
|
221
|
+
# Event emitters
|
|
222
|
+
grep -r "emit(['\"].*{event}" src/
|
|
223
|
+
grep -r "on(['\"].*{event}" src/
|
|
224
|
+
```
|
|
225
|
+
|
|
226
|
+
### State Management
|
|
227
|
+
|
|
228
|
+
```bash
|
|
229
|
+
# Redux actions
|
|
230
|
+
grep -r "dispatch.*{action}" src/
|
|
231
|
+
|
|
232
|
+
# Context usage
|
|
233
|
+
grep -r "useContext.*{Context}" src/
|
|
234
|
+
|
|
235
|
+
# Zustand stores
|
|
236
|
+
grep -r "use{Store}" src/
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
## Automated Scouting Script
|
|
240
|
+
|
|
241
|
+
```bash
|
|
242
|
+
#!/bin/bash
|
|
243
|
+
# scout-dependencies.sh
|
|
244
|
+
|
|
245
|
+
CHANGED_FILE=$1
|
|
246
|
+
|
|
247
|
+
echo "=== Scouting Dependencies for: $CHANGED_FILE ==="
|
|
248
|
+
echo ""
|
|
249
|
+
|
|
250
|
+
# Extract module name
|
|
251
|
+
MODULE_NAME=$(basename "$CHANGED_FILE" | sed 's/\.[^.]*$//')
|
|
252
|
+
|
|
253
|
+
echo "1. Direct Imports:"
|
|
254
|
+
grep -r "from.*$MODULE_NAME" src/ | head -10
|
|
255
|
+
echo ""
|
|
256
|
+
|
|
257
|
+
echo "2. Function Usage:"
|
|
258
|
+
# Extract function names from changed file
|
|
259
|
+
FUNCTIONS=$(grep -E "^(export )?(function|const) \w+" "$CHANGED_FILE" | awk '{print $2}' | sed 's/[=(].*//')
|
|
260
|
+
for func in $FUNCTIONS; do
|
|
261
|
+
echo " - $func:"
|
|
262
|
+
grep -r "$func(" src/ | grep -v "$CHANGED_FILE" | head -5
|
|
263
|
+
done
|
|
264
|
+
echo ""
|
|
265
|
+
|
|
266
|
+
echo "3. Type Usage:"
|
|
267
|
+
TYPES=$(grep -E "^(export )?(interface|type) \w+" "$CHANGED_FILE" | awk '{print $2}')
|
|
268
|
+
for type in $TYPES; do
|
|
269
|
+
echo " - $type:"
|
|
270
|
+
grep -r ": $type" src/ | grep -v "$CHANGED_FILE" | head -5
|
|
271
|
+
done
|
|
272
|
+
echo ""
|
|
273
|
+
|
|
274
|
+
echo "4. API Endpoints (if applicable):"
|
|
275
|
+
grep -E "router\.(get|post|put|delete)" "$CHANGED_FILE" | while read line; do
|
|
276
|
+
ENDPOINT=$(echo "$line" | grep -oE "['\"][^'\"]+['\"]" | head -1 | tr -d "'\"")
|
|
277
|
+
echo " - $ENDPOINT:"
|
|
278
|
+
grep -r "$ENDPOINT" src/ | grep -v "$CHANGED_FILE" | head -5
|
|
279
|
+
done
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
## Output Format
|
|
283
|
+
|
|
284
|
+
```json
|
|
285
|
+
{
|
|
286
|
+
"changedFile": "src/api/auth.ts",
|
|
287
|
+
"dependencies": {
|
|
288
|
+
"direct": [
|
|
289
|
+
{
|
|
290
|
+
"file": "src/utils/validation.ts",
|
|
291
|
+
"imports": ["validateEmail", "validatePassword"],
|
|
292
|
+
"risk": "medium"
|
|
293
|
+
}
|
|
294
|
+
],
|
|
295
|
+
"reverse": [
|
|
296
|
+
{
|
|
297
|
+
"file": "src/middleware/auth.ts",
|
|
298
|
+
"uses": ["verifyToken", "refreshToken"],
|
|
299
|
+
"impact": "high",
|
|
300
|
+
"reason": "Authentication middleware affected"
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
"file": "src/api/users.ts",
|
|
304
|
+
"uses": ["verifyToken"],
|
|
305
|
+
"impact": "medium",
|
|
306
|
+
"reason": "User API needs auth"
|
|
307
|
+
}
|
|
308
|
+
],
|
|
309
|
+
"integrationPoints": [
|
|
310
|
+
{
|
|
311
|
+
"type": "api",
|
|
312
|
+
"endpoint": "POST /api/login",
|
|
313
|
+
"consumers": [
|
|
314
|
+
"src/components/LoginForm.tsx",
|
|
315
|
+
"src/services/authService.ts"
|
|
316
|
+
]
|
|
317
|
+
}
|
|
318
|
+
]
|
|
319
|
+
},
|
|
320
|
+
"affectedComponents": 8,
|
|
321
|
+
"riskLevel": "high"
|
|
322
|
+
}
|
|
323
|
+
```
|
|
324
|
+
|
|
325
|
+
## Best Practices
|
|
326
|
+
|
|
327
|
+
1. **Start with direct imports** - Easiest to find
|
|
328
|
+
2. **Use parallel scouting** - For multiple files
|
|
329
|
+
3. **Check integration points** - APIs, events, state
|
|
330
|
+
4. **Verify test coverage** - Find test files
|
|
331
|
+
5. **Document findings** - For test scenario generation
|
|
332
|
+
|
|
333
|
+
## Next Steps
|
|
334
|
+
|
|
335
|
+
After scouting, proceed to:
|
|
336
|
+
1. **Edge Case Identification** - Analyze risks in affected files
|
|
337
|
+
2. **Test Scenario Generation** - Create tests for affected components
|