bugzero 0.0.42 → 0.0.43

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 (3) hide show
  1. package/README.md +4 -2
  2. package/dist/index.js +39 -16
  3. package/package.json +1 -1
package/README.md CHANGED
@@ -269,8 +269,10 @@ BugZero provides clear, actionable output for common failure modes:
269
269
  | Error | Message |
270
270
  |---|---|
271
271
  | Invalid API key (401) | Prompts you to check your `OPENROUTER_API_KEY` |
272
- | Rate limit exceeded (429) | Prompts you to check your OpenRouter credit balance |
273
- | Model not found | Displays the invalid model ID and suggests running `bugzero vibe` |
272
+ | Insufficient credits (402) | Says your OpenRouter balance is too low, links to the credits page, and suggests switching to a cheaper or free model with `bugzero vibe` |
273
+ | Rate limit exceeded (429) | Says OpenRouter is rate limiting and suggests waiting, switching models, or adding credits |
274
+ | Prompt too large for the model | Says the prompt exceeded the model's context window and suggests a larger-context model with `bugzero vibe` |
275
+ | Model not found | Names the unavailable model ID and suggests running `bugzero vibe` |
274
276
  | Patch not applied | Reports exact mismatch between AI suggestion and file content, after exhausting exact, whitespace, and fuzzy matching |
275
277
  | Max attempts reached | Exits cleanly with the last error log for manual review |
276
278
 
package/dist/index.js CHANGED
@@ -704,12 +704,47 @@ var require_dist3 = __commonJS({
704
704
  var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
705
705
  var index_exports = {};
706
706
  __export(index_exports, {
707
- OpenRouterProvider: () => OpenRouterProvider
707
+ OpenRouterProvider: () => OpenRouterProvider,
708
+ getErrorHints: () => getErrorHints
708
709
  });
709
710
  module2.exports = __toCommonJS(index_exports);
710
711
  var import_axios = __toESM2(require("axios"));
711
712
  var import_fs2 = __toESM2(require("fs"));
712
713
  var import_path2 = __toESM2(require("path"));
714
+ var CREDITS_PATTERN = /insufficient credits|credit balance|add more credits|requires more credits|token_limit_exceeded/i;
715
+ var CONTEXT_PATTERN = /context length|context window|maximum context|context_length_exceeded|string_too_long|too many tokens|reduce the length/i;
716
+ var MODEL_PATTERN = /not a valid model|no endpoints found|model.{0,40}(not found|does not exist|unavailable)/i;
717
+ function getErrorHints({ status, message, model }) {
718
+ if (status === 401) {
719
+ return ["\u{1F449} Please check if your OPENROUTER_API_KEY is correct and active."];
720
+ }
721
+ if (status === 402 || CREDITS_PATTERN.test(message)) {
722
+ return [
723
+ "\u{1F449} Your OpenRouter credit balance is too low for this request.",
724
+ " Add credits at https://openrouter.ai/settings/credits, or run 'bugzero vibe' to switch to a cheaper model",
725
+ " (models that cost nothing are listed at https://openrouter.ai/models?max_price=0)."
726
+ ];
727
+ }
728
+ if (status === 429) {
729
+ return [
730
+ "\u{1F449} OpenRouter is rate limiting these requests. Wait a moment and try again.",
731
+ " Free models have stricter limits; run 'bugzero vibe' to switch models, or add credits to raise them."
732
+ ];
733
+ }
734
+ if (CONTEXT_PATTERN.test(message)) {
735
+ return [
736
+ `\u{1F449} The prompt was too large for the context window of "${model}".`,
737
+ " Run 'bugzero vibe' to pick a model with a larger context window, or try again on a smaller failing scope."
738
+ ];
739
+ }
740
+ if (status === 404 || MODEL_PATTERN.test(message)) {
741
+ return [
742
+ `\u{1F449} The model "${model}" isn't available on OpenRouter (it wasn't found, or no provider currently serves it).`,
743
+ " Run 'bugzero vibe' to choose a different model."
744
+ ];
745
+ }
746
+ return [];
747
+ }
713
748
  function resolveModel(cwd) {
714
749
  try {
715
750
  const configPath = import_path2.default.resolve(cwd ?? process.cwd(), ".bugzerorc");
@@ -772,21 +807,9 @@ var require_dist3 = __commonJS({
772
807
  }
773
808
  console.error(`
774
809
  \u274C [BugZero] OpenRouter API Error: ${msg}`);
775
- if (error.response?.status === 401) {
776
- console.error(`\u{1F449} Please check if your OPENROUTER_API_KEY is correct and active.`);
777
- } else if (error.response?.status === 429 || error.response?.status === 402 || /credit/i.test(msg) || /token/i.test(msg)) {
778
- console.error(`
779
- \u{1F449} You have insufficient OpenRouter credits (or too low balance) for the selected model.`);
780
- console.error(`\u{1F449} We suggest using the 'bugzero vibe' command to change to a FREE model:`);
781
- console.error(` 1. Run the command: npx bugzero@latest vibe (or bugzero vibe)`);
782
- console.error(` 2. Select "Custom Model" and enter one of these free model IDs:`);
783
- console.error(` - google/gemma-2-9b-it:free`);
784
- console.error(` - meta-llama/llama-3-8b-instruct:free`);
785
- console.error(` - mistralai/mistral-7b-instruct:free`);
786
- console.error(` - microsoft/phi-3-medium-128k-instruct:free`);
787
- console.error(` - nvidia/llama-3.1-nemotron-70b-instruct:free
788
- `);
789
- }
810
+ const hints = getErrorHints({ status: error.response?.status, message: msg, model });
811
+ for (const line of hints) console.error(line);
812
+ if (hints.length > 0) console.error();
790
813
  throw new Error(`OpenRouter API failed: ${msg}`);
791
814
  }
792
815
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bugzero",
3
- "version": "0.0.42",
3
+ "version": "0.0.43",
4
4
  "description": "Autonomous AI-powered CLI and GitHub Action that detects build, lint, and test failures, generates multi-file patches, applies them atomically with fuzzy matching, and re-verifies until your project is green.",
5
5
  "license": "MIT",
6
6
  "author": "Saksham Agarwal (https://github.com/Saksham1800t)",