@regsorm/code-index-mcp 0.10.2
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 +40 -0
- package/bin/cli.js +38 -0
- package/package.json +47 -0
- package/scripts/postinstall.js +115 -0
package/README.md
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# @regsorm/code-index-mcp
|
|
2
|
+
|
|
3
|
+
npm-обёртка для [code-index](https://github.com/Regsorm/code-index-mcp) — высокопроизводительного индексатора кода с MCP-протоколом для AI-моделей.
|
|
4
|
+
|
|
5
|
+
Rust + tree-sitter + SQLite. Индексация 62K файлов за ~43 сек, 282K функций, поиск < 1 мс.
|
|
6
|
+
|
|
7
|
+
## Установка
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npm install -g @regsorm/code-index-mcp
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
При установке `postinstall` скачивает готовый нативный бинарник под вашу платформу из [GitHub Releases](https://github.com/Regsorm/code-index-mcp/releases). Сам код на Rust — обёртка ничего не компилирует.
|
|
14
|
+
|
|
15
|
+
Поддерживаемые платформы: Windows x64, Linux x64, macOS arm64.
|
|
16
|
+
|
|
17
|
+
## Запуск как MCP-сервера
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
npx @regsorm/code-index-mcp serve --path /path/to/your/repo
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
Транспорт по умолчанию — `stdio`. Для подключения к Claude Code / Cursor добавьте в MCP-конфигурацию:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"code-index": {
|
|
28
|
+
"command": "npx",
|
|
29
|
+
"args": ["-y", "@regsorm/code-index-mcp", "serve", "--path", "/path/to/your/repo"]
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## Документация
|
|
35
|
+
|
|
36
|
+
Полное описание инструментов (`search_function`, `get_function`, `grep_body`, `find_symbol`, `get_callers` и др.), режим демона и конфигурация — в [основном репозитории](https://github.com/Regsorm/code-index-mcp).
|
|
37
|
+
|
|
38
|
+
## Лицензия
|
|
39
|
+
|
|
40
|
+
MIT
|
package/bin/cli.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// Тонкая обёртка: запускает нативный бинарник code-index, прозрачно
|
|
3
|
+
// пробрасывая аргументы и stdin/stdout/stderr. Для MCP stdio-транспорта
|
|
4
|
+
// критично, чтобы потоки шли напрямую (stdio: 'inherit').
|
|
5
|
+
//
|
|
6
|
+
// Пример запуска MCP-сервера клиентом:
|
|
7
|
+
// npx @regsorm/code-index-mcp serve --path C:/MyRepo
|
|
8
|
+
// (транспорт stdio — по умолчанию).
|
|
9
|
+
|
|
10
|
+
'use strict';
|
|
11
|
+
|
|
12
|
+
const path = require('path');
|
|
13
|
+
const { spawn } = require('child_process');
|
|
14
|
+
|
|
15
|
+
const binName = process.platform === 'win32' ? 'code-index.exe' : 'code-index';
|
|
16
|
+
const binPath = path.join(__dirname, binName);
|
|
17
|
+
|
|
18
|
+
const child = spawn(binPath, process.argv.slice(2), { stdio: 'inherit' });
|
|
19
|
+
|
|
20
|
+
child.on('exit', (code, signal) => {
|
|
21
|
+
if (signal) {
|
|
22
|
+
process.kill(process.pid, signal);
|
|
23
|
+
} else {
|
|
24
|
+
process.exit(code == null ? 0 : code);
|
|
25
|
+
}
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
child.on('error', (err) => {
|
|
29
|
+
if (err.code === 'ENOENT') {
|
|
30
|
+
console.error(
|
|
31
|
+
'[code-index-mcp] Бинарник не найден. Похоже, postinstall не отработал.\n' +
|
|
32
|
+
'Переустановите пакет: npm install -g @regsorm/code-index-mcp'
|
|
33
|
+
);
|
|
34
|
+
} else {
|
|
35
|
+
console.error('[code-index-mcp] Не удалось запустить бинарник:', err.message);
|
|
36
|
+
}
|
|
37
|
+
process.exit(1);
|
|
38
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@regsorm/code-index-mcp",
|
|
3
|
+
"version": "0.10.2",
|
|
4
|
+
"description": "Высокопроизводительный индексатор кода с MCP-протоколом для AI-моделей. Rust + tree-sitter + SQLite. Поиск по 62K файлов за 43 сек.",
|
|
5
|
+
"mcpName": "io.github.regsorm/code-index",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"mcp",
|
|
8
|
+
"model-context-protocol",
|
|
9
|
+
"code-index",
|
|
10
|
+
"code-search",
|
|
11
|
+
"tree-sitter",
|
|
12
|
+
"claude",
|
|
13
|
+
"ai"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://github.com/Regsorm/code-index-mcp",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/Regsorm/code-index-mcp/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/Regsorm/code-index-mcp.git"
|
|
22
|
+
},
|
|
23
|
+
"license": "MIT",
|
|
24
|
+
"bin": {
|
|
25
|
+
"code-index-mcp": "bin/cli.js"
|
|
26
|
+
},
|
|
27
|
+
"scripts": {
|
|
28
|
+
"postinstall": "node scripts/postinstall.js"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"bin/cli.js",
|
|
32
|
+
"scripts/postinstall.js",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=18"
|
|
37
|
+
},
|
|
38
|
+
"os": [
|
|
39
|
+
"win32",
|
|
40
|
+
"linux",
|
|
41
|
+
"darwin"
|
|
42
|
+
],
|
|
43
|
+
"cpu": [
|
|
44
|
+
"x64",
|
|
45
|
+
"arm64"
|
|
46
|
+
]
|
|
47
|
+
}
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
// postinstall: скачивает архив с готовым бинарником code-index из GitHub
|
|
3
|
+
// Releases под текущую платформу и распаковывает его системным `tar`.
|
|
4
|
+
//
|
|
5
|
+
// Архивы уже публикуются в каждом релизе (.github/workflows/release.yml),
|
|
6
|
+
// поэтому пакет совместим с любым существующим релизом — отдельные сырые
|
|
7
|
+
// бинарники не нужны.
|
|
8
|
+
//
|
|
9
|
+
// `tar` есть из коробки: Windows 10 1803+ (bsdtar понимает и .zip, и .tar.gz),
|
|
10
|
+
// все Linux/macOS. Сеть нужна только при установке. Нет сборки под платформу
|
|
11
|
+
// или нет tar — печатаем понятное сообщение и выходим с кодом 1.
|
|
12
|
+
|
|
13
|
+
'use strict';
|
|
14
|
+
|
|
15
|
+
const fs = require('fs');
|
|
16
|
+
const os = require('os');
|
|
17
|
+
const path = require('path');
|
|
18
|
+
const https = require('https');
|
|
19
|
+
const { execFileSync } = require('child_process');
|
|
20
|
+
|
|
21
|
+
const REPO = 'Regsorm/code-index-mcp';
|
|
22
|
+
const { version } = require('../package.json');
|
|
23
|
+
|
|
24
|
+
// platform-arch -> { archive: имя архива в релизе, bin: имя бинарника внутри }
|
|
25
|
+
const TARGETS = {
|
|
26
|
+
'win32-x64': { archive: 'code-index-windows-x64.zip', bin: 'code-index.exe' },
|
|
27
|
+
'linux-x64': { archive: 'code-index-linux-x64.tar.gz', bin: 'code-index' },
|
|
28
|
+
'darwin-arm64': { archive: 'code-index-macos-arm64.tar.gz', bin: 'code-index' },
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const key = `${process.platform}-${process.arch}`;
|
|
32
|
+
const target = TARGETS[key];
|
|
33
|
+
|
|
34
|
+
if (!target) {
|
|
35
|
+
console.error(
|
|
36
|
+
`[code-index-mcp] Нет готового бинарника для платформы "${key}".\n` +
|
|
37
|
+
`Поддерживаются: ${Object.keys(TARGETS).join(', ')}.\n` +
|
|
38
|
+
`Соберите из исходников: https://github.com/${REPO}`
|
|
39
|
+
);
|
|
40
|
+
process.exit(1);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
const url = `https://github.com/${REPO}/releases/download/v${version}/${target.archive}`;
|
|
44
|
+
const binDir = path.join(__dirname, '..', 'bin');
|
|
45
|
+
// Архив качаем прямо в binDir, чтобы распаковывать tar-ом по относительному
|
|
46
|
+
// имени (cwd = binDir) — путь с двоеточием диска tar трактует как remote-хост.
|
|
47
|
+
const archivePath = path.join(binDir, target.archive);
|
|
48
|
+
|
|
49
|
+
fs.mkdirSync(binDir, { recursive: true });
|
|
50
|
+
|
|
51
|
+
// Скачивание с поддержкой редиректов (GitHub Releases отдаёт 302 на CDN).
|
|
52
|
+
function download(currentUrl, redirectsLeft, cb) {
|
|
53
|
+
if (redirectsLeft < 0) {
|
|
54
|
+
return cb(new Error('Слишком много редиректов'));
|
|
55
|
+
}
|
|
56
|
+
https
|
|
57
|
+
.get(currentUrl, { headers: { 'User-Agent': 'code-index-mcp-postinstall' } }, (res) => {
|
|
58
|
+
const { statusCode } = res;
|
|
59
|
+
if ([301, 302, 307, 308].includes(statusCode) && res.headers.location) {
|
|
60
|
+
res.resume();
|
|
61
|
+
return download(res.headers.location, redirectsLeft - 1, cb);
|
|
62
|
+
}
|
|
63
|
+
if (statusCode !== 200) {
|
|
64
|
+
res.resume();
|
|
65
|
+
return cb(new Error(`HTTP ${statusCode} для ${currentUrl}`));
|
|
66
|
+
}
|
|
67
|
+
const file = fs.createWriteStream(archivePath);
|
|
68
|
+
res.pipe(file);
|
|
69
|
+
file.on('finish', () => file.close(() => cb(null)));
|
|
70
|
+
file.on('error', (err) => cb(err));
|
|
71
|
+
})
|
|
72
|
+
.on('error', (err) => cb(err));
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
download(url, 5, (err) => {
|
|
76
|
+
if (err) {
|
|
77
|
+
console.error(
|
|
78
|
+
`[code-index-mcp] Не удалось скачать архив (${target.archive} v${version}): ${err.message}\n` +
|
|
79
|
+
`URL: ${url}`
|
|
80
|
+
);
|
|
81
|
+
process.exit(1);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
// Распаковка системным tar по относительному имени в cwd=binDir.
|
|
85
|
+
// На Windows зовём системный bsdtar явно (System32\tar.exe) — он понимает
|
|
86
|
+
// .zip; полагаться на первый `tar` из PATH нельзя (там может оказаться GNU
|
|
87
|
+
// tar, который .zip не читает и трактует диск C: как remote-хост).
|
|
88
|
+
const tarCmd = process.platform === 'win32'
|
|
89
|
+
? path.join(process.env.SystemRoot || 'C:\\Windows', 'System32', 'tar.exe')
|
|
90
|
+
: 'tar';
|
|
91
|
+
try {
|
|
92
|
+
execFileSync(tarCmd, ['-xf', target.archive], { cwd: binDir, stdio: 'inherit' });
|
|
93
|
+
} catch (e) {
|
|
94
|
+
console.error(
|
|
95
|
+
`[code-index-mcp] Не удалось распаковать архив через tar: ${e.message}\n` +
|
|
96
|
+
`Убедитесь, что в системе есть tar (Windows 10 1803+, Linux, macOS).\n` +
|
|
97
|
+
`Архив: ${archivePath}`
|
|
98
|
+
);
|
|
99
|
+
process.exit(1);
|
|
100
|
+
} finally {
|
|
101
|
+
try { fs.unlinkSync(archivePath); } catch (_) { /* не критично */ }
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
const dest = path.join(binDir, target.bin);
|
|
105
|
+
if (!fs.existsSync(dest)) {
|
|
106
|
+
console.error(
|
|
107
|
+
`[code-index-mcp] После распаковки не найден бинарник "${target.bin}" в ${binDir}.`
|
|
108
|
+
);
|
|
109
|
+
process.exit(1);
|
|
110
|
+
}
|
|
111
|
+
if (process.platform !== 'win32') {
|
|
112
|
+
fs.chmodSync(dest, 0o755);
|
|
113
|
+
}
|
|
114
|
+
console.log(`[code-index-mcp] Бинарник установлен: ${dest}`);
|
|
115
|
+
});
|