mirror of
https://github.com/harivansh-afk/clanker-agent.git
synced 2026-04-15 11:02:17 +00:00
move pi-mono into companion-cloud as apps/companion-os
- Copy all pi-mono source into apps/companion-os/ - Update Dockerfile to COPY pre-built binary instead of downloading from GitHub Releases - Update deploy-staging.yml to build pi from source (bun compile) before Docker build - Add apps/companion-os/** to path triggers - No more cross-repo dispatch needed Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
commit
0250f72976
579 changed files with 206942 additions and 0 deletions
93
packages/coding-agent/scripts/migrate-sessions.sh
Executable file
93
packages/coding-agent/scripts/migrate-sessions.sh
Executable file
|
|
@ -0,0 +1,93 @@
|
|||
#!/usr/bin/env bash
|
||||
#
|
||||
# Migrate sessions from ~/.pi/agent/*.jsonl to proper session directories.
|
||||
# This fixes sessions created by the bug in v0.30.0 where sessions were
|
||||
# saved to ~/.pi/agent/ instead of ~/.pi/agent/sessions/<encoded-cwd>/.
|
||||
#
|
||||
# Usage: ./migrate-sessions.sh [--dry-run]
|
||||
#
|
||||
|
||||
set -e
|
||||
|
||||
AGENT_DIR="${PI_AGENT_DIR:-$HOME/.pi/agent}"
|
||||
DRY_RUN=false
|
||||
|
||||
if [[ "$1" == "--dry-run" ]]; then
|
||||
DRY_RUN=true
|
||||
echo "Dry run mode - no files will be moved"
|
||||
echo
|
||||
fi
|
||||
|
||||
# Find all .jsonl files directly in agent dir (not in subdirectories)
|
||||
shopt -s nullglob
|
||||
files=("$AGENT_DIR"/*.jsonl)
|
||||
shopt -u nullglob
|
||||
|
||||
if [[ ${#files[@]} -eq 0 ]]; then
|
||||
echo "No session files found in $AGENT_DIR"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
echo "Found ${#files[@]} session file(s) to migrate"
|
||||
echo
|
||||
|
||||
migrated=0
|
||||
failed=0
|
||||
|
||||
for file in "${files[@]}"; do
|
||||
filename=$(basename "$file")
|
||||
|
||||
# Read first line and extract cwd using jq
|
||||
if ! first_line=$(head -1 "$file" 2>/dev/null); then
|
||||
echo "SKIP: $filename - cannot read file"
|
||||
((failed++))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Parse JSON and extract cwd
|
||||
if ! cwd=$(echo "$first_line" | jq -r '.cwd // empty' 2>/dev/null); then
|
||||
echo "SKIP: $filename - invalid JSON"
|
||||
((failed++))
|
||||
continue
|
||||
fi
|
||||
|
||||
if [[ -z "$cwd" ]]; then
|
||||
echo "SKIP: $filename - no cwd in session header"
|
||||
((failed++))
|
||||
continue
|
||||
fi
|
||||
|
||||
# Encode cwd: remove leading slash, replace slashes with dashes, wrap with --
|
||||
encoded=$(echo "$cwd" | sed 's|^/||' | sed 's|[/:\\]|-|g')
|
||||
encoded="--${encoded}--"
|
||||
|
||||
target_dir="$AGENT_DIR/sessions/$encoded"
|
||||
target_file="$target_dir/$filename"
|
||||
|
||||
if [[ -e "$target_file" ]]; then
|
||||
echo "SKIP: $filename - target already exists"
|
||||
((failed++))
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "MIGRATE: $filename"
|
||||
echo " cwd: $cwd"
|
||||
echo " to: $target_dir/"
|
||||
|
||||
if [[ "$DRY_RUN" == false ]]; then
|
||||
mkdir -p "$target_dir"
|
||||
mv "$file" "$target_file"
|
||||
fi
|
||||
|
||||
((migrated++))
|
||||
echo
|
||||
done
|
||||
|
||||
echo "---"
|
||||
echo "Migrated: $migrated"
|
||||
echo "Skipped: $failed"
|
||||
|
||||
if [[ "$DRY_RUN" == true && $migrated -gt 0 ]]; then
|
||||
echo
|
||||
echo "Run without --dry-run to perform the migration"
|
||||
fi
|
||||
Loading…
Add table
Add a link
Reference in a new issue