@paragraph-com/cli 0.0.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.
Files changed (4) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +266 -0
  3. package/dist/index.js +45972 -0
  4. package/package.json +53 -0
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Paragraph
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 ADDED
@@ -0,0 +1,266 @@
1
+ # @paragraph-com/cli
2
+
3
+ Command-line interface for [Paragraph](https://paragraph.com). Designed for both human and programmatic (agent) usage.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install -g @paragraph-com/cli
9
+ ```
10
+
11
+ Or via Homebrew:
12
+
13
+ ```bash
14
+ brew tap paragraph-com/tap && brew install paragraph
15
+ ```
16
+
17
+ ## Quick start
18
+
19
+ ```bash
20
+ # Authenticate
21
+ paragraph login
22
+
23
+ # Create a post
24
+ paragraph post create --title "My Post" --file ./draft.md
25
+
26
+ # Publish it
27
+ paragraph post publish my-post
28
+
29
+ # List your posts
30
+ paragraph post list
31
+ ```
32
+
33
+ Run `paragraph --help` to see all commands, or `paragraph <command> --help` for details on any command.
34
+
35
+ ## Authentication
36
+
37
+ Get your API key from **paragraph.com/settings -> Publication -> Developer**.
38
+
39
+ ```bash
40
+ # Interactive login (opens browser or prompts for key)
41
+ paragraph login
42
+
43
+ # Provide token directly
44
+ paragraph login --token <your-api-key>
45
+
46
+ # Pipe token from stdin (useful for CI/agents)
47
+ echo "<your-api-key>" | paragraph login --with-token
48
+
49
+ # Or skip login — pass the key per-command via env var
50
+ PARAGRAPH_API_KEY=<your-api-key> paragraph post list
51
+
52
+ # Verify
53
+ paragraph whoami
54
+
55
+ # Remove stored credentials
56
+ paragraph logout
57
+ ```
58
+
59
+ Credentials are stored in `~/.paragraph/config.json` (mode 0600). If an API key is revoked, the CLI automatically clears the stored credentials on the next 401 response.
60
+
61
+ ## Commands
62
+
63
+ ### Posts
64
+
65
+ ```bash
66
+ # List your posts (requires auth)
67
+ paragraph post list
68
+ paragraph post list --status draft
69
+ paragraph post list --limit 50 --cursor <cursor>
70
+
71
+ # List posts from any publication (public)
72
+ paragraph post list --publication <id-or-slug>
73
+
74
+ # Get a post -- accepts ID, URL, or @publication/slug
75
+ paragraph post get <post-id>
76
+ paragraph post get @yearn/some-post-slug
77
+ paragraph post get https://paragraph.com/@yearn/some-post-slug
78
+
79
+ # Extract a single field (outputs raw value to stdout, pipeable)
80
+ paragraph post get <id> --field markdown > post.md
81
+ paragraph post get <id> --field title
82
+
83
+ # Browse posts
84
+ paragraph post by-tag defi --limit 20
85
+ paragraph post feed --limit 10
86
+
87
+ # Create a post (defaults to draft)
88
+ paragraph post create --title "My Post" --text "# Hello World"
89
+ paragraph post create --title "My Post" --file ./draft.md
90
+ cat draft.md | paragraph post create --title "From Stdin"
91
+ paragraph post create --title "Post" --text "Content" --subtitle "Summary" --tags "web3,defi"
92
+
93
+ # Update a post
94
+ paragraph post update <id-or-slug> --title "New Title"
95
+ paragraph post update <id-or-slug> --file ./updated.md --tags "new,tags"
96
+
97
+ # Lifecycle
98
+ paragraph post publish <id-or-slug> # publish a draft
99
+ paragraph post publish <id-or-slug> --newsletter # publish + send email to subscribers
100
+ paragraph post draft <id-or-slug> # revert to draft
101
+ paragraph post archive <id-or-slug> # archive
102
+
103
+ # Preview before acting
104
+ paragraph post publish <id-or-slug> --dry-run
105
+ paragraph post delete <id-or-slug> --dry-run
106
+
107
+ # Send test newsletter email (draft only)
108
+ paragraph post test-email <id>
109
+
110
+ # Delete a post
111
+ paragraph post delete <id-or-slug>
112
+ paragraph post delete <id-or-slug> --yes # skip confirmation (required for agents/CI)
113
+ ```
114
+
115
+ Top-level shortcuts:
116
+
117
+ ```bash
118
+ paragraph create --title "Quick Post" --text "Content"
119
+ paragraph update my-post-slug --title "Updated"
120
+ paragraph delete my-post-slug --yes
121
+ ```
122
+
123
+ ### Publications
124
+
125
+ ```bash
126
+ # Get publication -- accepts ID, slug, or custom domain
127
+ paragraph publication get @variantwriting
128
+ paragraph publication get blog.variant.fund
129
+ paragraph publication get <publication-id>
130
+ ```
131
+
132
+ ### Search
133
+
134
+ ```bash
135
+ paragraph search post --query "ethereum"
136
+ paragraph search blog --query "web3"
137
+ ```
138
+
139
+ ### Subscribers
140
+
141
+ ```bash
142
+ paragraph subscriber list --limit 100
143
+ paragraph subscriber count <publication-id>
144
+ paragraph subscriber add --email user@example.com
145
+ paragraph subscriber import --csv subscribers.csv
146
+ ```
147
+
148
+ ### Coins
149
+
150
+ ```bash
151
+ paragraph coin get <id-or-address>
152
+ paragraph coin popular --limit 10
153
+ paragraph coin search --query "test"
154
+ paragraph coin holders <id-or-address> --limit 50
155
+ paragraph coin quote <id-or-address> --amount <wei>
156
+ ```
157
+
158
+ ### Users
159
+
160
+ ```bash
161
+ paragraph user get <user-id>
162
+ paragraph user get 0x1234... # by wallet address
163
+ ```
164
+
165
+ ## Interactive TUI
166
+
167
+ Running `paragraph` with no arguments launches an interactive terminal UI with menus, scrollable lists, and keyboard navigation.
168
+
169
+ The TUI is disabled automatically when:
170
+ - `--json`, `--help`, or `--version` flags are used
171
+ - stdout is not a TTY (e.g., piped output)
172
+ - `CI=true` or `PARAGRAPH_NON_INTERACTIVE=1` is set
173
+
174
+ ## Agent / programmatic usage
175
+
176
+ The CLI is designed for use by AI agents and scripts.
177
+
178
+ ### JSON output
179
+
180
+ All commands support `--json`. Data goes to **stdout**, status messages to **stderr**, so you can pipe cleanly:
181
+
182
+ ```bash
183
+ paragraph --json post list | jq '.data[0].title'
184
+ paragraph --json post get <id> | jq '.markdown'
185
+ paragraph --json search post --query "web3" | jq '.length'
186
+ ```
187
+
188
+ Paginated commands return:
189
+
190
+ ```json
191
+ {
192
+ "data": [{ "id": "...", "title": "..." }],
193
+ "pagination": { "cursor": "abc123", "hasMore": true }
194
+ }
195
+ ```
196
+
197
+ Single-item commands return the object directly:
198
+
199
+ ```json
200
+ { "id": "...", "title": "...", "markdown": "..." }
201
+ ```
202
+
203
+ ### Structured errors
204
+
205
+ In `--json` mode, errors are structured JSON on **stderr** with a non-zero exit code:
206
+
207
+ ```json
208
+ { "error": "Not found.", "code": "NOT_FOUND", "status": 404 }
209
+ ```
210
+
211
+ Error codes: `UNAUTHORIZED`, `FORBIDDEN`, `NOT_FOUND`, `RATE_LIMITED`, `SERVER_ERROR`, `REQUEST_FAILED`, `CLIENT_ERROR`, `UNKNOWN`.
212
+
213
+ ### Flags and stdin
214
+
215
+ Every identifier accepts both a positional argument and an `--id` flag, so you can chain commands:
216
+
217
+ ```bash
218
+ paragraph post get --id $(paragraph --json post list | jq -r '.data[0].id')
219
+ ```
220
+
221
+ Content can come from `--text`, `--file`, or stdin:
222
+
223
+ ```bash
224
+ cat draft.md | paragraph post create --title "My Post"
225
+ ```
226
+
227
+ ### Non-interactive safety
228
+
229
+ - `delete` requires `--yes` in non-TTY environments
230
+ - `login` supports `--with-token` for stdin piping and `--token` for direct input
231
+ - Destructive commands support `--dry-run` to preview without acting
232
+ - Set `PARAGRAPH_NON_INTERACTIVE=1` or `CI=true` to force CLI mode
233
+
234
+ ### Environment variables
235
+
236
+ | Variable | Purpose |
237
+ |----------|---------|
238
+ | `PARAGRAPH_API_KEY` | API key (alternative to `login`) |
239
+ | `PARAGRAPH_API_URL` | Custom API base URL |
240
+ | `PARAGRAPH_NON_INTERACTIVE` | Set to `1` to disable TUI |
241
+ | `CI` | Set to `true` to disable TUI |
242
+
243
+ ---
244
+
245
+ ## Development
246
+
247
+ ```bash
248
+ git clone https://github.com/paragraph-xyz/paragraph-cli.git
249
+ cd paragraph-cli
250
+ npm install
251
+ npm run build
252
+ npm run dev # watch mode
253
+ npm test
254
+ ```
255
+
256
+ Requires Node.js >= 18.
257
+
258
+ ## Releasing
259
+
260
+ ```bash
261
+ npm run release patch # 0.1.0 → 0.1.1
262
+ npm run release minor # 0.1.0 → 0.2.0
263
+ npm run release major # 0.1.0 → 1.0.0
264
+ ```
265
+
266
+ Builds, tests, publishes to npm, creates a GitHub release, and updates the Homebrew tap. Requires `gh` CLI and npm publish access.