@skillrecordings/cli 0.19.0 → 0.21.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 CHANGED
@@ -1,385 +1,190 @@
1
1
  # @skillrecordings/cli
2
2
 
3
- CLI for the support platform. Agent-friendly with non-interactive defaults.
3
+ Agent-friendly CLI for the Skill Recordings support platform.
4
4
 
5
- ## Install
5
+ ## Setup (2 minutes)
6
6
 
7
- ```bash
8
- curl -fsSL https://raw.githubusercontent.com/skillrecordings/support/main/packages/cli/install.sh | bash
9
- ```
10
-
11
- Installs to `~/.local/bin/skill`. Add to your PATH if needed:
7
+ You need: a GitHub account in the `skillrecordings` org.
12
8
 
13
9
  ```bash
14
- echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
15
- ```
16
-
17
- After install, run `skill auth setup` to configure credentials.
18
-
19
- ## Usage
20
-
21
- ```bash
22
- bunx @skillrecordings/cli <command> [options]
23
-
24
- # or with direct import
25
- skill <command> [options]
26
- ```
27
-
28
- All commands support `--json` for machine-readable output and reliable exit
29
- codes.
10
+ # 1. Install (private repo, so use gh)
11
+ gh auth login
12
+ gh api -H "Accept: application/vnd.github.raw" \
13
+ repos/skillrecordings/support/contents/packages/cli/install.sh?ref=main | bash
30
14
 
31
- ## 1Password Quickstart (60 seconds)
32
-
33
- If you already have access to the Support vault:
34
-
35
- ```bash
36
- # 1) Install required CLI
37
- brew install 1password-cli
38
-
39
- # 2) Optional but recommended: cache OP token in local secrets CLI
40
- secrets add skill_support_1password_service_account_token
15
+ # 2. Add to PATH (if not already)
16
+ echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.zshrc && source ~/.zshrc
41
17
 
42
- # 3) Run one setup command
18
+ # 3. Authenticate (opens browser, no other tools needed)
43
19
  skill auth setup
44
20
 
45
- # 4) Verify
21
+ # 4. Verify everything works
46
22
  skill doctor
47
23
  ```
48
24
 
49
- Notes:
50
- - `secrets` CLI is optional. If missing, `skill auth setup` falls back to `op signin`.
51
- - Setup writes `SKILL_AGE_KEY` to `~/.config/skill/age.key` so `.env.encrypted` works without keychain.
52
-
53
- ## OAuth Broker Spike
25
+ That's it. No 1Password CLI, no age keys, no manual secret management.
54
26
 
55
- Use this to inspect the planned GitHub OAuth + broker auth model that reduces
56
- local dependencies for team members:
27
+ The CLI authenticates via GitHub device flow the broker verifies your org
28
+ membership secrets are delivered encrypted and held in memory only.
57
29
 
58
- ```bash
59
- skill auth oauth-spike
60
- skill auth oauth-spike --json
61
- ```
62
-
63
- ## Adaptive Hints
64
-
65
- The CLI prints adaptive onboarding/discovery hints to `stderr` for new users.
66
- Hints learn from usage and fade as you run more commands.
30
+ ## Install troubleshooting
67
31
 
68
- **Opt out:**
69
- - Use `--quiet`
70
- - Use `--json`
71
- - Pipe output (non-TTY)
32
+ | Symptom | Fix |
33
+ |---|---|
34
+ | `gh: command not found` | Install GitHub CLI: https://cli.github.com/ |
35
+ | `gh` asks you to log in | Run `gh auth login`, then `gh auth status` |
36
+ | `HTTP 404` / repo access failure on bootstrap | Confirm you can access the private repo: `gh release list --repo skillrecordings/support --limit 5` |
37
+ | `skill: command not found` after install | Add `~/.local/bin` to PATH |
72
38
 
73
- ## Commands
74
-
75
- ### `skill init <name>`
76
-
77
- Initialize a new app integration with webhook secret.
39
+ Quick verification:
78
40
 
