@magnet-ai/cli 0.1.3 → 0.1.4
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/LICENSE +21 -0
- package/README.md +85 -21
- package/bin/{download.js → download.cjs} +4 -5
- package/bin/{magnet.js → magnet.cjs} +1 -1
- package/package.json +18 -10
- package/bin/magnet +0 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Magnet (Toolkit)
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,46 +1,110 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Magnet CLI
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A self-sufficient CLI for [Magnet](https://www.magnet.run): list, get, and create issues and pages, and search. Single native binary — **no Node.js or other runtime required**.
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## Requirements
|
|
6
|
+
|
|
7
|
+
- **API key**: Create an API key in your Magnet organization settings, then set it:
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
export MAGNET_API_KEY="your-uuid-api-key"
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
- **Base URL** (optional): Default is `https://www.magnet.run`. Override with:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
export MAGNET_API_URL="https://www.magnet.run"
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Installation
|
|
20
|
+
|
|
21
|
+
Choose one of the following. No Node.js is required unless you use the npm installer.
|
|
22
|
+
|
|
23
|
+
### 1. GitHub Releases (recommended)
|
|
24
|
+
|
|
25
|
+
Download the binary for your platform from [Releases](https://github.com/toolkit-ai/magnet-cli/releases). Extract and put `magnet` (or `magnet.exe` on Windows) in your `PATH`.
|
|
26
|
+
|
|
27
|
+
**Example (Linux/macOS):**
|
|
6
28
|
|
|
7
29
|
```bash
|
|
8
|
-
|
|
30
|
+
VERSION="v0.1.0"
|
|
31
|
+
PLATFORM="darwin-arm64" # or linux-amd64, windows-amd64
|
|
32
|
+
curl -sSL "https://github.com/toolkit-ai/magnet-cli/releases/download/${VERSION}/magnet-cli-${PLATFORM}.tar.gz" | tar xz
|
|
33
|
+
sudo mv magnet /usr/local/bin/
|
|
9
34
|
```
|
|
10
35
|
|
|
11
|
-
|
|
36
|
+
**Windows (PowerShell):**
|
|
12
37
|
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
magnet
|
|
16
|
-
|
|
38
|
+
```powershell
|
|
39
|
+
$VERSION = "v0.1.0"
|
|
40
|
+
Invoke-WebRequest -Uri "https://github.com/toolkit-ai/magnet-cli/releases/download/$VERSION/magnet-cli-windows-amd64.tar.gz" -OutFile magnet-cli.tar.gz
|
|
41
|
+
tar -xzf magnet-cli.tar.gz
|
|
42
|
+
# Move magnet.exe to a folder in PATH
|
|
17
43
|
```
|
|
18
44
|
|
|
19
|
-
|
|
45
|
+
### 2. npm (wrapper that downloads the binary)
|
|
20
46
|
|
|
21
|
-
|
|
47
|
+
If you have Node.js and npm:
|
|
22
48
|
|
|
23
49
|
```bash
|
|
24
|
-
|
|
50
|
+
npm install -g @magnet-ai/cli
|
|
25
51
|
```
|
|
26
52
|
|
|
27
|
-
|
|
53
|
+
Install finishes quickly; the first time you run `magnet`, it downloads the binary. You do **not** need Node to run the CLI afterward.
|
|
54
|
+
|
|
55
|
+
### 3. Homebrew (macOS/Linux)
|
|
56
|
+
|
|
57
|
+
_(Coming soon. Add when the tap is set up.)_
|
|
28
58
|
|
|
29
|
-
|
|
59
|
+
### 4. Build from source
|
|
30
60
|
|
|
31
|
-
|
|
61
|
+
Requires [Bun](https://bun.sh).
|
|
32
62
|
|
|
33
63
|
```bash
|
|
34
|
-
|
|
35
|
-
|
|
64
|
+
git clone https://github.com/toolkit-ai/magnet-cli.git
|
|
65
|
+
cd magnet-cli
|
|
66
|
+
bun install
|
|
67
|
+
bun run build
|
|
68
|
+
./magnet --help
|
|
36
69
|
```
|
|
37
70
|
|
|
38
|
-
|
|
71
|
+
For development, testing, and release workflow, see [CONTRIBUTING.md](CONTRIBUTING.md).
|
|
39
72
|
|
|
40
|
-
##
|
|
73
|
+
## Commands
|
|
41
74
|
|
|
42
|
-
|
|
75
|
+
### Issues
|
|
76
|
+
|
|
77
|
+
- **List**: `magnet issues list [--search q] [--limit n] [--cursor c]`
|
|
78
|
+
Pagination: use `--limit` and `--cursor` (from `pagination.nextCursor`) for the next page.
|
|
79
|
+
|
|
80
|
+
- **Get**: `magnet issues get <id>`
|
|
81
|
+
|
|
82
|
+
- **Create**: `magnet issues create --description "..." [--title "..."] [--base-branch main]`
|
|
83
|
+
|
|
84
|
+
### Pages
|
|
85
|
+
|
|
86
|
+
- **List**: `magnet pages list [--search q] [--limit n] [--cursor c]`
|
|
87
|
+
|
|
88
|
+
- **Get**: `magnet pages get <id>`
|
|
89
|
+
|
|
90
|
+
- **Create**: `magnet pages create --title "..." [--markdown "..."]`
|
|
91
|
+
|
|
92
|
+
### Search
|
|
93
|
+
|
|
94
|
+
- **Search**: `magnet search <query> [--types issue,page]`
|
|
95
|
+
|
|
96
|
+
## Output
|
|
97
|
+
|
|
98
|
+
All commands print JSON to stdout. Errors go to stderr and the process exits with a non-zero code.
|
|
99
|
+
|
|
100
|
+
**Pagination (issues list / pages list):** The response includes `pagination: { total, hasMore, nextCursor }`. To fetch the next page, set `--cursor` to `pagination.nextCursor`. You can omit `--limit` when using `--cursor` (default page size 50 is sent).
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
magnet issues list --limit 20 # first page
|
|
104
|
+
magnet issues list --limit 20 --cursor "abc123" # next page
|
|
105
|
+
magnet issues list --cursor "abc123" # next page (default limit 50)
|
|
106
|
+
```
|
|
43
107
|
|
|
44
108
|
## License
|
|
45
109
|
|
|
46
|
-
MIT
|
|
110
|
+
MIT — see [LICENSE](LICENSE).
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
3
|
+
* Download the magnet binary from GitHub Releases for this OS/arch.
|
|
4
|
+
* The bin/magnet.cjs wrapper runs the downloaded binary.
|
|
5
5
|
*/
|
|
6
6
|
const fs = require('fs');
|
|
7
7
|
const path = require('path');
|
|
8
8
|
const https = require('https');
|
|
9
9
|
const { execSync } = require('child_process');
|
|
10
10
|
|
|
11
|
-
// Use repo from package.json so it works when published from any org (e.g. toolkit-ai/magnet-cli)
|
|
12
11
|
function getRepo() {
|
|
13
12
|
try {
|
|
14
13
|
const pkg = require(path.join(__dirname, '..', 'package.json'));
|
|
@@ -35,8 +34,8 @@ function getPlatform() {
|
|
|
35
34
|
return null;
|
|
36
35
|
}
|
|
37
36
|
|
|
38
|
-
const FETCH_TIMEOUT_MS = 60000;
|
|
39
|
-
const DOWNLOAD_TIMEOUT_MS = 120000;
|
|
37
|
+
const FETCH_TIMEOUT_MS = 60000;
|
|
38
|
+
const DOWNLOAD_TIMEOUT_MS = 120000;
|
|
40
39
|
|
|
41
40
|
function fetch(url, redirects = 0, timeoutMs = FETCH_TIMEOUT_MS) {
|
|
42
41
|
if (redirects > 5) return Promise.reject(new Error('Too many redirects'));
|
|
@@ -8,7 +8,7 @@ const binary = path.join(binDir, process.platform === 'win32' ? 'magnet.exe' : '
|
|
|
8
8
|
|
|
9
9
|
if (!fs.existsSync(binary)) {
|
|
10
10
|
console.info('magnet: Downloading binary...');
|
|
11
|
-
const download = spawnSync(process.execPath, [path.join(__dirname, 'download.
|
|
11
|
+
const download = spawnSync(process.execPath, [path.join(__dirname, 'download.cjs')], {
|
|
12
12
|
stdio: 'inherit',
|
|
13
13
|
cwd: path.join(__dirname, '..'),
|
|
14
14
|
});
|
package/package.json
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@magnet-ai/cli",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Magnet CLI
|
|
3
|
+
"version": "0.1.4",
|
|
4
|
+
"description": "Magnet CLI — issues, pages, and search. Download the native binary from GitHub Releases.",
|
|
5
|
+
"type": "module",
|
|
5
6
|
"bin": {
|
|
6
|
-
"magnet": "bin/magnet.
|
|
7
|
+
"magnet": "bin/magnet.cjs"
|
|
7
8
|
},
|
|
8
9
|
"scripts": {
|
|
9
|
-
"
|
|
10
|
+
"build": "bun build src/cli.ts --compile --outfile magnet",
|
|
11
|
+
"test": "bun test",
|
|
12
|
+
"test-smoke": "bun test && bun run build && sh scripts/smoke.sh",
|
|
13
|
+
"clean": "rm -f magnet magnet.exe",
|
|
14
|
+
"start": "bun run src/cli.ts",
|
|
15
|
+
"download": "node bin/download.cjs"
|
|
10
16
|
},
|
|
11
17
|
"repository": {
|
|
12
18
|
"type": "git",
|
|
13
19
|
"url": "https://github.com/toolkit-ai/magnet-cli.git"
|
|
14
20
|
},
|
|
15
|
-
"keywords": [
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
+
"keywords": ["magnet", "cli"],
|
|
22
|
+
"license": "MIT",
|
|
23
|
+
"files": ["bin"],
|
|
24
|
+
"devDependencies": {
|
|
25
|
+
"@types/bun": "latest",
|
|
26
|
+
"commander": "^12.1.0"
|
|
27
|
+
}
|
|
28
|
+
}
|
package/bin/magnet
DELETED
|
Binary file
|