prjct-cli 0.17.0 → 0.18.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/core/__tests__/agentic/memory-system.test.ts +2 -1
- package/core/__tests__/agentic/plan-mode.test.ts +2 -1
- package/core/agentic/agent-router.ts +1 -1
- package/core/command-registry/setup-commands.ts +15 -0
- package/core/domain/agent-generator.ts +9 -17
- package/core/infrastructure/path-manager.ts +23 -1
- package/core/storage/ideas-storage.ts +4 -0
- package/core/storage/queue-storage.ts +4 -0
- package/core/storage/shipped-storage.ts +4 -0
- package/core/storage/state-storage.ts +4 -0
- package/core/storage/storage-manager.ts +10 -7
- package/core/sync/auth-config.ts +145 -0
- package/core/sync/index.ts +30 -0
- package/core/sync/oauth-handler.ts +148 -0
- package/core/sync/sync-client.ts +252 -0
- package/core/sync/sync-manager.ts +358 -0
- package/package.json +1 -1
- package/templates/commands/auth.md +234 -0
- package/templates/commands/sync.md +55 -0
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
---
|
|
2
|
+
allowed-tools: [Read, Write, Bash]
|
|
3
|
+
description: 'Manage Cloud Authentication'
|
|
4
|
+
timestamp-rule: 'GetTimestamp() for all timestamps'
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# /p:auth - Cloud Authentication
|
|
8
|
+
|
|
9
|
+
Manage authentication for prjct cloud sync.
|
|
10
|
+
|
|
11
|
+
## Subcommands
|
|
12
|
+
|
|
13
|
+
| Command | Purpose |
|
|
14
|
+
|---------|---------|
|
|
15
|
+
| `/p:auth` | Show current auth status |
|
|
16
|
+
| `/p:auth login` | Authenticate with prjct cloud |
|
|
17
|
+
| `/p:auth logout` | Clear authentication |
|
|
18
|
+
| `/p:auth status` | Detailed auth status |
|
|
19
|
+
|
|
20
|
+
## Context Variables
|
|
21
|
+
- `{authPath}`: `~/.prjct-cli/config/auth.json`
|
|
22
|
+
- `{apiUrl}`: API base URL (default: https://api.prjct.app)
|
|
23
|
+
- `{dashboardUrl}`: Web dashboard URL (https://app.prjct.app)
|
|
24
|
+
|
|
25
|
+
---
|
|
26
|
+
|
|
27
|
+
## /p:auth (default) - Show Status
|
|
28
|
+
|
|
29
|
+
### Flow
|
|
30
|
+
|
|
31
|
+
1. READ: `{authPath}`
|
|
32
|
+
2. IF authenticated:
|
|
33
|
+
- Show email and API key prefix
|
|
34
|
+
3. ELSE:
|
|
35
|
+
- Show "Not authenticated" message
|
|
36
|
+
|
|
37
|
+
### Output (Authenticated)
|
|
38
|
+
|
|
39
|
+
```
|
|
40
|
+
☁️ Cloud Sync: Connected
|
|
41
|
+
|
|
42
|
+
Email: {email}
|
|
43
|
+
API Key: {apiKeyPrefix}...
|
|
44
|
+
Last auth: {lastAuth}
|
|
45
|
+
|
|
46
|
+
Sync enabled for all projects.
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
### Output (Not Authenticated)
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
☁️ Cloud Sync: Not connected
|
|
53
|
+
|
|
54
|
+
Run `/p:auth login` to enable cloud sync.
|
|
55
|
+
|
|
56
|
+
Benefits:
|
|
57
|
+
- Sync progress across devices
|
|
58
|
+
- Access from web dashboard
|
|
59
|
+
- Backup your project data
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
---
|
|
63
|
+
|
|
64
|
+
## /p:auth login - Authenticate
|
|
65
|
+
|
|
66
|
+
### Flow
|
|
67
|
+
|
|
68
|
+
1. **Check existing auth**
|
|
69
|
+
READ: `{authPath}`
|
|
70
|
+
IF already authenticated:
|
|
71
|
+
ASK: "You're already logged in as {email}. Re-authenticate? (y/n)"
|
|
72
|
+
IF no: STOP
|
|
73
|
+
|
|
74
|
+
2. **Open dashboard**
|
|
75
|
+
OUTPUT: "Opening prjct dashboard to get your API key..."
|
|
76
|
+
OPEN browser: `{dashboardUrl}/settings/api-keys`
|
|
77
|
+
|
|
78
|
+
3. **Wait for API key**
|
|
79
|
+
OUTPUT instructions:
|
|
80
|
+
```
|
|
81
|
+
1. Log in to prjct.app (GitHub OAuth)
|
|
82
|
+
2. Go to Settings → API Keys
|
|
83
|
+
3. Click "Create New Key"
|
|
84
|
+
4. Copy the key (starts with prjct_)
|
|
85
|
+
5. Paste it below
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
4. **Get API key from user**
|
|
89
|
+
PROMPT: "Paste your API key: "
|
|
90
|
+
READ: `{apiKey}` from user input
|
|
91
|
+
|
|
92
|
+
5. **Validate key**
|
|
93
|
+
- Check format starts with "prjct_"
|
|
94
|
+
- Test connection with GET /health
|
|
95
|
+
- Fetch user info with GET /auth/me
|
|
96
|
+
|
|
97
|
+
IF invalid:
|
|
98
|
+
OUTPUT: "Invalid API key. Please try again."
|
|
99
|
+
STOP
|
|
100
|
+
|
|
101
|
+
6. **Save auth**
|
|
102
|
+
WRITE: `{authPath}`
|
|
103
|
+
```json
|
|
104
|
+
{
|
|
105
|
+
"apiKey": "{apiKey}",
|
|
106
|
+
"apiUrl": "https://api.prjct.app",
|
|
107
|
+
"userId": "{userId}",
|
|
108
|
+
"email": "{email}",
|
|
109
|
+
"lastAuth": "{GetTimestamp()}"
|
|
110
|
+
}
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
### Output (Success)
|
|
114
|
+
|
|
115
|
+
```
|
|
116
|
+
✅ Authentication successful!
|
|
117
|
+
|
|
118
|
+
Logged in as: {email}
|
|
119
|
+
API Key: {apiKeyPrefix}...
|
|
120
|
+
|
|
121
|
+
Cloud sync is now enabled. Your projects will sync automatically
|
|
122
|
+
when you run /p:sync or /p:ship.
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Output (Failure)
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
❌ Authentication failed
|
|
129
|
+
|
|
130
|
+
{error}
|
|
131
|
+
|
|
132
|
+
Please check your API key and try again.
|
|
133
|
+
Get a new key at: {dashboardUrl}/settings/api-keys
|
|
134
|
+
```
|
|
135
|
+
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
## /p:auth logout - Clear Auth
|
|
139
|
+
|
|
140
|
+
### Flow
|
|
141
|
+
|
|
142
|
+
1. READ: `{authPath}`
|
|
143
|
+
IF not authenticated:
|
|
144
|
+
OUTPUT: "Not logged in. Nothing to do."
|
|
145
|
+
STOP
|
|
146
|
+
|
|
147
|
+
2. ASK: "Are you sure you want to log out? (y/n)"
|
|
148
|
+
IF no: STOP
|
|
149
|
+
|
|
150
|
+
3. DELETE or CLEAR: `{authPath}`
|
|
151
|
+
|
|
152
|
+
### Output
|
|
153
|
+
|
|
154
|
+
```
|
|
155
|
+
✅ Logged out successfully
|
|
156
|
+
|
|
157
|
+
Cloud sync is now disabled.
|
|
158
|
+
Run `/p:auth login` to re-enable.
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## /p:auth status - Detailed Status
|
|
164
|
+
|
|
165
|
+
### Flow
|
|
166
|
+
|
|
167
|
+
1. READ: `{authPath}`
|
|
168
|
+
2. IF authenticated:
|
|
169
|
+
- Test connection
|
|
170
|
+
- Show detailed status
|
|
171
|
+
3. ELSE:
|
|
172
|
+
- Show not connected message
|
|
173
|
+
|
|
174
|
+
### Output (Connected)
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
☁️ Cloud Authentication Status
|
|
178
|
+
|
|
179
|
+
Connection: ✓ Connected
|
|
180
|
+
Email: {email}
|
|
181
|
+
User ID: {userId}
|
|
182
|
+
API Key: {apiKeyPrefix}...
|
|
183
|
+
API URL: {apiUrl}
|
|
184
|
+
Last Auth: {lastAuth}
|
|
185
|
+
|
|
186
|
+
API Status: ✓ Reachable
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Output (Connection Error)
|
|
190
|
+
|
|
191
|
+
```
|
|
192
|
+
☁️ Cloud Authentication Status
|
|
193
|
+
|
|
194
|
+
Connection: ⚠️ Error
|
|
195
|
+
Email: {email}
|
|
196
|
+
API Key: {apiKeyPrefix}...
|
|
197
|
+
API URL: {apiUrl}
|
|
198
|
+
|
|
199
|
+
Error: {connectionError}
|
|
200
|
+
|
|
201
|
+
Try `/p:auth login` to re-authenticate.
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## Error Handling
|
|
207
|
+
|
|
208
|
+
| Error | Response |
|
|
209
|
+
|-------|----------|
|
|
210
|
+
| Invalid key format | "API key must start with prjct_" |
|
|
211
|
+
| Key rejected by API | "Invalid or expired API key" |
|
|
212
|
+
| Network error | "Cannot connect to {apiUrl}. Check internet." |
|
|
213
|
+
| Already logged in | Offer to re-authenticate |
|
|
214
|
+
|
|
215
|
+
---
|
|
216
|
+
|
|
217
|
+
## Auth File Structure
|
|
218
|
+
|
|
219
|
+
Location: `~/.prjct-cli/config/auth.json`
|
|
220
|
+
|
|
221
|
+
```json
|
|
222
|
+
{
|
|
223
|
+
"apiKey": "prjct_live_xxxxxxxxxxxxxxxxxxxx",
|
|
224
|
+
"apiUrl": "https://api.prjct.app",
|
|
225
|
+
"userId": "uuid-from-server",
|
|
226
|
+
"email": "user@example.com",
|
|
227
|
+
"lastAuth": "2024-01-15T10:00:00.000Z"
|
|
228
|
+
}
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
**Security Notes:**
|
|
232
|
+
- API key is stored in plain text (like git credentials)
|
|
233
|
+
- File permissions should be 600 (user read/write only)
|
|
234
|
+
- Never commit this file to version control
|
|
@@ -409,6 +409,52 @@ APPEND to: `{globalPath}/memory/events.jsonl`
|
|
|
409
409
|
|
|
410
410
|
---
|
|
411
411
|
|
|
412
|
+
## Step 9: Backend Sync (Cloud)
|
|
413
|
+
|
|
414
|
+
Sync with prjct API if authenticated.
|
|
415
|
+
|
|
416
|
+
### 9.1 Check Authentication
|
|
417
|
+
|
|
418
|
+
READ: `~/.prjct-cli/config/auth.json`
|
|
419
|
+
|
|
420
|
+
IF no auth OR no apiKey:
|
|
421
|
+
SET: `{cloudSync}` = false
|
|
422
|
+
OUTPUT TIP: "💡 Run `prjct auth` to enable cloud sync"
|
|
423
|
+
CONTINUE to output (skip 9.2, 9.3)
|
|
424
|
+
|
|
425
|
+
ELSE:
|
|
426
|
+
SET: `{cloudSync}` = true
|
|
427
|
+
|
|
428
|
+
### 9.2 Push Pending Events
|
|
429
|
+
|
|
430
|
+
READ: `{globalPath}/sync/pending.json`
|
|
431
|
+
COUNT: `{pendingCount}` events
|
|
432
|
+
|
|
433
|
+
IF pendingCount > 0:
|
|
434
|
+
CALL syncManager.push(projectId)
|
|
435
|
+
|
|
436
|
+
IF success:
|
|
437
|
+
SET: `{pushedCount}` = result.count
|
|
438
|
+
OUTPUT: "☁️ Pushed {pushedCount} events to cloud"
|
|
439
|
+
ELSE:
|
|
440
|
+
OUTPUT: "⚠️ Cloud sync failed: {error}. Events queued for retry."
|
|
441
|
+
SET: `{syncError}` = error
|
|
442
|
+
ELSE:
|
|
443
|
+
SET: `{pushedCount}` = 0
|
|
444
|
+
|
|
445
|
+
### 9.3 Pull Updates (if push succeeded)
|
|
446
|
+
|
|
447
|
+
IF cloudSync AND no syncError:
|
|
448
|
+
CALL syncManager.pull(projectId)
|
|
449
|
+
|
|
450
|
+
IF success AND result.count > 0:
|
|
451
|
+
SET: `{pulledCount}` = result.count
|
|
452
|
+
OUTPUT: "📥 Pulled {pulledCount} updates from cloud"
|
|
453
|
+
ELSE:
|
|
454
|
+
SET: `{pulledCount}` = 0
|
|
455
|
+
|
|
456
|
+
---
|
|
457
|
+
|
|
412
458
|
## Output
|
|
413
459
|
|
|
414
460
|
```
|
|
@@ -436,6 +482,15 @@ APPEND to: `{globalPath}/memory/events.jsonl`
|
|
|
436
482
|
├── Workflow: prjct-workflow, prjct-planner, prjct-shipper
|
|
437
483
|
└── Domain: {domainAgents.join(', ') || 'none'}
|
|
438
484
|
|
|
485
|
+
{IF cloudSync}
|
|
486
|
+
☁️ Cloud Sync
|
|
487
|
+
├── Pushed: {pushedCount} events
|
|
488
|
+
├── Pulled: {pulledCount} updates
|
|
489
|
+
└── Status: {syncError ? "⚠️ " + syncError : "✓ Synced"}
|
|
490
|
+
{ELSE}
|
|
491
|
+
💡 Cloud sync disabled. Run `prjct auth` to enable.
|
|
492
|
+
{ENDIF}
|
|
493
|
+
|
|
439
494
|
{IF hasUncommittedChanges}
|
|
440
495
|
⚠️ You have uncommitted changes
|
|
441
496
|
|