soka-rails 0.0.1 → 0.0.2

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: a6730ee1778d50df9b15f89e90cae6ee7ad6e5ccad4957859ab99b328cd4d37f
4
- data.tar.gz: 51d7ca5f8469231d197f74317661f02d4a9cdfa6a3ba4deb92d85928aab51bf3
3
+ metadata.gz: 956c0fc8a0ecef6e81f471a6674f4a0c7c5df800f720618ecf54a32c87583d1f
4
+ data.tar.gz: d7d16aff15e796d33c284bb77f1db2f7ff42ba61dbf3fb7f76ded2e87a0758d5
5
5
  SHA512:
6
- metadata.gz: 2b5b44129a5845a5d9f4054f6b8128620767092b9db3862c715d12d9383d8d76dea3f0abe0cac00b67f91806a1247970dc9870828201795ce2d7396252435da3
7
- data.tar.gz: 48beed549db55eee4f4ca2d9a20dae03ec51b6de0103dc9c4a4519d5938f64be872c2ab41cee3b88766fe32cebfd32d44268f8fb9dc741c5ceee8fb0c4f47435
6
+ metadata.gz: fd259ec01dcb6ba6c760685a3d1f94bf0091a9298014f696c782cf7839e182651d1e9c44457ed9505bc76a6b048ab72a9bc9b16063c43b436a5b7d48ce98ad17
7
+ data.tar.gz: 3383aba5cdbf64703815efe55214ad63e9ae8d8aedcd6f845c97ef4c6382cf91ba8a9cd0217c75a4fa7db38fa62507072a3550d64c8098dadfa85fd97e0585d9
data/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.0.2] - 2025-08-01
9
+
10
+ ### Fixed
11
+ - Comment out private keyword in agent template
12
+ - Resolve Rails autoloading issues for agents and tools
13
+
14
+ ### Changed
15
+ - Add link to full changelog in release notes
16
+
8
17
  ## [0.0.1] - 2025-08-01
9
18
 
10
19
  ### Added
@@ -19,7 +19,7 @@ class <%= @agent_class_name %> < ApplicationAgent
19
19
  # after_action :your_method
20
20
  # on_error :your_method
21
21
 
22
- private
22
+ # private
23
23
 
24
24
  # Implement your private methods here
25
25
  end
@@ -1,14 +1,65 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'soka'
4
+
3
5
  module Soka
4
6
  module Rails
5
7
  # Rails integration for Soka, configuring autoloading and initializers
8
+ #
9
+ # This Railtie ensures that Soka agents and tools can be autoloaded
10
+ # properly by Rails' Zeitwerk autoloader. It sets up app/soka as a
11
+ # root directory and collapses subdirectories to avoid namespace requirements.
12
+ #
13
+ # @example Directory structure
14
+ # app/soka/
15
+ # ├── agents/
16
+ # │ ├── application_agent.rb # Defines ApplicationAgent (not Agents::ApplicationAgent)
17
+ # │ └── search_agent.rb # Defines SearchAgent (not Agents::SearchAgent)
18
+ # └── tools/
19
+ # ├── application_tool.rb # Defines ApplicationTool (not Tools::ApplicationTool)
20
+ # └── search_tool.rb # Defines SearchTool (not Tools::SearchTool)
6
21
  class Railtie < ::Rails::Railtie
7
- # Configure autoloading - executed after Rails completes basic setup
8
- initializer 'soka.setup_autoloading', before: :set_autoload_paths do |app|
9
- # Add app/soka to autoload paths
10
- # eager_load: true will automatically include all subdirectories
11
- app.config.paths.add 'app/soka', eager_load: true
22
+ # Configuration for collapsed directories
23
+ # Users can modify this in an initializer if needed
24
+ config.soka_collapsed_dirs = %w[agents tools]
25
+
26
+ # Set up Zeitwerk autoloading for Soka directories
27
+ #
28
+ # This initializer runs after Rails sets up its autoloaders but before
29
+ # eager loading begins. It configures app/soka as a root directory
30
+ # and collapses specified subdirectories.
31
+ initializer 'soka.setup_autoloading',
32
+ after: :setup_once_autoloader,
33
+ before: :eager_load! do |app|
34
+ setup_soka_autoloading(app)
35
+ end
36
+
37
+ private
38
+
39
+ def setup_soka_autoloading(app)
40
+ soka_path = app.root.join('app/soka')
41
+ return unless soka_path.exist?
42
+
43
+ configure_autoloader(soka_path)
44
+ rescue StandardError => e
45
+ ::Rails.logger&.error "[Soka] Failed to configure autoloading: #{e.message}"
46
+ raise
47
+ end
48
+
49
+ def configure_autoloader(soka_path)
50
+ # Add app/soka as a root directory without namespace
51
+ # This allows classes in app/soka to be loaded at the top level
52
+ ::Rails.autoloaders.main.push_dir(soka_path.to_s)
53
+
54
+ # Collapse configured directories
55
+ # This removes the directory name from the expected constant path
56
+ # e.g., app/soka/agents/foo.rb defines Foo instead of Agents::Foo
57
+ config.soka_collapsed_dirs.each do |dir|
58
+ dir_path = soka_path.join(dir)
59
+ ::Rails.autoloaders.main.collapse(dir_path.to_s) if dir_path.exist?
60
+ end
61
+
62
+ ::Rails.logger&.debug "[Soka] Configured autoloading for #{soka_path}"
12
63
  end
13
64
  end
14
65
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Soka
4
4
  module Rails
5
- VERSION = '0.0.1'
5
+ VERSION = '0.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: soka-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiunjiun