codeast 1.0.0 → 1.0.1

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 (2) hide show
  1. package/README.md +166 -0
  2. package/package.json +3 -2
package/README.md ADDED
@@ -0,0 +1,166 @@
1
+ # CodeAst
2
+
3
+ **MCP server for static code analysis** — Returns structured data instead of raw files to reduce context window usage by 10x.
4
+
5
+ Built with Rust (analyzer) + TypeScript (MCP wrapper).
6
+
7
+ ## Why CodeAst?
8
+
9
+ When LLMs analyze code, they typically read entire files. CodeAst extracts **only what matters**:
10
+
11
+ | Without CodeAst | With CodeAst |
12
+ |-----------------|--------------|
13
+ | Read 500 lines to find functions | Get structured list of symbols |
14
+ | Grep entire codebase for callers | Get precise caller locations |
15
+ | Manual dependency tracing | Automatic cycle detection |
16
+
17
+ ## Installation
18
+
19
+ ```bash
20
+ claude mcp add codeast npx codeast
21
+ ```
22
+
23
+ The analyzer binary is downloaded automatically on first run.
24
+
25
+ ## Tools
26
+
27
+ | Tool | Description |
28
+ |------|-------------|
29
+ | `get_symbols` | List functions, classes, types in a file |
30
+ | `get_callers` | Find all functions that call a function |
31
+ | `get_calls` | Get all functions called by a function |
32
+ | `get_imports` | Get imports (internal vs external) |
33
+ | `get_imported_by` | Find files that import a file |
34
+ | `get_complexity` | Get cyclomatic/cognitive complexity metrics |
35
+ | `get_cycles` | Detect circular dependencies |
36
+ | `get_duplicates` | Find duplicated code blocks |
37
+ | `get_file_info` | Quick file overview |
38
+ | `search_files` | Search files by glob pattern |
39
+ | `run_tests` | Run tests (auto-detects npm/cargo/pytest) |
40
+ | `status` | Check if analyzer is running |
41
+
42
+ ## Supported Languages
43
+
44
+ - JavaScript / TypeScript / JSX / TSX
45
+ - Python
46
+ - Rust
47
+ - Astro
48
+
49
+ ---
50
+
51
+ ## Contributing
52
+
53
+ This project is open source and welcomes contributions! Whether you're fixing bugs, adding features, or improving documentation, your help is appreciated.
54
+
55
+ ### Getting Started
56
+
57
+ ```bash
58
+ # Clone the repo
59
+ git clone https://github.com/YOUR_USERNAME/codeast.git
60
+ cd codeast
61
+
62
+ # Build the Rust analyzer
63
+ cd analyzer && cargo build --release
64
+
65
+ # Build and run MCP server
66
+ cd ../mcp && npm install && npm run build
67
+ node dist/mcp/server.js
68
+ ```
69
+
70
+ The MCP auto-detects the local binary in dev mode.
71
+
72
+ ### Areas for Contribution
73
+
74
+ #### Bugs to Fix
75
+
76
+ | # | Bug | Impact |
77
+ |---|-----|--------|
78
+ | 1 | `get_callers` doesn't find without module prefix (`fn` vs `module::fn`) | Usability |
79
+ | 2 | JS grammar doesn't detect exports (only TS works) | `.js` files |
80
+
81
+ #### Missing Features
82
+
83
+ | # | Feature | Description |
84
+ |---|---------|-------------|
85
+ | 1 | Function parameters | Extract params (name, type) from functions |
86
+ | 2 | Return types | Extract return type from functions |
87
+ | 3 | Class methods | `get_symbols` doesn't return methods |
88
+ | 4 | Export default | `export default function` not detected |
89
+ | 5 | Re-exports | `export { foo } from './bar'` not traced |
90
+ | 6 | Decorators | `@Controller`, `@Injectable` (NestJS, Angular) |
91
+ | 7 | JSDoc/TSDoc | Extract documentation comments |
92
+ | 8 | Async detection | Mark if a function is async |
93
+
94
+ #### MCP Improvements
95
+
96
+ | # | Tool | Improvement |
97
+ |---|------|-------------|
98
+ | 1 | `get_callers` | Fuzzy match (without module prefix) |
99
+ | 2 | `get_callers` | Add `recursive: true` param for call chain |
100
+ | 3 | `get_symbols` | Add methods for classes |
101
+ | 4 | `get_complexity` | Add maintainability index |
102
+ | 5 | `search_code` | New tool for grep with context |
103
+ | 6 | `get_dependencies` | Visualize dependency tree of a file |
104
+
105
+ #### Refactoring
106
+
107
+ | File | Complexity | Action |
108
+ |------|------------|--------|
109
+ | `symbols.rs` | 382 | Split into modules (`js.rs`, `rust.rs`, `python.rs`, `astro.rs`) |
110
+ | `analyzer.rs` | 73 | Extract `process_import` logic |
111
+ | `handlers.ts` | - | Factor out error handling |
112
+
113
+ ### New Language Support
114
+
115
+ Want to add support for a new language? Here's what you need:
116
+
117
+ 1. Add tree-sitter grammar to `analyzer/Cargo.toml`
118
+ 2. Create extraction functions in `analyzer/src/symbols.rs`
119
+ 3. Add import parsing in `analyzer/src/parser.rs`
120
+ 4. Add tests in `analyzer/tests/`
121
+
122
+ Languages we'd love to support:
123
+ - Go
124
+ - Java
125
+ - C/C++
126
+ - Ruby
127
+ - PHP
128
+
129
+ ---
130
+
131
+ ## Project Structure
132
+
133
+ ```
134
+ codeast/
135
+ ├── analyzer/ # Rust - Core analysis engine
136
+ │ ├── src/
137
+ │ │ ├── main.rs # CLI entry point
138
+ │ │ ├── analyzer.rs # Orchestration
139
+ │ │ ├── symbols.rs # AST symbol extraction
140
+ │ │ ├── parser.rs # Import extraction
141
+ │ │ ├── complexity.rs # Metrics calculation
142
+ │ │ ├── duplicates.rs # Duplicate detection
143
+ │ │ └── graph.rs # Dependency graph
144
+ │ └── Cargo.toml
145
+
146
+ ├── mcp/ # TypeScript - MCP server wrapper
147
+ │ ├── src/
148
+ │ │ ├── mcp/
149
+ │ │ │ ├── server.ts # MCP entry point
150
+ │ │ │ ├── tools.ts # Tool definitions
151
+ │ │ │ └── handlers.ts # Tool implementations
152
+ │ │ └── services/
153
+ │ │ ├── analyzer.ts # Process management
154
+ │ │ └── queries.ts # Query API
155
+ │ └── package.json
156
+
157
+ └── docs/ # Landing page
158
+ ```
159
+
160
+ ## License
161
+
162
+ MIT
163
+
164
+ ---
165
+
166
+ **Found a bug? Have an idea?** Open an issue or submit a PR!
package/package.json CHANGED
@@ -1,13 +1,14 @@
1
1
  {
2
2
  "name": "codeast",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "MCP server for code analysis - reduces context window usage by returning structured data",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "codeast": "./dist/mcp/server.js"
8
8
  },
9
9
  "files": [
10
- "dist"
10
+ "dist",
11
+ "README.md"
11
12
  ],
12
13
  "scripts": {
13
14
  "build": "tsc",