gut-cli 0.1.30 → 0.1.32

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/dist/index.js CHANGED
@@ -533,7 +533,7 @@ async function generateCommitMessage(diff, options, template) {
533
533
  const result = await generateText({
534
534
  model,
535
535
  prompt,
536
- maxTokens: 500
536
+ maxTokens: 1024
537
537
  });
538
538
  return result.text.trim();
539
539
  }
@@ -769,7 +769,7 @@ async function generateBranchName(description, options, context, template) {
769
769
  const result = await generateText({
770
770
  model,
771
771
  prompt,
772
- maxTokens: 100
772
+ maxTokens: 1024
773
773
  });
774
774
  return result.text.trim().replace(/[^a-zA-Z0-9/_-]/g, "");
775
775
  }
@@ -787,7 +787,7 @@ async function generateBranchNameFromDiff(diff, options, template) {
787
787
  const result = await generateText({
788
788
  model,
789
789
  prompt,
790
- maxTokens: 100
790
+ maxTokens: 1024
791
791
  });
792
792
  return result.text.trim().replace(/[^a-zA-Z0-9/_-]/g, "");
793
793
  }
@@ -805,7 +805,7 @@ async function generateStashName(diff, options, template) {
805
805
  const result = await generateText({
806
806
  model,
807
807
  prompt,
808
- maxTokens: 100
808
+ maxTokens: 1024
809
809
  });
810
810
  return result.text.trim();
811
811
  }
@@ -955,6 +955,21 @@ function getExistingPrUrl() {
955
955
  return null;
956
956
  }
957
957
  }
958
+ function hasUpstreamBranch() {
959
+ try {
960
+ execSync2("git rev-parse --abbrev-ref @{upstream}", {
961
+ stdio: ["pipe", "pipe", "pipe"]
962
+ });
963
+ return true;
964
+ } catch {
965
+ return false;
966
+ }
967
+ }
968
+ function pushBranchToOrigin(branch) {
969
+ execSync2(`git push -u origin ${branch}`, {
970
+ stdio: ["pipe", "pipe", "pipe"]
971
+ });
972
+ }
958
973
 
959
974
  // src/commands/branch.ts
