@iceinvein/code-intelligence-mcp 0.1.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.
Files changed (3) hide show
  1. package/bin/run.js +63 -0
  2. package/install.js +96 -0
  3. package/package.json +30 -0
package/bin/run.js ADDED
@@ -0,0 +1,63 @@
1
+ #!/usr/bin/env node
2
+
3
+ const { spawn } = require('child_process');
4
+ const path = require('path');
5
+ const os = require('os');
6
+ const fs = require('fs');
7
+
8
+ const BINARY_NAME = 'code-intelligence-mcp-server' + (os.platform() === 'win32' ? '.exe' : '');
9
+ const BINARY_PATH = path.join(__dirname, BINARY_NAME);
10
+
11
+ if (!fs.existsSync(BINARY_PATH)) {
12
+ console.error(`Binary not found at ${BINARY_PATH}`);
13
+ console.error('Please try reinstalling the package: npm install -g code-intelligence-mcp');
14
+ process.exit(1);
15
+ }
16
+
17
+ // Setup Environment
18
+ const env = { ...process.env };
19
+
20
+ // 1. Default BASE_DIR to current working directory if not set
21
+ if (!env.BASE_DIR) {
22
+ env.BASE_DIR = process.cwd();
23
+ }
24
+
25
+ // 2. Default to Candle backend (local AI)
26
+ if (!env.EMBEDDINGS_BACKEND) {
27
+ env.EMBEDDINGS_BACKEND = 'candle';
28
+ }
29
+
30
+ // 3. Enable Auto Download
31
+ if (!env.EMBEDDINGS_AUTO_DOWNLOAD) {
32
+ env.EMBEDDINGS_AUTO_DOWNLOAD = 'true';
33
+ }
34
+
35
+ // 4. Metal Acceleration for macOS
36
+ if (os.platform() === 'darwin' && !env.EMBEDDINGS_DEVICE) {
37
+ env.EMBEDDINGS_DEVICE = 'metal';
38
+ } else if (!env.EMBEDDINGS_DEVICE) {
39
+ env.EMBEDDINGS_DEVICE = 'cpu';
40
+ }
41
+
42
+ // 5. Set persistence paths to be inside the project (BASE_DIR/.cimcp)
43
+ // if not explicitly overridden. This keeps indexes local to the project.
44
+ const cimcpDir = path.join(env.BASE_DIR, '.cimcp');
45
+ if (!env.DB_PATH) env.DB_PATH = path.join(cimcpDir, 'code-intelligence.db');
46
+ if (!env.VECTOR_DB_PATH) env.VECTOR_DB_PATH = path.join(cimcpDir, 'vectors');
47
+ if (!env.TANTIVY_INDEX_PATH) env.TANTIVY_INDEX_PATH = path.join(cimcpDir, 'tantivy-index');
48
+ // Also set model dir to local project cache if not set globally
49
+ if (!env.EMBEDDINGS_MODEL_DIR) env.EMBEDDINGS_MODEL_DIR = path.join(cimcpDir, 'embeddings-model');
50
+
51
+ // Spawn the process
52
+ const child = spawn(BINARY_PATH, process.argv.slice(2), {
53
+ env: env,
54
+ stdio: 'inherit' // Pipe stdin/out/err directly
55
+ });
56
+
57
+ child.on('exit', (code) => {
58
+ process.exit(code);
59
+ });
60
+
61
+ // Forward signals
62
+ process.on('SIGINT', () => child.kill('SIGINT'));
63
+ process.on('SIGTERM', () => child.kill('SIGTERM'));
package/install.js ADDED
@@ -0,0 +1,96 @@
1
+ const fs = require('fs');
2
+ const path = require('path');
3
+ const axios = require('axios');
4
+ const tar = require('tar');
5
+ const os = require('os');
6
+
7
+ const REPO = 'iceinvein/code_intelligence_mcp_server';
8
+ const BINARY_NAME = 'code-intelligence-mcp-server';
9
+ // We use the version from package.json to fetch the matching tag
10
+ const VERSION = 'v' + require('./package.json').version;
11
+
12
+ const MAPPING = {
13
+ 'darwin': {
14
+ 'arm64': 'aarch64-apple-darwin',
15
+ 'x64': 'x86_64-apple-darwin'
16
+ },
17
+ 'linux': {
18
+ 'x64': 'x86_64-unknown-linux-gnu'
19
+ },
20
+ 'win32': {
21
+ 'x64': 'x86_64-pc-windows-msvc'
22
+ }
23
+ };
24
+
25
+ async function install() {
26
+ const platform = os.platform();
27
+ const arch = os.arch();
28
+
29
+ if (!MAPPING[platform] || !MAPPING[platform][arch]) {
30
+ console.error(`Unsupported platform: ${platform} ${arch}`);
31
+ process.exit(1);
32
+ }
33
+
34
+ const target = MAPPING[platform][arch];
35
+ const extension = platform === 'win32' ? '.exe' : '';
36
+ const tarFilename = `${BINARY_NAME}-${target}.tar.gz`;
37
+ const url = `https://github.com/${REPO}/releases/download/${VERSION}/${tarFilename}`;
38
+
39
+ const binDir = path.join(__dirname, 'bin');
40
+ const destBinary = path.join(binDir, BINARY_NAME + extension);
41
+
42
+ // Ensure bin dir exists
43
+ if (!fs.existsSync(binDir)) {
44
+ fs.mkdirSync(binDir, { recursive: true });
45
+ }
46
+
47
+ console.log(`Downloading ${BINARY_NAME} ${VERSION} for ${target}...`);
48
+ console.log(`URL: ${url}`);
49
+
50
+ try {
51
+ const response = await axios({
52
+ method: 'get',
53
+ url: url,
54
+ responseType: 'stream'
55
+ });
56
+
57
+ // Pipe the tar.gz stream directly into the extractor
58
+ const extract = tar.x({
59
+ C: binDir,
60
+ // We want to extract the binary, but the tar structure might depend on how it was packed.
61
+ // The CI "tar czf" command packs the binary directly at the root of the tarball.
62
+ // So we just extract it.
63
+ });
64
+
65
+ response.data.pipe(extract);
66
+
67
+ await new Promise((resolve, reject) => {
68
+ extract.on('finish', resolve);
69
+ extract.on('error', reject);
70
+ });
71
+
72
+ // Verify the binary exists
73
+ if (fs.existsSync(destBinary)) {
74
+ // Make executable on unix
75
+ if (platform !== 'win32') {
76
+ fs.chmodSync(destBinary, 0o755);
77
+ }
78
+ console.log(`Successfully installed to ${destBinary}`);
79
+ } else {
80
+ console.error('Extraction failed: Binary not found after unpacking.');
81
+ console.error(`Expected location: ${destBinary}`);
82
+ // List contents of binDir to help debug
83
+ console.log('Contents of bin directory:', fs.readdirSync(binDir));
84
+ process.exit(1);
85
+ }
86
+
87
+ } catch (error) {
88
+ console.error('Failed to download or install binary:', error.message);
89
+ if (error.response && error.response.status === 404) {
90
+ console.error(`Release not found. Please ensure version ${VERSION} is published on GitHub.`);
91
+ }
92
+ process.exit(1);
93
+ }
94
+ }
95
+
96
+ install();
package/package.json ADDED
@@ -0,0 +1,30 @@
1
+ {
2
+ "name": "@iceinvein/code-intelligence-mcp",
3
+ "version": "0.1.2",
4
+ "description": "Code Intelligence MCP Server - Smart context for your LLM coding agent",
5
+ "bin": {
6
+ "code-intelligence-mcp": "bin/run.js"
7
+ },
8
+ "scripts": {
9
+ "postinstall": "node install.js"
10
+ },
11
+ "repository": {
12
+ "type": "git",
13
+ "url": "git+https://github.com/iceinvein/code_intelligence_mcp_server.git"
14
+ },
15
+ "author": "iceinvein",
16
+ "license": "MIT",
17
+ "dependencies": {
18
+ "axios": "^1.13.2",
19
+ "tar": "^7.5.3"
20
+ },
21
+ "os": [
22
+ "darwin",
23
+ "linux",
24
+ "win32"
25
+ ],
26
+ "cpu": [
27
+ "x64",
28
+ "arm64"
29
+ ]
30
+ }