79
41
  ```bash
80
- # Interactive (terminal only)
81
- skill init
82
-
83
- # Non-interactive (required for agents/scripts)
84
- skill init my-app
85
-
86
- # JSON output
87
- skill init my-app --json
42
+ gh auth status
43
+ which skill
44
+ skill --version
88
45
  ```
89
46
 
90
- **Options:**
91
- - `--json` - Output result as JSON (machine-readable)
92
-
93
- **Exit codes:**
94
- - `0` - Success
95
- - `1` - Error (name required in non-interactive mode, etc.)
96
-
97
- ### `skill health <slug|url>`
98
-
99
- Test integration endpoint health.
47
+ ## Commands
100
48
 
101
49
  ```bash
102
- # Using database lookup (recommended)
103
- skill health total-typescript
104
-
105
- # Direct URL mode
106
- skill health https://example.com --secret whsec_xxx
107
-
108
- # List registered apps
109
- skill health --list
110
-
111
- # JSON output (for agents)
112
- skill health total-typescript --json
113
- ```
114
-
115
- **Options:**
116
- - `-s, --secret <secret>` - Webhook secret (required for direct URL mode)
117
- - `-l, --list` - List all registered apps
118
- - `--json` - Output result as JSON (machine-readable)
119
-
120
- **Exit codes:**
121
- - `0` - Health check passed
122
- - `1` - Health check failed or error
123
-
124
- **JSON output structure:**
125
- ```json
126
- {
127
- "success": true,
128
- "endpoint": "https://...",
129
- "status": "ok",
130
- "responseTime": 730,
131
- "actions": [
132
- { "name": "lookupUser", "status": "ok" },
133
- { "name": "getPurchases", "status": "ok" }
134
- ],
135
- "summary": { "ok": 4, "notImplemented": 1, "errors": 0 }
136
- }
50
+ skill <command> [options]
137
51
  ```
138
52
 
139
- ### `skill eval <type> <dataset>`
140
-
141
- Run evals against a dataset (e.g., routing classifier, canned response
142
- matcher).
53
+ All commands support `--json` for machine-readable output.
143
54
 
144
- ```bash
145
- # Run routing eval with defaults
146
- skill eval routing path/to/dataset.json
147
-
148
- # With strict thresholds
149
- skill eval routing dataset.json --min-precision 0.95 --min-recall 0.97
55
+ | Command | What it does |
56
+ |---|---|
57
+ | `skill auth setup` | One-command bootstrap (GitHub device flow) |
58
+ | `skill auth status` | Session + provider status |
59
+ | `skill doctor` | Deep health check with remediation hints |
60
+ | `skill health <app>` | Test app webhook endpoint |
61
+ | `skill health --list` | List registered apps |
62
+ | `skill init <name>` | Initialize new app integration |
63
+ | `skill eval routing <dataset>` | Run routing classifier evals |
64
+ | `skill auth oauth-spike` | Inspect broker readiness |
150
65
 
151
- # JSON output for automation
152
- skill eval routing dataset.json --json
66
+ ## How Auth Works
153
67
 
154
- # Custom thresholds
155
- skill eval routing dataset.json \
156
- --min-precision 0.92 \
157
- --min-recall 0.95 \
158
- --max-fp-rate 0.03 \
159
- --max-fn-rate 0.02
68
+ ```
69
+ skill auth setup
70
+ GitHub device flow (approve in browser)
71
+ Broker verifies skillrecordings org membership
72
+ → Short-lived session tokens issued (15min access / 8hr refresh)
73
+ → skill auth exec decrypts secrets in memory per-command
160
74
  ```
161
75
 
162
- **Arguments:**
163
- - `type` - Eval type (e.g., `routing`)
164
- - `dataset` - Path to JSON dataset file
165
-
166
- **Options:**
167
- - `--json` - Output result as JSON (machine-readable)
168
- - `--min-precision <number>` - Minimum precision threshold (default: 0.92)
169
- - `--min-recall <number>` - Minimum recall threshold (default: 0.95)
170
- - `--max-fp-rate <number>` - Maximum false positive rate (default: 0.03)
171
- - `--max-fn-rate <number>` - Maximum false negative rate (default: 0.02)
172
-
173
- **Exit codes:**
174
- - `0` - All metrics passed thresholds
175
- - `1` - One or more metrics below threshold or error
76
+ **Broker endpoints** (on `skill-support-agent-front.vercel.app`):
176
77
 
177
- **Output includes:**
178
- - Precision, recall, false positive/negative rates
179
- - Latency percentiles (p50, p95, p99)
180
- - Token usage and estimated cost
181
- - Category-level breakdown (if applicable)
78
+ | Endpoint | Purpose |
79
+ |---|---|
80
+ | `POST /api/auth/device/start` | Start GitHub device flow |
81
+ | `POST /api/auth/device/poll` | Exchange device code for session |
82
+ | `POST /api/auth/session/refresh` | Refresh session, re-check membership |
83
+ | `POST /api/env/materialize` | Age-encrypted env delivery |
182
84
 
183
- ## App Onboarding Workflow
85
+ **Legacy path:** 1Password CLI + `skill auth setup --legacy` still works as
86
+ admin/break-glass mode.
184
87
 
185
- Typical flow for adding a new app integration:
88
+ ## App Onboarding
186
89
 
187
90
  ```bash