960
975
  function getIssueInfo(issueNumber) {
@@ -1014,7 +1029,7 @@ ${issueInfo.body || ""}`;
1014
1029
  try {
1015
1030
  const branchName = await generateBranchName(
1016
1031
  description,
1017
- { provider, model: options.model },
1032
+ { provider, model: options.model, language: getLanguage() },
1018
1033
  { type: options.type, issue: issueNumber },
1019
1034
  template || void 0
1020
1035
  );
@@ -1111,7 +1126,7 @@ var changelogCommand = new Command3("changelog").description("Generate a changel
1111
1126
  }
1112
1127
  const changelog = await generateChangelog(
1113
1128
  { commits, diff, fromRef, toRef },
1114
- { provider, model: options.model },
1129
+ { provider, model: options.model, language: getLanguage() },
1115
1130
  template || void 0
1116
1131
  );
1117
1132
  spinner.stop();
@@ -1179,7 +1194,7 @@ ${untrackedFiles.map((f) => `+ ${f}`).join("\n")}`;
1179
1194
  try {
1180
1195
  const branchName = await generateBranchNameFromDiff(
1181
1196
  diff,
1182
- { provider, model: options.model },
1197
+ { provider, model: options.model, language: getLanguage() },
1183
1198
  template
1184
1199
  );
1185
1200
  spinner.stop();
@@ -1334,7 +1349,7 @@ var commitCommand = new Command6("commit").description("Generate a commit messag
1334
1349
  try {
1335
1350
  const message = await generateCommitMessage(
1336
1351
  diff,
1337
- { provider, model: options.model },
1352
+ { provider, model: options.model, language: getLanguage() },
1338
1353
  template || void 0
1339
1354
  );
1340
1355
  spinner.stop();
@@ -1580,7 +1595,7 @@ var explainCommand = new Command8("explain").description("Get an AI-powered expl
1580
1595
  spinner.text = "AI is generating explanation...";
1581
1596
  const explanation = await generateExplanation(
1582
1597
  context,
1583
- { provider, model: options.model },
1598
+ { provider, model: options.model, language: getLanguage() },
1584
1599
  template || void 0
1585
1600
  );
1586
1601
  spinner.stop();
@@ -1821,7 +1836,7 @@ var findCommand = new Command9("find").description("Find commits matching a vagu
1821
1836
  const results = await searchCommits(
1822
1837
  query,
1823
1838
  commits,
1824
- { provider, model: options.model },
1839
+ { provider, model: options.model, language: getLanguage() },
1825
1840
  parseInt(options.maxResults, 10),
1826
1841
  template || void 0
1827
1842
  );
@@ -2005,7 +2020,7 @@ ${content}
2005
2020
  configFiles: configFilesStr,
2006
2021
  existingGitignore
2007
2022
  },
2008
- { provider, model: options.model },
2023
+ { provider, model: options.model, language: getLanguage() },
2009
2024
  template || void 0
2010
2025
  );
2011
2026
  spinner.stop();
@@ -2327,7 +2342,7 @@ Merging ${chalk14.cyan(branch)} into ${chalk14.cyan(currentBranch)}...
2327
2342
  oursRef: currentBranch,
2328
2343
  theirsRef: branch
2329
2344
  },
2330
- { provider, model: options.model },
2345
+ { provider, model: options.model, language: getLanguage() },
2331
2346
  template || void 0
2332
2347
  );
2333
2348
  spinner.stop();
@@ -2452,7 +2467,7 @@ var prCommand = new Command14("pr").description("Generate a pull request title a
2452
2467
  commits,
2453
2468
  diff
2454
2469
  },
2455
- { provider, model: options.model },
2470
+ { provider, model: options.model, language: getLanguage() },
2456
2471
  template || void 0
2457
2472
  );
2458
2473
  spinner.stop();
@@ -2483,9 +2498,41 @@ ${body}`;
2483
2498
  console.log(chalk15.gray("\nTip: Use --copy to copy to clipboard"));
2484
2499
  }
2485
2500
  } else {
2501
+ const readline = await import("readline");
2502
+ if (!hasUpstreamBranch()) {
2503
+ const rl2 = readline.createInterface({
2504
+ input: process.stdin,
2505
+ output: process.stdout
2506
+ });
2507
+ const pushAnswer = await new Promise((resolve) => {
2508
+ rl2.question(
2509
+ chalk15.cyan(`
2510
+ No remote branch found. Push ${currentBranch} to origin? (y/N) `),
2511
+ resolve
2512
+ );
2513
+ });
2514
+ rl2.close();
2515
+ if (pushAnswer.toLowerCase() !== "y") {
2516
+ console.log(chalk15.gray("Aborted. Push your branch first to create a PR."));
2517
+ return;
2518
+ }
2519
+ const pushSpinner = ora11(`Pushing ${currentBranch} to origin...`).start();
2520
+ try {
2521
+ pushBranchToOrigin(currentBranch);
2522
+ pushSpinner.succeed(`Pushed ${currentBranch} to origin`);
2523
+ } catch (err) {
2524
+ pushSpinner.fail("Failed to push branch");
2525
+ if (err instanceof Error && "stderr" in err) {
2526
+ const stderr = err.stderr?.toString?.() || "";
2527
+ if (stderr) {
2528
+ console.error(chalk15.red(stderr.trim()));
2529
+ }
2530
+ }
2531
+ return;
2532
+ }
2533
+ }
2486
2534
  const existingPrUrl = getExistingPrUrl();
2487
2535
  const isUpdate = !!existingPrUrl;
2488
- const readline = await import("readline");
2489
2536
  const rl = readline.createInterface({
2490
2537
  input: process.stdin,
2491
2538
  output: process.stdout
@@ -2630,7 +2677,7 @@ ${diff}`;
2630
2677
  const template = findTemplate(repoRoot.trim(), "review");
2631
2678
  const review = await generateCodeReview(
2632
2679
  diff,
2633
- { provider, model: options.model },
2680
+ { provider, model: options.model, language: getLanguage() },
2634
2681
  template || void 0
2635
2682
  );
2636
2683
  spinner.stop();
@@ -2804,7 +2851,7 @@ ${stagedDiff}`;
2804
2851
  const template = findTemplate(repoRoot.trim(), "stash");
2805
2852
  stashName = await generateStashName(
2806
2853
  fullDiff,
2807
- { provider, model: options.model },
2854
+ { provider, model: options.model, language: getLanguage() },
2808
2855
  template || void 0
2809
2856
  );
2810
2857
  spinner.stop();
@@ -2883,7 +2930,7 @@ var summaryCommand = new Command17("summary").description("Generate a work summa
2883
2930
  const template = findTemplate(repoRoot.trim(), "summary");
2884
2931
  const summary = await generateWorkSummary(
2885
2932
  { commits, author, since, until: options.until, diff },
2886
- { provider, model: options.model },
2933
+ { provider, model: options.model, language: getLanguage() },
2887
2934
  format,
2888
2935
  template || void 0
2889
2936
  );