@keywaysh/cli 0.0.1 → 0.0.3

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 +285 -10
  2. package/dist/cli.js +1322 -123
  3. package/package.json +19 -12
package/README.md CHANGED
@@ -1,29 +1,193 @@
1
1
  # Keyway CLI
2
2
 
3
- > One link to all your secrets
3
+ > GitHub-native secrets manager for dev teams
4
+
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
6
+ [![npm version](https://badge.fury.io/js/%40keywaysh%2Fcli.svg)](https://www.npmjs.com/package/@keywaysh/cli)
4
7
 
5
8
  ## Installation
6
9
 
7
10
  ```bash
8
- npm install -g @keywaysh/cli
11
+ npm install @keywaysh/cli -g
9
12
  ```
10
13
 
11
- ## Usage
14
+ ## Quick Start
15
+
12
16
  ```bash
13
- # Initialize in your project
17
+ # Authenticate and create your vault
18
+ keyway login
14
19
  keyway init
15
20
 
16
- # Pull secrets from vault
21
+ # Push your secrets (defaults to .env; pick a file with --file)
22
+ keyway push
23
+
24
+ # On another machine, pull them back
17
25
  keyway pull
26
+ ```
27
+
28
+ ## Commands
29
+
30
+ ### `keyway login`
31
+
32
+ Authenticate with GitHub through the Keyway OAuth/device flow and cache a session locally.
33
+
34
+ ```bash
35
+ keyway login
36
+ ```
37
+
38
+ If you forget to log in, `init`, `push`, and `pull` will prompt you to authenticate (skip with `--no-login-prompt` in CI).
39
+
40
+ Fine-grained PAT alternative:
41
+
42
+ ```bash
43
+ keyway login --token
44
+ ```
45
+
46
+ This opens GitHub to create a repo-scoped fine-grained PAT (metadata: read-only, no account permissions). Paste the `github_pat_...` token when prompted; the CLI validates and stores it.
18
47
 
19
- # List all secrets
20
- keyway list
48
+ ### `keyway init`
21
49
 
22
- # Add a new secret
23
- keyway add API_KEY sk_test_123
50
+ Initialize a vault for the current repository.
51
+
52
+ ```bash
53
+ keyway init
54
+ ```
55
+
56
+ **Requirements:**
57
+ - Must be in a git repository
58
+ - Repository must have a GitHub remote
59
+ - Authenticated via `keyway login` (or provide `GITHUB_TOKEN`)
60
+
61
+ ### `keyway push`
62
+
63
+ Upload secrets from a local env file to the vault.
64
+
65
+ ```bash
66
+ # Push env file to development environment (default)
67
+ keyway push --file .env
68
+
69
+ # Push to a specific environment
70
+ keyway push --env production
71
+
72
+ # Push a different file
73
+ keyway push --file .env.staging --env staging
24
74
  ```
25
75
 
76
+ **Options:**
77
+ - `-e, --env <environment>` - Environment name (default: "development")
78
+ - `-f, --file <file>` - File to push (default file used if not provided)
79
+
80
+ ### `keyway pull`
81
+
82
+ Download secrets from the vault to a local env file.
83
+
84
+ ```bash
85
+ # Pull development environment to your env file (default path if omitted)
86
+ keyway pull --file .env
87
+
88
+ # Pull from a specific environment
89
+ keyway pull --env production
90
+
91
+ # Pull to a different file
92
+ keyway pull --file .env.local --env development
93
+ ```
94
+
95
+ **Options:**
96
+ - `-e, --env <environment>` - Environment name (default: "development")
97
+ - `-f, --file <file>` - File to write to (default file used if not provided)
98
+
99
+ ### `keyway doctor`
100
+
101
+ Run comprehensive environment diagnostics.
102
+
103
+ ```bash
104
+ # Run all checks
105
+ keyway doctor
106
+
107
+ # Output as JSON (for CI/CD)
108
+ keyway doctor --json
109
+
110
+ # Strict mode (treat warnings as failures)
111
+ keyway doctor --strict
112
+ ```
113
+
114
+ **Checks performed:**
115
+ - ✅ Node.js version (≥18.0.0 required)
116
+ - ✅ Git installation and repository status
117
+ - ✅ Network connectivity to API
118
+ - ✅ File system write permissions
119
+ - ✅ .gitignore configuration for environment files
120
+
121
+ ## Configuration
122
+
123
+ ### GitHub Token
124
+
125
+ Keyway prefers the OAuth/device flow:
126
+
127
+ ```bash
128
+ keyway login
129
+ ```
130
+
131
+ This opens a browser (or gives you a code/URL) and stores a Keyway token in `~/.config/keyway/config.json`.
132
+
133
+ If you cannot use the login flow, set a GitHub token manually:
134
+
135
+ **Option 1: Environment Variable**
136
+
137
+ ```bash
138
+ export GITHUB_TOKEN=your_github_personal_access_token
139
+ ```
140
+
141
+ **Option 2: Git Config**
142
+
143
+ ```bash
144
+ git config --global github.token your_github_personal_access_token
145
+ ```
146
+
147
+ **Creating a GitHub Token:**
148
+
149
+ 1. Go to GitHub Settings → Developer settings → Personal access tokens → Tokens (classic)
150
+ 2. Click "Generate new token"
151
+ 3. Select scopes: `repo` (Full control of private repositories)
152
+ 4. Generate and copy the token
153
+
154
+ ### API URL
155
+
156
+ By default, Keyway uses the production API at `https://keyway-backend-production.up.railway.app`. To point to another API:
157
+
158
+ ```bash
159
+ export KEYWAY_API_URL=http://localhost:3000
160
+ ```
161
+
162
+ ### Analytics
163
+
164
+ Keyway uses PostHog for privacy-first analytics. To configure:
165
+
166
+ ```bash
167
+ export KEYWAY_POSTHOG_KEY=your_posthog_key
168
+ export KEYWAY_POSTHOG_HOST=https://app.posthog.com
169
+ ```
170
+
171
+ Disable telemetry:
172
+
173
+ ```bash
174
+ export KEYWAY_DISABLE_TELEMETRY=1
175
+ ```
176
+
177
+ The CLI ships with built-in analytics defaults; use the env vars above to override for development.
178
+
179
+ **Privacy:** No secret names or values are ever sent to analytics.
180
+
181
+ ## How It Works
182
+
183
+ 1. **Authentication**: Uses your GitHub token to verify identity
184
+ 2. **Authorization**: Checks if you're a collaborator/admin on the repository
185
+ 3. **Encryption**: All secrets are encrypted server-side with AES-256-GCM
186
+ 4. **Storage**: Encrypted secrets stored in PostgreSQL
187
+ 5. **Retrieval**: Secrets are decrypted and returned only to authorized users
188
+
26
189
  ## Development
190
+
27
191
  ```bash
28
192
  # Install dependencies
29
193
  npm install
@@ -34,9 +198,120 @@ npm run dev
34
198
  # Build
35
199
  npm run build
36
200
 
201
+ # Watch mode
202
+ npm run build:watch
203
+
204
+ # Run tests
205
+ npm test
206
+
37
207
  # Test locally
38
208
  npm link
209
+ keyway --version
210
+ ```
211
+
212
+ ## Architecture
213
+
214
+ ```
215
+ src/
216
+ ├── cli.tsx # Main CLI entry point with commander
217
+ ├── types.ts # TypeScript types and interfaces
218
+ ├── ui/ # Ink React components
219
+ │ ├── Banner.tsx # Startup banner with gradient
220
+ │ └── Spinner.tsx # Loading spinner component
221
+ ├── cmds/ # Command implementations
222
+ │ ├── init.ts # Initialize vault
223
+ │ ├── push.ts # Push secrets
224
+ │ ├── pull.ts # Pull secrets
225
+ │ └── doctor.tsx # Environment diagnostics
226
+ ├── utils/ # Utility functions
227
+ │ ├── analytics.ts # PostHog integration
228
+ │ ├── api.ts # API client
229
+ │ └── git.ts # Git helpers
230
+ └── core/ # Core business logic
231
+ └── doctor.ts # Doctor checks implementations
232
+ ```
233
+
234
+ ## Privacy & Security
235
+
236
+ ### Analytics Safety
237
+
238
+ **NEVER tracked:**
239
+ - Secret names (e.g., `API_KEY`, `DATABASE_URL`)
240
+ - Secret values
241
+ - Environment variable content
242
+ - Access tokens
243
+ - File contents
244
+
245
+ **Only tracked:**
246
+ - Command usage (init, push, pull)
247
+ - Repository names (public info)
248
+ - Environment names (e.g., "production")
249
+ - Number of variables (count only)
250
+ - Error messages (sanitized)
251
+ - Machine-specific anonymous ID
252
+
253
+ ### Distinct ID
254
+
255
+ Each machine has a unique, anonymous identifier stored in `~/.config/keyway/id.json`. This ID is randomly generated and contains no personally identifiable information.
256
+
257
+ ## Troubleshooting
258
+
259
+ ### "Not in a git repository"
260
+
261
+ ```bash
262
+ # Initialize git and add a remote
263
+ git init
264
+ git remote add origin git@github.com:your-org/your-repo.git
265
+ ```
266
+
267
+ ### "GitHub token not found"
268
+
269
+ ```bash
270
+ # Set your GitHub token
271
+ export GITHUB_TOKEN=your_token
272
+ ```
273
+
274
+ ### "Vault not found"
275
+
276
+ ```bash
277
+ # Initialize the vault first
278
+ keyway init
279
+ ```
280
+
281
+ ### "You do not have access to this repository"
282
+
283
+ Make sure you're a collaborator or admin on the GitHub repository.
284
+
285
+ ### Disabling the Banner
286
+
287
+ ```bash
288
+ # Via command line flag
289
+ keyway --no-banner doctor
290
+
291
+ # Via environment variable
292
+ export KEYWAY_NO_BANNER=1
293
+ keyway doctor
294
+ ```
295
+
296
+ ## Publishing to npm
297
+
298
+ ```bash
299
+ # Update version
300
+ npm version patch # or minor, or major
301
+
302
+ # Build
303
+ npm run build
304
+
305
+ # Publish
306
+ npm publish
39
307
  ```
40
308
 
41
309
  ## License
42
- MIT
310
+
311
+ MIT © Nicolas Ritouet
312
+
313
+ ## Support
314
+
315
+ - **Issues**: https://github.com/keywaysh/cli/issues
316
+ - **Email**: unlock@keyway.sh
317
+ - **Website**: https://keyway.sh