188
- # 1. Initialize with app name
91
+ # 1. Initialize
189
92
  skill init my-app --json
190
- # Returns: { "success": true, "appName": "my-app",
191
- # "webhookSecret": "whsec_xxx" }
192
93
 
193
- # 2. Register webhook endpoint in your app
194
- # Save the webhook secret and configure your endpoint to:
94
+ # 2. Register webhook in your app (use returned secret)
195
95
  # POST /api/support-webhooks with Authorization: Bearer whsec_xxx
196
96
 
197
- # 3. Test health before going live
97
+ # 3. Verify
198
98
  skill health my-app
199
- # Verifies: endpoint reachable, signature verification works,
200
- # actions implemented
201
99
 
202
- # 4. Run evals (optional, for routing/matching logic)
203
- skill eval routing path/to/labeled-dataset.json --json
204
-
205
- # 5. Deploy and monitor
206
- # Check logs via Axiom/Langfuse for inbound messages
100
+ # 4. Run evals (optional)
101
+ skill eval routing labeled-dataset.json --json
207
102
  ```
208
103
 
209
- All commands work non-interactively and report errors with exit codes
210
- (0=success, 1=error).
211
-
212
- ## Agent Usage
213
-
214
- All commands support `--json` for machine-readable output and
215
- non-interactive operation:
216
-
217
- **init command:**
218
- - Requires `name` argument (non-interactive mode)
219
- - Returns JSON: `{ "success": true, "appName": "...",
220
- "webhookSecret": "whsec_..." }`
221
- - Use `--json` for reliable parsing
222
-
223
- **health command:**
224
- - Use `--json` for JSON output (structured for parsing)
225
- - Use `--list` to discover all registered apps
226
- - Returns exit code 0 if healthy, 1 if any check fails
227
-
228
- **eval command:**
229
- - Requires `type` and `dataset` arguments
230
- - Accepts custom threshold gates (precision, recall, false
231
- positive/negative rates)
232
- - Returns exit code 0 if all metrics pass, 1 otherwise
233
- - Use `--json` for machine-readable report
234
-
235
- **Error handling:**
236
- - All commands output `{ "success": false, "error": "message" }` on
237
- JSON mode
238
- - Check exit codes: 0 = success, 1 = error
239
- - Never interactive in non-TTY environments (CI/CD safe)
240
-
241
- ## Secrets Management
242
-
243
- The CLI uses a layered secrets system:
104
+ ## Health Check
244
105
 
245
- 1. **1Password (preferred)** - Service account token resolves secrets directly
246
- 2. **Encrypted `.env.encrypted`** - Age-encrypted env file for offline/CI use
247
- 3. **Plain `.env.local`** - Local development fallback
106
+ ```bash
107
+ # Quick check
108
+ skill health total-typescript
248
109
 
