soka-rails 0.0.1.beta4

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.
data/REQUIREMENT.md ADDED
@@ -0,0 +1,308 @@
1
+ # Soka Rails Requirements Specification
2
+
3
+ ## 1. Project Overview
4
+
5
+ ### 1.1 Project Name
6
+ Soka Rails - Rails Integration Package for Soka AI Agent Framework
7
+
8
+ ### 1.2 Project Goals
9
+ Provide seamless integration between Soka AI Agent Framework and Ruby on Rails, following Rails conventions, allowing developers to easily use AI Agent functionality in Rails applications.
10
+
11
+ ### 1.3 Target Users
12
+ - Rails developers
13
+ - Teams needing to integrate AI Agent functionality in Rails applications
14
+ - Existing users of Soka Framework
15
+
16
+ ## 2. Functional Requirements
17
+
18
+ ### 2.1 Core Features
19
+
20
+ #### 2.1.1 Native Rails Integration
21
+ - **Requirement ID**: FR-001
22
+ - **Priority**: High
23
+ - **Description**: Fully comply with Rails conventions and best practices
24
+ - **Acceptance Criteria**:
25
+ - Follow Rails directory structure conventions
26
+ - Support Rails configuration system
27
+ - Integrate Rails logging system
28
+ - Support Rails error handling mechanism
29
+
30
+ #### 2.1.2 Autoloading Support
31
+ - **Requirement ID**: FR-002
32
+ - **Priority**: High
33
+ - **Description**: Automatically load all Agents and Tools in app/soka directory
34
+ - **Acceptance Criteria**:
35
+ - Support Rails autoload_paths
36
+ - Support hot reload in development environment
37
+ - Properly handle namespaces
38
+
39
+ #### 2.1.3 Generator Support
40
+ - **Requirement ID**: FR-003
41
+ - **Priority**: High
42
+ - **Description**: Provide Rails Generators to quickly generate Agent and Tool templates
43
+ - **Acceptance Criteria**:
44
+ - Provide install generator
45
+ - Provide agent generator
46
+ - Provide tool generator
47
+ - Generated code follows Rails conventions
48
+
49
+ #### 2.1.4 Rails Configuration Integration
50
+ - **Requirement ID**: FR-004
51
+ - **Priority**: High
52
+ - **Description**: Use Rails configuration system to manage Soka settings
53
+ - **Acceptance Criteria**:
54
+ - Support initializer configuration
55
+ - Support environment variable configuration
56
+ - Support configuration overrides for different environments
57
+
58
+ #### 2.1.5 Rails Testing Integration
59
+ - **Requirement ID**: FR-005
60
+ - **Priority**: High
61
+ - **Description**: Seamless integration with RSpec
62
+ - **Acceptance Criteria**:
63
+ - Provide RSpec test helpers
64
+ - Support Agent and Tool testing
65
+ - Provide mock and stub functionality
66
+
67
+ ### 2.2 Agent System Requirements
68
+
69
+ #### 2.2.1 ApplicationAgent Base Class
70
+ - **Requirement ID**: FR-006
71
+ - **Priority**: High
72
+ - **Description**: Provide Rails-specific Agent base class
73
+ - **Acceptance Criteria**:
74
+ - Inherit from Soka::Agent
75
+ - Include Rails-specific default configuration
76
+ - Integrate Rails lifecycle hooks
77
+ - Support Rails error tracking
78
+
79
+ #### 2.2.2 Rails Integration Hooks
80
+ - **Requirement ID**: FR-007
81
+ - **Priority**: Medium
82
+ - **Description**: Support Rails-specific lifecycle hooks
83
+ - **Acceptance Criteria**:
84
+ - Support Rails logging integration
85
+ - Support error tracking service integration
86
+ - Support performance monitoring integration
87
+
88
+ ### 2.3 Tool System Requirements
89
+
90
+ #### 2.3.1 ApplicationTool Base Class
91
+ - **Requirement ID**: FR-008
92
+ - **Priority**: High
93
+ - **Description**: Provide Rails-specific Tool base class
94
+ - **Acceptance Criteria**:
95
+ - Inherit from Soka::AgentTool
96
+ - Include Rails-specific helper methods
97
+ - Support standardized error handling
98
+
99
+ #### 2.3.2 Rails-specific Tools
100
+ - **Requirement ID**: FR-009
101
+ - **Priority**: Medium
102
+ - **Description**: Provide Rails environment information tool
103
+ - **Acceptance Criteria**:
104
+ - RailsInfoTool can query route information
105
+ - RailsInfoTool can query version information
106
+ - RailsInfoTool can query environment configuration
107
+ - Only return safe configuration values
108
+
109
+ ### 2.4 Configuration System Requirements
110
+
111
+ #### 2.4.1 Initializer Configuration
112
+ - **Requirement ID**: FR-010
113
+ - **Priority**: High
114
+ - **Description**: Provide standard Rails initializer configuration file
115
+ - **Acceptance Criteria**:
116
+ - Support AI provider configuration
117
+ - Support performance parameter configuration
118
+ - Use ENV.fetch() to handle environment variables
119
+ - Support block-style configuration DSL
120
+
121
+ #### 2.4.2 Environment-specific Configuration
122
+ - **Requirement ID**: FR-011
123
+ - **Priority**: Medium
124
+ - **Description**: Support configuration for different Rails environments
125
+ - **Acceptance Criteria**:
126
+ - Development environment has reasonable defaults
127
+ - Production environment has optimized settings
128
+ - Test environment supports testing needs
129
+
130
+ ## 3. Non-functional Requirements
131
+
132
+ ### 3.1 Performance Requirements
133
+ - **Requirement ID**: NFR-001
134
+ - **Description**: System performance requirements
135
+ - **Acceptance Criteria**:
136
+ - Agent execution does not affect main Rails application functionality
137
+ - Support asynchronous execution mode
138
+ - Reasonable memory usage
139
+
140
+ ### 3.2 Compatibility Requirements
141
+ - **Requirement ID**: NFR-002
142
+ - **Description**: Version compatibility requirements
143
+ - **Acceptance Criteria**:
144
+ - Ruby >= 3.0
145
+ - Rails >= 7.0
146
+ - Soka >= 1.0
147
+ - Compatible with mainstream Rails gems
148
+
149
+ ### 3.3 Security Requirements
150
+ - **Requirement ID**: NFR-003
151
+ - **Description**: Security requirements
152
+ - **Acceptance Criteria**:
153
+ - API keys managed through environment variables
154
+ - No exposure of sensitive configuration information
155
+ - Follow Rails security best practices
156
+
157
+ ### 3.4 Maintainability Requirements
158
+ - **Requirement ID**: NFR-004
159
+ - **Description**: Code quality and maintainability
160
+ - **Acceptance Criteria**:
161
+ - Follow Rails code conventions
162
+ - Provide complete YARD documentation
163
+ - Test coverage > 90%
164
+ - Pass RuboCop checks
165
+
166
+ ## 4. Technical Requirements
167
+
168
+ ### 4.1 Dependency Management
169
+ - **Requirement ID**: TR-001
170
+ - **Description**: Gem dependency requirements
171
+ - **Specifications**:
172
+ - Depend on soka gem
173
+ - Depend on rails gem
174
+ - Minimize additional dependencies
175
+
176
+ ### 4.2 Testing Framework
177
+ - **Requirement ID**: TR-002
178
+ - **Description**: Testing framework support
179
+ - **Specifications**:
180
+ - Full RSpec support
181
+ - Provide test helper modules
182
+ - Support mock AI responses
183
+
184
+ ### 4.3 File Structure
185
+ - **Requirement ID**: TR-003
186
+ - **Description**: Standard file structure
187
+ - **Specifications**:
188
+ ```
189
+ app/soka/
190
+ ├── agents/
191
+ │ └── application_agent.rb
192
+ └── tools/
193
+ └── application_tool.rb
194
+ config/initializers/
195
+ └── soka.rb
196
+ ```
197
+
198
+ ## 5. Use Cases
199
+
200
+ ### 5.1 Basic Agent Usage
201
+ - **Case ID**: UC-001
202
+ - **Actor**: Rails Developer
203
+ - **Precondition**: soka-rails gem installed
204
+ - **Main Flow**:
205
+ 1. Developer instantiates Agent in Controller
206
+ 2. Call Agent.run() method
207
+ 3. Get result and return to frontend
208
+ - **Postcondition**: Successfully executed and returned result
209
+
210
+ ### 5.2 Generator Usage
211
+ - **Case ID**: UC-002
212
+ - **Actor**: Rails Developer
213
+ - **Precondition**: soka-rails gem installed
214
+ - **Main Flow**:
215
+ 1. Execute rails generate soka:install
216
+ 2. Execute rails generate soka:agent [name]
217
+ 3. Execute rails generate soka:tool [name]
218
+ - **Postcondition**: Generate corresponding file structure
219
+
220
+ ### 5.3 Test Writing
221
+ - **Case ID**: UC-003
222
+ - **Actor**: Rails Developer
223
+ - **Precondition**: RSpec configured
224
+ - **Main Flow**:
225
+ 1. Import test helpers
226
+ 2. Mock AI responses
227
+ 3. Execute Agent tests
228
+ 4. Verify results
229
+ - **Postcondition**: Tests pass
230
+
231
+ ## 6. Deliverables
232
+
233
+ ### 6.1 Code Deliverables
234
+ - soka-rails gem source code
235
+ - Complete test suite
236
+ - Example application
237
+
238
+ ### 6.2 Documentation Deliverables
239
+ - API documentation
240
+ - Usage guide
241
+ - Example code
242
+ - Upgrade guide
243
+
244
+ ### 6.3 Tool Deliverables
245
+ - Rails Generators
246
+ - RSpec test helpers
247
+ - Development tool integration
248
+
249
+ ## 7. Acceptance Criteria
250
+
251
+ ### 7.1 Functional Acceptance
252
+ - All functional requirements implemented and tested
253
+ - Generators work properly
254
+ - Test integration fully functional
255
+
256
+ ### 7.2 Quality Acceptance
257
+ - Test coverage above 90%
258
+ - Pass RuboCop checks
259
+ - Documentation complete and accurate
260
+
261
+ ### 7.3 Performance Acceptance
262
+ - Agent execution does not block main thread
263
+ - Reasonable memory usage
264
+ - Response time meets expectations
265
+
266
+ ## 8. Risk Assessment
267
+
268
+ ### 8.1 Technical Risks
269
+ - **Risk**: Rails version updates may cause incompatibility
270
+ - **Mitigation**: Build CI/CD to test multi-version compatibility
271
+
272
+ ### 8.2 Integration Risks
273
+ - **Risk**: Conflicts with other Rails gems
274
+ - **Mitigation**: Minimize dependencies, follow Rails standards
275
+
276
+ ### 8.3 Performance Risks
277
+ - **Risk**: AI calls may affect application performance
278
+ - **Mitigation**: Support asynchronous execution, optimize connection pool management
279
+
280
+ ## 9. Timeline
281
+
282
+ ### 9.1 Development Phase
283
+ - Week 1-2: Core integration development
284
+ - Week 3-4: Generator development
285
+ - Week 5-6: Test integration development
286
+ - Week 7-8: Documentation writing and optimization
287
+
288
+ ### 9.2 Testing Phase
289
+ - Week 9-10: Unit and integration testing
290
+ - Week 11: Performance testing and optimization
291
+ - Week 12: User acceptance testing
292
+
293
+ ## 10. Maintenance Plan
294
+
295
+ ### 10.1 Version Release
296
+ - Follow semantic versioning
297
+ - Regular security updates
298
+ - Provide upgrade guides
299
+
300
+ ### 10.2 Support Plan
301
+ - Provide GitHub Issues support
302
+ - Maintain detailed changelog
303
+ - Regular documentation updates
304
+
305
+ ### 10.3 Community Management
306
+ - Build user community
307
+ - Collect user feedback
308
+ - Regular publication of use cases
data/Rakefile ADDED
@@ -0,0 +1,12 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ require 'rubocop/rake_task'
9
+
10
+ RuboCop::RakeTask.new
11
+
12
+ task default: %i[spec rubocop]