monty-ai 0.2.0 → 0.4.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 +4 -4
- data/.github/workflows/main.yml +27 -0
- data/.gitignore +14 -0
- data/.rspec +3 -0
- data/.rubocop.yml +13 -0
- data/.rubocop_todo.yml +50 -0
- data/CHANGELOG.md +5 -0
- data/CODE_OF_CONDUCT.md +132 -0
- data/CONTRIBUTING.md +69 -0
- data/Gemfile +20 -0
- data/Gemfile.lock +113 -0
- data/Rakefile +12 -0
- data/bin/console +11 -0
- data/bin/setup +8 -0
- data/lib/monty_ai/cli.rb +3 -1
- data/lib/monty_ai/formatter.rb +22 -4
- data/lib/monty_ai/syntax_highlighter.rb +47 -0
- data/lib/monty_ai/version.rb +1 -1
- data/lib/monty_ai.rb +1 -0
- data/monty_ai.gemspec +39 -0
- data/montyai-logo.svg +44 -0
- data/sig/monty_ai.rbs +4 -0
- metadata +47 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81eee1ee0bb2c708fbac144ed4c897ef4fca4bfcf92092788cab32eae197a48b
|
4
|
+
data.tar.gz: 64867682c15ff89c95cbbbe59c2a629fb45d39172981121ed731b2acc1467beb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 92ffc6b0b9f2d6836539e165e97f16d085ea57449b349b391217a8c301f724ab748cf4d7c25ecf99be5f3306904edb9cf027100bc199079da16ac7df23c7b1ab
|
7
|
+
data.tar.gz: c9ec6226aa8d9d316c5a1e88bd2d42a4be2d4bb2c4f69617e7683fb6ac15d4ea44cc8e08e5787e7331fe2b06fa5705de5e364096c27f8d7a8c741f7bdec36ed1
|
@@ -0,0 +1,27 @@
|
|
1
|
+
name: Ruby
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
branches:
|
6
|
+
- main
|
7
|
+
|
8
|
+
pull_request:
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
build:
|
12
|
+
runs-on: ubuntu-latest
|
13
|
+
name: Ruby ${{ matrix.ruby }}
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
ruby:
|
17
|
+
- "3.4.2"
|
18
|
+
|
19
|
+
steps:
|
20
|
+
- uses: actions/checkout@v4
|
21
|
+
- name: Set up Ruby
|
22
|
+
uses: ruby/setup-ruby@v1
|
23
|
+
with:
|
24
|
+
ruby-version: ${{ matrix.ruby }}
|
25
|
+
bundler-cache: true
|
26
|
+
- name: Run the default task
|
27
|
+
run: bundle exec rake
|
data/.gitignore
ADDED
data/.rspec
ADDED
data/.rubocop.yml
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
inherit_from: .rubocop_todo.yml
|
2
|
+
|
3
|
+
AllCops:
|
4
|
+
TargetRubyVersion: 3.4.2
|
5
|
+
|
6
|
+
Style/StringLiterals:
|
7
|
+
EnforcedStyle: double_quotes
|
8
|
+
|
9
|
+
Style/StringLiteralsInInterpolation:
|
10
|
+
EnforcedStyle: double_quotes
|
11
|
+
|
12
|
+
Layout/FirstHashElementIndentation:
|
13
|
+
Enabled: false
|
data/.rubocop_todo.yml
ADDED
@@ -0,0 +1,50 @@
|
|
1
|
+
# This configuration was generated by
|
2
|
+
# `rubocop --auto-gen-config`
|
3
|
+
# on 2025-04-12 15:03:41 UTC using RuboCop version 1.75.2.
|
4
|
+
# The point is for the user to remove these configuration records
|
5
|
+
# one by one as the offenses are removed from the code base.
|
6
|
+
# Note that changes in the inspected code, or installation of new
|
7
|
+
# versions of RuboCop, may require this file to be generated again.
|
8
|
+
|
9
|
+
# Offense count: 1
|
10
|
+
# Configuration parameters: AllowedMethods, AllowedPatterns, CountRepeatedAttributes.
|
11
|
+
Metrics/AbcSize:
|
12
|
+
Max: 24
|
13
|
+
|
14
|
+
# Offense count: 3
|
15
|
+
# Configuration parameters: CountComments, CountAsOne, AllowedMethods, AllowedPatterns.
|
16
|
+
Metrics/MethodLength:
|
17
|
+
Max: 35
|
18
|
+
|
19
|
+
# Offense count: 4
|
20
|
+
# Configuration parameters: AllowedConstants.
|
21
|
+
Style/Documentation:
|
22
|
+
Exclude:
|
23
|
+
- 'spec/**/*'
|
24
|
+
- 'test/**/*'
|
25
|
+
- 'lib/monty_ai/ai_client.rb'
|
26
|
+
- 'lib/monty_ai/cli.rb'
|
27
|
+
- 'lib/monty_ai/file_handler.rb'
|
28
|
+
- 'lib/monty_ai/formatter.rb'
|
29
|
+
|
30
|
+
# Offense count: 1
|
31
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
32
|
+
# Configuration parameters: EnforcedStyle.
|
33
|
+
# SupportedStyles: always, always_true, never
|
34
|
+
Style/FrozenStringLiteralComment:
|
35
|
+
Exclude:
|
36
|
+
- '**/*.arb'
|
37
|
+
- 'bin/monty'
|
38
|
+
|
39
|
+
# Offense count: 2
|
40
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
41
|
+
Style/LineEndConcatenation:
|
42
|
+
Exclude:
|
43
|
+
- 'lib/monty_ai/ai_client.rb'
|
44
|
+
|
45
|
+
# Offense count: 1
|
46
|
+
# This cop supports unsafe autocorrection (--autocorrect-all).
|
47
|
+
# Configuration parameters: Mode.
|
48
|
+
Style/StringConcatenation:
|
49
|
+
Exclude:
|
50
|
+
- 'lib/monty_ai/ai_client.rb'
|
data/CHANGELOG.md
ADDED
data/CODE_OF_CONDUCT.md
ADDED
@@ -0,0 +1,132 @@
|
|
1
|
+
# Contributor Covenant Code of Conduct
|
2
|
+
|
3
|
+
## Our Pledge
|
4
|
+
|
5
|
+
We as members, contributors, and leaders pledge to make participation in our
|
6
|
+
community a harassment-free experience for everyone, regardless of age, body
|
7
|
+
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
+
identity and expression, level of experience, education, socio-economic status,
|
9
|
+
nationality, personal appearance, race, caste, color, religion, or sexual
|
10
|
+
identity and orientation.
|
11
|
+
|
12
|
+
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
+
diverse, inclusive, and healthy community.
|
14
|
+
|
15
|
+
## Our Standards
|
16
|
+
|
17
|
+
Examples of behavior that contributes to a positive environment for our
|
18
|
+
community include:
|
19
|
+
|
20
|
+
* Demonstrating empathy and kindness toward other people
|
21
|
+
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
+
* Giving and gracefully accepting constructive feedback
|
23
|
+
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
+
and learning from the experience
|
25
|
+
* Focusing on what is best not just for us as individuals, but for the overall
|
26
|
+
community
|
27
|
+
|
28
|
+
Examples of unacceptable behavior include:
|
29
|
+
|
30
|
+
* The use of sexualized language or imagery, and sexual attention or advances of
|
31
|
+
any kind
|
32
|
+
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
+
* Public or private harassment
|
34
|
+
* Publishing others' private information, such as a physical or email address,
|
35
|
+
without their explicit permission
|
36
|
+
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
+
professional setting
|
38
|
+
|
39
|
+
## Enforcement Responsibilities
|
40
|
+
|
41
|
+
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
+
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
+
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
+
or harmful.
|
45
|
+
|
46
|
+
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
+
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
+
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
+
decisions when appropriate.
|
50
|
+
|
51
|
+
## Scope
|
52
|
+
|
53
|
+
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
+
an individual is officially representing the community in public spaces.
|
55
|
+
Examples of representing our community include using an official email address,
|
56
|
+
posting via an official social media account, or acting as an appointed
|
57
|
+
representative at an online or offline event.
|
58
|
+
|
59
|
+
## Enforcement
|
60
|
+
|
61
|
+
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
+
reported to the community leaders responsible for enforcement at
|
63
|
+
[INSERT CONTACT METHOD].
|
64
|
+
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
+
|
66
|
+
All community leaders are obligated to respect the privacy and security of the
|
67
|
+
reporter of any incident.
|
68
|
+
|
69
|
+
## Enforcement Guidelines
|
70
|
+
|
71
|
+
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
+
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
+
|
74
|
+
### 1. Correction
|
75
|
+
|
76
|
+
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
+
unprofessional or unwelcome in the community.
|
78
|
+
|
79
|
+
**Consequence**: A private, written warning from community leaders, providing
|
80
|
+
clarity around the nature of the violation and an explanation of why the
|
81
|
+
behavior was inappropriate. A public apology may be requested.
|
82
|
+
|
83
|
+
### 2. Warning
|
84
|
+
|
85
|
+
**Community Impact**: A violation through a single incident or series of
|
86
|
+
actions.
|
87
|
+
|
88
|
+
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
+
interaction with the people involved, including unsolicited interaction with
|
90
|
+
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
+
includes avoiding interactions in community spaces as well as external channels
|
92
|
+
like social media. Violating these terms may lead to a temporary or permanent
|
93
|
+
ban.
|
94
|
+
|
95
|
+
### 3. Temporary Ban
|
96
|
+
|
97
|
+
**Community Impact**: A serious violation of community standards, including
|
98
|
+
sustained inappropriate behavior.
|
99
|
+
|
100
|
+
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
+
communication with the community for a specified period of time. No public or
|
102
|
+
private interaction with the people involved, including unsolicited interaction
|
103
|
+
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
+
Violating these terms may lead to a permanent ban.
|
105
|
+
|
106
|
+
### 4. Permanent Ban
|
107
|
+
|
108
|
+
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
+
standards, including sustained inappropriate behavior, harassment of an
|
110
|
+
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
+
|
112
|
+
**Consequence**: A permanent ban from any sort of public interaction within the
|
113
|
+
community.
|
114
|
+
|
115
|
+
## Attribution
|
116
|
+
|
117
|
+
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
+
version 2.1, available at
|
119
|
+
[https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
|
120
|
+
|
121
|
+
Community Impact Guidelines were inspired by
|
122
|
+
[Mozilla's code of conduct enforcement ladder][Mozilla CoC].
|
123
|
+
|
124
|
+
For answers to common questions about this code of conduct, see the FAQ at
|
125
|
+
[https://www.contributor-covenant.org/faq][FAQ]. Translations are available at
|
126
|
+
[https://www.contributor-covenant.org/translations][translations].
|
127
|
+
|
128
|
+
[homepage]: https://www.contributor-covenant.org
|
129
|
+
[v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
|
130
|
+
[Mozilla CoC]: https://github.com/mozilla/diversity
|
131
|
+
[FAQ]: https://www.contributor-covenant.org/faq
|
132
|
+
[translations]: https://www.contributor-covenant.org/translations
|
data/CONTRIBUTING.md
ADDED
@@ -0,0 +1,69 @@
|
|
1
|
+
# Contributing to MontyAI
|
2
|
+
|
3
|
+
First off, thank you for considering contributing to MontyAI! 🎉
|
4
|
+
|
5
|
+
## 🛠 Development Setup
|
6
|
+
|
7
|
+
1. Fork the repository
|
8
|
+
2. Clone your fork
|
9
|
+
3. Create a new branch for your feature
|
10
|
+
4. Make your changes
|
11
|
+
5. Run tests and linter
|
12
|
+
6. Submit a pull request
|
13
|
+
|
14
|
+
### Prerequisites
|
15
|
+
|
16
|
+
- Ruby 3.0+
|
17
|
+
- Bundler
|
18
|
+
- OpenAI API Key (for testing)
|
19
|
+
|
20
|
+
### Local Development
|
21
|
+
|
22
|
+
```bash
|
23
|
+
# Install dependencies
|
24
|
+
bundle install
|
25
|
+
|
26
|
+
# Run tests
|
27
|
+
bundle exec rspec
|
28
|
+
|
29
|
+
# Run linter
|
30
|
+
bundle exec rubocop
|
31
|
+
```
|
32
|
+
|
33
|
+
## 🤝 How to Contribute
|
34
|
+
|
35
|
+
### Reporting Bugs
|
36
|
+
|
37
|
+
- Use the GitHub Issues section
|
38
|
+
- Provide a clear and descriptive title
|
39
|
+
- Describe the expected behavior and actual behavior
|
40
|
+
- Include steps to reproduce the issue
|
41
|
+
- Provide your Ruby version and system details
|
42
|
+
|
43
|
+
### Suggesting Enhancements
|
44
|
+
|
45
|
+
- Open a GitHub Issue
|
46
|
+
- Clearly describe the enhancement
|
47
|
+
- Provide context and potential implementation details
|
48
|
+
|
49
|
+
### Pull Request Process
|
50
|
+
|
51
|
+
1. Ensure all tests pass
|
52
|
+
2. Update documentation if necessary
|
53
|
+
3. Add tests for new features
|
54
|
+
4. Ensure code follows RuboCop style guidelines
|
55
|
+
|
56
|
+
## 🌟 Code of Conduct
|
57
|
+
|
58
|
+
Be respectful, inclusive, and constructive. I welcome contributions from everyone!
|
59
|
+
|
60
|
+
## 📝 Code Style
|
61
|
+
|
62
|
+
- Follow RuboCop guidelines
|
63
|
+
- Write clear, concise comments
|
64
|
+
- Keep methods small and focused
|
65
|
+
- Write tests for new features
|
66
|
+
|
67
|
+
## 🏆 Recognition
|
68
|
+
|
69
|
+
Contributors will be acknowledged in the README and project documentation.
|
data/Gemfile
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
# Specify your gem's dependencies in monty_ai.gemspec
|
6
|
+
gemspec
|
7
|
+
|
8
|
+
gem "thor"
|
9
|
+
|
10
|
+
group :development, :test do
|
11
|
+
gem "irb"
|
12
|
+
gem "rake", "~> 13.0"
|
13
|
+
gem "rspec", "~> 3.0"
|
14
|
+
gem "rubocop", "~> 1.21"
|
15
|
+
end
|
16
|
+
|
17
|
+
# You might have a separate group for documentation as well
|
18
|
+
group :doc do
|
19
|
+
gem "yard"
|
20
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,113 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
monty-ai (0.3.0)
|
5
|
+
pastel (~> 0.8.0)
|
6
|
+
rouge (~> 4.0)
|
7
|
+
thor (~> 1.2)
|
8
|
+
|
9
|
+
GEM
|
10
|
+
remote: https://rubygems.org/
|
11
|
+
specs:
|
12
|
+
ast (2.4.3)
|
13
|
+
date (3.4.1)
|
14
|
+
diff-lcs (1.6.1)
|
15
|
+
io-console (0.8.0)
|
16
|
+
irb (1.15.2)
|
17
|
+
pp (>= 0.6.0)
|
18
|
+
rdoc (>= 4.0.0)
|
19
|
+
reline (>= 0.4.2)
|
20
|
+
json (2.10.2)
|
21
|
+
language_server-protocol (3.17.0.4)
|
22
|
+
lint_roller (1.1.0)
|
23
|
+
parallel (1.26.3)
|
24
|
+
parser (3.3.7.4)
|
25
|
+
ast (~> 2.4.1)
|
26
|
+
racc
|
27
|
+
pastel (0.8.0)
|
28
|
+
tty-color (~> 0.5)
|
29
|
+
pp (0.6.2)
|
30
|
+
prettyprint
|
31
|
+
prettyprint (0.2.0)
|
32
|
+
prism (1.4.0)
|
33
|
+
psych (5.2.3)
|
34
|
+
date
|
35
|
+
stringio
|
36
|
+
racc (1.8.1)
|
37
|
+
rainbow (3.1.1)
|
38
|
+
rake (13.2.1)
|
39
|
+
rdoc (6.13.1)
|
40
|
+
psych (>= 4.0.0)
|
41
|
+
regexp_parser (2.10.0)
|
42
|
+
reline (0.6.1)
|
43
|
+
io-console (~> 0.5)
|
44
|
+
rouge (4.5.1)
|
45
|
+
rspec (3.13.0)
|
46
|
+
rspec-core (~> 3.13.0)
|
47
|
+
rspec-expectations (~> 3.13.0)
|
48
|
+
rspec-mocks (~> 3.13.0)
|
49
|
+
rspec-core (3.13.3)
|
50
|
+
rspec-support (~> 3.13.0)
|
51
|
+
rspec-expectations (3.13.3)
|
52
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
53
|
+
rspec-support (~> 3.13.0)
|
54
|
+
rspec-mocks (3.13.2)
|
55
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
56
|
+
rspec-support (~> 3.13.0)
|
57
|
+
rspec-support (3.13.2)
|
58
|
+
rubocop (1.75.2)
|
59
|
+
json (~> 2.3)
|
60
|
+
language_server-protocol (~> 3.17.0.2)
|
61
|
+
lint_roller (~> 1.1.0)
|
62
|
+
parallel (~> 1.10)
|
63
|
+
parser (>= 3.3.0.2)
|
64
|
+
rainbow (>= 2.2.2, < 4.0)
|
65
|
+
regexp_parser (>= 2.9.3, < 3.0)
|
66
|
+
rubocop-ast (>= 1.44.0, < 2.0)
|
67
|
+
ruby-progressbar (~> 1.7)
|
68
|
+
unicode-display_width (>= 2.4.0, < 4.0)
|
69
|
+
rubocop-ast (1.44.1)
|
70
|
+
parser (>= 3.3.7.2)
|
71
|
+
prism (~> 1.4)
|
72
|
+
rubocop-performance (1.25.0)
|
73
|
+
lint_roller (~> 1.1)
|
74
|
+
rubocop (>= 1.75.0, < 2.0)
|
75
|
+
rubocop-ast (>= 1.38.0, < 2.0)
|
76
|
+
ruby-progressbar (1.13.0)
|
77
|
+
standard (1.49.0)
|
78
|
+
language_server-protocol (~> 3.17.0.2)
|
79
|
+
lint_roller (~> 1.0)
|
80
|
+
rubocop (~> 1.75.2)
|
81
|
+
standard-custom (~> 1.0.0)
|
82
|
+
standard-performance (~> 1.8)
|
83
|
+
standard-custom (1.0.2)
|
84
|
+
lint_roller (~> 1.0)
|
85
|
+
rubocop (~> 1.50)
|
86
|
+
standard-performance (1.8.0)
|
87
|
+
lint_roller (~> 1.1)
|
88
|
+
rubocop-performance (~> 1.25.0)
|
89
|
+
stringio (3.1.6)
|
90
|
+
thor (1.3.2)
|
91
|
+
tty-color (0.6.0)
|
92
|
+
unicode-display_width (3.1.4)
|
93
|
+
unicode-emoji (~> 4.0, >= 4.0.4)
|
94
|
+
unicode-emoji (4.0.4)
|
95
|
+
yard (0.9.37)
|
96
|
+
|
97
|
+
PLATFORMS
|
98
|
+
arm64-darwin-24
|
99
|
+
ruby
|
100
|
+
|
101
|
+
DEPENDENCIES
|
102
|
+
bundler (~> 2.0)
|
103
|
+
irb
|
104
|
+
monty-ai!
|
105
|
+
rake (~> 13.0)
|
106
|
+
rspec (~> 3.0)
|
107
|
+
rubocop (~> 1.21)
|
108
|
+
standard (~> 1.3)
|
109
|
+
thor
|
110
|
+
yard
|
111
|
+
|
112
|
+
BUNDLED WITH
|
113
|
+
2.6.6
|
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
4
|
+
require "bundler/setup"
|
5
|
+
require "monty_ai"
|
6
|
+
|
7
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
8
|
+
# with your gem easier. You can also use a different console, if you like.
|
9
|
+
|
10
|
+
require "irb"
|
11
|
+
IRB.start(__FILE__)
|
data/bin/setup
ADDED
data/lib/monty_ai/cli.rb
CHANGED
@@ -28,6 +28,8 @@ module MontyAI
|
|
28
28
|
|
29
29
|
private
|
30
30
|
|
31
|
+
# lib/monty_ai/cli.rb
|
32
|
+
# In the handle_code method:
|
31
33
|
def handle_code(code, filename = nil)
|
32
34
|
puts "Analyzing code..."
|
33
35
|
|
@@ -40,7 +42,7 @@ module MontyAI
|
|
40
42
|
puts ""
|
41
43
|
end
|
42
44
|
|
43
|
-
puts Formatter.format(explanation)
|
45
|
+
puts Formatter.format(explanation, code, filename)
|
44
46
|
rescue Error => e
|
45
47
|
puts "Error: #{e.message}"
|
46
48
|
exit 1
|
data/lib/monty_ai/formatter.rb
CHANGED
@@ -1,11 +1,29 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# lib/monty_ai/formatter.rb
|
3
4
|
module MontyAI
|
4
5
|
class Formatter
|
5
|
-
def self.format(explanation)
|
6
|
-
#
|
7
|
-
|
8
|
-
|
6
|
+
def self.format(explanation, code = nil, filename = nil)
|
7
|
+
# If no code is provided, just return the explanation
|
8
|
+
return explanation unless code
|
9
|
+
|
10
|
+
# Initialize highlighter
|
11
|
+
highlighter = SyntaxHighlighter.new
|
12
|
+
language = filename ? highlighter.detect_language(filename) : :text
|
13
|
+
|
14
|
+
# Highlight the code
|
15
|
+
highlighted_code = highlighter.highlight(code, language)
|
16
|
+
|
17
|
+
# Format the output with highlighted code
|
18
|
+
output = []
|
19
|
+
output << "```"
|
20
|
+
output << highlighted_code
|
21
|
+
output << "```"
|
22
|
+
output << ""
|
23
|
+
output << "Explanation:"
|
24
|
+
output << explanation
|
25
|
+
|
26
|
+
output.join("\n")
|
9
27
|
end
|
10
28
|
end
|
11
29
|
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rouge"
|
4
|
+
require "pastel"
|
5
|
+
|
6
|
+
module MontyAI
|
7
|
+
class SyntaxHighlighter
|
8
|
+
def initialize
|
9
|
+
@pastel = Pastel.new
|
10
|
+
end
|
11
|
+
|
12
|
+
def highlight(code, language = :ruby)
|
13
|
+
formatter = Rouge::Formatters::Terminal256.new(Rouge::Themes::Monokai.new)
|
14
|
+
lexer = Rouge::Lexer.find(language.to_s) || Rouge::Lexers::PlainText.new
|
15
|
+
formatter.format(lexer.lex(code))
|
16
|
+
end
|
17
|
+
|
18
|
+
def detect_language(filename)
|
19
|
+
extension = File.extname(filename).downcase
|
20
|
+
|
21
|
+
case extension
|
22
|
+
when ".go"
|
23
|
+
:go
|
24
|
+
when ".rb"
|
25
|
+
:ruby
|
26
|
+
when ".js"
|
27
|
+
:javascript
|
28
|
+
when ".jsx"
|
29
|
+
:react_javascript
|
30
|
+
when ".py"
|
31
|
+
:python
|
32
|
+
when ".java"
|
33
|
+
:java
|
34
|
+
when ".php"
|
35
|
+
:php
|
36
|
+
when ".rs"
|
37
|
+
:rust
|
38
|
+
when ".ts"
|
39
|
+
:typescript
|
40
|
+
when ".tsx"
|
41
|
+
:react_typescript
|
42
|
+
else
|
43
|
+
:text
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
data/lib/monty_ai/version.rb
CHANGED
data/lib/monty_ai.rb
CHANGED
data/monty_ai.gemspec
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative "lib/monty_ai/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |spec|
|
6
|
+
spec.name = "monty-ai"
|
7
|
+
spec.version = MontyAI::VERSION
|
8
|
+
spec.authors = ["Steve Cook"]
|
9
|
+
spec.email = ["stevorevo@duck.com"]
|
10
|
+
|
11
|
+
spec.summary = "CLI tool to explain code using AI"
|
12
|
+
spec.description = "MontyAI is an intelligent code explanation tool that uses AI to help you understand code faster."
|
13
|
+
spec.homepage = "https://github.com/scookdev/monty_ai"
|
14
|
+
spec.license = "MIT"
|
15
|
+
spec.required_ruby_version = ">= 3.4.2"
|
16
|
+
|
17
|
+
spec.metadata["homepage_uri"] = spec.homepage
|
18
|
+
spec.metadata["source_code_uri"] = spec.homepage
|
19
|
+
spec.metadata["changelog_uri"] = "#{spec.homepage}/blob/main/CHANGELOG.md"
|
20
|
+
|
21
|
+
# Specify which files should be added to the gem when it is released.
|
22
|
+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
|
23
|
+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
24
|
+
end
|
25
|
+
spec.bindir = "exe"
|
26
|
+
spec.executables = ["monty-ai"]
|
27
|
+
spec.require_paths = ["lib"]
|
28
|
+
|
29
|
+
# Dependencies
|
30
|
+
spec.add_dependency "pastel", "~> 0.8.0" # For terminal colors
|
31
|
+
spec.add_dependency "rouge", "~> 4.0" # For syntax highlighting
|
32
|
+
spec.add_dependency "thor", "~> 1.2"
|
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 "standard", "~> 1.3"
|
39
|
+
end
|
data/montyai-logo.svg
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
2
|
+
<svg viewBox="0 0 800 300" xmlns="http://www.w3.org/2000/svg">
|
3
|
+
<!-- Rounded Rectangle Background -->
|
4
|
+
<rect x="10" y="20" width="780" height="260" rx="60" ry="60" fill="#6a1fec" />
|
5
|
+
|
6
|
+
<!-- Three Dots -->
|
7
|
+
<circle cx="95" cy="70" r="12" fill="white" />
|
8
|
+
<circle cx="135" cy="70" r="12" fill="white" />
|
9
|
+
<circle cx="175" cy="70" r="12" fill="white" />
|
10
|
+
|
11
|
+
<!-- MontyAI Text -->
|
12
|
+
<text x="105" y="185" font-family="Arial, sans-serif" font-size="95" font-weight="bold" fill="white">
|
13
|
+
Monty<tspan fill="#7fffd4">AI</tspan>
|
14
|
+
</text>
|
15
|
+
|
16
|
+
<!-- Tagline -->
|
17
|
+
<text x="90" y="250" font-family="Arial, sans-serif" font-size="35" font-style="italic" fill="white">
|
18
|
+
Intelligent Code Explanations
|
19
|
+
</text>
|
20
|
+
|
21
|
+
<!-- Robot Character -->
|
22
|
+
<g transform="translate(630, 80)">
|
23
|
+
<!-- Head -->
|
24
|
+
<circle cx="40" cy="40" r="35" fill="#7fffd4" />
|
25
|
+
|
26
|
+
<!-- Eyes -->
|
27
|
+
<circle cx="30" cy="40" r="5" fill="#6a1fec" />
|
28
|
+
<circle cx="50" cy="40" r="5" fill="#6a1fec" />
|
29
|
+
|
30
|
+
<!-- Mouth -->
|
31
|
+
<line x1="30" y1="60" x2="50" y2="60" stroke="#6a1fec" stroke-width="3" />
|
32
|
+
|
33
|
+
<!-- Body -->
|
34
|
+
<rect x="20" y="80" width="40" height="40" rx="5" ry="5" fill="#7fffd4" />
|
35
|
+
|
36
|
+
<!-- Arms -->
|
37
|
+
<rect x="5" y="85" width="15" height="10" rx="3" ry="3" fill="#7fffd4" />
|
38
|
+
<rect x="60" y="85" width="15" height="10" rx="3" ry="3" fill="#7fffd4" />
|
39
|
+
|
40
|
+
<!-- Legs -->
|
41
|
+
<rect x="30" y="120" width="10" height="20" rx="3" ry="3" fill="#7fffd4" />
|
42
|
+
<rect x="50" y="120" width="10" height="20" rx="3" ry="3" fill="#7fffd4" />
|
43
|
+
</g>
|
44
|
+
</svg>
|
data/sig/monty_ai.rbs
ADDED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monty-ai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Cook
|
@@ -9,6 +9,34 @@ bindir: exe
|
|
9
9
|
cert_chain: []
|
10
10
|
date: 1980-01-02 00:00:00.000000000 Z
|
11
11
|
dependencies:
|
12
|
+
- !ruby/object:Gem::Dependency
|
13
|
+
name: pastel
|
14
|
+
requirement: !ruby/object:Gem::Requirement
|
15
|
+
requirements:
|
16
|
+
- - "~>"
|
17
|
+
- !ruby/object:Gem::Version
|
18
|
+
version: 0.8.0
|
19
|
+
type: :runtime
|
20
|
+
prerelease: false
|
21
|
+
version_requirements: !ruby/object:Gem::Requirement
|
22
|
+
requirements:
|
23
|
+
- - "~>"
|
24
|
+
- !ruby/object:Gem::Version
|
25
|
+
version: 0.8.0
|
26
|
+
- !ruby/object:Gem::Dependency
|
27
|
+
name: rouge
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '4.0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: !ruby/object:Gem::Requirement
|
36
|
+
requirements:
|
37
|
+
- - "~>"
|
38
|
+
- !ruby/object:Gem::Version
|
39
|
+
version: '4.0'
|
12
40
|
- !ruby/object:Gem::Dependency
|
13
41
|
name: thor
|
14
42
|
requirement: !ruby/object:Gem::Requirement
|
@@ -82,21 +110,38 @@ dependencies:
|
|
82
110
|
description: MontyAI is an intelligent code explanation tool that uses AI to help
|
83
111
|
you understand code faster.
|
84
112
|
email:
|
85
|
-
- stevorevo@duck.
|
113
|
+
- stevorevo@duck.com
|
86
114
|
executables:
|
87
115
|
- monty-ai
|
88
116
|
extensions: []
|
89
117
|
extra_rdoc_files: []
|
90
118
|
files:
|
119
|
+
- ".github/workflows/main.yml"
|
120
|
+
- ".gitignore"
|
121
|
+
- ".rspec"
|
122
|
+
- ".rubocop.yml"
|
123
|
+
- ".rubocop_todo.yml"
|
124
|
+
- CHANGELOG.md
|
125
|
+
- CODE_OF_CONDUCT.md
|
126
|
+
- CONTRIBUTING.md
|
127
|
+
- Gemfile
|
128
|
+
- Gemfile.lock
|
91
129
|
- LICENSE.txt
|
92
130
|
- README.md
|
131
|
+
- Rakefile
|
132
|
+
- bin/console
|
133
|
+
- bin/setup
|
93
134
|
- exe/monty-ai
|
94
135
|
- lib/monty_ai.rb
|
95
136
|
- lib/monty_ai/ai_client.rb
|
96
137
|
- lib/monty_ai/cli.rb
|
97
138
|
- lib/monty_ai/file_handler.rb
|
98
139
|
- lib/monty_ai/formatter.rb
|
140
|
+
- lib/monty_ai/syntax_highlighter.rb
|
99
141
|
- lib/monty_ai/version.rb
|
142
|
+
- monty_ai.gemspec
|
143
|
+
- montyai-logo.svg
|
144
|
+
- sig/monty_ai.rbs
|
100
145
|
homepage: https://github.com/scookdev/monty_ai
|
101
146
|
licenses:
|
102
147
|
- MIT
|