bugsage 0.2.0

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 (69) hide show
  1. checksums.yaml +7 -0
  2. data/ARCHITECTURE.md +442 -0
  3. data/CHANGELOG.md +28 -0
  4. data/CODE_OF_CONDUCT.md +10 -0
  5. data/CONTRIBUTING.md +301 -0
  6. data/LICENSE.txt +21 -0
  7. data/README.md +344 -0
  8. data/ROADMAP.md +217 -0
  9. data/SECURITY.md +83 -0
  10. data/docs/AI.md +167 -0
  11. data/docs/Configuration.md +168 -0
  12. data/docs/GettingStarted.md +146 -0
  13. data/docs/RELEASE_CHECKLIST.md +346 -0
  14. data/docs/Troubleshooting.md +181 -0
  15. data/docs/images/BadRequest.png +0 -0
  16. data/docs/images/BadRequest2.png +0 -0
  17. data/docs/images/BugSage_Logo.png +0 -0
  18. data/docs/images/BugSage_Social_Preview.png +0 -0
  19. data/docs/images/NoMethodError.png +0 -0
  20. data/docs/images/NoMethodError2.png +0 -0
  21. data/docs/images/README.md +38 -0
  22. data/docs/releases/README.md +21 -0
  23. data/docs/releases/v0.2.0.md +40 -0
  24. data/exe/bugsage +7 -0
  25. data/lib/bugsage/ai_analyzer.rb +145 -0
  26. data/lib/bugsage/ai_chat.rb +388 -0
  27. data/lib/bugsage/ai_context.rb +69 -0
  28. data/lib/bugsage/ai_panel.rb +708 -0
  29. data/lib/bugsage/ai_support.rb +36 -0
  30. data/lib/bugsage/auto_configurator.rb +97 -0
  31. data/lib/bugsage/cli.rb +59 -0
  32. data/lib/bugsage/code_context.rb +81 -0
  33. data/lib/bugsage/code_patch.rb +147 -0
  34. data/lib/bugsage/configuration.rb +149 -0
  35. data/lib/bugsage/console_context.rb +51 -0
  36. data/lib/bugsage/cursor_client.rb +165 -0
  37. data/lib/bugsage/dashboard.rb +627 -0
  38. data/lib/bugsage/editor_links.rb +34 -0
  39. data/lib/bugsage/error_page.rb +298 -0
  40. data/lib/bugsage/exception_handler.rb +66 -0
  41. data/lib/bugsage/exception_support.rb +95 -0
  42. data/lib/bugsage/exceptions_app.rb +31 -0
  43. data/lib/bugsage/fix_applicator.rb +107 -0
  44. data/lib/bugsage/formatter.rb +37 -0
  45. data/lib/bugsage/http_error_capture.rb +104 -0
  46. data/lib/bugsage/http_response_error.rb +14 -0
  47. data/lib/bugsage/inline_console.rb +226 -0
  48. data/lib/bugsage/installation.rb +94 -0
  49. data/lib/bugsage/installer.rb +66 -0
  50. data/lib/bugsage/json_endpoint.rb +34 -0
  51. data/lib/bugsage/locales/en.yml +439 -0
  52. data/lib/bugsage/middleware.rb +152 -0
  53. data/lib/bugsage/openai_client.rb +103 -0
  54. data/lib/bugsage/page_actions.rb +255 -0
  55. data/lib/bugsage/railtie.rb +49 -0
  56. data/lib/bugsage/request_context.rb +56 -0
  57. data/lib/bugsage/rule.rb +271 -0
  58. data/lib/bugsage/session_clear.rb +35 -0
  59. data/lib/bugsage/store.rb +60 -0
  60. data/lib/bugsage/suggestion.rb +58 -0
  61. data/lib/bugsage/trace_cleaner.rb +24 -0
  62. data/lib/bugsage/translations.rb +85 -0
  63. data/lib/bugsage/version.rb +5 -0
  64. data/lib/bugsage.rb +65 -0
  65. data/lib/generators/bugsage/install/install_generator.rb +21 -0
  66. data/lib/generators/bugsage/install/templates/bugsage.rb +22 -0
  67. data/scripts/publish-github-release.sh +38 -0
  68. data/sig/bugsage.rbs +4 -0
  69. metadata +157 -0
