@navi-agent/navi 0.2.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.
package/README.md ADDED
@@ -0,0 +1,46 @@
1
+ # @navi-agent/navi
2
+
3
+ **Install the [NAVI](https://github.com/navi-ai-org/navi) coding agent CLI via npm.**
4
+
5
+ This package provides the prebuilt `navi` binary for your platform. No Rust toolchain needed.
6
+
7
+ ## Install
8
+
9
+ ```bash
10
+ npm install -g @navi-agent/navi
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ```bash
16
+ # Open the interactive TUI
17
+ navi
18
+
19
+ # Run a task headlessly
20
+ navi --no-tui "explain this codebase"
21
+ ```
22
+
23
+ ## How it works
24
+
25
+ This is a thin wrapper that installs the correct prebuilt binary for your platform via optionalDependencies:
26
+
27
+ - `@navi-agent/navi-linux-x64`
28
+ - `@navi-agent/navi-linux-arm64`
29
+ - `@navi-agent/navi-darwin-x64`
30
+ - `@navi-agent/navi-darwin-arm64`
31
+ - `@navi-agent/navi-win32-x64`
32
+
33
+ If no prebuilt binary is available for your platform, the postinstall script will attempt to download one from GitHub Releases.
34
+
35
+ ## Alternative install methods
36
+
37
+ ```bash
38
+ # Shell installer (primary — no Node required)
39
+ curl -fsSL https://raw.githubusercontent.com/navi-ai-org/navi/main/scripts/install.sh | sh
40
+
41
+ # From source (development)
42
+ cargo install --git https://github.com/navi-ai-org/navi navi-cli
43
+ ```
44
+ ## License
45
+
46
+ Apache-2.0
package/bin/install.js ADDED
@@ -0,0 +1,111 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // Postinstall script for @navi-agent/navi.
5
+ //
6
+ // When a platform-specific optionalDependency is installed, this is a no-op.
7
+ // When installing from the wrapper alone (e.g., `npm pack` without platform
8
+ // packages), this script attempts to download the binary from GitHub Releases.
9
+
10
+ const https = require('node:https');
11
+ const fs = require('node:fs');
12
+ const path = require('node:path');
13
+ const { execSync } = require('node:child_process');
14
+
15
+ const platform = process.platform;
16
+ const arch = process.arch;
17
+ const platformArch = `${platform}-${arch}`;
18
+
19
+ // Check if the platform binary is already available (via optionalDependency)
20
+ function hasPlatformBinary() {
21
+ try {
22
+ require.resolve(`@navi-agent/navi-${platformArch}/package.json`);
23
+ return true;
24
+ } catch {
25
+ return false;
26
+ }
27
+ }
28
+
29
+ // Also check if a local binary exists next to the package root
30
+ function hasLocalBinary() {
31
+ const binName = platform === 'win32' ? 'navi.exe' : 'navi';
32
+ return fs.existsSync(path.join(__dirname, '..', binName));
33
+ }
34
+
35
+ if (hasPlatformBinary() || hasLocalBinary()) {
36
+ // Binary already available — nothing to do
37
+ process.exit(0);
38
+ }
39
+
40
+ // ── Fallback: download from GitHub Releases ──────────────────────────────────
41
+
42
+ const PACKAGE_VERSION = require('../package.json').version;
43
+ const REPO = 'navi-ai-org/navi';
44
+
45
+ function getArchiveName() {
46
+ const ext = platform === 'win32' ? 'zip' : 'tar.gz';
47
+ return `navi-${platformArch}.${ext}`;
48
+ }
49
+
50
+ function getDownloadUrl(version) {
51
+ return `https://github.com/${REPO}/releases/download/v${version}/${getArchiveName()}`;
52
+ }
53
+
54
+ function download(url) {
55
+ return new Promise((resolve, reject) => {
56
+ const follow = (redirectUrl, depth = 0) => {
57
+ if (depth > 5) return reject(new Error('Too many redirects'));
58
+ https.get(redirectUrl, (res) => {
59
+ if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
60
+ follow(res.headers.location, depth + 1);
61
+ return;
62
+ }
63
+ if (res.statusCode !== 200) {
64
+ reject(new Error(`HTTP ${res.statusCode}`));
65
+ return;
66
+ }
67
+ const chunks = [];
68
+ res.on('data', (chunk) => chunks.push(chunk));
69
+ res.on('end', () => resolve(Buffer.concat(chunks)));
70
+ res.on('error', reject);
71
+ }).on('error', reject);
72
+ };
73
+ follow(url);
74
+ });
75
+ }
76
+
77
+ async function main() {
78
+ const version = PACKAGE_VERSION;
79
+ const url = getDownloadUrl(version);
80
+
81
+ console.log(`@navi-agent/navi: downloading navi v${version} for ${platformArch}...`);
82
+
83
+ try {
84
+ const archive = await download(url);
85
+ const tmpDir = require('node:os').tmpdir();
86
+ const archivePath = path.join(tmpDir, `${platformArch}-${version}-${getArchiveName()}`);
87
+
88
+ fs.writeFileSync(archivePath, archive);
89
+
90
+ // Extract
91
+ if (platform === 'win32') {
92
+ execSync(`powershell -Command "Expand-Archive -Path '${archivePath}' -DestinationPath '${path.join(__dirname, '..')}' -Force"`, { stdio: 'inherit' });
93
+ } else {
94
+ execSync(`tar -xzf "${archivePath}" -C "${path.join(__dirname, '..')}"`, { stdio: 'inherit' });
95
+ }
96
+
97
+ // Clean up
98
+ try { fs.unlinkSync(archivePath); } catch {}
99
+
100
+ console.log(`@navi-agent/navi: installed navi binary for ${platformArch}`);
101
+ } catch (err) {
102
+ console.warn(`@navi-agent/navi: could not download prebuilt binary: ${err.message}`);
103
+ console.warn('');
104
+ console.warn('The navi CLI may not be available. You can install it via:');
105
+ console.warn(' cargo install navi-cli');
106
+ console.warn(` curl -fsSL https://raw.githubusercontent.com/navi-ai-org/navi/main/scripts/install.sh | sh`);
107
+ // Don't fail install — the user might install the binary separately
108
+ }
109
+ }
110
+
111
+ main();
package/bin/navi.js ADDED
@@ -0,0 +1,90 @@
1
+ #!/usr/bin/env node
2
+ 'use strict';
3
+
4
+ // CLI wrapper — resolves the platform-specific navi binary and exec's it.
5
+ // This file is what `npm install -g @navi-agent/navi` puts in PATH as `navi`.
6
+
7
+ const { execFileSync } = require('node:child_process');
8
+ const fs = require('node:fs');
9
+ const path = require('node:path');
10
+
11
+ const platform = process.platform;
12
+ const arch = process.arch;
13
+ const platformArch = `${platform}-${arch}`;
14
+ const isWindows = platform === 'win32';
15
+
16
+ // ---------------------------------------------------------------------------
17
+ // Binary resolution order:
18
+ //
19
+ // 1. NAVI_BINARY env var (explicit override).
20
+ // 2. Platform-specific optionalDependency (@navi-agent/navi-<platform>-<arch>).
21
+ // 3. Local binary next to this script.
22
+ // ---------------------------------------------------------------------------
23
+
24
+ function findBinary() {
25
+ const candidates = [];
26
+
27
+ // 1. Explicit env override
28
+ if (process.env.NAVI_BINARY) {
29
+ candidates.push(process.env.NAVI_BINARY);
30
+ }
31
+
32
+ // 2. Platform-specific optionalDependency
33
+ try {
34
+ const pkg = `@navi-agent/navi-${platformArch}`;
35
+ const pkgDir = path.dirname(require.resolve(`${pkg}/package.json`));
36
+ const binName = isWindows ? 'navi.exe' : 'navi';
37
+ candidates.push(path.join(pkgDir, binName));
38
+ } catch {
39
+ // optionalDependency not installed — expected on unsupported platforms
40
+ }
41
+
42
+ // 3. Local binary next to this script
43
+ const localBin = isWindows ? 'navi.exe' : 'navi';
44
+ candidates.push(path.join(__dirname, '..', localBin));
45
+
46
+ for (const candidate of candidates) {
47
+ if (candidate && fs.existsSync(candidate)) {
48
+ return candidate;
49
+ }
50
+ }
51
+
52
+ return null;
53
+ }
54
+
55
+ const binary = findBinary();
56
+
57
+ if (!binary) {
58
+ console.error(
59
+ [
60
+ 'Unable to find the navi binary.',
61
+ '',
62
+ `Platform: ${platform} ${arch}`,
63
+ '',
64
+ 'This usually means the prebuilt binary for your platform was not installed.',
65
+ '',
66
+ 'To resolve this:',
67
+ ' 1. Try reinstalling: npm install -g @navi-agent/navi',
68
+ ' 2. Or install via cargo: cargo install navi-cli',
69
+ ' 3. Or use the shell installer: curl -fsSL https://raw.githubusercontent.com/navi-ai-org/navi/main/scripts/install.sh | sh',
70
+ '',
71
+ `Expected package: @navi-agent/navi-${platformArch}`,
72
+ ].join('\n'),
73
+ );
74
+ process.exit(1);
75
+ }
76
+
77
+ // Forward all arguments to the real binary
78
+ const args = process.argv.slice(2);
79
+
80
+ try {
81
+ const result = isWindows
82
+ ? execFileSync(binary, args, { stdio: 'inherit' })
83
+ : execFileSync(binary, args, { stdio: 'inherit' });
84
+ process.exit(0);
85
+ } catch (err) {
86
+ if (err.status !== undefined) {
87
+ process.exit(err.status);
88
+ }
89
+ throw err;
90
+ }
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@navi-agent/navi",
3
+ "version": "0.2.2",
4
+ "description": "The coding agent engine that lives in your terminal. Install the navi CLI binary.",
5
+ "license": "Apache-2.0",
6
+ "author": "NAVI Contributors",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/navi-ai-org/navi.git"
10
+ },
11
+ "homepage": "https://github.com/navi-ai-org/navi",
12
+ "bugs": {
13
+ "url": "https://github.com/navi-ai-org/navi/issues"
14
+ },
15
+ "keywords": [
16
+ "navi",
17
+ "agent",
18
+ "cli",
19
+ "llm",
20
+ "ai",
21
+ "coding",
22
+ "terminal",
23
+ "rust"
24
+ ],
25
+ "bin": {
26
+ "navi": "bin/navi.js"
27
+ },
28
+ "files": [
29
+ "bin/",
30
+ "README.md"
31
+ ],
32
+ "scripts": {
33
+ "postinstall": "node bin/install.js"
34
+ },
35
+ "engines": {
36
+ "node": ">=18"
37
+ },
38
+ "os": [
39
+ "linux",
40
+ "darwin",
41
+ "win32"
42
+ ],
43
+ "cpu": [
44
+ "x64",
45
+ "arm64"
46
+ ],
47
+ "optionalDependencies": {
48
+ "@navi-agent/navi-linux-x64": "0.2.2",
49
+ "@navi-agent/navi-linux-arm64": "0.2.2",
50
+ "@navi-agent/navi-darwin-x64": "0.2.2",
51
+ "@navi-agent/navi-darwin-arm64": "0.2.2",
52
+ "@navi-agent/navi-win32-x64": "0.2.2"
53
+ },
54
+ "publishConfig": {
55
+ "access": "public",
56
+ "registry": "https://registry.npmjs.org/"
57
+ },
58
+ "sideEffects": false
59
+ }