compose 0.1.4 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/config/prompts/task.txt +3 -1
- data/config/prompts/verify.txt +4 -1
- data/lib/compose/cli.rb +1 -1
- data/lib/compose/edit_processor.rb +4 -2
- data/lib/compose/file_processor.rb +16 -1
- data/lib/compose/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: '0181e80bc473a0e67c074cc18b299be97ecad391875a7578780a3f8a93286cdc'
|
4
|
+
data.tar.gz: a4d171f396fd690387c122958565eb047efd3b0ef11c99acd6fc6e557a78f1e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 172b6babed118da8b989bffb8dad311eef02a27c21200df782fccf29783d929559ca44e98023c4ac2e3607e1ece53a36e7490834c9fc09aaffe82aaf8dfc94ec
|
7
|
+
data.tar.gz: 89b5cd472edfe13a5007e753d23bca1be694ae056314f71376f442af323de21e1bdcf395c0560445534172c22a7304185df21d0b1835c7e65f05c26c325bf050
|
data/config/prompts/task.txt
CHANGED
@@ -7,6 +7,8 @@ Facts:
|
|
7
7
|
2. Leave toLine empty for additions.
|
8
8
|
3. Make sure the code snippet in the edit is complete. Feel free to make multiple edits, avoid repeating existing code if you can.
|
9
9
|
4. Ensure the line numbers are accurate. Feel free to repeat existing code from previous or after lines to be sure.
|
10
|
+
5. When adding new code to the end of a file, make sure to repeat the last
|
11
|
+
line of the file in the edit before adding a new line.
|
10
12
|
|
11
13
|
```json
|
12
14
|
{
|
@@ -22,7 +24,7 @@ Facts:
|
|
22
24
|
"fromLineNumber": number;
|
23
25
|
"toLineNumber": number;
|
24
26
|
};
|
25
|
-
"code": string; // Code to insert or replace, make sure
|
27
|
+
"code": string; // Code to insert or replace, make sure " are double escaped.
|
26
28
|
}
|
27
29
|
```
|
28
30
|
|
data/config/prompts/verify.txt
CHANGED
@@ -10,7 +10,10 @@ Verify this change:
|
|
10
10
|
{{CHANGE}}
|
11
11
|
```
|
12
12
|
|
13
|
-
and make sure it's needed and it's only replacing the correct lines, or adding
|
13
|
+
and make sure it's needed and it's only replacing the correct lines, or adding
|
14
|
+
the code to the correct place. Feel free to change additions to replacements
|
15
|
+
or vice versa, fix atLine, fromLineNumber, toLineNumber if they would produce
|
16
|
+
duplicated code lines, `or skip edits if they're not needed.
|
14
17
|
Return only the fixed change object following this JSON spec:
|
15
18
|
|
16
19
|
```json
|
data/lib/compose/cli.rb
CHANGED
@@ -22,7 +22,7 @@ module Compose
|
|
22
22
|
ApiKeyUtils.setup(verifier_model)
|
23
23
|
|
24
24
|
file_processor = FileProcessor.new(files, include_imports: options[:include_imports], model: code_model)
|
25
|
-
puts "Loaded #{file_processor.files.count} file(s)."
|
25
|
+
puts "Loaded #{file_processor.files.count} file(s): #{file_processor.files.keys.map { |path| File.exist?(path) ? Pathname.new(path).relative_path_from(Pathname.pwd).to_s : path }.join(', ')}"
|
26
26
|
|
27
27
|
task = ask('What do you need me to do? (Type \'ask\' followed by your question to ask a question instead):')
|
28
28
|
|
@@ -86,7 +86,7 @@ module Compose
|
|
86
86
|
|
87
87
|
case edit[:change][:type]
|
88
88
|
when 'addition'
|
89
|
-
new_content.insert(edit[:change][:atLine] - 1, edit[:code])
|
89
|
+
new_content.insert(edit[:change][:atLine] - 1, edit[:code].split("\n").map { |line| line + "\n" })
|
90
90
|
when 'replacement'
|
91
91
|
new_content[edit[:change][:fromLineNumber] - 1..edit[:change][:toLineNumber] - 1] = edit[:code].split("\n").map { |line| line + "\n" }
|
92
92
|
end
|
@@ -109,7 +109,7 @@ module Compose
|
|
109
109
|
case edit[:change][:type]
|
110
110
|
when 'addition'
|
111
111
|
adjusted_line = edit[:change][:atLine] + line_offset
|
112
|
-
content.insert(adjusted_line - 1, edit[:code])
|
112
|
+
content.insert(adjusted_line - 1, edit[:code].split("\n").map { |line| line + "\n" })
|
113
113
|
line_offset += edit[:code].count("\n") + 1
|
114
114
|
when 'replacement'
|
115
115
|
from_line = edit[:change][:fromLineNumber] + line_offset
|
@@ -121,6 +121,8 @@ module Compose
|
|
121
121
|
end
|
122
122
|
end
|
123
123
|
|
124
|
+
content = content.flatten
|
125
|
+
|
124
126
|
FileUtils.mkdir_p(File.dirname(filename))
|
125
127
|
File.write(filename, content.join)
|
126
128
|
puts "Applied changes to #{filename}".green
|
@@ -80,7 +80,22 @@ module Compose
|
|
80
80
|
private
|
81
81
|
|
82
82
|
def find_files_in_directory(directory)
|
83
|
-
|
83
|
+
tracked_files = `git ls-files #{directory}`.split("\n")
|
84
|
+
tracked_files.select do |path|
|
85
|
+
File.file?(path) && text_file?(path)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
def text_file?(path)
|
90
|
+
return false if File.zero?(path)
|
91
|
+
|
92
|
+
bytes = File.read(path, 1024) or return false
|
93
|
+
bytes.each_byte do |byte|
|
94
|
+
return false if [0, 1, 2, 3, 4, 5, 6, 11, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31].include?(byte)
|
95
|
+
end
|
96
|
+
true
|
97
|
+
rescue
|
98
|
+
false
|
84
99
|
end
|
85
100
|
end
|
86
101
|
end
|
data/lib/compose/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: compose
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dreaming Tulpa
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-09-
|
11
|
+
date: 2024-09-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ruby-openai
|