korekt-cli 0.5.0-beta.2 → 0.5.0-beta.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "korekt-cli",
3
- "version": "0.5.0-beta.2",
3
+ "version": "0.5.0-beta.4",
4
4
  "description": "AI-powered code review CLI - Keep your kode korekt",
5
5
  "main": "src/index.js",
6
6
  "bin": {
package/scripts/azure.sh CHANGED
@@ -244,16 +244,16 @@ post_review_thread() {
244
244
  }
245
245
 
246
246
  # Parse results
247
- TOTAL_ISSUES=$(jq -r '.summary.total_issues // 0' "$RESULTS_FILE")
248
- TOTAL_PRAISES=$(jq -r '.summary.total_praises // 0' "$RESULTS_FILE")
249
- CRITICAL_ISSUES=$(jq -r '.summary.critical // 0' "$RESULTS_FILE")
247
+ TOTAL_ISSUES=$(jq -r '.data.summary.total_issues // 0' "$RESULTS_FILE")
248
+ TOTAL_PRAISES=$(jq -r '.data.summary.total_praises // 0' "$RESULTS_FILE")
249
+ CRITICAL_ISSUES=$(jq -r '.data.summary.critical // 0' "$RESULTS_FILE")
250
250
 
251
251
  # Post inline comments for issues (excluding low severity)
252
252
  if [ "$TOTAL_ISSUES" -gt 0 ] && [ "$POST_INLINE_COMMENTS" = "true" ]; then
253
253
  populate_existing_comments_map
254
254
 
255
255
  echo "Posting inline comments for non-low severity issues..."
256
- jq -r '.review.issues[] | select(.severity != "low") | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
256
+ jq -r '.data.review.issues[] | select(.severity != "low") | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
257
257
  file_path=$(echo "$issue_json" | jq -r '.file_path')
258
258
  line_number=$(echo "$issue_json" | jq -r '.line_number')
259
259
  message=$(echo "$issue_json" | jq -r '.message')
@@ -337,7 +337,7 @@ else
337
337
  if [ "$TOTAL_PRAISES" -gt 0 ]; then
338
338
  echo "### ✨ Praises ($TOTAL_PRAISES)" >> "$COMMENT_FILE"
339
339
  echo "" >> "$COMMENT_FILE"
340
- jq -r '.review.praises[] | @json' "$RESULTS_FILE" | while IFS= read -r praise_json; do
340
+ jq -r '.data.review.praises[] | @json' "$RESULTS_FILE" | while IFS= read -r praise_json; do
341
341
  file_path=$(echo "$praise_json" | jq -r '.file_path')
342
342
  line_number=$(echo "$praise_json" | jq -r '.line_number')
343
343
  message=$(echo "$praise_json" | jq -r '.message')
@@ -355,9 +355,9 @@ else
355
355
 
356
356
  # Issues section
357
357
  if [ "$TOTAL_ISSUES" -gt 0 ]; then
358
- HIGH_ISSUES=$(jq -r '.summary.high // 0' "$RESULTS_FILE")
359
- MEDIUM_ISSUES=$(jq -r '.summary.medium // 0' "$RESULTS_FILE")
360
- LOW_ISSUES=$(jq -r '.summary.low // 0' "$RESULTS_FILE")
358
+ HIGH_ISSUES=$(jq -r '.data.summary.high // 0' "$RESULTS_FILE")
359
+ MEDIUM_ISSUES=$(jq -r '.data.summary.medium // 0' "$RESULTS_FILE")
360
+ LOW_ISSUES=$(jq -r '.data.summary.low // 0' "$RESULTS_FILE")
361
361
 
362
362
  echo "### ⚠️ Issues Found ($TOTAL_ISSUES)" >> "$COMMENT_FILE"
363
363
  echo "" >> "$COMMENT_FILE"
@@ -369,7 +369,7 @@ else
369
369
  [ "$LOW_ISSUES" -gt 0 ] && echo "| 🟡 Low | $LOW_ISSUES |" >> "$COMMENT_FILE"
370
370
  echo "" >> "$COMMENT_FILE"
371
371
 
372
- jq -r '.review.issues[] | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
372
+ jq -r '.data.review.issues[] | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
373
373
  file_path=$(echo "$issue_json" | jq -r '.file_path')
374
374
  line_number=$(echo "$issue_json" | jq -r '.line_number')
375
375
  message=$(echo "$issue_json" | jq -r '.message')
@@ -202,16 +202,16 @@ post_inline_comment() {
202
202
  }
203
203
 
204
204
  # Parse results
205
- TOTAL_ISSUES=$(jq -r '.summary.total_issues // 0' "$RESULTS_FILE")
206
- TOTAL_PRAISES=$(jq -r '.summary.total_praises // 0' "$RESULTS_FILE")
207
- CRITICAL_ISSUES=$(jq -r '.summary.critical // 0' "$RESULTS_FILE")
205
+ TOTAL_ISSUES=$(jq -r '.data.summary.total_issues // 0' "$RESULTS_FILE")
206
+ TOTAL_PRAISES=$(jq -r '.data.summary.total_praises // 0' "$RESULTS_FILE")
207
+ CRITICAL_ISSUES=$(jq -r '.data.summary.critical // 0' "$RESULTS_FILE")
208
208
 
209
209
  # Post inline comments for issues (excluding low severity)
210
210
  if [ "$TOTAL_ISSUES" -gt 0 ] && [ "$POST_INLINE_COMMENTS" = "true" ]; then
211
211
  populate_existing_comments_map
212
212
 
213
213
  echo "Posting inline comments for non-low severity issues..."
214
- jq -r '.review.issues[] | select(.severity != "low") | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
214
+ jq -r '.data.review.issues[] | select(.severity != "low") | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
215
215
  file_path=$(echo "$issue_json" | jq -r '.file_path')
216
216
  line_number=$(echo "$issue_json" | jq -r '.line_number')
217
217
  message=$(echo "$issue_json" | jq -r '.message')
@@ -292,7 +292,7 @@ else
292
292
  if [ "$TOTAL_PRAISES" -gt 0 ]; then
293
293
  echo "### ✨ Praises ($TOTAL_PRAISES)" >> "$COMMENT_FILE"
294
294
  echo "" >> "$COMMENT_FILE"
295
- jq -r '.review.praises[] | @json' "$RESULTS_FILE" | while IFS= read -r praise_json; do
295
+ jq -r '.data.review.praises[] | @json' "$RESULTS_FILE" | while IFS= read -r praise_json; do
296
296
  file_path=$(echo "$praise_json" | jq -r '.file_path')
297
297
  line_number=$(echo "$praise_json" | jq -r '.line_number')
298
298
  message=$(echo "$praise_json" | jq -r '.message')
@@ -310,9 +310,9 @@ else
310
310
 
311
311
  # Issues section
312
312
  if [ "$TOTAL_ISSUES" -gt 0 ]; then
313
- HIGH_ISSUES=$(jq -r '.summary.high // 0' "$RESULTS_FILE")
314
- MEDIUM_ISSUES=$(jq -r '.summary.medium // 0' "$RESULTS_FILE")
315
- LOW_ISSUES=$(jq -r '.summary.low // 0' "$RESULTS_FILE")
313
+ HIGH_ISSUES=$(jq -r '.data.summary.high // 0' "$RESULTS_FILE")
314
+ MEDIUM_ISSUES=$(jq -r '.data.summary.medium // 0' "$RESULTS_FILE")
315
+ LOW_ISSUES=$(jq -r '.data.summary.low // 0' "$RESULTS_FILE")
316
316
 
317
317
  echo "### ⚠️ Issues Found ($TOTAL_ISSUES)" >> "$COMMENT_FILE"
318
318
  echo "" >> "$COMMENT_FILE"
@@ -324,7 +324,7 @@ else
324
324
  [ "$LOW_ISSUES" -gt 0 ] && echo "| 🟡 Low | $LOW_ISSUES |" >> "$COMMENT_FILE"
325
325
  echo "" >> "$COMMENT_FILE"
326
326
 
327
- jq -r '.review.issues[] | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
327
+ jq -r '.data.review.issues[] | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
328
328
  file_path=$(echo "$issue_json" | jq -r '.file_path')
329
329
  line_number=$(echo "$issue_json" | jq -r '.line_number')
330
330
  message=$(echo "$issue_json" | jq -r '.message')
package/scripts/github.sh CHANGED
@@ -201,16 +201,16 @@ post_review_comment() {
201
201
  }
202
202
 
203
203
  # Parse results
204
- TOTAL_ISSUES=$(jq -r '.summary.total_issues // 0' "$RESULTS_FILE")
205
- TOTAL_PRAISES=$(jq -r '.summary.total_praises // 0' "$RESULTS_FILE")
206
- CRITICAL_ISSUES=$(jq -r '.summary.critical // 0' "$RESULTS_FILE")
204
+ TOTAL_ISSUES=$(jq -r '.data.summary.total_issues // 0' "$RESULTS_FILE")
205
+ TOTAL_PRAISES=$(jq -r '.data.summary.total_praises // 0' "$RESULTS_FILE")
206
+ CRITICAL_ISSUES=$(jq -r '.data.summary.critical // 0' "$RESULTS_FILE")
207
207
 
208
208
  # Post inline comments for issues
209
209
  if [ "$TOTAL_ISSUES" -gt 0 ]; then
210
210
  populate_existing_comments_map
211
211
 
212
212
  echo "Posting inline comments for non-low severity issues..."
213
- jq -r '.review.issues[] | select(.severity != "low") | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
213
+ jq -r '.data.review.issues[] | select(.severity != "low") | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
214
214
  file_path=$(echo "$issue_json" | jq -r '.file_path')
215
215
  line_number=$(echo "$issue_json" | jq -r '.line_number')
216
216
  message=$(echo "$issue_json" | jq -r '.message')
@@ -291,7 +291,7 @@ else
291
291
  if [ "$TOTAL_PRAISES" -gt 0 ]; then
292
292
  echo "### ✨ Praises ($TOTAL_PRAISES)" >> "$COMMENT_FILE"
293
293
  echo "" >> "$COMMENT_FILE"
294
- jq -r '.review.praises[] | @json' "$RESULTS_FILE" | while IFS= read -r praise_json; do
294
+ jq -r '.data.review.praises[] | @json' "$RESULTS_FILE" | while IFS= read -r praise_json; do
295
295
  file_path=$(echo "$praise_json" | jq -r '.file_path')
296
296
  line_number=$(echo "$praise_json" | jq -r '.line_number')
297
297
  message=$(echo "$praise_json" | jq -r '.message')
@@ -308,9 +308,9 @@ else
308
308
 
309
309
  # Issues section
310
310
  if [ "$TOTAL_ISSUES" -gt 0 ]; then
311
- HIGH_ISSUES=$(jq -r '.summary.high // 0' "$RESULTS_FILE")
312
- MEDIUM_ISSUES=$(jq -r '.summary.medium // 0' "$RESULTS_FILE")
313
- LOW_ISSUES=$(jq -r '.summary.low // 0' "$RESULTS_FILE")
311
+ HIGH_ISSUES=$(jq -r '.data.summary.high // 0' "$RESULTS_FILE")
312
+ MEDIUM_ISSUES=$(jq -r '.data.summary.medium // 0' "$RESULTS_FILE")
313
+ LOW_ISSUES=$(jq -r '.data.summary.low // 0' "$RESULTS_FILE")
314
314
 
315
315
  echo "### ⚠️ Issues Found ($TOTAL_ISSUES)" >> "$COMMENT_FILE"
316
316
  echo "" >> "$COMMENT_FILE"
@@ -322,7 +322,7 @@ else
322
322
  [ "$LOW_ISSUES" -gt 0 ] && echo "| 🟡 Low | $LOW_ISSUES |" >> "$COMMENT_FILE"
323
323
  echo "" >> "$COMMENT_FILE"
324
324
 
325
- jq -r '.review.issues[] | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
325
+ jq -r '.data.review.issues[] | @json' "$RESULTS_FILE" | while IFS= read -r issue_json; do
326
326
  file_path=$(echo "$issue_json" | jq -r '.file_path')
327
327
  line_number=$(echo "$issue_json" | jq -r '.line_number')
328
328
  message=$(echo "$issue_json" | jq -r '.message')
package/src/git-logic.js CHANGED
@@ -305,30 +305,52 @@ export async function runLocalReview(
305
305
  // If a branch is provided, check it exists and try to fetch latest remote version
306
306
  let targetBranchRef = targetBranch; // Will be updated to origin/branch if remote exists
307
307
  if (targetBranch) {
308
- // Check if the branch exists locally
309
- try {
310
- await execa('git', ['rev-parse', '--verify', targetBranch]);
311
- } catch {
312
- console.error(chalk.red(`Branch '${targetBranch}' does not exist locally.`));
313
- console.error(chalk.gray(`Please check out the branch first or specify a different one.`));
314
- return null;
315
- }
308
+ // Check if user already specified a remote-tracking branch (e.g., origin/master)
309
+ const isRemoteRef = targetBranch.startsWith('origin/');
316
310
 
317
- // Try to fetch the latest changes from remote (non-destructive)
318
- try {
319
- console.error(chalk.gray(`Fetching latest changes for branch '${targetBranch}'...`));
320
- await execa('git', ['fetch', 'origin', targetBranch]);
311
+ if (isRemoteRef) {
312
+ // User specified origin/branch - verify it exists and use it directly
313
+ try {
314
+ await execa('git', ['rev-parse', '--verify', targetBranch]);
315
+ console.error(
316
+ chalk.gray(`Using remote-tracking branch '${targetBranch}' for comparison.`)
317
+ );
318
+ targetBranchRef = targetBranch;
319
+ } catch {
320
+ console.error(chalk.red(`Remote-tracking branch '${targetBranch}' does not exist.`));
321
+ console.error(chalk.gray(`Try fetching it first with: git fetch origin`));
322
+ return null;
323
+ }
324
+ } else {
325
+ // Local branch name specified - check if it exists locally
326
+ try {
327
+ await execa('git', ['rev-parse', '--verify', targetBranch]);
328
+ } catch {
329
+ console.error(chalk.red(`Branch '${targetBranch}' does not exist locally.`));
330
+ console.error(
331
+ chalk.gray(`Please check out the branch first or specify a different one.`)
332
+ );
333
+ return null;
334
+ }
321
335
 
322
- // If fetch succeeded, use the remote-tracking branch for comparison
323
- // This is safer as it doesn't modify the user's local branch
324
- targetBranchRef = `origin/${targetBranch}`;
325
- console.error(
326
- chalk.gray(`Using remote-tracking branch 'origin/${targetBranch}' for comparison.`)
327
- );
328
- } catch {
329
- console.warn(chalk.yellow(`Could not fetch remote branch 'origin/${targetBranch}'.`));
330
- console.warn(chalk.gray(`Proceeding with local branch '${targetBranch}' for comparison.`));
331
- // targetBranchRef stays as targetBranch (local branch)
336
+ // Try to fetch the latest changes from remote (non-destructive)
337
+ try {
338
+ console.error(chalk.gray(`Fetching latest changes for branch '${targetBranch}'...`));
339
+ await execa('git', ['fetch', 'origin', targetBranch]);
340
+
341
+ // If fetch succeeded, use the remote-tracking branch for comparison
342
+ // This is safer as it doesn't modify the user's local branch
343
+ targetBranchRef = `origin/${targetBranch}`;
344
+ console.error(
345
+ chalk.gray(`Using remote-tracking branch 'origin/${targetBranch}' for comparison.`)
346
+ );
347
+ } catch {
348
+ console.warn(chalk.yellow(`Could not fetch remote branch 'origin/${targetBranch}'.`));
349
+ console.warn(
350
+ chalk.gray(`Proceeding with local branch '${targetBranch}' for comparison.`)
351
+ );
352
+ // targetBranchRef stays as targetBranch (local branch)
353
+ }
332
354
  }
333
355
  }
334
356