|
57 | 57 | console.warn(` ${err.message}`); |
58 | 58 | } |
59 | 59 |
|
| 60 | +// Fetch the distilled static embedding model (best-effort) from the |
| 61 | +// release-independent `model` GitHub release. Only needed for |
| 62 | +// `--embedding-model static`; skipped if already present or if |
| 63 | +// CODEGRAPH_SKIP_MODEL_FETCH is set. Never fails the install. |
| 64 | +if (!process.env.CODEGRAPH_SKIP_MODEL_FETCH) { |
| 65 | + const MODEL = "jina-code-static-256"; |
| 66 | + const modelDir = path.join(os.homedir(), ".codegraph", "static_models", MODEL); |
| 67 | + if (!fs.existsSync(path.join(modelDir, "model.safetensors"))) { |
| 68 | + try { |
| 69 | + fs.mkdirSync(modelDir, { recursive: true }); |
| 70 | + const url = `https://github.com/codegraph-ai/CodeGraph/releases/download/model/${MODEL}.tar.gz`; |
| 71 | + const tgz = path.join(modelDir, "_model.tar.gz"); |
| 72 | + execFileSync("curl", ["-fsSL", url, "-o", tgz], { timeout: 180000 }); |
| 73 | + execFileSync("tar", ["xzf", tgz, "-C", modelDir], { timeout: 60000 }); |
| 74 | + fs.unlinkSync(tgz); |
| 75 | + console.log(`✓ codegraph-mcp: static embedding model ready (${modelDir})`); |
| 76 | + } catch { |
| 77 | + console.warn( |
| 78 | + `ℹ codegraph-mcp: static model not fetched (optional — only for --embedding-model static)` |
| 79 | + ); |
| 80 | + } |
| 81 | + } |
| 82 | +} |
| 83 | + |
60 | 84 | // Hint about the optional Claude Code hook. Installation is opt-in to avoid |
61 | 85 | // silently modifying the user's ~/.claude/settings.json. Both Unix |
62 | 86 | // (bash) and Windows (PowerShell) variants are shipped — the installer |
|
0 commit comments