@postshiba/cli 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 PostShiba
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,150 @@
1
- # Temporary Holding Version
1
+ # PostShiba CLI
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
+ Terminal app for the PostShiba API. Interactive prompts for humans. JSON for scripts.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install -g @postshiba/cli
9
+ ```
10
+
11
+ Node 20 or later. One-off: `npx @postshiba/cli`. Open pull requests on [postshiba/sdks](https://github.com/postshiba/sdks).
12
+
13
+ ## Sign in
14
+
15
+ ```sh
16
+ postshiba login
17
+ ```
18
+
19
+ The key can also come from `--api-key` or `POSTSHIBA_API_KEY`. Team id comes from `--team`, `POSTSHIBA_TEAM_ID`, or a prompt. Config is `$XDG_CONFIG_HOME/postshiba/config.json`, else `~/.config/postshiba/config.json`, mode `0600`.
20
+
21
+ ```sh
22
+ postshiba whoami
23
+ postshiba logout
24
+ ```
25
+
26
+ ## Send
27
+
28
+ ```sh
29
+ postshiba send --from hello@mail.example.com --to you@example.com --subject "Hi" --text "hello"
30
+ ```
31
+
32
+ `--cluster` sets `X-Capsule-Cluster-Id` on `POST /api/v1/emails`. `--sandbox` and `--idempotency-key` post to the cluster send path and need `--cluster`.
33
+
34
+ ```sh
35
+ postshiba send --cluster NmQpXr --sandbox --from hello@mail.example.com --to you@example.com --subject "Test" --text "sandbox"
36
+ ```
37
+
38
+ Template send. Pass `--template` and `--var`. Skip `--html` and `--text`.
39
+
40
+ ```sh
41
+ postshiba send --from hello@mail.example.com --to you@example.com --template welcome --var name=Ada
42
+ ```
43
+
44
+ ## Send in bulk
45
+
46
+ `emails send-bulk` posts up to 1,000 `messages` in one request. Each message has `to`, optional `name`, `variables`, and `unique_args`. Liquid such as `{{ name }}` works in `subject`, `html`, `text`, `reply_to`, and header values.
47
+
48
+ ```sh
49
+ postshiba emails send-bulk --data @invites.json
50
+ postshiba emails list-bulk --reference invites-2026-11-28
51
+ ```
52
+
53
+ `invites.json`:
54
+
55
+ ```json
56
+ {
57
+ "from": "Party <hello@mail.example.com>",
58
+ "subject": "{{ name }}, you're invited",
59
+ "html": "<p>RSVP at {{ rsvp_url }}</p>",
60
+ "text": "RSVP at {{ rsvp_url }}",
61
+ "reply_to": "rsvp+{{ guest_id }}@inbox.example.com",
62
+ "headers": {
63
+ "List-Unsubscribe": "<{{ unsubscribe_url }}>",
64
+ "List-Unsubscribe-Post": "List-Unsubscribe=One-Click"
65
+ },
66
+ "unique_args": {
67
+ "event_id": "evt_1"
68
+ },
69
+ "reference": "invites-2026-11-28",
70
+ "messages": [
71
+ {
72
+ "to": "ada@example.com",
73
+ "name": "Ada",
74
+ "variables": {
75
+ "guest_id": "g1",
76
+ "rsvp_url": "https://example.com/r/g1",
77
+ "unsubscribe_url": "https://example.com/u/g1"
78
+ },
79
+ "unique_args": {
80
+ "invite_id": "inv_1"
81
+ }
82
+ }
83
+ ]
84
+ }
85
+ ```
86
+
87
+ `--cluster` sets `X-Capsule-Cluster-Id`. Bulk sends take no idempotency key. Set `reference`, and check `emails list-bulk --reference` before you retry a request that timed out.
88
+
89
+ ## Resources
90
+
91
+ ```
92
+ postshiba <resource> <action> [ids...] [--data JSON | --data @file.json | --data -]
93
+ ```
94
+
95
+ ```sh
96
+ postshiba clusters list
97
+ postshiba clusters get NmQpXr
98
+ postshiba sending-domains create --data '{"name":"mail.example.com"}'
99
+ postshiba messages download-attachment PqRzMn GxTyVu 1 --output photo.png
100
+ postshiba outbound-messages raw OuTbMs --output receipt.eml
101
+ ```
102
+
103
+ `postshiba help` lists every resource and action. `postshiba help <resource>` shows ids and flags for each action.
104
+
105
+ Some actions take query flags. Optional ones are in brackets in help. Booleans such as `--compare` and `--all` send `true`.
106
+
107
+ ```sh
108
+ postshiba recipients get --email ada@example.com
109
+ postshiba sending-domains can-i-send-this-result HsVtYk --token tok_cist
110
+ postshiba outbound-messages list --q receipt --limit 25
111
+ postshiba analytics get --since 2026-11-01 --until 2026-11-28 --compare
112
+ postshiba support-tickets list --all
113
+ ```
114
+
115
+ `recipients get` needs `--email` and `sending-domains can-i-send-this-result` needs `--token`. A flag the action does not take exits 2.
116
+
117
+ `delete`, `suspend`, `release`, `unassign`, `cancel`, `rotate-secret`, `flush-queue`, `remove-ip`, `detach`, and `bulk-delete` ask before they run. `--yes` skips the confirm. Plain mode needs `--yes`.
118
+
119
+ ## Plain mode
120
+
121
+ Scripts and agents should pass `--json`. `--no-input`, a non-TTY, or `CI` also force plain mode. Plain mode never prompts. Success prints 2-space API JSON. Missing input exits 2.
122
+
123
+ ```sh
124
+ postshiba doctor --json
125
+ postshiba clusters list --json
126
+ ```
127
+
128
+ ## Agent skill
129
+
130
+ ```sh
131
+ postshiba skills install
132
+ npx skills add postshiba/postshiba-cli
133
+ ```
134
+
135
+ `--global` writes under the home directory. `--target cursor|claude|agents` picks the skill folder.
136
+
137
+ ## Errors
138
+
139
+ Non-2xx responses print `Error: <message>` and, when present, `(field: <field>)`. Exit 1.
140
+
141
+ A `429` with `error` `throttled` is the cluster hourly send limit. The CLI prints that line and exits. Do not retry that send immediately. Wait until the next hour.
142
+
143
+ ## Contributing
144
+
145
+ ```sh
146
+ npm install
147
+ npm test
148
+ ```
149
+
150
+ Tests mock HTTP. They do not call production.
@@ -0,0 +1,11 @@
1
+ #!/usr/bin/env node
2
+ // @ts-check
3
+ import { main } from "../src/cli.js";
4
+
5
+ process.exitCode = await main(process.argv.slice(2), {
6
+ env: process.env,
7
+ stdout: process.stdout,
8
+ stderr: process.stderr,
9
+ stdin: process.stdin,
10
+ fetch,
11
+ });
package/package.json CHANGED
@@ -1,6 +1,43 @@
1
1
  {
2
2
  "name": "@postshiba/cli",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "PostShiba command-line interface",
5
+ "license": "MIT",
6
+ "author": "PostShiba",
7
+ "homepage": "https://github.com/postshiba/postshiba-cli",
8
+ "repository": {
9
+ "type": "git",
10
+ "url": "git+https://github.com/postshiba/postshiba-cli.git"
11
+ },
12
+ "bugs": {
13
+ "url": "https://github.com/postshiba/postshiba-cli/issues"
14
+ },
15
+ "type": "module",
16
+ "bin": {
17
+ "postshiba": "bin/postshiba.js"
18
+ },
19
+ "files": [
20
+ "bin",
21
+ "src",
22
+ "skills",
23
+ "LICENSE",
24
+ "README.md"
25
+ ],
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "engines": {
30
+ "node": ">=20"
31
+ },
32
+ "scripts": {
33
+ "test": "tsc --noEmit && node --test"
34
+ },
35
+ "dependencies": {
36
+ "@clack/prompts": "^1.8.1",
37
+ "picocolors": "^1.1.1"
38
+ },
39
+ "devDependencies": {
40
+ "@types/node": "^24.5.2",
41
+ "typescript": "^5.9.2"
42
+ }
43
+ }
@@ -0,0 +1,146 @@
1
+ ---
2
+ name: postshiba-cli
3
+ description: Uses the PostShiba CLI to manage infrastructure and send mail from a terminal, script, or CI. Use when the user wants to manage PostShiba or send mail from a terminal, script, or CI, or when the `postshiba` command is installed or should be.
4
+ ---
5
+
6
+ # PostShiba CLI
7
+
8
+ Drive PostShiba from a terminal, script, or CI with the `postshiba` command. Always pass `--json` so the CLI never prompts. A non-TTY or set `CI` also forces plain mode.
9
+
10
+ For Cursor MCP workflows (first send, DNS walkthroughs, hosted inboxes), use the sibling skills in this plugin: `postshiba`, `postshiba-first-send`, `postshiba-create-cluster`, `postshiba-create-credentials`, `postshiba-send-test-email`, `postshiba-create-mailbox`, `postshiba-send-from-domain`, `postshiba-import-dkim`.
11
+
12
+ ## Install
13
+
14
+ ```bash
15
+ npm install -g @postshiba/cli
16
+ postshiba --version
17
+ ```
18
+
19
+ One-off: `npx @postshiba/cli`. If `--version` fails, install, then check again.
20
+
21
+ ## Credentials
22
+
23
+ Read credentials from the environment. Never echo the API key.
24
+
25
+ | Setting | Env |
26
+ | --- | --- |
27
+ | API key | `POSTSHIBA_API_KEY` |
28
+ | Team id | `POSTSHIBA_TEAM_ID` |
29
+ | Default cluster | `POSTSHIBA_CLUSTER_ID` |
30
+
31
+ Team-scoped commands need a team id. Never guess it. Prefer env over `postshiba login`. Login prompts.
32
+
33
+ ## Start
34
+
35
+ 1. Confirm the binary with `postshiba --version`.
36
+ 2. Run `postshiba doctor --json`.
37
+ 3. Fix what `doctor` reports before sending.
38
+
39
+ `doctor` checks the key, team id, a cluster with `sending_ready`, and a verified sending domain.
40
+
41
+ ## Resource commands
42
+
43
+ ```
44
+ postshiba <resource> <action> [ids...] --json [--data JSON | --data @file.json | --data -]
45
+ ```
46
+
47
+ Ids are public letter-only Hashids. Pass them in path order. Pass `--data` when the action has a request body (`create`, `update`, `boost`, `extend-boost`, `set-auto-boost`, `assign`, `unassign`, `switch`, `release`, `warmup`, `add-ip`, `remove-ip`, `attach`, `detach`, `move`, `import`, `bulk-delete`, `add-entry`, `reply`, `send-bulk`). `postshiba help <resource>` lists ids and flags for each action.
48
+
49
+ | Resource | Actions |
50
+ | --- | --- |
51
+ | `clusters` | `list` `get` `create` `update` `suspend` `resume` `delete` `boost` `extend-boost` `cancel-boost` `reactivate` `set-auto-boost` |
52
+ | `emails` | `send-bulk` `list-bulk` `get-bulk` |
53
+ | `network` | `list` `create` `assign` `unassign` `switch` `release` `warmup` |
54
+ | `ip-pools` | `list` `get` `create` `update` `delete` `add-ip` `remove-ip` `attach` `detach` |
55
+ | `sending-domains` | `list` `get` `create` `update` `refresh` `verify` `suspend` `resume` `make-primary` `delete` `flush-queue` `move` `can-i-send-this` `can-i-send-this-result` |
56
+ | `tenants` | `list` `get` `create` `update` `suspend` `resume` `delete` |
57
+ | `inboxes` | `list` `get` `create` `update` `verify` `delete` |
58
+ | `messages` | `list` `get` `download-attachment` |
59
+ | `events` | `list-team` `list` `get` |
60
+ | `outbound-messages` | `list` `get` `raw` `download-attachment` |
61
+ | `outbound-retention` | `get` `update` |
62
+ | `dkim-signing` | `get` `update` |
63
+ | `recipients` | `get` |
64
+ | `analytics` | `get` |
65
+ | `status` | `get` |
66
+ | `planned-sends` | `list` `get` `create` `cancel` |
67
+ | `support-tickets` | `list` `get` `create` `reply` |
68
+ | `smtp-credentials` | `create` `delete` `enable` |
69
+ | `webhooks` | `list` `get` `create` `update` `delete` `send-test` |
70
+ | `templates` | `list` `get` `create` `update` `publish` `duplicate` `delete` |
71
+ | `suppressions` | `list` `create` `import` `delete` `bulk-delete` |
72
+ | `firewall` | `get` `update` `add-entry` `delete-entry` |
73
+ | `shield-sites` | `list` `get` `create` `update` `rotate-secret` `delete` |
74
+
75
+ Also: `whoami`, `send`, `doctor`, `help`, `skills install`. `messages download-attachment`, `outbound-messages download-attachment`, and `outbound-messages raw` write bytes to `--output PATH`, else stdout.
76
+
77
+ Query flags. Send only what the user asked for. Booleans (`--compare`, `--all`) send `true`.
78
+
79
+ | Command | Flags |
80
+ | --- | --- |
81
+ | `recipients get` | `--email` (required) |
82
+ | `sending-domains can-i-send-this-result <id>` | `--token` (required, from `can-i-send-this`) |
83
+ | `outbound-messages list` | `--q` `--before` `--limit` |
84
+ | `analytics get` | `--since` `--until` `--dimension` `--min-processed` `--compare` `--compare-since` `--compare-until` |
85
+ | `ip-pools list` | `--classification` |
86
+ | `support-tickets list` | `--all` |
87
+ | `emails list-bulk` | `--reference` |
88
+
89
+ ```bash
90
+ postshiba clusters list --json
91
+ postshiba clusters get NmQpXr --json
92
+ postshiba sending-domains create --json --data '{"name":"mail.example.com"}'
93
+ postshiba messages get PqRzMn GxTyVu --json
94
+ postshiba recipients get --json --email ada@example.com
95
+ ```
96
+
97
+ ## Send
98
+
99
+ Required: `--from` and at least one `--to`.
100
+
101
+ Plain:
102
+
103
+ ```bash
104
+ postshiba send --json --from hello@mail.example.com --to you@example.com --subject "Hi" --text "Hello"
105
+ ```
106
+
107
+ Template. Pass `--var KEY=VALUE` for each Liquid variable. Do not also pass `--html` or `--text`.
108
+
109
+ ```bash
110
+ postshiba send --json --from hello@mail.example.com --to you@example.com --template welcome --var name=Ada
111
+ ```
112
+
113
+ Sandbox test. Requires `--cluster`. Success returns `queued: false`. The message is not delivered.
114
+
115
+ ```bash
116
+ postshiba send --json --cluster NmQpXr --sandbox --from hello@mail.example.com --to you@example.com --subject "Test" --text "Sandbox"
117
+ ```
118
+
119
+ Idempotent cluster send. Requires `--cluster`.
120
+
121
+ ```bash
122
+ postshiba send --json --cluster NmQpXr --idempotency-key run-1 --from hello@mail.example.com --to you@example.com --subject "Hi" --text "Hello"
123
+ ```
124
+
125
+ `--sandbox` and `--idempotency-key` post to the cluster send path. `--cluster` alone on a plain send sets the cluster header and keeps `POST /api/v1/emails`.
126
+
127
+ Bulk send. Up to 1,000 `messages`, each with `to`, optional `name`, `variables`, and `unique_args`. Liquid such as `{{ name }}` works in `subject`, `html`, `text`, `reply_to`, and header values. `--cluster` sets the cluster header. There is no idempotency key: set `reference`, and before retrying a request that timed out, run `emails list-bulk --reference` to check whether it landed.
128
+
129
+ ```bash
130
+ postshiba emails send-bulk --json --data @invites.json
131
+ postshiba emails list-bulk --json --reference invites-2026-11-28
132
+ ```
133
+
134
+ ## Exit codes
135
+
136
+ - `0` success. stdout is 2-space API JSON.
137
+ - `1` API error. stderr is `Error: <message>` and, when present, `(field: <field>)`. A `429` with `error` `throttled` is the hourly send cap. Wait until the next hour. Do not retry immediately.
138
+ - `2` usage error. Missing input, bad JSON, or a destructive action without `--yes`.
139
+
140
+ ## Destructive actions
141
+
142
+ `delete`, `suspend`, `release`, `unassign`, `cancel`, `rotate-secret`, `flush-queue`, `remove-ip`, `detach`, and `bulk-delete` need `--yes` in plain mode. `flush-queue` bounces the domain's queued mail. Pass `--yes` only when the user explicitly asked for that destructive action.
143
+
144
+ ## Secrets
145
+
146
+ Never echo the API key. Keep SMTP passwords and webhook secrets out of logs. An SMTP password appears once on create.