@nothumanwork/cursor-agent-cli 1.0.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 +36 -0
- package/bin/agent.js +21 -0
- package/install.js +120 -0
- package/package.json +35 -0
package/README.md
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# cursor-agent
|
|
2
|
+
|
|
3
|
+
Install the [Cursor Agent CLI](https://cursor.com) via npm.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```sh
|
|
8
|
+
npm i -g cursor-agent
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
This downloads the official Cursor Agent binary for your platform during `postinstall`.
|
|
12
|
+
|
|
13
|
+
## Usage
|
|
14
|
+
|
|
15
|
+
```sh
|
|
16
|
+
agent
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Both `agent` and `cursor-agent` commands are available after installation.
|
|
20
|
+
|
|
21
|
+
## Supported platforms
|
|
22
|
+
|
|
23
|
+
| OS | Architecture |
|
|
24
|
+
|-------|-------------|
|
|
25
|
+
| macOS | x64, arm64 |
|
|
26
|
+
| Linux | x64, arm64 |
|
|
27
|
+
|
|
28
|
+
## Updating
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
npm update -g cursor-agent
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## License
|
|
35
|
+
|
|
36
|
+
MIT
|
package/bin/agent.js
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const path = require("path");
|
|
5
|
+
const { execFileSync } = require("child_process");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
|
|
8
|
+
const binaryPath = path.join(__dirname, "..", "vendor", "cursor-agent");
|
|
9
|
+
|
|
10
|
+
if (!fs.existsSync(binaryPath)) {
|
|
11
|
+
console.error(
|
|
12
|
+
"cursor-agent: binary not found. Run `npm rebuild cursor-agent` to trigger installation."
|
|
13
|
+
);
|
|
14
|
+
process.exit(1);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
execFileSync(binaryPath, process.argv.slice(2), { stdio: "inherit" });
|
|
19
|
+
} catch (err) {
|
|
20
|
+
process.exit(err.status ?? 1);
|
|
21
|
+
}
|
package/install.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
|
|
4
|
+
const https = require("https");
|
|
5
|
+
const http = require("http");
|
|
6
|
+
const fs = require("fs");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
const { execFileSync } = require("child_process");
|
|
9
|
+
const os = require("os");
|
|
10
|
+
|
|
11
|
+
const VERSION = "2026.03.30-a5d3e17";
|
|
12
|
+
const BASE_URL = "https://downloads.cursor.com/lab";
|
|
13
|
+
|
|
14
|
+
function getPlatform() {
|
|
15
|
+
const platform = os.platform();
|
|
16
|
+
switch (platform) {
|
|
17
|
+
case "linux":
|
|
18
|
+
return "linux";
|
|
19
|
+
case "darwin":
|
|
20
|
+
return "darwin";
|
|
21
|
+
default:
|
|
22
|
+
throw new Error(`Unsupported platform: ${platform}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function getArch() {
|
|
27
|
+
const arch = os.arch();
|
|
28
|
+
switch (arch) {
|
|
29
|
+
case "x64":
|
|
30
|
+
return "x64";
|
|
31
|
+
case "arm64":
|
|
32
|
+
return "arm64";
|
|
33
|
+
default:
|
|
34
|
+
throw new Error(`Unsupported architecture: ${arch}`);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function fetch(url) {
|
|
39
|
+
return new Promise((resolve, reject) => {
|
|
40
|
+
const get = url.startsWith("https") ? https.get : http.get;
|
|
41
|
+
get(url, (res) => {
|
|
42
|
+
if (res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
|
|
43
|
+
return fetch(res.headers.location).then(resolve, reject);
|
|
44
|
+
}
|
|
45
|
+
if (res.statusCode !== 200) {
|
|
46
|
+
reject(new Error(`Download failed: HTTP ${res.statusCode} for ${url}`));
|
|
47
|
+
res.resume();
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
resolve(res);
|
|
51
|
+
}).on("error", reject);
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
async function install() {
|
|
56
|
+
const platform = getPlatform();
|
|
57
|
+
const arch = getArch();
|
|
58
|
+
const packageDir = __dirname;
|
|
59
|
+
const vendorDir = path.join(packageDir, "vendor");
|
|
60
|
+
const binaryPath = path.join(vendorDir, "cursor-agent");
|
|
61
|
+
|
|
62
|
+
// Skip if already installed
|
|
63
|
+
if (fs.existsSync(binaryPath)) {
|
|
64
|
+
try {
|
|
65
|
+
execFileSync(binaryPath, ["--version"], { stdio: "ignore" });
|
|
66
|
+
console.log("cursor-agent: binary already installed, skipping download");
|
|
67
|
+
return;
|
|
68
|
+
} catch {
|
|
69
|
+
// Binary exists but doesn't work — re-download
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const url = `${BASE_URL}/${VERSION}/${platform}/${arch}/agent-cli-package.tar.gz`;
|
|
74
|
+
|
|
75
|
+
console.log(`cursor-agent: downloading ${platform}/${arch} binary...`);
|
|
76
|
+
|
|
77
|
+
const tmpDir = path.join(packageDir, `.vendor-tmp-${Date.now()}`);
|
|
78
|
+
fs.mkdirSync(tmpDir, { recursive: true });
|
|
79
|
+
|
|
80
|
+
try {
|
|
81
|
+
const stream = await fetch(url);
|
|
82
|
+
|
|
83
|
+
// Use tar to extract, stripping the top-level directory
|
|
84
|
+
const tar = require("child_process").spawn(
|
|
85
|
+
"tar",
|
|
86
|
+
["--strip-components=1", "-xzf", "-", "-C", tmpDir],
|
|
87
|
+
{ stdio: ["pipe", "inherit", "inherit"] }
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
await new Promise((resolve, reject) => {
|
|
91
|
+
stream.pipe(tar.stdin);
|
|
92
|
+
tar.on("close", (code) => {
|
|
93
|
+
if (code === 0) resolve();
|
|
94
|
+
else reject(new Error(`tar exited with code ${code}`));
|
|
95
|
+
});
|
|
96
|
+
tar.on("error", reject);
|
|
97
|
+
stream.on("error", reject);
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
// Atomically swap into place
|
|
101
|
+
if (fs.existsSync(vendorDir)) {
|
|
102
|
+
fs.rmSync(vendorDir, { recursive: true, force: true });
|
|
103
|
+
}
|
|
104
|
+
fs.renameSync(tmpDir, vendorDir);
|
|
105
|
+
|
|
106
|
+
// Ensure the binary is executable
|
|
107
|
+
fs.chmodSync(binaryPath, 0o755);
|
|
108
|
+
|
|
109
|
+
console.log("cursor-agent: installation complete");
|
|
110
|
+
} catch (err) {
|
|
111
|
+
// Clean up temp dir on failure
|
|
112
|
+
fs.rmSync(tmpDir, { recursive: true, force: true });
|
|
113
|
+
throw err;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
install().catch((err) => {
|
|
118
|
+
console.error(`cursor-agent: ${err.message}`);
|
|
119
|
+
process.exit(1);
|
|
120
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@nothumanwork/cursor-agent-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Cursor Agent CLI — installs the official Cursor Agent binary via npm",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"bin": {
|
|
7
|
+
"agent": "bin/agent.js",
|
|
8
|
+
"cursor-agent": "bin/agent.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"postinstall": "node install.js"
|
|
12
|
+
},
|
|
13
|
+
"os": [
|
|
14
|
+
"darwin",
|
|
15
|
+
"linux"
|
|
16
|
+
],
|
|
17
|
+
"cpu": [
|
|
18
|
+
"x64",
|
|
19
|
+
"arm64"
|
|
20
|
+
],
|
|
21
|
+
"engines": {
|
|
22
|
+
"node": ">=16"
|
|
23
|
+
},
|
|
24
|
+
"files": [
|
|
25
|
+
"install.js",
|
|
26
|
+
"bin/agent.js"
|
|
27
|
+
],
|
|
28
|
+
"keywords": [
|
|
29
|
+
"cursor",
|
|
30
|
+
"agent",
|
|
31
|
+
"cli",
|
|
32
|
+
"ai",
|
|
33
|
+
"coding-agent"
|
|
34
|
+
]
|
|
35
|
+
}
|