@magnet-ai/cli 0.1.2 → 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 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,47 +1,110 @@
1
- # @magnet-ai/cli
1
+ # Magnet CLI
2
2
 
3
- Install the **Magnet CLI** via npm. This package downloads the native binary for your platform from [GitHub Releases](https://github.com/toolkit-ai/magnet-cli/releases) at install time. You do not need Node.js to run the CLI after installation.
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
- ## Install
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
- npm install -g @magnet-ai/cli
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
- Then run:
36
+ **Windows (PowerShell):**
12
37
 
13
- ```bash
14
- magnet --help
15
- magnet issues list
16
- magnet search "query"
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
- ## Requirements
45
+ ### 2. npm (wrapper that downloads the binary)
20
46
 
21
- Set your Magnet API key before using the CLI:
47
+ If you have Node.js and npm:
22
48
 
23
49
  ```bash
24
- export MAGNET_API_KEY="your-uuid-api-key"
50
+ npm install -g @magnet-ai/cli
25
51
  ```
26
52
 
27
- Get an API key from your [Magnet](https://www.magnet.run) organization settings.
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
- ## Test the download (before releasing)
59
+ ### 4. Build from source
30
60
 
31
- From the `npm` folder, run the download script to fetch the binary from the latest GitHub Release:
61
+ Requires [Bun](https://bun.sh).
32
62
 
33
63
  ```bash
34
- cd npm
35
- npm run download
36
- # or: node bin/download.js
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
37
69
  ```
38
70
 
39
- To test against a specific release tag: `MAGNET_CLI_VERSION=v0.1.0 node bin/download.js`. Then run `./bin/magnet.js --help` to confirm the binary works.
71
+ For development, testing, and release workflow, see [CONTRIBUTING.md](CONTRIBUTING.md).
40
72
 
41
- ## Full documentation
73
+ ## Commands
42
74
 
43
- See the [main repository](https://github.com/toolkit-ai/magnet-cli) for commands, pagination, and other install options (direct download, build from source).
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
+ ```
44
107
 
45
108
  ## License
46
109
 
47
- MIT
110
+ MIT — see [LICENSE](LICENSE).
@@ -1,14 +1,13 @@
1
1
  #!/usr/bin/env node
2
2
  /**
3
- * Postinstall: download the magnet binary from GitHub Releases for this OS/arch.
4
- * Requires no Node at runtime; the bin/magnet.js wrapper runs the downloaded binary.
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; // 60s for API / metadata
39
- const DOWNLOAD_TIMEOUT_MS = 120000; // 120s for the binary tarball
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'));
package/bin/magnet.cjs ADDED
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env node
2
+ const path = require('path');
3
+ const fs = require('fs');
4
+ const { spawnSync } = require('child_process');
5
+
6
+ const binDir = path.join(__dirname, '..', 'bin');
7
+ const binary = path.join(binDir, process.platform === 'win32' ? 'magnet.exe' : 'magnet');
8
+
9
+ if (!fs.existsSync(binary)) {
10
+ console.info('magnet: Downloading binary...');
11
+ const download = spawnSync(process.execPath, [path.join(__dirname, 'download.cjs')], {
12
+ stdio: 'inherit',
13
+ cwd: path.join(__dirname, '..'),
14
+ });
15
+ if (download.status !== 0) {
16
+ console.error('magnet: download failed. Ensure a GitHub Release exists (e.g. tag v0.1.0).');
17
+ process.exit(1);
18
+ }
19
+ if (!fs.existsSync(binary)) {
20
+ console.error('magnet: binary still missing after download.');
21
+ process.exit(1);
22
+ }
23
+ }
24
+
25
+ const result = spawnSync(binary, process.argv.slice(2), {
26
+ stdio: 'inherit',
27
+ windowsHide: true,
28
+ });
29
+ process.exit(result.status !== null ? result.status : 1);
package/package.json CHANGED
@@ -1,21 +1,28 @@
1
1
  {
2
2
  "name": "@magnet-ai/cli",
3
- "version": "0.1.2",
4
- "description": "Magnet CLI - download the native binary for your platform",
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.js"
7
+ "magnet": "bin/magnet.cjs"
7
8
  },
8
9
  "scripts": {
9
- "postinstall": "node bin/download.js",
10
- "download": "node bin/download.js"
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"
11
16
  },
12
17
  "repository": {
13
18
  "type": "git",
14
19
  "url": "https://github.com/toolkit-ai/magnet-cli.git"
15
20
  },
16
- "keywords": [
17
- "magnet",
18
- "cli"
19
- ],
20
- "license": "MIT"
21
- }
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
package/bin/magnet.js DELETED
@@ -1,20 +0,0 @@
1
- #!/usr/bin/env node
2
- const path = require('path');
3
- const fs = require('fs');
4
- const { spawnSync } = require('child_process');
5
-
6
- const binDir = path.join(__dirname, '..', 'bin');
7
- const binary = path.join(binDir, process.platform === 'win32' ? 'magnet.exe' : 'magnet');
8
-
9
- if (!fs.existsSync(binary)) {
10
- console.error('magnet: binary not found at', binary);
11
- console.error('Run "npm install -g @magnet-ai/cli" again. If that fails, the postinstall could not download the binary.');
12
- console.error('Ensure a GitHub Release exists (push a tag like v0.1.0) and the repo has prebuilt binaries.');
13
- process.exit(1);
14
- }
15
-
16
- const result = spawnSync(binary, process.argv.slice(2), {
17
- stdio: 'inherit',
18
- windowsHide: true,
19
- });
20
- process.exit(result.status !== null ? result.status : 1);