codebase-analyzer-mcp 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/.claude-plugin/marketplace.json +31 -0
- package/.claude-plugin/plugin.json +29 -0
- package/AGENTS.md +112 -0
- package/CLAUDE.md +150 -0
- package/LICENSE +21 -0
- package/README.md +252 -0
- package/agents/analysis/architecture-analyzer.md +115 -0
- package/agents/analysis/dataflow-tracer.md +120 -0
- package/agents/analysis/pattern-detective.md +110 -0
- package/agents/research/codebase-explorer.md +106 -0
- package/commands/analyze.md +74 -0
- package/commands/compare.md +66 -0
- package/commands/explore.md +64 -0
- package/commands/patterns.md +75 -0
- package/commands/trace.md +65 -0
- package/dist/cli/index.js +73758 -0
- package/dist/mcp/server.js +70931 -0
- package/package.json +75 -0
- package/skills/add-mcp-tool/SKILL.md +209 -0
- package/skills/codebase-analysis/SKILL.md +128 -0
- package/skills/codebase-analysis/references/api-reference.md +201 -0
- package/skills/debugging-analysis/SKILL.md +213 -0
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: debugging-analysis
|
|
3
|
+
description: This skill helps troubleshoot issues with codebase analysis - failed analyses, incorrect results, performance problems, and Gemini API errors. Use when analysis isn't working as expected.
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Debugging Analysis Issues
|
|
7
|
+
|
|
8
|
+
## Common Issues
|
|
9
|
+
|
|
10
|
+
### 1. Analysis Fails Immediately
|
|
11
|
+
|
|
12
|
+
**Symptom:** Error on startup, no analysis runs
|
|
13
|
+
|
|
14
|
+
**Check:**
|
|
15
|
+
```bash
|
|
16
|
+
# Verify build
|
|
17
|
+
pnpm build
|
|
18
|
+
|
|
19
|
+
# Check for TypeScript errors
|
|
20
|
+
pnpm tsc --noEmit
|
|
21
|
+
|
|
22
|
+
# Test CLI works
|
|
23
|
+
pnpm cba capabilities
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
**Common causes:**
|
|
27
|
+
- TypeScript compilation errors
|
|
28
|
+
- Missing dependencies (`pnpm install`)
|
|
29
|
+
- Syntax error in recent changes
|
|
30
|
+
|
|
31
|
+
### 2. Gemini API Errors
|
|
32
|
+
|
|
33
|
+
**Symptom:** Semantic analysis fails with API error
|
|
34
|
+
|
|
35
|
+
**Check:**
|
|
36
|
+
```bash
|
|
37
|
+
# Verify API key is set
|
|
38
|
+
echo $GEMINI_API_KEY
|
|
39
|
+
|
|
40
|
+
# Test with explicit key
|
|
41
|
+
GEMINI_API_KEY=your-key pnpm cba analyze . -d deep -s
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**Common causes:**
|
|
45
|
+
- Missing `GEMINI_API_KEY` environment variable
|
|
46
|
+
- Invalid or expired API key
|
|
47
|
+
- Rate limiting (wait and retry)
|
|
48
|
+
- Network issues
|
|
49
|
+
|
|
50
|
+
**Fix:** Set API key:
|
|
51
|
+
```bash
|
|
52
|
+
export GEMINI_API_KEY=your-key-here
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### 3. Analysis Returns Empty Results
|
|
56
|
+
|
|
57
|
+
**Symptom:** Analysis completes but sections are empty
|
|
58
|
+
|
|
59
|
+
**Check:**
|
|
60
|
+
```bash
|
|
61
|
+
# Run with verbose output
|
|
62
|
+
pnpm cba analyze . -v
|
|
63
|
+
|
|
64
|
+
# Check surface analysis
|
|
65
|
+
pnpm cba analyze . -d surface
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
**Common causes:**
|
|
69
|
+
- All files excluded by patterns
|
|
70
|
+
- Repository is empty or only has ignored files
|
|
71
|
+
- Focus filter matches nothing
|
|
72
|
+
|
|
73
|
+
**Debug:**
|
|
74
|
+
```typescript
|
|
75
|
+
// In orchestrator.ts, check modulesToAnalyze
|
|
76
|
+
console.log("Modules to analyze:", modulesToAnalyze);
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
### 4. Wrong Repository Name
|
|
80
|
+
|
|
81
|
+
**Symptom:** Shows temp directory name instead of repo name
|
|
82
|
+
|
|
83
|
+
**Check:** Ensure `sourceName` is passed through:
|
|
84
|
+
1. `extractSourceName()` in analyze.ts or cli/index.ts
|
|
85
|
+
2. Passed to `orchestrateAnalysis()` options
|
|
86
|
+
3. Passed to `surfaceAnalysis()` options
|
|
87
|
+
4. Used in `buildRepositoryMap()`
|
|
88
|
+
|
|
89
|
+
### 5. Structural Analysis Slow
|
|
90
|
+
|
|
91
|
+
**Symptom:** Takes too long on large repos
|
|
92
|
+
|
|
93
|
+
**Check:**
|
|
94
|
+
```bash
|
|
95
|
+
# See batch progress
|
|
96
|
+
pnpm cba analyze . -v
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
**Tune:**
|
|
100
|
+
- Reduce `MAX_PARALLEL_STRUCTURAL` in orchestrator.ts
|
|
101
|
+
- Use `--focus` to limit modules
|
|
102
|
+
- Increase `--exclude` patterns
|
|
103
|
+
|
|
104
|
+
### 6. Property Access Errors
|
|
105
|
+
|
|
106
|
+
**Symptom:** `Cannot read properties of undefined`
|
|
107
|
+
|
|
108
|
+
**Debug:**
|
|
109
|
+
```typescript
|
|
110
|
+
// Add defensive checks
|
|
111
|
+
const value = result?.property?.nested ?? defaultValue;
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
**Common pattern:** Type definition doesn't match actual usage
|
|
115
|
+
- Check `src/types.ts` for correct property names
|
|
116
|
+
- Grep for usages of old property names
|
|
117
|
+
|
|
118
|
+
## Debug Mode
|
|
119
|
+
|
|
120
|
+
Enable verbose logging:
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
# CLI
|
|
124
|
+
pnpm cba analyze . -v
|
|
125
|
+
|
|
126
|
+
# Programmatic
|
|
127
|
+
logger.setVerbose(true);
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
This shows:
|
|
131
|
+
- Surface analysis progress
|
|
132
|
+
- Structural batch progress
|
|
133
|
+
- Semantic analysis calls
|
|
134
|
+
- Timing information
|
|
135
|
+
|
|
136
|
+
## Log Categories
|
|
137
|
+
|
|
138
|
+
The logger uses categories for filtering:
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
logger.surface("message"); // Surface layer
|
|
142
|
+
logger.structural("message"); // Structural layer
|
|
143
|
+
logger.semantic("message"); // Semantic layer
|
|
144
|
+
logger.orchestrator("message"); // Orchestration
|
|
145
|
+
logger.error("category", "message"); // Errors
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Testing Individual Layers
|
|
149
|
+
|
|
150
|
+
### Surface Only
|
|
151
|
+
```bash
|
|
152
|
+
pnpm cba analyze . -d surface
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
### Structural Without Semantic
|
|
156
|
+
```bash
|
|
157
|
+
pnpm cba analyze . -d standard
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### With Semantic
|
|
161
|
+
```bash
|
|
162
|
+
pnpm cba analyze . -d deep -s
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
## Inspecting Cache
|
|
166
|
+
|
|
167
|
+
Analysis results are cached for `expand_section`:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
// In orchestrator.ts
|
|
171
|
+
import { analysisCache } from "./cache.js";
|
|
172
|
+
|
|
173
|
+
// Check cache
|
|
174
|
+
const cached = analysisCache.getByAnalysisId(analysisId);
|
|
175
|
+
console.log("Cached result:", cached);
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Gemini Retry Logic
|
|
179
|
+
|
|
180
|
+
The Gemini client in `src/core/gemini.ts` has retry logic:
|
|
181
|
+
|
|
182
|
+
```typescript
|
|
183
|
+
// Check retry configuration
|
|
184
|
+
const MAX_RETRIES = 3;
|
|
185
|
+
const RETRY_DELAY = 1000;
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
If retries fail, check:
|
|
189
|
+
- API quotas
|
|
190
|
+
- Request payload size
|
|
191
|
+
- Network connectivity
|
|
192
|
+
|
|
193
|
+
## Performance Profiling
|
|
194
|
+
|
|
195
|
+
For slow analyses:
|
|
196
|
+
|
|
197
|
+
```bash
|
|
198
|
+
# Time the analysis
|
|
199
|
+
time pnpm cba analyze . -d standard -q
|
|
200
|
+
|
|
201
|
+
# Profile with Node
|
|
202
|
+
node --prof dist/cli/index.js analyze .
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
## Checklist for Issues
|
|
206
|
+
|
|
207
|
+
- [ ] `pnpm build` succeeds
|
|
208
|
+
- [ ] `pnpm cba capabilities` returns JSON
|
|
209
|
+
- [ ] Surface analysis works (`-d surface`)
|
|
210
|
+
- [ ] Standard analysis works (`-d standard`)
|
|
211
|
+
- [ ] Semantic analysis works (if API key set)
|
|
212
|
+
- [ ] Verbose mode shows progress (`-v`)
|
|
213
|
+
- [ ] No TypeScript errors (`pnpm tsc --noEmit`)
|