@l4yercak3/cli 1.0.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.
Files changed (61) hide show
  1. package/.claude/settings.local.json +18 -0
  2. package/.cursor/rules.md +203 -0
  3. package/.eslintrc.js +31 -0
  4. package/README.md +227 -0
  5. package/bin/cli.js +61 -0
  6. package/docs/ADDING_NEW_PROJECT_TYPE.md +156 -0
  7. package/docs/ARCHITECTURE_RELATIONSHIPS.md +411 -0
  8. package/docs/CLI_AUTHENTICATION.md +214 -0
  9. package/docs/DETECTOR_ARCHITECTURE.md +326 -0
  10. package/docs/DEVELOPMENT.md +194 -0
  11. package/docs/IMPLEMENTATION_PHASES.md +468 -0
  12. package/docs/OAUTH_CLARIFICATION.md +258 -0
  13. package/docs/OAUTH_SETUP_GUIDE_TEMPLATE.md +211 -0
  14. package/docs/PHASE_0_PROGRESS.md +120 -0
  15. package/docs/PHASE_1_COMPLETE.md +366 -0
  16. package/docs/PHASE_SUMMARY.md +149 -0
  17. package/docs/PLAN.md +511 -0
  18. package/docs/README.md +56 -0
  19. package/docs/STRIPE_INTEGRATION.md +447 -0
  20. package/docs/SUMMARY.md +230 -0
  21. package/docs/UPDATED_PLAN.md +447 -0
  22. package/package.json +53 -0
  23. package/src/api/backend-client.js +148 -0
  24. package/src/commands/login.js +146 -0
  25. package/src/commands/logout.js +24 -0
  26. package/src/commands/spread.js +364 -0
  27. package/src/commands/status.js +62 -0
  28. package/src/config/config-manager.js +205 -0
  29. package/src/detectors/api-client-detector.js +85 -0
  30. package/src/detectors/base-detector.js +77 -0
  31. package/src/detectors/github-detector.js +74 -0
  32. package/src/detectors/index.js +80 -0
  33. package/src/detectors/nextjs-detector.js +139 -0
  34. package/src/detectors/oauth-detector.js +122 -0
  35. package/src/detectors/registry.js +97 -0
  36. package/src/generators/api-client-generator.js +197 -0
  37. package/src/generators/env-generator.js +162 -0
  38. package/src/generators/gitignore-generator.js +92 -0
  39. package/src/generators/index.js +50 -0
  40. package/src/generators/nextauth-generator.js +242 -0
  41. package/src/generators/oauth-guide-generator.js +277 -0
  42. package/src/logo.js +116 -0
  43. package/tests/api-client-detector.test.js +214 -0
  44. package/tests/api-client-generator.test.js +169 -0
  45. package/tests/backend-client.test.js +361 -0
  46. package/tests/base-detector.test.js +101 -0
  47. package/tests/commands/login.test.js +98 -0
  48. package/tests/commands/logout.test.js +70 -0
  49. package/tests/commands/status.test.js +167 -0
  50. package/tests/config-manager.test.js +313 -0
  51. package/tests/detector-index.test.js +209 -0
  52. package/tests/detector-registry.test.js +93 -0
  53. package/tests/env-generator.test.js +278 -0
  54. package/tests/generators-index.test.js +215 -0
  55. package/tests/github-detector.test.js +145 -0
  56. package/tests/gitignore-generator.test.js +109 -0
  57. package/tests/logo.test.js +96 -0
  58. package/tests/nextauth-generator.test.js +231 -0
  59. package/tests/nextjs-detector.test.js +235 -0
  60. package/tests/oauth-detector.test.js +264 -0
  61. package/tests/oauth-guide-generator.test.js +273 -0
