codebase-analyzer-mcp 2.0.4 → 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/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "codebase-analyzer-mcp",
3
- "version": "2.0.4",
3
+ "version": "2.1.0",
4
4
  "description": "Multi-layer codebase analysis with Gemini AI. MCP server + Claude plugin with progressive disclosure.",
5
5
  "type": "module",
6
6
  "main": "dist/mcp/server.js",
7
+ "packageManager": "bun@1.3.8",
7
8
  "bin": {
8
9
  "cba": "dist/cli/index.js",
9
10
  "codebase-analyzer": "dist/cli/index.js"
@@ -19,19 +20,15 @@
19
20
  "AGENTS.md"
20
21
  ],
21
22
  "scripts": {
22
- "build": "bun run build:js",
23
- "build:js": "bun build src/mcp/server.ts --outfile dist/mcp/server.js --target node && bun build src/cli/index.ts --outfile dist/cli/index.js --target node && node -e \"const fs=require('fs');const c=fs.readFileSync('dist/cli/index.js','utf8');fs.writeFileSync('dist/cli/index.js','#!/usr/bin/env node\\n'+c)\"",
23
+ "build": "bun scripts/build.ts",
24
24
  "dev": "bun --watch src/cli/index.ts",
25
25
  "start": "bun dist/mcp/server.js",
26
26
  "typecheck": "tsc --noEmit",
27
27
  "test": "bun test",
28
28
  "cli": "bun src/cli/index.ts",
29
- "cba": "bun src/cli/index.ts",
30
- "version:sync": "bun scripts/sync-version.ts",
31
- "release": "npm version patch && bun run version:sync",
32
- "release:minor": "npm version minor && bun run version:sync",
33
- "release:major": "npm version major && bun run version:sync",
34
- "prepublishOnly": "bun run version:sync && bun run build:js"
29
+ "version": "bun scripts/sync-version.ts && git add .",
30
+ "postversion": "git push --follow-tags",
31
+ "prepublishOnly": "bun run build"
35
32
  },
