rails_ai 0.1.0
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 +7 -0
- data/.rspec_status +96 -0
- data/AGENT_GUIDE.md +513 -0
- data/Appraisals +49 -0
- data/COMMERCIAL_LICENSE_TEMPLATE.md +92 -0
- data/FEATURES.md +204 -0
- data/LEGAL_PROTECTION_GUIDE.md +222 -0
- data/LICENSE +62 -0
- data/LICENSE_SUMMARY.md +74 -0
- data/MIT-LICENSE +62 -0
- data/PERFORMANCE.md +300 -0
- data/PROVIDERS.md +495 -0
- data/README.md +454 -0
- data/Rakefile +11 -0
- data/SPEED_OPTIMIZATIONS.md +217 -0
- data/STRUCTURE.md +139 -0
- data/USAGE_GUIDE.md +288 -0
- data/app/channels/ai_stream_channel.rb +33 -0
- data/app/components/ai/prompt_component.rb +25 -0
- data/app/controllers/concerns/ai/context_aware.rb +77 -0
- data/app/controllers/concerns/ai/streaming.rb +41 -0
- data/app/helpers/ai_helper.rb +164 -0
- data/app/jobs/ai/generate_embedding_job.rb +25 -0
- data/app/jobs/ai/generate_summary_job.rb +25 -0
- data/app/models/concerns/ai/embeddable.rb +38 -0
- data/app/views/rails_ai/dashboard/index.html.erb +51 -0
- data/config/routes.rb +19 -0
- data/lib/generators/rails_ai/install/install_generator.rb +38 -0
- data/lib/rails_ai/agents/agent_manager.rb +258 -0
- data/lib/rails_ai/agents/agent_team.rb +243 -0
- data/lib/rails_ai/agents/base_agent.rb +331 -0
- data/lib/rails_ai/agents/collaboration.rb +238 -0
- data/lib/rails_ai/agents/memory.rb +116 -0
- data/lib/rails_ai/agents/message_bus.rb +95 -0
- data/lib/rails_ai/agents/specialized_agents.rb +391 -0
- data/lib/rails_ai/agents/task_queue.rb +111 -0
- data/lib/rails_ai/cache.rb +14 -0
- data/lib/rails_ai/config.rb +40 -0
- data/lib/rails_ai/context.rb +7 -0
- data/lib/rails_ai/context_analyzer.rb +86 -0
- data/lib/rails_ai/engine.rb +48 -0
- data/lib/rails_ai/events.rb +9 -0
- data/lib/rails_ai/image_context.rb +110 -0
- data/lib/rails_ai/performance.rb +231 -0
- data/lib/rails_ai/provider.rb +8 -0
- data/lib/rails_ai/providers/anthropic_adapter.rb +256 -0
- data/lib/rails_ai/providers/base.rb +60 -0
- data/lib/rails_ai/providers/dummy_adapter.rb +29 -0
- data/lib/rails_ai/providers/gemini_adapter.rb +509 -0
- data/lib/rails_ai/providers/openai_adapter.rb +535 -0
- data/lib/rails_ai/providers/secure_anthropic_adapter.rb +206 -0
- data/lib/rails_ai/providers/secure_openai_adapter.rb +284 -0
- data/lib/rails_ai/railtie.rb +48 -0
- data/lib/rails_ai/redactor.rb +12 -0
- data/lib/rails_ai/security/api_key_manager.rb +82 -0
- data/lib/rails_ai/security/audit_logger.rb +46 -0
- data/lib/rails_ai/security/error_handler.rb +62 -0
- data/lib/rails_ai/security/input_validator.rb +176 -0
- data/lib/rails_ai/security/secure_file_handler.rb +45 -0
- data/lib/rails_ai/security/secure_http_client.rb +177 -0
- data/lib/rails_ai/security.rb +0 -0
- data/lib/rails_ai/version.rb +5 -0
- data/lib/rails_ai/window_context.rb +103 -0
- data/lib/rails_ai.rb +502 -0
- data/monitoring/ci_setup_guide.md +214 -0
- data/monitoring/enhanced_monitoring_script.rb +237 -0
- data/monitoring/google_alerts_setup.md +42 -0
- data/monitoring_log_20250921.txt +0 -0
- data/monitoring_script.rb +161 -0
- data/rails_ai.gemspec +54 -0
- data/scripts/security_scanner.rb +353 -0
- data/setup_monitoring.sh +163 -0
- data/wiki/API-Documentation.md +734 -0
- data/wiki/Architecture-Overview.md +672 -0
- data/wiki/Contributing-Guide.md +407 -0
- data/wiki/Development-Setup.md +532 -0
- data/wiki/Home.md +278 -0
- data/wiki/Installation-Guide.md +527 -0
- data/wiki/Quick-Start.md +186 -0
- data/wiki/README.md +135 -0
- data/wiki/Release-Process.md +467 -0
- metadata +385 -0
@@ -0,0 +1,407 @@
|
|
1
|
+
# Contributing to Rails AI
|
2
|
+
|
3
|
+
Thank you for your interest in contributing to Rails AI! This guide will help you get started with contributing to the project.
|
4
|
+
|
5
|
+
## 🚀 Getting Started
|
6
|
+
|
7
|
+
### Prerequisites
|
8
|
+
|
9
|
+
- Ruby 2.7+ (3.x recommended)
|
10
|
+
- Rails 5.2+ (8.0 recommended)
|
11
|
+
- Git
|
12
|
+
- Bundler
|
13
|
+
|
14
|
+
### Development Setup
|
15
|
+
|
16
|
+
1. **Fork the repository**
|
17
|
+
```bash
|
18
|
+
# Fork on GitHub, then clone your fork
|
19
|
+
git clone https://github.com/yourusername/rails_ai.git
|
20
|
+
cd rails_ai
|
21
|
+
```
|
22
|
+
|
23
|
+
2. **Install dependencies**
|
24
|
+
```bash
|
25
|
+
bundle install
|
26
|
+
```
|
27
|
+
|
28
|
+
3. **Run tests**
|
29
|
+
```bash
|
30
|
+
bundle exec rspec
|
31
|
+
```
|
32
|
+
|
33
|
+
4. **Run linter**
|
34
|
+
```bash
|
35
|
+
bundle exec standardrb
|
36
|
+
```
|
37
|
+
|
38
|
+
## 📝 Development Workflow
|
39
|
+
|
40
|
+
### 1. Create a Feature Branch
|
41
|
+
|
42
|
+
```bash
|
43
|
+
git checkout -b feature/your-feature-name
|
44
|
+
# or
|
45
|
+
git checkout -b fix/issue-number
|
46
|
+
```
|
47
|
+
|
48
|
+
### 2. Make Your Changes
|
49
|
+
|
50
|
+
- Write your code following the [Code Style](Code-Style.md) guidelines
|
51
|
+
- Add tests for new functionality
|
52
|
+
- Update documentation as needed
|
53
|
+
- Ensure all tests pass
|
54
|
+
|
55
|
+
### 3. Test Your Changes
|
56
|
+
|
57
|
+
```bash
|
58
|
+
# Run all tests
|
59
|
+
bundle exec rspec
|
60
|
+
|
61
|
+
# Run specific test files
|
62
|
+
bundle exec rspec spec/rails_ai_spec.rb
|
63
|
+
bundle exec rspec spec/performance_spec.rb
|
64
|
+
|
65
|
+
# Run with coverage
|
66
|
+
bundle exec rspec --format documentation
|
67
|
+
```
|
68
|
+
|
69
|
+
### 4. Lint Your Code
|
70
|
+
|
71
|
+
```bash
|
72
|
+
# Check code style
|
73
|
+
bundle exec standardrb
|
74
|
+
|
75
|
+
# Auto-fix issues
|
76
|
+
bundle exec standardrb --fix
|
77
|
+
```
|
78
|
+
|
79
|
+
### 5. Commit Your Changes
|
80
|
+
|
81
|
+
```bash
|
82
|
+
git add .
|
83
|
+
git commit -m "Add feature: brief description
|
84
|
+
|
85
|
+
- Detailed description of changes
|
86
|
+
- Any breaking changes
|
87
|
+
- Related issues: #123"
|
88
|
+
```
|
89
|
+
|
90
|
+
### 6. Push and Create Pull Request
|
91
|
+
|
92
|
+
```bash
|
93
|
+
git push origin feature/your-feature-name
|
94
|
+
```
|
95
|
+
|
96
|
+
Then create a pull request on GitHub.
|
97
|
+
|
98
|
+
## 🧪 Testing
|
99
|
+
|
100
|
+
### Test Structure
|
101
|
+
|
102
|
+
```
|
103
|
+
spec/
|
104
|
+
├── rails_ai_spec.rb # Core functionality tests
|
105
|
+
├── performance_spec.rb # Performance tests
|
106
|
+
├── context_aware_spec.rb # Context-aware tests
|
107
|
+
└── generators/ # Generator tests
|
108
|
+
├── install_generator_spec.rb
|
109
|
+
└── feature_generator_spec.rb
|
110
|
+
```
|
111
|
+
|
112
|
+
### Writing Tests
|
113
|
+
|
114
|
+
```ruby
|
115
|
+
# spec/your_feature_spec.rb
|
116
|
+
RSpec.describe "Your Feature" do
|
117
|
+
before do
|
118
|
+
RailsAi.configure do |config|
|
119
|
+
config.provider = :dummy
|
120
|
+
config.stub_responses = true
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
it "does something" do
|
125
|
+
result = RailsAi.your_method("input")
|
126
|
+
expect(result).to be_a(String)
|
127
|
+
end
|
128
|
+
end
|
129
|
+
```
|
130
|
+
|
131
|
+
### Test Requirements
|
132
|
+
|
133
|
+
- All new features must have tests
|
134
|
+
- Tests must pass on all supported Rails versions
|
135
|
+
- Performance tests must meet performance targets
|
136
|
+
- Context-aware tests must verify context inclusion
|
137
|
+
|
138
|
+
## 📋 Code Style
|
139
|
+
|
140
|
+
### Ruby Style
|
141
|
+
|
142
|
+
We use [StandardRB](https://github.com/standardrb/standardrb) for code style enforcement.
|
143
|
+
|
144
|
+
```ruby
|
145
|
+
# Good
|
146
|
+
def method_name(param1, param2: "default")
|
147
|
+
result = do_something(param1)
|
148
|
+
result.to_s
|
149
|
+
end
|
150
|
+
|
151
|
+
# Bad
|
152
|
+
def methodName( param1, param2 = "default" )
|
153
|
+
result=do_something( param1 )
|
154
|
+
return result.to_s
|
155
|
+
end
|
156
|
+
```
|
157
|
+
|
158
|
+
### Documentation Style
|
159
|
+
|
160
|
+
- Use YARD for method documentation
|
161
|
+
- Include examples in documentation
|
162
|
+
- Update README for user-facing changes
|
163
|
+
- Update wiki for architectural changes
|
164
|
+
|
165
|
+
```ruby
|
166
|
+
# Good documentation
|
167
|
+
# Generates an image using AI
|
168
|
+
#
|
169
|
+
# @param prompt [String] Description of the image to generate
|
170
|
+
# @param model [String] AI model to use (default: "dall-e-3")
|
171
|
+
# @param size [String] Image size (default: "1024x1024")
|
172
|
+
# @return [String] Base64-encoded image data
|
173
|
+
# @example
|
174
|
+
# image = RailsAi.generate_image("A sunset over mountains")
|
175
|
+
# # => "data:image/png;base64,..."
|
176
|
+
def generate_image(prompt, model: "dall-e-3", size: "1024x1024")
|
177
|
+
# implementation
|
178
|
+
end
|
179
|
+
```
|
180
|
+
|
181
|
+
## 🏗️ Architecture Guidelines
|
182
|
+
|
183
|
+
### Adding New Providers
|
184
|
+
|
185
|
+
1. Create provider class in `lib/rails_ai/providers/`
|
186
|
+
2. Inherit from `RailsAi::Providers::Base`
|
187
|
+
3. Implement required methods
|
188
|
+
4. Add to provider selection in `RailsAi.provider`
|
189
|
+
5. Add tests for the provider
|
190
|
+
|
191
|
+
```ruby
|
192
|
+
# lib/rails_ai/providers/my_provider.rb
|
193
|
+
module RailsAi
|
194
|
+
module Providers
|
195
|
+
class MyProvider < Base
|
196
|
+
def chat!(messages:, model:, **opts)
|
197
|
+
# Implementation
|
198
|
+
end
|
199
|
+
|
200
|
+
def generate_image!(prompt:, model:, **opts)
|
201
|
+
# Implementation
|
202
|
+
end
|
203
|
+
end
|
204
|
+
end
|
205
|
+
end
|
206
|
+
```
|
207
|
+
|
208
|
+
### Adding New Features
|
209
|
+
|
210
|
+
1. Add methods to main `RailsAi` module
|
211
|
+
2. Implement in all providers
|
212
|
+
3. Add caching if appropriate
|
213
|
+
4. Add performance monitoring
|
214
|
+
5. Add comprehensive tests
|
215
|
+
6. Update documentation
|
216
|
+
|
217
|
+
### Performance Requirements
|
218
|
+
|
219
|
+
- New features must not significantly impact performance
|
220
|
+
- Caching should be implemented for expensive operations
|
221
|
+
- Memory usage should be monitored
|
222
|
+
- Concurrent operations should be thread-safe
|
223
|
+
|
224
|
+
## 📊 Performance Guidelines
|
225
|
+
|
226
|
+
### Benchmarking
|
227
|
+
|
228
|
+
```ruby
|
229
|
+
# Use benchmark-ips for performance testing
|
230
|
+
require 'benchmark/ips'
|
231
|
+
|
232
|
+
Benchmark.ips do |x|
|
233
|
+
x.report("cached") { RailsAi.chat("test") }
|
234
|
+
x.report("uncached") { RailsAi.clear_cache!; RailsAi.chat("test") }
|
235
|
+
x.compare!
|
236
|
+
end
|
237
|
+
```
|
238
|
+
|
239
|
+
### Memory Profiling
|
240
|
+
|
241
|
+
```ruby
|
242
|
+
# Use memory_profiler for memory analysis
|
243
|
+
require 'memory_profiler'
|
244
|
+
|
245
|
+
report = MemoryProfiler.report do
|
246
|
+
RailsAi.chat("test")
|
247
|
+
end
|
248
|
+
|
249
|
+
puts report.pretty_print
|
250
|
+
```
|
251
|
+
|
252
|
+
## 🐛 Bug Reports
|
253
|
+
|
254
|
+
### Before Reporting
|
255
|
+
|
256
|
+
1. Check existing issues
|
257
|
+
2. Update to latest version
|
258
|
+
3. Check documentation
|
259
|
+
4. Try to reproduce the issue
|
260
|
+
|
261
|
+
### Bug Report Template
|
262
|
+
|
263
|
+
```markdown
|
264
|
+
## Bug Description
|
265
|
+
Brief description of the bug
|
266
|
+
|
267
|
+
## Steps to Reproduce
|
268
|
+
1. Step one
|
269
|
+
2. Step two
|
270
|
+
3. Step three
|
271
|
+
|
272
|
+
## Expected Behavior
|
273
|
+
What should happen
|
274
|
+
|
275
|
+
## Actual Behavior
|
276
|
+
What actually happens
|
277
|
+
|
278
|
+
## Environment
|
279
|
+
- Rails version: 8.0.2
|
280
|
+
- Ruby version: 3.2.0
|
281
|
+
- Rails AI version: 0.1.0
|
282
|
+
- OS: macOS 14.0
|
283
|
+
|
284
|
+
## Additional Context
|
285
|
+
Any other relevant information
|
286
|
+
```
|
287
|
+
|
288
|
+
## ✨ Feature Requests
|
289
|
+
|
290
|
+
### Before Requesting
|
291
|
+
|
292
|
+
1. Check existing issues and discussions
|
293
|
+
2. Consider if it fits the project's scope
|
294
|
+
3. Think about implementation complexity
|
295
|
+
4. Consider backward compatibility
|
296
|
+
|
297
|
+
### Feature Request Template
|
298
|
+
|
299
|
+
```markdown
|
300
|
+
## Feature Description
|
301
|
+
Brief description of the feature
|
302
|
+
|
303
|
+
## Use Case
|
304
|
+
Why is this feature needed?
|
305
|
+
|
306
|
+
## Proposed Solution
|
307
|
+
How should this feature work?
|
308
|
+
|
309
|
+
## Alternatives Considered
|
310
|
+
What other approaches were considered?
|
311
|
+
|
312
|
+
## Additional Context
|
313
|
+
Any other relevant information
|
314
|
+
```
|
315
|
+
|
316
|
+
## 🔄 Pull Request Process
|
317
|
+
|
318
|
+
### Before Submitting
|
319
|
+
|
320
|
+
- [ ] Tests pass locally
|
321
|
+
- [ ] Code follows style guidelines
|
322
|
+
- [ ] Documentation is updated
|
323
|
+
- [ ] Performance impact is considered
|
324
|
+
- [ ] Breaking changes are documented
|
325
|
+
|
326
|
+
### Pull Request Template
|
327
|
+
|
328
|
+
```markdown
|
329
|
+
## Description
|
330
|
+
Brief description of changes
|
331
|
+
|
332
|
+
## Type of Change
|
333
|
+
- [ ] Bug fix
|
334
|
+
- [ ] New feature
|
335
|
+
- [ ] Breaking change
|
336
|
+
- [ ] Documentation update
|
337
|
+
|
338
|
+
## Testing
|
339
|
+
- [ ] Tests pass locally
|
340
|
+
- [ ] New tests added
|
341
|
+
- [ ] Performance tests pass
|
342
|
+
|
343
|
+
## Checklist
|
344
|
+
- [ ] Code follows style guidelines
|
345
|
+
- [ ] Self-review completed
|
346
|
+
- [ ] Documentation updated
|
347
|
+
- [ ] Breaking changes documented
|
348
|
+
```
|
349
|
+
|
350
|
+
## 🏷️ Release Process
|
351
|
+
|
352
|
+
### Version Bumping
|
353
|
+
|
354
|
+
- **Patch** (0.1.1): Bug fixes, minor improvements
|
355
|
+
- **Minor** (0.2.0): New features, backward compatible
|
356
|
+
- **Major** (1.0.0): Breaking changes, major features
|
357
|
+
|
358
|
+
### Release Checklist
|
359
|
+
|
360
|
+
- [ ] All tests pass
|
361
|
+
- [ ] Documentation updated
|
362
|
+
- [ ] CHANGELOG.md updated
|
363
|
+
- [ ] Version bumped
|
364
|
+
- [ ] Tagged and released
|
365
|
+
|
366
|
+
## 🤝 Community Guidelines
|
367
|
+
|
368
|
+
### Code of Conduct
|
369
|
+
|
370
|
+
- Be respectful and inclusive
|
371
|
+
- Welcome newcomers
|
372
|
+
- Focus on constructive feedback
|
373
|
+
- Help others learn and grow
|
374
|
+
|
375
|
+
### Communication
|
376
|
+
|
377
|
+
- Use GitHub Issues for bugs and features
|
378
|
+
- Use GitHub Discussions for questions
|
379
|
+
- Use Discord for real-time chat
|
380
|
+
- Be patient with maintainers
|
381
|
+
|
382
|
+
## 📞 Getting Help
|
383
|
+
|
384
|
+
- **Documentation**: Check the wiki first
|
385
|
+
- **Issues**: Search existing issues
|
386
|
+
- **Discussions**: Ask questions in discussions
|
387
|
+
- **Discord**: Join our community chat
|
388
|
+
|
389
|
+
## 🎯 Contribution Ideas
|
390
|
+
|
391
|
+
### Good First Issues
|
392
|
+
|
393
|
+
- Documentation improvements
|
394
|
+
- Test coverage improvements
|
395
|
+
- Performance optimizations
|
396
|
+
- Bug fixes
|
397
|
+
|
398
|
+
### Advanced Contributions
|
399
|
+
|
400
|
+
- New provider implementations
|
401
|
+
- Major feature additions
|
402
|
+
- Performance improvements
|
403
|
+
- Architecture enhancements
|
404
|
+
|
405
|
+
---
|
406
|
+
|
407
|
+
Thank you for contributing to Rails AI! 🚀
|