internator 0.1.6 → 0.1.7
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 +5 -5
- data/lib/internator/cli.rb +57 -28
- data/lib/internator/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f6853d7e223f60aa6d4ea55bde5b3c5f3ba13b7f349b2f3029efd25c97b4ba6
|
4
|
+
data.tar.gz: 442f68165403712347f11e182aa5c460762568d3f50d7efbb347acf4e783c04c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 909efaf0ae3e29c473356f4a07e815a615488c32b138d3c06e502f82bfd748726a24f9c7151452825153305aeab739819429967612fddfd477e78701f713e0d7
|
7
|
+
data.tar.gz: bcc2c29ef1b5c197d45219c2ed4bea00beb520d40fe60c3f8b1b82a22be1ded73b937719620ad1fb45086874451767c395d843bd4ad43f45a34864b38e3c0f18
|
data/README.md
CHANGED
@@ -17,15 +17,15 @@ gem install internator
|
|
17
17
|
```
|
18
18
|
|
19
19
|
## Usage
|
20
|
-
|
21
|
-
Push to Github your new empty branch and run the `internator` command:
|
20
|
+
Create your new empty branch and run the `internator` command:
|
22
21
|
|
23
22
|
```bash
|
24
|
-
internator "<PR Objectives>" [delay_mins]
|
23
|
+
internator "<PR Objectives>" [delay_mins] [parent_branch]
|
25
24
|
```
|
26
25
|
|
27
|
-
|
28
|
-
|
26
|
+
- `<PR Objectives>`: Description of what the pull request should achieve.
|
27
|
+
- `[delay_mins]`: (Optional) Minutes to wait between commits (default: 0).
|
28
|
+
- `[parent_branch]`: (Optional) Branch name to diff against (default: detected repository default branch).
|
29
29
|
|
30
30
|
Example:
|
31
31
|
```bash
|
data/lib/internator/cli.rb
CHANGED
@@ -59,16 +59,42 @@ module Internator
|
|
59
59
|
abort "❌ OPENAI_API_KEY not set. Please set the environment variable."
|
60
60
|
end
|
61
61
|
|
62
|
-
|
63
|
-
|
62
|
+
# Parse arguments: objectives, optional delay (minutes), optional parent_branch
|
63
|
+
if args.empty? || args.size > 3
|
64
|
+
abort "❌ Usage: internator \"<PR Objectives>\" [delay_mins] [parent_branch]"
|
64
65
|
end
|
65
66
|
|
66
67
|
objectives = args[0]
|
67
|
-
delay_mins =
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
68
|
+
delay_mins = 0
|
69
|
+
parent_branch = nil
|
70
|
+
case args.size
|
71
|
+
when 2
|
72
|
+
# single extra arg: integer delay or parent branch
|
73
|
+
begin
|
74
|
+
delay_mins = Integer(args[1])
|
75
|
+
rescue ArgumentError
|
76
|
+
parent_branch = args[1]
|
77
|
+
end
|
78
|
+
when 3
|
79
|
+
delay_mins = Integer(args[1]) rescue abort("❌ Invalid delay_mins: must be an integer")
|
80
|
+
parent_branch = args[2]
|
81
|
+
end
|
82
|
+
|
83
|
+
remote, default_base = git_detect_default_base&.split("/", 2)
|
84
|
+
branch = git_current_branch
|
85
|
+
|
86
|
+
abort "❌ Git remote is not detected." unless remote
|
87
|
+
abort "❌ Git default branch is not detected." unless default_base
|
88
|
+
|
89
|
+
if branch == default_base
|
90
|
+
abort "❌ You are on the default branch '#{default_base}'. Please create a new branch before running Internator."
|
91
|
+
end
|
92
|
+
|
93
|
+
if parent_branch && !system("git rev-parse --verify --quiet #{parent_branch} > /dev/null 2>&1")
|
94
|
+
abort "❌ Specified parent branch '#{parent_branch}' does not exist."
|
95
|
+
end
|
96
|
+
|
97
|
+
git_upstream(remote, branch)
|
72
98
|
|
73
99
|
iteration = 1
|
74
100
|
Signal.trap("INT") do
|
@@ -79,15 +105,14 @@ module Internator
|
|
79
105
|
begin
|
80
106
|
loop do
|
81
107
|
puts "\n🌀 Iteration ##{iteration} - #{Time.now.strftime("%Y-%m-%d %H:%M:%S")}"
|
82
|
-
|
108
|
+
|
109
|
+
exit_code = codex_cycle(objectives, iteration, remote, default_base, branch, parent_branch)
|
83
110
|
if exit_code != 0
|
84
|
-
|
85
|
-
break
|
111
|
+
abort "🚨 Codex process exited with code #{exit_code}. Stopping."
|
86
112
|
end
|
87
113
|
|
88
114
|
if `git status --porcelain`.strip.empty?
|
89
|
-
|
90
|
-
break
|
115
|
+
abort "🎉 Objectives completed; no new changes. Exiting loop..."
|
91
116
|
end
|
92
117
|
|
93
118
|
auto_commit
|
@@ -103,7 +128,7 @@ module Internator
|
|
103
128
|
end
|
104
129
|
|
105
130
|
# Detect the repository's default branch across remotes (e.g., main, master, develop)
|
106
|
-
def self.
|
131
|
+
def self.git_detect_default_base
|
107
132
|
remotes = `git remote`.split("\n").reject(&:empty?)
|
108
133
|
remotes.unshift('origin') unless remotes.include?('origin')
|
109
134
|
remotes.each do |remote|
|
@@ -119,23 +144,27 @@ module Internator
|
|
119
144
|
nil
|
120
145
|
end
|
121
146
|
|
122
|
-
|
123
|
-
|
124
|
-
|
147
|
+
def self.git_current_branch
|
148
|
+
`git rev-parse --abbrev-ref HEAD`.strip
|
149
|
+
end
|
150
|
+
|
151
|
+
def self.git_upstream(remote, branch)
|
125
152
|
upstream = `git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null`.strip
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
base = detect_default_base || upstream
|
133
|
-
elsif !upstream.empty?
|
134
|
-
base = upstream
|
135
|
-
else
|
136
|
-
base = detect_default_base || 'master'
|
153
|
+
|
154
|
+
if upstream.empty?
|
155
|
+
# As upstream is not configured, push the current branch and set upstream to remote
|
156
|
+
puts "🔄 No upstream configured for branch '#{branch}'. Sending to #{remote}..."
|
157
|
+
system("git push -u #{remote} #{branch}")
|
158
|
+
upstream = `git rev-parse --abbrev-ref --symbolic-full-name @{u} 2>/dev/null`.strip
|
137
159
|
end
|
138
|
-
|
160
|
+
|
161
|
+
upstream
|
162
|
+
end
|
163
|
+
|
164
|
+
# Executes one Codex iteration by diffing against the parent or default branch
|
165
|
+
def self.codex_cycle(objectives, iteration, remote, default_base, branch, parent_branch = nil)
|
166
|
+
# Determine base branch: user-specified parent or detected default
|
167
|
+
base = parent_branch || default_base
|
139
168
|
current_diff = `git diff #{base} 2>/dev/null`
|
140
169
|
current_diff = "No initial changes" if current_diff.strip.empty?
|
141
170
|
prompt = <<~PROMPT
|
data/lib/internator/version.rb
CHANGED