eagle-mem 4.6.1 → 4.6.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/scripts/curate.sh +35 -25
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "eagle-mem",
3
- "version": "4.6.1",
3
+ "version": "4.6.2",
4
4
  "description": "Context that survives /compact for Claude Code — SQLite + FTS5, no daemon, no bloat",
5
5
  "bin": {
6
6
  "eagle-mem": "bin/eagle-mem"
package/scripts/curate.sh CHANGED
@@ -398,46 +398,56 @@ if [ -n "$co_edit_data" ]; then
398
398
  eagle_info " Co-edit pairs found:"
399
399
  fi
400
400
 
401
- co_edit_count=0
402
- declare -A co_map
403
-
404
- while IFS='|' read -r f1 f2 co_sessions; do
405
- [ -z "$f1" ] || [ -z "$f2" ] && continue
406
-
407
- # Build comma-separated partner list per file (both directions)
408
- if [ -n "${co_map[$f1]+x}" ]; then
409
- co_map[$f1]="${co_map[$f1]},$f2"
410
- else
411
- co_map[$f1]="$f2"
412
- fi
413
- if [ -n "${co_map[$f2]+x}" ]; then
414
- co_map[$f2]="${co_map[$f2]},$f1"
415
- else
416
- co_map[$f2]="$f1"
417
- fi
418
- co_edit_count=$((co_edit_count + 1))
419
- done <<< "$co_edit_data"
401
+ # Use awk for associative map (Bash 3.2 compatible)
402
+ co_map_output=$(printf '%s\n' "$co_edit_data" | awk -F'|' '
403
+ $1 && $2 {
404
+ m[$1] = (m[$1] ? m[$1] "," : "") $2
405
+ m[$2] = (m[$2] ? m[$2] "," : "") $1
406
+ n++
407
+ }
408
+ END {
409
+ for (f in m) print f "|" m[f]
410
+ print "__co_edit_count__|" n "|" length(m) > "/dev/stderr"
411
+ }
412
+ ' 2>&1 1>/dev/null)
413
+ # stderr has the count line, stdout has the map lines — reverse:
414
+ co_map_output=$(printf '%s\n' "$co_edit_data" | awk -F'|' '
415
+ $1 && $2 {
416
+ m[$1] = (m[$1] ? m[$1] "," : "") $2
417
+ m[$2] = (m[$2] ? m[$2] "," : "") $1
418
+ n++
419
+ }
420
+ END {
421
+ for (f in m) print f "|" m[f]
422
+ printf "%s\n", "__META__|" n "|" length(m) > "/dev/stderr"
423
+ }
424
+ ' 2>/tmp/eagle_co_edit_meta)
425
+ co_edit_count=$(awk -F'|' '{print $2}' /tmp/eagle_co_edit_meta)
426
+ co_map_file_count=$(awk -F'|' '{print $3}' /tmp/eagle_co_edit_meta)
427
+ rm -f /tmp/eagle_co_edit_meta
420
428
 
421
429
  if [ "$DRY_RUN" -eq 1 ]; then
422
- for f in "${!co_map[@]}"; do
423
- eagle_info " $(basename "$f") ${co_map[$f]}"
430
+ printf '%s\n' "$co_map_output" | while IFS='|' read -r f partners; do
431
+ [ -z "$f" ] && continue
432
+ eagle_info " $(basename "$f") → $partners"
424
433
  done
425
434
  else
426
435
  {
427
436
  echo "BEGIN;"
428
437
  echo "DELETE FROM file_hints WHERE project = '$(eagle_sql_escape "$project")' AND hint_type = 'co_edit';"
429
- for f in "${!co_map[@]}"; do
438
+ printf '%s\n' "$co_map_output" | while IFS='|' read -r f partners; do
439
+ [ -z "$f" ] && continue
430
440
  local_f=$(eagle_sql_escape "$f")
431
- local_v=$(eagle_sql_escape "${co_map[$f]}")
441
+ local_v=$(eagle_sql_escape "$partners")
432
442
  echo "INSERT INTO file_hints (project, hint_type, file_path, hint_value) VALUES ('$(eagle_sql_escape "$project")', 'co_edit', '$local_f', '$local_v') ON CONFLICT(project, hint_type, file_path) DO UPDATE SET hint_value = excluded.hint_value, updated_at = strftime('%Y-%m-%dT%H:%M:%fZ', 'now');"
433
443
  done
434
444
  echo "COMMIT;"
435
445
  } | eagle_db_pipe
436
446
  _proj_hash=$(printf '%s' "$project" | shasum | cut -c1-8)
437
447
  touch "$EAGLE_MEM_DIR/.co-edit-active.${_proj_hash}"
438
- eagle_log "INFO" "Curator: stored ${#co_map[@]} co-edit hints from $co_edit_count pairs"
448
+ eagle_log "INFO" "Curator: stored $co_map_file_count co-edit hints from $co_edit_count pairs"
439
449
  fi
440
- eagle_ok "$co_edit_count co-edit pairs found (${#co_map[@]} files)"
450
+ eagle_ok "$co_edit_count co-edit pairs found ($co_map_file_count files)"
441
451
  else
442
452
  if [ "$DRY_RUN" -eq 0 ]; then
443
453
  eagle_delete_file_hints "$project" "co_edit"