@@ -0,0 +1,146 @@
1
+ # Getting Started
2
+
3
+ This guide walks you through installing BugSage in a Rails app and verifying that exception capture, the error page, and the session dashboard work.
4
+
5
+ For configuration details, see [Configuration.md](Configuration.md). For AI setup, see [AI.md](AI.md). If something does not work, see [Troubleshooting.md](Troubleshooting.md).
6
+
7
+ ## Requirements
8
+
9
+ - Ruby `>= 3.2`
10
+ - A Rails application
11
+
12
+ ## Install the gem
13
+
14
+ ### From RubyGems
15
+
16
+ ```ruby
17
+ # Gemfile
18
+ gem "bugsage"
19
+ ```
20
+
21
+ ### From GitHub
22
+
23
+ ```ruby
24
+ # Gemfile
25
+ gem "bugsage", github: "MONARCHKOLI/bugsage", branch: "master"
26
+ ```
27
+
28
+ ### From a local path (gem development)
29
+
30
+ ```ruby
31
+ # Gemfile
32
+ gem "bugsage", path: "../bugsage"
33
+ ```
34
+
35
+ Then install:
36
+
37
+ ```bash
38
+ bundle install
39
+ ```
40
+
41
+ ## Start Rails
42
+
43
+ ```bash
44
+ bin/rails server
45
+ ```
46
+
47
+ BugSage wires itself through `Bugsage::Railtie`. You do **not** need to:
48
+
49
+ - edit `config/routes.rb`
50
+ - insert middleware manually
51
+ - change `config/application.rb` for basic use
52
+
53
+ ## Verify exception capture
54
+
55
+ 1. Trigger an exception in development (for example, call a method on `nil` in a controller action).
56
+ 2. Confirm you see the **BugSage error page** instead of the default Rails debugger page.
57
+ 3. Confirm the page shows:
58
+ - exception class and message
59
+ - highlighted source near the failure
60
+ - suggested fixes and a confidence score
61
+ - Rails request context
62
+
63
+ ## Open the session dashboard
64
+
65
+ Visit:
66
+
67
+ ```text
68
+ http://localhost:3000/bugsage
69
+ ```
70
+
71
+ You should see the error you just triggered listed in the session store.
72
+
73
+ The dashboard is enabled by default in **development** only.
74
+
75
+ ## Optional: generate an initializer
76
+
77
+ Only needed when you want documented overrides in your app:
78
+
79
+ ```bash
80
+ bundle exec rails generate bugsage:install
81
+ ```
82
+
83
+ Or:
84
+
85
+ ```bash
86
+ bundle exec bugsage install
87
+ ```
88
+
89
+ Guide only (no files written):
90
+
91
+ ```bash
92
+ bundle exec bugsage install --guide-only
93
+ ```
94
+
95
+ ## Optional: enable AI
96
+
97
+ Export a key in the **same terminal** that starts Rails:
98
+
99
+ ```bash
100
+ export OPENAI_API_KEY=sk-your-openai-key-here
101
+ # or
102
+ export CURSOR_API_KEY=crsr_your-cursor-key-here
103
+
104
+ bin/rails server
105
+ ```
106
+
107
+ Then on the error page or dashboard:
108
+
109
+ 1. Toggle **Enable AI** if needed.
110
+ 2. Click **Quick Fix Suggestion**.
111
+ 3. Optionally use **Chat** to refine the fix.
112
+ 4. Use **Apply AI to Codebase** on the dashboard when you are ready.
113
+
114
+ Full details: [AI.md](AI.md).
115
+
116
+ ## Optional: HTTP API error capture
117
+
118
+ BugSage can record HTTP status ≥ 400 responses (for example `render json: ..., status: :bad_request`) in the dashboard **without** changing the response body returned to Postman or other clients.
119
+
120
+ After calling a failing API endpoint, open `/bugsage` to see the captured HTTP error entry.
121
+
122
+ To disable:
123
+
124
+ ```ruby
125
+ config.bugsage.capture_http_errors = false
126
+ ```
127
+
128
+ ## What gets auto-wired
129
+
130
+ On boot, BugSage typically enables:
131
+
132
+ | Capability | Default (development) |
133
+ |------------|------------------------|
134
+ | Exception capture middleware | On |
135
+ | HTML error page | On |
136
+ | Session dashboard (`/bugsage`) | On |
137
+ | Inline Rails console | On |
138
+ | HTTP error capture | On (when error capture is on) |
139
+ | Routing error capture (`exceptions_app`) | On |
140
+ | AI panel | On when an API key is present |
141
+
142
+ ## Next steps
143
+
144
+ - Tune options in [Configuration.md](Configuration.md)
145
+ - Set up providers and patches in [AI.md](AI.md)
146
+ - Diagnose common issues in [Troubleshooting.md](Troubleshooting.md)
@@ -0,0 +1,346 @@
1
+ # Release Checklist
2
+
3
+ Checklist for publishing a new **BugSage** version to RubyGems and GitHub. Follow every step unless a release manager explicitly skips an item with a written reason.
4
+
5
+ Replace `X.Y.Z` with the version you are releasing (example: `0.3.0`).
6
+
7
+ ---
8
+
9
+ ## 0. Preconditions
10
+
11
+ - [ ] You have maintainer access to [github.com/MONARCHKOLI/bugsage](https://github.com/MONARCHKOLI/bugsage)
12
+ - [ ] You have a RubyGems.org account with push rights for `bugsage`
13
+ - [ ] MFA is enabled on RubyGems (gemspec sets `rubygems_mfa_required`)
14
+ - [ ] Working tree is clean on an up-to-date `master` (or a release branch based on it)
15
+ - [ ] CI is green on the commit you intend to release (`.github/workflows/ci.yml`)
16
+ - [ ] No open blockers for this version (security issues, broken install path)
17
+
18
+ ```bash
19
+ git checkout master
20
+ git pull origin master
21
+ git status
22
+ ```
23
+
24
+ ---
25
+
26
+ ## 1. Tests
27
+
28
+ - [ ] Run the full default suite locally:
29
+
30
+ ```bash
31
+ bundle install
32
+ bundle exec rake # RSpec + RuboCop
33
+ # or separately:
34
+ bundle exec rspec
35
+ ```
36
+
37
+ - [ ] Confirm CI matrix passed for Ruby **3.2**, **3.3**, and **3.4**
38
+ - [ ] Confirm **bundle-audit** job passed (no known vulnerable deps)
39
+ - [ ] If you touched HTTP capture, AI, or middleware: run focused examples and a manual smoke test
40
+
41
+ Failure here stops the release.
42
+
43
+ ---
44
+
45
+ ## 2. RuboCop
46
+
47
+ - [ ] Lint is clean with project config:
48
+
49
+ ```bash
50
+ bundle exec rubocop --config .rubocop.yml --force-exclusion
51
+ ```
52
+
53
+ - [ ] Do **not** disable cops or widen excludes solely to ship a release
54
+ - [ ] CI **RuboCop** job is green
55
+
56
+ ---
57
+
58
+ ## 3. README review
59
+
60
+ - [ ] Installation instructions still work (Gemfile, Git, path)
61
+ - [ ] Version badge / featured version references match `X.Y.Z` if hardcoded
62
+ - [ ] Configuration table matches `Bugsage::Configuration` defaults
63
+ - [ ] New user-facing behavior is documented (or linked under `docs/`)
64
+ - [ ] Links to CONTRIBUTING, SECURITY, ARCHITECTURE, ROADMAP, and docs are valid
65
+ - [ ] No secrets, private tokens, or broken example commands
66
+
67
+ Also skim:
68
+
69
+ - [ ] `docs/GettingStarted.md`
70
+ - [ ] `docs/Configuration.md` / `docs/AI.md` / `docs/Troubleshooting.md` (if the release touches those areas)
71
+ - [ ] `ARCHITECTURE.md` / `ROADMAP.md` status tables if milestones moved
72
+
73
+ ---
74
+
75
+ ## 4. Version bump
76
+
77
+ Single source of truth:
78
+
79
+ ```ruby
80
+ # lib/bugsage/version.rb
81
+ module Bugsage
82
+ VERSION = "X.Y.Z"
83
+ end
84
+ ```
85
+
86
+ - [ ] Bump `Bugsage::VERSION` in `lib/bugsage/version.rb`
87
+ - [ ] Confirm `bugsage.gemspec` reads `Bugsage::VERSION` (do not hardcode a second version)
88
+ - [ ] Choose SemVer intentionally:
89
+ - **MAJOR** — breaking public API / default behavior
90
+ - **MINOR** — new features, backwards compatible
91
+ - **PATCH** — bug fixes / docs-only release packaging
92
+ - [ ] Update gemspec metadata URIs if needed (especially `changelog_uri` branch name)
93
+
94
+ ```bash
95
+ ruby -e 'require_relative "lib/bugsage/version"; puts Bugsage::VERSION'
96
+ ```
97
+
98
+ ---
99
+
100
+ ## 5. CHANGELOG
101
+
102
+ Follow Keep a Changelog style in `CHANGELOG.md`:
103
+
104
+ - [ ] Move items from `## [Unreleased]` into `## [X.Y.Z] - YYYY-MM-DD`
105
+ - [ ] Group under `Added` / `Changed` / `Fixed` / `Deprecated` / `Removed` / `Security` as needed
106
+ - [ ] Leave an empty `## [Unreleased]` section at the top for the next cycle
107
+ - [ ] Write user-facing notes (why it matters), not only file lists
108
+ - [ ] Call out **breaking changes** explicitly
109
+
110
+ Example shape:
111
+
112
+ ```markdown
113
+ ## [Unreleased]
114
+
115
+ ## [X.Y.Z] - YYYY-MM-DD
116
+
117
+ ### Added
118
+ - ...
119
+
120
+ ### Fixed
121
+ - ...
122
+ ```
123
+
124
+ ---
125
+
126
+ ## 6. Build gem
127
+
128
+ - [ ] Build from a clean tree matching what will be tagged:
129
+
130
+ ```bash
131
+ rm -rf pkg/
132
+ bundle exec rake build
133
+ ls -la pkg/bugsage-X.Y.Z.gem
134
+ ```
135
+
136
+ - [ ] Validate gemspec / package (same checks CI runs):
137
+
138
+ ```bash
139
+ ruby -e 'spec = Gem::Specification.load("bugsage.gemspec"); spec.validate; puts spec.full_name'
140
+ gem unpack pkg/bugsage-X.Y.Z.gem --target /tmp/bugsage-unpack
141
+ test -f /tmp/bugsage-unpack/bugsage-X.Y.Z/lib/bugsage.rb
142
+ test -f /tmp/bugsage-unpack/bugsage-X.Y.Z/exe/bugsage
143
+ ```
144
+
145
+ - [ ] Confirm packaged files include locales, generators, and LICENSE; exclude `spec/`, `.github/`, etc.
146
+
147
+ ---
148
+
149
+ ## 7. Install locally
150
+
151
+ - [ ] Install the built `.gem` into a clean gem home or local path:
152
+
153
+ ```bash
154
+ gem install pkg/bugsage-X.Y.Z.gem
155
+ bugsage version
156
+ # expect: BugSage vX.Y.Z
157
+ ```
158
+
159
+ Or without polluting the default gemset:
160
+
161
+ ```bash
162
+ gem install pkg/bugsage-X.Y.Z.gem --install-dir /tmp/bugsage-gemhome
163
+ GEM_HOME=/tmp/bugsage-gemhome GEM_PATH=/tmp/bugsage-gemhome \
164
+ /tmp/bugsage-gemhome/bin/bugsage version
165
+ ```
166
+
167
+ - [ ] `require "bugsage"` loads without Rails
168
+ - [ ] Uninstall the local test install when finished (optional cleanup)
169
+
170
+ ---
171
+
172
+ ## 8. Test on a fresh Rails application
173
+
174
+ Do **not** rely only on the development dummy app path.
175
+
176
+ - [ ] Generate a new Rails app (versions you claim to support):
177
+
178
+ ```bash
179
+ rails new /tmp/bugsage_release_app --skip-javascript
180
+ cd /tmp/bugsage_release_app
181
+ ```
182
+
183
+ - [ ] Add the **built gem** (not the git worktree) via path to the `.gem` contents or:
184
+
185
+ ```ruby
186
+ # Gemfile
187
+ gem "bugsage", path: "/tmp/bugsage-unpack/bugsage-X.Y.Z"
188
+ # after: gem unpack pkg/bugsage-X.Y.Z.gem --target /tmp/bugsage-unpack
189
+ ```
190
+
191
+ Prefer testing the unpacked package so you catch packaging mistakes.
192
+
193
+ - [ ] `bundle install` and `bin/rails server`
194
+ - [ ] Trigger an exception → BugSage error page appears in development
195
+ - [ ] Visit `http://localhost:3000/bugsage` → dashboard loads
196
+ - [ ] If this release touches them, verify:
197
+ - [ ] HTTP 4xx capture (API `status: :bad_request`) without breaking the JSON body
198
+ - [ ] AI panel appears only with a key; Quick Fix does not run automatically
199
+ - [ ] `bundle exec rails generate bugsage:install` / `bundle exec bugsage install --guide-only`
200
+
201
+ Stop the release if zero-config install fails.
202
+
203
+ ---
204
+
205
+ ## 9. Commit, tag, and push
206
+
207
+ - [ ] Commit release metadata only (version, changelog, docs bumps):
208
+
209
+ ```bash
210
+ git add lib/bugsage/version.rb CHANGELOG.md README.md docs/
211
+ git commit -m "$(cat <<'EOF'
212
+ Release vX.Y.Z
213
+
214
+ EOF
215
+ )"
216
+ ```
217
+
218
+ - [ ] Create an annotated tag:
219
+
220
+ ```bash
221
+ git tag -a vX.Y.Z -m "BugSage vX.Y.Z"
222
+ ```
223
+
224
+ - [ ] Push commit and tag:
225
+
226
+ ```bash
227
+ git push origin master
228
+ git push origin vX.Y.Z
229
+ ```
230
+
231
+ - [ ] Confirm CI is green on the tagged commit / `master`
232
+
233
+ ---
234
+
235
+ ## 10. GitHub Release
236
+
237
+ Do **not** publish a bare tag with an empty body. Write human-readable release notes
238
+ (see `docs/releases/` — e.g. [`v0.2.0.md`](releases/v0.2.0.md)).
239
+
240
+ - [ ] Draft notes under `docs/releases/vX.Y.Z.md` with at least:
241
+
242
+ ```markdown
243
+ ## What's New
244
+
245
+ - …
246
+ ```
247
+
248
+ Include product highlights (features users feel), not only file-level changelog bullets.
249
+ Link to `CHANGELOG.md` for the full detail list.
250
+
251
+ - [ ] Open [Releases → Draft a new release](https://github.com/MONARCHKOLI/bugsage/releases/new)
252
+ or create from the CLI:
253
+
254
+ ```bash
255
+ gh release create vX.Y.Z \
256
+ --title "BugSage vX.Y.Z" \
257
+ --notes-file docs/releases/vX.Y.Z.md
258
+ ```
259
+
260
+ - [ ] Choose / confirm tag `vX.Y.Z`
261
+ - [ ] Title: `BugSage vX.Y.Z` (not only the raw tag)
262
+ - [ ] Body: paste or `--notes-file` the release notes (What's New + install + changelog link)
263
+ - [ ] Attach `pkg/bugsage-X.Y.Z.gem` only if you build it for distribution (keep `*.gem` / `pkg/` out of Git)
264
+ - [ ] Mark as pre-release only if intentionally unstable
265
+ - [ ] Publish the GitHub Release
266
+ - [ ] Confirm the release page renders: `https://github.com/MONARCHKOLI/bugsage/releases/tag/vX.Y.Z`
267
+
268
+ ---
269
+
270
+ ## 11. RubyGems publish
271
+
272
+ Final gate — only after GitHub tag/release (or immediately after tag if you publish then announce).
273
+
274
+ - [ ] Re-confirm you are publishing the exact built gem for `X.Y.Z`:
275
+
276
+ ```bash
277
+ gem env home
278
+ gem build bugsage.gemspec # or use existing pkg/bugsage-X.Y.Z.gem
279
+ gem push pkg/bugsage-X.Y.Z.gem
280
+ ```
281
+
282
+ - [ ] Complete MFA / OTP when prompted
283
+ - [ ] Verify the gem page: [https://rubygems.org/gems/bugsage](https://rubygems.org/gems/bugsage)
284
+ - [ ] Verify install from RubyGems:
285
+
286
+ ```bash
287
+ gem install bugsage -v X.Y.Z
288
+ bugsage version
289
+ ```
290
+
291
+ - [ ] `allowed_push_host` must remain `https://rubygems.org`
292
+
293
+ **Never** `--force` yank unless following a security process. Prefer a new patch release for fixes.
294
+
295
+ ---
296
+
297
+ ## 12. Post-release
298
+
299
+ - [ ] Smoke-install from RubyGems in another fresh Rails app (`gem "bugsage", "X.Y.Z"`)
300
+ - [ ] Update any hardcoded version badges (README) if still pointing at the old version
301
+ - [ ] Confirm GitHub **Social preview** uses `docs/images/BugSage_Social_Preview.png` (Settings → General → Social preview)
302
+ - [ ] Close/milestone related GitHub issues and PRs
303
+ - [ ] Announce briefly if you have a channel ( Discussions / social ) — optional
304
+ - [ ] Confirm `## [Unreleased]` is ready for the next cycle
305
+ - [ ] Rest before starting the next major feature branch ☕
306
+
307
+ ---
308
+
309
+ ## Quick command strip (healthy release)
310
+
311
+ ```bash
312
+ bundle exec rake
313
+ bundle exec bundle-audit check --update
314
+ # bump lib/bugsage/version.rb + CHANGELOG.md + docs/releases/vX.Y.Z.md
315
+ bundle exec rake build
316
+ gem install pkg/bugsage-X.Y.Z.gem
317
+ # unpack + install into a fresh rails app and smoke-test
318
+ git tag -a vX.Y.Z -m "BugSage vX.Y.Z"
319
+ git push origin master --follow-tags
320
+ gh release create vX.Y.Z --title "BugSage vX.Y.Z" --notes-file docs/releases/vX.Y.Z.md
321
+ gem push pkg/bugsage-X.Y.Z.gem
322
+ ```
323
+
324
+ ---
325
+
326
+ ## Abort criteria
327
+
328
+ Do **not** publish if any of the following are true:
329
+
330
+ - Specs or RuboCop fail
331
+ - Bundle audit reports a relevant unpatched vulnerability in a runtime dependency
332
+ - Fresh Rails app does not see the error page / dashboard with zero-config
333
+ - Version / changelog / tag disagree
334
+ - You cannot complete RubyGems MFA
335
+
336
+ ---
337
+
338
+ ## Related docs
339
+
340
+ - [CONTRIBUTING.md](../CONTRIBUTING.md)
341
+ - [CHANGELOG.md](../CHANGELOG.md)
342
+ - [Release notes — v0.2.0](releases/v0.2.0.md)
343
+ - [SECURITY.md](../SECURITY.md)
344
+ - [ARCHITECTURE.md](../ARCHITECTURE.md)
345
+ - [ROADMAP.md](../ROADMAP.md)
346
+ - RubyGems: [Make your own gem](https://guides.rubygems.org/make-your-own-gem/) · [Publishing](https://guides.rubygems.org/publishing/)
@@ -0,0 +1,181 @@
1
+ # Troubleshooting
2
+
3
+ Common issues when installing or using BugSage, and how to resolve them.
4
+
5
+ Related docs: [GettingStarted.md](GettingStarted.md) · [Configuration.md](Configuration.md) · [AI.md](AI.md)
6
+
7
+ ## Installation and loading
8
+
9
+ ### BugSage does nothing after `bundle install`
10
+
11
+ **Checks:**
12
+
13
+ 1. Confirm the gem is in the bundle:
14
+
15
+ ```bash
16
+ bundle show bugsage
17
+ ```
18
+
19
+ 2. Confirm you restarted `bin/rails server` after adding the gem.
20
+ 3. Confirm the environment is enabled (default: `development`, `test` only).
21
+
22
+ ```bash
23
+ echo $RAILS_ENV
24
+ echo $BUGSAGE_ENABLED_ENVIRONMENTS
25
+ ```
26
+
27
+ If you are in `staging` or `production`, add that environment explicitly:
28
+
29
+ ```bash
30
+ export BUGSAGE_ENABLED_ENVIRONMENTS=development,test,staging
31
+ ```
32
+
33
+ ### Changes to the gem path are not picked up
34
+
35
+ When using `gem "bugsage", path: "..."` or a GitHub branch:
36
+
37
+ ```bash
38
+ bundle update bugsage
39
+ bin/rails restart
40
+ # or stop and start bin/rails server
41
+ ```
42
+
43
+ Spring or another preloader can cache old code — stop Spring if needed: `bin/spring stop`.
44
+
45
+ ## Error page and dashboard
46
+
47
+ ### I still see the default Rails error page
48
+
49
+ Possible causes:
50
+
51
+ | Cause | Fix |
52
+ |-------|-----|
53
+ | Not in development | Use development, or set `show_error_page = true` for your env |
54
+ | BugSage disabled for this env | Add the env to `enabled_environments` |
55
+ | `show_error_page` forced off | Set `config.bugsage.show_error_page = true` |
56
+ | Exception handled by the app | BugSage only sees unhandled exceptions (and configured HTTP errors) |
57
+
58
+ ### `/bugsage` returns 404 or an empty app page
59
+
60
+ - Dashboard defaults to **development** only (`show_dashboard`).
61
+ - Ensure middleware is loading (restart server after install).
62
+ - Visit exactly `/bugsage` (trailing slash `/bugsage/` is also accepted).
63
+
64
+ ### Dashboard is empty after an API call from Postman
65
+
66
+ 1. Confirm `capture_errors` and `capture_http_errors` are enabled (both default to on when BugSage is enabled).
67
+ 2. Confirm the response status is **≥ 400**. Successful `200` responses are not captured as errors.
68
+ 3. Confirm you are looking at the **same Rails process** session (restarting the server clears the in-memory store).
69
+ 4. If you previously hit a BugSage middleware bug on body extraction, update to a build that iterates Rack bodies with `each` (not `map`).
70
+
71
+ Disable HTTP capture intentionally:
72
+
73
+ ```ruby
74
+ config.bugsage.capture_http_errors = false
75
+ ```
76
+
77
+ ### `NoMethodError` on `map` for `ActionDispatch::Response::RackBody`
78
+
79
+ Older BugSage builds extracted response bodies with `body.map`. Rails API responses often implement `each` only.
80
+
81
+ **Fix:** upgrade BugSage to a version that collects body parts with `each`, then `bundle update bugsage` and restart.
82
+
83
+ ## AI issues
84
+
85
+ ### AI panel does not appear
86
+
87
+ 1. Export a key in the **same terminal** that runs Rails:
88
+
89
+ ```bash
90
+ export OPENAI_API_KEY=sk-...
91
+ # or
92
+ export CURSOR_API_KEY=crsr_...
93
+ bin/rails server
94
+ ```
95
+
96
+ 2. Confirm `config.bugsage.ai_enabled` is not `false`.
97
+ 3. Confirm BugSage is enabled for the current environment.
98
+
99
+ ### Quick Fix fails or times out
100
+
101
+ Look for:
102
+
103
+ ```text
104
+ [BugSage] AI enhancement failed: ...
105
+ ```
106
+
107
+ in the Rails log or server terminal.
108
+
109
+ | Symptom | Likely cause | What to try |
110
+ |---------|--------------|-------------|
111
+ | Auth / 401 errors | Invalid or expired key | Rotate the key; confirm prefix (`sk-` vs `crsr_`) |
112
+ | Timeouts with Cursor | Cloud Agent duration | Raise `ai_timeout` (Cursor uses at least 90s) |
113
+ | Wrong provider | Mis-detected key | Set `config.bugsage.ai_provider = :openai` or `:cursor` |
114
+ | Rate limits | Provider quota | Retry later or switch providers |
115
+
116
+ ```ruby
117
+ config.bugsage.ai_timeout = 120
118
+ config.bugsage.ai_provider = :cursor
119
+ ```
120
+
121
+ ### Chat reply does not change **Apply AI to Codebase**
122
+
123
+ Chat must return a structured `code_patch` in the response. If the model only returns prose, the apply button keeps the previous Quick Fix patch.
124
+
125
+ Ask explicitly, for example: “Update the code_patch to comment out line N instead of deleting it.”
126
+
127
+ ### Apply fix does nothing / is forbidden
128
+
129
+ `/bugsage/apply-fix` is allowed in **development** and **test** only. It will not write files in production-like environments.
130
+
131
+ ## Inline console
132
+
133
+ ### Console is missing
134
+
135
+ `show_inline_console` defaults to **development** only. Enable it explicitly if needed:
136
+
137
+ ```ruby
138
+ config.bugsage.show_inline_console = true
139
+ ```
140
+
141
+ Evaluate carefully — the console runs Ruby in the application process.
142
+
143
+ ## Configuration not applying
144
+
145
+ 1. Prefer `config/initializers/bugsage.rb` with:
146
+
147
+ ```ruby
148
+ Rails.application.configure do |config|
149
+ config.bugsage.ai_enabled = false
150
+ end
151
+ ```
152
+
153
+ 2. Restart the server after edits.
154
+ 3. Remember: `BUGSAGE_ENABLED_ENVIRONMENTS` can override enabled environments at boot via auto-configuration.
155
+
156
+ ## Logging and inspection
157
+
158
+ When diagnosing capture or AI failures, check:
159
+
160
+ - BugSage HTML error page
161
+ - `http://localhost:3000/bugsage`
162
+ - `log/development.log`
163
+ - The terminal running `bin/rails server`
164
+ - `[BugSage] AI enhancement failed: ...` warnings
165
+
166
+ ## Still stuck?
167
+
168
+ 1. Confirm Ruby `>= 3.2` and a supported Rails app.
169
+ 2. Run the gem’s own checks if developing locally:
170
+
171
+ ```bash
172
+ bundle exec rake
173
+ ```
174
+
175
+ 3. Open a GitHub issue with:
176
+ - BugSage version or Git commit SHA
177
+ - Ruby / Rails versions
178
+ - Steps to reproduce
179
+ - Relevant logs (redact secrets)
180
+
181
+ For vulnerabilities, use [SECURITY.md](../SECURITY.md) instead of a public issue.
Binary file
Binary file
Binary file
Binary file
Binary file