ask-rails-harness 0.1.0 → 0.1.1

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: 1c1a8388500ab4366c876be18f2b8fb2fd2c489fcd6c04da90c2a1ee9eea8b59
4
- data.tar.gz: 6012eff1acc1cdecd8b606a91027f517a69ddb77d252c0aae8846e23b5e7f15e
3
+ metadata.gz: fbfa4dd4bde386eb1600fd036a12cad723ad335365b46cfadd97e040707674e9
4
+ data.tar.gz: a2af592dae8fec3fe8a6f4fefae6e252456b5dbbe510787fc86e7bc9066f60b2
5
5
  SHA512:
6
- metadata.gz: 7492561a0888730defddcff380d3800afefab364f41bf4df2e842a1894cdc4229c08e7d9c249df0b2d8ece1d0e9e345369840434a1af10d8802eb2f9f2fac4c4
7
- data.tar.gz: 490b772093ac41af1ca679dfa55af7500ede1c634d01e82a3f7393ba23381fdf30507bf95929d8405e824ab7daf0d05f17052164a41724e8547bf7c4f3848abb
6
+ metadata.gz: 3dfc9d467a70c966cb3f4400605c7625bb1792d4f5da096aaba508dae32cf09429e4da281b91b8022d390f5dfa54cd9c5dc495dd550e0aab0a3c3b5daa3ff32f
7
+ data.tar.gz: 40589044b3cb0e691e08b036fdedc19ed8f3727f2e57af909a820e6ee2c442f2bde7c94313a8a18bd526a5b8ba9653e4acb8248342f81eed18477ba99a9c6624
data/README.md CHANGED
@@ -1,24 +1,10 @@
1
1
  # ask-rails-harness
2
2
 
