@haposoft/cafekit 0.13.3 โ†’ 0.14.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.
Files changed (114) hide show
  1. package/README.md +1 -2
  2. package/bin/lib/i18n.js +2 -2
  3. package/bin/lib/manifest.js +15 -0
  4. package/bin/lib/opencode-install.js +0 -14
  5. package/bin/phases/claude-runtime.js +4 -1
  6. package/bin/phases/claude-settings.js +38 -7
  7. package/package.json +1 -1
  8. package/src/claude/agents/ui-ux-designer.md +4 -4
  9. package/src/claude/hooks/__tests__/privacy-block.test.js +79 -0
  10. package/src/claude/hooks/__tests__/session-writeenv.test.js +68 -0
  11. package/src/claude/hooks/__tests__/spec-gate.test.js +270 -0
  12. package/src/claude/hooks/privacy-block.cjs +22 -2
  13. package/src/claude/hooks/session.cjs +5 -1
  14. package/src/claude/hooks/spec-gate.cjs +173 -0
  15. package/src/claude/hooks/spec-state.cjs +10 -17
  16. package/src/claude/hooks/task-scaffold-guard.cjs +4 -2
  17. package/src/claude/migration-manifest.json +5 -4
  18. package/src/claude/rules/skill-domain-routing.md +2 -3
  19. package/src/claude/rules/skill-workflow-routing.md +2 -3
  20. package/src/claude/rules/state-sync.md +4 -0
  21. package/src/claude/runtime.json +4 -0
  22. package/src/claude/scripts/validate-docs.cjs +4 -7
  23. package/src/claude/scripts/validate-spec-output.cjs +29 -9
  24. package/src/claude/settings/settings.json +4 -0
  25. package/src/claude/skills/ai-multimodal/.env.example +11 -13
  26. package/src/claude/skills/ai-multimodal/SKILL.md +1 -1
  27. package/src/claude/skills/ai-multimodal/references/audio-processing.md +25 -27
  28. package/src/claude/skills/ai-multimodal/references/video-analysis.md +23 -27
  29. package/src/claude/skills/ai-multimodal/references/vision-understanding.md +26 -26
  30. package/src/claude/skills/ai-multimodal/scripts/check_setup.py +1 -1
  31. package/src/claude/skills/ai-multimodal/scripts/gemini_batch_process.py +7 -9
  32. package/src/claude/skills/brainstorm/SKILL.md +1 -2
  33. package/src/claude/skills/docx/SKILL.md +1 -1
  34. package/src/claude/skills/frontend-design/SKILL.md +1 -1
  35. package/src/claude/skills/frontend-design/references/ai-multimodal-overview.md +4 -4
  36. package/src/claude/skills/frontend-design/references/analysis-techniques.md +3 -3
  37. package/src/claude/skills/frontend-design/references/asset-generation.md +2 -2
  38. package/src/claude/skills/frontend-design/references/design-extraction-overview.md +4 -4
  39. package/src/claude/skills/frontend-design/references/extraction-best-practices.md +3 -3
  40. package/src/claude/skills/frontend-design/references/technical-accessibility.md +1 -1
  41. package/src/claude/skills/frontend-design/references/technical-optimization.md +1 -1
  42. package/src/claude/skills/frontend-design/references/technical-overview.md +2 -2
  43. package/src/claude/skills/frontend-design/references/technical-workflows.md +6 -6
  44. package/src/claude/skills/frontend-design/references/visual-analysis-overview.md +3 -3
  45. package/src/claude/skills/inspect/SKILL.md +3 -3
  46. package/src/claude/skills/inspect/references/external-gemini-inspection.md +9 -9
  47. package/src/claude/skills/pdf/SKILL.md +1 -1
  48. package/src/claude/skills/pptx/SKILL.md +1 -1
  49. package/src/claude/skills/specs/SKILL.md +1 -1
  50. package/src/claude/skills/xlsx/SKILL.md +1 -1
  51. package/src/opencode/AGENTS.md +1 -2
  52. package/src/opencode/plugins/session.ts +2 -2
  53. package/src/opencode/plugins/spec-state.ts +244 -0
  54. package/src/opencode/plugins/task-scaffold-guard.ts +161 -0
  55. package/src/claude/scripts/browser-tool.cjs +0 -138
  56. package/src/claude/skills/generate-graph/LICENSE +0 -21
  57. package/src/claude/skills/generate-graph/README.md +0 -523
  58. package/src/claude/skills/generate-graph/SKILL.md +0 -429
  59. package/src/claude/skills/generate-graph/agentloop-core.svg +0 -101
  60. package/src/claude/skills/generate-graph/agents/openai.yaml +0 -4
  61. package/src/claude/skills/generate-graph/assets/samples/sample-style1-flat.png +0 -0
  62. package/src/claude/skills/generate-graph/assets/samples/sample-style2-dark.png +0 -0
  63. package/src/claude/skills/generate-graph/assets/samples/sample-style3-blueprint.png +0 -0
  64. package/src/claude/skills/generate-graph/assets/samples/sample-style4-notion.png +0 -0
  65. package/src/claude/skills/generate-graph/assets/samples/sample-style5-glass.png +0 -0
  66. package/src/claude/skills/generate-graph/assets/samples/sample-style6-claude.png +0 -0
  67. package/src/claude/skills/generate-graph/assets/samples/sample-style7-openai.png +0 -0
  68. package/src/claude/skills/generate-graph/fixtures/agent-memory-types-style4.json +0 -181
  69. package/src/claude/skills/generate-graph/fixtures/api-flow-style7.json +0 -40
  70. package/src/claude/skills/generate-graph/fixtures/mem0-style1.json +0 -297
  71. package/src/claude/skills/generate-graph/fixtures/microservices-style3.json +0 -64
  72. package/src/claude/skills/generate-graph/fixtures/multi-agent-style5.json +0 -45
  73. package/src/claude/skills/generate-graph/fixtures/system-architecture-style6.json +0 -48
  74. package/src/claude/skills/generate-graph/fixtures/tool-call-style2.json +0 -182
  75. package/src/claude/skills/generate-graph/package.json +0 -42
  76. package/src/claude/skills/generate-graph/references/icons.md +0 -281
  77. package/src/claude/skills/generate-graph/references/style-1-flat-icon.md +0 -108
  78. package/src/claude/skills/generate-graph/references/style-2-dark-terminal.md +0 -107
  79. package/src/claude/skills/generate-graph/references/style-3-blueprint.md +0 -113
  80. package/src/claude/skills/generate-graph/references/style-4-notion-clean.md +0 -94
  81. package/src/claude/skills/generate-graph/references/style-5-glassmorphism.md +0 -125
  82. package/src/claude/skills/generate-graph/references/style-6-claude-official.md +0 -209
  83. package/src/claude/skills/generate-graph/references/style-7-openai.md +0 -215
  84. package/src/claude/skills/generate-graph/references/style-diagram-matrix.md +0 -135
  85. package/src/claude/skills/generate-graph/references/svg-layout-best-practices.md +0 -100
  86. package/src/claude/skills/generate-graph/scripts/generate-diagram.sh +0 -157
  87. package/src/claude/skills/generate-graph/scripts/generate-from-template.py +0 -1556
  88. package/src/claude/skills/generate-graph/scripts/test-all-styles.sh +0 -135
  89. package/src/claude/skills/generate-graph/scripts/validate-svg.sh +0 -292
  90. package/src/claude/skills/generate-graph/templates/agent-architecture.svg +0 -28
  91. package/src/claude/skills/generate-graph/templates/architecture.svg +0 -23
  92. package/src/claude/skills/generate-graph/templates/comparison-matrix.svg +0 -14
  93. package/src/claude/skills/generate-graph/templates/data-flow.svg +0 -28
  94. package/src/claude/skills/generate-graph/templates/er-diagram.svg +0 -21
  95. package/src/claude/skills/generate-graph/templates/flowchart.svg +0 -21
  96. package/src/claude/skills/generate-graph/templates/sequence.svg +0 -20
  97. package/src/claude/skills/generate-graph/templates/state-machine.svg +0 -20
  98. package/src/claude/skills/generate-graph/templates/timeline.svg +0 -19
  99. package/src/claude/skills/generate-graph/templates/use-case.svg +0 -21
  100. package/src/claude/skills/impact-analysis/SKILL.md +0 -276
  101. package/src/claude/skills/impact-analysis/references/change-detection.md +0 -270
  102. package/src/claude/skills/impact-analysis/references/dependency-scouting.md +0 -338
  103. package/src/claude/skills/impact-analysis/references/edge-case-identification.md +0 -439
  104. package/src/claude/skills/impact-analysis/references/industry-techniques.md +0 -695
  105. package/src/claude/skills/impact-analysis/references/practical-techniques-guide.md +0 -753
  106. package/src/claude/skills/impact-analysis/references/project-detection.md +0 -704
  107. package/src/claude/skills/impact-analysis/references/react-native-customization.md +0 -508
  108. package/src/claude/skills/impact-analysis/references/report-template.md +0 -604
  109. package/src/claude/skills/impact-analysis/references/test-scenario-generation.md +0 -459
  110. package/src/claude/skills/impact-analysis/scripts/README.md +0 -476
  111. package/src/claude/skills/impact-analysis/scripts/ast-analyze.js +0 -403
  112. package/src/claude/skills/impact-analysis/scripts/calculate-risk.js +0 -475
  113. package/src/claude/skills/impact-analysis/scripts/find-dependencies.sh +0 -202
  114. package/src/claude/skills/impact-analysis/scripts/run-analysis.sh +0 -312