249
- ### Secret Resolution Order
110
+ # All apps
111
+ skill health --list
250
112
 
251
- ```
252
- 1Password (OP_SERVICE_ACCOUNT_TOKEN set?)
253
- ↓ yes → resolve from 1Password vault
254
- ↓ no
255
- .env.encrypted exists + SKILL_AGE_KEY available?
256
- ↓ yes → decrypt and load
257
- ↓ no
258
- .env.local exists?
259
- ↓ yes → load plain env vars
260
- ↓ no → error: missing secrets
113
+ # Deep system check
114
+ skill doctor --json
261
115
  ```
262
116
 
263
- ### Adding a New Secret
117
+ ## Agent Usage
264
118
 
265
- **Step 1: Add to `secret-refs.ts`**
119
+ - `--json` on every command for structured output
120
+ - `--quiet` suppresses adaptive hints
121
+ - Exit codes: `0` = success, `1` = error
122
+ - Non-interactive in non-TTY environments (CI/CD safe)
123
+ - Error shape: `{ "success": false, "error": "message" }`
266
124
 
267
- ```typescript
268
- // packages/cli/src/core/secret-refs.ts
269
- export const SECRET_REFS = {
270
- // ... existing secrets
271
- MY_NEW_KEY: 'op://Support/skill-cli/MY_NEW_KEY',
272
- } as const
273
- ```
125
+ ## Secrets Management
274
126
 
275
- **Step 2: Add to 1Password**
127
+ The broker handles secrets for most users. Admins who need direct access:
276
128
 
277
- ```bash
278
- # Using op CLI
279
- op item edit "skill-cli" --vault "Support" "MY_NEW_KEY=your-secret-value"
129
+ ### Resolution Order
280
130
 
281
- # Or via 1Password UI:
282
- # 1. Open Support vault → skill-cli item
283
- # 2. Add new field: MY_NEW_KEY = your-value
284
131
  ```
285
-
286
- **Step 3: Update `.env.encrypted`**
287
-
288
- ```bash
289
- # Decrypt current secrets
290
- AGE_KEY=$(op read "op://Support/skill-cli-age-key/private_key")
291
- age -d -i <(echo "$AGE_KEY") .env.encrypted > .env.local
292
-
293
- # Add new secret to .env.local
294
- echo "MY_NEW_KEY=your-secret-value" >> .env.local
295
-
296
- # Re-encrypt
297
- AGE_PUB=$(echo "$AGE_KEY" | age-keygen -y)
298
- age -r "$AGE_PUB" .env.local > .env.encrypted
299
-
300
- # Verify
301
- age -d -i <(echo "$AGE_KEY") .env.encrypted | grep MY_NEW_KEY
132
+ OAuth Broker (default, v0.19.0+)
133
+ GitHub auth → broker decrypts → ephemeral age envelope → memory only
134
+ 1Password (admin/break-glass)
135
+ → OP_SERVICE_ACCOUNT_TOKEN → resolve from vault
136
+ .env.encrypted (CI fallback)
137
+ SKILL_AGE_KEY → decrypt and load
138
+ .env.local (local dev fallback)
139
+ → load plain env vars
302
140
  ```
303
141
 
304
- **Step 4: Commit changes**
142
+ ### Adding a Secret
305
143
 
