mason-context 0.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/README.md +155 -0
- package/dist/bin/mason-mcp.js +1206 -0
- package/dist/bin/mason-mcp.js.map +1 -0
- package/dist/bin/mason.js +2024 -0
- package/dist/bin/mason.js.map +1 -0
- package/dist/src/cli.js +2023 -0
- package/dist/src/cli.js.map +1 -0
- package/package.json +44 -0
package/README.md
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
# Mason
|
|
2
|
+
|
|
3
|
+
A context engineering tool that helps LLMs understand your codebase. Mason handles the expensive parts — aggregating git history, selecting architecturally important files, mapping test coverage, and persisting project knowledge across sessions — so the LLM can focus on interpretation.
|
|
4
|
+
|
|
5
|
+
Works as an **MCP server** (for Claude Code, Cursor, etc.) or as a **standalone CLI** with any LLM provider.
|
|
6
|
+
|
|
7
|
+
## Quick start
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx mason-ai setup # registers Mason with Claude Code
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Restart Claude Code, then ask: "use mason to analyze this project and generate a CLAUDE.md."
|
|
14
|
+
|
|
15
|
+
## Install
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install -g mason-ai
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
### As an MCP server (recommended)
|
|
24
|
+
|
|
25
|
+
One-command setup for Claude Code:
|
|
26
|
+
|
|
27
|
+
```bash
|
|
28
|
+
mason setup # registers with Claude Code (user scope)
|
|
29
|
+
mason setup --scope project # project-scoped instead
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Or manually:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
claude mcp add mason -- npx mason-ai mcp
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
Then ask Claude to generate a CLAUDE.md — it will call Mason's tools automatically.
|
|
39
|
+
|
|
40
|
+
Mason exposes 9 tools via MCP:
|
|
41
|
+
|
|
42
|
+
| Tool | What it does |
|
|
43
|
+
|---|---|
|
|
44
|
+
| `full_analysis` | All-in-one: git stats + project structure + code samples + test map + snapshot |
|
|
45
|
+
| `get_snapshot` | Load persistent project snapshot (auto-detects staleness) |
|
|
46
|
+
| `save_snapshot` | Save file summaries for future sessions (no API key needed) |
|
|
47
|
+
| `configure_project` | Customize sampling — add patterns, always-include files, ignore paths |
|
|
48
|
+
| `analyze_project` | Git history stats (commit patterns, stale dirs, hot files) |
|
|
49
|
+
| `get_code_samples` | Smart file previews — config, entry points, architectural patterns, tests |
|
|
50
|
+
| `get_file_content` | Read any file in full (drill-down after previewing) |
|
|
51
|
+
| `get_project_structure` | Directory tree with file counts and extension breakdown |
|
|
52
|
+
| `get_test_map` | Map test files to source files by name matching |
|
|
53
|
+
|
|
54
|
+
### Persistent snapshots
|
|
55
|
+
|
|
56
|
+
Mason persists its understanding of your project across conversations, saving thousands of tokens per session.
|
|
57
|
+
|
|
58
|
+
**Via MCP (no API key needed):**
|
|
59
|
+
|
|
60
|
+
Ask your AI assistant to "create a mason snapshot for this project." It will analyze the codebase, summarize key files, and call `save_snapshot` to persist. Next session, it loads the snapshot via `get_snapshot` instead of re-reading everything. If the snapshot is stale (files changed since last update), Mason tells the LLM exactly which files to re-read.
|
|
61
|
+
|
|
62
|
+
**Via CLI (requires LLM provider):**
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
mason set-llm gemini AIza-xxx # configure a provider
|
|
66
|
+
mason snapshot ~/my-project # generate snapshot
|
|
67
|
+
mason snapshot --install-hook # auto-update on every commit
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### As a standalone CLI
|
|
71
|
+
|
|
72
|
+
Configure an LLM provider once:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
mason set-llm claude sk-ant-xxx # Anthropic
|
|
76
|
+
mason set-llm gemini AIza-xxx # Google (free tier available)
|
|
77
|
+
mason set-llm openai sk-xxx # OpenAI
|
|
78
|
+
mason set-llm ollama # Local, no API key needed
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
Then generate:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
mason generate # current directory
|
|
85
|
+
mason generate ~/my-project # specific directory
|
|
86
|
+
mason generate --model claude-haiku-4-5-20251001 # override model
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Just analyze (no LLM needed)
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
mason analyze # print git history findings
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
## How it works
|
|
96
|
+
|
|
97
|
+
Mason's philosophy: **the LLM is smart, Mason is fast.** Instead of trying to understand your code (badly, with regex), Mason does what LLMs can't do cheaply:
|
|
98
|
+
|
|
99
|
+
1. **Aggregate stats** across hundreds of commits — stale directories, hot files, commit conventions
|
|
100
|
+
2. **Select the right files** — architecturally important files the LLM should read, based on naming patterns (ViewModel, Repository, Service, Module, UseCase, etc.)
|
|
101
|
+
3. **Pair interfaces with implementations** — surfaces both `WeatherRepository.kt` and `WeatherRepositoryImpl.kt`
|
|
102
|
+
4. **Include module build files** — so the LLM can infer the dependency graph itself
|
|
103
|
+
5. **Map tests to source** — structural test coverage analysis
|
|
104
|
+
6. **Persist knowledge** — snapshot summaries survive across conversations, eliminating cold-start token waste
|
|
105
|
+
|
|
106
|
+
The LLM does all the interpretation — identifying conventions, understanding patterns, writing rules. Mason just makes sure it sees the right files and remembers what it learned.
|
|
107
|
+
|
|
108
|
+
## Smart file sampling
|
|
109
|
+
|
|
110
|
+
Mason doesn't dump your whole repo. It picks ~25 files across these categories:
|
|
111
|
+
|
|
112
|
+
- **Config files** — build configs, linter configs, version catalogs
|
|
113
|
+
- **Module build files** — subdirectory build files that reveal dependency graphs
|
|
114
|
+
- **Entry points** — main files, app entry points
|
|
115
|
+
- **Hot files** — most frequently changed in the last 3 months (from git)
|
|
116
|
+
- **Architectural files** — ViewModels, Repositories, Services, DI Modules, UseCases, Mappers, Controllers, Middleware
|
|
117
|
+
- **Both interfaces and implementations** — `*Repository.*` and `*RepositoryImpl.*`
|
|
118
|
+
- **Test examples** — diverse across languages (JVM, Swift, Python, Go, etc.)
|
|
119
|
+
- **Directory representatives** — one source file per top-level directory for breadth
|
|
120
|
+
|
|
121
|
+
All files are returned as previews (~60 lines) with metadata. The LLM can request full content of any file it wants to dig into.
|
|
122
|
+
|
|
123
|
+
### Custom patterns
|
|
124
|
+
|
|
125
|
+
Mason's built-in patterns won't catch everything. If your project uses different naming conventions (e.g., `*Gateway*` instead of `*Repository*`, `*Bloc*` instead of `*ViewModel*`), configure it per-project:
|
|
126
|
+
|
|
127
|
+
```json
|
|
128
|
+
// .mason/config.json
|
|
129
|
+
{
|
|
130
|
+
"patterns": ["**/*Gateway.*", "**/*Bloc.*", "**/*Cubit.*"],
|
|
131
|
+
"alwaysInclude": ["src/core/config.ts", "lib/injection.dart"],
|
|
132
|
+
"ignore": ["**/fixtures/**", "**/mocks/**"]
|
|
133
|
+
}
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
Or let the LLM configure it via the `configure_project` MCP tool when it notices the sampler missed important files.
|
|
137
|
+
|
|
138
|
+
## Language support
|
|
139
|
+
|
|
140
|
+
Mason is completely language-agnostic. It works with any project that has source files and a git history:
|
|
141
|
+
|
|
142
|
+
- TypeScript/JavaScript (React, Node, etc.)
|
|
143
|
+
- Kotlin (Android, KMP, server)
|
|
144
|
+
- Java (Spring, Android)
|
|
145
|
+
- Python (Django, FastAPI, etc.)
|
|
146
|
+
- Go
|
|
147
|
+
- Rust
|
|
148
|
+
- Swift (iOS, SwiftUI)
|
|
149
|
+
- Ruby, C#, C++, Dart, and more
|
|
150
|
+
|
|
151
|
+
No language-specific parsing — the architectural file selection works by naming conventions that are common across ecosystems.
|
|
152
|
+
|
|
153
|
+
## License
|
|
154
|
+
|
|
155
|
+
MIT
|