basemind 0.2.1__py3-none-any.whl

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.
basemind/__init__.py ADDED
@@ -0,0 +1,5 @@
1
+ """
2
+ basemind: Code-map MCP server + scanner — content-addressed, Fjall-backed inverted index over tree-sitter outlines.
3
+ """
4
+
5
+ __version__ = "0.2.1"
basemind/cli.py ADDED
@@ -0,0 +1,15 @@
1
+ """CLI entry point for basemind."""
2
+
3
+ import sys
4
+
5
+ from .downloader import run_basemind
6
+
7
+
8
+ def main():
9
+ """Main entry point for the CLI."""
10
+ args = sys.argv[1:]
11
+ run_basemind(args)
12
+
13
+
14
+ if __name__ == "__main__":
15
+ main()
basemind/downloader.py ADDED
@@ -0,0 +1,133 @@
1
+ from __future__ import annotations
2
+
3
+ import os
4
+ import platform
5
+ import ssl
6
+ import subprocess
7
+ import sys
8
+ import tempfile
9
+ import tarfile
10
+ import zipfile
11
+ from pathlib import Path
12
+ from urllib.error import URLError
13
+ from urllib.request import Request, urlopen
14
+
15
+ import certifi
16
+
17
+
18
+ def _platform_triple() -> str:
19
+ system = platform.system().lower()
20
+ machine = platform.machine().lower()
21
+
22
+ if system == "windows":
23
+ if machine in {"amd64", "x86_64"}:
24
+ return "x86_64-pc-windows-gnu"
25
+ if machine in {"x86", "i386", "i686"}:
26
+ raise RuntimeError("32-bit Windows is not supported")
27
+ elif system == "linux":
28
+ if machine in {"amd64", "x86_64"}:
29
+ return "x86_64-unknown-linux-gnu"
30
+ if machine in {"aarch64", "arm64"}:
31
+ return "aarch64-unknown-linux-gnu"
32
+ elif system == "darwin":
33
+ if machine in {"amd64", "x86_64"}:
34
+ return "x86_64-apple-darwin"
35
+ if machine in {"aarch64", "arm64"}:
36
+ return "aarch64-apple-darwin"
37
+
38
+ raise RuntimeError(f"Unsupported platform: {system} {machine}")
39
+
40
+
41
+ def _python_version_to_tag(version: str) -> str:
42
+ if "rc" in version:
43
+ core, suffix = version.split("rc")
44
+ return f"{core}-rc.{suffix}"
45
+ return version
46
+
47
+
48
+ def _asset(version: str) -> tuple[str, str]:
49
+ tag = _python_version_to_tag(version)
50
+ triple = _platform_triple()
51
+ ext = "zip" if "windows" in triple else "tar.gz"
52
+ url = (
53
+ f"https://github.com/Goldziher/basemind/releases/download/"
54
+ f"v{tag}/basemind-{triple}.{ext}"
55
+ )
56
+ return url, ext
57
+
58
+
59
+ def _download(url: str, destination: Path) -> None:
60
+ request = Request(url, headers={"User-Agent": "basemind-python-wrapper"})
61
+ context = ssl.create_default_context(cafile=certifi.where())
62
+ try:
63
+ with urlopen(request, timeout=30, context=context) as response:
64
+ if response.status != 200:
65
+ raise RuntimeError(f"HTTP {response.status}: {response.reason}")
66
+ destination.write_bytes(response.read())
67
+ except URLError as exc:
68
+ raise RuntimeError(f"Failed to download binary: {exc}") from exc
69
+
70
+
71
+ def _extract(archive: Path, ext: str, destination: Path) -> None:
72
+ if ext == "zip":
73
+ with zipfile.ZipFile(archive) as zf:
74
+ for name in zf.namelist():
75
+ if name.endswith("basemind") or name.endswith("basemind.exe"):
76
+ with zf.open(name) as src, destination.open("wb") as dst:
77
+ dst.write(src.read())
78
+ return
79
+ else:
80
+ with tarfile.open(archive, "r:gz") as tar:
81
+ for member in tar.getmembers():
82
+ if member.name.endswith("basemind") or member.name.endswith("basemind.exe"):
83
+ with tar.extractfile(member) as src, destination.open("wb") as dst:
84
+ dst.write(src.read())
85
+ return
86
+ raise RuntimeError("Binary not found in downloaded archive")
87
+
88
+
89
+ def _cache_path(version: str) -> Path:
90
+ cache_dir = Path.home() / ".cache" / "basemind" / version
91
+ cache_dir.mkdir(parents=True, exist_ok=True)
92
+ suffix = ".exe" if platform.system().lower() == "windows" else ""
93
+ return cache_dir / f"basemind{suffix}"
94
+
95
+
96
+ def ensure_binary():
97
+ """Ensure the binary is available, downloading if necessary."""
98
+ from . import __version__
99
+
100
+ override = os.getenv("BASEMIND_BINARY")
101
+ if override:
102
+ return override
103
+
104
+ binary_path = _cache_path(__version__)
105
+ if binary_path.exists() and os.access(binary_path, os.X_OK):
106
+ return str(binary_path)
107
+
108
+ url, ext = _asset(__version__)
109
+ print(f"Downloading basemind binary v{__version__}...", file=sys.stderr)
110
+
111
+ with tempfile.TemporaryDirectory() as tmpdir:
112
+ archive_path = Path(tmpdir) / f"basemind.{ext}"
113
+ _download(url, archive_path)
114
+ _extract(archive_path, ext, binary_path)
115
+
116
+ if platform.system().lower() != "windows":
117
+ binary_path.chmod(0o755)
118
+
119
+ print("Binary downloaded successfully!", file=sys.stderr)
120
+ return str(binary_path)
121
+
122
+
123
+ def run_basemind(args):
124
+ """Run the basemind binary with the given arguments."""
125
+ binary_path = ensure_binary()
126
+
127
+ try:
128
+ result = subprocess.run([binary_path] + args, check=False)
129
+ sys.exit(result.returncode)
130
+ except FileNotFoundError:
131
+ raise RuntimeError(f"Binary not found at {binary_path}")
132
+ except Exception as e:
133
+ raise RuntimeError(f"Failed to run basemind: {e}")
@@ -0,0 +1,67 @@
1
+ Metadata-Version: 2.1
2
+ Name: basemind
3
+ Version: 0.2.1
4
+ Summary: Full AI context layer over MCP — tree-sitter code-map, document RAG (PDF/Office/HTML/email + OCR + reranker), shared agent memory, on-demand web crawl, git history + blame + per-symbol diff. 300+ languages, 8 coding-agent harnesses, content-addressed Fjall + LanceDB.
5
+ Author-email: Na'aman Hirschfeld <nhirschfeld@gmail.com>
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/Goldziher/basemind
8
+ Project-URL: Repository, https://github.com/Goldziher/basemind.git
9
+ Project-URL: Issues, https://github.com/Goldziher/basemind/issues
10
+ Keywords: mcp,agent-context,rag,code-map,tree-sitter
11
+ Classifier: Development Status :: 4 - Beta
12
+ Classifier: Intended Audience :: Developers
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Programming Language :: Python :: 3
15
+ Classifier: Programming Language :: Python :: 3.8
16
+ Classifier: Programming Language :: Python :: 3.9
17
+ Classifier: Programming Language :: Python :: 3.10
18
+ Classifier: Programming Language :: Python :: 3.11
19
+ Classifier: Programming Language :: Python :: 3.12
20
+ Classifier: Programming Language :: Python :: 3.13
21
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
22
+ Classifier: Topic :: Software Development :: Code Generators
23
+ Classifier: Environment :: Console
24
+ Requires-Python: >=3.8
25
+ Description-Content-Type: text/markdown
26
+ Requires-Dist: certifi>=2024.7.4
27
+
28
+ # basemind
29
+
30
+ Full AI context layer for coding agents — code-map, document RAG, shared memory, web crawl,
31
+ git history. 300+ languages, one MCP server.
32
+
33
+ <!-- markdownlint-disable-next-line MD013 -->
34
+ [![License: MIT](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/Goldziher/basemind/blob/main/LICENSE)
35
+ [![PyPI](https://img.shields.io/pypi/v/basemind.svg)](https://pypi.org/project/basemind/)
36
+
37
+ ## Install
38
+
39
+ ```bash
40
+ pip install basemind
41
+ ```
42
+
43
+ On first invocation, the pre-compiled Rust binary for your platform (macOS, Linux, Windows;
44
+ x86_64 + arm64) is downloaded from
45
+ [GitHub Releases](https://github.com/Goldziher/basemind/releases) and cached under
46
+ `~/.cache/basemind/<version>/`.
47
+
48
+ Override the binary location with `BASEMIND_BINARY=/path/to/basemind`.
49
+
50
+ ## Quickstart
51
+
52
+ ```bash
53
+ cd /path/to/your/repo
54
+ basemind scan # index the working tree
55
+ basemind serve # run the MCP stdio server
56
+ ```
57
+
58
+ Wire `basemind serve` into Claude Code or any MCP client.
59
+
60
+ ## Full documentation
61
+
62
+ See the [main README](https://github.com/Goldziher/basemind#readme) for complete docs,
63
+ architecture, MCP tool reference, and per-harness setup instructions.
64
+
65
+ ## License
66
+
67
+ [MIT](https://github.com/Goldziher/basemind/blob/main/LICENSE).
@@ -0,0 +1,8 @@
1
+ basemind/__init__.py,sha256=7q0OZVqcw3jrBWjRexj249ByXoFSbBtTRU80pPpxn1o,149
2
+ basemind/cli.py,sha256=yKfxm1GBq9uZwTrLeNSDFZgdrFsOOGVVnHIJXTlWCv8,227
3
+ basemind/downloader.py,sha256=6xf1PPkFmsoVIHJSaTdbGJyxiSuzAyAnsAZvNJ8s_js,4464
4
+ basemind-0.2.1.dist-info/METADATA,sha256=cFAcyweYhJP-7n_oN2Os5kVk5mll_VTlqyNmdrcdsJk,2640
5
+ basemind-0.2.1.dist-info/WHEEL,sha256=BNRMDyzLkkcmlv0J8ppDQkk2VED33SesJDynr9ED1gc,91
6
+ basemind-0.2.1.dist-info/entry_points.txt,sha256=etoC-7zCcRjKT3Ie0sSzWI_cYUigtd2vk8dNfHIa_8A,47
7
+ basemind-0.2.1.dist-info/top_level.txt,sha256=uAaKHxi1hnhqokG_Z6VD1T48e1vYcRzziZWf7nwu0a0,9
8
+ basemind-0.2.1.dist-info/RECORD,,
@@ -0,0 +1,5 @@
1
+ Wheel-Version: 1.0
2
+ Generator: setuptools (75.3.4)
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
5
+
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ basemind = basemind.cli:main
@@ -0,0 +1 @@
1
+ basemind