306
- ```bash
307
- git add packages/cli/src/core/secret-refs.ts packages/cli/.env.encrypted
308
- git commit -m "chore(cli): add MY_NEW_KEY secret"
309
- ```
144
+ 1. Add ref to `packages/cli/src/core/secret-refs.ts`
145
+ 2. Add value to 1Password: `op item edit "skill-cli" --vault "Support" "MY_KEY=value"`
146
+ 3. Update `.env.encrypted` (see below)
147
+ 4. Commit: `git add secret-refs.ts .env.encrypted`
310
148
 
311
- ### Updating an Existing Secret
149
+ ### Updating `.env.encrypted`
312
150
 
313
151
  ```bash
314
- # 1. Update in 1Password
315
- op item edit "skill-cli" --vault "Support" "MY_KEY=new-value"
316
-
317
- # 2. Update .env.encrypted (same process as adding)
318
152
  AGE_KEY=$(op read "op://Support/skill-cli-age-key/private_key")
319
153
  age -d -i <(echo "$AGE_KEY") .env.encrypted > .env.local
320
-
321
- # Edit .env.local with new value
322
- sed -i '' 's/MY_KEY=.*/MY_KEY=new-value/' .env.local
323
-
324
- # Re-encrypt
154
+ # edit .env.local
325
155
  AGE_PUB=$(echo "$AGE_KEY" | age-keygen -y)
326
156
  age -r "$AGE_PUB" .env.local > .env.encrypted
327
- ```
328
-
329
- ### Auth Commands
330
-
331
- ```bash
332
- # Check current auth status
333
- skill auth status
334
-
335
- # Validate 1Password token
336
- skill auth login
337
-
338
- # Show service account info
339
- skill auth whoami
340
-
341
- # Interactive setup wizard
342
- skill auth setup
157
+ rm .env.local
343
158
  ```
344
159
 
345
160
  ### Key Locations
346
161
 
347
162
  | Item | Location |
348
- |------|----------|
163
+ |---|---|
349
164
  | Secrets | `op://Support/skill-cli/*` |
350
165
  | Age keypair | `op://Support/skill-cli-age-key/private_key` |
351
166
  | Encrypted env | `packages/cli/.env.encrypted` |
352
167
  | Secret refs | `packages/cli/src/core/secret-refs.ts` |
353
168
 
354
- ### CI/CD Usage
355
-
356
- For CI environments without 1Password:
169
+ ### CI/CD
357
170
 
358
171
  ```bash
359
- # Set age key as CI secret, then:
172
+ # With 1Password service account
173
+ export OP_SERVICE_ACCOUNT_TOKEN="$OP_TOKEN"
174
+ skill auth status
175
+
176
+ # Or with age key
360
177
  echo "$SKILL_AGE_KEY" > /tmp/age.key
361
178
  age -d -i /tmp/age.key .env.encrypted > .env.local
362
179
  rm /tmp/age.key
363
180
  ```
364
181
 
365
- Or use 1Password service account:
182
+ ## Adaptive Hints
366
183
 
367
- ```bash
368
- export OP_SERVICE_ACCOUNT_TOKEN="$OP_TOKEN"
369
- skill auth status # Verifies connection
370
- skill front inbox # Commands auto-resolve secrets
371
- ```
184
+ New users see contextual onboarding hints on `stderr`. They fade with usage.
185
+ Suppress with `--quiet`, `--json`, or piped output.
372
186
 
373
187
  ## Implementation
374
188
 
375
- - `packages/cli/src/commands/` - Command implementations
376
- - `packages/cli/src/index.ts` - CLI entry point
377
- - Entry point: `#!/usr/bin/env bun` (runs with Bun directly)
378
-
379
- ## Do / Don't
380
-
381
- - Do use `--json` flag for automation/agents/scripts
382
- - Do check exit codes in shell scripts
383
- - Do pass `name` argument to `init` in CI/CD (non-interactive required)
384
- - Don't rely on interactive prompts outside terminal
385
- - Don't parse stdout (use `--json` for structured output)
189
+ - `packages/cli/src/commands/` command implementations
190
+ - `packages/cli/src/index.ts` entry point (`#!/usr/bin/env bun`)