code_sage 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/.github/workflows/gem.yml +47 -0
- data/.gitignore +54 -0
- data/.rspec +3 -0
- data/CHANGELOG.md +24 -0
- data/Gemfile +11 -0
- data/Gemfile.lock +150 -0
- data/LICENSE +21 -0
- data/README.md +279 -0
- data/Rakefile +20 -0
- data/bin/console +10 -0
- data/bin/setup +8 -0
- data/code_sage.gemspec +39 -0
- data/exe/code_sage +6 -0
- data/lib/code_sage/cli.rb +161 -0
- data/lib/code_sage/config.rb +87 -0
- data/lib/code_sage/git_analyzer.rb +183 -0
- data/lib/code_sage/report_formatter.rb +171 -0
- data/lib/code_sage/reviewer.rb +226 -0
- data/lib/code_sage/version.rb +3 -0
- data/lib/code_sage.rb +15 -0
- metadata +179 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 54bbfe11204be27b426808d1ee98e5ea40aed7c8a25d525c613044f75f35e9c6
|
4
|
+
data.tar.gz: 453c726fd2f5dc7f2a6c7a975ead2f36420a7d40f3d96c3eb9a7099ad7b710cd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 49e79a62468d7dda3d7d027259802d2fa00d3049a096e885430e634b70384185cda168be105afc0c3842c9908751d4f18bdb761e4dfd15aa022791ada6f02430
|
7
|
+
data.tar.gz: 45280224e33c0dbf2c8c721a0def678388148b2bc294f714c2956d5234e2c7cc52a909f4f7340dc6b29595d6c96570259441e2bc5add7c240fe925040f86749d
|
@@ -0,0 +1,47 @@
|
|
1
|
+
name: Ruby Gem
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches: [ "master" ]
|
6
|
+
pull_request:
|
7
|
+
branches: [ "master" ]
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
build:
|
11
|
+
name: Build + Publish
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
permissions:
|
14
|
+
contents: read
|
15
|
+
packages: write
|
16
|
+
|
17
|
+
steps:
|
18
|
+
- uses: actions/checkout@v4
|
19
|
+
|
20
|
+
- name: Set up Ruby
|
21
|
+
uses: ruby/setup-ruby@v1
|
22
|
+
with:
|
23
|
+
ruby-version: 3.2.2
|
24
|
+
bundler-cache: true
|
25
|
+
|
26
|
+
- name: Install dependencies
|
27
|
+
run: bundle install
|
28
|
+
|
29
|
+
- name: Build gem
|
30
|
+
run: gem build *.gemspec
|
31
|
+
|
32
|
+
- name: Publish to GPR (GitHub Package Registry)
|
33
|
+
run: |
|
34
|
+
mkdir -p $HOME/.gem
|
35
|
+
touch $HOME/.gem/credentials
|
36
|
+
chmod 0600 $HOME/.gem/credentials
|
37
|
+
printf -- "---\n:github: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
|
38
|
+
gem push --KEY github --host https://rubygems.pkg.github.com/${OWNER} *.gem
|
39
|
+
env:
|
40
|
+
GEM_HOST_API_KEY: "Bearer ${{secrets.GITHUB_TOKEN}}"
|
41
|
+
OWNER: ${{ github.repository_owner }}
|
42
|
+
|
43
|
+
- name: Publish to RubyGems
|
44
|
+
if: success()
|
45
|
+
run: gem push *.gem
|
46
|
+
env:
|
47
|
+
GEM_HOST_API_KEY: "${{secrets.RUBYGEMS_AUTH_TOKEN}}"
|
data/.gitignore
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
/.bundle/
|
2
|
+
/.yardoc
|
3
|
+
/_yardoc/
|
4
|
+
/coverage/
|
5
|
+
/doc/
|
6
|
+
/pkg/
|
7
|
+
/spec/reports/
|
8
|
+
/tmp/
|
9
|
+
|
10
|
+
# rspec failure tracking
|
11
|
+
.rspec_status
|
12
|
+
|
13
|
+
# IDE files
|
14
|
+
.vscode/
|
15
|
+
.idea/
|
16
|
+
*.swp
|
17
|
+
*.swo
|
18
|
+
|
19
|
+
# OS generated files
|
20
|
+
.DS_Store
|
21
|
+
.DS_Store?
|
22
|
+
._*
|
23
|
+
.Spotlight-V100
|
24
|
+
.Trashes
|
25
|
+
ehthumbs.db
|
26
|
+
Thumbs.db
|
27
|
+
|
28
|
+
# Gem builds
|
29
|
+
*.gem
|
30
|
+
|
31
|
+
# Config files with sensitive data
|
32
|
+
config/credentials.yml.enc
|
33
|
+
config/master.key
|
34
|
+
|
35
|
+
# Logs
|
36
|
+
*.log
|
37
|
+
|
38
|
+
# Runtime data
|
39
|
+
*.pid
|
40
|
+
*.seed
|
41
|
+
*.pid.lock
|
42
|
+
|
43
|
+
# Coverage directory used by tools like istanbul
|
44
|
+
coverage/
|
45
|
+
|
46
|
+
# nyc test coverage
|
47
|
+
.nyc_output
|
48
|
+
|
49
|
+
# node_modules
|
50
|
+
node_modules/
|
51
|
+
|
52
|
+
# Local configuration
|
53
|
+
.env
|
54
|
+
.env.local
|
data/.rspec
ADDED
data/CHANGELOG.md
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
6
|
+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
7
|
+
|
8
|
+
## [Unreleased]
|
9
|
+
|
10
|
+
### Added
|
11
|
+
- Initial gem structure
|
12
|
+
- CLI interface with Thor
|
13
|
+
- Git integration using Rugged
|
14
|
+
- LLM-powered code review using llm_chain
|
15
|
+
- Multiple output formats (console, JSON, markdown)
|
16
|
+
- Ruby code analysis and review
|
17
|
+
- Comprehensive reporting system
|
18
|
+
|
19
|
+
## [0.1.0] - 2025-01-XX
|
20
|
+
|
21
|
+
### Added
|
22
|
+
- Initial release of CodeSage
|
23
|
+
- Basic code review functionality
|
24
|
+
- CLI interface for easy usage
|
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,150 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
code_sage (0.1.0)
|
5
|
+
colorize (~> 0.8)
|
6
|
+
llm_chain (~> 0.5.2)
|
7
|
+
rugged (~> 1.0)
|
8
|
+
thor (~> 1.0)
|
9
|
+
|
10
|
+
GEM
|
11
|
+
remote: https://rubygems.org/
|
12
|
+
specs:
|
13
|
+
activesupport (8.0.2)
|
14
|
+
base64
|
15
|
+
benchmark (>= 0.3)
|
16
|
+
bigdecimal
|
17
|
+
concurrent-ruby (~> 1.0, >= 1.3.1)
|
18
|
+
connection_pool (>= 2.2.5)
|
19
|
+
drb
|
20
|
+
i18n (>= 1.6, < 2)
|
21
|
+
logger (>= 1.4.2)
|
22
|
+
minitest (>= 5.1)
|
23
|
+
securerandom (>= 0.3)
|
24
|
+
tzinfo (~> 2.0, >= 2.0.5)
|
25
|
+
uri (>= 0.13.1)
|
26
|
+
ast (2.4.3)
|
27
|
+
base64 (0.3.0)
|
28
|
+
benchmark (0.4.1)
|
29
|
+
bigdecimal (3.2.2)
|
30
|
+
coderay (1.1.3)
|
31
|
+
colorize (0.8.1)
|
32
|
+
concurrent-ruby (1.3.5)
|
33
|
+
connection_pool (2.5.3)
|
34
|
+
csv (3.3.5)
|
35
|
+
diff-lcs (1.6.2)
|
36
|
+
drb (2.2.3)
|
37
|
+
faraday (2.13.1)
|
38
|
+
faraday-net_http (>= 2.0, < 3.5)
|
39
|
+
json
|
40
|
+
logger
|
41
|
+
faraday-net_http (3.4.1)
|
42
|
+
net-http (>= 0.5.0)
|
43
|
+
fiber-storage (1.0.1)
|
44
|
+
graphlient (0.8.0)
|
45
|
+
faraday (~> 2.0)
|
46
|
+
graphql-client
|
47
|
+
graphql (2.5.9)
|
48
|
+
base64
|
49
|
+
fiber-storage
|
50
|
+
logger
|
51
|
+
graphql-client (0.26.0)
|
52
|
+
activesupport (>= 3.0)
|
53
|
+
graphql (>= 1.13.0)
|
54
|
+
httparty (0.23.1)
|
55
|
+
csv
|
56
|
+
mini_mime (>= 1.0.0)
|
57
|
+
multi_xml (>= 0.5.2)
|
58
|
+
i18n (1.14.7)
|
59
|
+
concurrent-ruby (~> 1.0)
|
60
|
+
json (2.12.2)
|
61
|
+
language_server-protocol (3.17.0.5)
|
62
|
+
lint_roller (1.1.0)
|
63
|
+
llm_chain (0.5.2)
|
64
|
+
faraday (~> 2.7)
|
65
|
+
faraday-net_http
|
66
|
+
httparty
|
67
|
+
json
|
68
|
+
redis
|
69
|
+
weaviate-ruby (= 0.9.1)
|
70
|
+
logger (1.7.0)
|
71
|
+
method_source (1.1.0)
|
72
|
+
mini_mime (1.1.5)
|
73
|
+
minitest (5.25.5)
|
74
|
+
multi_xml (0.7.2)
|
75
|
+
bigdecimal (~> 3.1)
|
76
|
+
net-http (0.6.0)
|
77
|
+
uri
|
78
|
+
parallel (1.27.0)
|
79
|
+
parser (3.3.8.0)
|
80
|
+
ast (~> 2.4.1)
|
81
|
+
racc
|
82
|
+
prism (1.4.0)
|
83
|
+
pry (0.15.2)
|
84
|
+
coderay (~> 1.1)
|
85
|
+
method_source (~> 1.0)
|
86
|
+
racc (1.8.1)
|
87
|
+
rainbow (3.1.1)
|
88
|
+
rake (13.3.0)
|
89
|
+
redis (5.4.0)
|
90
|
+
redis-client (>= 0.22.0)
|
91
|
+
redis-client (0.25.0)
|
92
|
+
connection_pool
|
93
|
+
regexp_parser (2.10.0)
|
94
|
+
rspec (3.13.1)
|
95
|
+
rspec-core (~> 3.13.0)
|
96
|
+
rspec-expectations (~> 3.13.0)
|
97
|
+
rspec-mocks (~> 3.13.0)
|
98
|
+
rspec-core (3.13.5)
|
99
|
+
rspec-support (~> 3.13.0)
|
100
|
+
rspec-expectations (3.13.5)
|
101
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
102
|
+
rspec-support (~> 3.13.0)
|
103
|
+
rspec-mocks (3.13.5)
|
104
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
105
|
+
rspec-support (~> 3.13.0)
|
106
|
+
rspec-support (3.13.4)
|
107
|
+
rubocop (1.77.0)
|
108
|
+
json (~> 2.3)
|
109
|
+
language_server-protocol (~> 3.17.0.2)
|
110
|
+
lint_roller (~> 1.1.0)
|
111
|
+
parallel (~> 1.10)
|
112
|
+
parser (>= 3.3.0.2)
|
113
|
+
rainbow (>= 2.2.2, < 4.0)
|
114
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
115
|
+
rubocop-ast (>= 1.45.1, < 2.0)
|
116
|
+
ruby-progressbar (~> 1.7)
|
117
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
118
|
+
rubocop-ast (1.45.1)
|
119
|
+
parser (>= 3.3.7.2)
|
120
|
+
prism (~> 1.4)
|
121
|
+
ruby-progressbar (1.13.0)
|
122
|
+
rugged (1.9.0)
|
123
|
+
securerandom (0.4.1)
|
124
|
+
thor (1.3.2)
|
125
|
+
tzinfo (2.0.6)
|
126
|
+
concurrent-ruby (~> 1.0)
|
127
|
+
unicode-display_width (3.1.4)
|
128
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
129
|
+
unicode-emoji (4.0.4)
|
130
|
+
uri (1.0.3)
|
131
|
+
weaviate-ruby (0.9.1)
|
132
|
+
faraday (>= 2.0.1, < 3.0)
|
133
|
+
graphlient (>= 0.7.0, < 0.9.0)
|
134
|
+
yard (0.9.37)
|
135
|
+
|
136
|
+
PLATFORMS
|
137
|
+
ruby
|
138
|
+
x86_64-linux
|
139
|
+
|
140
|
+
DEPENDENCIES
|
141
|
+
bundler (~> 2.0)
|
142
|
+
code_sage!
|
143
|
+
pry
|
144
|
+
rake (~> 13.0)
|
145
|
+
rspec (~> 3.0)
|
146
|
+
rubocop
|
147
|
+
yard
|
148
|
+
|
149
|
+
BUNDLED WITH
|
150
|
+
2.6.7
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
MIT License
|
2
|
+
|
3
|
+
Copyright (c) 2025 FuryCow
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,279 @@
|
|
1
|
+
# CodeSage 🔮
|
2
|
+
|
3
|
+
**Wisdom for your code** - AI-powered code review tool for Ruby projects.
|
4
|
+
|
5
|
+
CodeSage leverages the power of Large Language Models (LLM) through the [`llm_chain`](https://github.com/FuryCow/llm_chain) library to provide intelligent, context-aware code reviews for your Ruby projects. Get expert-level feedback on code quality, security, performance, and best practices.
|
6
|
+
|
7
|
+
## Features
|
8
|
+
|
9
|
+
- 🤖 **AI-Powered Reviews**: Intelligent code analysis using advanced language models
|
10
|
+
- 🔍 **Git Integration**: Seamless integration with Git workflows
|
11
|
+
- 📊 **Multiple Output Formats**: Console, JSON, and Markdown reports
|
12
|
+
- ⚙️ **Configurable**: Customizable review criteria and output preferences
|
13
|
+
- 🎯 **Ruby-Focused**: Specialized knowledge of Ruby best practices and idioms
|
14
|
+
- 🚀 **CLI Interface**: Easy-to-use command-line interface
|
15
|
+
- 🌐 **Multiple LLM Providers**: OpenAI, Ollama, Qwen, and more via llm_chain
|
16
|
+
- 🏠 **Local Models**: Support for local models through Ollama
|
17
|
+
- 🔧 **System Diagnostics**: Built-in health checks and configuration validation
|
18
|
+
|
19
|
+
## Installation
|
20
|
+
|
21
|
+
Add this line to your application's Gemfile:
|
22
|
+
|
23
|
+
```ruby
|
24
|
+
gem 'code_sage'
|
25
|
+
```
|
26
|
+
|
27
|
+
And then execute:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
$ bundle install
|
31
|
+
```
|
32
|
+
|
33
|
+
Or install it yourself as:
|
34
|
+
|
35
|
+
```bash
|
36
|
+
$ gem install code_sage
|
37
|
+
```
|
38
|
+
|
39
|
+
## Usage
|
40
|
+
|
41
|
+
### System Check
|
42
|
+
|
43
|
+
Before starting, run diagnostics to ensure your system is properly configured:
|
44
|
+
|
45
|
+
```bash
|
46
|
+
$ code_sage diagnose
|
47
|
+
```
|
48
|
+
|
49
|
+
### Basic Usage
|
50
|
+
|
51
|
+
Review changes between your current branch and main:
|
52
|
+
|
53
|
+
```bash
|
54
|
+
$ code_sage review
|
55
|
+
```
|
56
|
+
|
57
|
+
### Advanced Usage
|
58
|
+
|
59
|
+
```bash
|
60
|
+
# Review against a specific branch
|
61
|
+
$ code_sage review -b develop
|
62
|
+
|
63
|
+
# Review specific files
|
64
|
+
$ code_sage review -f lib/my_class.rb app/controllers/my_controller.rb
|
65
|
+
|
66
|
+
# Output in JSON format
|
67
|
+
$ code_sage review --format json
|
68
|
+
|
69
|
+
# Output in Markdown format
|
70
|
+
$ code_sage review --format markdown
|
71
|
+
|
72
|
+
# Verbose output
|
73
|
+
$ code_sage review -v
|
74
|
+
|
75
|
+
# Review with custom configuration
|
76
|
+
$ code_sage review -c ~/.my_code_sage_config.yml
|
77
|
+
```
|
78
|
+
|
79
|
+
### Configuration
|
80
|
+
|
81
|
+
CodeSage can be configured using a YAML file. By default, it looks for `~/.code_sage.yml`:
|
82
|
+
|
83
|
+
#### Basic Configuration
|
84
|
+
|
85
|
+
```yaml
|
86
|
+
llm:
|
87
|
+
provider: openai # openai, ollama, qwen
|
88
|
+
model: gpt-4
|
89
|
+
temperature: 0.1
|
90
|
+
max_tokens: 2000
|
91
|
+
api_key: null # Will use ENV variables
|
92
|
+
|
93
|
+
git:
|
94
|
+
default_branch: main
|
95
|
+
include_patterns:
|
96
|
+
- "*.rb"
|
97
|
+
- "*.rake"
|
98
|
+
- "Gemfile"
|
99
|
+
- "Rakefile"
|
100
|
+
exclude_patterns:
|
101
|
+
- "spec/**/*"
|
102
|
+
- "test/**/*"
|
103
|
+
|
104
|
+
review:
|
105
|
+
focus_areas:
|
106
|
+
- security
|
107
|
+
- performance
|
108
|
+
- maintainability
|
109
|
+
- best_practices
|
110
|
+
severity_levels:
|
111
|
+
- low
|
112
|
+
- medium
|
113
|
+
- high
|
114
|
+
- critical
|
115
|
+
|
116
|
+
output:
|
117
|
+
format: console
|
118
|
+
verbose: false
|
119
|
+
colors: true
|
120
|
+
```
|
121
|
+
|
122
|
+
#### Configuration Examples
|
123
|
+
|
124
|
+
**Using OpenAI GPT-4:**
|
125
|
+
```yaml
|
126
|
+
llm:
|
127
|
+
provider: openai
|
128
|
+
model: gpt-4
|
129
|
+
temperature: 0.1
|
130
|
+
max_tokens: 2000
|
131
|
+
```
|
132
|
+
|
133
|
+
**Using Local Ollama with Qwen:**
|
134
|
+
```yaml
|
135
|
+
llm:
|
136
|
+
provider: qwen
|
137
|
+
model: qwen2:7b
|
138
|
+
temperature: 0.2
|
139
|
+
```
|
140
|
+
|
141
|
+
**Using Local Ollama with LLaMA:**
|
142
|
+
```yaml
|
143
|
+
llm:
|
144
|
+
provider: ollama
|
145
|
+
model: llama2:7b
|
146
|
+
temperature: 0.1
|
147
|
+
```
|
148
|
+
|
149
|
+
#### Configuration Management
|
150
|
+
|
151
|
+
```bash
|
152
|
+
# Show current configuration
|
153
|
+
$ code_sage config --show
|
154
|
+
|
155
|
+
# Set LLM provider
|
156
|
+
$ code_sage config --key llm.provider --value ollama
|
157
|
+
|
158
|
+
# Set model
|
159
|
+
$ code_sage config --key llm.model --value qwen2:7b
|
160
|
+
|
161
|
+
# Reset to defaults
|
162
|
+
$ code_sage config --reset
|
163
|
+
```
|
164
|
+
|
165
|
+
### Programmatic Usage
|
166
|
+
|
167
|
+
You can also use CodeSage programmatically in your Ruby code:
|
168
|
+
|
169
|
+
```ruby
|
170
|
+
require 'code_sage'
|
171
|
+
|
172
|
+
# Basic review
|
173
|
+
result = CodeSage.review
|
174
|
+
|
175
|
+
# With options
|
176
|
+
result = CodeSage.review(
|
177
|
+
branch: 'develop',
|
178
|
+
files: ['lib/my_file.rb'],
|
179
|
+
format: 'json',
|
180
|
+
verbose: true
|
181
|
+
)
|
182
|
+
|
183
|
+
puts result[:report] if result[:success]
|
184
|
+
```
|
185
|
+
|
186
|
+
## CLI Commands
|
187
|
+
|
188
|
+
### `review`
|
189
|
+
|
190
|
+
Perform a code review on your repository.
|
191
|
+
|
192
|
+
**Options:**
|
193
|
+
- `-b, --branch BRANCH` - Branch to compare against (default: main)
|
194
|
+
- `-f, --files FILES` - Specific files to review
|
195
|
+
- `--format FORMAT` - Output format: console, json, markdown (default: console)
|
196
|
+
- `-c, --config PATH` - Path to configuration file
|
197
|
+
- `-v, --verbose` - Verbose output
|
198
|
+
- `--rag` - Enable RAG (Retrieval Augmented Generation) functionality
|
199
|
+
|
200
|
+
### `config`
|
201
|
+
|
202
|
+
Manage configuration settings.
|
203
|
+
|
204
|
+
**Options:**
|
205
|
+
- `--show` - Show current configuration
|
206
|
+
- `--key KEY --value VALUE` - Set configuration values
|
207
|
+
- `--reset` - Reset configuration to defaults
|
208
|
+
|
209
|
+
### `diagnose`
|
210
|
+
|
211
|
+
Run comprehensive system diagnostics to check your setup.
|
212
|
+
|
213
|
+
**Features:**
|
214
|
+
- Check Ruby, Git, and llm_chain availability
|
215
|
+
- Validate API key configuration
|
216
|
+
- Display current LLM provider and model
|
217
|
+
- Provide setup recommendations
|
218
|
+
|
219
|
+
### `version`
|
220
|
+
|
221
|
+
Show the current version of CodeSage.
|
222
|
+
|
223
|
+
## Requirements
|
224
|
+
|
225
|
+
- Ruby >= 2.7.0
|
226
|
+
- Git repository
|
227
|
+
- [`llm_chain`](https://github.com/FuryCow/llm_chain) gem configured with your preferred LLM provider
|
228
|
+
|
229
|
+
### LLM Provider Setup
|
230
|
+
|
231
|
+
CodeSage supports multiple LLM providers through llm_chain:
|
232
|
+
|
233
|
+
#### OpenAI (Default)
|
234
|
+
```bash
|
235
|
+
export OPENAI_API_KEY="your-openai-api-key"
|
236
|
+
```
|
237
|
+
|
238
|
+
#### Local Models via Ollama
|
239
|
+
```bash
|
240
|
+
# Install Ollama
|
241
|
+
curl -fsSL https://ollama.ai/install.sh | sh
|
242
|
+
|
243
|
+
# Download models
|
244
|
+
ollama pull qwen2:7b
|
245
|
+
ollama pull llama2:7b
|
246
|
+
|
247
|
+
# Start Ollama server
|
248
|
+
ollama serve
|
249
|
+
```
|
250
|
+
|
251
|
+
#### Other Providers
|
252
|
+
- **Anthropic**: Set `ANTHROPIC_API_KEY`
|
253
|
+
- **Google**: Set `GOOGLE_API_KEY`
|
254
|
+
- **Qwen**: Available through Ollama
|
255
|
+
|
256
|
+
## Dependencies
|
257
|
+
|
258
|
+
- `llm_chain` - For LLM integration
|
259
|
+
- `thor` - CLI framework
|
260
|
+
- `colorize` - Terminal colors
|
261
|
+
- `rugged` - Git integration
|
262
|
+
|
263
|
+
## Development
|
264
|
+
|
265
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
|
266
|
+
|
267
|
+
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
268
|
+
|
269
|
+
## Contributing
|
270
|
+
|
271
|
+
Bug reports and pull requests are welcome on GitHub at https://github.com/FuryCow/code_sage.
|
272
|
+
|
273
|
+
## License
|
274
|
+
|
275
|
+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
|
276
|
+
|
277
|
+
## Changelog
|
278
|
+
|
279
|
+
See [CHANGELOG.md](CHANGELOG.md) for version history and changes.
|
data/Rakefile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
require "rspec/core/rake_task"
|
3
|
+
|
4
|
+
RSpec::Core::RakeTask.new(:spec)
|
5
|
+
|
6
|
+
begin
|
7
|
+
require 'rubocop/rake_task'
|
8
|
+
RuboCop::RakeTask.new
|
9
|
+
rescue LoadError
|
10
|
+
# Rubocop not available
|
11
|
+
end
|
12
|
+
|
13
|
+
task :default => :spec
|
14
|
+
|
15
|
+
desc "Run a console with code_sage loaded"
|
16
|
+
task :console do
|
17
|
+
require 'pry'
|
18
|
+
require_relative 'lib/code_sage'
|
19
|
+
Pry.start
|
20
|
+
end
|
data/bin/console
ADDED
data/bin/setup
ADDED
data/code_sage.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative 'lib/code_sage/version'
|
2
|
+
|
3
|
+
Gem::Specification.new do |spec|
|
4
|
+
spec.name = "code_sage"
|
5
|
+
spec.version = CodeSage::VERSION
|
6
|
+
spec.authors = ["FuryCow"]
|
7
|
+
spec.email = ["info@furycow.com"]
|
8
|
+
|
9
|
+
spec.summary = "AI-powered code review tool for Ruby"
|
10
|
+
spec.description = "Wisdom for your code - an intelligent code review assistant using LLM"
|
11
|
+
spec.homepage = "https://github.com/FuryCow/code_sage"
|
12
|
+
spec.license = "MIT"
|
13
|
+
|
14
|
+
spec.required_ruby_version = Gem::Requirement.new(">= 2.7.0")
|
15
|
+
|
16
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
17
|
+
spec.metadata["source_code_uri"] = "https://github.com/FuryCow/code_sage"
|
18
|
+
spec.metadata["changelog_uri"] = "https://github.com/FuryCow/code_sage/blob/master/CHANGELOG.md"
|
19
|
+
|
20
|
+
# Specify which files should be added to the gem when it is released.
|
21
|
+
spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
|
22
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
23
|
+
end
|
24
|
+
spec.bindir = "exe"
|
25
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
26
|
+
spec.require_paths = ["lib"]
|
27
|
+
|
28
|
+
# Dependencies
|
29
|
+
spec.add_dependency "llm_chain", "~> 0.5.2"
|
30
|
+
spec.add_dependency "thor", "~> 1.0"
|
31
|
+
spec.add_dependency "colorize", "~> 0.8"
|
32
|
+
spec.add_dependency "rugged", "~> 1.0"
|
33
|
+
|
34
|
+
# Development dependencies
|
35
|
+
spec.add_development_dependency "bundler", "~> 2.0"
|
36
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
37
|
+
spec.add_development_dependency "rspec", "~> 3.0"
|
38
|
+
spec.add_development_dependency "pry"
|
39
|
+
end
|