@tryghost/ghst 0.4.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,22 @@
1
+ Copyright (c) 2013-2026 Ghost Foundation
2
+
3
+ Permission is hereby granted, free of charge, to any person
4
+ obtaining a copy of this software and associated documentation
5
+ files (the "Software"), to deal in the Software without
6
+ restriction, including without limitation the rights to use,
7
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the
9
+ Software is furnished to do so, subject to the following
10
+ conditions:
11
+
12
+ The above copyright notice and this permission notice shall be
13
+ included in all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
17
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
20
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22
+ OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,306 @@
1
+ # ghst cli
2
+
3
+ `ghst` is a CLI tool for managing Ghost instances from the terminal. Anything you can do with the Ghost Admin API, you can do with `ghst`. (And a bit more)
4
+
5
+ - CRUD for Ghost resources
6
+ - Full Admin API support
7
+ - JSON-first scripting support (`--json`, `--jq`)
8
+ - Built-in MCP server mode for editor/agent integration
9
+ - Utility functions for development
10
+
11
+ > [!IMPORTANT]
12
+ > This tool is pre-1.0 and not yet stable. Use with caution, and back up critical data.
13
+
14
+ ## Contents
15
+
16
+ - [Install](#install)
17
+ - [Quick Start](#quick-start)
18
+ - [Authentication and Site Selection](#authentication-and-site-selection)
19
+ - [Command Reference](#command-reference)
20
+ - [Global Options](#global-options)
21
+ - [Common Workflows](#common-workflows)
22
+ - [Configuration and Environment Variables](#configuration-and-environment-variables)
23
+ - [Output, Automation, and Exit Codes](#output-automation-and-exit-codes)
24
+ - [MCP Server Mode](#mcp-server-mode)
25
+ - [Troubleshooting](#troubleshooting)
26
+ - [Development](#development)
27
+ - [License & trademark](#license--trademark)
28
+
29
+ ## Install
30
+
31
+ Install globally with npm:
32
+
33
+ ```bash
34
+ npm install -g @tryghost/ghst
35
+ ```
36
+
37
+ or run instantly without global install:
38
+
39
+ ```bash
40
+ npx @tryghost/ghst
41
+ ```
42
+
43
+ Other package managers:
44
+
45
+ ```bash
46
+ pnpm add -g @tryghost/ghst
47
+ ```
48
+
49
+ ```bash
50
+ yarn global add @tryghost/ghst
51
+ ```
52
+
53
+ ## Quick Start
54
+
55
+ 1. Authenticate:
56
+
57
+ ```bash
58
+ ghst auth login
59
+ ```
60
+
61
+ 2. Verify active auth:
62
+
63
+ ```bash
64
+ ghst auth status
65
+ ```
66
+
67
+ 3. Fetch content:
68
+
69
+ ```bash
70
+ ghst post list --limit 5
71
+ ```
72
+
73
+ 4. Create content:
74
+
75
+ ```bash
76
+ ghst post create --title "Launch" --markdown-file ./launch.md
77
+ ```
78
+
79
+ 5. Get help:
80
+
81
+ ```bash
82
+ ghst --help
83
+ ghst <resource> --help
84
+ ghst <resource> <action> --help
85
+ ```
86
+
87
+ ## Authentication and Site Selection
88
+
89
+ Interactive auth flow:
90
+
91
+ 1. Run `ghst auth login`.
92
+ 2. Open Ghost Admin when prompted.
93
+ 3. Create or copy a staff access token from your user profile.
94
+ 4. Paste `Ghost API URL` and `Ghost Staff Access Token`.
95
+
96
+ Non-interactive auth for CI/scripts:
97
+
98
+ ```bash
99
+ ghst auth login \
100
+ --non-interactive \
101
+ --url https://myblog.ghost.io \
102
+ --staff-token "{id}:{secret}" \
103
+ --json
104
+ ```
105
+
106
+ Site/profile management:
107
+
108
+ ```bash
109
+ ghst auth list
110
+ ghst auth switch <site-alias>
111
+ ghst auth link --site <site-alias>
112
+ ghst auth token
113
+ ```
114
+
115
+ ## Command Reference
116
+
117
+ | Resource | Actions |
118
+ | --- | --- |
119
+ | `auth` | `login`, `status`, `list`, `switch`, `logout`, `link`, `token` |
120
+ | `post` | `list`, `get`, `create`, `update`, `delete`, `publish`, `schedule`, `unschedule`, `copy`, `bulk` |
121
+ | `page` | `list`, `get`, `create`, `update`, `delete`, `copy`, `bulk` |
122
+ | `tag` | `list`, `get`, `create`, `update`, `delete`, `bulk` |
123
+ | `member` | `list`, `get`, `create`, `update`, `delete`, `import`, `export`, `bulk` |
124
+ | `newsletter` | `list`, `get`, `create`, `update`, `bulk` |
125
+ | `tier` | `list`, `get`, `create`, `update`, `bulk` |
126
+ | `offer` | `list`, `get`, `create`, `update`, `bulk` |
127
+ | `label` | `list`, `get`, `create`, `update`, `delete`, `bulk` |
128
+ | `webhook` | `create`, `update`, `delete`, `events`, `listen` |
129
+ | `user` | `list`, `get`, `me` |
130
+ | `image` | `upload` |
131
+ | `theme` | `list`, `upload`, `activate`, `validate`, `dev` |
132
+ | `site` | `info` |
133
+ | `setting` | `list`, `get`, `set` |
134
+ | `migrate` | `wordpress`, `medium`, `substack`, `csv`, `json`, `export` |
135
+ | `config` | `show`, `path`, `list`, `get`, `set` |
136
+ | `api` | raw Ghost request command (`ghst api [endpointPath]`) |
137
+ | `mcp` | `stdio`, `http` |
138
+ | `completion` | `<bash|zsh|fish|powershell>` |
139
+
140
+ ## Global Options
141
+
142
+ | Flag | Purpose |
143
+ | --- | --- |
144
+ | `--json` | Emit JSON output for automation |
145
+ | `--jq <filter>` | Apply jq-style extraction to JSON output |
146
+ | `--site <alias>` | Use configured site alias |
147
+ | `--url <url>` + `--staff-token <token>` | Use direct credentials for this invocation |
148
+ | `--debug [level]` | Enable debug output |
149
+ | `--no-color` | Disable color output |
150
+
151
+ ## Common Workflows
152
+
153
+ Create and publish:
154
+
155
+ ```bash
156
+ ghst post create --title "Launch" --markdown-file ./launch.md --newsletter weekly --email-segment all
157
+ ghst post publish <post-id>
158
+ ```
159
+
160
+ Bulk updates:
161
+
162
+ ```bash
163
+ ghst post bulk --filter "status:draft" --update --add-tag release-notes --authors editor@example.com
164
+ ghst member bulk --update --filter "status:free" --labels "trial,needs-follow-up"
165
+ ghst label bulk --filter "name:'legacy'" --action delete --yes
166
+ ```
167
+
168
+ Scheduling:
169
+
170
+ ```bash
171
+ ghst post schedule <post-id> --at 2026-03-01T10:00:00Z
172
+ ghst post unschedule <post-id>
173
+ ```
174
+
175
+ Theme development:
176
+
177
+ ```bash
178
+ ghst theme validate ./theme-dir
179
+ ghst theme dev ./theme-dir --watch --activate
180
+ ```
181
+
182
+ Webhook relay for local development:
183
+
184
+ ```bash
185
+ ghst webhook listen \
186
+ --public-url https://hooks.example.com/ghost \
187
+ --forward-to http://localhost:3000/webhooks
188
+ ```
189
+
190
+ Direct API calls:
191
+
192
+ ```bash
193
+ ghst api /posts/ --paginate --include-headers
194
+ ghst api /settings/ -X PUT -f settings[0].key=title -f settings[0].value="New title"
195
+ ```
196
+
197
+ ## Configuration and Environment Variables
198
+
199
+ Connection resolution order:
200
+
201
+ 1. `--site`
202
+ 2. `--url` + `--staff-token`
203
+ 3. `GHOST_URL` + `GHOST_STAFF_ACCESS_TOKEN`
204
+ 4. project link file `.ghst/config.json`
205
+ 5. active site in user config
206
+
207
+ Primary config/state files:
208
+
209
+ | Path | Purpose |
210
+ | --- | --- |
211
+ | `~/.config/ghst/config.json` | User config (saved sites, active site) |
212
+ | `.ghst/config.json` | Project-level linked site |
213
+ | `.env.example` | Example environment configuration |
214
+
215
+ Environment variables:
216
+
217
+ | Variable | Purpose |
218
+ | --- | --- |
219
+ | `GHOST_URL` | Ghost site URL override |
220
+ | `GHOST_STAFF_ACCESS_TOKEN` | Ghost staff access token (`{id}:{secret}`) |
221
+ | `GHOST_API_VERSION` | Admin API version override (default `v6.0`) |
222
+ | `GHOST_SITE` | Site alias fallback lookup in user config |
223
+ | `GHOST_CONTENT_API_KEY` | Required when using `ghst api --content-api` |
224
+ | `GHST_CONFIG_DIR` | Override user config directory path |
225
+ | `GHST_OUTPUT` | Force JSON output when set to `json` |
226
+ | `GHST_FORCE_TTY` | Force TTY behavior for non-interactive environments |
227
+ | `GHST_NO_COLOR` / `NO_COLOR` | Disable colorized output |
228
+
229
+ ## Output, Automation, and Exit Codes
230
+
231
+ JSON + jq-style extraction:
232
+
233
+ ```bash
234
+ ghst post list --json
235
+ ghst post list --json --jq '.posts[].title'
236
+ ```
237
+
238
+ Common machine-safe practices:
239
+
240
+ - Use `--json` for scripts.
241
+ - Use `--non-interactive` for CI where prompts are invalid.
242
+ - Pass explicit auth (`--url` and `--staff-token`) or set env vars.
243
+
244
+ Exit code mapping:
245
+
246
+ | Code | Meaning |
247
+ | --- | --- |
248
+ | `0` | Success |
249
+ | `1` | General error |
250
+ | `2` | Usage/argument error |
251
+ | `3` | Authentication/authorization error |
252
+ | `4` | Operation cancelled |
253
+ | `5` | Not found |
254
+ | `6` | Conflict |
255
+ | `7` | Validation error |
256
+ | `8` | Rate limited |
257
+
258
+ ## MCP Server Mode
259
+
260
+ Run MCP over stdio or HTTP:
261
+
262
+ ```bash
263
+ ghst mcp stdio --tools all
264
+ ghst mcp http --host 127.0.0.1 --port 3100 --tools posts,tags,site
265
+ ```
266
+
267
+ Supported tool groups:
268
+
269
+ - `posts`
270
+ - `pages`
271
+ - `tags`
272
+ - `members`
273
+ - `site`
274
+ - `settings`
275
+ - `users`
276
+ - `api`
277
+ - `search`
278
+
279
+ ## Troubleshooting
280
+
281
+ `No site configuration found`:
282
+
283
+ - Run `ghst auth login`, or
284
+ - Provide `--url` and `--staff-token`, or
285
+ - Set `GHOST_URL` and `GHOST_STAFF_ACCESS_TOKEN`.
286
+
287
+ `GHOST_CONTENT_API_KEY is required for --content-api requests`:
288
+
289
+ - Export `GHOST_CONTENT_API_KEY` before `ghst api --content-api`.
290
+
291
+ `Use --non-interactive when combining auth login with --json`:
292
+
293
+ - Re-run auth with `--non-interactive` and explicit credentials.
294
+
295
+ Commands and flags drift:
296
+
297
+ - Re-check current command docs with `ghst <resource> --help`.
298
+
299
+ ## Development
300
+
301
+ For cloning, testing, and developing the repository from source, see [CONTRIBUTING.md](CONTRIBUTING.md).
302
+
303
+ ## License & trademark
304
+
305
+ Copyright (c) 2013-2026 Ghost Foundation - Released under the [MIT license](LICENSE).
306
+ Ghost and the Ghost Logo are trademarks of Ghost Foundation Ltd. Please see our [trademark policy](https://ghost.org/trademark/) for info on acceptable usage.