dwmkerr / dwmkerr/git-workforest

feat: detect and migrate coding-agent state on `git forest migrate`

Open
#57 0 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
TypeScript
Stars
1
Forks
0
Avg merge
3d 23h
Merged PRs (30d)
1

Description

## Problem

`git forest migrate` moves repo contents into a branch subdirectory. This changes `cwd`, which breaks state stored by coding agents that key off cwd:

- **Claude Code** — project key under `~/.claude/projects//` holds session history, conversation logs, and file-based memory. New cwd → new key → `claude --resume` finds nothing.
- **Cursor** — keys workspace state by absolute path under `~/Library/Application Support/Cursor/User/workspaceStorage//`.
- **Aider, Continue, others** — similar patterns.

Today users discover this only after running migrate, then lose session continuity unless they know to symlink.

## Proposal

Three options, pick one (or layer):

### Option A — print a hint after `migrate` succeeds (lowest risk)

Detect known agent state dirs by inspecting `$HOME` and print exact `ln -sfn` commands the user can copy/paste. No state mutated by workforest.

```
✓ migrated dwmkerr/foo to forest layout

claude code session detected. to preserve session + memory:
ln -sfn ~/.claude/projects/-Users-x-repos-foo \
~/.claude/projects/-Users-x-repos-foo-main
claude --resume
```

### Option B — `--migrate-agent-state` flag (opt-in)

Same detection, but workforest creates the symlinks itself when the flag is passed. Default off.

### Option C — `--migrate-agent-state=` (granular)

Choose per-agent: `claude`, `cursor`, `aider`. Plugin-able longer term.

## Detection sketch

| Agent | State path | Key derivation |
|---|---|---|
| Claude Code | `~/.claude/projects/` | `cwd` with `/` and `_` → `-` |
| Cursor | `~/Library/Application Support/Cursor/User/workspaceStorage/` | hash of `file://` |
| Aider | `/.aider.*` | local to cwd, moves with migrate ✓ |

For Claude Code, walk up from new `cwd` looking for an existing project key dir; that's the old key. Compute new key from new cwd. `ln -sfn old new`.

## Why now

Lightweight Option A is ~10 lines in `migrate.ts` and zero risk — strictly informational. Surfaces the right command at the right moment. PR #56 documents the manual workaround in the README; this issue tracks moving it into the tool.

## Related

- PR #56 — README snippet for the manual workaround.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.