magic-spells 0.0.0-stage → 0.2.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Magic Spells
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,3 +1,91 @@
1
- # Temporary Holding Version
1
+ # magic-spells
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ `magic`: one command line and MCP server for Magic Spells' hosted services. Node 24 or newer.
4
+
5
+ ```sh
6
+ npx -y magic-spells --help # or: npm i -g magic-spells
7
+ ```
8
+
9
+ ## Sign in
10
+
11
+ ```sh
12
+ magic login # opens your browser; or prints a code when there is none
13
+ magic login --device # always use a code (SSH, containers, another device)
14
+ magic whoami # your account, and your workspaces and keys in each product
15
+ magic logout # revoke your keys and sign-in, forget everything stored
16
+ ```
17
+
18
+ `magic login` signs in to your Magic Spells account, then mints a short-lived key (24 h)
19
+ in Pyramid, Sites and Marketing for every workspace you belong to. Expired keys are
20
+ re-minted for you while your sign-in lives (60 days, or 14 days unused); a product where
21
+ you have no workspace is skipped. With a local browser it uses a one-time callback on
22
+ `127.0.0.1` (PKCE); over SSH or on Linux without a display it uses a code you enter at
23
+ the verification page on any device. With several workspaces in a product, pick one per
24
+ command with `--workspace <handle>` (or set `defaultWorkspace` in
25
+ `~/.config/magic/config.json`). `magic login --product <p>` re-mints one product;
26
+ `magic logout --product <p>` forgets one.
27
+
28
+ Credentials live in the macOS Keychain (service `io.magicspells.cli`) or, elsewhere, a
29
+ mode-0600 file in `~/.config/magic/credentials.json`: `account:grant`, `account:sessions`
30
+ and one `<product>:<workspace>` item per key.
31
+
32
+ ### Product keys (CI)
33
+
34
+ ```sh
35
+ echo "$KEY" | magic login --product-key pyramid # or paste at the hidden prompt
36
+ export MAGIC_PYRAMID_KEY=pyramid_… # or just set the variable
37
+ ```
38
+
39
+ Keys are read from the prompt or stdin, never from arguments. A key in the environment
40
+ wins over a stored one; pasted keys are never re-minted.
41
+
42
+ ## Commands
43
+
44
+ | Command | Does |
45
+ |---|---|
46
+ | `magic login [--device] [--product <p>] [--yes]` | sign in to your account and mint product keys |
47
+ | `magic login --product-key [<product>]` | store a product key (product detected from the key's prefix) |
48
+ | `magic logout [--product <p>]` | revoke and forget credentials |
49
+ | `magic whoami [--json]` | your account (name, email, sign-in expiry) and per product: key source (env, account, manual, none), workspaces, default, masked keys |
50
+ | `magic doctor [--json]` | Node, credential store, Account and your sign-in, and per product: API reachable, key present, product checks |
51
+ | `magic mcp [--products a,b]` | the MCP server over stdio: every product's tools, prefixed (`pyramid_*`) |
52
+ | `magic pyramid <noun> <verb>` | Pyramid: `task next`, `task move WEB-42 --status "In Review"`, `task comment`, `project list`, `whoami`, … (`magic pyramid --help`) |
53
+
54
+ Global flags: `--json`, `--yes/-y`, `--no-color`, `--quiet/-q`, `--workspace <handle>`.
55
+ Output is JSON whenever stdout is not a terminal; errors go to stderr as
56
+ `{ "error": { "code", "message", "hint", "product" } }`.
57
+
58
+ ## MCP
59
+
60
+ ```sh
61
+ claude mcp add magic -- npx -y magic-spells mcp
62
+ ```
63
+
64
+ It uses the keys `magic login` stored (and re-mints them when they expire). A product
65
+ without a key still lists its tools; their calls answer `not_logged_in` until a key is
66
+ stored, without restarting the server. With several workspaces in a product, set
67
+ `defaultWorkspace` in the config file so its tools know which one to use.
68
+
69
+ ## Environment
70
+
71
+ | Variable | Meaning |
72
+ |---|---|
73
+ | `MAGIC_<PRODUCT>_KEY` | the product's key, e.g. `MAGIC_PYRAMID_KEY=pyramid_…`; never stored, wins over the sign-in |
74
+ | `MAGIC_<PRODUCT>_URL` | the product's API base URL, e.g. `MAGIC_PYRAMID_URL`, `MAGIC_SITES_URL`, `MAGIC_MARKETING_URL` |
75
+ | `MAGIC_ACCOUNT_URL` | the Account to sign in with, default `https://account.magicspells.io` |
76
+ | `MAGIC_ACCOUNT_CLIENT_ID` | the `magic` application's client id at that Account |
77
+ | `MAGIC_ALLOW_DESTRUCTIVE=1` | allow destructive operations (with `--yes`, or `yes: true` in MCP) |
78
+ | `MAGIC_CREDENTIALS_FILE=1` | store keys in the 0600 file instead of the OS keychain |
79
+ | `XDG_CONFIG_HOME` | where `magic/` (config and credentials file) lives |
80
+ | `NO_COLOR` | no colour |
81
+
82
+ ## Exit codes
83
+
84
+ Scripts branch on the exit code, or on `error.code` in the JSON envelope: 0 ok, 1 unknown,
85
+ 2 usage, 3 not logged in, bad or expired key, or sign-in cancelled, 4 permission denied, 5 not found, 6 ambiguous name,
86
+ 7 validation or conflict, 8 destructive action disabled, 9 rate limited, 10 network,
87
+ 11 product unavailable. The table lives in
88
+ [`packages/kit/src/errors.ts`](https://github.com/magic-spells/cli/blob/main/packages/kit/src/errors.ts)
89
+ (`exitCodeFor`).
90
+
91
+ MIT licensed.
package/bin/magic.js ADDED
@@ -0,0 +1,12 @@
1
+ #!/usr/bin/env node
2
+ // The `magic` binary. Plain JS so the Node version check runs before any modern syntax
3
+ // or dependency loads; everything else lives in the compiled shell (src/main.ts).
4
+
5
+ const major = Number(process.versions.node.split('.')[0]);
6
+ if (major < 24) {
7
+ process.stderr.write(`magic needs Node 24 or newer (this is Node ${process.versions.node}).\n`);
8
+ process.exit(1);
9
+ }
10
+
11
+ const { run } = await import('../dist/main.js');
12
+ process.exitCode = await run(process.argv.slice(2));