magic-spells 0.1.0 → 0.2.1

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 CHANGED
@@ -6,28 +6,48 @@
6
6
  npx -y magic-spells --help # or: npm i -g magic-spells
7
7
  ```
8
8
 
9
- ## Sign in with a product key
9
+ ## Sign in
10
10
 
11
11
  ```sh
12
- magic login --product-key # paste the key at the hidden prompt
13
- echo "$KEY" | magic login --product-key pyramid # or pipe it (CI)
14
- magic whoami # where each key comes from, and who it is
15
- magic logout # forget every stored key (--product <p> for one)
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
16
  ```
17
17
 
18
- Keys are read from the prompt or stdin, never from arguments, and stored in the macOS
19
- Keychain (service `io.magicspells.cli`) or, elsewhere, a mode-0600 file in
20
- `~/.config/magic/credentials.json`. A key in the environment wins over a stored one.
21
- `magic pyramid login` is the browser sign-in that mints a Pyramid key for you.
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.
22
41
 
23
42
  ## Commands
24
43
 
25
44
  | Command | Does |
26
45
  |---|---|
46
+ | `magic login [--device] [--product <p>] [--yes]` | sign in to your account and mint product keys |
27
47
  | `magic login --product-key [<product>]` | store a product key (product detected from the key's prefix) |
28
- | `magic logout [--product <p>]` | forget stored keys |
29
- | `magic whoami [--json]` | per product: key source (env, keychain, file, none), masked key, identity |
30
- | `magic doctor [--json]` | Node, credential store, and per product: API reachable, key present, product checks |
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 |
31
51
  | `magic mcp [--products a,b]` | the MCP server over stdio: every product's tools, prefixed (`pyramid_*`) |
32
52
  | `magic pyramid <noun> <verb>` | Pyramid: `task next`, `task move WEB-42 --status "In Review"`, `task comment`, `project list`, `whoami`, … (`magic pyramid --help`) |
33
53
 
@@ -41,15 +61,19 @@ Output is JSON whenever stdout is not a terminal; errors go to stderr as
41
61
  claude mcp add magic -- npx -y magic-spells mcp
42
62
  ```
43
63
 
44
- A product without a key still lists its tools; their calls answer `not_logged_in` until a
45
- key is stored, without restarting the server.
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.
46
68
 
47
69
  ## Environment
48
70
 
49
71
  | Variable | Meaning |
50
72
  |---|---|
51
- | `MAGIC_<PRODUCT>_KEY` | the product's key, e.g. `MAGIC_PYRAMID_KEY=pyramid_…`; never stored |
52
- | `MAGIC_<PRODUCT>_URL` | the product's API base URL, e.g. `MAGIC_PYRAMID_URL` |
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 |
53
77
  | `MAGIC_ALLOW_DESTRUCTIVE=1` | allow destructive operations (with `--yes`, or `yes: true` in MCP) |
54
78
  | `MAGIC_CREDENTIALS_FILE=1` | store keys in the 0600 file instead of the OS keychain |
55
79
  | `XDG_CONFIG_HOME` | where `magic/` (config and credentials file) lives |
@@ -58,7 +82,7 @@ key is stored, without restarting the server.
58
82
  ## Exit codes
59
83
 
60
84
  Scripts branch on the exit code, or on `error.code` in the JSON envelope: 0 ok, 1 unknown,
61
- 2 usage, 3 not logged in or bad key, 4 permission denied, 5 not found, 6 ambiguous name,
85
+ 2 usage, 3 not logged in, bad or expired key, or sign-in cancelled, 4 permission denied, 5 not found, 6 ambiguous name,
62
86
  7 validation or conflict, 8 destructive action disabled, 9 rate limited, 10 network,
63
87
  11 product unavailable. The table lives in
64
88
  [`packages/kit/src/errors.ts`](https://github.com/magic-spells/cli/blob/main/packages/kit/src/errors.ts)
@@ -4,7 +4,7 @@ import {
4
4
  readStr,
5
5
  rec,
6
6
  toMagicError
7
- } from "./chunk-YT2Z756Z.js";
7
+ } from "./chunk-ZC4NCQBG.js";
8
8
 
9
9
  // ../pyramid/src/operations/index.ts
10
10
  import { z } from "zod";