mason-context 0.1.0 → 0.2.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 +70 -108
- package/dist/bin/mason-mcp.js +281 -136
- package/dist/bin/mason-mcp.js.map +1 -1
- package/dist/bin/mason.js +389 -169
- package/dist/bin/mason.js.map +1 -1
- package/dist/src/cli.js +389 -169
- package/dist/src/cli.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,154 +1,116 @@
|
|
|
1
|
-
# Mason
|
|
1
|
+
# Mason – the context builder for LLMs 👷
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
Mason gives LLMs a persistent map of your codebase so they stop exploring from scratch every session.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**The problem:** Every time an LLM starts a new conversation about your code, it greps, reads files, and pieces together the architecture — burning tokens on context it already understood yesterday. On a 164-file project, answering "what features does this app have?" requires reading 8+ files across multiple tool calls.
|
|
6
6
|
|
|
7
|
-
|
|
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."
|
|
7
|
+
**Mason's fix:** A concept map that persists across sessions. One tool call returns a feature-to-file lookup table — the LLM knows exactly where to look, without exploring.
|
|
14
8
|
|
|
15
|
-
|
|
9
|
+
**Measured result** ([deepeval](https://github.com/confident-ai/deepeval), Claude Sonnet, 164-file KMP project):
|
|
16
10
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
| Question | With Mason | Without Mason | Token saving |
|
|
12
|
+
|---|---|---|---|
|
|
13
|
+
| List all features | 10,258 tok | 31,346 tok | **67%** |
|
|
14
|
+
| Trace data flow | 12,010 tok | 15,258 tok | **21%** |
|
|
15
|
+
| Compare platforms | 10,897 tok | 19,353 tok | **44%** |
|
|
16
|
+
| Onboarding flow | 10,271 tok | 11,432 tok | **10%** |
|
|
17
|
+
| **Average** | | | **36%** |
|
|
22
18
|
|
|
23
|
-
|
|
19
|
+
Same answer quality (0.9/1.0 on all tests, both paths). Reproduce: [bench/](bench/).
|
|
24
20
|
|
|
25
|
-
|
|
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:
|
|
21
|
+
## Quick start
|
|
33
22
|
|
|
34
23
|
```bash
|
|
35
|
-
claude mcp add mason -- npx mason-
|
|
24
|
+
claude mcp add mason --scope user -- npx mason-context mcp
|
|
36
25
|
```
|
|
37
26
|
|
|
38
|
-
|
|
27
|
+
Restart Claude Code, then ask: *"use mason to analyze this project and create a snapshot."*
|
|
39
28
|
|
|
40
|
-
Mason
|
|
29
|
+
That's it — Mason will analyze your codebase and create a concept map. Next session, it loads the map instead of re-exploring everything.
|
|
41
30
|
|
|
42
|
-
|
|
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):**
|
|
31
|
+
## How it works
|
|
59
32
|
|
|
60
|
-
|
|
33
|
+
### Concept map
|
|
61
34
|
|
|
62
|
-
|
|
35
|
+
Mason's core feature. It persists a feature-to-file map in `.mason/snapshot.json` that survives across conversations. When the LLM needs to understand your project, it reads this map instead of grepping through your entire codebase:
|
|
63
36
|
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
37
|
+
```json
|
|
38
|
+
{
|
|
39
|
+
"features": {
|
|
40
|
+
"home screen": {
|
|
41
|
+
"files": ["HomeScreen.kt", "HomeViewModel.kt", "GetWeatherDataUseCase.kt"]
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
"flows": {
|
|
45
|
+
"weather fetch": {
|
|
46
|
+
"chain": ["HomeViewModel.kt", "WeatherRepositoryImpl.kt", "WeatherServiceImpl.kt"]
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
68
50
|
```
|
|
69
51
|
|
|
70
|
-
|
|
52
|
+
The map is generated by the LLM itself — Mason provides the analysis tools, and the LLM interprets your code to decide what the features and flows are. This means the map captures architectural understanding, not just file listings.
|
|
71
53
|
|
|
72
|
-
|
|
54
|
+
Create one by asking your AI assistant to *"create a mason snapshot"*, or via CLI:
|
|
73
55
|
|
|
74
56
|
```bash
|
|
75
|
-
mason set-llm
|
|
76
|
-
mason
|
|
77
|
-
mason
|
|
78
|
-
mason set-llm ollama # Local, no API key needed
|
|
57
|
+
mason set-llm gemini # configure a provider (no API key needed)
|
|
58
|
+
mason snapshot ~/my-project # generate concept map
|
|
59
|
+
mason snapshot --install-hook # auto-update on every commit
|
|
79
60
|
```
|
|
80
61
|
|
|
81
|
-
|
|
62
|
+
### Change impact analysis
|
|
82
63
|
|
|
83
|
-
|
|
84
|
-
mason generate # current directory
|
|
85
|
-
mason generate ~/my-project # specific directory
|
|
86
|
-
mason generate --model claude-haiku-4-5-20251001 # override model
|
|
87
|
-
```
|
|
64
|
+
Before editing a file, Mason can tell you what else might be affected. It combines three signals that would each require multiple tool calls to gather manually:
|
|
88
65
|
|
|
89
|
-
|
|
66
|
+
- **Co-change history** — files that historically change together in git commits
|
|
67
|
+
- **References** — files that import or mention the target by name
|
|
68
|
+
- **Related tests** — test files paired to the target by naming convention
|
|
90
69
|
|
|
91
70
|
```bash
|
|
92
|
-
mason
|
|
71
|
+
mason impact WeatherRepository.kt -d ~/my-project
|
|
93
72
|
```
|
|
94
73
|
|
|
95
|
-
|
|
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:
|
|
74
|
+
Also available as the `get_impact` MCP tool — ask your assistant *"what would be affected if I changed WeatherRepository?"*
|
|
98
75
|
|
|
99
|
-
|
|
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
|
|
76
|
+
### Git history analysis
|
|
105
77
|
|
|
106
|
-
|
|
78
|
+
Mason aggregates hundreds of commits into actionable stats: which files change most often (hot files you should be careful with), which directories haven't been touched in months (potentially stale code), and what commit conventions the team follows. This is the kind of analysis that would take dozens of `git log` calls to compute manually.
|
|
107
79
|
|
|
108
|
-
|
|
80
|
+
```bash
|
|
81
|
+
mason analyze ~/my-project
|
|
82
|
+
```
|
|
109
83
|
|
|
110
|
-
|
|
84
|
+
## MCP tools
|
|
111
85
|
|
|
112
|
-
|
|
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
|
|
86
|
+
Mason exposes 6 tools via the Model Context Protocol. Any MCP-compatible client (Claude Code, Cursor, etc.) can use them:
|
|
120
87
|
|
|
121
|
-
|
|
88
|
+
| Tool | What it does |
|
|
89
|
+
|---|---|
|
|
90
|
+
| `get_snapshot` | Load the concept map — maps features/flows to files |
|
|
91
|
+
| `save_snapshot` | Persist the concept map for future sessions |
|
|
92
|
+
| `get_impact` | Change impact: co-change history, references, related tests |
|
|
93
|
+
| `analyze_project` | Git history: commit patterns, hot files, stale dirs |
|
|
94
|
+
| `full_analysis` | All-in-one first visit: git stats + structure + code samples + test map |
|
|
95
|
+
| `get_code_samples` | Smart file previews selected by architectural role |
|
|
122
96
|
|
|
123
|
-
|
|
97
|
+
## CLI usage
|
|
124
98
|
|
|
125
|
-
Mason
|
|
99
|
+
Mason also works as a standalone CLI for generating CLAUDE.md files and running analysis without an MCP client. Configure an LLM provider once, then use any command:
|
|
126
100
|
|
|
127
|
-
```
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}
|
|
101
|
+
```bash
|
|
102
|
+
mason set-llm claude|gemini|ollama|openai # configure provider
|
|
103
|
+
mason generate # analyze codebase + LLM -> CLAUDE.md
|
|
104
|
+
mason analyze # git stats only (no LLM needed)
|
|
105
|
+
mason impact File.kt # change impact analysis
|
|
106
|
+
mason snapshot # create/update concept map
|
|
134
107
|
```
|
|
135
108
|
|
|
136
|
-
|
|
109
|
+
Most providers work without an API key — `claude`, `gemini`, and `ollama` all use their respective CLIs directly.
|
|
137
110
|
|
|
138
111
|
## Language support
|
|
139
112
|
|
|
140
|
-
Mason is completely language-agnostic. It works with any project that has source files and a git
|
|
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.
|
|
113
|
+
Mason is completely language-agnostic. It uses file naming patterns and git history rather than language-specific parsing, so it works with any project that has source files and a git repository — TypeScript, Kotlin, Python, Go, Rust, Swift, Java, C#, Dart, and more.
|
|
152
114
|
|
|
153
115
|
## License
|
|
154
116
|
|