36
33
  "repository": {
37
34
  "type": "git",
@@ -1,128 +1,61 @@
1
1
  ---
2
- name: codebase-analysis
3
- description: This skill teaches how to effectively analyze codebases using the codebase-analyzer MCP tools. Use when exploring new repositories, understanding architecture, detecting patterns, or tracing data flow.
2
+ name: cba:codebase-analysis
3
+ description: How to analyze codebases using the codebase-analyzer MCP tools. Use when exploring repositories, understanding architecture, or answering questions about code.
4
4
  ---
5
5
 
6
6
  # Codebase Analysis
7
7
 
8
8
  ## Quick Start
9
9
 
10
- Analyze any codebase with progressive disclosure:
11
-
12
10
  ```
13
11
  mcp__codebase-analyzer__analyze_repo(source: ".", depth: "standard")
14
12
  ```
15
13
 
16
- ## Analysis Depths
17
-
18
- | Depth | Speed | Cost | Use When |
19
- |-------|-------|------|----------|
20
- | `surface` | Fast | Free | Quick overview, file structure |
21
- | `standard` | Medium | Low | Understanding architecture, symbols |
22
- | `deep` | Slow | High | Full semantic analysis with AI |
23
-
24
- **Rule of thumb:** Start with surface, upgrade if needed.
25
-
26
- ## Core Tools
14
+ ## Primary Tools
27
15
 
28
- ### 1. Analyze Repository
16
+ ### analyze_repo Understand a codebase
29
17
 
30
18
  ```javascript
31
19
  mcp__codebase-analyzer__analyze_repo({
32
- source: ".", // Local path or GitHub URL
33
- depth: "standard", // surface | standard | deep
34
- focus: ["src/api"], // Optional: focus areas
35
- exclude: ["node_modules"], // Optional: exclude patterns
36
- tokenBudget: 800000, // Optional: max tokens
37
- includeSemantics: false // Optional: enable AI analysis
20
+ source: ".", // Local path or GitHub URL
21
+ depth: "standard", // surface (fast/free) | standard (balanced) | deep (AI-powered)
22
+ focus: ["src/api"], // Optional: limit to specific paths
38
23
  })
39
24
  ```
40
25
 
41
- **Returns:**
42
- - `repositoryMap`: Files, languages, structure
43
- - `summary`: Architecture type, patterns, complexity
44
- - `sections`: Expandable areas for drill-down
45
- - `forAgent`: Quick summary and next steps
26
+ Returns `analysisId`, repository map, architecture summary, and expandable sections.
46
27
 
47
- ### 2. Expand Section
48
-
49
- After analysis, drill into specific sections:
28
+ ### query_repo Ask questions about code
50
29
 
51
30
  ```javascript
52
- mcp__codebase-analyzer__expand_section({
53
- analysisId: "analysis_xxx", // From analyze_repo result
54
- sectionId: "module_src_api", // Section ID to expand
55
- depth: "detail" // detail | full
56
- })
57
- ```
58
-
59
- ### 3. Find Patterns
60
-
61
- Detect design and architecture patterns:
62
-
63
- ```javascript
64
- mcp__codebase-analyzer__find_patterns({
31
+ mcp__codebase-analyzer__query_repo({
65
32
  source: ".",
66
- patternTypes: ["singleton", "factory", "repository"] // Optional filter
33
+ question: "how is authentication handled?"
67
34
  })
68
35
  ```
69
36
 
70
- **Available patterns:** singleton, factory, observer, strategy, decorator, adapter, facade, repository, dependency-injection, event-driven, pub-sub, middleware, mvc, mvvm, clean-architecture, hexagonal, cqrs, saga
71
-
72
- ### 4. Trace Dataflow
37
+ Returns an answer with relevant files, confidence level, and follow-up suggestions. Reuses cached analysis for speed. Best with `GEMINI_API_KEY` set; falls back to keyword matching without it.
73
38
 
74
- Follow data through the system:
39
+ ## Example Workflow
75
40
 
76
41
  ```javascript
77
- mcp__codebase-analyzer__trace_dataflow({
78
- source: ".",
79
- from: "user login", // Entry point
80
- to: "database" // Optional destination
81
- })
82
- ```
42
+ // 1. Get the big picture
43
+ const analysis = analyze_repo({ source: ".", depth: "surface" });
83
44
 
84
- ### 5. Get Capabilities
45
+ // 2. Ask a specific question (reuses the cached analysis)
46
+ const answer = query_repo({ source: ".", question: "where is the API defined?" });
85
47
 
86
- Check what's available:
87
-
88
- ```javascript
89
- mcp__codebase-analyzer__get_analysis_capabilities()
48
+ // 3. Done — answer includes relevant files and suggested follow-ups
90
49
  ```
91
50
 
92
- ## Workflow Patterns
93
-
94
- ### New Codebase Orientation
95
-
96
- 1. Run surface analysis
97
- 2. Review repository map and entry points
98
- 3. Expand interesting modules
99
- 4. Run pattern detection if architecture unclear
100
-
101
- ### Security Review
102
-
103
- 1. Trace dataflow from external inputs
104
- 2. Check for anti-patterns
105
- 3. Map trust boundaries
106
-
107
- ### Understanding Legacy Code
108
-
109
- 1. Deep analysis with semantics
110
- 2. Pattern detection for architecture
111
- 3. Expand each major module
112
-
113
- ## Guidelines
114
-
115
- **DO:**
116
- - Start cheap (surface), escalate if needed
117
- - Use `focus` to limit scope for large repos
118
- - Check `expansionCost` before expanding sections
119
- - Use `forAgent.suggestedNextSteps`
120
-
121
- **DON'T:**
122
- - Run deep analysis on first request
123
- - Ignore token budget warnings
124
- - Expand all sections at once
51
+ ## Power User Tools
125
52
 
126
- ## References
53
+ These additional tools are available for advanced use cases. See [references/api-reference.md](./references/api-reference.md) for full documentation.
127
54
 
128
- For detailed API documentation, see [references/api-reference.md](./references/api-reference.md).
55
+ | Tool | What it does |
56
+ |------|-------------|
57
+ | `expand_section` | Drill into a specific section from `analyze_repo` results |
58
+ | `read_files` | Read source files using an `analysisId` (no re-clone needed) |
59
+ | `find_patterns` | Detect design patterns (singleton, factory, etc.) and anti-patterns |
60
+ | `trace_dataflow` | Trace data flow from an entry point through the system |
61
+ | `get_analysis_capabilities` | List supported languages, depths, and available tools |
@@ -21,7 +21,7 @@ Full architectural analysis with progressive disclosure.
21
21
 
22
22
  ```typescript
23
23
  {
24
- analysisId: string; // Use for expand_section
24
+ analysisId: string; // Use for expand_section, read_files
25
25
  version: 2;
26
26
  timestamp: string;
27
27
  source: string;
@@ -177,6 +177,73 @@ Trace data flow through the system.
177
177
  }
178
178
  ```
179
179
 
180
+ ## read_files
181
+
182
+ Read specific files from a previously analyzed repository. Uses the cached clone so you don't need to re-analyze or re-clone.
183
+
184
+ ### Parameters
185
+
186
+ | Parameter | Type | Required | Default | Description |
187
+ |-----------|------|----------|---------|-------------|
188
+ | `analysisId` | string | Yes | - | From analyze_repo or query_repo result |
189
+ | `paths` | string[] | Yes | - | Relative file paths (min 1, max 20) |
190
+ | `maxLines` | number | No | 500 | Max lines per file (max 2000) |
191
+
192
+ ### Response
193
+
194
+ ```typescript
195
+ {
196
+ analysisId: string;
197
+ files: Array<{
198
+ path: string;
199
+ content?: string; // File content (if readable)
200
+ lineCount?: number; // Total lines in file
201
+ truncated?: boolean; // True if content was truncated
202
+ error?: string; // Error message (if not readable)
203
+ }>;
204
+ }
205
+ ```
206
+
207
+ ### Notes
208
+
209
+ - Paths must be relative to the repository root
210
+ - Path traversal (../) is blocked for security
211
+ - Works with both local repos and GitHub clones
212
+ - Cache expires after 1 hour — re-run analyze_repo or query_repo if expired
213
+
214
+ ## query_repo
215
+
216
+ Ask a question about a codebase and get an AI-powered answer with relevant file references.
217
+
218
+ ### Parameters
219
+
220
+ | Parameter | Type | Required | Description |
221
+ |-----------|------|----------|-------------|
222
+ | `source` | string | Yes | Local path or GitHub URL |
223
+ | `question` | string | Yes | Question about the codebase |
224
+
225
+ ### Response
226
+
227
+ ```typescript
228
+ {
229
+ answer: string; // Detailed answer referencing code
230
+ relevantFiles: Array<{
231
+ path: string; // Relative file path
232
+ reason: string; // Why this file is relevant
233
+ }>;
234
+ confidence: "high" | "medium" | "low";
235
+ analysisId: string; // Use for follow-up read_files
236
+ suggestedFollowUps: string[];
237
+ }
238
+ ```
239
+
240
+ ### Notes
241
+
242
+ - Reuses cached analysis when available (fast for repeated queries on same repo)
243
+ - With `GEMINI_API_KEY`: AI-powered answer using structural analysis + file contents
244
+ - Without `GEMINI_API_KEY`: keyword-matching fallback with pointers to relevant files
245
+ - The `analysisId` enables follow-up `read_files` calls to examine code in detail
246
+
180
247
  ## get_analysis_capabilities
181
248
 
182
249
  List available analysis options.
@@ -1,66 +0,0 @@
1
- ---
2
- name: compare
3
- description: Compare how multiple repositories approach the same problem
4
- user-invocable: true
5
- ---
6
-
7
- # Compare Repositories
8
-
9
- Compare how different codebases approach the same problem or aspect.
10
-
11
- ## Usage
12
-
13
- ```
14
- /compare <repos...> --aspect <aspect>
15
- ```
16
-
17
- **Arguments:**
18
- - `repos` - Two or more repository paths or URLs
19
-
20
- **Options:**
21
- - `--aspect <aspect>` - What to compare (required)
22
-
23
- ## Examples
24
-
25
- ```bash
26
- # Compare authentication approaches
27
- /compare ./app1 ./app2 --aspect authentication
28
-
29
- # Compare state management
30
- /compare https://github.com/user/repo1 https://github.com/user/repo2 --aspect "state management"
31
-
32
- # Compare API design
33
- /compare ./rest-api ./graphql-api --aspect "API design"
34
-
35
- # Compare error handling
36
- /compare ./project-a ./project-b ./project-c --aspect "error handling"
37
- ```
38
-
39
- ## Workflow
40
-
41
- 1. **Analyze each repo** at surface level
42
- 2. **Focus on aspect** specified
43
- 3. **Compare approaches** side by side
44
- 4. **Identify pros/cons** of each
45
- 5. **Provide recommendation**
46
-
47
- ## Implementation
48
-
49
- ```javascript
50
- const repos = args.repos;
51
- const aspect = args.aspect;
52
-
53
- // Use MCP tool directly
54
- mcp__codebase-analyzer__compare_repos({
55
- sources: repos,
56
- aspect: aspect
57
- });
58
- ```
59
-
60
- ## Output
61
-
62
- Returns comparison with:
63
- - Approach summary for each repo
64
- - Pros and cons
65
- - Key files implementing the aspect
66
- - Recommendation for best approach
@@ -1,64 +0,0 @@
1
- ---
2
- name: explore
3
- description: Quick exploration of a codebase structure
4
- user-invocable: true
5
- ---
6
-
7
- # Explore Codebase
8
-
9
- Quick, lightweight exploration of a codebase - faster than full analysis.
10
-
11
- ## Usage
12
-
13
- ```
14
- /explore [source] [question]
15
- ```
16
-
17
- **Arguments:**
18
- - `source` - Local path or GitHub URL (default: current directory)
19
- - `question` - Optional specific question about the codebase
20
-
21
- ## Examples
22
-
23
- ```bash
24
- # Quick overview of current directory
25
- /explore
26
-
27
- # Explore specific repo
28
- /explore https://github.com/user/repo
29
-
30
- # Ask specific question
31
- /explore . "where is authentication handled?"
32
-
33
- # Find specific functionality
34
- /explore "how does email sending work?"
35
- ```
36
-
37
- ## Workflow
38
-
39
- 1. **Run surface analysis** (fast, no LLM cost)
40
- 2. **Answer question** if provided
41
- 3. **Present structure** and key files
42
- 4. **Suggest areas** to explore further
43
-
44
- ## Implementation
45
-
46
- ```javascript
47
- const source = args.source || ".";
48
- const question = args.question;
49
-
50
- Task("codebase-explorer", {
51
- prompt: question
52
- ? `Explore ${source} and answer: ${question}`
53
- : `Give me a quick overview of ${source}`
54
- });
55
- ```
56
-
57
- ## Output
58
-
59
- Returns quick overview with:
60
- - Tech stack and primary language
61
- - Directory structure with purposes
62
- - Key entry points
63
- - Answer to specific question (if asked)
64
- - Suggestions for deeper exploration
@@ -1,75 +0,0 @@
1
- ---
2
- name: patterns
3
- description: Detect design and architecture patterns in a codebase
4
- user-invocable: true
5
- ---
6
-
7
- # Find Patterns
8
-
9
- Detect design patterns, architectural patterns, and anti-patterns in a codebase.
10
-
11
- ## Usage
12
-
13
- ```
14
- /patterns [source] [options]
15
- ```
16
-
17
- **Arguments:**
18
- - `source` - Local path or GitHub URL (default: current directory)
19
-
20
- **Options:**
21
- - `--types <patterns>` - Specific patterns to look for
22
- - `--anti` - Focus on anti-patterns
23
-
24
- ## Available Patterns
25
-
26
- **Design Patterns:**
27
- - singleton, factory, observer, strategy, decorator
28
- - adapter, facade, repository, dependency-injection
29
-
30
- **Architectural Patterns:**
31
- - event-driven, pub-sub, middleware, mvc, mvvm
32
- - clean-architecture, hexagonal, cqrs, saga
33
-
34
- ## Examples
35
-
36
- ```bash
37
- # Find all patterns in current directory
38
- /patterns
39
-
40
- # Look for specific patterns
41
- /patterns --types singleton,factory,repository
42
-
43
- # Find anti-patterns
44
- /patterns --anti
45
-
46
- # Analyze GitHub repo
47
- /patterns https://github.com/user/repo
48
- ```
49
-
50
- ## Workflow
51
-
52
- 1. **Parse arguments** from user input
53
- 2. **Run detection** using pattern-detective agent
54
- 3. **Present findings** with confidence levels
55
- 4. **Map locations** for each pattern
56
-
57
- ## Implementation
58
-
59
- ```javascript
60
- const source = args.source || ".";
61
- const types = args.types?.split(",");
62
- const antiPatterns = args.anti || false;
63
-
64
- Task("pattern-detective", {
65
- prompt: `Find ${antiPatterns ? "anti-patterns" : "patterns"} in ${source}${types ? ` focusing on ${types.join(", ")}` : ""}`
66
- });
67
- ```
68
-
69
- ## Output
70
-
71
- Returns pattern analysis with:
72
- - Detected patterns with confidence scores
73
- - File locations for each pattern
74
- - Anti-pattern warnings
75
- - Recommendations for improvement
package/commands/trace.md DELETED
@@ -1,65 +0,0 @@
1
- ---
2
- name: trace
3
- description: Trace data flow through a codebase
4
- user-invocable: true
5
- ---
6
-
7
- # Trace Dataflow
8
-
9
- Trace how data flows from an entry point through the system.
10
-
11
- ## Usage
12
-
13
- ```
14
- /trace <from> [options]
15
- ```
16
-
17
- **Arguments:**
18
- - `from` - Entry point (function name, file, or description)
19
-
20
- **Options:**
21
- - `--to <destination>` - Trace to specific destination
22
- - `--source <path>` - Repository path (default: current directory)
23
-
24
- ## Examples
25
-
26
- ```bash
27
- # Trace from user login
28
- /trace "user login"
29
-
30
- # Trace from specific function to database
31
- /trace processPayment --to database
32
-
33
- # Trace API endpoint
34
- /trace "POST /api/users"
35
-
36
- # Trace in specific repo
37
- /trace checkout --source ./ecommerce-app
38
- ```
39
-
40
- ## Workflow
41
-
42
- 1. **Identify entry point** from user input
43
- 2. **Run trace** using dataflow-tracer agent
44
- 3. **Map transformations** at each step
45
- 4. **Identify risks** and security concerns
46
-
47
- ## Implementation
48
-
49
- ```javascript
50
- const from = args.from;
51
- const to = args.to;
52
- const source = args.source || ".";
53
-
54
- Task("dataflow-tracer", {
55
- prompt: `Trace data flow from "${from}"${to ? ` to "${to}"` : ""} in ${source}`
56
- });
57
- ```
58
-
59
- ## Output
60
-
61
- Returns dataflow analysis with:
62
- - Step-by-step trace through the system
63
- - Data transformations at each point
64
- - Security observations
65
- - Trust boundary crossings