@grundy40/contextslice 0.0.0-stage → 0.3.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.
- package/LICENSE +21 -0
- package/README.md +104 -2
- package/bin/ctxslice-mcp.mjs +1104 -0
- package/bin/ctxslice.mjs +745 -0
- package/package.json +38 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ContextSlice Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,105 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @grundy40/contextslice
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> **Zero-dependency multi-language AST code slicer & 1-Tool MCP server for AI coding agents.**
|
|
4
|
+
|
|
5
|
+
`ContextSlice` builds a lightweight local call graph of your repository, keeps **focal target functions complete**, folds direct `1-hop` / `2-hop` neighbors into **signature-only skeletons**, and drops unrelated noise — cutting token costs dramatically with **zero runtime dependencies**.
|
|
6
|
+
|
|
7
|
+
- **Zero runtime `dependencies`**: Uses only Node.js built-ins + an embedded `web-tree-sitter` WASM runtime with lazy grammar caching (`~/.contextslice/parsers/`) and automatic offline state-machine fallback.
|
|
8
|
+
- **Multi-language AST & Call Graph**: Supports TypeScript/JavaScript, Python, Go, Rust, Java, Kotlin, C#, C/C++, Swift, PHP, Ruby, SQL, and generic text files.
|
|
9
|
+
- **Smart Relevance & Quotas**: TF-IDF keyword scarcity weighting, directory quota cap (65%), CJK 2-gram + bilingual matching, and `<omitted_top_matches>` recovery hints.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Quick Usage via `npx`
|
|
14
|
+
|
|
15
|
+
### 1. Run CLI Slicer Directly
|
|
16
|
+
|
|
17
|
+
Slice the current repository in one command without installing anything permanently:
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @grundy40/contextslice "login token validation" --budget 32768
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Slice a specific repository path:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
npx @grundy40/contextslice "checkout discount" --root ./my-project --budget 16384
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Check version or CLI options:
|
|
30
|
+
|
|
31
|
+
```bash
|
|
32
|
+
npx @grundy40/contextslice --version
|
|
33
|
+
npx @grundy40/contextslice --help
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
Or install globally if you prefer short commands (`ctxslice` and `ctxslice-mcp`):
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
npm install -g @grundy40/contextslice
|
|
40
|
+
ctxslice "retry queue" --budget 32768
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
---
|
|
44
|
+
|
|
45
|
+
## Connect 1-Tool MCP to AI Coding Agents
|
|
46
|
+
|
|
47
|
+
`@grundy40/contextslice` exposes two MCP tools inside a single ultra-lean stdio server (`ctxslice-mcp`):
|
|
48
|
+
1. `get_context_slice` — Primary code-reading tool (Tree-sitter WASM / state-machine AST + True Call Graph + TF-IDF).
|
|
49
|
+
2. `expand_skeleton_cluster` — On-demand symbol expander for `<omitted_top_matches>` or folded skeleton hubs.
|
|
50
|
+
|
|
51
|
+
### Claude Code (`npx` Zero-Setup)
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
claude mcp add --scope user context-slice -- npx -y -p @grundy40/contextslice ctxslice-mcp
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
Or if installed globally (`npm i -g @grundy40/contextslice`):
|
|
58
|
+
|
|
59
|
+
```bash
|
|
60
|
+
claude mcp add --scope user context-slice -- ctxslice-mcp
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
Add to `~/.claude/CLAUDE.md` so Claude always slices first before reading raw files:
|
|
64
|
+
|
|
65
|
+
```markdown
|
|
66
|
+
When inspecting, debugging, or modifying code in any project folder, ALWAYS call the `get_context_slice` MCP tool first (passing `projectPath` and `query`) BEFORE reading raw files.
|
|
67
|
+
```
|
|
68
|
+
|
|
69
|
+
### Claude Desktop / Cursor / Windsurf (`mcpServers` JSON)
|
|
70
|
+
|
|
71
|
+
```json
|
|
72
|
+
{
|
|
73
|
+
"mcpServers": {
|
|
74
|
+
"context-slice": {
|
|
75
|
+
"command": "npx",
|
|
76
|
+
"args": ["-y", "-p", "@grundy40/contextslice", "ctxslice-mcp"]
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
### OpenCode (`~/.config/opencode/opencode.json`)
|
|
83
|
+
|
|
84
|
+
```json
|
|
85
|
+
{
|
|
86
|
+
"mcp": {
|
|
87
|
+
"context-slice": {
|
|
88
|
+
"type": "local",
|
|
89
|
+
"command": ["npx", "-y", "-p", "@grundy40/contextslice", "ctxslice-mcp"]
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
---
|
|
96
|
+
|
|
97
|
+
## Environment Variables
|
|
98
|
+
|
|
99
|
+
- `CTXSLICE_DISABLE_WASM_FETCH=1`: Skip downloading `.wasm` language parsers and run purely on the built-in zero-network state-machine AST parser.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
## License
|
|
104
|
+
|
|
105
|
+
[MIT](https://github.com/grundy40/ContextSlice/blob/main/LICENSE)
|