rails-informant 0.5.1 → 0.5.3

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: ef3e66d24feee02958d2d57db85411ec1e19db17fa0cc440936c3f2072016d7c
4
- data.tar.gz: a43101bb80bffbad9d1a940d06e2a2d35bc5a8853a2978d5ada0dfdcbd87063d
3
+ metadata.gz: 87e632d9075cba7b12f2a9d4f37654dbf5c38503d4d037916f70956db5831da6
4
+ data.tar.gz: a004d0304531b5f591b1c7cf55cf57c188edb1fa0969ab3c1b86dd340f9a1c69
5
5
  SHA512:
6
- metadata.gz: 626124766b399453b846fb37ea492a9cc971206dafcbe5019e050b8adde854f20a55944c84f8906d03c5a55255530480c7599dd3aaf143ac37bc4aca743ae83a
7
- data.tar.gz: 8fb18f7ab56d4044601224d6c7c20ffcc77944517738d2a7fded15470fc3a18bb83ae963b6784305145519166d54f887b39e84f34c7ff3b5e2623581fd85096c
6
+ metadata.gz: 938408a0098cc497a2498bd6ac34ff70b1b69740d81647f5a32b997c227d5e2bee260d6f7d7737d26ae92dff5aeb17ba70c78fc530d4b146732b3f0bd251c137
7
+ data.tar.gz: 2e8a5894b1c1c9f3e4129c813c3717d78c2ecf0c31a338bbf15843044684123d614f465ebf1fe389bf0d433b6ae453d83c4fb1927e8a46f594c790f1270c035b
data/README.md CHANGED
@@ -87,6 +87,7 @@ Every option can be set via an environment variable. The initializer takes prece
87
87
  |--------|---------|---------|-------------|
88
88
  | `api_token` | `INFORMANT_API_TOKEN` | `nil` | Authentication token for API/MCP access |
89
89
  | `capture_errors` | `INFORMANT_CAPTURE_ERRORS` | `true` | Enable/disable error capture |
90
+ | `capture_runner_errors` | `INFORMANT_CAPTURE_RUNNER_ERRORS` | `true` | Capture errors raised under `rails runner` |
90
91
  | `capture_user_email` | _(none)_ | `false` | Capture email from detected user (PII -- opt-in) |
91
92
  | `ignored_exceptions` | `INFORMANT_IGNORED_EXCEPTIONS` | `[]` | Exception classes to skip (walks cause chain) |
92
93
  | `ignored_paths` | `INFORMANT_IGNORED_PATHS` | `[]` | Request paths to skip (exact or segment match) |
@@ -126,6 +127,19 @@ is recorded and no notifications are sent. You see exceptions live at the prompt
126
127
  recording and alerting on them would only be noise. This is always on and not configurable.
127
128
  Errors from web requests, background jobs, and rake tasks are captured as normal.
128
129
 
130
+ ### Rails Runner
131
+
132
+ `rails runner` is captured by default, because it is how many apps run cron and scheduled
133
+ tasks -- exactly the errors you want to hear about. If your app instead uses it by hand, for
134
+ one-off production data corrections, the operator already sees the exception on their own
135
+ terminal and recording it only pages the team:
136
+
137
+ ```ruby
138
+ config.capture_runner_errors = false
139
+ ```
140
+
141
+ That applies only to `rails runner`; requests, jobs and rake tasks are captured either way.
142
+
129
143
  ### Silenced Blocks
130
144
 
131
145
  ```ruby
@@ -192,6 +206,22 @@ export INFORMANT_STAGING_URL=https://staging.myapp.com
192
206
  export INFORMANT_STAGING_TOKEN=<token>
193
207
  ```
194
208
 
209
+ ### Keeping it in sync
210
+
211
+ The generator's output (`.claude/`, `.mcp.json`) is committed to your app, so a gem update leaves those files untouched. After `bundle update rails-informant`, re-run the generator and commit the result to pick up template changes:
212
+
213
+ ```sh
214
+ bin/rails generate rails_informant:skill
215
+ ```
216
+
217
+ Re-running migrates any prior hook registration in place, so there are no duplicates. The gem also flags drift when the committed files fall behind the installed version — via a warning on dev boot, an in-session Claude Code nudge, and an on-demand check:
218
+
219
+ ```sh
220
+ bin/rails informant:doctor # reports current / stale / not installed; exits nonzero when stale
221
+ ```
222
+
223
+ Apps that use the gem only for error capture (no Claude Code integration) are never affected.
224
+
195
225
  ### Tools
