relic 0.2.0 → 0.4.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.
package/README.md ADDED
@@ -0,0 +1,129 @@
1
+ # Relic CLI
2
+
3
+ Zero-knowledge secret layer CLI. Fetches encrypted secrets from the server, decrypts them locally, and injects them into the process environment.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun install
9
+ ```
10
+
11
+ ## Commands
12
+
13
+ | Command | Description |
14
+ |---------|-------------|
15
+ | `relic` | Launch the TUI (default) |
16
+ | `relic login` | Authenticate via device code flow |
17
+ | `relic logout` | Clear session, cached keys, and password |
18
+ | `relic whoami` | Show current user (name, email, plan) |
19
+ | `relic projects` | List projects with environments and folders |
20
+ | `relic init` | Create `relic.toml` and `.relic/` directory |
21
+ | `relic run` | Run a command with secrets injected |
22
+ | `relic telemetry status` | Show telemetry status |
23
+ | `relic telemetry enable` | Enable telemetry |
24
+ | `relic telemetry disable` | Disable telemetry |
25
+
26
+ ### `relic run`
27
+
28
+ ```bash
29
+ relic run -e <environment> [options] -- <command>
30
+ ```
31
+
32
+ | Flag | Description |
33
+ |------|-------------|
34
+ | `-e, --environment` | Environment name (required) |
35
+ | `-f, --folder` | Folder name |
36
+ | `-s, --scope` | `client`, `server`, or `shared` |
37
+ | `-p, --project` | Project ID (overrides `relic.toml`) |
38
+
39
+ ```bash
40
+ relic run -e production -- npm run deploy
41
+ relic run -e staging -f database -- ./migrate.sh
42
+ relic run -e production -s client -- npm run build
43
+ ```
44
+
45
+ ## Configuration
46
+
47
+ `relic.toml` in project root:
48
+
49
+ ```toml
50
+ project_id = "<uuid>"
51
+ ```
52
+
53
+ Created by `relic init`. The CLI walks up from the current directory to find it.
54
+
55
+ ## Runner (FFI)
56
+
57
+ Secret injection uses a Rust binary (`packages/runner`) loaded via Bun FFI (`dlopen`). The runner:
58
+
59
+ - Spawns the child process with a clean environment (`env_clear()`)
60
+ - Injects only the decrypted secrets
61
+ - Forwards signals (SIGTERM, SIGINT)
62
+ - Uses `Zeroizing` for secret memory and disables core dumps
63
+
64
+ Prebuilt binaries in `prebuilds/` for: `darwin-arm64`, `darwin-x64`, `linux-x64`, `win32-x64`.
65
+
66
+ ## Caching
67
+
68
+ Local SQLite cache at `.relic/cache.db` (relative to `relic.toml` location). Used in session mode only; API key mode always fetches fresh data.
69
+
70
+ **Cached data:** environment/folder ID mappings, encrypted secrets, encrypted project key.
71
+
72
+ **Invalidation:** on each `relic run`, the CLI compares local `lastCachedAt` against the backend `updatedAt`. Stale cache triggers a fresh fetch. Key rotation invalidates all caches.
73
+
74
+ Scope filtering (`--scope`) is applied locally against cached data.
75
+
76
+ ## CI/CD
77
+
78
+ Use API keys instead of interactive login:
79
+
80
+ | Variable | Description |
81
+ |----------|-------------|
82
+ | `RELIC_API_KEY` | API key for authentication |
83
+ | `RELIC_PASSWORD` | Master password for decryption |
84
+ | `RELIC_PROJECT_ID` | Project ID (optional if `relic.toml` exists) |
85
+ | `CONVEX_SITE_URL` | Convex HTTP actions URL |
86
+
87
+ ### GitHub Actions
88
+
89
+ ```yaml
90
+ - name: Deploy with secrets
91
+ env:
92
+ RELIC_API_KEY: ${{ secrets.RELIC_API_KEY }}
93
+ RELIC_PASSWORD: ${{ secrets.RELIC_PASSWORD }}
94
+ RELIC_PROJECT_ID: ${{ secrets.RELIC_PROJECT_ID }}
95
+ CONVEX_URL: ${{ secrets.CONVEX_URL }}
96
+ CONVEX_SITE_URL: ${{ secrets.CONVEX_SITE_URL }}
97
+ run: bunx relic run -e production -- npm run deploy
98
+ ```
99
+
100
+ ## Structure
101
+
102
+ ```
103
+ ├── index.ts # Entry point (commander setup)
104
+ ├── commands/
105
+ │ ├── init.ts # relic init
106
+ │ ├── login.ts # relic login
107
+ │ ├── logout.ts # relic logout
108
+ │ ├── whoami.ts # relic whoami
109
+ │ ├── projects.ts # relic projects
110
+ │ ├── run.ts # relic run
111
+ │ └── telemetry.ts # relic telemetry
112
+ ├── lib/
113
+ │ ├── api.ts # Convex API client, secret export
114
+ │ ├── config.ts # relic.toml loading/saving
115
+ │ ├── crypto.ts # Secret decryption helpers
116
+ │ └── types.ts # SecretScope type
117
+ ├── ffi/
118
+ │ ├── bridge.ts # RunnerBridge FFI wrapper
119
+ │ ├── helper.ts # Library loading (dlopen)
120
+ │ └── constants.ts # URLs
121
+ └── helpers/
122
+ └── cache.ts # SQLite cache
123
+ ```
124
+
125
+ ## Development
126
+
127
+ ```bash
128
+ bun run index.ts
129
+ ```