bugzero 0.0.1 → 0.0.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.
@@ -1,5 +1,5 @@
1
1
 
2
- > bugzero@0.0.1 build D:\WD projects\OpsPilot\packages\cli
2
+ > bugzero@0.0.4 build D:\WD projects\OpsPilot\packages\cli
3
3
  > tsup src/index.ts --format esm --dts
4
4
 
5
5
  CLI Building entry: src/index.ts
@@ -7,8 +7,10 @@
7
7
  CLI tsup v8.5.1
8
8
  CLI Target: es2022
9
9
  ESM Build start
10
- ESM dist\index.js 41.55 KB
11
- ESM ⚡️ Build success in 165ms
10
+ ESM dist\index.js 31.38 KB
11
+ ESM dist\chunk-4ANZDGVD.js 16.11 KB
12
+ ESM dist\dist-FQYNA36C.js 85.00 B
13
+ ESM ⚡️ Build success in 133ms
12
14
  DTS Build start
13
- DTS ⚡️ Build success in 1740ms
15
+ DTS ⚡️ Build success in 1828ms
14
16
  DTS dist\index.d.ts 20.00 B
package/README.md ADDED
@@ -0,0 +1,165 @@
1
+ # 🚀 BugZero
2
+
3
+ [![npm version](https://img.shields.io/npm/v/bugzero.svg?style=flat-square&color=FF69B4)](https://www.npmjs.com/package/bugzero)
4
+ [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg?style=flat-square)](https://opensource.org/licenses/MIT)
5
+ [![pnpm](https://img.shields.io/badge/maintained%20with-pnpm-cc00ff.svg?style=flat-square)](https://pnpm.io/)
6
+ [![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square)](https://github.com/Saksham1800t)
7
+
8
+ **BugZero** is an autonomous, AI-powered self-healing command-line tool. It monitors build, lint, and test errors in your project, analyzes them using an LLM, generates precise surgical code patches, applies them safely, and runs validation loops recursively until your build is completely green.
9
+
10
+ Designed for modern developer loops, CI/CD pipelines, and automated hotfixes.
11
+
12
+ ---
13
+
14
+ ## 🛠️ How it Works
15
+
16
+ ```
17
+ bugzero rescue
18
+ │
19
+ ▼
20
+ Run Build + Lint + Tests
21
+ │
22
+ ▼
23
+ Any failures? ──── No ──▶ ✅ Exit cleanly
24
+ │
25
+ Yes
26
+ │
27
+ ▼
28
+ Capture error logs
29
+ │
30
+ ▼
31
+ Prompt LLM via LangGraph
32
+ │
33
+ ▼
34
+ Parse fix suggestion (JSON)
35
+ │
36
+ ▼
37
+ Apply search-and-replace patch
38
+ │
39
+ ▼
40
+ Re-run build to verify
41
+ │
42
+ ▼
43
+ Build fixed? ─── Yes ──▶ ✅ Print fix details & Exit
44
+ │
45
+ No
46
+ │
47
+ ▼
48
+ Max attempts reached? ── Yes ──▶ ❌ Exit with logs
49
+ │
50
+ No
51
+ │
52
+ └──────────────────▶ Prompt LLM again (loop)
53
+ ```
54
+
55
+ ---
56
+
57
+ ## 🌟 Key Features
58
+
59
+ * **🔍 Automatic Framework Detection**: Detects common web frameworks and tooling setups inside your target directories.
60
+ * **🤖 LangGraph-Based Feedback Loop**: Employs stateful graphs to analyze compiler/test outputs, write minimal patches, and re-run compilation checks recursively.
61
+ * **⚡ Surgical Search-and-Replace**: Avoids corrupting files by using highly specific search-and-replace strings generated directly from the abstract syntax context.
62
+ * **📦 Safe Backups**: Creates a backup `.bugzero.bak` for every modified file so you can revert modifications easily.
63
+ * **📈 Multiple Checkups**: Validates builds, style guidelines (ESLint), and testing frameworks (Jest) automatically.
64
+
65
+ ---
66
+
67
+ ## 🚀 Getting Started
68
+
69
+ ### 1. Global Installation
70
+ Install `bugzero` globally from NPM:
71
+ ```bash
72
+ npm install -g bugzero
73
+ ```
74
+
75
+ ### 2. Configure Environment Variables
76
+ BugZero relies on OpenRouter to access AI models (such as DeepSeek, Claude, Gemini, or GPT-4o). Configure your environment variable in your terminal session or add it to a `.env` file at the root of the project you are fixing:
77
+
78
+ **On macOS/Linux:**
79
+ ```bash
80
+ export OPENROUTER_API_KEY="your_openrouter_api_key_here"
81
+ ```
82
+
83
+ **On Windows (PowerShell):**
84
+ ```powershell
85
+ $env:OPENROUTER_API_KEY="your_openrouter_api_key_here"
86
+ ```
87
+
88
+ ---
89
+
90
+ ## 💻 Usage & Commands
91
+
92
+ Run `bugzero` from any terminal directory.
93
+
94
+ ### 1. Hunt for Bugs (Dry-Run / Safe Check)
95
+ Run build, lint, and test checks to report error diagnostics without modifying any files.
96
+ ```bash
97
+ bugzero hunt --path /path/to/your/project
98
+ ```
99
+
100
+ ### 2. Rescue Your Project (Autonomous Mode)
101
+ Run the AI repair loop to automatically detect compilation errors, generate code patches, apply them, and verify the build.
102
+ ```bash
103
+ bugzero rescue --path /path/to/your/project
104
+ ```
105
+
106
+ ### 3. Vibe With a Brain (Change AI Model)
107
+ List and select which LLM model you want to use. This fetches the latest available models from OpenRouter, lets you pick one, and saves it inside `.bugzerorc`.
108
+ ```bash
109
+ bugzero vibe
110
+ ```
111
+
112
+ ### CLI Command Options
113
+
114
+ | Option | Shorthand | Description | Default |
115
+ | :--- | :--- | :--- | :--- |
116
+ | `--path <dir>` | `-p <dir>` | The path to the target project you want to check/fix | `.` (Current directory) |
117
+ | `--max-attempts <num>` | `-n <num>` | Maximum AI fix loops/attempts before giving up | `3` |
118
+ | `--dry-run` | | Print the recommended fixes without saving changes to files | `false` |
119
+
120
+ ---
121
+
122
+ ## 🧱 Monorepo Development & Local Setup
123
+
124
+ If you want to contribute to the BugZero engine:
125
+
126
+ ### Prerequisites
127
+ * Node.js (LTS version recommended)
128
+ * `pnpm` (workspace manager)
129
+
130
+ ### Installation
131
+ Clone the repository, go into the workspace root, and run:
132
+ ```bash
133
+ pnpm install
134
+ ```
135
+
136
+ ### Local Commands
137
+ * **Build all monorepo packages**:
138
+ ```bash
139
+ pnpm build
140
+ ```
141
+ * **Run CLI locally in development mode (shortcuts)**:
142
+ ```bash
143
+ pnpm hunt --path ./demo-project
144
+ pnpm rescue --path ./demo-project
145
+ pnpm vibe
146
+ ```
147
+
148
+ ---
149
+
150
+ ## 👥 Author
151
+
152
+ Made with ❤️ and 😎 by:
153
+
154
+ * **Name**: Saksham Agarwal
155
+ * **Email**: [sakshamagarwal0507@gmail.com](mailto:sakshamagarwal0507@gmail.com)
156
+ * **GitHub**: [@Saksham1800t](https://github.com/Saksham1800t)
157
+ * **LinkedIn**: [Saksham Agarwal](https://www.linkedin.com/in/saksham-agarwal-/)
158
+
159
+ ---
160
+
161
+ ## ☕ Support My Work
162
+
163
+ If BugZero saved you debugging hours in production or deployment pipelines, support the project!
164
+
165
+ [!["Buy Me A Coffee"](https://www.buymeacoffee.com/assets/img/custom_images/orange_img.png)](https://www.buymeacoffee.com/saksham_)
@@ -0,0 +1,426 @@
1
+ var __create = Object.create;
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __getProtoOf = Object.getPrototypeOf;
6
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
7
+ var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
8
+ get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
9
+ }) : x)(function(x) {
10
+ if (typeof require !== "undefined") return require.apply(this, arguments);
11
+ throw Error('Dynamic require of "' + x + '" is not supported');
12
+ });
13
+ var __commonJS = (cb, mod) => function __require2() {
14
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
15
+ };
16
+ var __copyProps = (to, from, except, desc) => {
17
+ if (from && typeof from === "object" || typeof from === "function") {
18
+ for (let key of __getOwnPropNames(from))
19
+ if (!__hasOwnProp.call(to, key) && key !== except)
20
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
21
+ }
22
+ return to;
23
+ };
24
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
25
+ // If the importer is in node compatibility mode or this is not an ESM
26
+ // file that has been converted to a CommonJS file using a Babel-
27
+ // compatible transform (i.e. "__esModule" has not been set), then set
28
+ // "default" to the CommonJS "module.exports" for node compatibility.
29
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
30
+ mod
31
+ ));
32
+
33
+ // ../../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js
34
+ var require_main = __commonJS({
35
+ "../../node_modules/.pnpm/dotenv@17.4.2/node_modules/dotenv/lib/main.js"(exports, module) {
36
+ "use strict";
37
+ var fs = __require("fs");
38
+ var path = __require("path");
39
+ var os = __require("os");
40
+ var crypto = __require("crypto");
41
+ var TIPS = [
42
+ "\u25C8 encrypted .env [www.dotenvx.com]",
43
+ "\u25C8 secrets for agents [www.dotenvx.com]",
44
+ "\u2301 auth for agents [www.vestauth.com]",
45
+ "\u2318 custom filepath { path: '/custom/path/.env' }",
46
+ "\u2318 enable debugging { debug: true }",
47
+ "\u2318 override existing { override: true }",
48
+ "\u2318 suppress logs { quiet: true }",
49
+ "\u2318 multiple files { path: ['.env.local', '.env'] }"
50
+ ];
51
+ function _getRandomTip() {
52
+ return TIPS[Math.floor(Math.random() * TIPS.length)];
53
+ }
54
+ function parseBoolean(value) {
55
+ if (typeof value === "string") {
56
+ return !["false", "0", "no", "off", ""].includes(value.toLowerCase());
57
+ }
58
+ return Boolean(value);
59
+ }
60
+ function supportsAnsi() {
61
+ return process.stdout.isTTY;
62
+ }
63
+ function dim(text) {
64
+ return supportsAnsi() ? `\x1B[2m${text}\x1B[0m` : text;
65
+ }
66
+ var LINE = /(?:^|^)\s*(?:export\s+)?([\w.-]+)(?:\s*=\s*?|:\s+?)(\s*'(?:\\'|[^'])*'|\s*"(?:\\"|[^"])*"|\s*`(?:\\`|[^`])*`|[^#\r\n]+)?\s*(?:#.*)?(?:$|$)/mg;
67
+ function parse(src) {
68
+ const obj = {};
69
+ let lines = src.toString();
70
+ lines = lines.replace(/\r\n?/mg, "\n");
71
+ let match;
72
+ while ((match = LINE.exec(lines)) != null) {
73
+ const key = match[1];
74
+ let value = match[2] || "";
75
+ value = value.trim();
76
+ const maybeQuote = value[0];
77
+ value = value.replace(/^(['"`])([\s\S]*)\1$/mg, "$2");
78
+ if (maybeQuote === '"') {
79
+ value = value.replace(/\\n/g, "\n");
80
+ value = value.replace(/\\r/g, "\r");
81
+ }
82
+ obj[key] = value;
83
+ }
84
+ return obj;
85
+ }
86
+ function _parseVault(options) {
87
+ options = options || {};
88
+ const vaultPath = _vaultPath(options);
89
+ options.path = vaultPath;
90
+ const result = DotenvModule.configDotenv(options);
91
+ if (!result.parsed) {
92
+ const err = new Error(`MISSING_DATA: Cannot parse ${vaultPath} for an unknown reason`);
93
+ err.code = "MISSING_DATA";
94
+ throw err;
95
+ }
96
+ const keys = _dotenvKey(options).split(",");
97
+ const length = keys.length;
98
+ let decrypted;
99
+ for (let i = 0; i < length; i++) {
100
+ try {
101
+ const key = keys[i].trim();
102
+ const attrs = _instructions(result, key);
103
+ decrypted = DotenvModule.decrypt(attrs.ciphertext, attrs.key);
104
+ break;
105
+ } catch (error) {
106
+ if (i + 1 >= length) {
107
+ throw error;
108
+ }
109
+ }
110
+ }
111
+ return DotenvModule.parse(decrypted);
112
+ }
113
+ function _warn(message) {
114
+ console.error(`\u26A0 ${message}`);
115
+ }
116
+ function _debug(message) {
117
+ console.log(`\u2506 ${message}`);
118
+ }
119
+ function _log(message) {
120
+ console.log(`\u25C7 ${message}`);
121
+ }
122
+ function _dotenvKey(options) {
123
+ if (options && options.DOTENV_KEY && options.DOTENV_KEY.length > 0) {
124
+ return options.DOTENV_KEY;
125
+ }
126
+ if (process.env.DOTENV_KEY && process.env.DOTENV_KEY.length > 0) {
127
+ return process.env.DOTENV_KEY;
128
+ }
129
+ return "";
130
+ }
131
+ function _instructions(result, dotenvKey) {
132
+ let uri;
133
+ try {
134
+ uri = new URL(dotenvKey);
135
+ } catch (error) {
136
+ if (error.code === "ERR_INVALID_URL") {
137
+ const err = new Error("INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development");
138
+ err.code = "INVALID_DOTENV_KEY";
139
+ throw err;
140
+ }
141
+ throw error;
142
+ }
143
+ const key = uri.password;
144
+ if (!key) {
145
+ const err = new Error("INVALID_DOTENV_KEY: Missing key part");
146
+ err.code = "INVALID_DOTENV_KEY";
147
+ throw err;
148
+ }
149
+ const environment = uri.searchParams.get("environment");
150
+ if (!environment) {
151
+ const err = new Error("INVALID_DOTENV_KEY: Missing environment part");
152
+ err.code = "INVALID_DOTENV_KEY";
153
+ throw err;
154
+ }
155
+ const environmentKey = `DOTENV_VAULT_${environment.toUpperCase()}`;
156
+ const ciphertext = result.parsed[environmentKey];
157
+ if (!ciphertext) {
158
+ const err = new Error(`NOT_FOUND_DOTENV_ENVIRONMENT: Cannot locate environment ${environmentKey} in your .env.vault file.`);
159
+ err.code = "NOT_FOUND_DOTENV_ENVIRONMENT";
160
+ throw err;
161
+ }
162
+ return { ciphertext, key };
163
+ }
164
+ function _vaultPath(options) {
165
+ let possibleVaultPath = null;
166
+ if (options && options.path && options.path.length > 0) {
167
+ if (Array.isArray(options.path)) {
168
+ for (const filepath of options.path) {
169
+ if (fs.existsSync(filepath)) {
170
+ possibleVaultPath = filepath.endsWith(".vault") ? filepath : `${filepath}.vault`;
171
+ }
172
+ }
173
+ } else {
174
+ possibleVaultPath = options.path.endsWith(".vault") ? options.path : `${options.path}.vault`;
175
+ }
176
+ } else {
177
+ possibleVaultPath = path.resolve(process.cwd(), ".env.vault");
178
+ }
179
+ if (fs.existsSync(possibleVaultPath)) {
180
+ return possibleVaultPath;
181
+ }
182
+ return null;
183
+ }
184
+ function _resolveHome(envPath) {
185
+ return envPath[0] === "~" ? path.join(os.homedir(), envPath.slice(1)) : envPath;
186
+ }
187
+ function _configVault(options) {
188
+ const debug = parseBoolean(process.env.DOTENV_CONFIG_DEBUG || options && options.debug);
189
+ const quiet = parseBoolean(process.env.DOTENV_CONFIG_QUIET || options && options.quiet);
190
+ if (debug || !quiet) {
191
+ _log("loading env from encrypted .env.vault");
192
+ }
193
+ const parsed = DotenvModule._parseVault(options);
194
+ let processEnv = process.env;
195
+ if (options && options.processEnv != null) {
196
+ processEnv = options.processEnv;
197
+ }
198
+ DotenvModule.populate(processEnv, parsed, options);
199
+ return { parsed };
200
+ }
201
+ function configDotenv(options) {
202
+ const dotenvPath = path.resolve(process.cwd(), ".env");
203
+ let encoding = "utf8";
204
+ let processEnv = process.env;
205
+ if (options && options.processEnv != null) {
206
+ processEnv = options.processEnv;
207
+ }
208
+ let debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || options && options.debug);
209
+ let quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || options && options.quiet);
210
+ if (options && options.encoding) {
211
+ encoding = options.encoding;
212
+ } else {
213
+ if (debug) {
214
+ _debug("no encoding is specified (UTF-8 is used by default)");
215
+ }
216
+ }
217
+ let optionPaths = [dotenvPath];
218
+ if (options && options.path) {
219
+ if (!Array.isArray(options.path)) {
220
+ optionPaths = [_resolveHome(options.path)];
221
+ } else {
222
+ optionPaths = [];
223
+ for (const filepath of options.path) {
224
+ optionPaths.push(_resolveHome(filepath));
225
+ }
226
+ }
227
+ }
228
+ let lastError;
229
+ const parsedAll = {};
230
+ for (const path2 of optionPaths) {
231
+ try {
232
+ const parsed = DotenvModule.parse(fs.readFileSync(path2, { encoding }));
233
+ DotenvModule.populate(parsedAll, parsed, options);
234
+ } catch (e) {
235
+ if (debug) {
236
+ _debug(`failed to load ${path2} ${e.message}`);
237
+ }
238
+ lastError = e;
239
+ }
240
+ }
241
+ const populated = DotenvModule.populate(processEnv, parsedAll, options);
242
+ debug = parseBoolean(processEnv.DOTENV_CONFIG_DEBUG || debug);
243
+ quiet = parseBoolean(processEnv.DOTENV_CONFIG_QUIET || quiet);
244
+ if (debug || !quiet) {
245
+ const keysCount = Object.keys(populated).length;
246
+ const shortPaths = [];
247
+ for (const filePath of optionPaths) {
248
+ try {
249
+ const relative = path.relative(process.cwd(), filePath);
250
+ shortPaths.push(relative);
251
+ } catch (e) {
252
+ if (debug) {
253
+ _debug(`failed to load ${filePath} ${e.message}`);
254
+ }
255
+ lastError = e;
256
+ }
257
+ }
258
+ _log(`injected env (${keysCount}) from ${shortPaths.join(",")} ${dim(`// tip: ${_getRandomTip()}`)}`);
259
+ }
260
+ if (lastError) {
261
+ return { parsed: parsedAll, error: lastError };
262
+ } else {
263
+ return { parsed: parsedAll };
264
+ }
265
+ }
266
+ function config(options) {
267
+ if (_dotenvKey(options).length === 0) {
268
+ return DotenvModule.configDotenv(options);
269
+ }
270
+ const vaultPath = _vaultPath(options);
271
+ if (!vaultPath) {
272
+ _warn(`you set DOTENV_KEY but you are missing a .env.vault file at ${vaultPath}`);
273
+ return DotenvModule.configDotenv(options);
274
+ }
275
+ return DotenvModule._configVault(options);
276
+ }
277
+ function decrypt(encrypted, keyStr) {
278
+ const key = Buffer.from(keyStr.slice(-64), "hex");
279
+ let ciphertext = Buffer.from(encrypted, "base64");
280
+ const nonce = ciphertext.subarray(0, 12);
281
+ const authTag = ciphertext.subarray(-16);
282
+ ciphertext = ciphertext.subarray(12, -16);
283
+ try {
284
+ const aesgcm = crypto.createDecipheriv("aes-256-gcm", key, nonce);
285
+ aesgcm.setAuthTag(authTag);
286
+ return `${aesgcm.update(ciphertext)}${aesgcm.final()}`;
287
+ } catch (error) {
288
+ const isRange = error instanceof RangeError;
289
+ const invalidKeyLength = error.message === "Invalid key length";
290
+ const decryptionFailed = error.message === "Unsupported state or unable to authenticate data";
291
+ if (isRange || invalidKeyLength) {
292
+ const err = new Error("INVALID_DOTENV_KEY: It must be 64 characters long (or more)");
293
+ err.code = "INVALID_DOTENV_KEY";
294
+ throw err;
295
+ } else if (decryptionFailed) {
296
+ const err = new Error("DECRYPTION_FAILED: Please check your DOTENV_KEY");
297
+ err.code = "DECRYPTION_FAILED";
298
+ throw err;
299
+ } else {
300
+ throw error;
301
+ }
302
+ }
303
+ }
304
+ function populate(processEnv, parsed, options = {}) {
305
+ const debug = Boolean(options && options.debug);
306
+ const override = Boolean(options && options.override);
307
+ const populated = {};
308
+ if (typeof parsed !== "object") {
309
+ const err = new Error("OBJECT_REQUIRED: Please check the processEnv argument being passed to populate");
310
+ err.code = "OBJECT_REQUIRED";
311
+ throw err;
312
+ }
313
+ for (const key of Object.keys(parsed)) {
314
+ if (Object.prototype.hasOwnProperty.call(processEnv, key)) {
315
+ if (override === true) {
316
+ processEnv[key] = parsed[key];
317
+ populated[key] = parsed[key];
318
+ }
319
+ if (debug) {
320
+ if (override === true) {
321
+ _debug(`"${key}" is already defined and WAS overwritten`);
322
+ } else {
323
+ _debug(`"${key}" is already defined and was NOT overwritten`);
324
+ }
325
+ }
326
+ } else {
327
+ processEnv[key] = parsed[key];
328
+ populated[key] = parsed[key];
329
+ }
330
+ }
331
+ return populated;
332
+ }
333
+ var DotenvModule = {
334
+ configDotenv,
335
+ _configVault,
336
+ _parseVault,
337
+ config,
338
+ decrypt,
339
+ parse,
340
+ populate
341
+ };
342
+ module.exports.configDotenv = DotenvModule.configDotenv;
343
+ module.exports._configVault = DotenvModule._configVault;
344
+ module.exports._parseVault = DotenvModule._parseVault;
345
+ module.exports.config = DotenvModule.config;
346
+ module.exports.decrypt = DotenvModule.decrypt;
347
+ module.exports.parse = DotenvModule.parse;
348
+ module.exports.populate = DotenvModule.populate;
349
+ module.exports = DotenvModule;
350
+ }
351
+ });
352
+
353
+ // ../config/dist/index.js
354
+ var require_dist = __commonJS({
355
+ "../config/dist/index.js"(exports, module) {
356
+ var __create2 = Object.create;
357
+ var __defProp2 = Object.defineProperty;
358
+ var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
359
+ var __getOwnPropNames2 = Object.getOwnPropertyNames;
360
+ var __getProtoOf2 = Object.getPrototypeOf;
361
+ var __hasOwnProp2 = Object.prototype.hasOwnProperty;
362
+ var __export = (target, all) => {
363
+ for (var name in all)
364
+ __defProp2(target, name, { get: all[name], enumerable: true });
365
+ };
366
+ var __copyProps2 = (to, from, except, desc) => {
367
+ if (from && typeof from === "object" || typeof from === "function") {
368
+ for (let key of __getOwnPropNames2(from))
369
+ if (!__hasOwnProp2.call(to, key) && key !== except)
370
+ __defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
371
+ }
372
+ return to;
373
+ };
374
+ var __toESM2 = (mod, isNodeMode, target) => (target = mod != null ? __create2(__getProtoOf2(mod)) : {}, __copyProps2(
375
+ // If the importer is in node compatibility mode or this is not an ESM
376
+ // file that has been converted to a CommonJS file using a Babel-
377
+ // compatible transform (i.e. "__esModule" has not been set), then set
378
+ // "default" to the CommonJS "module.exports" for node compatibility.
379
+ isNodeMode || !mod || !mod.__esModule ? __defProp2(target, "default", { value: mod, enumerable: true }) : target,
380
+ mod
381
+ ));
382
+ var __toCommonJS = (mod) => __copyProps2(__defProp2({}, "__esModule", { value: true }), mod);
383
+ var index_exports = {};
384
+ __export(index_exports, {
385
+ env: () => env,
386
+ getLocalConfig: () => getLocalConfig,
387
+ getSelectedModel: () => getSelectedModel,
388
+ saveLocalConfig: () => saveLocalConfig
389
+ });
390
+ module.exports = __toCommonJS(index_exports);
391
+ var import_dotenv = __toESM2(require_main());
392
+ import_dotenv.default.config();
393
+ var env = {
394
+ openRouterKey: process.env.OPENROUTER_API_KEY
395
+ };
396
+ var import_fs = __toESM2(__require("fs"));
397
+ var import_path = __toESM2(__require("path"));
398
+ var CONFIG_FILENAME = ".bugzerorc";
399
+ function getLocalConfig(cwd = process.cwd()) {
400
+ try {
401
+ const configPath = import_path.default.resolve(cwd, CONFIG_FILENAME);
402
+ if (import_fs.default.existsSync(configPath)) {
403
+ const content = import_fs.default.readFileSync(configPath, "utf-8");
404
+ return JSON.parse(content);
405
+ }
406
+ } catch (e) {
407
+ }
408
+ return {};
409
+ }
410
+ function saveLocalConfig(config, cwd = process.cwd()) {
411
+ const configPath = import_path.default.resolve(cwd, CONFIG_FILENAME);
412
+ import_fs.default.writeFileSync(configPath, JSON.stringify(config, null, 2), "utf-8");
413
+ }
414
+ function getSelectedModel(cwd = process.cwd()) {
415
+ const config = getLocalConfig(cwd);
416
+ return config.model || "deepseek/deepseek-chat";
417
+ }
418
+ }
419
+ });
420
+
421
+ export {
422
+ __require,
423
+ __commonJS,
424
+ __toESM,
425
+ require_dist
426
+ };
@@ -0,0 +1,4 @@
1
+ import {
2
+ require_dist
3
+ } from "./chunk-4ANZDGVD.js";
4
+ export default require_dist();