korekt-cli 0.13.1 → 0.13.4

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
@@ -4,17 +4,7 @@
4
4
  [![npm downloads](https://img.shields.io/npm/dm/korekt-cli.svg)](https://www.npmjs.com/package/korekt-cli)
5
5
  [![license](https://img.shields.io/npm/l/korekt-cli.svg)](https://www.npmjs.com/package/korekt-cli)
6
6
 
7
- AI-powered code review CLI - Keep your kode korekt
8
-
9
- `kk` integrates seamlessly with your local Git workflow to provide intelligent code reviews powered by AI.
10
-
11
- ## Features
12
-
13
- * **AI-Powered Analysis**: Get instant, intelligent code reviews with severity levels, categories, and actionable suggestions
14
- * **Local Git Integration**: Works with committed changes, staged changes, and unstaged modifications
15
- * **Ticket Context Enrichment**: Server-side ticket extraction from branch names and commit messages (Jira & Azure DevOps)
16
- * **Beautiful Output**: Color-coded issues with severity indicators, file locations, and suggested fixes
17
- * **Ultra-Fast**: Short command syntax (`kk`) for maximum developer efficiency
7
+ AI-powered code review from your terminal.
18
8
 
19
9
  ## Installation
20
10
 
@@ -22,112 +12,81 @@ AI-powered code review CLI - Keep your kode korekt
22
12
  npm install -g korekt-cli
23
13
  ```
24
14
 
25
- ## Quick Start
26
-
27
- Configure the CLI with your API credentials:
15
+ ## Setup
28
16
 
29
17
  ```bash
30
18
  kk config --key YOUR_API_KEY
31
- kk config --endpoint https://api.korekt.ai/api/review
32
19
  ```
33
20
 
34
- Run your first review:
35
-
36
- ```bash
37
- # Review committed changes against a target branch
38
- kk review main
39
-
40
- # Review only staged changes
41
- kk stg
42
-
43
- # Review only unstaged changes
44
- kk diff
21
+ ## Local Workflow
45
22
 
23
+ ### Review Your Changes
46
24
 
25
+ ```bash
26
+ kk review main # Review commits against main
27
+ kk stg # Review staged changes
28
+ kk diff # Review unstaged changes
47
29
  ```
48
30
 
49
- ## Usage
50
-
51
- ### Configuration
31
+ ### Choose AI Model
52
32
 
53
33
  ```bash
54
- # Set API key
55
- kk config --key YOUR_API_KEY
56
-
57
- # Set API endpoint
58
- kk config --endpoint https://api.korekt.ai/api/review
59
-
60
- # Show current configuration
61
- kk config --show
34
+ kk review -m # Interactive model picker
35
+ kk review -m gemini-3-flash-preview # Direct selection
62
36
  ```
63
37
 
64
- ### Review Commands
38
+ Available models (ranked by recommendation):
65
39
 
66
- ```bash
67
- # Review committed changes (auto-detect base branch)
68
- kk review
40
+ 1. **gemini-3-flash-preview** - Most efficient, recommended for daily use
41
+ 2. **gemini-3-pro-preview** - Best quality for complex reviews
42
+ 3. **gemini-2.5-pro** - High quality alternative
43
+ 4. **gemini-2.5-flash** - Legacy, avoid
69
44
 
70
- # Review against specific branch
71
- kk review main
45
+ ### Ignore Files
72
46
 
73
- # Review with ignored files
47
+ ```bash
74
48
  kk review main --ignore "*.lock" "dist/*"
49
+ ```
75
50
 
76
- # Dry run (preview payload without sending)
77
- kk review main --dry-run
51
+ ## CI/CD Integration
78
52
 
79
- # Output JSON for CI/CD integration
80
- kk review main --json
53
+ ### Post to Pull Request
81
54
 
82
- # Review staged changes only
83
- kk stg
84
- # Aliases: kk staged, kk cached
55
+ ```bash
56
+ kk review --comment # Auto-posts findings to PR
57
+ ```
85
58
 
86
- # Review unstaged changes only
87
- kk diff
59
+ Works with GitHub Actions, Azure Pipelines, and Bitbucket Pipelines.
88
60
 
89
- # JSON output works with all review commands
90
- kk stg --json
91
- kk diff --json
61
+ ### Post to Ticket
62
+
63
+ ```bash
64
+ kk review --post-ticket # Posts findings to linked Jira/Azure ticket
92
65
  ```
93
66
 
94
- ### Alternative Command
67
+ Ticket IDs are automatically extracted from branch names and commit messages.
95
68
 
96
- Both `kk` and `korekt` commands are available:
69
+ ### JSON Output
97
70
 
98
71
  ```bash
99
- korekt review main # Same as: kk review main
72
+ kk review main --json # Machine-readable output
100
73
  ```
101
74
 
102
75
  ## Environment Variables
103
76
 
104
- You can also configure using environment variables:
105
-
106
77
  ```bash
107
78
  export KOREKT_API_KEY="your-api-key"
108
- export KOREKT_API_ENDPOINT="https://api.korekt.ai/api/review"
109
79
  ```
110
80
 
111
- Note: Config file takes precedence over environment variables.
81
+ Alternative to `kk config --key`. Config file takes precedence.
112
82
 
113
83
  ## Help
114
84
 
115
- For more options and detailed help:
116
-
117
85
  ```bash
118
86
  kk --help
119
87
  kk review --help
120
88
  ```
121
89
 
122
- ## Development
123
-
124
- To run tests:
125
- ```bash
126
- npm test
127
- ```
128
-
129
90
  ## License
130
91
 
131
- MIT © [Vladan Djokic](https://korekt.ai)
132
-
133
- See [LICENSE](./LICENSE) for details.
92
+ MIT - See [LICENSE](./LICENSE) for details.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korekt-cli",
3
- "version": "0.13.1",
3
+ "version": "0.13.4",
4
4
  "description": "AI-powered code review CLI - Keep your kode korekt",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/src/git-logic.js CHANGED
@@ -18,7 +18,9 @@ export function truncateContent(content, maxLines = 2000) {
18
18
  const halfMax = Math.floor(maxLines / 2);
19
19
  const head = lines.slice(0, halfMax).join('\n');
20
20
  const tail = lines.slice(-halfMax).join('\n');
21
- return `${head}\n\n... [truncated] ...\n\n${tail}`;
21
+ const linesKept = 2 * halfMax;
22
+ const omittedLines = lines.length - linesKept;
23
+ return `${head}\n\n... [${omittedLines} lines truncated] ...\n\n${tail}`;
22
24
  }
23
25
 
24
26
  /**
@@ -450,7 +450,7 @@ describe('truncateContent', () => {
450
450
  // Should contain head and tail
451
451
  expect(result).toContain('line 0');
452
452
  expect(result).toContain('line 999'); // Last line of head (first 1000 lines)
453
- expect(result).toContain('... [truncated] ...');
453
+ expect(result).toContain('... [1000 lines truncated] ...');
454
454
  expect(result).toContain('line 2000'); // First line of tail (last 1000 lines)
455
455
  expect(result).toContain('line 2999');
456
456
 
@@ -464,7 +464,7 @@ describe('truncateContent', () => {
464
464
 
465
465
  expect(result).toContain('line 0');
466
466
  expect(result).toContain('line 49'); // Last of first 50
467
- expect(result).toContain('... [truncated] ...');
467
+ expect(result).toContain('... [100 lines truncated] ...');
468
468
  expect(result).toContain('line 150'); // First of last 50
469
469
  expect(result).toContain('line 199');
470
470
  });
package/src/index.js CHANGED
@@ -19,6 +19,9 @@ import { detectCIProvider, truncateFileData, formatErrorOutput } from './utils.j
19
19
  // Re-export utilities for backward compatibility
20
20
  export { detectCIProvider, truncateFileData, formatErrorOutput, getPrUrl } from './utils.js';
21
21
 
22
+ // Export for testing
23
+ export { GEMINI_MODELS, resolveModel };
24
+
22
25
  const require = createRequire(import.meta.url);
23
26
  const { version } = require('../package.json');
24
27
 
@@ -103,6 +106,19 @@ const GEMINI_MODELS = [
103
106
  },
104
107
  ];
105
108
 
109
+ /**
110
+ * Resolve model input - supports numeric shortcuts (1-4) or full model names
111
+ * @param {string} input - Model input (number or name)
112
+ * @returns {string} - Resolved model name
113
+ */
114
+ function resolveModel(input) {
115
+ const num = parseInt(input, 10);
116
+ if (!isNaN(num) && num >= 1 && num <= GEMINI_MODELS.length) {
117
+ return GEMINI_MODELS[num - 1].value;
118
+ }
119
+ return input;
120
+ }
121
+
106
122
  /**
107
123
  * Prompt user to select a Gemini model
108
124
  * @returns {Promise<string>} - Selected model name
@@ -258,7 +274,8 @@ program
258
274
  selectedModel = await selectModel();
259
275
  log(chalk.green(`Using model: ${selectedModel}\n`));
260
276
  } else if (typeof options.model === 'string') {
261
- selectedModel = options.model;
277
+ selectedModel = resolveModel(options.model);
278
+ log(chalk.green(`Using model: ${selectedModel}\n`));
262
279
  }
263
280
 
264
281
  // Fetch file rules config from API
@@ -465,7 +482,8 @@ async function reviewUncommitted(mode, options) {
465
482
  selectedModel = await selectModel();
466
483
  log(chalk.green(`Using model: ${selectedModel}\n`));
467
484
  } else if (typeof options.model === 'string') {
468
- selectedModel = options.model;
485
+ selectedModel = resolveModel(options.model);
486
+ log(chalk.green(`Using model: ${selectedModel}\n`));
469
487
  }
470
488
 
471
489
  // Fetch file rules config from API
package/src/index.test.js CHANGED
@@ -5,6 +5,7 @@ import {
5
5
  detectCIProvider,
6
6
  getPrUrl,
7
7
  handleSkippedResponse,
8
+ resolveModel,
8
9
  } from './index.js';
9
10
 
10
11
  describe('CLI JSON output mode', () => {
@@ -553,6 +554,34 @@ describe('--model flag behavior', () => {
553
554
  });
554
555
  });
555
556
  });
557
+
558
+ describe('numeric model shortcuts', () => {
559
+ it('should resolve "1" to gemini-2.5-pro', () => {
560
+ expect(resolveModel('1')).toBe('gemini-2.5-pro');
561
+ });
562
+
563
+ it('should resolve "2" to gemini-2.5-flash', () => {
564
+ expect(resolveModel('2')).toBe('gemini-2.5-flash');
565
+ });
566
+
567
+ it('should resolve "3" to gemini-3-pro-preview', () => {
568
+ expect(resolveModel('3')).toBe('gemini-3-pro-preview');
569
+ });
570
+
571
+ it('should resolve "4" to gemini-3-flash-preview', () => {
572
+ expect(resolveModel('4')).toBe('gemini-3-flash-preview');
573
+ });
574
+
575
+ it('should pass through full model names unchanged', () => {
576
+ expect(resolveModel('gemini-3-pro-preview')).toBe('gemini-3-pro-preview');
577
+ });
578
+
579
+ it('should pass through invalid input unchanged', () => {
580
+ expect(resolveModel('invalid')).toBe('invalid');
581
+ expect(resolveModel('0')).toBe('0');
582
+ expect(resolveModel('5')).toBe('5');
583
+ });
584
+ });
556
585
  });
557
586
 
558
587
  describe('skipped response handling', () => {