196
226
 
197
227
  | Tool | Description |
@@ -15,8 +15,16 @@ module RailsInformant
15
15
  MCP_PATH = ".mcp.json"
16
16
 
17
17
  # The command string a settings.json hook entry uses to invoke the script.
18
- # Match-by-path detection keys on this value across every event key.
19
- HOOK_COMMAND = HOOK_SCRIPT_PATH
18
+ # Absolute via Claude Code's $CLAUDE_PROJECT_DIR because the hook's cwd is
19
+ # not guaranteed to be the app root: a bare relative path fails on every
20
+ # prompt with "No such file or directory". Quoted as written — the expansion
21
+ # can contain spaces.
22
+ HOOK_COMMAND = %("$CLAUDE_PROJECT_DIR"/#{HOOK_SCRIPT_PATH})
23
+
24
+ # Every command form informant has ever written. Match-by-path detection
25
+ # keys on this list across every event key, so a re-run migrates an install
26
+ # registered by an older gem instead of appending a second entry beside it.
27
+ HOOK_COMMANDS = [ HOOK_COMMAND, HOOK_SCRIPT_PATH ].freeze
20
28
 
21
29
  # The event key the current gem registers the hook under.
22
30
  HOOK_EVENT = "UserPromptSubmit"
@@ -70,7 +78,7 @@ module RailsInformant
70
78
  # registrations) and detection (to extract the informant fragment).
71
79
  def informant_hook_entry?(entry)
72
80
  entry.is_a?(Hash) && Array(entry["hooks"]).any? do |hook|
73
- hook.is_a?(Hash) && hook["command"] == HOOK_COMMAND
81
+ hook.is_a?(Hash) && HOOK_COMMANDS.include?(hook["command"])
74
82
  end
75
83
  end
76
84
  end
@@ -1,6 +1,7 @@
1
1
  module RailsInformant
2
2
  class Configuration
3
3
  attr_accessor :capture_errors,
4
+ :capture_runner_errors,
4
5
  :capture_user_email,
5
6
  :api_token,
6
7
  :ignored_exceptions,
@@ -17,6 +18,7 @@ module RailsInformant
17
18
  @api_token = ENV["INFORMANT_API_TOKEN"]
18
19
  @app_name = ENV["INFORMANT_APP_NAME"]
19
20
  @capture_errors = ENV.fetch("INFORMANT_CAPTURE_ERRORS", "true") != "false"
21
+ @capture_runner_errors = ENV.fetch("INFORMANT_CAPTURE_RUNNER_ERRORS", "true") != "false"
20
22
  @capture_user_email = false
21
23
  @custom_notifiers = []
22
24
  @ignored_exceptions = ENV["INFORMANT_IGNORED_EXCEPTIONS"]&.split(",")&.map(&:strip) || []
@@ -15,6 +15,10 @@ module RailsInformant
15
15
  # Never capture from an interactive console — the operator sees errors
16
16
  # live, so recording and alerting on them is noise.
17
17
  return if RailsInformant.console_mode?
18
+ # `rails runner` is the same shape when an operator drives it by hand, but it also
19
+ # backs cron and scheduled tasks, where those errors are the whole point. Apps that
20
+ # only use it interactively opt out; capturing stays the default.
21
+ return if RailsInformant.runner_mode? && !RailsInformant.config.capture_runner_errors
18
22
  return unless RailsInformant.initialized?
19
23
  return if self_caused_error?(error)
20
24
 
@@ -139,6 +139,11 @@ module RailsInformant
139
139
  defined?(Rails::Console)
140
140
  end
141
141
 
142
+ # `rails runner` loads this command class; a server, worker or rake process never does.
143
+ def runner_mode?
144
+ defined?(Rails::Command::RunnerCommand)
145
+ end
146
+
142
147
  def server_mode?
143
148
  defined?(Rails::Server)
144
149
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-informant
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.1
4
+ version: 0.5.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Daniel López Prat
@@ -198,7 +198,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
198
198
  - !ruby/object:Gem::Version
199
199
  version: '0'
200
200
  requirements: []
201
- rubygems_version: 4.0.10
201
+ rubygems_version: 4.0.16
202
202
  specification_version: 4
203
203
  summary: Self-hosted error monitoring for Rails with MCP server for agentic workflows
204
204
  test_files: []