@abdulmunimjemal/codescope 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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Abdulmunim Jemal
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 ADDED
@@ -0,0 +1,153 @@
1
+ # codescope
2
+
3
+ > Local-first codebase knowledge-graph MCP server. Parses your repo into a symbol
4
+ > graph and serves it to AI coding agents so they stop wasting tokens re-scanning
5
+ > files. **Watch-first:** the graph stays fresh as you type.
6
+
7
+ Coding agents (Claude Code, Cursor, Codex, …) burn tokens and tool calls
8
+ re-discovering your codebase — `grep` for a name, `read` the whole file, `grep`
9
+ again for the callers, `read` those files too. codescope indexes the repo once
10
+ into a local SQLite graph and answers "where is `X`, what calls it, what's in
11
+ this file" in a handful of tokens and a single tool call — then keeps the graph
12
+ current by re-indexing each file the instant you save it.
13
+
14
+ 100% local. No API keys, no network, no telemetry.
15
+
16
+ ## Why not just grep?
17
+
18
+ `grep` finds *text*; codescope understands *structure*. It knows that `run` is a
19
+ method on `Service`, that `loadConfig` is called from three places, and that a
20
+ bare `parse()` call is a different thing from `obj.parse()`. It returns
21
+ `file:line` + signatures, not raw matches — and it returns a bounded **call
22
+ neighbourhood** (callers + callees, a few hops out) so an agent gets the relevant
23
+ slice of the codebase for a change without opening a dozen files.
24
+
25
+ See [BENCHMARKS.md](./BENCHMARKS.md): on a 2,500-file repo, codescope answers a
26
+ navigation query in **~70–98% fewer tokens** than reading the file, and refreshes
27
+ a changed file in **~0.5 ms** — roughly **3,000× cheaper than a full re-index**.
28
+
29
+ ## How it compares to codegraph
30
+
31
+ If you know [codegraph](https://github.com/colbymchenry/codegraph) (~35k★): it's
32
+ the mature, feature-rich option — 20+ languages, impact/test-affected analysis, a
33
+ task-context builder, agent auto-install — and it already does incremental
34
+ indexing and file-watching. **codescope doesn't try to out-feature it.** In a
35
+ measured head-to-head ([BENCHMARKS.md](./BENCHMARKS.md)) codescope's edge is being
36
+ **leaner**: ~3× smaller index DB and faster pure indexing on the same repo, a
37
+ ~1k-LOC auditable codebase, and zero-config `npx codescope mcp .`. Pick codescope
38
+ if you want something small, fast, and easy to read; pick codegraph if you want
39
+ the deepest feature set and widest language coverage.
40
+
41
+ ## Install
42
+
43
+ ```bash
44
+ npx @abdulmunimjemal/codescope mcp . # zero-install, or:
45
+ npm i -g @abdulmunimjemal/codescope # then the `codescope` command is on your PATH
46
+ ```
47
+
48
+ Requires Node ≥ 18. (The npm package is scoped because the bare name `codescope`
49
+ collides with an existing package; the installed command is still `codescope`.)
50
+
51
+ ## Quick start
52
+
53
+ Point your agent at codescope as an MCP server. It indexes the repo, starts
54
+ watching for changes, and serves the graph over stdio:
55
+
56
+ ```bash
57
+ codescope mcp /path/to/your/repo
58
+ ```
59
+
60
+ **Claude Code** (`.mcp.json` or `claude mcp add`):
61
+
62
+ ```json
63
+ {
64
+ "mcpServers": {
65
+ "codescope": { "command": "npx", "args": ["-y", "@abdulmunimjemal/codescope", "mcp", "."] }
66
+ }
67
+ }
68
+ ```
69
+
70
+ **Cursor / Codex / any MCP client:** use the same command —
71
+ `npx -y @abdulmunimjemal/codescope mcp .` over stdio.
72
+
73
+ You can also drive it straight from the terminal:
74
+
75
+ ```bash
76
+ codescope index . # build the graph, print stats
77
+ codescope search useState # fuzzy symbol search
78
+ codescope get GraphStore # jump to a definition
79
+ codescope callers parseSource # who calls this
80
+ codescope neighborhood handleRequest --depth 3
81
+ codescope watch . # keep the graph fresh, log updates
82
+ ```
83
+
84
+ ## MCP tools
85
+
86
+ | tool | what it answers |
87
+ |------|-----------------|
88
+ | `search_symbols(query, kind?, limit?)` | fuzzy substring search over definitions — use instead of grep/glob |
89
+ | `get_symbol(name, limit?)` | jump to a definition by exact name (kind, `file:line`, signature) |
90
+ | `find_callers(name, limit?)` | who calls this function/method |
91
+ | `find_references(name, kind?, limit?)` | all calls + imports of a name |
92
+ | `file_outline(path)` | every symbol in a file, in order — a compact alternative to reading it |
93
+ | `neighborhood(name, depth?, limit?)` | the call neighbourhood (callers + callees) around a symbol, as a subgraph |
94
+ | `stats()` | counts for the indexed graph |
95
+
96
+ Tool descriptions are written *for the agent* — they nudge it to query the graph
97
+ instead of scanning files.
98
+
99
+ ## How it works
100
+
101
+ 1. **Parse.** Every supported file is parsed with [tree-sitter](https://tree-sitter.github.io)
102
+ (WASM grammars, no native build) into definitions (functions, methods,
103
+ classes, interfaces, types, enums) and references (calls, imports).
104
+ 2. **Store.** Symbols and references go into a local SQLite database with a
105
+ trigram FTS5 index for fast substring search. References are stored **by name**
106
+ and resolved to definitions lazily at query time — so changing one file never
107
+ invalidates another's data.
108
+ 3. **Resolve.** Calls are resolved **kind-aware**: a bare `foo()` resolves to a
109
+ *function* named `foo`, while `x.foo()` resolves to a *method* named `foo`.
110
+ This avoids the classic name-collision explosion (e.g. a project that happens
111
+ to define a function called `push`). Ambiguous, library-ish names are left
112
+ unresolved rather than blowing up the graph.
113
+ 4. **Watch.** A file watcher re-indexes each file on save in sub-millisecond
114
+ time. Because updates are per-file and content-hash gated, the graph is always
115
+ current and a re-scan skips everything that hasn't changed.
116
+
117
+ The index lives in `.codescope/graph.db` (add `.codescope/` to your
118
+ `.gitignore`). codescope respects your repo's `.gitignore` when indexing.
119
+
120
+ ## Languages
121
+
122
+ TypeScript, JavaScript, TSX/JSX, Python, Go, Rust, Java, Ruby, C, C++, C#, PHP.
123
+
124
+ ## Programmatic API
125
+
126
+ Everything is importable:
127
+
128
+ ```ts
129
+ import { GraphStore, Indexer, watch, parseSource } from "codescope";
130
+
131
+ const store = new GraphStore("graph.db"); // or ":memory:"
132
+ const indexer = new Indexer(store, "/repo");
133
+ await indexer.indexAll();
134
+
135
+ store.searchSymbols("config");
136
+ store.neighborhood("handleRequest", { depth: 2 });
137
+
138
+ watch(indexer, { onChange: (file, action) => console.log(action, file) });
139
+ ```
140
+
141
+ ## Limitations
142
+
143
+ - References resolve by **name + call shape**, not full type/scope analysis. It is
144
+ a fast heuristic graph, not a compiler. Cross-file import resolution is not yet
145
+ modelled.
146
+ - Rust `impl` methods are currently labelled `function` (impl blocks aren't tracked
147
+ as containers).
148
+ - Symbol extraction targets top-level and class-member definitions; deeply nested
149
+ local helpers are captured, anonymous expressions are not.
150
+
151
+ ## License
152
+
153
+ MIT © Abdulmunim Jemal
package/dist/cli.d.ts ADDED
@@ -0,0 +1 @@
1
+ #!/usr/bin/env node