codex-ralph 0.4.5 → 0.4.6
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.
- package/agent/ralph-loop.sh +65 -2
- package/package.json +1 -1
package/agent/ralph-loop.sh
CHANGED
|
@@ -210,6 +210,69 @@ print(filled + empty)
|
|
|
210
210
|
PY
|
|
211
211
|
}
|
|
212
212
|
|
|
213
|
+
filter_repeated_diffs() {
|
|
214
|
+
python3 - <<'PYFILTER'
|
|
215
|
+
import sys
|
|
216
|
+
import hashlib
|
|
217
|
+
import re
|
|
218
|
+
from collections import deque
|
|
219
|
+
|
|
220
|
+
# Keep only last 30 diff hashes to avoid memory issues
|
|
221
|
+
seen_hashes = deque(maxlen=30)
|
|
222
|
+
current_block = []
|
|
223
|
+
collecting_diff = False
|
|
224
|
+
|
|
225
|
+
for line in sys.stdin:
|
|
226
|
+
stripped = line.rstrip('\n\r')
|
|
227
|
+
|
|
228
|
+
# Start of a file update block
|
|
229
|
+
if stripped == 'file update:':
|
|
230
|
+
if current_block:
|
|
231
|
+
# Process previous block
|
|
232
|
+
block_text = '\n'.join(current_block)
|
|
233
|
+
block_hash = hashlib.md5(block_text.encode()).hexdigest()
|
|
234
|
+
if block_hash not in seen_hashes:
|
|
235
|
+
sys.stdout.write(block_text + '\n')
|
|
236
|
+
sys.stdout.flush()
|
|
237
|
+
seen_hashes.append(block_hash)
|
|
238
|
+
# else: skip repeated diff
|
|
239
|
+
|
|
240
|
+
current_block = [stripped]
|
|
241
|
+
collecting_diff = True
|
|
242
|
+
elif collecting_diff:
|
|
243
|
+
current_block.append(stripped)
|
|
244
|
+
# Check if we hit a new action (end of diff block)
|
|
245
|
+
if re.match(r'^(thinking|exec):', stripped):
|
|
246
|
+
# End of diff block
|
|
247
|
+
block_text = '\n'.join(current_block)
|
|
248
|
+
block_hash = hashlib.md5(block_text.encode()).hexdigest()
|
|
249
|
+
|
|
250
|
+
if block_hash not in seen_hashes:
|
|
251
|
+
sys.stdout.write(block_text + '\n')
|
|
252
|
+
sys.stdout.flush()
|
|
253
|
+
seen_hashes.append(block_hash)
|
|
254
|
+
else:
|
|
255
|
+
# Skip the diff, only output the new action
|
|
256
|
+
sys.stdout.write(line)
|
|
257
|
+
sys.stdout.flush()
|
|
258
|
+
|
|
259
|
+
current_block = []
|
|
260
|
+
collecting_diff = False
|
|
261
|
+
else:
|
|
262
|
+
# Regular output, pass through immediately
|
|
263
|
+
sys.stdout.write(line)
|
|
264
|
+
sys.stdout.flush()
|
|
265
|
+
|
|
266
|
+
# Output any remaining block
|
|
267
|
+
if current_block:
|
|
268
|
+
block_text = '\n'.join(current_block)
|
|
269
|
+
block_hash = hashlib.md5(block_text.encode()).hexdigest()
|
|
270
|
+
if block_hash not in seen_hashes:
|
|
271
|
+
sys.stdout.write(block_text + '\n')
|
|
272
|
+
sys.stdout.flush()
|
|
273
|
+
PYFILTER
|
|
274
|
+
}
|
|
275
|
+
|
|
213
276
|
iteration=1
|
|
214
277
|
while true; do
|
|
215
278
|
remaining="$(remaining_count)"
|
|
@@ -249,9 +312,9 @@ while true; do
|
|
|
249
312
|
} > "$prompt_tmp"
|
|
250
313
|
|
|
251
314
|
if [[ "$USE_CURSOR_AGENT" == "true" ]]; then
|
|
252
|
-
cursor-agent -f -p < "$prompt_tmp"
|
|
315
|
+
cursor-agent -f -p < "$prompt_tmp" 2>&1 | filter_repeated_diffs
|
|
253
316
|
else
|
|
254
|
-
codex exec - < "$prompt_tmp"
|
|
317
|
+
codex exec - < "$prompt_tmp" 2>&1 | filter_repeated_diffs
|
|
255
318
|
fi
|
|
256
319
|
|
|
257
320
|
rm -f "$prompt_tmp"
|