diff --git a/.beads/formulas/mol-sync-workspace.formula.toml b/.beads/formulas/mol-sync-workspace.formula.toml index 495a990d..ee8fb5cf 100644 --- a/.beads/formulas/mol-sync-workspace.formula.toml +++ b/.beads/formulas/mol-sync-workspace.formula.toml @@ -84,143 +84,50 @@ This information guides decisions in subsequent steps. **Exit criteria:** Context primed, starting state documented.""" [[steps]] -id = "handle-uncommitted" -title = "Handle uncommitted changes" +id = "handle-dirty-state" +title = "Handle uncommitted and untracked work" needs = ["assess-state"] description = """ -Handle staged and unstaged changes before syncing. - -**Check for uncommitted changes:** -```bash -git status --porcelain | grep -v '^??' # Exclude untracked -``` - -**If no uncommitted changes:** Skip to next step. +Clean up any in-flight work before syncing. **If uncommitted changes exist:** -**Option A - Commit if ready:** -Changes are complete enough to commit (even as WIP): +Option A - Commit if ready: ```bash git add -A && git commit -m "WIP: " ``` -Use this when: -- Changes are coherent (one logical unit) -- You want to preserve them through sync -- They're ready for potential rebase - -**Option B - Stash if not ready:** -Changes are experimental or incomplete: +Option B - Stash if not ready: ```bash git stash push -m "pre-sync stash $(date +%Y%m%d-%H%M%S)" ``` -Use this when: -- Changes are scattered/incomplete -- You're unsure if you want to keep them -- You need to temporarily set them aside +**If untracked files exist:** -**Exit criteria:** No staged or unstaged changes (git status clean except untracked).""" +For each untracked file, decide: +- **Keep**: Add to .gitignore or commit +- **Delete**: `rm ` +- **Stash**: Can't stash untracked directly; commit or delete -[[steps]] -id = "handle-untracked" -title = "Handle untracked files" -needs = ["handle-uncommitted"] -description = """ -Review and handle untracked files before syncing. +**WARN the agent**: Report untracked files prominently. They may be: +- WIP that should be preserved +- Build artifacts that should be gitignored +- Cruft that should be deleted -**List untracked files:** -```bash -git status --porcelain | grep '^??' -``` +Don't auto-delete without confirmation. -**If no untracked files:** Skip to next step. +**If stash entries exist:** -**For each untracked file, decide:** - -| File Type | Action | -|-----------|--------| -| Build artifacts (.exe, .o, *.test) | Add to .gitignore | -| IDE/editor files (.idea/, .vscode/) | Add to .gitignore | -| Log files (*.log) | Delete or gitignore | -| WIP code files | Commit or delete | -| Config with secrets | Add to .gitignore, WARN | -| Unknown | Ask before deleting | - -**Actions:** - -- **Keep (gitignore):** - ```bash - echo "" >> .gitignore - ``` - -- **Keep (commit):** - ```bash - git add - git commit -m "add: " - ``` - -- **Delete:** - ```bash - rm - ``` - -**WARN the agent**: Untracked files may contain valuable WIP. -Never auto-delete without review. When in doubt, gitignore. - -**Exit criteria:** All untracked files handled (committed, gitignored, or deleted).""" - -[[steps]] -id = "handle-stashes" -title = "Review and clean stash entries" -needs = ["handle-untracked"] -description = """ -Review stash entries and clean up old ones. - -**List stashes:** +List and assess: ```bash git stash list +git stash show -p stash@{0} # Preview each ``` -**If no stashes:** Skip to next step. +Old stashes (>1 week) are likely stale. Consider dropping. +Recent stashes may contain valuable WIP - preserve or commit. -**For each stash entry:** - -1. **Check age:** - ```bash - git log -1 --format="%ar" stash@{N} # "2 weeks ago" - ``` - -2. **Preview contents:** - ```bash - git stash show stash@{N} # Files changed - git stash show -p stash@{N} # Full diff - ``` - -**Decision matrix:** - -| Age | Contents | Action | -|-----|----------|--------| -| < 1 week | Valuable WIP | Keep or apply | -| < 1 week | Obsolete | Drop | -| > 1 week | Any | Likely stale, consider dropping | -| > 1 month | Any | Almost certainly stale, drop | - -**Actions:** - -- **Keep:** Leave in stash list (no action) -- **Apply:** `git stash apply stash@{N}` then handle as uncommitted -- **Drop:** `git stash drop stash@{N}` - -**Caution:** Stash indices shift when you drop! Drop from highest index first: -```bash -git stash drop stash@{2} # Drop this first -git stash drop stash@{1} # Then this -git stash drop stash@{0} # Then this -``` - -**Exit criteria:** Stash reviewed, old/stale entries dropped.""" +**Exit criteria:** Working tree clean or explicitly stashed.""" [[steps]] id = "sync-git" @@ -467,7 +374,7 @@ However, they must be tracked. [[steps]] id = "cleanup-worktrees" title = "Clean up stale worktrees" -needs = ["handle-stashes"] +needs = ["handle-dirty-state"] description = """ Remove orphaned worktrees from cross-rig work.