llmed 0.2.9 → 0.2.11
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/lib/llmed/application.rb +33 -4
- data/lib/llmed/configuration.rb +3 -3
- 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: 4479a97e9e36926e4f7af8677a06268824c84563e441d2b14c862c8c07f648f1
|
4
|
+
data.tar.gz: daad9497943bb738f429fca0cb67a18858c9557657090af5878e803863c63fee
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d765dabbd6b724f8d37d21b36f8dcf7bf9a75b3ba73e3c635701f6ce5d716e6977447b8584291bb79ec97074519118cf3746a9be865fe4572f4d71387ba6295e
|
7
|
+
data.tar.gz: 0611b8c5c945ab1ec79252275646b11f8699ea22edfee23c5ba5ba09166732676fa4f45832d43035896377e0ccaaece993d32e2cccdbf2387c94abd36ddbd280
|
data/lib/llmed/application.rb
CHANGED
@@ -83,10 +83,18 @@ class LLMed
|
|
83
83
|
end
|
84
84
|
end
|
85
85
|
|
86
|
-
@logger.info("APPLICATION #{@name} PATCHING CONTEXT #{name} \n\tFROM #{digest}\n\tTO DIGEST #{new_digest}")
|
87
86
|
release_source_code_content = release_source_code_content.sub(%r{(.*?)(<llmed-code context='#{name}' digest='.*?'>)(.+?)(</llmed-code>)(.*?)}m) do
|
88
87
|
"#{::Regexp.last_match(1)}<llmed-code context='#{name}' digest='#{new_digest}'>#{new_code}#{::Regexp.last_match(4)}#{::Regexp.last_match(5)}"
|
89
88
|
end
|
89
|
+
|
90
|
+
if release_contexts[name].nil?
|
91
|
+
@logger.info("APPLICATION #{@name} ADDING NEW CONTEXT #{name}")
|
92
|
+
release_source_code_content += "<llmed-code context='#{name}' digest='#{new_digest}'>
|
93
|
+
#{new_code}
|
94
|
+
#{code_comment}</llmed-code>"
|
95
|
+
else
|
96
|
+
@logger.info("APPLICATION #{@name} PATCHING CONTEXT #{name} \n\tFROM #{digest}\n\tTO DIGEST #{new_digest}")
|
97
|
+
end
|
90
98
|
end
|
91
99
|
|
92
100
|
output_content = release_source_code_content
|
@@ -110,7 +118,11 @@ class LLMed
|
|
110
118
|
!digests_of_context_to_update.tap do |digests|
|
111
119
|
digests.each do |digest|
|
112
120
|
context_by_digest = release_contexts.invert
|
113
|
-
|
121
|
+
if context_by_digest[digest].nil?
|
122
|
+
@logger.info("APPLICATION #{@name} ADDING CONTEXT #{user_contexts.invert[digest]}")
|
123
|
+
else
|
124
|
+
@logger.info("APPLICATION #{@name} REBUILDING CONTEXT #{context_by_digest[digest]}")
|
125
|
+
end
|
114
126
|
end
|
115
127
|
end.empty?
|
116
128
|
end
|
@@ -141,6 +153,10 @@ class LLMed
|
|
141
153
|
|
142
154
|
private
|
143
155
|
|
156
|
+
def code_comment
|
157
|
+
{ ruby: '#' }.fetch(@language.to_sym)
|
158
|
+
end
|
159
|
+
|
144
160
|
def digests_of_context_to_update
|
145
161
|
update_context_digest = []
|
146
162
|
|
@@ -152,8 +168,15 @@ class LLMed
|
|
152
168
|
update_rest = false
|
153
169
|
@contexts.each do |ctx|
|
154
170
|
release_context_digest = release_contexts[ctx.name]
|
155
|
-
|
156
|
-
|
171
|
+
|
172
|
+
# added new context
|
173
|
+
if release_context_digest.nil? and !user_contexts[ctx.name].nil?
|
174
|
+
update_context_digest << user_contexts[ctx.name]
|
175
|
+
next
|
176
|
+
elsif release_context_digest.nil?
|
177
|
+
# maybe the context is not connected to the source code
|
178
|
+
next
|
179
|
+
end
|
157
180
|
|
158
181
|
if update_rest
|
159
182
|
update_context_digest << release_context_digest
|
@@ -177,6 +200,12 @@ class LLMed
|
|
177
200
|
Pathname.new(@release_dir) + "#{@output_file}.release"
|
178
201
|
end
|
179
202
|
|
203
|
+
def user_contexts
|
204
|
+
@contexts.map do |ctx|
|
205
|
+
[ctx.name, ctx.digest]
|
206
|
+
end.to_h
|
207
|
+
end
|
208
|
+
|
180
209
|
def release_contexts
|
181
210
|
return {} unless @release
|
182
211
|
|
data/lib/llmed/configuration.rb
CHANGED
@@ -5,7 +5,8 @@ class LLMed
|
|
5
5
|
class Configuration
|
6
6
|
def initialize
|
7
7
|
@prompt = LLMed::LLM::Template.build(template: "
|
8
|
-
You are a software developer with knowledge only of the programming language {language}
|
8
|
+
You are a software developer with knowledge only of the programming language {language}, following the SOLID principles strictly, you always use only imperative and functional programming, and design highly isolated components.
|
9
|
+
The contexts are declarations of how the source code will be, ensure to follow this always.
|
9
10
|
Your response must contain only the generated source code, with no additional text.
|
10
11
|
All source code must be written in a single file, and you must ensure it runs correctly on the first attempt.
|
11
12
|
There is always a one-to-one correspondence between context and source code.
|
@@ -14,13 +15,12 @@ Always include the properly escaped comment: LLMED-COMPILED.
|
|
14
15
|
You must only modify the following source code:
|
15
16
|
{source_code}
|
16
17
|
|
17
|
-
Only generate source code of the context who digest belongs to {update_context_digests}.
|
18
|
+
Only generate source code of the context who digest belongs to {update_context_digests} or a is a new context.
|
18
19
|
|
19
20
|
Wrap with comment every code that belongs to the indicated context, example in ruby:
|
20
21
|
#<llmed-code context='context name' digest='....'>
|
21
22
|
...
|
22
23
|
#</llmed-code>
|
23
|
-
|
24
24
|
", input_variables: %w[language source_code update_context_digests])
|
25
25
|
end
|
26
26
|
|