diff --git a/README.md b/README.md index b901d3a..a3b86ec 100644 --- a/README.md +++ b/README.md @@ -124,6 +124,11 @@ ccswitch seed # ... or from another config dir Re-run `ccswitch seed` anytime to re-sync from the source (source wins on same-named files). +While `shared/` is empty, `ccswitch isolate` warns and asks for confirmation +before launching (so you don't start with no memory by accident). The prompt +stops appearing once `shared/` has content — from `ccswitch seed` or from your +first session. + > Note: this pattern relies on `CLAUDE_CONFIG_DIR` (supported) plus symlinking of > account-agnostic paths (a community pattern, not officially documented). Auth > stays isolated; only memory/history is shared. Two sessions writing the same diff --git a/functions/ccswitch.fish b/functions/ccswitch.fish index cd560b4..d59d9fe 100644 --- a/functions/ccswitch.fish +++ b/functions/ccswitch.fish @@ -313,6 +313,17 @@ function __ccswitch_link -d "symlink a shared path into a profile dir, non-destr end end +function __ccswitch_seeded -d "true if the shared isolate dir has any seeded memory/history" + set -l shared $argv[1] + test -s "$shared/history.jsonl"; and return 0 + test -s "$shared/CLAUDE.md"; and return 0 + if test -d "$shared/projects" + set -l first (find "$shared/projects" -mindepth 1 -maxdepth 1 2>/dev/null | head -1) + test -n "$first"; and return 0 + end + return 1 +end + function __ccswitch_isolate -d "launch a concurrent session isolated to a profile, memory shared" set -l base (__ccswitch_isolate_home) set -l shared "$base/shared" @@ -349,6 +360,18 @@ function __ccswitch_isolate -d "launch a concurrent session isolated to a profil __ccswitch_link "$shared/history.jsonl" "$dir/history.jsonl" __ccswitch_link "$shared/CLAUDE.md" "$dir/CLAUDE.md" + # blocking warning while the shared memory is still empty (unseeded) + if not __ccswitch_seeded "$shared" + echo "⚠ shared isolate memory is empty — this session starts with no" >&2 + echo " history or CLAUDE.md. Run 'ccswitch seed' first to import your" >&2 + echo " ~/.claude memory/history." >&2 + read -l -P " launch '$name' anyway? [y/N] " ans + if not string match -rqi '^y(es)?$' -- "$ans" + echo "aborted — nothing launched" >&2 + return 1 + end + end + echo "launching isolated '$name' — CLAUDE_CONFIG_DIR=$dir (memory shared via $shared)" echo "(first run for a profile will ask you to sign in)" env CLAUDE_CONFIG_DIR="$dir" claude $argv[2..-1]