@@ -1,753 +0,0 @@
1
- # Practical Techniques Guide - Hฦฐแป›ng Dแบซn รp Dแปฅng Thแปฑc Tแบฟ
2
-
3
- Hฦฐแป›ng dแบซn chi tiแบฟt cรกch รกp dแปฅng cรกc industry techniques vร o Impact Analysis.
4
-
5
- ## ๐Ÿ“‹ Overview
6
-
7
- Document nร y cung cแบฅp:
8
- - Scripts vร  commands thแปฑc tแบฟ cho tแปซng technique
9
- - Vรญ dแปฅ cแปฅ thแปƒ cho tแปซng loแบกi project
10
- - Integration vแป›i existing workflow
11
- - Troubleshooting vร  best practices
12
-
13
- ---
14
-
15
- ## ๐ŸŽฏ Technique #1: Dependency Analysis (MUST HAVE)
16
-
17
- ### Purpose
18
- Find all files affected by code changes.
19
-
20
- ### Tools & Commands
21
-
22
- #### JavaScript/TypeScript Projects
23
-
24
- **1. Find Direct Imports**
25
- ```bash
26
- # Find files importing modified module
27
- grep -r "from.*authService" src/ --include="*.ts" --include="*.tsx"
28
- grep -r "import.*authService" src/ --include="*.ts" --include="*.tsx"
29
-
30
- # Hoแบทc dรนng ripgrep (nhanh hฦกn)
31
- rg "from.*authService" src/ -t ts -t tsx
32
- ```
33
-
34
- **2. Find Function Calls**
35
- ```bash
36
- # Find files calling modified function
37
- grep -r "login\(" src/ --include="*.ts" --include="*.tsx"
38
-
39
- # Exclude test files
40
- grep -r "login\(" src/ --include="*.ts" --include="*.tsx" --exclude="*.test.*"
41
- ```
42
-
43
- **3. Build Dependency Graph**
44
- ```bash
45
- # Install madge
46
- npm install -g madge
47
-
48
- # Generate dependency graph
49
- madge --image graph.png src/
50
-
51
- # Find circular dependencies
52
- madge --circular src/
53
-
54
- # Show dependencies for specific file
55
- madge src/services/authService.ts
56
- ```
57
-
58
- **4. Find API Consumers**
59
- ```bash
60
- # Find frontend components calling API
61
- grep -r "fetch.*\/api\/auth" src/
62
- grep -r "axios.*\/api\/auth" src/
63
- grep -r "\/api\/auth" src/ --include="*.ts" --include="*.tsx"
64
- ```
65
-
66
- #### React/React Native Projects
67
-
68
- **Find Component Usage**
69
- ```bash
70
- # Find components using modified component
71
- grep -r "<LoginButton" src/ --include="*.tsx"
72
- grep -r "LoginButton" src/ --include="*.tsx" | grep "import"
73
- ```
74
-
75
- #### Python Projects
76
-
77
- ```bash
78
- # Find imports
79
- grep -r "from.*auth_service" . --include="*.py"
80
- grep -r "import auth_service" . --include="*.py"
81
-
82
- # Find function calls
83
- grep -r "login(" . --include="*.py"
84
- ```
85
-
86
- ### Output Format
87
-
88
- ```markdown
89
- ## ๐Ÿ”— Dependencies & Affected Files
90
-
91
- ### Direct Imports (5 files)
92
- - `src/screens/Auth/LoginScreen.tsx` โ†’ imports `authService`
93
- - `src/hooks/useAuth.ts` โ†’ imports `authService`
94
- - `src/api/client.ts` โ†’ imports `authService`
95
- - `src/utils/session.ts` โ†’ imports `authService`
96
- - `src/services/userService.ts` โ†’ imports `authService`
97
-
98
- ### Function Calls (8 locations)
99
- - `src/screens/Auth/LoginScreen.tsx:45` โ†’ calls `login()`
100
- - `src/screens/Auth/SignupScreen.tsx:67` โ†’ calls `login()`
101
- - `src/hooks/useAuth.ts:23` โ†’ calls `login()`
102
- - ...
103
-
104
- ### API Consumers (3 components)
105
- - `src/screens/Profile/ProfileScreen.tsx` โ†’ calls `/api/auth/me`
106
- - `src/components/Header.tsx` โ†’ calls `/api/auth/logout`
107
- - `src/screens/Settings/SettingsScreen.tsx` โ†’ calls `/api/auth/change-password`
108
- ```
109
-
110
- ---
111
-
112
- ## ๐ŸŽฏ Technique #2: AST-Based Analysis (NICE TO HAVE)
113
-
114
- ### Purpose
115
- Detect semantic changes (function signature, type changes, breaking changes).
116
-
117
- ### Tools & Setup
118
-
119
- #### JavaScript/TypeScript
120
-
121
- **Install Dependencies**
122
- ```bash
123
- npm install --save-dev @babel/parser @babel/traverse
124
- # Or
125
- npm install --save-dev typescript
126
- ```
127
-
128
- **Script: Detect Function Signature Changes**
129
-
130
- Create `scripts/ast-analyze.js`:
131
-
132
- ```javascript
133
- const fs = require('fs');
134
- const parser = require('@babel/parser');
135
- const traverse = require('@babel/traverse').default;
136
-
137
- function analyzeFunctionSignatures(filePath) {
138
- const code = fs.readFileSync(filePath, 'utf-8');
139
-
140
- const ast = parser.parse(code, {
141
- sourceType: 'module',
142
- plugins: ['typescript', 'jsx']
143
- });
144
-
145
- const functions = [];
146
-
147
- traverse(ast, {
148
- FunctionDeclaration(path) {
149
- functions.push({
150
- name: path.node.id.name,
151
- params: path.node.params.length,
152
- async: path.node.async,
153
- line: path.node.loc.start.line
154
- });
155
- },
156
- ArrowFunctionExpression(path) {
157
- if (path.parent.type === 'VariableDeclarator') {
158
- functions.push({
159
- name: path.parent.id.name,
160
- params: path.node.params.length,
161
- async: path.node.async,
162
- line: path.node.loc.start.line
163
- });
164
- }
165
- }
166
- });
167
-
168
- return functions;
169
- }
170
-
171
- // Usage
172
- const file = process.argv[2];
173
- const functions = analyzeFunctionSignatures(file);
174
- console.log(JSON.stringify(functions, null, 2));
175
- ```
176
-
177
- **Usage**
178
- ```bash
179
- node scripts/ast-analyze.js src/services/authService.ts
180
- ```
181
-
182
- **Compare Before/After**
183
- ```bash
184
- # Analyze before
185
- git show HEAD~1:src/services/authService.ts > /tmp/before.ts
186
- node scripts/ast-analyze.js /tmp/before.ts > /tmp/before.json
187
-
188
- # Analyze after
189
- node scripts/ast-analyze.js src/services/authService.ts > /tmp/after.json
190
-
191
- # Compare
192
- diff /tmp/before.json /tmp/after.json
193
- ```
194
-
195
- ### Output Format
196
-
197
- ```markdown
198
- ## ๐Ÿ” Semantic Changes Detected (AST Analysis)
199
-
200
- ### Function Signature Changes
201
-
202
- **1. `login()` - BREAKING CHANGE**
203
- - **Before**: `login(email, password)` (2 params)
204
- - **After**: `login(email, password, rememberMe)` (3 params)
205
- - **Impact**: All 8 callers need update
206
- - **Files affected**: [list]
207
-
208
- **2. `validateUser()` - Non-breaking**
209
- - **Before**: `validateUser(email)` (1 param)
210
- - **After**: `validateUser(email, options = {})` (2 params, optional)
211
- - **Impact**: Backward compatible, no changes needed
212
-
213
- ### Type Changes
214
-
215
- **1. `User` interface - BREAKING CHANGE**
216
- - **Added fields**: `biometricEnabled: boolean`
217
- - **Impact**: Serialization/deserialization affected
218
- - **Files affected**: [list]
219
- ```
220
-
221
- ---
222
-
223
- ## ๐ŸŽฏ Technique #3: Static Analysis (NICE TO HAVE)
224
-
225
- ### Purpose
226
- Detect code quality issues, security issues, and potential bugs.
227
-
228
- ### Tools
229
-
230
- #### ESLint (JavaScript/TypeScript)
231
-
232
- ```bash
233
- # Run ESLint on changed files
234
- eslint src/services/authService.ts --format json > eslint-report.json
235
-
236
- # Check specific rules
237
- eslint src/ --rule 'no-console: error' --rule 'no-unused-vars: error'
238
- ```
239
-
240
- #### TypeScript Compiler
241
-
242
- ```bash
243
- # Type check
244
- tsc --noEmit
245
-
246
- # Type check specific file
247
- tsc --noEmit src/services/authService.ts
248
-
249
- # Get diagnostics
250
- tsc --noEmit --pretty false 2>&1 | grep "error TS"
251
- ```
252
-
253
- #### SonarQube (Advanced)
254
-
255
- ```bash
256
- # Run SonarQube scanner
257
- sonar-scanner \
258
- -Dsonar.projectKey=my-project \
259
- -Dsonar.sources=src \
260
- -Dsonar.host.url=http://localhost:9000
261
- ```
262
-
263
- ### Output Format
264
-
265
- ```markdown
266
- ## ๐Ÿ” Static Analysis Results
267
-
268
- ### Type Errors (3)
269
- 1. **src/services/authService.ts:45**
270
- - Error: Property 'biometricEnabled' does not exist on type 'User'
271
- - Fix: Add field to User interface
272
-
273
- 2. **src/hooks/useAuth.ts:23**
274
- - Error: Argument of type 'string' is not assignable to parameter of type 'User'
275
- - Fix: Update function call
276
-
277
- ### Code Quality Issues (5)
278
- 1. **Unused variable** - `src/services/authService.ts:67`
279
- 2. **Missing error handling** - `src/services/authService.ts:89`
280
- 3. **Console.log in production** - `src/services/authService.ts:102`
281
- ```
282
-
283
- ---
284
-
285
- ## ๐ŸŽฏ Technique #4: Test Coverage Analysis (SHOULD HAVE)
286
-
287
- ### Purpose
288
- Find affected tests and identify untested code.
289
-
290
- ### Tools & Commands
291
-
292
- #### Jest (JavaScript/TypeScript)
293
-
294
- **1. Find Related Tests**
295
- ```bash
296
- # Find tests covering changed files
297
- jest --findRelatedTests src/services/authService.ts
298
-
299
- # Run with coverage
300
- jest --coverage --collectCoverageFrom="src/services/authService.ts"
301
- ```
302
-
303
- **2. Generate Coverage Report**
304
- ```bash
305
- # HTML report
306
- jest --coverage --coverageReporters=html
307
-
308
- # JSON report
309
- jest --coverage --coverageReporters=json
310
-
311
- # View report
312
- open coverage/index.html
313
- ```
314
-
315
- **3. Coverage Thresholds**
316
- ```bash
317
- # Check if coverage meets threshold
318
- jest --coverage --coverageThreshold='{"global":{"branches":80,"functions":80,"lines":80}}'
319
- ```
320
-
321
- #### Python (pytest + coverage)
322
-
323
- ```bash
324
- # Run tests with coverage
325
- pytest --cov=src/services --cov-report=html
326
-
327
- # Find tests for specific file
328
- pytest --collect-only | grep auth_service
329
- ```
330
-
331
- ### Output Format
332
-
333
- ```markdown
334
- ## ๐Ÿงช Test Coverage Analysis
335
-
336
- ### Affected Tests (12 tests)
337
-
338
- **Unit Tests** (5 tests)
339
- - `authService.test.ts` - 8 tests
340
- - โœ… login() with valid credentials
341
- - โœ… login() with invalid credentials
342
- - โœ… logout()
343
- - โŒ login() with biometric (NEW - not covered)
344
- - โŒ biometric permission handling (NEW - not covered)
345
-
346
- **Integration Tests** (4 tests)
347
- - `auth.integration.test.ts` - 4 tests
348
- - โœ… Full login flow
349
- - โœ… Session persistence
350
- - โŒ Biometric login flow (NEW - not covered)
351
-
352
- **E2E Tests** (3 tests)
353
- - `e2e/auth.spec.ts` - 3 tests
354
- - โœ… User can login
355
- - โœ… User can logout
356
- - โŒ User can login with biometric (NEW - not covered)
357
-
358
- ### Coverage Gaps
359
-
360
- **Uncovered Lines** (45 lines)
361
- - `src/services/authService.ts:89-102` - Biometric authentication logic
362
- - `src/services/authService.ts:145-156` - Permission handling
363
- - `src/utils/biometric/biometricHelper.ts:23-67` - Entire file
364
-
365
- **Coverage**: 67% (target: 80%)
366
- **Action**: Add 8 new tests to reach 80%
367
- ```
368
-
369
- ---
370
-
371
- ## ๐ŸŽฏ Technique #5: Feature Mapping (MUST HAVE)
372
-
373
- ### Purpose
374
- Map code changes to features and user actions.
375
-
376
- ### Implementation
377
-
378
- **Pattern-Based Mapping**
379
-
380
- Create `scripts/map-features.js`:
381
-
382
- ```javascript
383
- const featurePatterns = {
384
- 'Authentication & Login': {
385
- patterns: [
386
- '**/api/auth**',
387
- '**/auth**',
388
- '**/login**',
389
- '**/services/auth*'
390
- ],
391
- keywords: ['login', 'signin', 'authenticate', 'token', 'session'],
392
- userActions: [
393
- 'Login',
394
- 'Logout',
395
- 'Sign Up',
396
- 'Password Reset',
397
- 'Session Management',
398
- '2FA',
399
- 'Biometric Authentication'
400
- ]
401
- },
402
- 'User Profile Management': {
403
- patterns: [
404
- '**/api/users**',
405
- '**/user**',
406
- '**/profile**'
407
- ],
408
- keywords: ['profile', 'avatar', 'bio', 'settings'],
409
- userActions: [
410
- 'View Profile',
411
- 'Edit Profile',
412
- 'Upload Avatar',
413
- 'Change Settings',
414
- 'Update Bio'
415
- ]
416
- },
417
- // ... more features
418
- };
419
-
420
- function mapFeatures(changedFiles) {
421
- const affectedFeatures = [];
422
-
423
- for (const [featureName, config] of Object.entries(featurePatterns)) {
424
- const matched = changedFiles.some(file =>
425
- config.patterns.some(pattern =>
426
- minimatch(file, pattern)
427
- )
428
- );
429
-
430
- if (matched) {
431
- affectedFeatures.push({
432
- name: featureName,
433
- userActions: config.userActions,
434
- files: changedFiles.filter(file =>
435
- config.patterns.some(pattern => minimatch(file, pattern))
436
- )
437
- });
438
- }
439
- }
440
-
441
- return affectedFeatures;
442
- }
443
- ```
444
-
445
- ### Output Format
446
-
447
- ```markdown
448
- ## ๐ŸŽฏ Feature Impact Map
449
-
450
- ### Feature 1: Authentication & Login (HIGH IMPACT)
451
-
452
- **Files Changed** (3):
453
- - src/services/authService.ts
454
- - src/utils/biometric/biometricHelper.ts
455
- - src/screens/Auth/LoginScreen.tsx
456
-
457
- **User Actions Affected** (7):
458
- - โœ“ Login (modified)
459
- - โœ“ Logout (no change)
460
- - โœ“ Sign Up (no change)
461
- - โœ“ Password Reset (no change)
462
- - โœ“ Session Management (modified)
463
- - โœ“ 2FA (no change)
464
- - ๐Ÿ†• Biometric Authentication (NEW)
465
-
466
- **Impact Scenarios**:
467
- 1. **When user tries to login**
468
- - Can now use biometric (Face ID/Touch ID)
469
- - Password login still works
470
- - Session storage changed (may need re-login)
471
-
472
- 2. **When user opens app**
473
- - May see biometric prompt
474
- - May need to re-login after update
475
- ```
476
-
477
- ---
478
-
479
- ## ๐ŸŽฏ Technique #6: Risk Scoring (SHOULD HAVE)
480
-
481
- ### Purpose
482
- Assess risk level of changes.
483
-
484
- ### Algorithm
485
-
486
- ```javascript
487
- function calculateRiskScore(changes) {
488
- let score = 0;
489
-
490
- // File type risk
491
- if (changes.database.length > 0) score += 5; // Database changes = high risk
492
- if (changes.api.length > 0) score += 3; // API changes = medium risk
493
- if (changes.frontend.length > 0) score += 1; // Frontend = low risk
494
-
495
- // Change size risk
496
- const totalLines = changes.linesAdded + changes.linesRemoved;
497
- if (totalLines > 500) score += 3;
498
- else if (totalLines > 200) score += 2;
499
- else if (totalLines > 50) score += 1;
500
-
501
- // Dependency risk
502
- const affectedFiles = changes.dependencies.length;
503
- if (affectedFiles > 20) score += 3;
504
- else if (affectedFiles > 10) score += 2;
505
- else if (affectedFiles > 5) score += 1;
506
-
507
- // Feature risk
508
- const criticalFeatures = ['auth', 'payment', 'security'];
509
- const hasCritical = changes.features.some(f =>
510
- criticalFeatures.some(cf => f.toLowerCase().includes(cf))
511
- );
512
- if (hasCritical) score += 5;
513
-
514
- // Breaking changes
515
- if (changes.breakingChanges > 0) score += 5;
516
-
517
- // Test coverage
518
- if (changes.testCoverage < 50) score += 2;
519
- else if (changes.testCoverage < 70) score += 1;
520
-
521
- return {
522
- score,
523
- level: score >= 15 ? 'CRITICAL' : score >= 10 ? 'HIGH' : score >= 5 ? 'MEDIUM' : 'LOW'
524
- };
525
- }
526
- ```
527
-
528
- ### Output Format
529
-
530
- ```markdown
531
- ## ๐ŸŽฏ Risk Assessment
532
-
533
- **Risk Score**: 18/25
534
- **Risk Level**: CRITICAL โš ๏ธโš ๏ธโš ๏ธ
535
-
536
- ### Risk Breakdown
537
-
538
- | Factor | Score | Reason |
539
- |--------|-------|--------|
540
- | Database Changes | 5 | Schema migration required |
541
- | API Changes | 3 | Breaking changes in auth API |
542
- | Change Size | 2 | 250 lines changed |
543
- | Dependencies | 2 | 12 files affected |
544
- | Critical Feature | 5 | Authentication system |
545
- | Breaking Changes | 5 | Function signature changed |
546
- | Test Coverage | 0 | 75% coverage (good) |
547
-
548
- ### Mitigation Recommendations
549
-
550
- 1. **Database Migration**
551
- - Create rollback script
552
- - Test migration on staging
553
- - Backup production data
554
-
555
- 2. **Breaking Changes**
556
- - Update all 8 callers
557
- - Add deprecation warnings
558
- - Document migration guide
559
-
560
- 3. **Testing**
561
- - Add 8 new test scenarios
562
- - Run full regression suite
563
- - Test on multiple devices
564
- ```
565
-
566
- ---
567
-
568
- ## ๐Ÿ”„ Integration vแป›i Workflow
569
-
570
- ### Step-by-Step Integration
571
-
572
- **1. Detect Changes** (existing)
573
- ```bash
574
- git diff HEAD --name-only
575
- ```
576
-
577
- **2. Dependency Analysis** (NEW - Technique #1)
578
- ```bash
579
- # For each changed file
580
- for file in $(git diff HEAD --name-only); do
581
- echo "=== Dependencies for $file ==="
582
- grep -r "from.*$(basename $file .ts)" src/
583
- done
584
- ```
585
-
586
- **3. AST Analysis** (NEW - Technique #2)
587
- ```bash
588
- # Analyze function signatures
589
- node scripts/ast-analyze.js src/services/authService.ts
590
- ```
591
-
592
- **4. Feature Mapping** (NEW - Technique #5)
593
- ```bash
594
- # Map to features
595
- node scripts/map-features.js $(git diff HEAD --name-only)
596
- ```
597
-
598
- **5. Test Coverage** (NEW - Technique #4)
599
- ```bash
600
- # Find related tests
601
- jest --findRelatedTests $(git diff HEAD --name-only | grep -E '\.(ts|tsx)$')
602
- ```
603
-
604
- **6. Risk Scoring** (NEW - Technique #6)
605
- ```bash
606
- # Calculate risk
607
- node scripts/calculate-risk.js
608
- ```
609
-
610
- **7. Generate Report** (existing)
611
- ```bash
612
- # Combine all findings into report
613
- ```
614
-
615
- ---
616
-
617
- ## ๐Ÿ“Š Complete Example
618
-
619
- ### Scenario: Added Biometric Authentication
620
-
621
- **Input**:
622
- ```bash
623
- /impact-analysis biometric-auth
624
- ```
625
-
626
- **Execution**:
627
-
628
- ```bash
629
- # 1. Detect changes
630
- git diff feature/biometric-auth --name-only
631
- # Output: 5 files changed
632
-
633
- # 2. Dependency analysis
634
- grep -r "from.*authService" src/
635
- # Output: 12 files import authService
636
-
637
- # 3. AST analysis
638
- node scripts/ast-analyze.js src/services/authService.ts
639
- # Output: login() signature changed (2 โ†’ 3 params)
640
-
641
- # 4. Feature mapping
642
- node scripts/map-features.js
643
- # Output: Authentication & Login feature affected
644
-
645
- # 5. Test coverage
646
- jest --findRelatedTests src/services/authService.ts
647
- # Output: 8 tests found, 3 new scenarios needed
648
-
649
- # 6. Risk scoring
650
- node scripts/calculate-risk.js
651
- # Output: Risk = HIGH (score: 18)
652
- ```
653
-
654
- **Output Report**: See `impact-analysis-output-example.md`
655
-
656
- ---
657
-
658
- ## ๐Ÿ› ๏ธ Helper Scripts
659
-
660
- ### Create All Helper Scripts
661
-
662
- ```bash
663
- # Create scripts directory
664
- mkdir -p scripts/impact-analysis
665
-
666
- # Create scripts
667
- touch scripts/impact-analysis/ast-analyze.js
668
- touch scripts/impact-analysis/map-features.js
669
- touch scripts/impact-analysis/calculate-risk.js
670
- touch scripts/impact-analysis/find-dependencies.sh
671
- touch scripts/impact-analysis/analyze-coverage.sh
672
- ```
673
-
674
- ### Master Script
675
-
676
- Create `scripts/impact-analysis/run-all.sh`:
677
-
678
- ```bash
679
- #!/bin/bash
680
-
681
- echo "๐Ÿ” Running Impact Analysis..."
682
-
683
- # 1. Detect changes
684
- echo "๐Ÿ“ Detecting changes..."
685
- CHANGED_FILES=$(git diff HEAD --name-only)
686
- echo "$CHANGED_FILES"
687
-
688
- # 2. Find dependencies
689
- echo "๐Ÿ”— Finding dependencies..."
690
- ./scripts/impact-analysis/find-dependencies.sh "$CHANGED_FILES"
691
-
692
- # 3. AST analysis
693
- echo "๐ŸŒณ Running AST analysis..."
694
- for file in $CHANGED_FILES; do
695
- if [[ $file == *.ts ]] || [[ $file == *.tsx ]]; then
696
- node scripts/impact-analysis/ast-analyze.js "$file"
697
- fi
698
- done
699
-
700
- # 4. Feature mapping
701
- echo "๐ŸŽฏ Mapping features..."
702
- node scripts/impact-analysis/map-features.js "$CHANGED_FILES"
703
-
704
- # 5. Test coverage
705
- echo "๐Ÿงช Analyzing test coverage..."
706
- ./scripts/impact-analysis/analyze-coverage.sh "$CHANGED_FILES"
707
-
708
- # 6. Risk scoring
709
- echo "โš ๏ธ Calculating risk..."
710
- node scripts/impact-analysis/calculate-risk.js
711
-
712
- echo "โœ… Analysis complete!"
713
- ```
714
-
715
- ---
716
-
717
- ## ๐Ÿ’ก Best Practices
718
-
719
- ### 1. Start Simple
720
- - Begin vแป›i Dependency Analysis (Technique #1)
721
- - Add Feature Mapping (Technique #5)
722
- - Gradually add advanced techniques
723
-
724
- ### 2. Automate
725
- - Create helper scripts
726
- - Integrate vร o CI/CD
727
- - Run on pre-commit hook
728
-
729
- ### 3. Customize
730
- - Adjust patterns cho project
731
- - Tune risk scoring thresholds
732
- - Add project-specific checks
733
-
734
- ### 4. Iterate
735
- - Review findings
736
- - Improve detection logic
737
- - Add missing patterns
738
-
739
- ---
740
-
741
- ## ๐Ÿš€ Next Steps
742
-
743
- 1. โœ… Read this guide
744
- 2. โš ๏ธ Create helper scripts
745
- 3. โœ… Test on sample changes
746
- 4. โœ… Integrate vร o workflow
747
- 5. โœ… Customize cho project
748
-
749
- ---
750
-
751
- **Estimated setup time**: 2-3 hours
752
- **Estimated time saved per analysis**: 30-60 minutes
753
- **ROI**: High (prevents regression bugs)