internator 0.1.2 → 0.1.4
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/README.md +1 -8
- data/internator.gemspec +0 -1
- data/lib/internator/cli.rb +36 -3
- data/lib/internator/version.rb +1 -1
- metadata +3 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5a53d4badad8dc9c225a8c7775fa6d805faaa185eb94701e309354aeae99836a
|
4
|
+
data.tar.gz: 48458c4e7a3c7fb6d281f8c251487d3dad194d71230053dac8c53b6bbd1d86e1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7da4a252fbe140a6f714863ebe838cf1a7e7bb4e7774e06c8de945dc868bfa080f7e6767153ad9651c6b95d647024be51ec05092885e338dcb19a6825296c9c
|
7
|
+
data.tar.gz: 300909518f184467a06bef0b139be885f0d6a41d4ac9e37d3013341fa15276473e9f1792e557e998ab07e94fb71687c33d941c5bc1b5b13c8f949bed0f7d19cd
|
data/README.md
CHANGED
@@ -31,15 +31,8 @@ Example:
|
|
31
31
|
```bash
|
32
32
|
internator "Refactor authentication flow and add tests" 10
|
33
33
|
```
|
34
|
-
|
34
|
+
For more detailed usage tips, see the [Usage Tips wiki page](https://github.com/AlexLarra/internator/wiki/Usage-tips).
|
35
35
|
|
36
|
-
If you use tmux ensure `OPENAI_API_KEY` is forwarded into tmux sessions. Add the following to your `~/.tmux.conf`:
|
37
|
-
|
38
|
-
```tmux
|
39
|
-
# Ensure OPENAI_API_KEY is passed into tmux sessions if you use it.
|
40
|
-
set -g update-environment "OPENAI_API_KEY"
|
41
|
-
set-environment -g OPENAI_API_KEY "#{ENV:OPENAI_API_KEY}"
|
42
|
-
```
|
43
36
|
## Contributing
|
44
37
|
|
45
38
|
Feel free to open issues or submit pull requests.
|
data/internator.gemspec
CHANGED
@@ -13,7 +13,6 @@ Gem::Specification.new do |spec|
|
|
13
13
|
|
14
14
|
spec.files = Dir.glob("lib/**/*.rb") + ["README.md", "LICENSE", "internator.gemspec", "bin/internator"]
|
15
15
|
spec.executables = ["internator"]
|
16
|
-
spec.require_paths = ["lib"]
|
17
16
|
|
18
17
|
# Development dependencies for building and releasing the gem
|
19
18
|
spec.add_development_dependency "bundler", "~> 2.0"
|
data/lib/internator/cli.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
require "internator/codex_service"
|
2
1
|
require "net/http"
|
3
2
|
require "uri"
|
4
3
|
require "json"
|
4
|
+
require "tempfile"
|
5
5
|
|
6
6
|
module Internator
|
7
7
|
# Command-line interface for the Internator gem
|
@@ -58,8 +58,41 @@ module Internator
|
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
61
|
+
# Detect the repository's default branch across remotes (e.g., main, master, develop)
|
62
|
+
def self.detect_default_base
|
63
|
+
remotes = `git remote`.split("\n").reject(&:empty?)
|
64
|
+
remotes.unshift('origin') unless remotes.include?('origin')
|
65
|
+
remotes.each do |remote|
|
66
|
+
# Try to resolve remote HEAD via rev-parse
|
67
|
+
ref = `git rev-parse --abbrev-ref #{remote}/HEAD 2>/dev/null`.strip
|
68
|
+
return ref unless ref.empty?
|
69
|
+
# Fallback to symbolic-ref
|
70
|
+
sym = `git symbolic-ref refs/remotes/#{remote}/HEAD 2>/dev/null`.strip
|
71
|
+
if sym.start_with?('refs/remotes/')
|
72
|
+
return sym.sub('refs/remotes/', '')
|
73
|
+
end
|
74
|
+
end
|
75
|
+
nil
|
76
|
+
end
|
77
|
+
|
78
|
+
# Executes one Codex iteration by diffing against the appropriate base branch
|
61
79
|
def self.codex_cycle(objectives, iteration)
|
62
|
-
|
80
|
+
# Determine configured upstream and current branch name
|
81
|
+
upstream = `git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null`.strip
|
82
|
+
current_branch = `git rev-parse --abbrev-ref HEAD`.strip
|
83
|
+
# Choose diff base:
|
84
|
+
# 1) If upstream is tracking current branch, use remote default branch
|
85
|
+
# 2) Else if upstream exists, diff against that
|
86
|
+
# 3) Otherwise fallback to remote default branch or master
|
87
|
+
if !upstream.empty? && upstream.split('/').last == current_branch
|
88
|
+
base = detect_default_base || upstream
|
89
|
+
elsif !upstream.empty?
|
90
|
+
base = upstream
|
91
|
+
else
|
92
|
+
base = detect_default_base || 'master'
|
93
|
+
end
|
94
|
+
# Get the diff against the chosen base
|
95
|
+
current_diff = `git diff #{base} 2>/dev/null`
|
63
96
|
current_diff = "No initial changes" if current_diff.strip.empty?
|
64
97
|
prompt = <<~PROMPT
|
65
98
|
Objectives: #{objectives}
|
@@ -105,7 +138,7 @@ module Internator
|
|
105
138
|
nil
|
106
139
|
end
|
107
140
|
|
108
|
-
def auto_commit
|
141
|
+
def self.auto_commit
|
109
142
|
system('git', 'add', '-A')
|
110
143
|
status = `git diff --cached --name-status`
|
111
144
|
content = `git diff --cached`
|
data/lib/internator/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: internator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- AlexLarra
|
8
|
-
autorequire:
|
9
8
|
bindir: bin
|
10
9
|
cert_chain: []
|
11
|
-
date:
|
10
|
+
date: 1980-01-02 00:00:00.000000000 Z
|
12
11
|
dependencies:
|
13
12
|
- !ruby/object:Gem::Dependency
|
14
13
|
name: bundler
|
@@ -61,7 +60,6 @@ homepage: https://github.com/AlexLarra/internator
|
|
61
60
|
licenses:
|
62
61
|
- MIT
|
63
62
|
metadata: {}
|
64
|
-
post_install_message:
|
65
63
|
rdoc_options: []
|
66
64
|
require_paths:
|
67
65
|
- lib
|
@@ -76,8 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
74
|
- !ruby/object:Gem::Version
|
77
75
|
version: '0'
|
78
76
|
requirements: []
|
79
|
-
rubygems_version: 3.
|
80
|
-
signing_key:
|
77
|
+
rubygems_version: 3.6.9
|
81
78
|
specification_version: 4
|
82
79
|
summary: CLI tool that automates iterative pull request improvements using OpenAI's
|
83
80
|
Codex
|