@seed-hypermedia/cli 0.1.0-alpha.2 → 0.1.0-alpha.7

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 (3) hide show
  1. package/README.md +732 -52
  2. package/dist/index.js +336 -65
  3. package/package.json +10 -6
package/README.md CHANGED
@@ -1,87 +1,762 @@
1
- # Seed CLI
1
+ # Seed Hypermedia CLI
2
2
 
3
- Command-line interface for [Seed Hypermedia](https://hyper.media).
3
+ A command-line interface for interacting with the Seed Hypermedia network. Query documents, manage accounts, search content, and work with decentralized hypermedia from your terminal.
4
4
 
5
5
  ## Installation
6
6
 
7
7
  ```bash
8
- # Install globally (recommended)
8
+ # Install globally via npm
9
9
  npm install -g @seed-hypermedia/cli
10
- seed --help
11
10
 
12
11
  # Or run directly with npx
13
- npx seed-hypermedia --help
12
+ npx @seed-hypermedia/cli --help
14
13
  ```
15
14
 
16
- ## Usage
15
+ ### Development Mode
17
16
 
18
17
  ```bash
19
- # Fetch a document
20
- seed get hm://z6MkhaXgBZDvotDkL5257faiztiGiC2QtKLGpbnnEGta2doK
18
+ # From the CLI directory
19
+ cd frontend/apps/cli
21
20
 
22
- # Fetch as markdown
23
- seed get hm://... --md
21
+ # Run directly with bun
22
+ bun run src/index.ts [command]
24
23
 
25
- # Fetch with resolved embeds and queries
26
- seed get hm://... --md --resolve
24
+ # Or use the dev script
25
+ bun run dev [command]
26
+ ```
27
27
 
28
- # Search
29
- seed search "hello world"
28
+ ## Quick Start
30
29
 
31
- # List accounts
30
+ ```bash
31
+ # List all known accounts
32
32
  seed accounts
33
33
 
34
- # Query children
35
- seed children z6Mkh...
34
+ # Get a document
35
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
36
+
37
+ # Search for content
38
+ seed search "climate change"
39
+
40
+ # Get document as markdown
41
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --md
36
42
  ```
37
43
 
44
+ ---
45
+
46
+ ## Global Options
47
+
48
+ These options work with all commands:
49
+
50
+ | Option | Description |
51
+ |--------|-------------|
52
+ | `-s, --server <url>` | Server URL (default: `https://hyper.media`) |
53
+ | `--json` | Output as JSON (default) |
54
+ | `--yaml` | Output as YAML |
55
+ | `--pretty` | Pretty formatted output |
56
+ | `-q, --quiet` | Minimal output (IDs and names only) |
57
+ | `-V, --version` | Display version |
58
+ | `-h, --help` | Display help |
59
+
60
+ ### Examples
61
+
62
+ ```bash
63
+ # Use a different server
64
+ seed --server http://localhost:4000 accounts
65
+
66
+ # Get YAML output
67
+ seed accounts --yaml
68
+
69
+ # Get pretty-printed JSON
70
+ seed account z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --pretty
71
+
72
+ # Quiet mode for scripting
73
+ seed accounts -q
74
+ ```
75
+
76
+ ### Environment Variables
77
+
78
+ | Variable | Description |
79
+ |----------|-------------|
80
+ | `SEED_SERVER` | Default server URL |
81
+
82
+ ---
83
+
38
84
  ## Configuration
39
85
 
86
+ The CLI stores configuration in `~/.seed/config.json`.
87
+
88
+ ### Show Configuration
89
+
40
90
  ```bash
41
- # Set default server
42
- export SEED_SERVER=https://dev.hyper.media
91
+ seed config --show
92
+ ```
43
93
 
44
- # Or use --server flag
45
- seed --server https://hyper.media get hm://...
94
+ ### Set Default Server
95
+
96
+ ```bash
97
+ seed config --server https://hyper.media
46
98
  ```
47
99
 
48
- ## Commands
100
+ ---
49
101
 
50
- ### Read Operations
102
+ ## Document Commands
51
103
 
52
- | Command | Description |
53
- |---------|-------------|
54
- | `get <id>` | Fetch document/entity |
55
- | `account <uid>` | Get account info |
56
- | `accounts` | List all accounts |
57
- | `search <query>` | Full-text search |
58
- | `query <space>` | List documents in space |
59
- | `children <space>` | List child documents |
60
- | `comments <id>` | List comments |
61
- | `discussions <id>` | List threaded discussions |
62
- | `changes <id>` | Document history |
63
- | `citations <id>` | Backlinks |
64
- | `capabilities <id>` | Access control |
65
- | `activity` | Activity feed |
66
- | `stats <id>` | Interaction statistics |
104
+ ### `seed get <id>`
67
105
 
68
- ### Output Options
106
+ Fetch a document, comment, or entity by Hypermedia ID.
69
107
 
70
- | Flag | Description |
71
- |------|-------------|
72
- | `--server <url>` | Server URL |
73
- | `--json` | JSON output (default) |
74
- | `--yaml` | YAML output |
75
- | `--pretty` | Pretty formatted output |
76
- | `-q, --quiet` | Minimal output (id + name) |
108
+ **Options:**
109
+
110
+ | Option | Description |
111
+ |--------|-------------|
112
+ | `-m, --metadata` | Fetch metadata only (faster) |
113
+ | `--md` | Output as Markdown |
114
+ | `--frontmatter` | Include YAML frontmatter (with `--md`) |
115
+ | `-r, --resolve` | Resolve embeds, mentions, and queries (with `--md`) |
116
+ | `-q, --quiet` | Output minimal info |
117
+
118
+ **Examples:**
119
+
120
+ ```bash
121
+ # Get document as JSON
122
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
123
+
124
+ # Get document as Markdown
125
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --md
126
+
127
+ # Get Markdown with frontmatter metadata
128
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --md --frontmatter
129
+
130
+ # Resolve all embeds and queries in the document
131
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --md --resolve
132
+
133
+ # Get just the metadata (name, summary, etc.)
134
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou -m
135
+
136
+ # Get a specific version of a document
137
+ seed get "hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou?v=bafy..."
138
+
139
+ # Get a child document at a path
140
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou/child-path
141
+
142
+ # Quiet mode: just print the document title
143
+ seed get hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou -q
144
+ ```
145
+
146
+ ### Markdown Output
147
+
148
+ When using `--md`, the CLI converts documents to GitHub-flavored Markdown:
149
+
150
+ - **Headings** are converted to `#`, `##`, etc.
151
+ - **Bold/Italic/Code** annotations are preserved
152
+ - **Links** are converted to `[text](url)` format
153
+ - **Images** become `![alt](url)` with IPFS URLs converted to gateway URLs
154
+ - **Code blocks** include language syntax highlighting markers
155
+ - **Math blocks** are wrapped in `$$...$$` (LaTeX)
156
+ - **Embeds** show as quoted blocks with links
157
+ - **Queries** are resolved to lists of linked documents (with `--resolve`)
158
+
159
+ ### `seed cid <cid>`
160
+
161
+ Fetch raw IPFS block data by CID.
162
+
163
+ ```bash
164
+ seed cid bafybeigdyrzt5sfp7udm7hu76uh7y26nf3efuylqabf3oclgtqy55fbzdi
165
+ ```
166
+
167
+ ### `seed stats <id>`
168
+
169
+ Get interaction statistics for a document.
170
+
171
+ ```bash
172
+ seed stats hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
173
+ ```
174
+
175
+ **Output includes:**
176
+
177
+ - Citation count
178
+ - Comment count
179
+ - Change count
180
+ - Child document count
181
+ - Per-block citation and comment counts
182
+
183
+ ---
184
+
185
+ ## Account Commands
186
+
187
+ ### `seed accounts`
188
+
189
+ List all known accounts on the server.
190
+
191
+ ```bash
192
+ # Full JSON output
193
+ seed accounts
194
+
195
+ # Compact output: ID<tab>name per line
196
+ seed accounts -q
197
+
198
+ # As YAML
199
+ seed accounts --yaml
200
+ ```
201
+
202
+ ### `seed account <uid>`
203
+
204
+ Get detailed information about a specific account.
205
+
206
+ ```bash
207
+ # Get account info
208
+ seed account z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
209
+
210
+ # Pretty print
211
+ seed account z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --pretty
212
+
213
+ # Just the name (or ID if no name)
214
+ seed account z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou -q
215
+ ```
216
+
217
+ ### `seed contacts <uid>`
218
+
219
+ List contacts for an account.
220
+
221
+ ```bash
222
+ # Full output
223
+ seed contacts z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
224
+
225
+ # Just names
226
+ seed contacts z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou -q
227
+ ```
228
+
229
+ ---
230
+
231
+ ## Search Commands
232
+
233
+ ### `seed search <query>`
234
+
235
+ Search for documents across the network.
236
+
237
+ **Options:**
238
+
239
+ | Option | Description |
240
+ |--------|-------------|
241
+ | `-a, --account <uid>` | Limit search to a specific account |
242
+ | `-q, --quiet` | Output ID and title only |
243
+
244
+ **Examples:**
245
+
246
+ ```bash
247
+ # Search all documents
248
+ seed search "artificial intelligence"
249
+
250
+ # Search within a specific account
251
+ seed search "meeting notes" --account z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
252
+
253
+ # Compact output for scripting
254
+ seed search "project" -q
255
+ ```
256
+
257
+ ---
258
+
259
+ ## Query Commands
260
+
261
+ ### `seed query <space>`
262
+
263
+ List documents in a space (account).
264
+
265
+ **Options:**
266
+
267
+ | Option | Description |
268
+ |--------|-------------|
269
+ | `-p, --path <path>` | Path prefix to filter |
270
+ | `-m, --mode <mode>` | `Children` (default) or `AllDescendants` |
271
+ | `-l, --limit <n>` | Maximum results |
272
+ | `--sort <term>` | Sort by: `Path`, `Title`, `CreateTime`, `UpdateTime`, `DisplayTime` |
273
+ | `--reverse` | Reverse sort order |
274
+ | `-q, --quiet` | Output ID and name only |
275
+
276
+ **Examples:**
277
+
278
+ ```bash
279
+ # List direct children of an account
280
+ seed query z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
281
+
282
+ # List all descendants recursively
283
+ seed query z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --mode AllDescendants
284
+
285
+ # List children under a specific path
286
+ seed query z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --path projects
287
+
288
+ # Sort by update time (newest first)
289
+ seed query z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --sort UpdateTime --reverse
290
+
291
+ # Limit to 5 results
292
+ seed query z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --limit 5
293
+
294
+ # Compact output
295
+ seed query z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou -q
296
+ ```
297
+
298
+ ### `seed children <space>`
299
+
300
+ Shorthand for `query --mode Children`.
301
+
302
+ ```bash
303
+ # These are equivalent:
304
+ seed children z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
305
+ seed query z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --mode Children
306
+ ```
307
+
308
+ ### `seed citations <id>`
309
+
310
+ List documents that cite (link to) a given resource.
311
+
312
+ ```bash
313
+ # Full output
314
+ seed citations hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
315
+
316
+ # Just source IDs
317
+ seed citations hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou -q
318
+ ```
319
+
320
+ ### `seed capabilities <id>`
321
+
322
+ List access control capabilities for a document.
323
+
324
+ ```bash
325
+ seed capabilities hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
326
+ ```
327
+
328
+ **Output includes:**
329
+
330
+ - Capability ID
331
+ - Issuer (who granted the capability)
332
+ - Delegate (who received the capability)
333
+ - Role (Writer, Editor, etc.)
334
+ - Path restrictions
335
+ - Whether it's recursive
336
+
337
+ ---
338
+
339
+ ## Comments Commands
340
+
341
+ ### `seed comments <targetId>`
342
+
343
+ List all comments on a document.
344
+
345
+ ```bash
346
+ # Full output
347
+ seed comments hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
348
+
349
+ # Compact: ID<tab>author per line
350
+ seed comments hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou -q
351
+ ```
352
+
353
+ ### `seed discussions <targetId>`
354
+
355
+ List threaded discussions on a document.
356
+
357
+ **Options:**
358
+
359
+ | Option | Description |
360
+ |--------|-------------|
361
+ | `-c, --comment <id>` | Filter to a specific thread |
362
+
363
+ ```bash
364
+ # All discussions
365
+ seed discussions hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
366
+
367
+ # Specific thread
368
+ seed discussions hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou --comment bafy...
369
+ ```
370
+
371
+ ### `seed comment <id>`
372
+
373
+ Get a single comment by its ID.
374
+
375
+ ```bash
376
+ seed comment hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou?c=bafy...
377
+ ```
378
+
379
+ ---
380
+
381
+ ## Activity Commands
382
+
383
+ ### `seed activity`
384
+
385
+ List recent activity events across the network.
386
+
387
+ **Options:**
388
+
389
+ | Option | Description |
390
+ |--------|-------------|
391
+ | `-l, --limit <n>` | Page size |
392
+ | `-t, --token <token>` | Pagination token |
393
+ | `--authors <uids>` | Filter by author UIDs (comma-separated) |
394
+ | `--resource <id>` | Filter by resource |
395
+ | `-q, --quiet` | Summary output only |
396
+
397
+ **Examples:**
398
+
399
+ ```bash
400
+ # Recent activity
401
+ seed activity
402
+
403
+ # Limit to 10 events
404
+ seed activity --limit 10
405
+
406
+ # Filter by author
407
+ seed activity --authors z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
77
408
 
78
- ### Markdown Options (for `get`)
409
+ # Filter by resource
410
+ seed activity --resource hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
79
411
 
80
- | Flag | Description |
81
- |------|-------------|
82
- | `--md` | Output as markdown |
83
- | `--frontmatter` | Include YAML frontmatter |
84
- | `-r, --resolve` | Resolve embeds, mentions, queries |
412
+ # Paginate through results
413
+ seed activity --limit 20
414
+ # ... note the nextPageToken in output ...
415
+ seed activity --limit 20 --token <nextPageToken>
416
+ ```
417
+
418
+ ---
419
+
420
+ ## Changes Commands
421
+
422
+ ### `seed changes <targetId>`
423
+
424
+ List the change history (versions) of a document.
425
+
426
+ ```bash
427
+ # Full output
428
+ seed changes hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
429
+
430
+ # Compact: CID<tab>author per line
431
+ seed changes hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou -q
432
+ ```
433
+
434
+ **Output includes:**
435
+
436
+ - Change ID (CID)
437
+ - Author
438
+ - Dependencies (parent changes)
439
+ - Create time
440
+ - Latest version CID
441
+
442
+ ---
443
+
444
+ ## Key Management Commands
445
+
446
+ Local key management for signing documents. Keys are stored in `~/.seed/keys.json`.
447
+
448
+ ### `seed key generate`
449
+
450
+ Generate a new signing key from a BIP-39 mnemonic.
451
+
452
+ **Options:**
453
+
454
+ | Option | Description |
455
+ |--------|-------------|
456
+ | `-n, --name <name>` | Name for the key (default: "default") |
457
+ | `-w, --words <count>` | Mnemonic word count: 12 or 24 (default: 12) |
458
+ | `--passphrase <pass>` | Optional BIP-39 passphrase |
459
+ | `--show-mnemonic` | Display the mnemonic (save it securely!) |
460
+
461
+ **Examples:**
462
+
463
+ ```bash
464
+ # Generate a new key
465
+ seed key generate -n myaccount
466
+
467
+ # Generate with 24 words and show mnemonic
468
+ seed key generate -n secure-key --words 24 --show-mnemonic
469
+
470
+ # Generate with passphrase
471
+ seed key generate -n passphrase-protected --passphrase "my secret"
472
+ ```
473
+
474
+ ### `seed key import`
475
+
476
+ Import an existing key from a mnemonic.
477
+
478
+ **Options:**
479
+
480
+ | Option | Description |
481
+ |--------|-------------|
482
+ | `-n, --name <name>` | Name for the key (default: "imported") |
483
+ | `--passphrase <pass>` | Optional BIP-39 passphrase |
484
+
485
+ ```bash
486
+ # Import a 12-word mnemonic
487
+ seed key import -n restored "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
488
+
489
+ # Import with passphrase
490
+ seed key import -n restored --passphrase "my secret" "word1 word2 ... word12"
491
+ ```
492
+
493
+ ### `seed key list`
494
+
495
+ List all stored signing keys.
496
+
497
+ ```bash
498
+ seed key list
499
+
500
+ # Just names
501
+ seed key list -q
502
+ ```
503
+
504
+ ### `seed key show [nameOrId]`
505
+
506
+ Show details for a specific key (or default key if none specified).
507
+
508
+ **Options:**
509
+
510
+ | Option | Description |
511
+ |--------|-------------|
512
+ | `--show-mnemonic` | Also display the mnemonic (DANGER) |
513
+
514
+ ```bash
515
+ # Show default key
516
+ seed key show
517
+
518
+ # Show specific key
519
+ seed key show myaccount
520
+
521
+ # Show with mnemonic (be careful!)
522
+ seed key show myaccount --show-mnemonic
523
+ ```
524
+
525
+ ### `seed key default [nameOrId]`
526
+
527
+ Set or show the default signing key.
528
+
529
+ ```bash
530
+ # Show current default
531
+ seed key default
532
+
533
+ # Set default
534
+ seed key default myaccount
535
+ ```
536
+
537
+ ### `seed key remove <nameOrId>`
538
+
539
+ Remove a stored key.
540
+
541
+ **Options:**
542
+
543
+ | Option | Description |
544
+ |--------|-------------|
545
+ | `-f, --force` | Skip confirmation |
546
+
547
+ ```bash
548
+ # Will show warning and require --force
549
+ seed key remove myaccount
550
+
551
+ # Actually remove it
552
+ seed key remove myaccount --force
553
+ ```
554
+
555
+ ### `seed key derive`
556
+
557
+ Derive an account ID from a mnemonic without storing the key.
558
+
559
+ ```bash
560
+ seed key derive "abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon abandon about"
561
+ # Output: z6MkiTBz1ymuepAQ4HEHYSF1H8quG5GLVVQR3djdX3mDooWp
562
+
563
+ # With passphrase
564
+ seed key derive --passphrase "secret" "word1 word2 ... word12"
565
+ ```
566
+
567
+ ---
568
+
569
+ ## Hypermedia ID Format
570
+
571
+ Seed uses Hypermedia IDs (HM IDs) to reference documents:
572
+
573
+ ```
574
+ hm://<account-uid>[/<path>][?v=<version>][#<block-ref>]
575
+ ```
576
+
577
+ **Components:**
578
+
579
+ | Component | Description |
580
+ |-----------|-------------|
581
+ | `account-uid` | The account's public key ID (z6Mk...) |
582
+ | `path` | Optional path segments (e.g., `/projects/alpha`) |
583
+ | `version` | Optional version CID (`?v=bafy...`) |
584
+ | `block-ref` | Optional block reference (`#block-id`) |
585
+
586
+ **Examples:**
587
+
588
+ ```bash
589
+ # Account home document
590
+ hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou
591
+
592
+ # Child document
593
+ hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou/projects/alpha
594
+
595
+ # Specific version
596
+ hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou?v=bafy2bzacedfvnsgafyaocwbf7gnszzc576thsuxprntawefhhprdi2mlplbo4
597
+
598
+ # Block reference
599
+ hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou#block-abc123
600
+
601
+ # Comment reference
602
+ hm://z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou?c=bafy...
603
+ ```
604
+
605
+ ---
606
+
607
+ ## Scripting Examples
608
+
609
+ ### Export all documents as Markdown
610
+
611
+ ```bash
612
+ #!/bin/bash
613
+ ACCOUNT="z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou"
614
+
615
+ # Get all document IDs
616
+ seed query "$ACCOUNT" --mode AllDescendants -q | while IFS=$'\t' read -r id name; do
617
+ # Create filename from name or path
618
+ filename=$(echo "$name" | tr ' /' '_' | tr -cd '[:alnum:]_-')
619
+ [ -z "$filename" ] && filename="unnamed_$(echo $id | md5sum | head -c 8)"
620
+
621
+ # Export as markdown
622
+ seed get "$id" --md --resolve > "${filename}.md"
623
+ echo "Exported: ${filename}.md"
624
+ done
625
+ ```
626
+
627
+ ### Monitor activity feed
628
+
629
+ ```bash
630
+ #!/bin/bash
631
+ while true; do
632
+ seed activity --limit 5 -q
633
+ sleep 60
634
+ done
635
+ ```
636
+
637
+ ### Backup all keys
638
+
639
+ ```bash
640
+ #!/bin/bash
641
+ seed key list -q | while read name; do
642
+ echo "=== Key: $name ==="
643
+ seed key show "$name" --show-mnemonic
644
+ echo ""
645
+ done
646
+ ```
647
+
648
+ ### Find documents by author
649
+
650
+ ```bash
651
+ #!/bin/bash
652
+ AUTHOR="z6MkrbYsRzKb1VABdvhsDSAk6JK8fAszKsyHhcaZigYeWCou"
653
+
654
+ seed activity --authors "$AUTHOR" --limit 100 | jq -r '.events[].resource' | sort -u
655
+ ```
656
+
657
+ ### Check if document exists
658
+
659
+ ```bash
660
+ #!/bin/bash
661
+ if seed get "$1" -q 2>/dev/null | grep -q "not-found"; then
662
+ echo "Document not found"
663
+ exit 1
664
+ else
665
+ echo "Document exists"
666
+ exit 0
667
+ fi
668
+ ```
669
+
670
+ ---
671
+
672
+ ## Output Formats
673
+
674
+ ### JSON (default)
675
+
676
+ ```bash
677
+ seed accounts
678
+ ```
679
+
680
+ ```json
681
+ {
682
+ "accounts": [
683
+ {
684
+ "id": {"id": "hm://z6Mk...", "uid": "z6Mk..."},
685
+ "metadata": {"name": "Account Name"}
686
+ }
687
+ ]
688
+ }
689
+ ```
690
+
691
+ ### YAML
692
+
693
+ ```bash
694
+ seed accounts --yaml
695
+ ```
696
+
697
+ ```yaml
698
+ accounts:
699
+ - id:
700
+ id: hm://z6Mk...
701
+ uid: z6Mk...
702
+ metadata:
703
+ name: Account Name
704
+ ```
705
+
706
+ ### Pretty JSON
707
+
708
+ ```bash
709
+ seed accounts --pretty
710
+ ```
711
+
712
+ Outputs indented, colorized JSON for readability.
713
+
714
+ ### Quiet Mode
715
+
716
+ ```bash
717
+ seed accounts -q
718
+ ```
719
+
720
+ ```
721
+ hm://z6Mk... Account Name
722
+ hm://z6Mk... Another Account
723
+ ```
724
+
725
+ Tab-separated values, one per line. Ideal for piping to other tools.
726
+
727
+ ---
728
+
729
+ ## Error Handling
730
+
731
+ The CLI uses standard exit codes:
732
+
733
+ | Code | Meaning |
734
+ |------|---------|
735
+ | 0 | Success |
736
+ | 1 | Error (invalid input, network error, not found, etc.) |
737
+
738
+ Errors are printed to stderr with a descriptive message:
739
+
740
+ ```bash
741
+ $ seed get hm://invalid
742
+ Error: Invalid Hypermedia ID
743
+
744
+ $ seed account nonexistent
745
+ Error: API error (500): Account not found
746
+ ```
747
+
748
+ ---
749
+
750
+ ## Data Storage
751
+
752
+ | Path | Contents |
753
+ |------|----------|
754
+ | `~/.seed/config.json` | CLI configuration (server URL, default account) |
755
+ | `~/.seed/keys.json` | Stored signing keys (mnemonics, account IDs) |
756
+
757
+ Files are created with mode `0600` (owner read/write only) for security.
758
+
759
+ ---
85
760
 
86
761
  ## Development
87
762
 
@@ -94,8 +769,13 @@ npm run build
94
769
 
95
770
  # Type check
96
771
  npm run typecheck
772
+
773
+ # Run tests
774
+ bun test src/test/cli-live.test.ts
97
775
  ```
98
776
 
777
+ ---
778
+
99
779
  ## License
100
780
 
101
781
  MIT