ask-rails 0.2.5 → 0.6.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 +34 -24
- data/README.md +38 -13
- data/lib/ask/rails/generators/install/install_generator.rb +45 -0
- data/lib/ask/rails/generators/install/templates/application_agent.rb +26 -0
- data/lib/ask/rails/generators/install/templates/audit_log_migration.rb +19 -0
- data/lib/ask/rails/generators/install/templates/initializer.rb +27 -0
- data/lib/ask/rails/generators/install/templates/state_migration.rb +18 -0
- data/lib/ask/rails/railtie.rb +1 -18
- data/lib/ask/rails/version.rb +1 -1
- data/lib/ask/rails.rb +1 -70
- data/lib/generators/ask/install/templates/audit_log_migration.rb +16 -0
- data/lib/generators/ask/install/templates/initializer.rb +19 -0
- data/lib/generators/ask/install/templates/state_migration.rb +15 -0
- data/lib/generators/ask/install_generator.rb +39 -0
- metadata +13 -78
- data/lib/ask/rails/configuration.rb +0 -19
- data/lib/ask/rails/engine.rb +0 -11
- data/lib/ask/rails/persistence.rb +0 -35
- data/lib/ask/rails/service_discovery.rb +0 -48
- data/lib/ask/rails/tool.rb +0 -11
- data/lib/ask/rails/tools/query_database.rb +0 -72
- data/lib/ask/rails/tools/read_file.rb +0 -24
- data/lib/ask/rails/tools/read_log.rb +0 -118
- data/lib/ask/rails/tools/read_model.rb +0 -73
- data/lib/ask/rails/tools/read_routes.rb +0 -21
- data/lib/ask/rails/tools/run_command.rb +0 -20
- data/lib/ask/rails/tools/search_codebase.rb +0 -22
- data/lib/ask/skills/rails.db_debug/SKILL.md +0 -118
- data/lib/ask/skills/rails.deploy_pipeline/SKILL.md +0 -125
- data/lib/ask/skills/rails.route_trouble/SKILL.md +0 -127
- data/lib/generators/ask/rails/install/install_generator.rb +0 -29
- data/lib/generators/ask/rails/install/templates/initializer.rb +0 -5
- data/lib/generators/ask/rails/install/templates/migration.rb +0 -12
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 87296c9e940bcd34d48e640c3a13c3e3d634b57abf253c434d0919b1dc3388bc
|
|
4
|
+
data.tar.gz: b8edd3def1dfa96b41d6af0dd842bebb724ac9909c8728d5c8a193a3956e83be
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4533e9675014317d48c973bcfa23dd30a996d24f9f5e734060c37250735cdf0569df6b38ed2bb60c3a6c6d0dfdb8cf814869d5b628a9f0e37a8f5f91616f8347
|
|
7
|
+
data.tar.gz: 13fc4f80420ad209ab5e531d254883858acb6e8ac28d7806bac514afcc58c278df79a3c7026dfa69a49f20fbd70fa7ef0ac5ecada3255afedb3d23c338dcff2d
|
data/CHANGELOG.md
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
|
-
## [0.
|
|
1
|
+
## [0.6.0] — 2026-07-29
|
|
2
|
+
|
|
3
|
+
### Added
|
|
4
|
+
|
|
5
|
+
- **`ask_state` migration in install generator** — `rails generate ask:install` now creates `db/migrate/create_ask_state.rb` with a shared key-value table for agent sessions and graph checkpoints.
|
|
6
|
+
|
|
7
|
+
- **Standard Rails generator path** — Generator moved to `lib/generators/ask/install_generator.rb` for automatic Rails discovery. Run `rails generate ask:install` with no additional configuration.
|
|
2
8
|
|
|
3
9
|
### Changed
|
|
4
|
-
|
|
5
|
-
|
|
10
|
+
|
|
11
|
+
- Generator creates two migrations with unique timestamps: `ask_state` first, then `ask_audit_logs`.
|
|
12
|
+
|
|
13
|
+
### Tested
|
|
14
|
+
|
|
15
|
+
- `rails generate ask:install` tested in production Rails app (kawibot) — creates initializer and both migrations.
|
|
16
|
+
- Migrations run successfully against PostgreSQL.
|
|
17
|
+
|
|
18
|
+
## [0.5.0] — 2026-07-26
|
|
6
19
|
|
|
7
20
|
### Added
|
|
8
|
-
- `Ask::Rails::Engine` — Rails engine for autoloading and generator discovery
|
|
9
|
-
- Skills directory with methodology skills (rails.db_debug, rails.deploy_pipeline, rails.route_trouble)
|
|
10
|
-
- Gemspec metadata for Rubygems discovery
|
|
11
21
|
|
|
12
|
-
|
|
22
|
+
- **Audit log migration in install generator** — `rails generate ask_rails:install` now creates `db/migrate/create_ask_audit_logs.rb` with `if_not_exists: true`.
|
|
23
|
+
Table schema: `session_id`, `event_type`, `jsonb data`, `timestamp`, `created_at`, `updated_at`. Indexed on `[session_id, event_type]` and `timestamp`.
|
|
13
24
|
|
|
14
|
-
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Install generator now includes `::Rails::Generators::Migration` for `migration_template` support.
|
|
28
|
+
|
|
29
|
+
## [0.4.0] — 2026-07-26
|
|
15
30
|
|
|
16
31
|
### Added
|
|
17
|
-
- `Ask::Rails::QueryDatabase` — read-only SQL queries via ActiveRecord with auto-LIMIT,
|
|
18
|
-
binary column handling, and production write guards
|
|
19
|
-
- `Ask::Rails::ReadModel` — structured model introspection returning columns, associations,
|
|
20
|
-
validators, and primary keys; supports detail filtering
|
|
21
|
-
- `Ask::Rails::ReadLog` — filtered log reading that tail-reads from end of file, supports
|
|
22
|
-
level filtering (ERROR/WARN/INFO/DEBUG), case-insensitive search, and automatically
|
|
23
|
-
detects log rotation files
|
|
24
32
|
|
|
25
|
-
|
|
33
|
+
- **ask-rails-harness** — new `Ask::Rails::Harness` module for configuring the Rails-facing agent harness. Separates ask-rb ecosystem configuration from Rails-specific agent harness settings.
|
|
34
|
+
|
|
35
|
+
### Changed
|
|
36
|
+
|
|
37
|
+
- `config/initializers/ask_rails.rb` now configures `Ask::Rails::Harness` instead of `Ask::Rails`.
|
|
38
|
+
|
|
39
|
+
## [0.1.0] — 2026-07-26
|
|
26
40
|
|
|
27
41
|
### Added
|
|
28
|
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
-
|
|
32
|
-
- AR Persistence — `Ask::Rails::Persistence` saves/loads session state to database
|
|
33
|
-
- Rails Tools — `ReadFile`, `RunCommand`, `SearchCodebase`, `ReadRoutes` (Rails.root-aware)
|
|
34
|
-
- Generators — `rails generate ask_rails:install` creates migration, initializer, `app/tools/`
|
|
35
|
-
- Dependencies: rails >= 7.1, ask-tools, ask-tools-shell, ask-agent, ask-auth
|
|
42
|
+
|
|
43
|
+
- Initial release of `ask-rails` — Rails integration for the ask-rb ecosystem.
|
|
44
|
+
- **Install generator** — `rails generate ask:install` creates `config/initializers/ask.rb`, `app/agents/application_agent.rb`, and `app/agents/` directory.
|
|
45
|
+
- **Railtie** — Wires `Ask::Agent.logger` to `Rails.logger`, discovers agent definitions in `app/agents/`.
|
data/README.md
CHANGED
|
@@ -1,34 +1,59 @@
|
|
|
1
1
|
# ask-rails
|
|
2
2
|
|
|
3
|
-
Rails integration for the ask-rb ecosystem.
|
|
4
|
-
the ask-rb stack — provides a Railtie, AR session persistence, a session factory,
|
|
5
|
-
automatic service gem discovery, and generators.
|
|
3
|
+
Rails integration for the [ask-rb](https://github.com/ask-rb) ecosystem. Provides generators, file conventions, and railtie for using AI agents in your Rails app.
|
|
6
4
|
|
|
7
5
|
## Installation
|
|
8
6
|
|
|
9
7
|
```bash
|
|
10
8
|
bundle add ask-rails
|
|
11
|
-
rails generate
|
|
9
|
+
rails generate ask:install
|
|
12
10
|
```
|
|
13
11
|
|
|
12
|
+
This creates:
|
|
13
|
+
- `config/initializers/ask.rb` — agent configuration
|
|
14
|
+
- `app/agents/application_agent.rb` — base class for your agents
|
|
15
|
+
- `app/agents/` — directory for agent definitions
|
|
16
|
+
|
|
14
17
|
## Usage
|
|
15
18
|
|
|
19
|
+
Define an agent:
|
|
20
|
+
|
|
16
21
|
```ruby
|
|
17
|
-
#
|
|
18
|
-
|
|
19
|
-
|
|
22
|
+
# app/agents/support_bot.rb
|
|
23
|
+
class Agents::SupportBot < ApplicationAgent
|
|
24
|
+
model "gpt-4o"
|
|
25
|
+
system_prompt "You help users with support questions."
|
|
26
|
+
|
|
27
|
+
tool :bash
|
|
28
|
+
tool :read
|
|
29
|
+
tool :grep
|
|
30
|
+
end
|
|
20
31
|
```
|
|
21
32
|
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
Run it:
|
|
34
|
+
|
|
35
|
+
```ruby
|
|
36
|
+
agent = Ask::Agent.new("support_bot")
|
|
37
|
+
response = agent.run("Find all open issues in the codebase")
|
|
38
|
+
puts response
|
|
39
|
+
```
|
|
24
40
|
|
|
25
|
-
|
|
41
|
+
Or use `Ask.chat` for one-off conversations:
|
|
26
42
|
|
|
27
|
-
```
|
|
28
|
-
|
|
29
|
-
bundle exec rake test
|
|
43
|
+
```ruby
|
|
44
|
+
Ask.chat("Summarize this article: #{text}")
|
|
30
45
|
```
|
|
31
46
|
|
|
47
|
+
## Configuration
|
|
48
|
+
|
|
49
|
+
API keys are resolved automatically by `Ask::Auth`:
|
|
50
|
+
|
|
51
|
+
- **Environment variables:** `OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, etc.
|
|
52
|
+
- **Rails credentials:** `rails credentials:edit` → add `ask.openai`, `ask.anthropic`
|
|
53
|
+
- **File:** `~/.ask/credentials.yml`
|
|
54
|
+
|
|
55
|
+
No manual credential setup is required.
|
|
56
|
+
|
|
32
57
|
## License
|
|
33
58
|
|
|
34
59
|
MIT
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
require "rails/generators/active_record"
|
|
5
|
+
|
|
6
|
+
module Ask
|
|
7
|
+
module Rails
|
|
8
|
+
module Generators
|
|
9
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
10
|
+
include ::Rails::Generators::Migration
|
|
11
|
+
|
|
12
|
+
source_root File.expand_path("templates", __dir__)
|
|
13
|
+
|
|
14
|
+
desc "Sets up ask-rb for Rails — creates initializer, agents directory, state and audit log migrations"
|
|
15
|
+
|
|
16
|
+
def create_initializer
|
|
17
|
+
template "initializer.rb", "config/initializers/ask.rb"
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def create_application_agent
|
|
21
|
+
template "application_agent.rb", "app/agents/application_agent.rb"
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
def create_agents_directory
|
|
25
|
+
empty_directory "app/agents"
|
|
26
|
+
create_file "app/agents/.keep", "" unless options[:skip_keep]
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
def create_state_migration
|
|
30
|
+
migration_template "state_migration.rb", "db/migrate/create_ask_state.rb"
|
|
31
|
+
end
|
|
32
|
+
|
|
33
|
+
def create_audit_log_migration
|
|
34
|
+
migration_template "audit_log_migration.rb", "db/migrate/create_ask_audit_logs.rb"
|
|
35
|
+
end
|
|
36
|
+
|
|
37
|
+
private
|
|
38
|
+
|
|
39
|
+
def migration_version
|
|
40
|
+
"[#{ActiveRecord::Migration.current_version}]"
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Base class for your application's AI agents.
|
|
4
|
+
#
|
|
5
|
+
# Subclass this to define agents:
|
|
6
|
+
#
|
|
7
|
+
# class Agents::SupportBot < ApplicationAgent
|
|
8
|
+
# model "gpt-4o"
|
|
9
|
+
# system_prompt "You help users with support questions."
|
|
10
|
+
#
|
|
11
|
+
# tool :search_knowledge_base
|
|
12
|
+
# end
|
|
13
|
+
#
|
|
14
|
+
# Then run:
|
|
15
|
+
# agent = Ask::Agent.new("support_bot")
|
|
16
|
+
# agent.run("How do I reset my password?")
|
|
17
|
+
#
|
|
18
|
+
class ApplicationAgent < Ask::Agent::Definition
|
|
19
|
+
# Default instructions — override in subclasses
|
|
20
|
+
system_prompt "You are a helpful assistant."
|
|
21
|
+
|
|
22
|
+
# Uncomment to add built-in tools:
|
|
23
|
+
# tool :bash
|
|
24
|
+
# tool :read
|
|
25
|
+
# tool :grep
|
|
26
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Migration for ask-agent's audit log table.
|
|
4
|
+
# This table records session events (tool calls, errors, token usage, etc.)
|
|
5
|
+
# from every agent that has audit_log configured.
|
|
6
|
+
class CreateAskAuditLogs < ActiveRecord::Migration[<%= migration_version %>]
|
|
7
|
+
def change
|
|
8
|
+
create_table :ask_audit_logs, if_not_exists: true do |t|
|
|
9
|
+
t.string :session_id, null: false
|
|
10
|
+
t.string :event_type, null: false
|
|
11
|
+
t.jsonb :data, default: {}
|
|
12
|
+
t.datetime :timestamp, null: false
|
|
13
|
+
t.timestamps
|
|
14
|
+
|
|
15
|
+
t.index [:session_id, :event_type]
|
|
16
|
+
t.index :timestamp
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Ask Agent Configuration
|
|
4
|
+
# ========================
|
|
5
|
+
#
|
|
6
|
+
# API keys are resolved automatically by Ask::Auth:
|
|
7
|
+
# - Environment variables: OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.
|
|
8
|
+
# - Rails credentials: rails credentials:edit → ask.openai, ask.anthropic
|
|
9
|
+
# - ~/.ask/credentials.yml
|
|
10
|
+
#
|
|
11
|
+
# See https://github.com/ask-rb/ask-auth for details.
|
|
12
|
+
|
|
13
|
+
# Shared key-value state store for agent sessions and graph checkpoints.
|
|
14
|
+
# Uses the ask_state table created by the migration.
|
|
15
|
+
ASK_STATE = Ask::State::PostgreSQL.new(
|
|
16
|
+
table_name: :ask_state
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
Ask::Agent.configure do |config|
|
|
20
|
+
# State persistence for agent sessions
|
|
21
|
+
config.state = ASK_STATE
|
|
22
|
+
|
|
23
|
+
# Audit log for session events
|
|
24
|
+
config.audit_log = { adapter: :active_record }
|
|
25
|
+
|
|
26
|
+
# config.default_model = "gpt-4o"
|
|
27
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Migration for ask-rb's shared key-value state table.
|
|
4
|
+
# Used by ask-agent (session persistence) and ask-graph (workflow checkpoints).
|
|
5
|
+
# This single table serves both components — keys are namespaced by convention.
|
|
6
|
+
class CreateAskState < ActiveRecord::Migration[<%= migration_version %>]
|
|
7
|
+
def change
|
|
8
|
+
create_table :ask_state do |t|
|
|
9
|
+
t.string :key, null: false
|
|
10
|
+
t.jsonb :value, null: false, default: {}
|
|
11
|
+
t.datetime :expires_at
|
|
12
|
+
t.timestamps
|
|
13
|
+
|
|
14
|
+
t.index :key, unique: true
|
|
15
|
+
t.index :expires_at
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
data/lib/ask/rails/railtie.rb
CHANGED
|
@@ -3,25 +3,8 @@
|
|
|
3
3
|
module Ask
|
|
4
4
|
module Rails
|
|
5
5
|
class Railtie < ::Rails::Railtie
|
|
6
|
-
rake_tasks do
|
|
7
|
-
# Load rake tasks if any
|
|
8
|
-
end
|
|
9
|
-
|
|
10
6
|
generators do
|
|
11
|
-
require_relative "
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
initializer "ask_rails.configure" do |app|
|
|
15
|
-
Ask::Rails.configuration.default_model ||= ENV["ASK_DEFAULT_MODEL"] || "gpt-4o"
|
|
16
|
-
Ask::Rails.configuration.max_turns ||= (ENV["ASK_MAX_TURNS"] || 25).to_i
|
|
17
|
-
end
|
|
18
|
-
|
|
19
|
-
initializer "ask_rails.discover_tools", after: :eager_load_most do
|
|
20
|
-
Ask::Rails.discover_tools!
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
initializer "ask_rails.discover_services", after: :eager_load_most do
|
|
24
|
-
Ask::Rails::ServiceDiscovery.discover!
|
|
7
|
+
require_relative "generators/install/install_generator"
|
|
25
8
|
end
|
|
26
9
|
end
|
|
27
10
|
end
|
data/lib/ask/rails/version.rb
CHANGED
data/lib/ask/rails.rb
CHANGED
|
@@ -1,80 +1,11 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
require "rails"
|
|
4
3
|
require "ask/agent"
|
|
5
|
-
require "ask/auth"
|
|
6
4
|
|
|
7
5
|
module Ask
|
|
8
6
|
module Rails
|
|
9
|
-
class << self
|
|
10
|
-
def configure
|
|
11
|
-
yield configuration
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def configuration
|
|
15
|
-
@configuration ||= Configuration.new
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
def agent_session(**extra)
|
|
19
|
-
tools = configuration.tools.map { |t| t.is_a?(Class) ? t.new : t }
|
|
20
|
-
prompt = extra.delete(:system_prompt) || configuration.system_prompt || default_system_prompt
|
|
21
|
-
|
|
22
|
-
Ask::Agent::Session.new(
|
|
23
|
-
model: configuration.default_model,
|
|
24
|
-
max_turns: configuration.max_turns,
|
|
25
|
-
system_prompt: prompt,
|
|
26
|
-
tools: tools,
|
|
27
|
-
persistence: configuration.persistence_adapter,
|
|
28
|
-
**extra
|
|
29
|
-
)
|
|
30
|
-
end
|
|
31
|
-
|
|
32
|
-
def discover_tools!
|
|
33
|
-
self.configuration.tools = Ask::Tools::Shell::TOOLS.map(&:new) + discovered_rails_tools
|
|
34
|
-
end
|
|
35
|
-
|
|
36
|
-
def root
|
|
37
|
-
@root ||= Pathname.new(File.expand_path("..", __dir__))
|
|
38
|
-
end
|
|
39
|
-
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
def discovered_rails_tools
|
|
43
|
-
tools = []
|
|
44
|
-
files = Dir[::Rails.root.join("app", "tools", "*.rb")]
|
|
45
|
-
files.each do |f|
|
|
46
|
-
require f
|
|
47
|
-
klass = File.basename(f, ".rb").camelize.constantize rescue next
|
|
48
|
-
tools << klass if klass < Ask::Rails::Tool
|
|
49
|
-
end
|
|
50
|
-
tools
|
|
51
|
-
rescue
|
|
52
|
-
tools
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def default_system_prompt
|
|
56
|
-
<<~PROMPT
|
|
57
|
-
You are a Ruby on Rails software engineer.
|
|
58
|
-
You have direct access to the application's code, database, and runtime.
|
|
59
|
-
Use your tools to inspect and modify the codebase.
|
|
60
|
-
Once you have enough information, stop calling tools and give your answer.
|
|
61
|
-
PROMPT
|
|
62
|
-
end
|
|
63
|
-
end
|
|
64
7
|
end
|
|
65
8
|
end
|
|
66
9
|
|
|
67
10
|
require_relative "rails/version"
|
|
68
|
-
require_relative "rails/
|
|
69
|
-
require_relative "rails/configuration"
|
|
70
|
-
require_relative "rails/railtie"
|
|
71
|
-
require_relative "rails/persistence"
|
|
72
|
-
require_relative "rails/service_discovery"
|
|
73
|
-
require_relative "rails/tool"
|
|
74
|
-
require_relative "rails/tools/read_file"
|
|
75
|
-
require_relative "rails/tools/run_command"
|
|
76
|
-
require_relative "rails/tools/search_codebase"
|
|
77
|
-
require_relative "rails/tools/read_routes"
|
|
78
|
-
require_relative "rails/tools/query_database"
|
|
79
|
-
require_relative "rails/tools/read_model"
|
|
80
|
-
require_relative "rails/tools/read_log"
|
|
11
|
+
require_relative "rails/railtie" if defined?(::Rails::Railtie)
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateAskAuditLogs < ActiveRecord::Migration[8.1]
|
|
4
|
+
def change
|
|
5
|
+
create_table :ask_audit_logs, if_not_exists: true do |t|
|
|
6
|
+
t.string :session_id, null: false
|
|
7
|
+
t.string :event_type, null: false
|
|
8
|
+
t.jsonb :data, default: {}
|
|
9
|
+
t.datetime :timestamp, null: false
|
|
10
|
+
t.timestamps
|
|
11
|
+
|
|
12
|
+
t.index [:session_id, :event_type]
|
|
13
|
+
t.index :timestamp
|
|
14
|
+
end
|
|
15
|
+
end
|
|
16
|
+
end
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# Ask Agent Configuration
|
|
4
|
+
# ========================
|
|
5
|
+
#
|
|
6
|
+
# API keys are resolved automatically by Ask::Auth:
|
|
7
|
+
# - Environment variables: OPENAI_API_KEY, ANTHROPIC_API_KEY, etc.
|
|
8
|
+
# - Rails credentials: rails credentials:edit → ask.openai, ask.anthropic
|
|
9
|
+
# - ~/.ask/credentials.yml
|
|
10
|
+
#
|
|
11
|
+
# See https://github.com/ask-rb/ask-auth for details.
|
|
12
|
+
|
|
13
|
+
Ask::Agent.configure do |config|
|
|
14
|
+
# Enable audit logging to the ask_audit_logs table
|
|
15
|
+
# config.audit_log = { adapter: :active_record }
|
|
16
|
+
|
|
17
|
+
# Optional: set a default model
|
|
18
|
+
# config.default_model = "gpt-4o"
|
|
19
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
class CreateAskState < ActiveRecord::Migration[8.1]
|
|
4
|
+
def change
|
|
5
|
+
create_table :ask_state do |t|
|
|
6
|
+
t.string :key, null: false
|
|
7
|
+
t.jsonb :value, null: false, default: {}
|
|
8
|
+
t.datetime :expires_at
|
|
9
|
+
t.timestamps
|
|
10
|
+
|
|
11
|
+
t.index :key, unique: true
|
|
12
|
+
t.index :expires_at
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
end
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "rails/generators"
|
|
4
|
+
require "rails/generators/active_record"
|
|
5
|
+
|
|
6
|
+
module Ask
|
|
7
|
+
module Generators
|
|
8
|
+
class InstallGenerator < ::Rails::Generators::Base
|
|
9
|
+
include ::Rails::Generators::Migration
|
|
10
|
+
|
|
11
|
+
source_root File.expand_path("install/templates", __dir__)
|
|
12
|
+
|
|
13
|
+
desc "Sets up ask-rb for Rails — creates initializer, state and audit log migrations"
|
|
14
|
+
|
|
15
|
+
def create_initializer
|
|
16
|
+
template "initializer.rb", "config/initializers/ask.rb"
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def create_state_migration
|
|
20
|
+
template "state_migration.rb", "db/migrate/#{next_migration_number}_create_ask_state.rb"
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def create_audit_log_migration
|
|
24
|
+
template "audit_log_migration.rb", "db/migrate/#{next_migration_number}_create_ask_audit_logs.rb"
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
private
|
|
28
|
+
|
|
29
|
+
def next_migration_number
|
|
30
|
+
# Rails requires exactly YYYYMMDDHHMMSS format
|
|
31
|
+
@migration_suffix ||= 0
|
|
32
|
+
now = Time.now.utc.strftime("%Y%m%d%H%M")
|
|
33
|
+
"#{now}#{format('%02d', @migration_suffix)}"
|
|
34
|
+
ensure
|
|
35
|
+
@migration_suffix = (@migration_suffix || 0) + 1
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: ask-rails
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Kaka Ruto
|
|
@@ -23,34 +23,6 @@ dependencies:
|
|
|
23
23
|
- - ">="
|
|
24
24
|
- !ruby/object:Gem::Version
|
|
25
25
|
version: '7.1'
|
|
26
|
-
- !ruby/object:Gem::Dependency
|
|
27
|
-
name: ask-tools
|
|
28
|
-
requirement: !ruby/object:Gem::Requirement
|
|
29
|
-
requirements:
|
|
30
|
-
- - ">="
|
|
31
|
-
- !ruby/object:Gem::Version
|
|
32
|
-
version: '0.1'
|
|
33
|
-
type: :runtime
|
|
34
|
-
prerelease: false
|
|
35
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
36
|
-
requirements:
|
|
37
|
-
- - ">="
|
|
38
|
-
- !ruby/object:Gem::Version
|
|
39
|
-
version: '0.1'
|
|
40
|
-
- !ruby/object:Gem::Dependency
|
|
41
|
-
name: ask-tools-shell
|
|
42
|
-
requirement: !ruby/object:Gem::Requirement
|
|
43
|
-
requirements:
|
|
44
|
-
- - ">="
|
|
45
|
-
- !ruby/object:Gem::Version
|
|
46
|
-
version: '0.1'
|
|
47
|
-
type: :runtime
|
|
48
|
-
prerelease: false
|
|
49
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
50
|
-
requirements:
|
|
51
|
-
- - ">="
|
|
52
|
-
- !ruby/object:Gem::Version
|
|
53
|
-
version: '0.1'
|
|
54
26
|
- !ruby/object:Gem::Dependency
|
|
55
27
|
name: ask-agent
|
|
56
28
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -65,34 +37,6 @@ dependencies:
|
|
|
65
37
|
- - ">="
|
|
66
38
|
- !ruby/object:Gem::Version
|
|
67
39
|
version: '0.1'
|
|
68
|
-
- !ruby/object:Gem::Dependency
|
|
69
|
-
name: ask-auth
|
|
70
|
-
requirement: !ruby/object:Gem::Requirement
|
|
71
|
-
requirements:
|
|
72
|
-
- - ">="
|
|
73
|
-
- !ruby/object:Gem::Version
|
|
74
|
-
version: '0.1'
|
|
75
|
-
type: :runtime
|
|
76
|
-
prerelease: false
|
|
77
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
78
|
-
requirements:
|
|
79
|
-
- - ">="
|
|
80
|
-
- !ruby/object:Gem::Version
|
|
81
|
-
version: '0.1'
|
|
82
|
-
- !ruby/object:Gem::Dependency
|
|
83
|
-
name: sqlite3
|
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
|
85
|
-
requirements:
|
|
86
|
-
- - ">="
|
|
87
|
-
- !ruby/object:Gem::Version
|
|
88
|
-
version: '2.0'
|
|
89
|
-
type: :development
|
|
90
|
-
prerelease: false
|
|
91
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
92
|
-
requirements:
|
|
93
|
-
- - ">="
|
|
94
|
-
- !ruby/object:Gem::Version
|
|
95
|
-
version: '2.0'
|
|
96
40
|
- !ruby/object:Gem::Dependency
|
|
97
41
|
name: minitest
|
|
98
42
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -135,8 +79,8 @@ dependencies:
|
|
|
135
79
|
- - "~>"
|
|
136
80
|
- !ruby/object:Gem::Version
|
|
137
81
|
version: '13.0'
|
|
138
|
-
description:
|
|
139
|
-
|
|
82
|
+
description: Rails generators, file conventions, and railtie for using ask-agent in
|
|
83
|
+
Rails apps.
|
|
140
84
|
email:
|
|
141
85
|
- kaka@myrrlabs.com
|
|
142
86
|
executables: []
|
|
@@ -148,33 +92,24 @@ files:
|
|
|
148
92
|
- README.md
|
|
149
93
|
- lib/ask-rails.rb
|
|
150
94
|
- lib/ask/rails.rb
|
|
151
|
-
- lib/ask/rails/
|
|
152
|
-
- lib/ask/rails/
|
|
153
|
-
- lib/ask/rails/
|
|
95
|
+
- lib/ask/rails/generators/install/install_generator.rb
|
|
96
|
+
- lib/ask/rails/generators/install/templates/application_agent.rb
|
|
97
|
+
- lib/ask/rails/generators/install/templates/audit_log_migration.rb
|
|
98
|
+
- lib/ask/rails/generators/install/templates/initializer.rb
|
|
99
|
+
- lib/ask/rails/generators/install/templates/state_migration.rb
|
|
154
100
|
- lib/ask/rails/railtie.rb
|
|
155
|
-
- lib/ask/rails/service_discovery.rb
|
|
156
|
-
- lib/ask/rails/tool.rb
|
|
157
|
-
- lib/ask/rails/tools/query_database.rb
|
|
158
|
-
- lib/ask/rails/tools/read_file.rb
|
|
159
|
-
- lib/ask/rails/tools/read_log.rb
|
|
160
|
-
- lib/ask/rails/tools/read_model.rb
|
|
161
|
-
- lib/ask/rails/tools/read_routes.rb
|
|
162
|
-
- lib/ask/rails/tools/run_command.rb
|
|
163
|
-
- lib/ask/rails/tools/search_codebase.rb
|
|
164
101
|
- lib/ask/rails/version.rb
|
|
165
|
-
- lib/ask/
|
|
166
|
-
- lib/ask/
|
|
167
|
-
- lib/ask/
|
|
168
|
-
- lib/generators/ask/
|
|
169
|
-
- lib/generators/ask/rails/install/templates/initializer.rb
|
|
170
|
-
- lib/generators/ask/rails/install/templates/migration.rb
|
|
102
|
+
- lib/generators/ask/install/templates/audit_log_migration.rb
|
|
103
|
+
- lib/generators/ask/install/templates/initializer.rb
|
|
104
|
+
- lib/generators/ask/install/templates/state_migration.rb
|
|
105
|
+
- lib/generators/ask/install_generator.rb
|
|
171
106
|
homepage: https://github.com/ask-rb/ask-rails
|
|
172
107
|
licenses:
|
|
173
108
|
- MIT
|
|
174
109
|
metadata:
|
|
175
110
|
homepage_uri: https://github.com/ask-rb/ask-rails
|
|
176
111
|
source_code_uri: https://github.com/ask-rb/ask-rails
|
|
177
|
-
changelog_uri: https://github.com/ask-rb/ask-rails/blob/
|
|
112
|
+
changelog_uri: https://github.com/ask-rb/ask-rails/blob/main/CHANGELOG.md
|
|
178
113
|
rdoc_options: []
|
|
179
114
|
require_paths:
|
|
180
115
|
- lib
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Ask
|
|
4
|
-
module Rails
|
|
5
|
-
class Configuration
|
|
6
|
-
attr_accessor :default_model, :max_turns, :system_prompt,
|
|
7
|
-
:tool_concurrency, :persistence_adapter, :tools
|
|
8
|
-
|
|
9
|
-
def initialize
|
|
10
|
-
@default_model = "gpt-4o"
|
|
11
|
-
@max_turns = 25
|
|
12
|
-
@system_prompt = nil
|
|
13
|
-
@tool_concurrency = 5
|
|
14
|
-
@persistence_adapter = nil
|
|
15
|
-
@tools = []
|
|
16
|
-
end
|
|
17
|
-
end
|
|
18
|
-
end
|
|
19
|
-
end
|