rails_console_ai 0.22.0 → 0.23.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 +4 -4
- data/CHANGELOG.md +22 -0
- data/lib/generators/rails_console_ai/templates/initializer.rb +8 -4
- data/lib/rails_console_ai/channel/slack.rb +2 -1
- data/lib/rails_console_ai/configuration.rb +23 -0
- data/lib/rails_console_ai/context_builder.rb +14 -7
- data/lib/rails_console_ai/conversation_engine.rb +327 -104
- data/lib/rails_console_ai/executor.rb +19 -10
- data/lib/rails_console_ai/providers/bedrock.rb +2 -0
- data/lib/rails_console_ai/repl.rb +2 -2
- data/lib/rails_console_ai/skill_loader.rb +49 -0
- data/lib/rails_console_ai/slack_bot.rb +20 -16
- data/lib/rails_console_ai/tools/memory_tools.rb +22 -5
- data/lib/rails_console_ai/tools/model_tools.rb +28 -0
- data/lib/rails_console_ai/tools/registry.rb +61 -3
- data/lib/rails_console_ai/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 6f97d0243924a105c21ebd4a86049bef4fdda6ed76d738c1c2850244f8cb6e0e
|
|
4
|
+
data.tar.gz: 930e70d14ae27b0d87999b4625f299390bc928646e73417aef2fc5f7f46aaf5f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 17d56e01106acbeee8e1299c39e2fbcc3c0f3150922b977652f8857139d8ad7c481c13d080216f492833e22287df616eb4967a6d46162d39b618ac51e74bbeb4
|
|
7
|
+
data.tar.gz: 259216bdd4cf23d0b6c8634fad2d48d520eac0b4600d16697cdf176e55a3677a5a7975304697be2f36817bf04aaa0f7317459a7e9d79da591cfe49879398cca3
|
data/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,28 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
|
|
5
|
+
## [0.23.0]
|
|
6
|
+
|
|
7
|
+
- Add `save_skill` tool
|
|
8
|
+
- Add targeted single-memory recall to avoid extraneous results
|
|
9
|
+
- Summarize memory recall output
|
|
10
|
+
- Fix Bedrock blank content handling
|
|
11
|
+
- Improve debug output and fix `trim_outputs` in Bedrock provider
|
|
12
|
+
- Preserve activated skills in conversation without truncating
|
|
13
|
+
- Show executed code in Slack log
|
|
14
|
+
- Include columns in `describe_model` to reduce tool calls
|
|
15
|
+
- Show less error detail in Slack channel
|
|
16
|
+
- Show thinking text before `execute_code` prompt in console
|
|
17
|
+
- Allow code execution without safety guards
|
|
18
|
+
- Add Slack configuration option to prevent all users from executing code
|
|
19
|
+
- Detect LLM tool loops and break out
|
|
20
|
+
- Refactor output truncation to fix LLM not seeing all needed outputs
|
|
21
|
+
- Show cache usage in `display_usage`
|
|
22
|
+
- Fix `recall_output` forcing expansion in later turns
|
|
23
|
+
- Fix conversation debug to show "tool_result" instead of "user"
|
|
24
|
+
- Make `/context` and `!context` show the same as debug output
|
|
25
|
+
- Improve `!context` handling in Slack
|
|
26
|
+
|
|
5
27
|
## [0.22.0]
|
|
6
28
|
|
|
7
29
|
- Fix blank content block handling in Bedrock provider
|
|
@@ -29,9 +29,8 @@ RailsConsoleAi.configure do |config|
|
|
|
29
29
|
# config.local_model = 'qwen2.5:7b'
|
|
30
30
|
# config.local_api_key = nil
|
|
31
31
|
|
|
32
|
-
# Slack: which users the bot responds to (
|
|
33
|
-
# config.slack_allowed_usernames = ['alice', 'bob']
|
|
34
|
-
# config.slack_allowed_usernames = 'ALL' # everyone
|
|
32
|
+
# Slack: which users the bot responds to (legacy — prefer channels config below)
|
|
33
|
+
# config.slack_allowed_usernames = ['alice', 'bob']
|
|
35
34
|
|
|
36
35
|
# AWS Bedrock provider (uses AWS credential chain — no API key needed):
|
|
37
36
|
# config.provider = :bedrock
|
|
@@ -85,7 +84,12 @@ RailsConsoleAi.configure do |config|
|
|
|
85
84
|
|
|
86
85
|
# Per-channel settings (channel mode keys: 'slack', 'console'):
|
|
87
86
|
# config.channels = {
|
|
88
|
-
# 'slack'
|
|
87
|
+
# 'slack' => {
|
|
88
|
+
# 'allowed_usernames' => ['alice', 'bob'], # who can use the bot (or 'ALL')
|
|
89
|
+
# 'allow_code_execution' => ['alice'], # who can run code (nil = everyone)
|
|
90
|
+
# 'pinned_memory_tags' => ['sharding'],
|
|
91
|
+
# 'bypass_guards_for_methods' => ['ChangeApproval#approve_by!']
|
|
92
|
+
# },
|
|
89
93
|
# 'console' => { 'pinned_memory_tags' => [] }
|
|
90
94
|
# }
|
|
91
95
|
end
|
|
@@ -65,7 +65,8 @@ module RailsConsoleAi
|
|
|
65
65
|
# Don't post raw code/plan steps to Slack — non-technical users don't need to see Ruby
|
|
66
66
|
# But do log to STDOUT so server logs show what was generated/executed
|
|
67
67
|
@output_log.write("# Generated code:\n#{code}\n")
|
|
68
|
-
STDOUT.puts "#{@log_prefix} (code)
|
|
68
|
+
STDOUT.puts "#{@log_prefix} (code)"
|
|
69
|
+
code.each_line { |line| STDOUT.puts "#{@log_prefix} (code) #{line.rstrip}" }
|
|
69
70
|
end
|
|
70
71
|
|
|
71
72
|
def display_result_output(output)
|
|
@@ -71,6 +71,29 @@ module RailsConsoleAi
|
|
|
71
71
|
@user_extra_info[username.to_s.downcase]
|
|
72
72
|
end
|
|
73
73
|
|
|
74
|
+
# Look up a per-channel setting with backward compatibility.
|
|
75
|
+
# Falls back to top-level slack_* config when channels hash doesn't have the key.
|
|
76
|
+
def channel_setting(mode, key)
|
|
77
|
+
channel_cfg = @channels[mode.to_s] || {}
|
|
78
|
+
value = channel_cfg[key.to_s]
|
|
79
|
+
|
|
80
|
+
# Backward compatibility: slack_allowed_usernames → channels.slack.allowed_usernames
|
|
81
|
+
if value.nil? && mode.to_s == 'slack' && key.to_s == 'allowed_usernames'
|
|
82
|
+
value = @slack_allowed_usernames
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
value
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
# Check if a username is permitted by a channel setting.
|
|
89
|
+
# Returns true when the setting is nil (not configured = no restriction).
|
|
90
|
+
def username_allowed?(mode, key, username)
|
|
91
|
+
list = channel_setting(mode, key)
|
|
92
|
+
return true if list.nil?
|
|
93
|
+
normalized = Array(list).map(&:to_s).map(&:downcase)
|
|
94
|
+
normalized.include?('all') || normalized.include?(username.to_s.downcase)
|
|
95
|
+
end
|
|
96
|
+
|
|
74
97
|
def safety_guards
|
|
75
98
|
@safety_guards ||= begin
|
|
76
99
|
require 'rails_console_ai/safety_guards'
|
|
@@ -55,8 +55,9 @@ module RailsConsoleAi
|
|
|
55
55
|
You help them query data, debug issues, and understand their application.
|
|
56
56
|
|
|
57
57
|
You have tools available to introspect the app's database schema, models, and source code.
|
|
58
|
-
Use them as needed to write accurate queries. For example, call
|
|
59
|
-
|
|
58
|
+
Use them as needed to write accurate queries. For example, call list_models to see what
|
|
59
|
+
models exist, then describe_model to get columns, associations, and validations.
|
|
60
|
+
Use describe_table only for tables that have no corresponding model.
|
|
60
61
|
|
|
61
62
|
You also have an ask_user tool to ask the console user clarifying questions. Use it when
|
|
62
63
|
you need specific information to write accurate code — such as which user they are, which
|
|
@@ -66,7 +67,10 @@ module RailsConsoleAi
|
|
|
66
67
|
- save_memory: persist facts or procedures you learn about this codebase.
|
|
67
68
|
If a memory with the same name already exists, it will be updated in place.
|
|
68
69
|
- delete_memory: remove a memory by name
|
|
69
|
-
-
|
|
70
|
+
- recall_memory: retrieve a specific memory by name. Use when you see a relevant memory
|
|
71
|
+
in the Memories section and want its full details.
|
|
72
|
+
- recall_memories: search memories by keyword or tag. Use when you're not sure which
|
|
73
|
+
memory you need.
|
|
70
74
|
|
|
71
75
|
IMPORTANT: Check the Memories section below BEFORE answering. If a memory is relevant,
|
|
72
76
|
use recall_memories to get full details and apply that knowledge to your answer.
|
|
@@ -82,9 +86,12 @@ module RailsConsoleAi
|
|
|
82
86
|
(e.g. `api = SalesforceApi.new(step1)`).
|
|
83
87
|
- If the user asks you to provide code for them to run later (not execute now), put it
|
|
84
88
|
in a ```ruby code block in your text response.
|
|
85
|
-
You have skills —
|
|
86
|
-
|
|
87
|
-
|
|
89
|
+
You have skills — reusable procedures for specific operations:
|
|
90
|
+
- When a user's request matches an existing skill, call activate_skill to load the recipe
|
|
91
|
+
and enable its guard bypasses, then follow the recipe.
|
|
92
|
+
- When a user asks you to "create a skill" or "make a runbook", use save_skill to create
|
|
93
|
+
a new skill with a step-by-step recipe. Skills are procedures (how to do X); memories
|
|
94
|
+
are facts (what you learned about X). Do NOT use save_memory when asked to create a skill.
|
|
88
95
|
|
|
89
96
|
RULES:
|
|
90
97
|
- Give ONE concise answer. Do not offer multiple alternatives or variations.
|
|
@@ -176,7 +183,7 @@ module RailsConsoleAi
|
|
|
176
183
|
lines = ["## Memories"]
|
|
177
184
|
lines.concat(summaries)
|
|
178
185
|
lines << ""
|
|
179
|
-
lines << "Call recall_memories to get details before answering. Do NOT guess from the name alone."
|
|
186
|
+
lines << "Call recall_memory (by name) or recall_memories (by keyword) to get details before answering. Do NOT guess from the name alone."
|
|
180
187
|
lines.join("\n")
|
|
181
188
|
rescue => e
|
|
182
189
|
RailsConsoleAi.logger.debug("RailsConsoleAi: memory context failed: #{e.message}")
|