@kodus/cli 0.0.12 → 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.
Files changed (151) hide show
  1. package/README.md +387 -0
  2. package/dist/cli.d.ts +4 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +26 -0
  5. package/dist/cli.js.map +1 -0
  6. package/dist/commands/auth/index.d.ts +3 -0
  7. package/dist/commands/auth/index.d.ts.map +1 -0
  8. package/dist/commands/auth/index.js +36 -0
  9. package/dist/commands/auth/index.js.map +1 -0
  10. package/dist/commands/auth/login.d.ts +7 -0
  11. package/dist/commands/auth/login.d.ts.map +1 -0
  12. package/dist/commands/auth/login.js +97 -0
  13. package/dist/commands/auth/login.js.map +1 -0
  14. package/dist/commands/auth/logout.d.ts +2 -0
  15. package/dist/commands/auth/logout.d.ts.map +1 -0
  16. package/dist/commands/auth/logout.js +24 -0
  17. package/dist/commands/auth/logout.js.map +1 -0
  18. package/dist/commands/auth/signup.d.ts +2 -0
  19. package/dist/commands/auth/signup.d.ts.map +1 -0
  20. package/dist/commands/auth/signup.js +74 -0
  21. package/dist/commands/auth/signup.js.map +1 -0
  22. package/dist/commands/auth/status.d.ts +2 -0
  23. package/dist/commands/auth/status.d.ts.map +1 -0
  24. package/dist/commands/auth/status.js +91 -0
  25. package/dist/commands/auth/status.js.map +1 -0
  26. package/dist/commands/auth/team-key.d.ts +5 -0
  27. package/dist/commands/auth/team-key.d.ts.map +1 -0
  28. package/dist/commands/auth/team-key.js +59 -0
  29. package/dist/commands/auth/team-key.js.map +1 -0
  30. package/dist/commands/auth/token.d.ts +2 -0
  31. package/dist/commands/auth/token.d.ts.map +1 -0
  32. package/dist/commands/auth/token.js +31 -0
  33. package/dist/commands/auth/token.js.map +1 -0
  34. package/dist/commands/config.d.ts +3 -0
  35. package/dist/commands/config.d.ts.map +1 -0
  36. package/dist/commands/config.js +47 -0
  37. package/dist/commands/config.js.map +1 -0
  38. package/dist/commands/pr.d.ts +3 -0
  39. package/dist/commands/pr.d.ts.map +1 -0
  40. package/dist/commands/pr.js +75 -0
  41. package/dist/commands/pr.js.map +1 -0
  42. package/dist/commands/review.d.ts +3 -0
  43. package/dist/commands/review.d.ts.map +1 -0
  44. package/dist/commands/review.js +245 -0
  45. package/dist/commands/review.js.map +1 -0
  46. package/dist/commands/telemetry.d.ts +3 -0
  47. package/dist/commands/telemetry.d.ts.map +1 -0
  48. package/dist/commands/telemetry.js +76 -0
  49. package/dist/commands/telemetry.js.map +1 -0
  50. package/dist/commands/upgrade.d.ts +3 -0
  51. package/dist/commands/upgrade.d.ts.map +1 -0
  52. package/dist/commands/upgrade.js +35 -0
  53. package/dist/commands/upgrade.js.map +1 -0
  54. package/dist/constants.d.ts +3 -0
  55. package/dist/constants.d.ts.map +1 -0
  56. package/dist/constants.js +3 -0
  57. package/dist/constants.js.map +1 -0
  58. package/dist/formatters/json.d.ts +7 -0
  59. package/dist/formatters/json.d.ts.map +1 -0
  60. package/dist/formatters/json.js +7 -0
  61. package/dist/formatters/json.js.map +1 -0
  62. package/dist/formatters/markdown.d.ts +7 -0
  63. package/dist/formatters/markdown.d.ts.map +1 -0
  64. package/dist/formatters/markdown.js +93 -0
  65. package/dist/formatters/markdown.js.map +1 -0
  66. package/dist/formatters/prompt.d.ts +12 -0
  67. package/dist/formatters/prompt.d.ts.map +1 -0
  68. package/dist/formatters/prompt.js +90 -0
  69. package/dist/formatters/prompt.js.map +1 -0
  70. package/dist/formatters/terminal.d.ts +7 -0
  71. package/dist/formatters/terminal.d.ts.map +1 -0
  72. package/dist/formatters/terminal.js +127 -0
  73. package/dist/formatters/terminal.js.map +1 -0
  74. package/dist/index.d.ts +3 -0
  75. package/dist/index.d.ts.map +1 -0
  76. package/dist/index.js +4 -0
  77. package/dist/index.js.map +1 -0
  78. package/dist/services/api/api.interface.d.ts +46 -0
  79. package/dist/services/api/api.interface.d.ts.map +1 -0
  80. package/dist/services/api/api.interface.js +2 -0
  81. package/dist/services/api/api.interface.js.map +1 -0
  82. package/dist/services/api/api.mock.d.ts +8 -0
  83. package/dist/services/api/api.mock.d.ts.map +1 -0
  84. package/dist/services/api/api.mock.js +249 -0
  85. package/dist/services/api/api.mock.js.map +1 -0
  86. package/dist/services/api/api.real.d.ts +8 -0
  87. package/dist/services/api/api.real.d.ts.map +1 -0
  88. package/dist/services/api/api.real.js +253 -0
  89. package/dist/services/api/api.real.js.map +1 -0
  90. package/dist/services/api/index.d.ts +4 -0
  91. package/dist/services/api/index.d.ts.map +1 -0
  92. package/dist/services/api/index.js +9 -0
  93. package/dist/services/api/index.js.map +1 -0
  94. package/dist/services/auth.service.d.ts +19 -0
  95. package/dist/services/auth.service.d.ts.map +1 -0
  96. package/dist/services/auth.service.js +90 -0
  97. package/dist/services/auth.service.js.map +1 -0
  98. package/dist/services/context.service.d.ts +22 -0
  99. package/dist/services/context.service.d.ts.map +1 -0
  100. package/dist/services/context.service.js +104 -0
  101. package/dist/services/context.service.js.map +1 -0
  102. package/dist/services/fix.service.d.ts +31 -0
  103. package/dist/services/fix.service.d.ts.map +1 -0
  104. package/dist/services/fix.service.js +120 -0
  105. package/dist/services/fix.service.js.map +1 -0
  106. package/dist/services/git.service.d.ts +32 -0
  107. package/dist/services/git.service.d.ts.map +1 -0
  108. package/dist/services/git.service.js +261 -0
  109. package/dist/services/git.service.js.map +1 -0
  110. package/dist/services/review.service.d.ts +26 -0
  111. package/dist/services/review.service.d.ts.map +1 -0
  112. package/dist/services/review.service.js +82 -0
  113. package/dist/services/review.service.js.map +1 -0
  114. package/dist/services/telemetry.service.d.ts +73 -0
  115. package/dist/services/telemetry.service.d.ts.map +1 -0
  116. package/dist/services/telemetry.service.js +229 -0
  117. package/dist/services/telemetry.service.js.map +1 -0
  118. package/dist/types/index.d.ts +143 -0
  119. package/dist/types/index.d.ts.map +1 -0
  120. package/dist/types/index.js +15 -0
  121. package/dist/types/index.js.map +1 -0
  122. package/dist/ui/interactive.d.ts +26 -0
  123. package/dist/ui/interactive.d.ts.map +1 -0
  124. package/dist/ui/interactive.js +365 -0
  125. package/dist/ui/interactive.js.map +1 -0
  126. package/dist/utils/config.d.ts +10 -0
  127. package/dist/utils/config.d.ts.map +1 -0
  128. package/dist/utils/config.js +54 -0
  129. package/dist/utils/config.js.map +1 -0
  130. package/dist/utils/credentials.d.ts +6 -0
  131. package/dist/utils/credentials.d.ts.map +1 -0
  132. package/dist/utils/credentials.js +54 -0
  133. package/dist/utils/credentials.js.map +1 -0
  134. package/dist/utils/rate-limit.d.ts +5 -0
  135. package/dist/utils/rate-limit.d.ts.map +1 -0
  136. package/dist/utils/rate-limit.js +47 -0
  137. package/dist/utils/rate-limit.js.map +1 -0
  138. package/dist/utils/review-loading.d.ts +19 -0
  139. package/dist/utils/review-loading.d.ts.map +1 -0
  140. package/dist/utils/review-loading.js +140 -0
  141. package/dist/utils/review-loading.js.map +1 -0
  142. package/package.json +39 -33
  143. package/index.js +0 -15
  144. package/license.md +0 -21
  145. package/readme.md +0 -128
  146. package/scripts/setup-db.sh +0 -77
  147. package/src/commands/install.js +0 -357
  148. package/src/config/default.js +0 -66
  149. package/src/utils/helpers.js +0 -128
  150. package/templates/.env.example +0 -142
  151. package/templates/docker-compose.yml +0 -139
