@sansavision/atlas 0.1.0

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 ADDED
@@ -0,0 +1,64 @@
1
+ # atlas-context
2
+
3
+ > Atlas Context Engine — MCP-native context engine for AI coding agents.
4
+
5
+ This npm package is a thin wrapper around the native `atlas` and `atlas-mcp` binaries.
6
+ The correct binary for your platform is fetched automatically during `npm install`.
7
+
8
+ ## Requirements
9
+
10
+ - Node.js ≥ 18
11
+ - Internet access during install (binary is downloaded from GitHub Releases)
12
+
13
+ ## Installation
14
+
15
+ ```bash
16
+ npm install -g atlas-context
17
+ # or locally in a project
18
+ npm install atlas-context
19
+ ```
20
+
21
+ ## CLI usage
22
+
23
+ ```bash
24
+ # Index a repository
25
+ atlas index /path/to/repo
26
+
27
+ # Start the MCP server (stdio transport)
28
+ atlas-mcp
29
+
30
+ # Start the MCP server (HTTP transport on port 8080)
31
+ atlas-mcp --port 8080
32
+
33
+ # Run full help
34
+ atlas --help
35
+ atlas-mcp --help
36
+ ```
37
+
38
+ ## Programmatic usage (Node.js)
39
+
40
+ ```js
41
+ const { startMcpServer } = require('atlas-context');
42
+
43
+ // Spawn atlas-mcp in the current working directory
44
+ const server = startMcpServer(['--port', '8080']);
45
+ server.on('close', (code) => console.log(`atlas-mcp exited with code ${code}`));
46
+ ```
47
+
48
+ ## Supported platforms
49
+
50
+ | Platform | Target triple |
51
+ |------------------|---------------------------------|
52
+ | Linux x86_64 | `x86_64-unknown-linux-musl` |
53
+ | macOS arm64 | `aarch64-apple-darwin` |
54
+ | macOS x86_64 | `x86_64-apple-darwin` |
55
+ | Windows x86_64 | `x86_64-pc-windows-msvc` |
56
+
57
+ ## Building from source
58
+
59
+ See the [main repository](https://github.com/atlas-context/atlas#building) for
60
+ Rust build instructions.
61
+
62
+ ## License
63
+
64
+ MIT
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ // bin/atlas-mcp.js — thin shim: exec the native atlas-mcp binary (MCP server).
3
+
4
+ "use strict";
5
+
6
+ const { spawnSync } = require("child_process");
7
+ const os = require("os");
8
+ const path = require("path");
9
+ const fs = require("fs");
10
+
11
+ const name = os.platform() === "win32" ? "atlas-mcp.exe" : "atlas-mcp";
12
+ const binary = path.join(__dirname, name);
13
+
14
+ if (!fs.existsSync(binary)) {
15
+ console.error(
16
+ "atlas-mcp: native binary not found.\n" +
17
+ "Try reinstalling: npm install atlas-context\n" +
18
+ "Or build from source: https://github.com/atlas-context/atlas#building",
19
+ );
20
+ process.exit(1);
21
+ }
22
+
23
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
24
+
25
+ if (result.error) {
26
+ console.error("atlas-mcp: failed to launch binary:", result.error.message);
27
+ process.exit(1);
28
+ }
29
+
30
+ process.exit(result.status ?? 0);
package/bin/atlas.js ADDED
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env node
2
+ // bin/atlas.js — thin shim: exec the native atlas binary.
3
+
4
+ "use strict";
5
+
6
+ const { spawnSync } = require("child_process");
7
+ const os = require("os");
8
+ const path = require("path");
9
+ const fs = require("fs");
10
+
11
+ const name = os.platform() === "win32" ? "atlas.exe" : "atlas";
12
+ const binary = path.join(__dirname, name);
13
+
14
+ if (!fs.existsSync(binary)) {
15
+ console.error(
16
+ "atlas: native binary not found.\n" +
17
+ "Try reinstalling: npm install @sansavision/atlas\n" +
18
+ "Or build from source: https://github.com/sansavision/atlas#building",
19
+ );
20
+ process.exit(1);
21
+ }
22
+
23
+ const result = spawnSync(binary, process.argv.slice(2), { stdio: "inherit" });
24
+
25
+ if (result.error) {
26
+ console.error("atlas: failed to launch binary:", result.error.message);
27
+ process.exit(1);
28
+ }
29
+
30
+ process.exit(result.status ?? 0);
package/index.js ADDED
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+
3
+ /**
4
+ * atlas-context — programmatic Node.js interface.
5
+ *
6
+ * For most use-cases you only need the CLI binaries (`atlas` / `atlas-mcp`)
7
+ * that are installed into your PATH. Import this module when you want to
8
+ * launch the MCP server from Node code.
9
+ */
10
+
11
+ const { spawn } = require("child_process");
12
+ const os = require("os");
13
+ const path = require("path");
14
+
15
+ /**
16
+ * Absolute path to the `atlas` CLI binary for the current platform.
17
+ * Returns null when the binary hasn't been downloaded yet.
18
+ *
19
+ * @returns {string|null}
20
+ */
21
+ function binaryPath() {
22
+ const name = os.platform() === "win32" ? "atlas.exe" : "atlas";
23
+ const p = path.join(__dirname, "bin", name);
24
+ try {
25
+ require("fs").accessSync(p);
26
+ return p;
27
+ } catch {
28
+ return null;
29
+ }
30
+ }
31
+
32
+ /**
33
+ * Absolute path to the `atlas-mcp` MCP server binary.
34
+ * Returns null when the binary hasn't been downloaded yet.
35
+ *
36
+ * @returns {string|null}
37
+ */
38
+ function mcpBinaryPath() {
39
+ const name = os.platform() === "win32" ? "atlas-mcp.exe" : "atlas-mcp";
40
+ const p = path.join(__dirname, "bin", name);
41
+ try {
42
+ require("fs").accessSync(p);
43
+ return p;
44
+ } catch {
45
+ return null;
46
+ }
47
+ }
48
+
49
+ /**
50
+ * Launch the `atlas-mcp` MCP server and return the child process.
51
+ *
52
+ * @param {string[]} [args] Extra CLI arguments (e.g. ['--port', '8080'])
53
+ * @param {object} [opts] Options forwarded to `child_process.spawn`
54
+ * @returns {import('child_process').ChildProcess}
55
+ */
56
+ function startMcpServer(args = [], opts = {}) {
57
+ const bin = mcpBinaryPath();
58
+ if (!bin) {
59
+ throw new Error(
60
+ "atlas-mcp binary not found. " +
61
+ "Reinstall the package to trigger the download: npm install atlas-context",
62
+ );
63
+ }
64
+ return spawn(bin, args, { stdio: "inherit", ...opts });
65
+ }
66
+
67
+ module.exports = { binaryPath, mcpBinaryPath, startMcpServer };
package/install.js ADDED
@@ -0,0 +1,120 @@
1
+ #!/usr/bin/env node
2
+ // postinstall — download the correct Atlas binary for the current platform.
3
+
4
+ "use strict";
5
+
6
+ const os = require("os");
7
+ const fs = require("fs");
8
+ const path = require("path");
9
+ const https = require("https");
10
+ const { execFileSync } = require("child_process");
11
+
12
+ // ── Platform detection ───────────────────────────────────────────────────────
13
+
14
+ /** Map Node's (platform, arch) to the Rust target triple used in release archives. */
15
+ function detectTarget() {
16
+ const p = os.platform();
17
+ const a = os.arch();
18
+
19
+ if (p === "linux" && a === "x64") return "x86_64-unknown-linux-musl";
20
+ if (p === "darwin" && a === "arm64") return "aarch64-apple-darwin";
21
+ if (p === "darwin" && a === "x64") return "x86_64-apple-darwin";
22
+ if (p === "win32" && a === "x64") return "x86_64-pc-windows-msvc";
23
+
24
+ throw new Error(
25
+ `Unsupported platform: ${p}/${a}. ` +
26
+ "See https://github.com/atlas-context/atlas for build-from-source instructions.",
27
+ );
28
+ }
29
+
30
+ // ── Helpers ──────────────────────────────────────────────────────────────────
31
+
32
+ function downloadTo(url, destPath) {
33
+ return new Promise((resolve, reject) => {
34
+ const file = fs.createWriteStream(destPath);
35
+
36
+ function get(u) {
37
+ https
38
+ .get(u, (res) => {
39
+ if (res.statusCode === 301 || res.statusCode === 302) {
40
+ return get(res.headers.location);
41
+ }
42
+ if (res.statusCode !== 200) {
43
+ return reject(new Error(`HTTP ${res.statusCode} downloading ${u}`));
44
+ }
45
+ res.pipe(file);
46
+ file.on("finish", () => file.close(resolve));
47
+ })
48
+ .on("error", reject);
49
+ }
50
+
51
+ get(url);
52
+ });
53
+ }
54
+
55
+ async function extractArchive(archivePath, destDir) {
56
+ if (archivePath.endsWith(".tar.gz")) {
57
+ // Use the system tar — available on Linux, macOS, and Windows 10+
58
+ execFileSync(
59
+ "tar",
60
+ ["xzf", archivePath, "-C", destDir, "atlas", "atlas-mcp"],
61
+ { stdio: "inherit" },
62
+ );
63
+ } else if (archivePath.endsWith(".zip")) {
64
+ // Node 18+ has a built-in unzip via child process; fall back to PowerShell
65
+ execFileSync(
66
+ "powershell",
67
+ [
68
+ "-NoProfile",
69
+ "-Command",
70
+ `Expand-Archive -Path "${archivePath}" -DestinationPath "${destDir}" -Force`,
71
+ ],
72
+ { stdio: "inherit" },
73
+ );
74
+ } else {
75
+ throw new Error(`Unknown archive format: ${archivePath}`);
76
+ }
77
+ }
78
+
79
+ // ── Main ─────────────────────────────────────────────────────────────────────
80
+
81
+ async function main() {
82
+ const pkg = require("./package.json");
83
+ const version = pkg.version;
84
+ const target = detectTarget();
85
+ const isWindows = os.platform() === "win32";
86
+ const ext = isWindows ? ".zip" : ".tar.gz";
87
+
88
+ const archiveName = `atlas-v${version}-${target}${ext}`;
89
+ const downloadUrl = `https://github.com/sansavision/atlas/releases/download/v${version}/${archiveName}`;
90
+
91
+ const binDir = path.join(__dirname, "bin");
92
+ fs.mkdirSync(binDir, { recursive: true });
93
+
94
+ const tmpArchive = path.join(os.tmpdir(), archiveName);
95
+
96
+ console.log(`atlas-context: downloading ${archiveName}…`);
97
+
98
+ try {
99
+ await downloadTo(downloadUrl, tmpArchive);
100
+ await extractArchive(tmpArchive, binDir);
101
+ fs.rmSync(tmpArchive, { force: true });
102
+
103
+ // Make binaries executable on POSIX
104
+ if (!isWindows) {
105
+ fs.chmodSync(path.join(binDir, "atlas"), 0o755);
106
+ fs.chmodSync(path.join(binDir, "atlas-mcp"), 0o755);
107
+ }
108
+
109
+ console.log("atlas-context: binaries installed successfully.");
110
+ } catch (err) {
111
+ // Non-fatal: user can still build from source
112
+ console.warn(`atlas-context: binary download failed — ${err.message}`);
113
+ console.warn(
114
+ "You can build from source: https://github.com/sansavision/atlas#building",
115
+ );
116
+ process.exit(0); // Don't fail `npm install`
117
+ }
118
+ }
119
+
120
+ main();
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@sansavision/atlas",
3
+ "version": "0.1.0",
4
+ "description": "Atlas Context Engine — MCP-native context engine for AI coding agents",
5
+ "private": false,
6
+ "publishConfig": {
7
+ "access": "restricted",
8
+ "registry": "https://registry.npmjs.org"
9
+ },
10
+ "keywords": [
11
+ "mcp",
12
+ "model-context-protocol",
13
+ "ai",
14
+ "context",
15
+ "coding-agent",
16
+ "llm"
17
+ ],
18
+ "homepage": "https://github.com/sansavision/atlas",
19
+ "repository": {
20
+ "type": "git",
21
+ "url": "https://github.com/sansavision/atlas.git"
22
+ },
23
+ "bugs": {
24
+ "url": "https://github.com/sansavision/atlas/issues"
25
+ },
26
+ "license": "MIT",
27
+ "engines": {
28
+ "node": ">=18"
29
+ },
30
+ "bin": {
31
+ "atlas": "./bin/atlas.js",
32
+ "atlas-mcp": "./bin/atlas-mcp.js"
33
+ },
34
+ "scripts": {
35
+ "postinstall": "node install.js"
36
+ },
37
+ "files": [
38
+ "install.js",
39
+ "bin/",
40
+ "index.js",
41
+ "README.md"
42
+ ]
43
+ }