@suatkocar/codegraph 0.1.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/README.md +30 -0
- package/bin/codegraph +20 -0
- package/install.js +168 -0
- package/package.json +38 -0
package/README.md
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# @suatkocar/codegraph
|
|
2
|
+
|
|
3
|
+
**Codebase intelligence as an MCP server.** Native Rust. Sub-second indexing. Zero runtime dependencies.
|
|
4
|
+
|
|
5
|
+
This npm package installs the `codegraph` binary for your platform.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
npx @suatkocar/codegraph init .
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Or install globally:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install -g @suatkocar/codegraph
|
|
17
|
+
codegraph init .
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
Or install without npm:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
curl -fsSL https://raw.githubusercontent.com/suatkocar/codegraph/main/install.sh | bash
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## What It Does
|
|
27
|
+
|
|
28
|
+
CodeGraph builds a semantic graph of your codebase (15 languages, 13 MCP tools) and makes it instantly available to AI coding agents. **68% fewer tokens** per task compared to reading all files.
|
|
29
|
+
|
|
30
|
+
See [GitHub](https://github.com/suatkocar/codegraph) for full documentation.
|
package/bin/codegraph
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
#!/bin/sh
|
|
2
|
+
# Wrapper that delegates to the native codegraph binary.
|
|
3
|
+
# The native binary is downloaded during npm postinstall.
|
|
4
|
+
|
|
5
|
+
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
6
|
+
NATIVE="$SCRIPT_DIR/codegraph-native"
|
|
7
|
+
|
|
8
|
+
if [ -x "$NATIVE" ]; then
|
|
9
|
+
exec "$NATIVE" "$@"
|
|
10
|
+
fi
|
|
11
|
+
|
|
12
|
+
# Fallback: check if installed globally via curl
|
|
13
|
+
if command -v codegraph >/dev/null 2>&1; then
|
|
14
|
+
exec codegraph "$@"
|
|
15
|
+
fi
|
|
16
|
+
|
|
17
|
+
echo "[codegraph] Binary not found. Try: npm rebuild @suatkocar/codegraph" >&2
|
|
18
|
+
echo "[codegraph] Or install directly:" >&2
|
|
19
|
+
echo " curl -fsSL https://raw.githubusercontent.com/suatkocar/codegraph/main/install.sh | bash" >&2
|
|
20
|
+
exit 1
|
package/install.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* postinstall script for @suatkocar/codegraph
|
|
4
|
+
*
|
|
5
|
+
* Downloads the correct platform binary from GitHub releases
|
|
6
|
+
* and places it in the package's bin/ directory.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
const { execSync } = require("child_process");
|
|
10
|
+
const fs = require("fs");
|
|
11
|
+
const os = require("os");
|
|
12
|
+
const path = require("path");
|
|
13
|
+
const https = require("https");
|
|
14
|
+
|
|
15
|
+
const REPO = "suatkocar/codegraph";
|
|
16
|
+
const BINARY = "codegraph"; // Rust binary name in GitHub releases
|
|
17
|
+
const LOCAL_NAME = "codegraph-native"; // Local binary name (wrapper calls this)
|
|
18
|
+
const BIN_DIR = path.join(__dirname, "bin");
|
|
19
|
+
|
|
20
|
+
function getPlatformTarget() {
|
|
21
|
+
const platform = os.platform();
|
|
22
|
+
const arch = os.arch();
|
|
23
|
+
|
|
24
|
+
const targets = {
|
|
25
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
26
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
27
|
+
"linux-x64": "x86_64-unknown-linux-gnu",
|
|
28
|
+
"linux-arm64": "aarch64-unknown-linux-gnu",
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const key = `${platform}-${arch}`;
|
|
32
|
+
const target = targets[key];
|
|
33
|
+
|
|
34
|
+
if (!target) {
|
|
35
|
+
console.error(`Unsupported platform: ${platform}-${arch}`);
|
|
36
|
+
console.error(`Supported: ${Object.keys(targets).join(", ")}`);
|
|
37
|
+
process.exit(1);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return target;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function getLatestRelease() {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
const options = {
|
|
46
|
+
hostname: "api.github.com",
|
|
47
|
+
path: `/repos/${REPO}/releases/latest`,
|
|
48
|
+
headers: { "User-Agent": "codegraph-npm-installer" },
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
https
|
|
52
|
+
.get(options, (res) => {
|
|
53
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
54
|
+
// Follow redirect
|
|
55
|
+
https.get(res.headers.location, { headers: options.headers }, (res2) => {
|
|
56
|
+
let data = "";
|
|
57
|
+
res2.on("data", (chunk) => (data += chunk));
|
|
58
|
+
res2.on("end", () => resolve(JSON.parse(data)));
|
|
59
|
+
});
|
|
60
|
+
return;
|
|
61
|
+
}
|
|
62
|
+
let data = "";
|
|
63
|
+
res.on("data", (chunk) => (data += chunk));
|
|
64
|
+
res.on("end", () => {
|
|
65
|
+
if (res.statusCode !== 200) {
|
|
66
|
+
reject(new Error(`GitHub API returned ${res.statusCode}: ${data}`));
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
resolve(JSON.parse(data));
|
|
70
|
+
});
|
|
71
|
+
})
|
|
72
|
+
.on("error", reject);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
function downloadFile(url, dest) {
|
|
77
|
+
return new Promise((resolve, reject) => {
|
|
78
|
+
const follow = (url) => {
|
|
79
|
+
https
|
|
80
|
+
.get(url, { headers: { "User-Agent": "codegraph-npm-installer" } }, (res) => {
|
|
81
|
+
if (res.statusCode === 302 || res.statusCode === 301) {
|
|
82
|
+
follow(res.headers.location);
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
if (res.statusCode !== 200) {
|
|
86
|
+
reject(new Error(`Download failed with status ${res.statusCode}`));
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const file = fs.createWriteStream(dest);
|
|
90
|
+
res.pipe(file);
|
|
91
|
+
file.on("finish", () => {
|
|
92
|
+
file.close();
|
|
93
|
+
resolve();
|
|
94
|
+
});
|
|
95
|
+
})
|
|
96
|
+
.on("error", reject);
|
|
97
|
+
};
|
|
98
|
+
follow(url);
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
async function main() {
|
|
103
|
+
const target = getPlatformTarget();
|
|
104
|
+
const binPath = path.join(BIN_DIR, LOCAL_NAME);
|
|
105
|
+
|
|
106
|
+
// Skip if binary already exists and is executable
|
|
107
|
+
if (fs.existsSync(binPath)) {
|
|
108
|
+
try {
|
|
109
|
+
fs.accessSync(binPath, fs.constants.X_OK);
|
|
110
|
+
console.log(`[codegraph] Binary already installed at ${binPath}`);
|
|
111
|
+
return;
|
|
112
|
+
} catch {
|
|
113
|
+
// Binary exists but not executable, re-download
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
console.log(`[codegraph] Installing for ${os.platform()}-${os.arch()}...`);
|
|
118
|
+
|
|
119
|
+
try {
|
|
120
|
+
// Try GitHub release first
|
|
121
|
+
const release = await getLatestRelease();
|
|
122
|
+
const assetName = `${BINARY}-${target}.tar.gz`;
|
|
123
|
+
const asset = release.assets.find((a) => a.name === assetName);
|
|
124
|
+
|
|
125
|
+
if (!asset) {
|
|
126
|
+
// Try without .tar.gz (direct binary)
|
|
127
|
+
const directAsset = release.assets.find((a) => a.name === `${BINARY}-${target}`);
|
|
128
|
+
if (directAsset) {
|
|
129
|
+
await downloadFile(directAsset.browser_download_url, binPath);
|
|
130
|
+
fs.chmodSync(binPath, 0o755);
|
|
131
|
+
console.log(`[codegraph] Installed ${BINARY} v${release.tag_name}`);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
console.error(`[codegraph] No binary found for ${target} in release ${release.tag_name}`);
|
|
136
|
+
console.error(`[codegraph] Available assets: ${release.assets.map((a) => a.name).join(", ")}`);
|
|
137
|
+
console.error(`[codegraph] Install manually: https://github.com/${REPO}/releases`);
|
|
138
|
+
process.exit(1);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Download tarball and extract
|
|
142
|
+
const tmpDir = fs.mkdtempSync(path.join(os.tmpdir(), "codegraph-"));
|
|
143
|
+
const tarPath = path.join(tmpDir, assetName);
|
|
144
|
+
|
|
145
|
+
await downloadFile(asset.browser_download_url, tarPath);
|
|
146
|
+
|
|
147
|
+
// Extract to temp, then rename to -native
|
|
148
|
+
fs.mkdirSync(BIN_DIR, { recursive: true });
|
|
149
|
+
execSync(`tar -xzf "${tarPath}" -C "${tmpDir}"`, { stdio: "pipe" });
|
|
150
|
+
|
|
151
|
+
// Move and rename: codegraph -> codegraph-native
|
|
152
|
+
const extractedBin = path.join(tmpDir, BINARY);
|
|
153
|
+
fs.copyFileSync(extractedBin, binPath);
|
|
154
|
+
fs.chmodSync(binPath, 0o755);
|
|
155
|
+
|
|
156
|
+
// Cleanup
|
|
157
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
158
|
+
|
|
159
|
+
console.log(`[codegraph] Installed ${BINARY} v${release.tag_name}`);
|
|
160
|
+
} catch (err) {
|
|
161
|
+
console.error(`[codegraph] Installation failed: ${err.message}`);
|
|
162
|
+
console.error(`[codegraph] Install manually:`);
|
|
163
|
+
console.error(` curl -fsSL https://raw.githubusercontent.com/${REPO}/main/install.sh | bash`);
|
|
164
|
+
process.exit(1);
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
main();
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@suatkocar/codegraph",
|
|
3
|
+
"version": "0.1.1",
|
|
4
|
+
"description": "Codebase intelligence as an MCP server — semantic code graph with 15 languages, 13 tools, and 68% token reduction",
|
|
5
|
+
"author": "Suat Kocar",
|
|
6
|
+
"license": "MIT",
|
|
7
|
+
"repository": {
|
|
8
|
+
"type": "git",
|
|
9
|
+
"url": "https://github.com/suatkocar/codegraph"
|
|
10
|
+
},
|
|
11
|
+
"homepage": "https://github.com/suatkocar/codegraph#readme",
|
|
12
|
+
"keywords": [
|
|
13
|
+
"mcp",
|
|
14
|
+
"claude",
|
|
15
|
+
"code-intelligence",
|
|
16
|
+
"tree-sitter",
|
|
17
|
+
"semantic-search",
|
|
18
|
+
"code-graph",
|
|
19
|
+
"codebase",
|
|
20
|
+
"ai-tools"
|
|
21
|
+
],
|
|
22
|
+
"bin": {
|
|
23
|
+
"codegraph": "bin/codegraph"
|
|
24
|
+
},
|
|
25
|
+
"scripts": {
|
|
26
|
+
"postinstall": "node install.js"
|
|
27
|
+
},
|
|
28
|
+
"os": ["darwin", "linux"],
|
|
29
|
+
"cpu": ["x64", "arm64"],
|
|
30
|
+
"engines": {
|
|
31
|
+
"node": ">=16"
|
|
32
|
+
},
|
|
33
|
+
"files": [
|
|
34
|
+
"bin/",
|
|
35
|
+
"install.js",
|
|
36
|
+
"README.md"
|
|
37
|
+
]
|
|
38
|
+
}
|