@relyio/cli 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/README.md ADDED
@@ -0,0 +1,589 @@
1
+ # RelyIO CLI
2
+
3
+ Command Line Interface for RelyIO - a modern content management system.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ # Install globally
9
+ npm install -g @relyio/cli
10
+
11
+ # Or use with npx
12
+ npx @relyio/cli
13
+ ```
14
+
15
+ ## Quick Start
16
+
17
+ ```bash
18
+ # Initialize a new project
19
+ relyio init
20
+
21
+ # Log in to your account
22
+ relyio login
23
+
24
+ # Link to an existing project
25
+ relyio link --project_id <id>
26
+
27
+ # Check schema status
28
+ relyio status
29
+
30
+ # Deploy schemas
31
+ relyio deploy
32
+ ```
33
+
34
+ ## Schema Definition
35
+
36
+ RelyIO supports two ways to define your content schemas:
37
+
38
+ ### TypeScript Schemas (Recommended)
39
+
40
+ Define your schemas with full type safety using the RelyIO SDK:
41
+
42
+ ```typescript
43
+ // relyio/schema.ts
44
+ import { defineSchema, defineContentType, fields } from '@relyio/sdk/schema'
45
+
46
+ const blogPost = defineContentType('blogPost', {
47
+ displayName: 'Blog Post',
48
+ fields: [
49
+ fields.shortText('title', { config: { required: true } }),
50
+ fields.richText('content'),
51
+ fields.media('featuredImage'),
52
+ ],
53
+ })
54
+
55
+ export const schema = defineSchema({
56
+ contentTypes: { blogPost },
57
+ })
58
+ ```
59
+
60
+ ### YAML Schemas
61
+
62
+ Define schemas in YAML format for GitOps workflows:
63
+
64
+ ```yaml
65
+ # relyio/contentTypes/blogPost.yaml
66
+ name: blogPost
67
+ displayName: Blog Post
68
+ fields:
69
+ - name: title
70
+ type: shortText
71
+ config:
72
+ required: true
73
+ - name: content
74
+ type: richText
75
+ ```
76
+
77
+ The CLI automatically detects which format you're using—no configuration required.
78
+
79
+ ## Commands
80
+
81
+ ### Authentication
82
+
83
+ | Command | Description |
84
+ | -------- | ------------------------------ |
85
+ | `login` | Log in to your RelyIO account |
86
+ | `logout` | Log out of your RelyIO account |
87
+ | `whoami` | Show current user info |
88
+
89
+ ### Project Management
90
+
91
+ | Command | Description |
92
+ | ---------------- | ---------------------------------------- |
93
+ | `init` | Initialize a new RelyIO project |
94
+ | `link` | Link to an existing RelyIO project |
95
+ | `status` | Check local schema status against remote |
96
+ | `validate` | Validate schemas locally |
97
+ | `deploy` | Deploy schemas to a branch environment |
98
+ | `diff` | Show detailed schema differences |
99
+ | `generate-types` | Generate TypeScript/Python types |
100
+
101
+ ### Branch Environments
102
+
103
+ | Command | Description |
104
+ | --------------- | --------------------------- |
105
+ | `branch list` | List branch environments |
106
+ | `branch create` | Create a branch environment |
107
+ | `branch delete` | Delete a branch environment |
108
+
109
+ ### AI
110
+
111
+ | Command | Description |
112
+ | -------- | -------------------------------------------------------------- |
113
+ | `ai` | Start an interactive AI REPL session in the current project |
114
+ | `schema` | One-shot schema edits with the schema-architect agent |
115
+ | `draft` | One-shot content drafting with the content-editor agent |
116
+ | `query` | Ask a natural-language question about your content (read-only) |
117
+
118
+ ### Utilities
119
+
120
+ | Command | Description |
121
+ | ------------ | ------------------------------------ |
122
+ | `doctor` | Diagnose common configuration issues |
123
+ | `open` | Open RelyIO URLs in your browser |
124
+ | `alias` | Manage command shortcuts |
125
+ | `completion` | Generate shell completion scripts |
126
+ | `version` | Show CLI version |
127
+
128
+ ## Command Reference
129
+
130
+ ### `relyio status`
131
+
132
+ Check your local schema status with enhanced validation insights.
133
+
134
+ ```bash
135
+ # Check status once
136
+ relyio status
137
+
138
+ # Check status for a specific branch
139
+ relyio status -b my-branch
140
+
141
+ # Watch mode - automatically update when schema files change
142
+ relyio status --watch
143
+
144
+ # Output as JSON (for CI/CD)
145
+ relyio status --json
146
+
147
+ # Verbose output with detailed validation
148
+ relyio status --verbose
149
+ ```
150
+
151
+ **Options:**
152
+
153
+ - `-b, --branch <branch>` - Target branch (defaults to current Git branch)
154
+ - `-w, --watch` - Watch for schema file changes
155
+ - `--json` - Output as JSON for CI/CD integration
156
+ - `-v, --verbose` - Show detailed validation insights
157
+
158
+ ### `relyio deploy`
159
+
160
+ Deploy your schema to a branch environment.
161
+
162
+ ```bash
163
+ # Deploy to current branch
164
+ relyio deploy
165
+
166
+ # Deploy to a specific branch
167
+ relyio deploy -b development
168
+
169
+ # Skip confirmation prompt
170
+ relyio deploy --yes
171
+
172
+ # Output as JSON (for CI/CD)
173
+ relyio deploy --json
174
+ ```
175
+
176
+ **Options:**
177
+
178
+ - `-b, --branch <branch>` - Target branch (defaults to current Git branch)
179
+ - `-y, --yes` - Skip confirmation prompt
180
+ - `--skip-notes` - Skip deployment notes prompt
181
+ - `--json` - Output result as JSON
182
+
183
+ ### `relyio diff`
184
+
185
+ Show detailed differences between local and remote schemas.
186
+
187
+ ```bash
188
+ # Show diff for current branch
189
+ relyio diff
190
+
191
+ # Show diff for a specific branch
192
+ relyio diff -b production
193
+
194
+ # Output as JSON
195
+ relyio diff --json
196
+ ```
197
+
198
+ **Options:**
199
+
200
+ - `-b, --branch <branch>` - Target branch (defaults to current Git branch)
201
+ - `--json` - Output diff as JSON
202
+
203
+ ### `relyio validate`
204
+
205
+ Validate your local schema without connecting to the API.
206
+
207
+ ```bash
208
+ # Validate schema
209
+ relyio validate
210
+
211
+ # Output as JSON
212
+ relyio validate --json
213
+ ```
214
+
215
+ **Options:**
216
+
217
+ - `--json` - Output validation result as JSON
218
+
219
+ ### `relyio generate-types`
220
+
221
+ Generate typed code from your schema.
222
+
223
+ ```bash
224
+ # Generate TypeScript types
225
+ relyio generate-types
226
+
227
+ # Generate for a specific language
228
+ relyio generate-types -l python
229
+
230
+ # Generate multiple languages
231
+ relyio generate-types --languages typescript,python
232
+
233
+ # Custom output directory
234
+ relyio generate-types -o ./src/types
235
+
236
+ # Watch mode
237
+ relyio generate-types --watch
238
+ ```
239
+
240
+ **Options:**
241
+
242
+ - `-l, --language <language>` - Target language (default: typescript)
243
+ - `--languages <list>` - Comma-separated list of languages
244
+ - `-o, --output <dir>` - Output directory (default: ./types)
245
+ - `-c, --config <path>` - Path to codegen configuration file
246
+ - `-b, --branch <branch>` - Generate types from a specific branch schema
247
+ - `--naming-convention <style>` - Naming style (camelCase, PascalCase, snake_case)
248
+ - `--include-api-types` - Generate API response wrapper types
249
+ - `--include-helpers` - Generate utility functions
250
+ - `--module-format <format>` - Module format (esm, commonjs, both)
251
+ - `-w, --watch` - Watch for schema changes
252
+
253
+ ### `relyio ai`
254
+
255
+ Open an interactive AI REPL where you can chat with RelyIO agents about
256
+ your project. The REPL loads the active branch's schema, lets the agent
257
+ read/write files in the project (gated by your permission mode), and
258
+ supports slash commands like `/agent`, `/deploy`, `/undo`,
259
+ `/diff-history`.
260
+
261
+ ```bash
262
+ # Start a fresh session in the current project
263
+ relyio ai
264
+
265
+ # Pick the permission mode up front
266
+ relyio ai --mode safe # ask before every file mutation (default)
267
+ relyio ai --mode trust # remember per-tool decisions for the session
268
+ relyio ai --mode plan # read-only, no mutations
269
+ relyio ai --mode auto # run unattended (CI-friendly)
270
+
271
+ # Start with a specific agent
272
+ relyio ai --agent schema-architect
273
+
274
+ # Resume the most recent session
275
+ relyio ai --resume
276
+ ```
277
+
278
+ **Options:**
279
+
280
+ - `-m, --mode <mode>` — permission mode (`safe`, `trust`, `plan`, `auto`)
281
+ - `-a, --agent <slug>` — start with a specific agent (e.g. `schema-architect`, `content-editor`)
282
+ - `--resume` — resume the most recent local session
283
+
284
+ ### `relyio schema "<instruction>"`
285
+
286
+ One-shot schema edits via the `schema-architect` agent. The agent reads
287
+ the local schema, proposes edits as a unified diff, and (with
288
+ confirmation) writes them back to disk.
289
+
290
+ ```bash
291
+ # Add a field interactively
292
+ relyio schema "add a video field to blogPost"
293
+
294
+ # Target a non-default branch
295
+ relyio schema "rename the hero component to banner" --branch staging
296
+
297
+ # Apply changes without prompts (CI)
298
+ relyio schema "add SEO fields" --no-confirm
299
+
300
+ # Apply *and* deploy on success
301
+ relyio schema "add a tags field to blogPost" --deploy
302
+
303
+ # Plan-only mode — agent describes changes without writing anything
304
+ relyio schema "review my schema for missing required fields" --dry-run
305
+ ```
306
+
307
+ **Options:**
308
+
309
+ - `-b, --branch <name>` — override branch detection
310
+ - `--no-confirm` — auto-apply file changes without prompting
311
+ - `--dry-run` — plan-only mode (no writes, no deploy)
312
+ - `--deploy` — deploy the resolved branch on success
313
+
314
+ ### `relyio draft "<instruction>"`
315
+
316
+ One-shot content drafting via the `content-editor` agent. The agent
317
+ creates entries against the active dataset using the deployed schema.
318
+ Drafts go through the same proposal flow as the AI REPL, so you can
319
+ review every entry before applying.
320
+
321
+ ```bash
322
+ # Draft 5 blog posts
323
+ relyio draft "create 5 blog posts about AI development workflows"
324
+
325
+ # Draft against a specific dataset / branch
326
+ relyio draft "add 3 product reviews for the laptop SKU" --dataset prod
327
+
328
+ # Auto-commit the drafts (CI / scripted bulk ops)
329
+ relyio draft "translate every blog post to Spanish" --auto-commit
330
+ ```
331
+
332
+ **Options:**
333
+
334
+ - `-d, --dataset <name>` — dataset to draft into
335
+ - `-b, --branch <name>` — override branch detection
336
+ - `--no-confirm` — auto-approve incidental confirmations
337
+ - `--auto-commit` — apply every drafted proposal without prompting
338
+
339
+ > Note: drafting requires the local schema to be in sync with the
340
+ > remote branch. If you have uncommitted schema changes, `relyio
341
+ draft` blocks with a `schema-dirty` error and asks you to run
342
+ > `/deploy` (in the REPL) or `relyio deploy` first.
343
+
344
+ ### `relyio query "<question>"`
345
+
346
+ Ask a natural-language question about your content. Read-only — never
347
+ mutates anything. Results render as a table by default, or as JSON / CSV
348
+ / count for piping into other tools.
349
+
350
+ ```bash
351
+ # Default table view
352
+ relyio query "all published blog posts by John, sorted by date"
353
+
354
+ # Filter / sort / limit, table-rendered
355
+ relyio query "products under \$50 with low stock" --format table
356
+
357
+ # Just the count
358
+ relyio query "how many draft entries exist" --format count
359
+
360
+ # JSON for piping to jq
361
+ relyio query "entries modified this week" --format json --limit 100
362
+ ```
363
+
364
+ **Options:**
365
+
366
+ - `-f, --format <fmt>` — `table` (default), `json`, `csv`, or `count`
367
+ - `-d, --dataset <name>` — dataset to query (skips the picker)
368
+ - `-b, --branch <name>` — override branch detection
369
+ - `-l, --limit <n>` — max results (default 25, capped at 50)
370
+ - `--no-confirm` — auto-approve any incidental confirmations
371
+
372
+ The result table always includes the `entryUid` column so you can copy
373
+ canonical IDs straight into follow-up commands.
374
+
375
+ ### `relyio doctor`
376
+
377
+ Diagnose common configuration and connectivity issues.
378
+
379
+ ```bash
380
+ relyio doctor
381
+ ```
382
+
383
+ Checks:
384
+
385
+ - Node.js version
386
+ - Git installation
387
+ - Authentication status
388
+ - API connectivity
389
+ - Project configuration
390
+ - Schema files
391
+
392
+ ### `relyio open`
393
+
394
+ Open RelyIO URLs in your default browser.
395
+
396
+ ```bash
397
+ # Open dashboard
398
+ relyio open dashboard
399
+
400
+ # Open current project
401
+ relyio open project
402
+
403
+ # Open current branch
404
+ relyio open branch
405
+
406
+ # Open documentation
407
+ relyio open docs
408
+
409
+ # Open API docs
410
+ relyio open api
411
+ ```
412
+
413
+ ### `relyio alias`
414
+
415
+ Create shortcuts for frequently used commands.
416
+
417
+ ```bash
418
+ # List all aliases
419
+ relyio alias
420
+
421
+ # Create an alias
422
+ relyio alias set d deploy
423
+ relyio alias set sw "status --watch"
424
+
425
+ # Remove an alias
426
+ relyio alias remove d
427
+ ```
428
+
429
+ ### `relyio completion`
430
+
431
+ Generate shell completion scripts for tab completion.
432
+
433
+ ```bash
434
+ # Generate for your current shell
435
+ relyio completion
436
+
437
+ # Generate for a specific shell
438
+ relyio completion --shell zsh
439
+
440
+ # Install (add to your shell config)
441
+ # For bash:
442
+ eval "$(relyio completion --shell bash)"
443
+
444
+ # For zsh:
445
+ eval "$(relyio completion --shell zsh)"
446
+
447
+ # For fish:
448
+ relyio completion --shell fish | source
449
+ ```
450
+
451
+ ## Configuration
452
+
453
+ The CLI uses a three-tier configuration system:
454
+
455
+ 1. **Global User Configuration** - `~/.relyio/config.json`
456
+
457
+ - Stores non-secret state (project link, PAT metadata)
458
+ - Auth tokens themselves are kept in the OS keychain whenever
459
+ possible — see [Secret storage](#secret-storage) below
460
+
461
+ 2. **Project Link Configuration** - `.relyio-context.json`
462
+
463
+ - Stores project ID and organization ID
464
+ - Created when you run `relyio link` or `relyio init`
465
+
466
+ 3. **Local Project Configuration** - `relyio/config.yaml`
467
+ - Stores project-specific settings
468
+ - Created when you run `relyio init`
469
+
470
+ ## CI/CD Integration
471
+
472
+ All major commands support `--json` output for easy integration with CI/CD pipelines:
473
+
474
+ ```bash
475
+ # Check status in CI
476
+ STATUS=$(relyio status --json)
477
+ if echo "$STATUS" | jq -e '.hasChanges' > /dev/null; then
478
+ echo "Schema changes detected"
479
+ relyio deploy --yes --json
480
+ fi
481
+ ```
482
+
483
+ ### Exit Codes
484
+
485
+ The one-shot AI commands (`relyio schema`, `relyio draft`, `relyio
486
+ query`) follow a stable exit-code contract so shell pipelines and CI
487
+ jobs can branch reliably without parsing stdout:
488
+
489
+ | Code | Meaning |
490
+ | ----- | ------------------------------------------------------------------------------------------------------------------- |
491
+ | `0` | Success — agent finished and the user resolved everything that needed resolving. |
492
+ | `1` | Unrecoverable error — auth missing, project not linked, network failure, agent crashed. |
493
+ | `2` | Cannot proceed — schema is dirty (run `relyio deploy`), validation failed, or `--auto-commit` had nothing to apply. |
494
+ | `130` | User pressed `Ctrl-C` (POSIX `128 + SIGINT`). |
495
+
496
+ Other commands follow the standard `0 = ok`, `1 = error` convention.
497
+
498
+ ```bash
499
+ # Example: deploy schema only if drafting succeeds
500
+ relyio schema "add a tags field" --no-confirm
501
+ case $? in
502
+ 0) relyio deploy --yes ;;
503
+ 2) echo "schema is dirty — please run 'relyio deploy' first" >&2; exit 1 ;;
504
+ *) echo "drafting failed" >&2; exit 1 ;;
505
+ esac
506
+ ```
507
+
508
+ ## Configuration Details
509
+
510
+ ### Secret storage
511
+
512
+ The CLI persists auth tokens (login PAT, API keys) in your operating
513
+ system's secure credential store via [`keytar`][keytar] when available
514
+ — Keychain on macOS, Credential Vault on Windows, libsecret on Linux.
515
+
516
+ If the native module fails to load (commonly on headless Linux without
517
+ `libsecret-1-dev`, or in Docker images without build prerequisites),
518
+ the CLI prints a one-time stderr warning and falls back to plaintext
519
+ storage in `~/.relyio/config.json`. Run `relyio doctor` to see which
520
+ backend is currently active.
521
+
522
+ [keytar]: https://github.com/atom/node-keytar
523
+
524
+ ### Override URLs
525
+
526
+ | Variable | Default | Purpose |
527
+ | -------------------------- | ------------------------------ | --------------------------------------- |
528
+ | `RELYIO_API_URL` | `https://api.relyio.com` | Manage API base URL |
529
+ | `RELYIO_AI_GATEWAY_URL` | `https://ai.relyio.com` | AI gateway streaming endpoint |
530
+ | `RELYIO_DASHBOARD_URL` | `https://dashboard.relyio.com` | Dashboard URL used by `relyio open` |
531
+ | `RELYIO_BRANCH` | _(detected from git)_ | Force branch detection (CI containers) |
532
+ | `RELYIO_CLI_TEMPLATES_DIR` | _(bundled with CLI)_ | Override the `init` templates location |
533
+ | `DEBUG` | _(off)_ | Set to `true` to enable verbose logging |
534
+
535
+ ## Development
536
+
537
+ ### Setup
538
+
539
+ ```bash
540
+ # Clone the repository
541
+ git clone https://github.com/relyio/relyio.git
542
+ cd relyio
543
+
544
+ # Install dependencies
545
+ pnpm install
546
+
547
+ # Build the CLI
548
+ pnpm --filter @relyio/cli build
549
+ ```
550
+
551
+ ### Local Testing
552
+
553
+ ```bash
554
+ # Link the CLI globally
555
+ cd packages/customer/cli
556
+ pnpm local-test
557
+
558
+ # Now you can use the CLI from anywhere
559
+ relyio --help
560
+ ```
561
+
562
+ ### Running Tests
563
+
564
+ ```bash
565
+ # Run tests
566
+ pnpm --filter @relyio/cli test
567
+
568
+ # Run tests in watch mode
569
+ pnpm --filter @relyio/cli test:watch
570
+ ```
571
+
572
+ ## Publishing
573
+
574
+ This package is published as `@relyio/cli` on npm. To publish a new version:
575
+
576
+ ```bash
577
+ # Create a new changeset
578
+ pnpm changeset
579
+
580
+ # Build before publish
581
+ pnpm --filter @relyio/cli build
582
+
583
+ # Publishing (handled by CI)
584
+ pnpm publish -r
585
+ ```
586
+
587
+ ## License
588
+
589
+ MIT
@@ -0,0 +1,2 @@
1
+
2
+ export { }