3
- An admin AI agent for your Rails app. Mount the engine, get a chat interface at `/ask` that can inspect your code, query your database, read logs, and help you debug — all through an authenticated admin UI.
3
+ [![Gem Version](https://badge.fury.io/rb/ask-rails-harness.svg)](https://badge.fury.io/rb/ask-rails-harness)
4
4
 
5
- > **Previously developed as `ask-rails` (v0.1.0–0.11.1).** Renamed to `ask-rails-harness` for clarity this gem is the *harness* that wraps an AI agent with Rails-aware tools, environment, state, and feedback for internal/admin use.
5
+ Admin AI copilot for Rails apps. Mounts a Rails Engine at `/ask` with an admin chat UI and 9 Rails-aware tools that inspect your code, query your database, read logs, and help you debug. For internal/admin use only: the agent has direct access to your database, file system, and shell.
6
6
 
7
- ## Who is this for?
8
-
9
- - **Rails developers** who want an AI co-pilot that understands their app's codebase, schema, routes, and logs
10
- - **Internal/Admin use only** — the agent has direct access to your database, file system, and shell. Not for external/customer-facing use.
11
-
12
- For building customer-facing AI agents, use `ask-agent` directly with your own tools and UI.
13
-
14
- ## What it gives you
15
-
16
- - **9 Rails-aware tools**: `ReadFile`, `QueryDatabase`, `ReadRoutes`, `ReadModel`, `ReadLog`, `RunCommand`, `SearchCodebase`, `SchemaGraph`, `RouteInspector`
17
- - **Admin chat UI**: Mount the engine, get a working chat at `/ask` with SSE streaming
18
- - **Auth integration**: Protect `/ask` behind your existing Devise/authentication
19
- - **AR persistence**: Agent sessions survive server restarts
20
- - **Service discovery**: Auto-detects installed ask-\* service gems
21
- - **Skills**: Built-in guides for Rails debugging, deployment, and database performance
7
+ Previously released as `ask-rails` (v0.1.0-0.11.1) and renamed to `ask-rails-harness`. For customer-facing agents, use [ask-agent](https://github.com/ask-rb/ask-agent) directly.
22
8
 
23
9
  ## Installation
24
10
 
@@ -27,36 +13,21 @@ bundle add ask-rails-harness
27
13
  rails generate ask_rails_harness:install
28
14
  ```
29
15
 
30
- ## Quick Start
16
+ The generator creates `config/initializers/ask_rails_harness.rb`, the `ask_sessions` and `ask_audit_logs` migrations, and an `app/tools/` directory. Requires Rails 7.1+.
31
17
 
32
- Add the engine mount and auth protection to `config/routes.rb`:
18
+ Run the migration, then mount the engine in `config/routes.rb`:
33
19
 
34
20
  ```ruby
35
- # config/routes.rb
36
21
  Rails.application.routes.draw do
37
- # ... your routes ...
38
-
39
22
  authenticate :user, ->(u) { u.admin? } do
40
23
  mount Ask::Rails::Harness::Engine, at: "/ask"
41
24
  end
42
25
  end
43
26
  ```
44
27
 
45
- Then visit `/ask` in your browser.
46
-
47
- ## Usage
48
-
49
- ### Configuration
50
-
51
- ```ruby
52
- # config/initializers/ask_rails_harness.rb
53
- Ask::Rails::Harness.configure do |c|
54
- c.default_model = "claude-sonnet-4"
55
- c.max_turns = 50
56
- end
57
- ```
28
+ Visit `/ask` in your browser.
58
29
 
59
- ### Programmatic Access
30
+ ## Quick Start
60
31
 
61
32
  ```ruby
62
33
  # From any controller, view, or job
@@ -64,58 +35,59 @@ session = Ask::Rails::Harness.agent_session
64
35
  session.run("Find all open issues labeled 'bug' in our repo")
65
36
  ```
66
37
 
67
- ### Route Helpers
38
+ ## Configuration
68
39
 
69
40
  ```ruby
70
- ask_rails_harness.root_path # => /ask
71
- ask_rails_harness.sessions_path # => /ask/sessions
72
- ask_rails_harness.session_messages_path(session_id) # => /ask/sessions/:id/messages
41
+ # config/initializers/ask_rails_harness.rb
42
+ Ask::Rails::Harness.configure do |c|
43
+ c.default_model = "claude-sonnet-4"
44
+ c.max_turns = 50
45
+ c.tool_concurrency = 5
46
+ c.allowed_commands = [/^rails /]
47
+ c.denied_commands = [/rm/, /dropdb/]
48
+ c.max_session_age = 7.days
49
+ c.max_sessions = 100
50
+ c.environment :production do |env|
51
+ env.mode = :read_only
52
+ end
53
+ end
73
54
  ```
74
55
 
75
- ### Auth
56
+ Available settings: `default_model`, `max_turns`, `tool_concurrency`, `system_prompt`, `persistence_adapter`, `current_user`, `allowed_commands`, `denied_commands`, `max_session_age`, `max_sessions`, and per-environment permissions via `environment(name) { |env| env.mode = ... }`.
76
57
 
77
- By default, the admin chat is unprotected. Add auth in your routes (as shown above) or set a custom check:
58
+ ## Essential API
78
59
 
79
- ```ruby
80
- # config/initializers/ask_rails_harness.rb
81
- Ask::Rails::Harness::Auth.check = -> {
82
- redirect_to main_app.login_path unless current_user&.admin?
83
- }
84
- ```
60
+ - `Ask::Rails::Harness.agent_session`: build an agent session with the configured tools and prompt
61
+ - `Ask::Rails::Harness.configure { |c| ... }`: configuration (see above)
62
+ - `Ask::Rails::Harness.cleanup!`: prune old sessions and audit logs; also available as `rails ask_rails_harness:cleanup`
63
+ - `Ask::Rails::Harness::Persistence`: ActiveRecord session persistence backed by the `ask_sessions` table
64
+ - `Ask::Rails::Harness::Auth.check = -> { ... }`: auth proc evaluated in the controller context; the engine routes are unprotected by default
65
+ - Audit log: every tool call is recorded in `ask_audit_logs` and broadcast as the `audit_log.ask_rails_harness` ActiveSupport notification
85
66
 
86
67
  ## Tools
87
68
 
88
69
  | Tool | What it does |
89
70
  |---|---|
90
- | `ReadFile` | Read any file (relative to `Rails.root`) |
91
- | `QueryDatabase` | Run read-only SQL (rejects non-SELECT in production) |
92
- | `ReadModel` | Inspect AR model schema, associations, validations |
93
- | `ReadRoutes` | View `config/routes.rb` |
71
+ | `ReadFile` | Read any file relative to `Rails.root` |
72
+ | `QueryDatabase` | Read-only SQL (non-SELECT rejected in production) |
73
+ | `ReadModel` | Inspect an ActiveRecord model's columns, associations, validations |
74
+ | `ReadRoutes` | Read `config/routes.rb` |
94
75
  | `ReadLog` | Read log files with level/search filtering |
95
76
  | `RunCommand` | Run shell commands in the app root |
96
- | `SearchCodebase` | Grep the codebase for patterns |
97
- | `SchemaGraph` | Full schema introspection — all models, tables, columns, associations |
77
+ | `SearchCodebase` | Grep the codebase |
78
+ | `SchemaGraph` | Full schema introspection: models, tables, columns, associations |
98
79
  | `RouteInspector` | Parsed route table with filters |
99
80
 
100
- ## Engine Routes
81
+ ## Full documentation
101
82
 
102
- ```
103
- GET /ask → Chat UI
104
- POST /ask/sessions → Create new session
105
- POST /ask/sessions/:id/messages → Send message (SSE streamed response)
106
- GET /ask/sessions/:id/messages → Get message history
107
- GET /ask/sessions/:id/stream → SSE stream for existing session
108
- ```
83
+ The full ask-rb documentation lives at https://ask-rb.github.io/ask-docs. [Rails setup](https://ask-rb.github.io/ask-docs/rails/setup) covers ask-rails-harness in depth. API reference: https://ask-rb.github.io/ask-docs/reference/api.
109
84
 
110
- ## Compared to ask-agent
85
+ ## Development
111
86
 
112
- | `ask-agent` | `ask-rails-harness` |
113
- |---|---|
114
- | Build external-facing agents | Build an internal admin co-pilot |
115
- | Bring your own tools | Ships Rails-specific tools |
116
- | Bring your own UI | Ships an admin chat UI |
117
- | Any Ruby app | Rails apps only |
118
- | General purpose | Development, debugging, ops |
87
+ ```bash
88
+ bundle install
89
+ bundle exec rake test
90
+ ```
119
91
 
120
92
  ## License
121
93
 
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ require "time"
2
3
 
3
4
  module Ask
4
5
  module Rails
@@ -3,7 +3,7 @@
3
3
  module Ask
4
4
  module Rails
5
5
  module Harness
6
- VERSION = "0.1.0"
6
+ VERSION = "0.1.1"
7
7
  end
8
8
  end
9
9
  end
@@ -3,6 +3,7 @@
3
3
  require "rails"
4
4
  require "ask/agent"
5
5
  require "ask/auth"
6
+ require "time"
6
7
 
7
8
  module Ask
8
9
  module Rails
@@ -64,7 +65,7 @@ module Ask
64
65
  env_mode = configuration.effective_mode
65
66
  return {} unless env_mode
66
67
 
67
- perms = Ask::Agent::Extensions::Permissions.new(mode: env_mode)
68
+ perms = Ask::Agent::Policies::Permissions.new(mode: env_mode)
68
69
  { before_tool: [perms.method(:before_tool_call)] }
69
70
  rescue ArgumentError => e
70
71
  warn "[ask-rails-harness] Invalid environment mode: #{e.message}"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ask-rails-harness
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaka Ruto
@@ -57,14 +57,14 @@ dependencies:
57
57
  requirements:
58
58
  - - ">="
59
59
  - !ruby/object:Gem::Version
60
- version: '0.1'
60
+ version: 0.28.0
61
61
  type: :runtime
62
62
  prerelease: false
63
63
  version_requirements: !ruby/object:Gem::Requirement
64
64
  requirements:
65
65
  - - ">="
66
66
  - !ruby/object:Gem::Version
67
- version: '0.1'
67
+ version: 0.28.0
68
68
  - !ruby/object:Gem::Dependency
69
69
  name: ask-auth
70
70
  requirement: !ruby/object:Gem::Requirement