ask-rails 0.4.0 → 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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1a8258ca96d9513529bc1c0c9c54bd8e2492a110e48d90c9af3f53ca3aa24d9f
4
- data.tar.gz: 4a776f46230d7a87719d5a6e12154e90987f71f60af63707da686ba2cce20377
3
+ metadata.gz: 87296c9e940bcd34d48e640c3a13c3e3d634b57abf253c434d0919b1dc3388bc
4
+ data.tar.gz: b8edd3def1dfa96b41d6af0dd842bebb724ac9909c8728d5c8a193a3956e83be
5
5
  SHA512:
6
- metadata.gz: 894f5146923889fd014f1ac770c52eba2cfdc6d84fd546062c05ac85473f6e716e70a298761f25a19ea1b00ba60461aae3ab38889c05a95698d891320879cc86
7
- data.tar.gz: d58b94569c064b58493bd0a929cfb1dde3310a43c110c92474947c57e711f5a4e6d57ca596c389e73fcb4ee6bddeff7e8797bc5915ca8e4cbf94eadaf5f2353d
6
+ metadata.gz: 4533e9675014317d48c973bcfa23dd30a996d24f9f5e734060c37250735cdf0569df6b38ed2bb60c3a6c6d0dfdb8cf814869d5b628a9f0e37a8f5f91616f8347
7
+ data.tar.gz: 13fc4f80420ad209ab5e531d254883858acb6e8ac28d7806bac514afcc58c278df79a3c7026dfa69a49f20fbd70fa7ef0ac5ecada3255afedb3d23c338dcff2d
data/CHANGELOG.md CHANGED
@@ -1,3 +1,41 @@
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.
8
+
9
+ ### Changed
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
19
+
20
+ ### Added
21
+
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`.
24
+
25
+ ### Changed
26
+
27
+ - Install generator now includes `::Rails::Generators::Migration` for `migration_template` support.
28
+
29
+ ## [0.4.0] — 2026-07-26
30
+
31
+ ### Added
32
+
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
+
1
39
  ## [0.1.0] — 2026-07-26
2
40
 
3
41
  ### Added
@@ -1,14 +1,17 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rails/generators"
4
+ require "rails/generators/active_record"
4
5
 
5
6
  module Ask
6
7
  module Rails
7
8
  module Generators
8
9
  class InstallGenerator < ::Rails::Generators::Base
10
+ include ::Rails::Generators::Migration
11
+
9
12
  source_root File.expand_path("templates", __dir__)
10
13
 
11
- desc "Sets up ask-rb for Rails — creates initializer and app/agents/ directory"
14
+ desc "Sets up ask-rb for Rails — creates initializer, agents directory, state and audit log migrations"
12
15
 
13
16
  def create_initializer
14
17
  template "initializer.rb", "config/initializers/ask.rb"
@@ -22,6 +25,20 @@ module Ask
22
25
  empty_directory "app/agents"
23
26
  create_file "app/agents/.keep", "" unless options[:skip_keep]
24
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
25
42
  end
26
43
  end
27
44
  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
@@ -10,6 +10,18 @@
10
10
  #
11
11
  # See https://github.com/ask-rb/ask-auth for details.
12
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
+
13
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
+
14
26
  # config.default_model = "gpt-4o"
15
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
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Ask
4
4
  module Rails
5
- VERSION = "0.4.0"
5
+ VERSION = "0.6.0"
6
6
  end
7
7
  end
@@ -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.0
4
+ version: 0.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -94,9 +94,15 @@ files:
94
94
  - lib/ask/rails.rb
95
95
  - lib/ask/rails/generators/install/install_generator.rb
96
96
  - lib/ask/rails/generators/install/templates/application_agent.rb
97
+ - lib/ask/rails/generators/install/templates/audit_log_migration.rb
97
98
  - lib/ask/rails/generators/install/templates/initializer.rb
99
+ - lib/ask/rails/generators/install/templates/state_migration.rb
98
100
  - lib/ask/rails/railtie.rb
99
101
  - lib/ask/rails/version.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
100
106
  homepage: https://github.com/ask-rb/ask-rails
101
107
  licenses:
102
108
  - MIT