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.
- checksums.yaml +7 -0
- data/ARCHITECTURE.md +442 -0
- data/CHANGELOG.md +28 -0
- data/CODE_OF_CONDUCT.md +10 -0
- data/CONTRIBUTING.md +301 -0
- data/LICENSE.txt +21 -0
- data/README.md +344 -0
- data/ROADMAP.md +217 -0
- data/SECURITY.md +83 -0
- data/docs/AI.md +167 -0
- data/docs/Configuration.md +168 -0
- data/docs/GettingStarted.md +146 -0
- data/docs/RELEASE_CHECKLIST.md +346 -0
- data/docs/Troubleshooting.md +181 -0
- data/docs/images/BadRequest.png +0 -0
- data/docs/images/BadRequest2.png +0 -0
- data/docs/images/BugSage_Logo.png +0 -0
- data/docs/images/BugSage_Social_Preview.png +0 -0
- data/docs/images/NoMethodError.png +0 -0
- data/docs/images/NoMethodError2.png +0 -0
- data/docs/images/README.md +38 -0
- data/docs/releases/README.md +21 -0
- data/docs/releases/v0.2.0.md +40 -0
- data/exe/bugsage +7 -0
- data/lib/bugsage/ai_analyzer.rb +145 -0
- data/lib/bugsage/ai_chat.rb +388 -0
- data/lib/bugsage/ai_context.rb +69 -0
- data/lib/bugsage/ai_panel.rb +708 -0
- data/lib/bugsage/ai_support.rb +36 -0
- data/lib/bugsage/auto_configurator.rb +97 -0
- data/lib/bugsage/cli.rb +59 -0
- data/lib/bugsage/code_context.rb +81 -0
- data/lib/bugsage/code_patch.rb +147 -0
- data/lib/bugsage/configuration.rb +149 -0
- data/lib/bugsage/console_context.rb +51 -0
- data/lib/bugsage/cursor_client.rb +165 -0
- data/lib/bugsage/dashboard.rb +627 -0
- data/lib/bugsage/editor_links.rb +34 -0
- data/lib/bugsage/error_page.rb +298 -0
- data/lib/bugsage/exception_handler.rb +66 -0
- data/lib/bugsage/exception_support.rb +95 -0
- data/lib/bugsage/exceptions_app.rb +31 -0
- data/lib/bugsage/fix_applicator.rb +107 -0
- data/lib/bugsage/formatter.rb +37 -0
- data/lib/bugsage/http_error_capture.rb +104 -0
- data/lib/bugsage/http_response_error.rb +14 -0
- data/lib/bugsage/inline_console.rb +226 -0
- data/lib/bugsage/installation.rb +94 -0
- data/lib/bugsage/installer.rb +66 -0
- data/lib/bugsage/json_endpoint.rb +34 -0
- data/lib/bugsage/locales/en.yml +439 -0
- data/lib/bugsage/middleware.rb +152 -0
- data/lib/bugsage/openai_client.rb +103 -0
- data/lib/bugsage/page_actions.rb +255 -0
- data/lib/bugsage/railtie.rb +49 -0
- data/lib/bugsage/request_context.rb +56 -0
- data/lib/bugsage/rule.rb +271 -0
- data/lib/bugsage/session_clear.rb +35 -0
- data/lib/bugsage/store.rb +60 -0
- data/lib/bugsage/suggestion.rb +58 -0
- data/lib/bugsage/trace_cleaner.rb +24 -0
- data/lib/bugsage/translations.rb +85 -0
- data/lib/bugsage/version.rb +5 -0
- data/lib/bugsage.rb +65 -0
- data/lib/generators/bugsage/install/install_generator.rb +21 -0
- data/lib/generators/bugsage/install/templates/bugsage.rb +22 -0
- data/scripts/publish-github-release.sh +38 -0
- data/sig/bugsage.rbs +4 -0
- metadata +157 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Bugsage
|
|
4
|
+
module AiContext
|
|
5
|
+
module_function
|
|
6
|
+
|
|
7
|
+
def set(exception:, suggestion:, context:)
|
|
8
|
+
@exception = exception
|
|
9
|
+
@suggestion = suggestion
|
|
10
|
+
@context = context || {}
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def load_from_event(event)
|
|
14
|
+
return false unless event
|
|
15
|
+
|
|
16
|
+
klass = safe_constantize(event[:exception_class])
|
|
17
|
+
message = event[:exception_message].to_s
|
|
18
|
+
message = event[:root_cause].to_s if message.empty?
|
|
19
|
+
|
|
20
|
+
set(
|
|
21
|
+
exception: klass.new(message),
|
|
22
|
+
suggestion: suggestion_from_event(event),
|
|
23
|
+
context: event[:context] || {}
|
|
24
|
+
)
|
|
25
|
+
true
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def clear!
|
|
29
|
+
@exception = nil
|
|
30
|
+
@suggestion = nil
|
|
31
|
+
@context = {}
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
def available?
|
|
35
|
+
!@exception.nil? && !@suggestion.nil?
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
def current
|
|
39
|
+
return nil unless available?
|
|
40
|
+
|
|
41
|
+
{
|
|
42
|
+
exception: @exception,
|
|
43
|
+
suggestion: @suggestion,
|
|
44
|
+
context: @context
|
|
45
|
+
}
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def suggestion_from_event(event)
|
|
49
|
+
Suggestion.new(
|
|
50
|
+
issue: event[:issue],
|
|
51
|
+
location: event[:location],
|
|
52
|
+
root_cause: event[:root_cause],
|
|
53
|
+
fixes: event[:fixes] || [],
|
|
54
|
+
confidence: event[:confidence],
|
|
55
|
+
source: event[:source] || :rules,
|
|
56
|
+
ai_notes: event[:ai_notes],
|
|
57
|
+
code_patch: event[:code_patch]
|
|
58
|
+
)
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def safe_constantize(name)
|
|
62
|
+
return StandardError if name.to_s.strip.empty?
|
|
63
|
+
|
|
64
|
+
Object.const_get(name)
|
|
65
|
+
rescue NameError
|
|
66
|
+
StandardError
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
end
|