@@ -0,0 +1,411 @@
1
+ # Architecture & Relationships - CORRECTED
2
+
3
+ ## The Correct Hierarchy
4
+
5
+ ### For Agency Organizations
6
+
7
+ ```
8
+ ┌─────────────────────────────────────────────────────────┐
9
+ │ Agency Organization (Platform User) │
10
+ │ - Platform organization account │
11
+ │ - Can create sub-organizations │
12
+ │ - Owns the relationship │
13
+ └──────────────────┬──────────────────────────────────────┘
14
+
15
+ │ Creates/manages
16
+
17
+ ┌─────────────────────────────────────────────────────────┐
18
+ │ Sub-Organization (Agency's Customer) │
19
+ │ - The customer the boilerplate is built FOR │
20
+ │ - Owns their own Stripe account (legal requirement) │
21
+ │ - Has CRM Organizations (their customers) │
22
+ │ - Frontend app is built for THIS sub-organization │
23
+ └──────────────────┬──────────────────────────────────────┘
24
+
25
+ │ Has customers (CRM data)
26
+
27
+ ┌─────────────────────────────────────────────────────────┐
28
+ │ CRM Organization (Sub-Org's Customer) │
29
+ │ - The customer's customer │
30
+ │ - NOT a platform organization │
31
+ │ - Stored in CRM system │
32
+ │ - Has CRM Contacts (people within the org) │
33
+ └──────────────────┬──────────────────────────────────────┘
34
+
35
+ │ Contains
36
+
37
+ ┌─────────────────────────────────────────────────────────┐
38
+ │ CRM Contacts / Frontend Users │
39
+ │ - People who log into the frontend │
40
+ │ - Created via NextAuth.js OAuth │
41
+ │ - Linked to CRM Organization │
42
+ │ - Authentication managed by backend │
43
+ └─────────────────────────────────────────────────────────┘
44
+ ```
45
+
46
+ ### For Regular Organizations (Non-Agency)
47
+
48
+ ```
49
+ ┌─────────────────────────────────────────────────────────┐
50
+ │ Regular Organization (Platform User) │
51
+ │ - Platform organization account │
52
+ │ - Works for themselves │
53
+ │ - Owns their own Stripe account │
54
+ └──────────────────┬──────────────────────────────────────┘
55
+
56
+ │ Has customers (CRM data)
57
+
58
+ ┌─────────────────────────────────────────────────────────┐
59
+ │ CRM Organization (Organization's Customer) │
60
+ │ - The organization's customer │
61
+ │ - NOT a platform organization │
62
+ │ - Stored in CRM system │
63
+ │ - Has CRM Contacts (people within the org) │
64
+ └──────────────────┬──────────────────────────────────────┘
65
+
66
+ │ Contains
67
+
68
+ ┌─────────────────────────────────────────────────────────┐
69
+ │ CRM Contacts / Frontend Users │
70
+ │ - People who log into the frontend │
71
+ │ - Created via NextAuth.js OAuth │
72
+ │ - Linked to CRM Organization │
73
+ │ - Authentication managed by backend │
74
+ └─────────────────────────────────────────────────────────┘
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Key Distinctions
80
+
81
+ ### Platform Organizations vs CRM Organizations
82
+
83
+ **Platform Organizations:**
84
+ - Agency Organization: Platform account, can create sub-organizations
85
+ - Sub-Organization: Platform account, created by agency, owns Stripe account
86
+ - Regular Organization: Platform account, works for themselves
87
+
88
+ **CRM Organizations:**
89
+ - NOT platform organizations
90
+ - Customer data stored in CRM system
91
+ - The customer's customer (for agencies) or the organization's customer (for regular)
92
+ - Has CRM Contacts (people)
93
+
94
+ ### Why "CRM" Prefix?
95
+
96
+ **CRM Organization** = Customer data, not platform organization data
97
+ - Stored in `objects` table with `type: "crm_organization"`
98
+ - Part of CRM system, not platform organization system
99
+ - Represents the end customer
100
+
101
+ **CRM Contact** = Person within a CRM Organization
102
+ - Stored in `objects` table with `type: "crm_contact"`
103
+ - Can become a Frontend User when they authenticate
104
+ - Linked to CRM Organization
105
+
106
+ ---
107
+
108
+ ## Complete Flow Examples
109
+
110
+ ### Example 1: Agency Building Site for Customer
111
+
112
+ ```
113
+ 1. Agency Organization: "WebDev Agency"
114
+ ↓ Creates sub-organization
115
+ 2. Sub-Organization: "Acme Corp" (Agency's customer)
116
+ - Boilerplate built FOR Acme Corp
117
+ - Acme Corp connects their Stripe account
118
+ ↓ Has customers (CRM data)
119
+ 3. CRM Organization: "Widgets Inc" (Acme Corp's customer)
120
+ ↓ Contains people
121
+ 4. CRM Contacts: "John Doe", "Jane Smith" (people at Widgets Inc)
122
+ ↓ When they authenticate
123
+ 5. Frontend Users: John and Jane log into Acme Corp's frontend
124
+ ```
125
+
126
+ **In Backend:**
127
+ - Agency Organization: `organizations` table
128
+ - Sub-Organization: `organizations` table (with `parentOrganizationId`)
129
+ - CRM Organization: `objects` table (`type: "crm_organization"`)
130
+ - CRM Contacts: `objects` table (`type: "crm_contact"`)
131
+ - Frontend Users: `objects` table (`type: "frontend_user"`)
132
+
133
+ ### Example 2: Regular Organization
134
+
135
+ ```
136
+ 1. Regular Organization: "Freelancer Joe"
137
+ - Works for themselves
138
+ - Connects their own Stripe account
139
+ ↓ Has customers (CRM data)
140
+ 2. CRM Organization: "Client Corp" (Joe's customer)
141
+ ↓ Contains people
142
+ 3. CRM Contacts: "Alice", "Bob" (people at Client Corp)
143
+ ↓ When they authenticate
144
+ 4. Frontend Users: Alice and Bob log into Joe's frontend
145
+ ```
146
+
147
+ ---
148
+
149
+ ## Stripe Account Ownership
150
+
151
+ ### Agency Scenario
152
+
153
+ **Sub-Organization owns Stripe account:**
154
+ - Sub-Organization (Acme Corp) connects their Stripe account
155
+ - Agency (WebDev Agency) can view transactions (read-only)
156
+ - Agency CANNOT onboard sub-org to Stripe (legal requirement)
157
+ - Sub-Organization must onboard themselves
158
+
159
+ **CRM Organizations do NOT have Stripe accounts:**
160
+ - CRM Organizations are just customer data
161
+ - They don't process payments
162
+ - Payments go through Sub-Organization's Stripe account
163
+
164
+ ### Regular Organization Scenario
165
+
166
+ **Organization owns Stripe account:**
167
+ - Regular Organization (Freelancer Joe) connects their Stripe account
168
+ - All transactions go through this account
169
+ - CRM Organizations are just customer data (no Stripe accounts)
170
+
171
+ ---
172
+
173
+ ## Frontend Authentication Flow
174
+
175
+ ### Who Authenticates?
176
+
177
+ **Frontend Users authenticate:**
178
+ - These are CRM Contacts who log into the frontend
179
+ - They authenticate via NextAuth.js (Google/Microsoft)
180
+ - Creates `frontend_user` object in backend
181
+ - Automatically linked to `crm_contact` object
182
+ - Scoped to the Sub-Organization (for agencies) or Regular Organization
183
+
184
+ ### Example Flow
185
+
186
+ ```
187
+ 1. Alice (CRM Contact at Widgets Inc) visits Acme Corp's frontend
188
+
189
+ 2. Alice clicks "Sign in with Google"
190
+
191
+ 3. NextAuth.js handles OAuth
192
+
193
+ 4. Frontend calls backend: POST /api/v1/auth/sync-user
194
+ Body: {
195
+ email: "alice@widgetsinc.com",
196
+ name: "Alice",
197
+ oauthProvider: "google",
198
+ oauthId: "123456"
199
+ }
200
+
201
+ 5. Backend:
202
+ a. Creates/updates frontend_user object
203
+ b. Finds CRM contact by email (alice@widgetsinc.com)
204
+ c. Links frontend_user to crm_contact
205
+ d. Links to CRM Organization (Widgets Inc)
206
+ e. Scopes to Sub-Organization (Acme Corp)
207
+
208
+ 6. Alice can now use Acme Corp's frontend
209
+ - All API calls scoped to Acme Corp (Sub-Organization)
210
+ - Alice's data linked to Widgets Inc (CRM Organization)
211
+ ```
212
+
213
+ ---
214
+
215
+ ## CLI Boilerplate Generation
216
+
217
+ ### What Gets Generated
218
+
219
+ #### For Agency Setting Up Boilerplate
220
+
221
+ ```
222
+ 1. Agency runs: npx @l4yercak3/cli spread
223
+
224
+ 2. CLI asks: "Organization type?" [regular/agency] agency
225
+
226
+ 3. CLI asks: "Create sub-organization for customer?" (y/n) y
227
+ ? Customer name: Acme Corp
228
+ ? Customer email: contact@acme.com
229
+ ✅ Sub-Organization created: sub_org_123
230
+ ✅ API key generated: l4y_sub_org_123...
231
+
232
+ 4. CLI generates boilerplate:
233
+ - API client (scoped to Sub-Organization)
234
+ - Authentication (creates frontend_users → crm_contacts)
235
+ - Stripe onboarding page (for Sub-Org to connect)
236
+ - Webhook handler (forwards to backend)
237
+
238
+ 5. Sub-Organization (Acme Corp) connects Stripe account
239
+
240
+ 6. CRM Organizations (Acme Corp's customers) added via CRM
241
+
242
+ 7. CRM Contacts authenticate and become Frontend Users
243
+ ```
244
+
245
+ #### For Regular Organization
246
+
247
+ ```
248
+ 1. Organization runs: npx @l4yercak3/cli spread
249
+
250
+ 2. CLI asks: "Organization type?" [regular/agency] regular
251
+
252
+ 3. CLI uses existing organization
253
+ ✅ API key: l4y_org_123...
254
+
255
+ 4. CLI generates boilerplate:
256
+ - API client (scoped to Organization)
257
+ - Authentication (creates frontend_users → crm_contacts)
258
+ - Stripe onboarding page (for Organization to connect)
259
+ - Webhook handler (forwards to backend)
260
+
261
+ 5. Organization connects Stripe account
262
+
263
+ 6. CRM Organizations (Organization's customers) added via CRM
264
+
265
+ 7. CRM Contacts authenticate and become Frontend Users
266
+ ```
267
+
268
+ ---
269
+
270
+ ## Environment Variables by Context
271
+
272
+ ### Sub-Organization (Agency's Customer)
273
+
274
+ ```bash
275
+ # Sub-Organization's API key (for their frontend)
276
+ BACKEND_API_URL=https://backend.convex.site
277
+ BACKEND_API_KEY=l4y_sub_org_123... # Sub-Org's key
278
+
279
+ # Stripe (Sub-Organization's Stripe account)
280
+ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_... # Sub-Org's key
281
+ STRIPE_WEBHOOK_SECRET=whsec_...
282
+
283
+ # OAuth (for CRM Contacts/Frontend Users)
284
+ GOOGLE_CLIENT_ID=...
285
+ GOOGLE_CLIENT_SECRET=...
286
+ ```
287
+
288
+ ### Regular Organization
289
+
290
+ ```bash
291
+ # Organization's API key (for their frontend)
292
+ BACKEND_API_URL=https://backend.convex.site
293
+ BACKEND_API_KEY=l4y_org_123... # Organization's key
294
+
295
+ # Stripe (Organization's Stripe account)
296
+ NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_... # Org's key
297
+ STRIPE_WEBHOOK_SECRET=whsec_...
298
+
299
+ # OAuth (for CRM Contacts/Frontend Users)
300
+ GOOGLE_CLIENT_ID=...
301
+ GOOGLE_CLIENT_SECRET=...
302
+ ```
303
+
304
+ ---
305
+
306
+ ## Key Principles (Corrected)
307
+
308
+ ### 1. **Platform Organizations vs CRM Organizations**
309
+
310
+ **Platform Organizations:**
311
+ - Agency Organization: Platform account
312
+ - Sub-Organization: Platform account (created by agency)
313
+ - Regular Organization: Platform account
314
+
315
+ **CRM Organizations:**
316
+ - NOT platform organizations
317
+ - Customer data in CRM system
318
+ - The customer's customer (for agencies) or organization's customer (for regular)
319
+ - Stored as `objects` with `type: "crm_organization"`
320
+
321
+ ### 2. **Stripe Account Ownership**
322
+
323
+ **Agency Scenario:**
324
+ - Sub-Organization owns Stripe account
325
+ - Agency can view transactions (read-only)
326
+ - Agency CANNOT onboard sub-org (legal requirement)
327
+ - Sub-Organization must onboard themselves
328
+
329
+ **Regular Scenario:**
330
+ - Organization owns Stripe account
331
+ - All transactions go through this account
332
+
333
+ ### 3. **Frontend Authentication**
334
+
335
+ **Who authenticates:**
336
+ - CRM Contacts authenticate and become Frontend Users
337
+ - Scoped to Sub-Organization (for agencies) or Organization (for regular)
338
+ - All user management in backend
339
+
340
+ ### 4. **Boilerplate Scope**
341
+
342
+ **For Agencies:**
343
+ - Boilerplate scoped to Sub-Organization
344
+ - Uses Sub-Organization's API key
345
+ - Stripe onboarding for Sub-Organization
346
+ - Frontend users are CRM Contacts from CRM Organizations
347
+
348
+ **For Regular:**
349
+ - Boilerplate scoped to Organization
350
+ - Uses Organization's API key
351
+ - Stripe onboarding for Organization
352
+ - Frontend users are CRM Contacts from CRM Organizations
353
+
354
+ ---
355
+
356
+ ## Updated CLI Generation Checklist
357
+
358
+ ### For Agency Setting Up Boilerplate
359
+
360
+ - [ ] Detect organization type (agency vs regular)
361
+ - [ ] Create Sub-Organization via backend API (not CRM Organization)
362
+ - [ ] Generate API key for Sub-Organization
363
+ - [ ] Generate API client scoped to Sub-Organization
364
+ - [ ] Generate authentication (NextAuth.js)
365
+ - Creates frontend_users from crm_contacts
366
+ - Scoped to Sub-Organization
367
+ - [ ] Generate Stripe onboarding page (for Sub-Organization)
368
+ - [ ] Generate webhook handler
369
+ - [ ] Document: CRM Organizations are customer data, not platform orgs
370
+
371
+ ### For Regular Organization
372
+
373
+ - [ ] Use existing Organization
374
+ - [ ] Generate API client scoped to Organization
375
+ - [ ] Generate authentication (NextAuth.js)
376
+ - Creates frontend_users from crm_contacts
377
+ - Scoped to Organization
378
+ - [ ] Generate Stripe onboarding page (for Organization)
379
+ - [ ] Generate webhook handler
380
+
381
+ ---
382
+
383
+ ## Questions Resolved ✅
384
+
385
+ 1. **What is a CRM Organization?**
386
+ - ✅ Customer data, NOT a platform organization
387
+ - ✅ The customer's customer (for agencies) or organization's customer (for regular)
388
+ - ✅ Stored in CRM system (`objects` table)
389
+
390
+ 2. **What is a Sub-Organization?**
391
+ - ✅ Platform organization created by Agency
392
+ - ✅ The customer the boilerplate is built FOR
393
+ - ✅ Owns their own Stripe account
394
+ - ✅ Has CRM Organizations as their customers
395
+
396
+ 3. **Who owns Stripe accounts?**
397
+ - ✅ Sub-Organization (for agencies) or Organization (for regular)
398
+ - ✅ NOT CRM Organizations (they're just customer data)
399
+ - ✅ Customers must onboard themselves (legal requirement)
400
+
401
+ 4. **Who authenticates?**
402
+ - ✅ CRM Contacts authenticate and become Frontend Users
403
+ - ✅ Scoped to Sub-Organization (for agencies) or Organization (for regular)
404
+ - ✅ All managed by backend
405
+
406
+ ---
407
+
408
+ **Last Updated:** 2025-01-14
409
+ **Status:** Architecture Corrected
410
+ **Key Insight:** CRM Organization = Customer data, NOT platform organization
411
+
@@ -0,0 +1,214 @@
1
+ # CLI Authentication Design
2
+
3
+ ## Overview
4
+
5
+ The CLI follows the **GitHub CLI (`gh`)** authentication pattern - users must authenticate before using the CLI. This ensures security and proper access control.
6
+
7
+ ## Authentication Flow
8
+
9
+ ### 1. User Runs Login Command
10
+
11
+ ```bash
12
+ $ l4yercak3 login
13
+ ```
14
+
15
+ ### 2. Browser-Based OAuth Flow
16
+
17
+ 1. CLI opens browser to: `https://platform.l4yercak3.com/auth/cli-login`
18
+ 2. User authenticates with platform (Google/Microsoft/GitHub)
19
+ 3. User may need to complete 2FA if enabled
20
+ 4. Platform generates CLI session token
21
+ 5. Browser redirects to: `l4yercak3://auth/callback?token=...`
22
+ 6. CLI receives token via local server or deep link
23
+
24
+ ### 3. Store Session Securely
25
+
26
+ CLI stores session token in:
27
+ - **macOS/Linux:** `~/.l4yercak3/config.json`
28
+ - **Windows:** `%APPDATA%/.l4yercak3/config.json`
29
+
30
+ ```json
31
+ {
32
+ "session": {
33
+ "token": "cli_session_abc123...",
34
+ "expiresAt": 1234567890,
35
+ "userId": "user_123",
36
+ "email": "user@example.com"
37
+ },
38
+ "organizations": [
39
+ {
40
+ "id": "org_123",
41
+ "name": "My Organization",
42
+ "apiKey": "sk_live_..."
43
+ }
44
+ ]
45
+ }
46
+ ```
47
+
48
+ ### 4. Use Session for API Calls
49
+
50
+ All CLI commands use the stored session token:
51
+ - Validate session before each command
52
+ - Refresh token if expired
53
+ - Prompt re-login if session invalid
54
+
55
+ ## Commands
56
+
57
+ ### Login
58
+
59
+ ```bash
60
+ $ l4yercak3 login
61
+ ```
62
+
63
+ **Flow:**
64
+ 1. Opens browser for OAuth
65
+ 2. User authenticates
66
+ 3. Stores session token
67
+ 4. Confirms login success
68
+
69
+ ### Logout
70
+
71
+ ```bash
72
+ $ l4yercak3 logout
73
+ ```
74
+
75
+ **Flow:**
76
+ 1. Removes session token
77
+ 2. Clears stored credentials
78
+ 3. Confirms logout
79
+
80
+ ### Status
81
+
82
+ ```bash
83
+ $ l4yercak3 auth status
84
+ ```
85
+
86
+ **Shows:**
87
+ - Logged in: Yes/No
88
+ - User email
89
+ - Session expiration
90
+ - Organizations accessible
91
+
92
+ ## Security Considerations
93
+
94
+ ### Session Tokens
95
+
96
+ - **Format:** `cli_session_{random_32_bytes}`
97
+ - **Expiration:** 30 days (configurable)
98
+ - **Storage:** Encrypted at rest (OS keychain on macOS)
99
+ - **Scope:** Limited to CLI operations
100
+
101
+ ### Token Refresh
102
+
103
+ - Automatically refresh before expiration
104
+ - Prompt re-login if refresh fails
105
+ - Handle 2FA gracefully
106
+
107
+ ### 2FA Support
108
+
109
+ - If user has 2FA enabled, require it during login
110
+ - Store 2FA status in session
111
+ - Re-prompt if session expires
112
+
113
+ ## Backend Requirements
114
+
115
+ ### OAuth Endpoints Needed
116
+
117
+ 1. **CLI Login Initiation**
118
+ - `GET /auth/cli-login`
119
+ - Redirects to OAuth provider
120
+ - Sets up callback URL: `l4yercak3://auth/callback`
121
+
122
+ 2. **CLI Callback Handler**
123
+ - `GET /auth/cli/callback`
124
+ - Receives OAuth code
125
+ - Exchanges for CLI session token
126
+ - Redirects to: `l4yercak3://auth/callback?token=...`
127
+
128
+ 3. **Session Validation**
129
+ - `GET /auth/cli/validate`
130
+ - Validates CLI session token
131
+ - Returns user info and organizations
132
+
133
+ 4. **Session Refresh**
134
+ - `POST /auth/cli/refresh`
135
+ - Refreshes expired session
136
+ - Returns new token
137
+
138
+ ### Session Storage
139
+
140
+ Backend stores CLI sessions in:
141
+ - `cli_sessions` table (or similar)
142
+ - Fields: `token`, `userId`, `expiresAt`, `createdAt`, `lastUsedAt`
143
+ - Auto-cleanup expired sessions
144
+
145
+ ## Implementation Phases
146
+
147
+ ### Phase 0: Basic Authentication
148
+
149
+ - [ ] CLI login command
150
+ - [ ] Browser OAuth flow
151
+ - [ ] Session token storage
152
+ - [ ] Session validation
153
+
154
+ ### Phase 1: Session Management
155
+
156
+ - [ ] Token refresh
157
+ - [ ] Auto-logout on expiration
158
+ - [ ] Status command
159
+
160
+ ### Phase 2: Security Enhancements
161
+
162
+ - [ ] 2FA support
163
+ - [ ] OS keychain integration (macOS)
164
+ - [ ] Encrypted storage
165
+ - [ ] Session revocation
166
+
167
+ ## Example Usage
168
+
169
+ ```bash
170
+ # First time user
171
+ $ l4yercak3 login
172
+ Opening browser for authentication...
173
+ ✓ Successfully logged in as user@example.com
174
+
175
+ # Check status
176
+ $ l4yercak3 auth status
177
+ Logged in as: user@example.com
178
+ Session expires: 2025-02-14
179
+ Organizations: 2
180
+
181
+ # Use CLI commands (session automatically used)
182
+ $ l4yercak3 spread
183
+ ✓ Using organization: My Organization
184
+ ✓ Generating boilerplate...
185
+
186
+ # Logout
187
+ $ l4yercak3 logout
188
+ ✓ Logged out successfully
189
+ ```
190
+
191
+ ## Comparison to GitHub CLI
192
+
193
+ | Feature | GitHub CLI (`gh`) | L4YERCAK3 CLI |
194
+ |---------|------------------|---------------|
195
+ | Login Command | `gh auth login` | `l4yercak3 login` |
196
+ | Browser OAuth | ✅ | ✅ |
197
+ | 2FA Support | ✅ | ✅ |
198
+ | Session Storage | `~/.config/gh/` | `~/.l4yercak3/` |
199
+ | Token Format | `gho_...` | `cli_session_...` |
200
+ | Auto Refresh | ✅ | ✅ |
201
+
202
+ ## Benefits
203
+
204
+ 1. **Security:** Users authenticate securely with 2FA
205
+ 2. **Familiar:** Follows industry standard (GitHub CLI pattern)
206
+ 3. **Flexible:** Can create multiple orgs after login
207
+ 4. **Auditable:** All actions tied to authenticated user
208
+ 5. **Revocable:** Sessions can be revoked from platform UI
209
+
210
+ ---
211
+
212
+ **Status:** Design Phase
213
+ **Next:** Implement Phase 0 authentication flow
214
+