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 +4 -4
- data/README.md +42 -70
- data/lib/ask/rails/harness/tools/query_database.rb +1 -0
- data/lib/ask/rails/harness/version.rb +1 -1
- data/lib/ask/rails/harness.rb +2 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fbfa4dd4bde386eb1600fd036a12cad723ad335365b46cfadd97e040707674e9
|
|
4
|
+
data.tar.gz: a2af592dae8fec3fe8a6f4fefae6e252456b5dbbe510787fc86e7bc9066f60b2
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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
|
-
|
|
3
|
+
[](https://badge.fury.io/rb/ask-rails-harness)
|
|
4
4
|
|
|
5
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
+
## Configuration
|
|
68
39
|
|
|
69
40
|
```ruby
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
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
|
-
|
|
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
|
-
|
|
58
|
+
## Essential API
|
|
78
59
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
Ask::Rails::Harness
|
|
82
|
-
|
|
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
|
|
91
|
-
| `QueryDatabase` |
|
|
92
|
-
| `ReadModel` | Inspect
|
|
93
|
-
| `ReadRoutes` |
|
|
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
|
|
97
|
-
| `SchemaGraph` | Full schema introspection
|
|
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
|
-
##
|
|
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
|
-
##
|
|
85
|
+
## Development
|
|
111
86
|
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
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
|
|
data/lib/ask/rails/harness.rb
CHANGED
|
@@ -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::
|
|
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.
|
|
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:
|
|
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:
|
|
67
|
+
version: 0.28.0
|
|
68
68
|
- !ruby/object:Gem::Dependency
|
|
69
69
|
name: ask-auth
|
|
70
70
|
requirement: !ruby/object:Gem::Requirement
|