mincut-context 1.0.0 → 1.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 +134 -31
- package/dist/adapters/cli/bin.js +16 -3
- package/dist/adapters/cli/bin.js.map +1 -1
- package/dist/adapters/mcp/index.js +1 -1
- package/dist/core/communities.d.ts +17 -0
- package/dist/core/communities.d.ts.map +1 -0
- package/dist/core/communities.js +54 -0
- package/dist/core/communities.js.map +1 -0
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -0
- package/dist/core/index.js.map +1 -1
- package/dist/core/select.d.ts +11 -0
- package/dist/core/select.d.ts.map +1 -1
- package/dist/core/select.js +23 -2
- package/dist/core/select.js.map +1 -1
- package/dist/index/builder.d.ts +9 -1
- package/dist/index/builder.d.ts.map +1 -1
- package/dist/index/builder.js +33 -1
- package/dist/index/builder.js.map +1 -1
- package/dist/index/cache.d.ts +31 -0
- package/dist/index/cache.d.ts.map +1 -0
- package/dist/index/cache.js +72 -0
- package/dist/index/cache.js.map +1 -0
- package/dist/index/walker.d.ts.map +1 -1
- package/dist/index/walker.js +6 -1
- package/dist/index/walker.js.map +1 -1
- package/dist/parsers/php.d.ts +3 -0
- package/dist/parsers/php.d.ts.map +1 -0
- package/dist/parsers/php.js +186 -0
- package/dist/parsers/php.js.map +1 -0
- package/dist/parsers/vue.d.ts +17 -0
- package/dist/parsers/vue.d.ts.map +1 -0
- package/dist/parsers/vue.js +52 -0
- package/dist/parsers/vue.js.map +1 -0
- package/dist/select/pack.d.ts +11 -0
- package/dist/select/pack.d.ts.map +1 -1
- package/dist/select/pack.js +29 -4
- package/dist/select/pack.js.map +1 -1
- package/package.json +2 -1
package/README.md
CHANGED
|
@@ -3,23 +3,58 @@
|
|
|
3
3
|
# `mincut-context`
|
|
4
4
|
|
|
5
5
|
**Token-minimal context selection for AI coding agents.**
|
|
6
|
-
A symbol graph of your repo + personalized PageRank + budget-constrained min-cut — picks the smallest provably-relevant context for any task.
|
|
7
6
|
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
A symbol graph of your repo + personalized PageRank + budget-constrained min-cut
|
|
8
|
+
— picks the smallest provably-relevant context for any task.
|
|
9
|
+
|
|
10
|
+
[](https://www.npmjs.com/package/mincut-context)
|
|
11
|
+
[](https://www.npmjs.com/package/mincut-context)
|
|
12
|
+
[](https://bundlephobia.com/package/mincut-context)
|
|
13
|
+
[](./src)
|
|
14
|
+
[](./package.json)
|
|
10
15
|
[](./tests)
|
|
11
|
-
[](./package.json)
|
|
16
|
+
[](./LICENSE)
|
|
13
17
|
|
|
14
18
|
</div>
|
|
15
19
|
|
|
16
20
|
<p align="center"><img src="docs/demo.gif" alt="mcx pack demo — keyword + semantic search on a real repo" width="900" /></p>
|
|
17
21
|
|
|
22
|
+
<div align="center">
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
npm install -g mincut-context # global CLI: mcx
|
|
26
|
+
npx mincut-context pack "fix the login validation bug" --budget 4000
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
</div>
|
|
30
|
+
|
|
18
31
|
> One sentence: an agent that opens `mincut-context` first gets the minimum cohesive *region* of code its task depends on — not a grep hit, not a whole file, not the whole repo.
|
|
19
32
|
|
|
20
33
|
---
|
|
21
34
|
|
|
22
|
-
|
|
35
|
+
<details>
|
|
36
|
+
<summary><b>Table of contents</b></summary>
|
|
37
|
+
|
|
38
|
+
- [Why](#why)
|
|
39
|
+
- [The idea](#the-idea)
|
|
40
|
+
- [Install](#install)
|
|
41
|
+
- [Quick start](#quick-start)
|
|
42
|
+
- [Use it three ways](#use-it-three-ways) — [MCP server](#1-as-an-mcp-server--recommended-for-agents) · [CLI](#2-as-a-cli) · [Library](#3-as-a-library)
|
|
43
|
+
- [How it works](#how-it-works)
|
|
44
|
+
- [Real-world examples](#real-world-examples)
|
|
45
|
+
- [Languages](#languages)
|
|
46
|
+
- [CLI reference](#cli-reference)
|
|
47
|
+
- [How it compares](#how-it-compares)
|
|
48
|
+
- [Roadmap](#roadmap)
|
|
49
|
+
- [Tradeoffs (honest)](#tradeoffs-honest)
|
|
50
|
+
- [Contributing](#contributing)
|
|
51
|
+
- [License](#license)
|
|
52
|
+
|
|
53
|
+
</details>
|
|
54
|
+
|
|
55
|
+
---
|
|
56
|
+
|
|
57
|
+
## Why
|
|
23
58
|
|
|
24
59
|
AI coding agents waste your context window. Two failure modes:
|
|
25
60
|
|
|
@@ -47,16 +82,37 @@ The objective is **submodular**, so a greedy algorithm gives a `(1 - 1/e) ≈ 0.
|
|
|
47
82
|
## Install
|
|
48
83
|
|
|
49
84
|
```bash
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
85
|
+
# global CLI (recommended)
|
|
86
|
+
npm install -g mincut-context
|
|
87
|
+
|
|
88
|
+
# or per-project
|
|
89
|
+
npm install --save-dev mincut-context
|
|
90
|
+
|
|
91
|
+
# or one-shot, no install
|
|
92
|
+
npx mincut-context pack "your task" --budget 4000
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
Requires **Node ≥ 18.17**. TypeScript types ship with the package.
|
|
96
|
+
|
|
97
|
+
## Quick start
|
|
98
|
+
|
|
99
|
+
```bash
|
|
100
|
+
# 1. Index any repo once (warms the cache)
|
|
101
|
+
mcx index .
|
|
102
|
+
|
|
103
|
+
# 2. Ask for context for a task
|
|
104
|
+
mcx pack "fix the login validation bug" --budget 4000
|
|
105
|
+
|
|
106
|
+
# 3. Pipe straight into your agent
|
|
107
|
+
mcx pack "..." --format markdown > context.md
|
|
108
|
+
mcx pack "..." --format json | jq '.files[].path'
|
|
53
109
|
```
|
|
54
110
|
|
|
55
|
-
|
|
111
|
+
---
|
|
56
112
|
|
|
57
113
|
## Use it three ways
|
|
58
114
|
|
|
59
|
-
### 1. As an MCP server —
|
|
115
|
+
### 1. As an MCP server — recommended for agents
|
|
60
116
|
|
|
61
117
|
Drop into Claude Code, Codex, Cursor, or any MCP-aware client:
|
|
62
118
|
|
|
@@ -109,10 +165,26 @@ for (const f of result.files) {
|
|
|
109
165
|
// → src/auth/session.ts 0.408 483 · attached (60%)
|
|
110
166
|
```
|
|
111
167
|
|
|
168
|
+
Full TypeScript types — `pack`, `indexRepo`, `SymbolGraph`, `personalizedPageRank`, `greedySelect` are all exported.
|
|
169
|
+
|
|
112
170
|
---
|
|
113
171
|
|
|
114
172
|
## How it works
|
|
115
173
|
|
|
174
|
+
```mermaid
|
|
175
|
+
flowchart LR
|
|
176
|
+
A[Repo files] -->|tree-sitter| B[Symbol graph<br/>V: functions/classes<br/>E: imports/calls]
|
|
177
|
+
T[Task string] -->|keyword IDF| S[Seeds S ⊆ V]
|
|
178
|
+
T -->|optional: --embed| S
|
|
179
|
+
B --> R[Personalized<br/>PageRank<br/>α=0.85]
|
|
180
|
+
S --> R
|
|
181
|
+
R --> C[Greedy<br/>budget min-cut<br/>1−1/e bound]
|
|
182
|
+
B --> C
|
|
183
|
+
C --> P[Packed context<br/>files + ranges<br/>+ per-node reason]
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The five steps in pseudocode:
|
|
187
|
+
|
|
116
188
|
```text
|
|
117
189
|
pack(task, repo, budget):
|
|
118
190
|
1. graph = index(repo) # tree-sitter → symbol+edge graph
|
|
@@ -130,7 +202,7 @@ pack(task, repo, budget):
|
|
|
130
202
|
|
|
131
203
|
The "no isolated nodes" rule (`attach(v, T) > 0`) is what gives you the *cohesion guarantee* — adding a fully-detached node would strictly increase the cut without benefit, so the greedy refuses. That's why an "auth" task never drags in unrelated UI files even when budget permits.
|
|
132
204
|
|
|
133
|
-
###
|
|
205
|
+
### Semantic embeddings (optional)
|
|
134
206
|
|
|
135
207
|
Pure keyword matching misses semantic neighbors:
|
|
136
208
|
|
|
@@ -144,7 +216,8 @@ $ mcx pack "ranking and centrality algorithm" --repo . --embed --embed-weight 0.
|
|
|
144
216
|
→ src/seeds/keyword.ts 0.080 18 tok
|
|
145
217
|
```
|
|
146
218
|
|
|
147
|
-
"Centrality" never appears in any symbol name — only embeddings could find this.
|
|
219
|
+
"Centrality" never appears in any symbol name — only embeddings could find this.
|
|
220
|
+
Uses [`@xenova/transformers`](https://github.com/xenova/transformers.js) (Transformers.js + ONNX). Fully local, ~22 MB model download on first use.
|
|
148
221
|
|
|
149
222
|
---
|
|
150
223
|
|
|
@@ -172,13 +245,16 @@ That's exactly the analytics slice — no UI noise, no test fixtures, no unrelat
|
|
|
172
245
|
|---|---|---|
|
|
173
246
|
| TypeScript / JavaScript | ✅ v1.0 | `.ts .tsx .js .jsx .mjs .cjs` |
|
|
174
247
|
| Python | ✅ v1.0 | `.py .pyi`, relative imports, decorators, methods |
|
|
175
|
-
|
|
|
248
|
+
| **PHP** | ✅ **v1.2** | `.php`, namespaces, traits, `use` (incl. grouped + aliased), `$this->`, `Foo::bar()` |
|
|
249
|
+
| **Vue SFC** | ✅ **v1.2** | `.vue`, `<script>` Options API + `<script setup>` Composition API, `lang="ts"` honored |
|
|
250
|
+
| Rust, Go, Svelte, … | community welcome | tree-sitter grammar + symbol queries |
|
|
176
251
|
|
|
177
252
|
Adding a language is one parser file implementing `LanguageParser` + one line in `parseForExt`. See [`src/parsers/py.ts`](./src/parsers/py.ts) as a template.
|
|
178
253
|
|
|
179
254
|
---
|
|
180
255
|
|
|
181
|
-
|
|
256
|
+
<details>
|
|
257
|
+
<summary><b>CLI reference</b></summary>
|
|
182
258
|
|
|
183
259
|
```text
|
|
184
260
|
Usage: mcx pack [options] <task...>
|
|
@@ -198,8 +274,21 @@ Options:
|
|
|
198
274
|
--embed-weight <number> Blend 0..1 (0=keyword, 1=embedding only)
|
|
199
275
|
--embed-model <id> HF model id (default Xenova/all-MiniLM-L6-v2)
|
|
200
276
|
-i, --interactive Ink TUI for pin/exclude before output
|
|
277
|
+
--cache Use persistent parse cache (.mincut-cache/) — fast repeat runs
|
|
278
|
+
--cache-dir <path> Override cache directory (absolute path)
|
|
279
|
+
--community-boost <number> Louvain same-community boost (default 0.5, 0 = disabled)
|
|
201
280
|
```
|
|
202
281
|
|
|
282
|
+
Other commands:
|
|
283
|
+
|
|
284
|
+
```text
|
|
285
|
+
mcx index [path] warm the parse cache (no output beyond stats)
|
|
286
|
+
mcx mcp run as an MCP server over stdio
|
|
287
|
+
mcx --version print the installed version
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
</details>
|
|
291
|
+
|
|
203
292
|
---
|
|
204
293
|
|
|
205
294
|
## How it compares
|
|
@@ -210,28 +299,32 @@ Options:
|
|
|
210
299
|
| **Grep / ripgrep** | ❌ | ❌ | ❌ | yes |
|
|
211
300
|
| **Cursor/Continue RAG** | partial | ❌ | ✅ | hard |
|
|
212
301
|
| **AST/symbol graph alone** | ❌ | ✅ | ❌ | yes |
|
|
213
|
-
| **`mincut-context`** | ✅ (budget) | ✅ (graph) | ✅ (
|
|
302
|
+
| **`mincut-context`** | ✅ (budget) | ✅ (graph) | ✅ (`--embed`) | per-node `reason` |
|
|
214
303
|
|
|
215
304
|
---
|
|
216
305
|
|
|
217
306
|
## Roadmap
|
|
218
307
|
|
|
219
|
-
- [x] Core: graph + personalized PageRank + greedy min-cut
|
|
220
|
-
- [x] TS/JS parser
|
|
221
|
-
- [x] Python parser
|
|
222
|
-
- [x] CLI (plain / JSON / markdown)
|
|
223
|
-
- [x] MCP server
|
|
224
|
-
- [x] Local embeddings (`@xenova/transformers`)
|
|
225
|
-
- [x] Ink TUI
|
|
226
|
-
- [
|
|
227
|
-
- [
|
|
228
|
-
- [
|
|
229
|
-
- [
|
|
230
|
-
- [ ]
|
|
308
|
+
- [x] Core: graph + personalized PageRank + greedy min-cut **(v1.0)**
|
|
309
|
+
- [x] TS/JS parser **(v1.0)**
|
|
310
|
+
- [x] Python parser **(v1.0)**
|
|
311
|
+
- [x] CLI (plain / JSON / markdown) **(v1.0)**
|
|
312
|
+
- [x] MCP server **(v1.0)**
|
|
313
|
+
- [x] Local embeddings (`@xenova/transformers`) **(v1.0)**
|
|
314
|
+
- [x] Ink TUI **(v1.0)**
|
|
315
|
+
- [x] Persistent on-disk parse cache (incremental reindex) **(v1.1)** — 5.2× warm-run speedup
|
|
316
|
+
- [x] Louvain community boost **(v1.1)**
|
|
317
|
+
- [x] **PHP parser** **(v1.2)**
|
|
318
|
+
- [x] **Vue SFC parser** **(v1.2)**
|
|
319
|
+
- [ ] Svelte / Rust / Go parsers
|
|
320
|
+
- [ ] Sub-symbol AST-block chunking
|
|
321
|
+
- [ ] Parallel parsing (worker pool)
|
|
322
|
+
- [ ] LSP-backed type-aware call resolution
|
|
231
323
|
|
|
232
324
|
---
|
|
233
325
|
|
|
234
|
-
|
|
326
|
+
<details>
|
|
327
|
+
<summary><b>Tradeoffs (honest)</b></summary>
|
|
235
328
|
|
|
236
329
|
| What's not optimal | What we do |
|
|
237
330
|
|---|---|
|
|
@@ -241,6 +334,8 @@ Options:
|
|
|
241
334
|
| Cold start parses whole repo | `.mincut-cache/` per-file cache planned for v1.1 |
|
|
242
335
|
| Python class-level constants aren't symbols yet | Only `def` and `class` for now |
|
|
243
336
|
|
|
337
|
+
</details>
|
|
338
|
+
|
|
244
339
|
---
|
|
245
340
|
|
|
246
341
|
## Contributing
|
|
@@ -255,14 +350,22 @@ node dist/adapters/cli/bin.js pack "..." --repo /path/to/some-repo
|
|
|
255
350
|
```
|
|
256
351
|
|
|
257
352
|
PRs especially welcome for:
|
|
353
|
+
|
|
258
354
|
- **New language parsers** — tree-sitter grammar + symbol queries
|
|
259
355
|
- **LSP integration** — type-aware call resolution
|
|
260
356
|
- **Cache layer** — persistent `.mincut-cache/`
|
|
261
357
|
|
|
262
358
|
Each PR must keep the test suite green (`npm test`). New behavior requires tests first (TDD).
|
|
263
359
|
|
|
264
|
-
|
|
360
|
+
## Built with
|
|
361
|
+
|
|
362
|
+
- [`tree-sitter`](https://tree-sitter.github.io/tree-sitter/) — incremental parsing
|
|
363
|
+
- [`graphology`](https://graphology.github.io/) — graph primitives
|
|
364
|
+
- [`@xenova/transformers`](https://github.com/xenova/transformers.js) — local ONNX embeddings
|
|
365
|
+
- [`@modelcontextprotocol/sdk`](https://github.com/modelcontextprotocol/typescript-sdk) — MCP server
|
|
366
|
+
- [`commander`](https://github.com/tj/commander.js) + [`ink`](https://github.com/vadimdemedes/ink) — CLI & TUI
|
|
367
|
+
- [`vitest`](https://vitest.dev/) — testing
|
|
265
368
|
|
|
266
369
|
## License
|
|
267
370
|
|
|
268
|
-
[MIT](./LICENSE)
|
|
371
|
+
[MIT](./LICENSE) © [Dhrupo Nil](https://github.com/dhrupo)
|
package/dist/adapters/cli/bin.js
CHANGED
|
@@ -30,7 +30,7 @@ const program = new Command();
|
|
|
30
30
|
program
|
|
31
31
|
.name('mcx')
|
|
32
32
|
.description('mincut-context — token-minimal context selection for AI coding agents')
|
|
33
|
-
.version('1.
|
|
33
|
+
.version('1.2.0');
|
|
34
34
|
program
|
|
35
35
|
.command('pack <task...>')
|
|
36
36
|
.description('Pack a token-minimal context window for the given task')
|
|
@@ -46,6 +46,9 @@ program
|
|
|
46
46
|
.option('--embed-weight <number>', 'Blend factor 0..1 (0=keyword, 1=embedding only)', (v) => Number(v), 0.5)
|
|
47
47
|
.option('--embed-model <id>', 'Hugging Face model id', 'Xenova/all-MiniLM-L6-v2')
|
|
48
48
|
.option('-i, --interactive', 'Interactive review — pin/exclude in a TUI before output', false)
|
|
49
|
+
.option('--cache', 'Use persistent parse cache at .mincut-cache/ (fast repeat runs)', false)
|
|
50
|
+
.option('--cache-dir <path>', 'Override cache directory (absolute path)')
|
|
51
|
+
.option('--community-boost <number>', 'Louvain same-community boost factor (0 = disabled)', (v) => Number(v), 0.5)
|
|
49
52
|
.action(async (taskWords, opts) => {
|
|
50
53
|
const task = taskWords.join(' ').trim();
|
|
51
54
|
if (!task) {
|
|
@@ -68,6 +71,9 @@ program
|
|
|
68
71
|
exclude: opts.exclude,
|
|
69
72
|
embedder,
|
|
70
73
|
embedWeight: opts.embedWeight,
|
|
74
|
+
cache: opts.cache,
|
|
75
|
+
cacheDir: opts.cacheDir,
|
|
76
|
+
communityBoost: opts.communityBoost,
|
|
71
77
|
});
|
|
72
78
|
const color = Boolean(opts.color) && process.stdout.isTTY;
|
|
73
79
|
const fmt = (opts.format ?? 'plain').toLowerCase();
|
|
@@ -93,17 +99,24 @@ program
|
|
|
93
99
|
});
|
|
94
100
|
program
|
|
95
101
|
.command('index')
|
|
96
|
-
.description('Index the repo and print stats (
|
|
102
|
+
.description('Index the repo and print stats (optionally warm the on-disk parse cache)')
|
|
97
103
|
.option('-r, --repo <path>', 'Repository root', process.cwd())
|
|
98
104
|
.option('--include <pattern...>', 'Restrict to glob patterns')
|
|
105
|
+
.option('--cache', 'Use persistent parse cache at .mincut-cache/', false)
|
|
106
|
+
.option('--cache-dir <path>', 'Override cache directory (absolute path)')
|
|
99
107
|
.action((opts) => {
|
|
100
108
|
const t0 = Date.now();
|
|
101
109
|
const { stats } = indexRepo(path.resolve(opts.repo), {
|
|
102
110
|
include: opts.include,
|
|
111
|
+
cache: opts.cache,
|
|
112
|
+
cacheDir: opts.cacheDir,
|
|
103
113
|
});
|
|
104
114
|
const elapsed = Date.now() - t0;
|
|
115
|
+
const cacheNote = opts.cache
|
|
116
|
+
? ` · cache: ${stats.cacheHits} hit / ${stats.cacheMisses} miss`
|
|
117
|
+
: '';
|
|
105
118
|
process.stdout.write(`indexed ${stats.files} files · ${stats.symbols} symbols · ${stats.edges} edges ` +
|
|
106
|
-
`(${stats.unresolvedCalls} unresolved calls) in ${elapsed} ms\n`);
|
|
119
|
+
`(${stats.unresolvedCalls} unresolved calls)${cacheNote} in ${elapsed} ms\n`);
|
|
107
120
|
});
|
|
108
121
|
program
|
|
109
122
|
.command('mcp')
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bin.js","sourceRoot":"","sources":["../../../src/adapters/cli/bin.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,IAAI,MAAM,WAAW,C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CAAC,OAAO,IAAI,CAAC,CAAC;IAC3D,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
|
@@ -7,7 +7,7 @@ import { handleMcpCall, TOOLS } from './handler.js';
|
|
|
7
7
|
* All business logic lives in the handler — this file only does transport.
|
|
8
8
|
*/
|
|
9
9
|
export async function runMcpServer() {
|
|
10
|
-
const server = new Server({ name: 'mincut-context', version: '1.
|
|
10
|
+
const server = new Server({ name: 'mincut-context', version: '1.2.0' }, { capabilities: { tools: {} } });
|
|
11
11
|
server.setRequestHandler(ListToolsRequestSchema, async () => ({
|
|
12
12
|
tools: TOOLS.map((t) => ({
|
|
13
13
|
name: t.name,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { SymbolGraph } from './graph.js';
|
|
2
|
+
export interface CommunityOptions {
|
|
3
|
+
/** Optional deterministic RNG seed for reproducible runs. */
|
|
4
|
+
seed?: number;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Louvain community detection on the symbol graph.
|
|
8
|
+
*
|
|
9
|
+
* Why undirected? Community detection asks "which nodes are densely
|
|
10
|
+
* interconnected" — a directed call edge a→b should still place a and b in
|
|
11
|
+
* the same module. We collapse to an undirected weight-summed multigraph.
|
|
12
|
+
*
|
|
13
|
+
* Returns a Map<nodeId, communityId>. Community IDs are arbitrary integers;
|
|
14
|
+
* only equality is meaningful (two nodes share a community iff equal).
|
|
15
|
+
*/
|
|
16
|
+
export declare function detectCommunities(symbols: SymbolGraph, options?: CommunityOptions): Map<string, number>;
|
|
17
|
+
//# sourceMappingURL=communities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"communities.d.ts","sourceRoot":"","sources":["../../src/core/communities.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAqB9C,MAAM,WAAW,gBAAgB;IAC/B,6DAA6D;IAC7D,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;;;;GASG;AACH,wBAAgB,iBAAiB,CAC/B,OAAO,EAAE,WAAW,EACpB,OAAO,GAAE,gBAAqB,GAC7B,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAuBrB"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
// graphology + graphology-communities-louvain are CommonJS — bridge via require.
|
|
3
|
+
const require_ = createRequire(import.meta.url);
|
|
4
|
+
const { UndirectedGraph } = require_('graphology');
|
|
5
|
+
const louvain = require_('graphology-communities-louvain');
|
|
6
|
+
/**
|
|
7
|
+
* Louvain community detection on the symbol graph.
|
|
8
|
+
*
|
|
9
|
+
* Why undirected? Community detection asks "which nodes are densely
|
|
10
|
+
* interconnected" — a directed call edge a→b should still place a and b in
|
|
11
|
+
* the same module. We collapse to an undirected weight-summed multigraph.
|
|
12
|
+
*
|
|
13
|
+
* Returns a Map<nodeId, communityId>. Community IDs are arbitrary integers;
|
|
14
|
+
* only equality is meaningful (two nodes share a community iff equal).
|
|
15
|
+
*/
|
|
16
|
+
export function detectCommunities(symbols, options = {}) {
|
|
17
|
+
const g = new UndirectedGraph();
|
|
18
|
+
for (const id of symbols.nodes())
|
|
19
|
+
g.addNode(id);
|
|
20
|
+
// Sum directed weights to a single undirected edge weight per pair.
|
|
21
|
+
for (const sourceId of symbols.nodes()) {
|
|
22
|
+
for (const e of symbols.outEdges(sourceId)) {
|
|
23
|
+
const a = sourceId;
|
|
24
|
+
const b = e.target;
|
|
25
|
+
if (a === b)
|
|
26
|
+
continue;
|
|
27
|
+
if (g.hasEdge(a, b)) {
|
|
28
|
+
g.updateEdgeAttribute(a, b, 'weight', (v) => Number(v ?? 0) + e.data.weight);
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
g.addEdge(a, b, { weight: e.data.weight });
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
const rng = options.seed !== undefined ? mulberry32(options.seed) : Math.random;
|
|
36
|
+
// Louvain with no edges returns a single community for everything; for an
|
|
37
|
+
// isolated-node graph the library treats every node as its own community,
|
|
38
|
+
// which matches our test contract.
|
|
39
|
+
const raw = louvain(g, { rng });
|
|
40
|
+
return new Map(Object.entries(raw));
|
|
41
|
+
}
|
|
42
|
+
/** Tiny deterministic PRNG so tests can lock results across runs. */
|
|
43
|
+
function mulberry32(seed) {
|
|
44
|
+
let a = seed | 0;
|
|
45
|
+
return function rng() {
|
|
46
|
+
a |= 0;
|
|
47
|
+
a = (a + 0x6d2b79f5) | 0;
|
|
48
|
+
let t = a;
|
|
49
|
+
t = Math.imul(t ^ (t >>> 15), t | 1);
|
|
50
|
+
t ^= t + Math.imul(t ^ (t >>> 7), t | 61);
|
|
51
|
+
return ((t ^ (t >>> 14)) >>> 0) / 4294967296;
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=communities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"communities.js","sourceRoot":"","sources":["../../src/core/communities.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAG5C,iFAAiF;AACjF,MAAM,QAAQ,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAChD,MAAM,EAAE,eAAe,EAAE,GAAG,QAAQ,CAAC,YAAY,CAEhD,CAAC;AACF,MAAM,OAAO,GAAG,QAAQ,CAAC,gCAAgC,CAG9B,CAAC;AAgB5B;;;;;;;;;GASG;AACH,MAAM,UAAU,iBAAiB,CAC/B,OAAoB,EACpB,UAA4B,EAAE;IAE9B,MAAM,CAAC,GAAG,IAAI,eAAe,EAAE,CAAC;IAChC,KAAK,MAAM,EAAE,IAAI,OAAO,CAAC,KAAK,EAAE;QAAE,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAChD,oEAAoE;IACpE,KAAK,MAAM,QA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AC,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC;QACzB,IAAI,CAAC,GAAG,CAAC,CAAC;QACV,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;QACrC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QAC1C,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,UAAU,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC"}
|
package/dist/core/index.d.ts
CHANGED
|
@@ -4,4 +4,6 @@ export { personalizedPageRank } from './pagerank.js';
|
|
|
4
4
|
export type { PageRankOptions } from './pagerank.js';
|
|
5
5
|
export { greedySelect } from './select.js';
|
|
6
6
|
export type { SelectOptions, SelectionEntry, SelectionResult } from './select.js';
|
|
7
|
+
export { detectCommunities } from './communities.js';
|
|
8
|
+
export type { CommunityOptions } from './communities.js';
|
|
7
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/core/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,YAAY,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAClF,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AACrD,YAAY,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAClF,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AACrD,YAAY,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/core/index.js
CHANGED
package/dist/core/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/core/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAEzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAErD,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/core/select.d.ts
CHANGED
|
@@ -17,12 +17,23 @@ export interface SelectOptions {
|
|
|
17
17
|
* even at the cost of some rank.
|
|
18
18
|
*/
|
|
19
19
|
attachmentWeight?: number;
|
|
20
|
+
/**
|
|
21
|
+
* Optional Louvain community labels per node. When provided AND
|
|
22
|
+
* `communityBoost > 0`, candidates sharing a community with any seed get
|
|
23
|
+
* a multiplicative boost in the greedy objective — surface results stay
|
|
24
|
+
* inside the task's natural module instead of drifting outside.
|
|
25
|
+
*/
|
|
26
|
+
communities?: ReadonlyMap<string, number>;
|
|
27
|
+
/** Multiplicative boost for same-community candidates. Default 0 (off). */
|
|
28
|
+
communityBoost?: number;
|
|
20
29
|
}
|
|
21
30
|
export interface SelectionEntry {
|
|
22
31
|
id: string;
|
|
23
32
|
tokens: number;
|
|
24
33
|
rank: number;
|
|
25
34
|
reason: string;
|
|
35
|
+
/** Louvain community label, present only when communities were supplied. */
|
|
36
|
+
community?: number;
|
|
26
37
|
}
|
|
27
38
|
export interface SelectionResult {
|
|
28
39
|
selected: Set<string>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/core/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,6EAA6E;IAC7E,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"select.d.ts","sourceRoot":"","sources":["../../src/core/select.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,WAAW,aAAa;IAC5B,qDAAqD;IACrD,KAAK,EAAE,WAAW,CAAC,MAAM,CAAC,CAAC;IAC3B,6EAA6E;IAC7E,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,+CAA+C;IAC/C,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B;;;;;OAKG;IACH,WAAW,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1C,4EAA4E;IAC5E,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,4EAA4E;IAC5E,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,QAAQ,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACtB,OAAO,EAAE,cAAc,EAAE,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,wBAAgB,YAAY,CAAC,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,aAAa,GAAG,eAAe,CA4GxF"}
|
package/dist/core/select.js
CHANGED
|
@@ -25,7 +25,17 @@
|
|
|
25
25
|
* the remaining budget.
|
|
26
26
|
*/
|
|
27
27
|
export function greedySelect(graph, options) {
|
|
28
|
-
const { seeds, ranks, budget, rankWeight = 1, attachmentWeight = 1, } = options;
|
|
28
|
+
const { seeds, ranks, budget, rankWeight = 1, attachmentWeight = 1, communities, communityBoost = 0, } = options;
|
|
29
|
+
// Pre-compute the set of community ids the seeds occupy — candidate gets
|
|
30
|
+
// the boost iff its community is in this set.
|
|
31
|
+
const seedCommunities = new Set();
|
|
32
|
+
if (communities && communityBoost > 0) {
|
|
33
|
+
for (const id of seeds) {
|
|
34
|
+
const c = communities.get(id);
|
|
35
|
+
if (c !== undefined)
|
|
36
|
+
seedCommunities.add(c);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
29
39
|
const selected = new Set();
|
|
30
40
|
const entries = [];
|
|
31
41
|
let usedTokens = 0;
|
|
@@ -44,6 +54,7 @@ export function greedySelect(graph, options) {
|
|
|
44
54
|
tokens: data.tokens,
|
|
45
55
|
rank: ranks.get(id) ?? 0,
|
|
46
56
|
reason: 'seed — matched directly by task',
|
|
57
|
+
community: communities?.get(id),
|
|
47
58
|
});
|
|
48
59
|
}
|
|
49
60
|
// 2. Greedy fill.
|
|
@@ -66,7 +77,16 @@ export function greedySelect(graph, options) {
|
|
|
66
77
|
if (attach === 0)
|
|
67
78
|
continue;
|
|
68
79
|
const rank = ranks.get(id) ?? 0;
|
|
69
|
-
|
|
80
|
+
let score = (rankWeight * rank * attach * attachmentWeight) / Math.max(data.tokens, 1);
|
|
81
|
+
// Multiplicative community boost: candidates inside any seed's community
|
|
82
|
+
// win ties. Caps at 2x by design so a wildly relevant outsider can
|
|
83
|
+
// still beat a same-community filler.
|
|
84
|
+
if (communities && communityBoost > 0) {
|
|
85
|
+
const c = communities.get(id);
|
|
86
|
+
if (c !== undefined && seedCommunities.has(c)) {
|
|
87
|
+
score *= 1 + communityBoost;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
70
90
|
if (!best || score > best.score) {
|
|
71
91
|
best = { id, score, tokens: data.tokens, rank, attach };
|
|
72
92
|
}
|
|
@@ -80,6 +100,7 @@ export function greedySelect(graph, options) {
|
|
|
80
100
|
tokens: best.tokens,
|
|
81
101
|
rank: best.rank,
|
|
82
102
|
reason: reasonFor(best.attach, best.rank),
|
|
103
|
+
community: communities?.get(best.id),
|
|
83
104
|
});
|
|
84
105
|
}
|
|
85
106
|
return {
|
package/dist/core/select.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/core/select.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"select.js","sourceRoot":"","sources":["../../src/core/select.ts"],"names":[],"mappings":"AA+CA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,MAAM,UAAU,YAAY,CAAC,KAAkB,EAAE,OAAsB;IACrE,MAAM,EACJ,KAAK,EACL,KAAK,EACL,MAAM,EACN,UAAU,GAAG,CAAC,EACd,gBAAgB,GAAG,CAAC,EACpB,WAAW,EACX,cAAc,GAAG,CAAC,GACnB,GAAG,OAAO,CAAC;IAEZ,yEAAyE;IACzE,8CAA8C;IAC9C,MAAM,eAAe,GAAG,IAAI,GAAG,EAAU,CAAC;IAC1C,IAAI,WAAW,IAAI,cAAc,GAAG,CAAC,EAAE,CAAC;QACtC,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;YACvB,MAAM,CAAC,GAAG,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;YAC9B,IAAI,CAAC,KAAK,SAAS;gBAAE,eAAe,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAU,CAAC;IACnC,MAAM,OAAO,GAAqB,EAAE,CAAC;IACrC,IAAI,UAAU,GAAG,CAAC,CAAC;IAEnB,sCAAsC;IACtC,KAAK,MAAM,EAAE,IAAI,KAAK,EAAE,CAAC;QACvB,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QAC/B,IAAI,CAAC,IAAI;YAAE,MAAM,IAAI,KAAK,CAAC,sBAAsB,EAAE,EAAE,CAAC,CAAC;QACvD,IAAI,UAAU,GAAG,IAAI,CAAC,MAAM,GAAG,MAAM,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CACb,8BAA8B,EAAE,WAAW,IAAI,CAAC,MAAM,YACp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5 +1,11 @@
|
|
|
1
1
|
import { SymbolGraph } from '../core/graph.js';
|
|
2
2
|
import { type WalkOptions } from './walker.js';
|
|
3
|
+
export interface IndexOptions extends WalkOptions {
|
|
4
|
+
/** Enable persistent on-disk parse cache. Default false (in-memory only). */
|
|
5
|
+
cache?: boolean;
|
|
6
|
+
/** Override cache directory. Default `<repo>/.mincut-cache/`. */
|
|
7
|
+
cacheDir?: string;
|
|
8
|
+
}
|
|
3
9
|
export interface IndexResult {
|
|
4
10
|
graph: SymbolGraph;
|
|
5
11
|
stats: {
|
|
@@ -7,7 +13,9 @@ export interface IndexResult {
|
|
|
7
13
|
symbols: number;
|
|
8
14
|
edges: number;
|
|
9
15
|
unresolvedCalls: number;
|
|
16
|
+
cacheHits: number;
|
|
17
|
+
cacheMisses: number;
|
|
10
18
|
};
|
|
11
19
|
}
|
|
12
|
-
export declare function indexRepo(root: string, options?:
|
|
20
|
+
export declare function indexRepo(root: string, options?: IndexOptions): IndexResult;
|
|
13
21
|
//# sourceMappingURL=builder.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/index/builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"builder.d.ts","sourceRoot":"","sources":["../../src/index/builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAM/C,OAAO,EAAQ,KAAK,WAAW,EAAE,MAAM,aAAa,CAAC;AAiBrD,MAAM,WAAW,YAAa,SAAQ,WAAW;IAC/C,8EAA8E;IAC9E,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,kEAAkE;IAClE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,WAAW;IAC1B,KAAK,EAAE,WAAW,CAAC;IACnB,KAAK,EAAE;QACL,KAAK,EAAE,MAAM,CAAC;QACd,OAAO,EAAE,MAAM,CAAC;QAChB,KAAK,EAAE,MAAM,CAAC;QACd,eAAe,EAAE,MAAM,CAAC;QACxB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;CACH;AAED,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,WAAW,CA6G/E"}
|