skillsd 0.1.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 +484 -0
- package/bin/sd.js +3 -0
- package/dist/commands/auth.d.ts +3 -0
- package/dist/commands/auth.d.ts.map +1 -0
- package/dist/commands/auth.js +148 -0
- package/dist/commands/auth.js.map +1 -0
- package/dist/commands/clone.d.ts +3 -0
- package/dist/commands/clone.d.ts.map +1 -0
- package/dist/commands/clone.js +86 -0
- package/dist/commands/clone.js.map +1 -0
- package/dist/commands/collection.d.ts +3 -0
- package/dist/commands/collection.d.ts.map +1 -0
- package/dist/commands/collection.js +206 -0
- package/dist/commands/collection.js.map +1 -0
- package/dist/commands/diff.d.ts +3 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +93 -0
- package/dist/commands/diff.js.map +1 -0
- package/dist/commands/pr.d.ts +3 -0
- package/dist/commands/pr.d.ts.map +1 -0
- package/dist/commands/pr.js +230 -0
- package/dist/commands/pr.js.map +1 -0
- package/dist/commands/pull.d.ts +3 -0
- package/dist/commands/pull.d.ts.map +1 -0
- package/dist/commands/pull.js +136 -0
- package/dist/commands/pull.js.map +1 -0
- package/dist/commands/push.d.ts +3 -0
- package/dist/commands/push.d.ts.map +1 -0
- package/dist/commands/push.js +129 -0
- package/dist/commands/push.js.map +1 -0
- package/dist/commands/search.d.ts +3 -0
- package/dist/commands/search.d.ts.map +1 -0
- package/dist/commands/search.js +55 -0
- package/dist/commands/search.js.map +1 -0
- package/dist/commands/skill.d.ts +3 -0
- package/dist/commands/skill.d.ts.map +1 -0
- package/dist/commands/skill.js +270 -0
- package/dist/commands/skill.js.map +1 -0
- package/dist/commands/status.d.ts +8 -0
- package/dist/commands/status.d.ts.map +1 -0
- package/dist/commands/status.js +115 -0
- package/dist/commands/status.js.map +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +214 -0
- package/dist/index.js.map +1 -0
- package/dist/lib/api.d.ts +208 -0
- package/dist/lib/api.d.ts.map +1 -0
- package/dist/lib/api.js +216 -0
- package/dist/lib/api.js.map +1 -0
- package/dist/lib/auth.d.ts +13 -0
- package/dist/lib/auth.d.ts.map +1 -0
- package/dist/lib/auth.js +181 -0
- package/dist/lib/auth.js.map +1 -0
- package/dist/lib/config.d.ts +58 -0
- package/dist/lib/config.d.ts.map +1 -0
- package/dist/lib/config.js +144 -0
- package/dist/lib/config.js.map +1 -0
- package/package.json +48 -0
package/README.md
ADDED
|
@@ -0,0 +1,484 @@
|
|
|
1
|
+
# SkillsDojo CLI
|
|
2
|
+
|
|
3
|
+
The official command-line interface for [SkillsDojo](https://skillsdojo.ai) - manage AI agent skills from your terminal.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
# From the packages/cli directory
|
|
9
|
+
npm install
|
|
10
|
+
npm run build
|
|
11
|
+
npm link
|
|
12
|
+
|
|
13
|
+
# Or run directly
|
|
14
|
+
./bin/sd.js --help
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
```bash
|
|
20
|
+
# Search for public skills
|
|
21
|
+
sdojo search "code review"
|
|
22
|
+
|
|
23
|
+
# Clone a collection to work on locally
|
|
24
|
+
sdojo clone anthropic/core-skills
|
|
25
|
+
|
|
26
|
+
# Make changes, then push as a pull request
|
|
27
|
+
cd core-skills
|
|
28
|
+
sdojo skill create my-new-skill
|
|
29
|
+
sdojo push --title "Add my new skill"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Authentication
|
|
33
|
+
|
|
34
|
+
### Login
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
# Interactive login (opens browser)
|
|
38
|
+
sdojo auth login
|
|
39
|
+
|
|
40
|
+
# Login with email/password (for CI/scripts)
|
|
41
|
+
sdojo auth login -u you@example.com -p yourpassword
|
|
42
|
+
|
|
43
|
+
# Login with API token
|
|
44
|
+
sdojo auth login --token
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
### Check Current User
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
sdojo auth whoami
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Output:
|
|
54
|
+
```
|
|
55
|
+
Logged in as: you@example.com
|
|
56
|
+
Account: yourusername (Your Name)
|
|
57
|
+
API: https://skillsdojo.ai
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
### Logout
|
|
61
|
+
|
|
62
|
+
```bash
|
|
63
|
+
sdojo auth logout
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
## Working with Collections
|
|
67
|
+
|
|
68
|
+
### List Your Collections
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
sdojo collection list
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
Output:
|
|
75
|
+
```
|
|
76
|
+
NAME VISIBILITY SKILLS STARS FORKS
|
|
77
|
+
yourusername/my-skills private 12 - -
|
|
78
|
+
yourusername/shared public 45 23 5
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Create a New Collection
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
sdojo collection create my-new-collection
|
|
85
|
+
sdojo collection create my-new-collection --visibility public
|
|
86
|
+
sdojo collection create my-new-collection --description "My awesome skills"
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
### Fork a Public Collection
|
|
90
|
+
|
|
91
|
+
```bash
|
|
92
|
+
sdojo collection fork anthropic/core-skills
|
|
93
|
+
# Creates: yourusername/core-skills
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
### View Collection Details
|
|
97
|
+
|
|
98
|
+
```bash
|
|
99
|
+
sdojo collection show anthropic/core-skills
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Delete a Collection
|
|
103
|
+
|
|
104
|
+
```bash
|
|
105
|
+
sdojo collection delete yourusername/old-collection
|
|
106
|
+
```
|
|
107
|
+
|
|
108
|
+
## Cloning & Syncing
|
|
109
|
+
|
|
110
|
+
### Clone a Collection
|
|
111
|
+
|
|
112
|
+
```bash
|
|
113
|
+
# Clone to directory with same name as collection
|
|
114
|
+
sdojo clone anthropic/core-skills
|
|
115
|
+
|
|
116
|
+
# Clone to custom directory
|
|
117
|
+
sdojo clone anthropic/core-skills ./my-skills
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
This creates a local workspace:
|
|
121
|
+
```
|
|
122
|
+
core-skills/
|
|
123
|
+
├── .skillsdojo/
|
|
124
|
+
│ ├── config.json # Remote connection info
|
|
125
|
+
│ └── index.json # File tracking for change detection
|
|
126
|
+
├── code-review/
|
|
127
|
+
│ └── SKILL.md
|
|
128
|
+
├── debugging/
|
|
129
|
+
│ └── SKILL.md
|
|
130
|
+
└── README.md
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
### Check Status
|
|
134
|
+
|
|
135
|
+
See what files have changed locally:
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
sdojo status
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Output:
|
|
142
|
+
```
|
|
143
|
+
Collection: yourusername/my-skills
|
|
144
|
+
Branch: main
|
|
145
|
+
|
|
146
|
+
Changes not yet pushed:
|
|
147
|
+
modified: code-review/SKILL.md
|
|
148
|
+
new file: data-analysis/SKILL.md
|
|
149
|
+
deleted: old-skill/SKILL.md
|
|
150
|
+
|
|
151
|
+
Run 'sdojo push' to create a pull request with these changes.
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### View Diffs
|
|
155
|
+
|
|
156
|
+
```bash
|
|
157
|
+
# Show all changes
|
|
158
|
+
sdojo diff
|
|
159
|
+
|
|
160
|
+
# Show changes for specific skill
|
|
161
|
+
sdojo diff code-review
|
|
162
|
+
```
|
|
163
|
+
|
|
164
|
+
### Pull Latest Changes
|
|
165
|
+
|
|
166
|
+
```bash
|
|
167
|
+
# Pull and merge with local changes
|
|
168
|
+
sdojo pull
|
|
169
|
+
|
|
170
|
+
# Force overwrite local changes
|
|
171
|
+
sdojo pull --force
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
### Push Changes (Create Pull Request)
|
|
175
|
+
|
|
176
|
+
```bash
|
|
177
|
+
# Interactive - prompts for title and description
|
|
178
|
+
sdojo push
|
|
179
|
+
|
|
180
|
+
# With title
|
|
181
|
+
sdojo push --title "Update code review skill"
|
|
182
|
+
|
|
183
|
+
# With title and description
|
|
184
|
+
sdojo push --title "Fix bug" --description "Fixed the edge case handling"
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
## Managing Skills
|
|
188
|
+
|
|
189
|
+
### List Skills
|
|
190
|
+
|
|
191
|
+
```bash
|
|
192
|
+
# In current workspace
|
|
193
|
+
sdojo skill list
|
|
194
|
+
|
|
195
|
+
# In specific collection
|
|
196
|
+
sdojo skill list anthropic/core-skills
|
|
197
|
+
|
|
198
|
+
# Search within collection
|
|
199
|
+
sdojo skill list --search "review"
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Create a New Skill
|
|
203
|
+
|
|
204
|
+
```bash
|
|
205
|
+
sdojo skill create my-new-skill
|
|
206
|
+
sdojo skill create tools/web-scraper # Nested path
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
This creates a skill template:
|
|
210
|
+
```yaml
|
|
211
|
+
---
|
|
212
|
+
name: my-new-skill
|
|
213
|
+
description: TODO: Add description
|
|
214
|
+
user-invocable: true
|
|
215
|
+
allowed-tools: []
|
|
216
|
+
---
|
|
217
|
+
|
|
218
|
+
# My New Skill
|
|
219
|
+
|
|
220
|
+
Instructions for this skill...
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
### View Skill Details
|
|
224
|
+
|
|
225
|
+
```bash
|
|
226
|
+
sdojo skill show code-review
|
|
227
|
+
```
|
|
228
|
+
|
|
229
|
+
### Delete a Skill
|
|
230
|
+
|
|
231
|
+
```bash
|
|
232
|
+
sdojo skill delete old-skill
|
|
233
|
+
```
|
|
234
|
+
|
|
235
|
+
### Move/Rename a Skill
|
|
236
|
+
|
|
237
|
+
```bash
|
|
238
|
+
sdojo skill move old-name new-name
|
|
239
|
+
sdojo skill move utils/helper tools/helper # Move between directories
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
## Pull Requests
|
|
243
|
+
|
|
244
|
+
### List Pull Requests
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
# List open PRs
|
|
248
|
+
sdojo pr list
|
|
249
|
+
|
|
250
|
+
# List all PRs (including merged/closed)
|
|
251
|
+
sdojo pr list --state merged
|
|
252
|
+
sdojo pr list --state closed
|
|
253
|
+
|
|
254
|
+
# For specific collection
|
|
255
|
+
sdojo pr list anthropic/core-skills
|
|
256
|
+
```
|
|
257
|
+
|
|
258
|
+
### View PR Details
|
|
259
|
+
|
|
260
|
+
```bash
|
|
261
|
+
sdojo pr view 12
|
|
262
|
+
```
|
|
263
|
+
|
|
264
|
+
### Merge a PR
|
|
265
|
+
|
|
266
|
+
```bash
|
|
267
|
+
sdojo pr merge 12
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
### Close a PR (without merging)
|
|
271
|
+
|
|
272
|
+
```bash
|
|
273
|
+
sdojo pr close 12
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Search
|
|
277
|
+
|
|
278
|
+
Search public skills across all collections:
|
|
279
|
+
|
|
280
|
+
```bash
|
|
281
|
+
sdojo search "code review"
|
|
282
|
+
sdojo search "mcp server"
|
|
283
|
+
sdojo search "data analysis" --limit 50
|
|
284
|
+
```
|
|
285
|
+
|
|
286
|
+
Output:
|
|
287
|
+
```
|
|
288
|
+
Search results for "code review"
|
|
289
|
+
|
|
290
|
+
┌──────────────────────────────────┬─────────────────────────────────────────┐
|
|
291
|
+
│ SKILL │ DESCRIPTION │
|
|
292
|
+
├──────────────────────────────────┼─────────────────────────────────────────┤
|
|
293
|
+
│ anthropic/core/code-review │ Review code for bugs and improvements │
|
|
294
|
+
│ community/tools/pr-reviewer │ Automated PR review assistant │
|
|
295
|
+
└──────────────────────────────────┴─────────────────────────────────────────┘
|
|
296
|
+
|
|
297
|
+
Page 1 of 1 (2 total)
|
|
298
|
+
|
|
299
|
+
Clone a skill collection with: sdojo clone <account>/<collection>
|
|
300
|
+
```
|
|
301
|
+
|
|
302
|
+
## Configuration
|
|
303
|
+
|
|
304
|
+
### Set Configuration
|
|
305
|
+
|
|
306
|
+
```bash
|
|
307
|
+
sdojo config set api.url https://skillsdojo.ai
|
|
308
|
+
sdojo config set defaults.visibility private
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### View Configuration
|
|
312
|
+
|
|
313
|
+
```bash
|
|
314
|
+
sdojo config get api.url
|
|
315
|
+
sdojo config list
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### Configuration File
|
|
319
|
+
|
|
320
|
+
Global config is stored at `~/.skillsdojo/config.json`:
|
|
321
|
+
|
|
322
|
+
```json
|
|
323
|
+
{
|
|
324
|
+
"api": {
|
|
325
|
+
"url": "https://skillsdojo.ai"
|
|
326
|
+
},
|
|
327
|
+
"defaults": {
|
|
328
|
+
"visibility": "private"
|
|
329
|
+
},
|
|
330
|
+
"output": {
|
|
331
|
+
"format": "table"
|
|
332
|
+
}
|
|
333
|
+
}
|
|
334
|
+
```
|
|
335
|
+
|
|
336
|
+
## Environment Variables
|
|
337
|
+
|
|
338
|
+
| Variable | Description |
|
|
339
|
+
|----------|-------------|
|
|
340
|
+
| `SKILLSDOJO_API_URL` | Override API URL (default: https://skillsdojo.ai) |
|
|
341
|
+
| `SKILLSDOJO_TOKEN` | API token for authentication (useful for CI/CD) |
|
|
342
|
+
|
|
343
|
+
## JSON Output
|
|
344
|
+
|
|
345
|
+
Most commands support `--json` for machine-readable output:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
sdojo search "mcp" --json
|
|
349
|
+
sdojo collection list --json
|
|
350
|
+
sdojo status --json
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
## Common Workflows
|
|
354
|
+
|
|
355
|
+
### Contributing to Public Skills
|
|
356
|
+
|
|
357
|
+
```bash
|
|
358
|
+
# Fork the collection to your account
|
|
359
|
+
sdojo collection fork anthropic/core-skills
|
|
360
|
+
|
|
361
|
+
# Clone your fork
|
|
362
|
+
sdojo clone yourusername/core-skills
|
|
363
|
+
cd core-skills
|
|
364
|
+
|
|
365
|
+
# Make changes
|
|
366
|
+
vim code-review/SKILL.md
|
|
367
|
+
|
|
368
|
+
# Push as PR to your fork
|
|
369
|
+
sdojo push --title "Improve code review prompts"
|
|
370
|
+
```
|
|
371
|
+
|
|
372
|
+
### Team Collaboration
|
|
373
|
+
|
|
374
|
+
```bash
|
|
375
|
+
# Clone team's collection
|
|
376
|
+
sdojo clone myorg/team-skills
|
|
377
|
+
cd team-skills
|
|
378
|
+
|
|
379
|
+
# Create new skill
|
|
380
|
+
sdojo skill create data-pipeline
|
|
381
|
+
|
|
382
|
+
# Edit and push for review
|
|
383
|
+
vim data-pipeline/SKILL.md
|
|
384
|
+
sdojo push --title "Add data pipeline skill"
|
|
385
|
+
|
|
386
|
+
# Team reviews PR #5 and merges
|
|
387
|
+
sdojo pr merge 5
|
|
388
|
+
```
|
|
389
|
+
|
|
390
|
+
### CI/CD Integration
|
|
391
|
+
|
|
392
|
+
```bash
|
|
393
|
+
# Use environment token
|
|
394
|
+
export SKILLSDOJO_TOKEN="sk_..."
|
|
395
|
+
|
|
396
|
+
# Clone and sync
|
|
397
|
+
sdojo clone myorg/production-skills
|
|
398
|
+
cd production-skills
|
|
399
|
+
|
|
400
|
+
# Check for changes
|
|
401
|
+
sdojo status --json | jq '.changes'
|
|
402
|
+
|
|
403
|
+
# Automated updates
|
|
404
|
+
sdojo push --title "Automated update $(date +%Y-%m-%d)"
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
## Troubleshooting
|
|
408
|
+
|
|
409
|
+
### "Not in a SkillsDojo workspace"
|
|
410
|
+
|
|
411
|
+
You need to be inside a cloned collection directory:
|
|
412
|
+
|
|
413
|
+
```bash
|
|
414
|
+
sdojo clone yourusername/my-skills
|
|
415
|
+
cd my-skills
|
|
416
|
+
sdojo status # Now works
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
### "Authentication required"
|
|
420
|
+
|
|
421
|
+
Login first:
|
|
422
|
+
|
|
423
|
+
```bash
|
|
424
|
+
sdojo auth login
|
|
425
|
+
```
|
|
426
|
+
|
|
427
|
+
### "Collection not found"
|
|
428
|
+
|
|
429
|
+
- Check the collection path is correct: `account/collection`
|
|
430
|
+
- Ensure you have access (private collections require authentication)
|
|
431
|
+
- Verify the collection exists and isn't archived
|
|
432
|
+
|
|
433
|
+
### "Base SHA does not match"
|
|
434
|
+
|
|
435
|
+
Your local workspace is out of sync. Pull latest changes first:
|
|
436
|
+
|
|
437
|
+
```bash
|
|
438
|
+
sdojo pull
|
|
439
|
+
# Then try pushing again
|
|
440
|
+
sdojo push
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
## Command Reference
|
|
444
|
+
|
|
445
|
+
| Command | Description |
|
|
446
|
+
|---------|-------------|
|
|
447
|
+
| `sdojo auth login` | Authenticate with SkillsDojo |
|
|
448
|
+
| `sdojo auth logout` | Clear credentials |
|
|
449
|
+
| `sdojo auth whoami` | Show current user |
|
|
450
|
+
| `sdojo clone <path>` | Clone collection locally |
|
|
451
|
+
| `sdojo status` | Show local changes |
|
|
452
|
+
| `sdojo diff` | Show diff of changes |
|
|
453
|
+
| `sdojo pull` | Pull latest from remote |
|
|
454
|
+
| `sdojo push` | Push changes as PR |
|
|
455
|
+
| `sdojo collection list` | List your collections |
|
|
456
|
+
| `sdojo collection create` | Create new collection |
|
|
457
|
+
| `sdojo collection fork` | Fork a collection |
|
|
458
|
+
| `sdojo collection delete` | Delete collection |
|
|
459
|
+
| `sdojo skill list` | List skills |
|
|
460
|
+
| `sdojo skill create` | Create new skill |
|
|
461
|
+
| `sdojo skill show` | Show skill details |
|
|
462
|
+
| `sdojo skill delete` | Delete skill |
|
|
463
|
+
| `sdojo skill move` | Move/rename skill |
|
|
464
|
+
| `sdojo pr list` | List pull requests |
|
|
465
|
+
| `sdojo pr view` | View PR details |
|
|
466
|
+
| `sdojo pr merge` | Merge PR |
|
|
467
|
+
| `sdojo pr close` | Close PR |
|
|
468
|
+
| `sdojo search` | Search public skills |
|
|
469
|
+
|
|
470
|
+
## Getting Help
|
|
471
|
+
|
|
472
|
+
```bash
|
|
473
|
+
# General help
|
|
474
|
+
sdojo --help
|
|
475
|
+
|
|
476
|
+
# Command-specific help
|
|
477
|
+
sdojo clone --help
|
|
478
|
+
sdojo collection --help
|
|
479
|
+
sdojo skill create --help
|
|
480
|
+
```
|
|
481
|
+
|
|
482
|
+
## License
|
|
483
|
+
|
|
484
|
+
MIT
|
package/bin/sd.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAYpC,eAAO,MAAM,WAAW,SACe,CAAC"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
import { Command } from 'commander';
|
|
2
|
+
import chalk from 'chalk';
|
|
3
|
+
import inquirer from 'inquirer';
|
|
4
|
+
import { loginWithBrowser, loginWithCredentials, loginWithToken, logout, getCurrentUser, } from '../lib/auth.js';
|
|
5
|
+
import { getCredentials, getConfig } from '../lib/config.js';
|
|
6
|
+
export const authCommand = new Command('auth')
|
|
7
|
+
.description('Manage authentication');
|
|
8
|
+
// sdojo auth login
|
|
9
|
+
authCommand
|
|
10
|
+
.command('login')
|
|
11
|
+
.description('Authenticate with SkillsDojo')
|
|
12
|
+
.option('-t, --token [token]', 'Login with API token (optionally provide token value)')
|
|
13
|
+
.option('-u, --email <email>', 'Email address')
|
|
14
|
+
.option('-p, --password <password>', 'Password')
|
|
15
|
+
.action(async (options) => {
|
|
16
|
+
// Token-based login
|
|
17
|
+
if (options.token) {
|
|
18
|
+
let token = typeof options.token === 'string' ? options.token : null;
|
|
19
|
+
// If token not provided as value, prompt for it
|
|
20
|
+
if (!token) {
|
|
21
|
+
const answer = await inquirer.prompt([
|
|
22
|
+
{
|
|
23
|
+
type: 'password',
|
|
24
|
+
name: 'token',
|
|
25
|
+
message: 'Enter your API token:',
|
|
26
|
+
mask: '*',
|
|
27
|
+
},
|
|
28
|
+
]);
|
|
29
|
+
token = answer.token;
|
|
30
|
+
}
|
|
31
|
+
const result = await loginWithToken(token);
|
|
32
|
+
if (!result.success) {
|
|
33
|
+
console.error(chalk.red(result.message));
|
|
34
|
+
process.exit(1);
|
|
35
|
+
}
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
// Credential-based login (for CI/scripts)
|
|
39
|
+
if (options.email && options.password) {
|
|
40
|
+
const result = await loginWithCredentials(options.email, options.password);
|
|
41
|
+
if (!result.success) {
|
|
42
|
+
console.error(chalk.red(result.message));
|
|
43
|
+
process.exit(1);
|
|
44
|
+
}
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
// Interactive login (email/password prompt or browser)
|
|
48
|
+
const { method } = await inquirer.prompt([
|
|
49
|
+
{
|
|
50
|
+
type: 'list',
|
|
51
|
+
name: 'method',
|
|
52
|
+
message: 'How would you like to log in?',
|
|
53
|
+
choices: [
|
|
54
|
+
{ name: 'Open browser (recommended)', value: 'browser' },
|
|
55
|
+
{ name: 'Enter email and password', value: 'credentials' },
|
|
56
|
+
{ name: 'Enter API token', value: 'token' },
|
|
57
|
+
],
|
|
58
|
+
},
|
|
59
|
+
]);
|
|
60
|
+
if (method === 'browser') {
|
|
61
|
+
const result = await loginWithBrowser();
|
|
62
|
+
if (!result.success) {
|
|
63
|
+
console.error(chalk.red(result.message));
|
|
64
|
+
process.exit(1);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
else if (method === 'credentials') {
|
|
68
|
+
const { email, password } = await inquirer.prompt([
|
|
69
|
+
{
|
|
70
|
+
type: 'input',
|
|
71
|
+
name: 'email',
|
|
72
|
+
message: 'Email:',
|
|
73
|
+
validate: (input) => input.includes('@') || 'Please enter a valid email',
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
type: 'password',
|
|
77
|
+
name: 'password',
|
|
78
|
+
message: 'Password:',
|
|
79
|
+
mask: '*',
|
|
80
|
+
},
|
|
81
|
+
]);
|
|
82
|
+
const result = await loginWithCredentials(email, password);
|
|
83
|
+
if (!result.success) {
|
|
84
|
+
console.error(chalk.red(result.message));
|
|
85
|
+
process.exit(1);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const { token } = await inquirer.prompt([
|
|
90
|
+
{
|
|
91
|
+
type: 'password',
|
|
92
|
+
name: 'token',
|
|
93
|
+
message: 'Enter your API token:',
|
|
94
|
+
mask: '*',
|
|
95
|
+
},
|
|
96
|
+
]);
|
|
97
|
+
const result = await loginWithToken(token);
|
|
98
|
+
if (!result.success) {
|
|
99
|
+
console.error(chalk.red(result.message));
|
|
100
|
+
process.exit(1);
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
// sdojo auth logout
|
|
105
|
+
authCommand
|
|
106
|
+
.command('logout')
|
|
107
|
+
.description('Clear stored credentials')
|
|
108
|
+
.action(() => {
|
|
109
|
+
logout();
|
|
110
|
+
console.log(chalk.green('Logged out successfully'));
|
|
111
|
+
});
|
|
112
|
+
// sdojo auth whoami
|
|
113
|
+
authCommand
|
|
114
|
+
.command('whoami')
|
|
115
|
+
.description('Show current authenticated user')
|
|
116
|
+
.action(() => {
|
|
117
|
+
const creds = getCurrentUser();
|
|
118
|
+
if (!creds) {
|
|
119
|
+
console.log(chalk.yellow('Not logged in'));
|
|
120
|
+
console.log(chalk.gray('Run `sdojo auth login` to authenticate'));
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const config = getConfig();
|
|
124
|
+
console.log(`Logged in as: ${chalk.green(creds.user.email)}`);
|
|
125
|
+
console.log(`Account: ${chalk.cyan(creds.account.slug)} (${creds.account.name})`);
|
|
126
|
+
console.log(`API: ${chalk.gray(config.api.url)}`);
|
|
127
|
+
// Check token expiry
|
|
128
|
+
if (creds.expiresAt < Date.now()) {
|
|
129
|
+
console.log(chalk.yellow('\nWarning: Session expired. Run `sdojo auth login` to re-authenticate.'));
|
|
130
|
+
}
|
|
131
|
+
});
|
|
132
|
+
// sdojo auth switch <account>
|
|
133
|
+
authCommand
|
|
134
|
+
.command('switch <account>')
|
|
135
|
+
.description('Switch active account context')
|
|
136
|
+
.action(async (accountSlug) => {
|
|
137
|
+
const creds = getCredentials();
|
|
138
|
+
if (!creds) {
|
|
139
|
+
console.error(chalk.red('Not logged in'));
|
|
140
|
+
console.error(chalk.gray('Run `sdojo auth login` to authenticate'));
|
|
141
|
+
process.exit(1);
|
|
142
|
+
}
|
|
143
|
+
// TODO: Fetch user's accounts and switch
|
|
144
|
+
// For now, just update the account slug
|
|
145
|
+
console.log(chalk.yellow('Account switching not yet implemented'));
|
|
146
|
+
console.log(chalk.gray(`Requested switch to: ${accountSlug}`));
|
|
147
|
+
});
|
|
148
|
+
//# sourceMappingURL=auth.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"auth.js","sourceRoot":"","sources":["../../src/commands/auth.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,cAAc,EACd,MAAM,EACN,cAAc,GACf,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7D,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,uBAAuB,CAAC,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