package/README.md ADDED
@@ -0,0 +1,387 @@
1
+ # Kodus CLI
2
+
3
+ AI-powered code review from your terminal.
4
+
5
+ ## Installation
6
+
7
+ ### npm (Recommended)
8
+
9
+ ```bash
10
+ npm install -g @kodus/cli
11
+ ```
12
+
13
+ ### Via curl
14
+
15
+ ```bash
16
+ curl -fsSL https://raw.githubusercontent.com/kodustech/cli/main/install.sh | bash
17
+ ```
18
+
19
+ ### Homebrew (Coming soon)
20
+
21
+ ```bash
22
+ brew install kodus/tap/kodus
23
+ ```
24
+
25
+ ### Using npx (No installation)
26
+
27
+ ```bash
28
+ npx @kodus/cli review
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ```bash
34
+ # Run an interactive review (default mode)
35
+ kodus review
36
+
37
+ # Run a review on staged files (interactive)
38
+ kodus review --staged
39
+
40
+ # Run a review on a specific commit (interactive)
41
+ kodus review --commit HEAD~1
42
+
43
+ # Run a review comparing against another branch (interactive)
44
+ kodus review --branch main
45
+
46
+ # Run a review on specific files (interactive)
47
+ kodus review src/index.ts src/utils.ts
48
+
49
+ # Review using only configured rules (no general suggestions)
50
+ kodus review --rules-only
51
+
52
+ # Fast mode: quicker analysis (good for large diffs)
53
+ kodus review --fast
54
+
55
+ # Auto-fix: apply all fixable issues automatically
56
+ kodus review --fix
57
+
58
+ # Non-interactive modes:
59
+ # - JSON output
60
+ kodus review --format json
61
+
62
+ # - Markdown report
63
+ kodus review --format markdown
64
+
65
+ # - AI Agent mode (optimized for Claude Code, Cursor, etc)
66
+ kodus review --prompt-only
67
+ ```
68
+
69
+ ## Authentication
70
+
71
+ Sign up at **https://app.kodus.io** to create your account.
72
+
73
+ ```bash
74
+ # Login with your account
75
+ kodus auth login
76
+
77
+ # Check authentication status
78
+ kodus auth status
79
+
80
+ # Logout
81
+ kodus auth logout
82
+
83
+ # Generate CI/CD token
84
+ kodus auth token
85
+ ```
86
+
87
+ ## Review Modes
88
+
89
+ ### Interactive Mode (Default)
90
+ Navigate through issues and apply fixes interactively:
91
+
92
+ ```bash
93
+ # Interactive mode is now the default
94
+ kodus review
95
+
96
+ # You can also explicitly enable it
97
+ kodus review --interactive
98
+ kodus review -i
99
+ ```
100
+
101
+ Features:
102
+ - **File-first navigation**: Browse files with issue counts
103
+ - **Copy fix prompt**: Generate AI-friendly prompts for Claude Code, Cursor, etc.
104
+ - **One-by-one review**: See issues with detailed information
105
+ - **Preview fixes**: View changes before applying
106
+ - **Apply fixes**: Choose which fixes to apply
107
+ - **Live progress**: Track fixed vs remaining issues
108
+
109
+ ### Auto-fix Mode
110
+ Automatically apply all fixable issues:
111
+
112
+ ```bash
113
+ kodus review --fix
114
+ ```
115
+
116
+ Features:
117
+ - Applies all auto-fixable issues at once
118
+ - Shows confirmation prompt before applying
119
+ - Reports success/failure for each fix
120
+
121
+ ### AI Agent Mode
122
+ Optimized for AI coding agents (Claude Code, Cursor, Windsurf):
123
+
124
+ ```bash
125
+ kodus review --prompt-only
126
+ ```
127
+
128
+ Features:
129
+ - Minimal, structured output
130
+ - Easy to parse programmatically
131
+ - Includes fix code for auto-fixable issues
132
+ - Perfect for autonomous generate-review-fix loops
133
+
134
+ ## Output Formats
135
+
136
+ ```bash
137
+ # Interactive mode (default)
138
+ kodus review
139
+
140
+ # JSON output (non-interactive)
141
+ kodus review --format json
142
+
143
+ # Markdown report (non-interactive)
144
+ kodus review --format markdown
145
+
146
+ # AI Agent output (non-interactive)
147
+ kodus review --prompt-only
148
+
149
+ # Save to file (non-interactive)
150
+ kodus review --format markdown --output report.md
151
+
152
+ # Terminal output without interactivity
153
+ kodus review --format terminal --output report.txt
154
+ ```
155
+
156
+ ## Context-Aware Reviews
157
+
158
+ Kodus CLI automatically reads your project's context files to provide better, more relevant reviews:
159
+
160
+ **Auto-detected files:**
161
+ - `.cursorrules` - Cursor IDE rules
162
+ - `claude.md` / `.claude.md` - Claude Code guidelines
163
+ - `.kodus.md` / `.kodus/rules.md` - Kodus-specific rules
164
+
165
+ **Custom context:**
166
+ ```bash
167
+ # Include custom context file
168
+ kodus review --context path/to/custom-guidelines.md
169
+ ```
170
+
171
+ This ensures reviews follow your team's standards, coding patterns, and architectural preferences.
172
+
173
+ ## Configuration
174
+
175
+ When logged in, the CLI fetches your configuration from the Kodus platform:
176
+
177
+ ```bash
178
+ # View active configuration
179
+ kodus config
180
+
181
+ # Review with only your configured rules
182
+ kodus review --rules-only
183
+ ```
184
+
185
+ ### Flags
186
+
187
+ | Flag | Description | Use Case |
188
+ |------|-------------|----------|
189
+ | (none) | Interactive mode (default) | Local development, manual review |
190
+ | `--rules-only` | Only check configured rules | Team standards, CI/CD |
191
+ | `--fast` | Faster analysis with lighter checks | Large diffs, quick feedback |
192
+ | `--staged` | Analyze only staged files | Pre-commit |
193
+ | `--interactive` / `-i` | Explicitly enable interactive mode | When combined with other flags |
194
+ | `--fix` | Auto-apply all fixable issues | Quick fixes, automation |
195
+ | `--prompt-only` | AI agent optimized output | Claude Code, Cursor integration |
196
+ | `--context <file>` | Include custom context file | Project-specific guidelines |
197
+ | `--format json` | Output as JSON (non-interactive) | Automation, integrations |
198
+ | `--output <file>` | Save to file (non-interactive) | Reports, CI/CD artifacts |
199
+
200
+ **Examples:**
201
+
202
+ ```bash
203
+ # Pre-commit: interactive check on staged files (default)
204
+ kodus review --staged
205
+
206
+ # CI/CD: strict rules only, JSON output
207
+ kodus review --rules-only --format json
208
+
209
+ # Quick feedback on large changes (still interactive)
210
+ kodus review --fast
211
+
212
+ # Auto-fix all issues in staged files
213
+ kodus review --staged --fix
214
+
215
+ # AI agent workflow (non-interactive)
216
+ kodus review --prompt-only
217
+
218
+ # Custom context with interactive mode (default)
219
+ kodus review --context .github/GUIDELINES.md
220
+
221
+ # Copy fix prompts and paste into Claude Code
222
+ kodus review # Select file → "Copy fix prompt for AI agent"
223
+ ```
224
+
225
+ ## AI Agent Integration
226
+
227
+ Kodus CLI works seamlessly with AI coding agents like **Claude Code**, **Cursor**, and **Windsurf**.
228
+
229
+ ### Interactive Mode with Copy Prompt (Recommended)
230
+
231
+ The easiest way to use with AI agents:
232
+
233
+ ```bash
234
+ # 1. Run interactive review
235
+ kodus review
236
+
237
+ # 2. Navigate to a file with issues
238
+ # 3. Select "Copy fix prompt for AI agent"
239
+ # 4. Paste into Claude Code/Cursor
240
+ # 5. AI automatically fixes the issues
241
+ ```
242
+
243
+ The copied prompt includes:
244
+ - File path
245
+ - All issues with line numbers and severity
246
+ - Detailed suggestions and recommendations
247
+ - AI-optimized formatting
248
+
249
+ ### Automated Mode with --prompt-only
250
+
251
+ For fully automated workflows:
252
+
253
+ Add this to your `.cursorrules` or prompt:
254
+
255
+ ```
256
+ When writing code:
257
+ 1. Implement the feature
258
+ 2. Run: kodus review --prompt-only
259
+ 3. If issues are found, fix them automatically
260
+ 4. Repeat until review is clean
261
+ 5. Show final result
262
+ ```
263
+
264
+ Claude Code will automatically run reviews and fix issues in a loop.
265
+
266
+ ### Using with Cursor
267
+
268
+ Similar workflow - the AI agent can autonomously:
269
+ - Generate code
270
+ - Review with `kodus review --prompt-only`
271
+ - Parse the structured output
272
+ - Apply fixes
273
+ - Iterate until clean
274
+
275
+ ### Benefits
276
+ - ✅ Catch issues during development, not after
277
+ - ✅ Autonomous fix loops (no manual intervention)
278
+ - ✅ Consistent with team standards
279
+ - ✅ Faster development cycles
280
+
281
+ ## Trial Mode
282
+
283
+ Without an account, you can use the CLI with rate limits:
284
+
285
+ - 5 reviews per day
286
+ - 10 files per review
287
+ - 500 lines per file
288
+
289
+ Sign up for free to remove these limits.
290
+
291
+ ## Development
292
+
293
+ ```bash
294
+ # Install dependencies
295
+ npm install
296
+
297
+ # Build
298
+ npm run build
299
+
300
+ # Run in development
301
+ npm run dev
302
+
303
+ # Test locally
304
+ node dist/index.js review
305
+ ```
306
+
307
+ ## Telemetry
308
+
309
+ Kodus CLI collects anonymous usage data to help improve the product. We take privacy seriously:
310
+
311
+ **What we collect:**
312
+ - Command usage (which commands you run)
313
+ - Feature usage (interactive mode, fix mode, etc)
314
+ - Performance metrics (review duration, files analyzed)
315
+ - Error events (to improve reliability)
316
+
317
+ **What we DON'T collect:**
318
+ - Your code or file contents
319
+ - File names or paths (only basenames)
320
+ - Passwords, tokens, or secrets
321
+ - Any personally identifiable information
322
+
323
+ ### Managing Telemetry
324
+
325
+ ```bash
326
+ # Check telemetry status
327
+ kodus telemetry status
328
+
329
+ # Disable telemetry (opt-out)
330
+ kodus telemetry disable
331
+
332
+ # Enable telemetry
333
+ kodus telemetry enable
334
+ ```
335
+
336
+ ### Environment Variables
337
+
338
+ You can also control telemetry via environment variables:
339
+
340
+ ```bash
341
+ # Disable telemetry
342
+ export KODUS_TELEMETRY=false
343
+
344
+ # Or use standard DO_NOT_TRACK
345
+ export DO_NOT_TRACK=1
346
+ ```
347
+
348
+ ## Environment Variables
349
+
350
+ | Variable | Description | Security Notes |
351
+ |----------|-------------|----------------|
352
+ | `KODUS_API_URL` | API endpoint (default: https://api.kodus.io) | ⚠️ Only HTTPS URLs accepted (except localhost). Custom URLs validated for security. |
353
+ | `KODUS_VERBOSE` | Set to `true` to enable verbose logging | ⚠️ **DO NOT use in production/CI** - may expose sensitive data in logs |
354
+ | `KODUS_MOCK` | Set to `true` to use mock API | Development only |
355
+ | `KODUS_TOKEN` | CI/CD token for non-interactive environments | - |
356
+ | `KODUS_TELEMETRY` | Set to `false` to disable telemetry | - |
357
+ | `DO_NOT_TRACK` | Set to `1` to disable telemetry | Standard privacy flag |
358
+ | `POSTHOG_API_KEY` | Custom PostHog API key | Development only |
359
+ | `POSTHOG_HOST` | Custom PostHog host | Development only |
360
+
361
+ ### Verbose Mode
362
+
363
+ Enable detailed logging for debugging purposes:
364
+
365
+ ```bash
366
+ # Enable verbose logging
367
+ export KODUS_VERBOSE=true
368
+ kodus review
369
+ ```
370
+
371
+ **⚠️ Security Warning:** Verbose mode may log sensitive information including:
372
+ - API responses and errors
373
+ - Authentication token details
374
+ - Full request/response payloads
375
+
376
+ **Never use verbose mode in:**
377
+ - Production environments
378
+ - CI/CD pipelines
379
+ - Shared or public logs
380
+ - Automated workflows
381
+
382
+ Verbose mode is intended **only for local development and debugging**.
383
+
384
+ ## License
385
+
386
+ MIT
387
+
package/dist/cli.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ import { Command } from 'commander';
2
+ declare const program: Command;
3
+ export { program };
4
+ //# sourceMappingURL=cli.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAQpC,QAAA,MAAM,OAAO,SAAgB,CAAC;AAoB9B,OAAO,EAAE,OAAO,EAAE,CAAC"}
package/dist/cli.js ADDED
@@ -0,0 +1,26 @@
1
+ import { Command } from 'commander';
2
+ import { reviewCommand } from './commands/review.js';
3
+ import { authCommand } from './commands/auth/index.js';
4
+ import { configCommand } from './commands/config.js';
5
+ import { upgradeCommand } from './commands/upgrade.js';
6
+ import { telemetryCommand } from './commands/telemetry.js';
7
+ import { prCommand } from './commands/pr.js';
8
+ const program = new Command();
9
+ program
10
+ .name('kodus')
11
+ .description('Kodus CLI - AI-powered code review from your terminal')
12
+ .version('1.0.0')
13
+ .option('-f, --format <format>', 'Output format: terminal, json, markdown', 'terminal')
14
+ .option('-o, --output <file>', 'Output file (for json/markdown)')
15
+ .option('-v, --verbose', 'Verbose output', false)
16
+ .option('-q, --quiet', 'Quiet mode (errors only)', false)
17
+ .option('--org <org>', 'Organization name')
18
+ .option('--repo <repo>', 'Repository name');
19
+ program.addCommand(reviewCommand);
20
+ program.addCommand(authCommand);
21
+ program.addCommand(configCommand);
22
+ program.addCommand(upgradeCommand);
23
+ program.addCommand(telemetryCommand);
24
+ program.addCommand(prCommand);
25
+ export { program };
26
+ //# sourceMappingURL=cli.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAC;AACvD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,OAAO,GAAG,IAAI,OAAO,EAAE,CAAC;AAE9B,OAAO;KACJ,IAAI,CAAC,OAAO,CAAC;KACb,WAAW,CAAC,uDAAuD,CAAC;KACpE,OAAO,CAAC,OAAO,CAAC;KAChB,MAAM,CAAC,uBAAuB,EAAE,yCAAyC,EAAE,UAAU,CAAC;KACtF,MAAM,CAAC,qBAAqB,EAAE,iCAAiC,CAAC;KAChE,MAAM,CAAC,eAAe,EAAE,gBAAgB,EAAE,KAAK,CAAC;KAChD,MAAM,CAAC,aAAa,EAAE,0BAA0B,EAAE,KAAK,CAAC;KACxD,MAAM,CAAC,aAAa,EAAE,mBAAmB,CAAC;KAC1C,MAAM,CAAC,eAAe,EAAE,iBAAiB,CAAC,CAAC;AAE9C,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;AAChC,OAAO,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;AAClC,OAAO,CAAC,UAAU,CAAC,cAAc,CAAC,CAAC;AACnC,OAAO,CAAC,UAAU,CAAC,gBAAgB,CAAC,CAAC;AACrC,OAAO,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC;AAE9B,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -0,0 +1,3 @@
1
+ import { Command } from 'commander';
2
+ export declare const authCommand: Command;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAOpC,eAAO,MAAM,WAAW,SACiB,CAAC"}
@@ -0,0 +1,36 @@
1
+ import { Command } from 'commander';
2
+ import { loginAction } from './login.js';
3
+ import { logoutAction } from './logout.js';
4
+ import { statusAction } from './status.js';
5
+ import { tokenAction } from './token.js';
6
+ import { teamKeyAction, teamStatusAction } from './team-key.js';
7
+ export const authCommand = new Command('auth')
8
+ .description('Authentication commands');
9
+ authCommand
10
+ .command('login')
11
+ .description('Login with email and password')
12
+ .option('-e, --email <email>', 'Email address')
13
+ .option('-p, --password <password>', 'Password')
14
+ .action(loginAction);
15
+ authCommand
16
+ .command('logout')
17
+ .description('Remove local credentials')
18
+ .action(logoutAction);
19
+ authCommand
20
+ .command('status')
21
+ .description('Show authentication status and usage limits')
22
+ .action(statusAction);
23
+ authCommand
24
+ .command('token')
25
+ .description('Generate a token for CI/CD')
26
+ .action(tokenAction);
27
+ authCommand
28
+ .command('team-key')
29
+ .description('Authenticate using team API key')
30
+ .requiredOption('--key <key>', 'Team API key from Kodus dashboard')
31
+ .action(teamKeyAction);
32
+ authCommand
33
+ .command('team-status')
34
+ .description('Show team authentication status')
35
+ .action(teamStatusAction);
36
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/commands/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEhE,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,OAAO,CAAC,MAAM,CAAC;KAC3C,WAAW,CAAC,yBAAyB,CAAC,CAAC;AAE1C,WAAW;KACR,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,+BAA+B,CAAC;KAC5C,MAAM,CAAC,qBAAqB,EAAE,eAAe,CAAC;KAC9C,MAAM,CAAC,2BAA2B,EAAE,UAAU,CAAC;KAC/C,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,WAAW;KACR,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,0BAA0B,CAAC;KACvC,MAAM,CAAC,YAAY,CAAC,CAAC;AAExB,WAAW;KACR,OAAO,CAAC,QAAQ,CAAC;KACjB,WAAW,CAAC,6CAA6C,CAAC;KAC1D,MAAM,CAAC,YAAY,CAAC,CAAC;AAExB,WAAW;KACR,OAAO,CAAC,OAAO,CAAC;KAChB,WAAW,CAAC,4BAA4B,CAAC;KACzC,MAAM,CAAC,WAAW,CAAC,CAAC;AAEvB,WAAW;KACR,OAAO,CAAC,UAAU,CAAC;KACnB,WAAW,CAAC,iCAAiC,CAAC;KAC9C,cAAc,CAAC,aAAa,EAAE,mCAAmC,CAAC;KAClE,MAAM,CAAC,aAAa,CAAC,CAAC;AAEzB,WAAW;KACR,OAAO,CAAC,aAAa,CAAC;KACtB,WAAW,CAAC,iCAAiC,CAAC;KAC9C,MAAM,CAAC,gBAAgB,CAAC,CAAC"}
@@ -0,0 +1,7 @@
1
+ interface LoginOptions {
2
+ email?: string;
3
+ password?: string;
4
+ }
5
+ export declare function loginAction(options: LoginOptions): Promise<void>;
6
+ export {};
7
+ //# sourceMappingURL=login.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAMA,UAAU,YAAY;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAsB,WAAW,CAAC,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAyGtE"}
@@ -0,0 +1,97 @@
1
+ import inquirer from 'inquirer';
2
+ import chalk from 'chalk';
3
+ import ora from 'ora';
4
+ import { authService } from '../../services/auth.service.js';
5
+ import { telemetryService } from '../../services/telemetry.service.js';
6
+ export async function loginAction(options) {
7
+ const spinner = ora();
8
+ try {
9
+ const isAuthenticated = await authService.isAuthenticated();
10
+ if (isAuthenticated && !options.email) {
11
+ const credentials = await authService.getCredentials();
12
+ console.log(chalk.yellow(`\nAlready logged in as ${credentials?.user.email}`));
13
+ const { confirm } = await inquirer.prompt([
14
+ {
15
+ type: 'confirm',
16
+ name: 'confirm',
17
+ message: 'Do you want to login with a different account?',
18
+ default: false,
19
+ },
20
+ ]);
21
+ if (!confirm) {
22
+ return;
23
+ }
24
+ }
25
+ let email = options.email;
26
+ let password = options.password;
27
+ if (!email || !password) {
28
+ const answers = await inquirer.prompt([
29
+ ...(!email ? [{
30
+ type: 'input',
31
+ name: 'email',
32
+ message: 'Email:',
33
+ validate: (input) => {
34
+ if (!input || !input.includes('@')) {
35
+ return 'Please enter a valid email';
36
+ }
37
+ return true;
38
+ },
39
+ }] : []),
40
+ ...(!password ? [{
41
+ type: 'password',
42
+ name: 'password',
43
+ message: 'Password:',
44
+ mask: '*',
45
+ validate: (input) => {
46
+ if (!input || input.length < 6) {
47
+ return 'Password must be at least 6 characters';
48
+ }
49
+ return true;
50
+ },
51
+ }] : []),
52
+ ]);
53
+ email = email || answers.email;
54
+ password = password || answers.password;
55
+ }
56
+ spinner.start(chalk.blue('Logging in...'));
57
+ await authService.login(email, password);
58
+ spinner.succeed(chalk.green(`Logged in as ${email}`));
59
+ // Telemetry and debug info are best-effort and should not fail the login command
60
+ try {
61
+ // Get credentials for debug output and telemetry
62
+ const creds = await authService.getCredentials();
63
+ // Track successful login
64
+ telemetryService.track('auth_login_success');
65
+ // Identify user for telemetry
66
+ if (creds) {
67
+ await telemetryService.identify(creds.user.id, {
68
+ email: creds.user.email,
69
+ orgs: creds.user.orgs,
70
+ });
71
+ if (process.env.KODUS_VERBOSE) {
72
+ console.log(chalk.dim('\nDebug - Stored credentials:'));
73
+ console.log(chalk.dim(JSON.stringify(creds, null, 2)));
74
+ }
75
+ }
76
+ }
77
+ catch (postLoginError) {
78
+ // Silently ignore telemetry or credential errors to not disrupt the user flow
79
+ if (process.env.KODUS_VERBOSE) {
80
+ console.log(chalk.dim('\nDebug - Post-login operations failed:'));
81
+ console.log(chalk.dim(postLoginError instanceof Error ? postLoginError.message : String(postLoginError)));
82
+ }
83
+ }
84
+ }
85
+ catch (error) {
86
+ spinner.fail(chalk.red('Login failed'));
87
+ // Track failed login
88
+ telemetryService.track('auth_login_failed', {
89
+ error: error instanceof Error ? error.message : 'Unknown error',
90
+ });
91
+ if (error instanceof Error) {
92
+ console.error(chalk.red(error.message));
93
+ }
94
+ process.exit(1);
95
+ }
96
+ }
97
+ //# sourceMappingURL=login.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"login.js","sourceRoot":"","sources":["../../../src/commands/auth/login.ts"],"names":[],"mappings":"AAAA,OAAO,QAAQ,MAAM,UAAU,CAAC;AAChC,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,qCAAqC,CAAC;AAOvE,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,OAAqB;IACrD,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC;IAEtB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,MAAM,WAAW,CAAC,eAAe,EAAE,CAAC;QAE5D,IAAI,eAAe,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC;YACtC,MAAM,WAAW,GAAG,MAAM,WAAW,CAAC,cAAc,EAAE,CAAC;YACvD,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,0BAA0B,WAAW,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC;YAE/E,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,QAAQ,CAAC,MAAM,CAAC;gBACxC;oBACE,IAAI,EAAE,SAAS;oBACf,IAAI,EAAE,SAAS;oBACf,OAAO,EAAE,gDAAgD;oBACzD,OAAO,EAAE,KAAK;iBACf;aACF,CAAC,CAAC;YAEH,IAAI,CAAC,OAAO,EAAE,CAAC;gBACb,OAAO;YACT,CAAC;QACH,CAAC;QAED,IAAI,KAAK,GAAG,OAAO,CAAC,KAAK,C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AC;QACf,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC;QAExC,qBAAqB;QACrB,gBAAgB,CAAC,KAAK,CAAC,mBAAmB,EAAE;YAC1C,KAAK,EAAE,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe;SAChE,CAAC,CAAC;QAEH,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function logoutAction(): Promise<void>;
2
+ //# sourceMappingURL=logout.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAIA,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CAwBlD"}
@@ -0,0 +1,24 @@
1
+ import chalk from 'chalk';
2
+ import ora from 'ora';
3
+ import { authService } from '../../services/auth.service.js';
4
+ export async function logoutAction() {
5
+ const spinner = ora();
6
+ try {
7
+ const isAuthenticated = await authService.isAuthenticated();
8
+ if (!isAuthenticated) {
9
+ console.log(chalk.yellow('\nNot logged in.'));
10
+ return;
11
+ }
12
+ spinner.start(chalk.blue('Logging out...'));
13
+ await authService.logout();
14
+ spinner.succeed(chalk.green('Logged out successfully'));
15
+ }
16
+ catch (error) {
17
+ spinner.fail(chalk.red('Logout failed'));
18
+ if (error instanceof Error) {
19
+ console.error(chalk.red(error.message));
20
+ }
21
+ process.exit(1);
22
+ }
23
+ }
24
+ //# sourceMappingURL=logout.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logout.js","sourceRoot":"","sources":["../../../src/commands/auth/logout.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAE7D,MAAM,CAAC,KAAK,UAAU,YAAY;IAChC,MAAM,OAAO,GAAG,GAAG,EAAE,CAAC;IAEtB,IAAI,CAAC;QACH,MAAM,eAAe,GAAG,MAAM,WAAW,CAAC,eAAe,EAAE,CAAC;QAE5D,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;YAC9C,OAAO;QACT,CAAC;QAED,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC,CAAC;QAE5C,MAAM,WAAW,CAAC,MAAM,EAAE,CAAC;QAE3B,OAAO,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;IAE1D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,CAAC;QACzC,IAAI,KAAK,YAAY,KAAK,EAAE,CAAC;YAC3B,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC;QAC1C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function signupAction(): Promise<void>;
2
+ //# sourceMappingURL=signup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"signup.d.ts","sourceRoot":"","sources":["../../../src/commands/auth/signup.ts"],"names":[],"mappings":"AAMA,wBAAsB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC,CA0ElD"}