feat: add pm - project manager for multi-repo workspaces#581
feat: add pm - project manager for multi-repo workspaces#581
Conversation
Simple CLI for managing multi-repo projects with git worktree pooling. Commands: pm new <project> - create a new project pm add <repo> - add a repo (infers project from cwd, GitHub shorthand) pm rm <project> - remove a project (handles manual rm gracefully) pm status - show all projects and pool state pm cleanup - find stale/merged projects Key features: - GitHub shorthand: 'block/goose' just works - HTTPS-first clone with SSH fallback - Branch convention: $USER/$PROJECT - Auto-init, auto-clone, cwd-aware - Resilient to manual rm of project dirs
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c79877e778
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| if project_dir.exists() { | ||
| std::fs::remove_dir_all(&project_dir) | ||
| .with_context(|| format!("Failed to remove {}", project_dir.display()))?; |
There was a problem hiding this comment.
Refuse deleting directories not tracked as projects
rm recursively deletes base/<name> whenever that path exists, even if <name> was never registered in state.projects. In practice, a typo like pm rm docs can wipe an unrelated workspace folder and its contents. This should be gated on the project being managed (or return an error) before calling remove_dir_all.
Useful? React with 👍 / 👎.
| let state: State = | ||
| serde_json::from_str(&data).with_context(|| "Failed to parse state file")?; | ||
| Ok(Some(state)) |
There was a problem hiding this comment.
Rebind loaded state root to the active workspace path
State::load returns the deserialized struct without normalizing root to the base being opened. Since later operations (including save() and pool path resolution) use self.root, moving/renaming a workspace or opening it via a different canonical path can make pm read/write state and worktrees in the old location instead of the current one.
Useful? React with 👍 / 👎.
| if needs_checkout { | ||
| let repo = state.repos.get(repo_name).unwrap(); | ||
| if slot.path.exists() { | ||
| git::checkout(&slot.path, branch)?; | ||
| } else { |
There was a problem hiding this comment.
Recreate missing worktree when reusing an owned slot
For slots already owned by the same project, repair logic only runs when the branch changes. If the slot directory was manually removed and the branch is unchanged, this path returns success without restoring the worktree, so subsequent pm add can leave a symlink pointing at a non-existent target while reporting success.
Useful? React with 👍 / 👎.
wesbillman
left a comment
There was a problem hiding this comment.
Nice! This is great! In a follow on PR maybe, we should add some README and a bunch of tests for this thing.
Pool conflict resolution: - Interactive terminal: dialoguer Select menu to choose which project to evict, grow the pool, or abort - Non-interactive (agent/CI): aborts with clear error and actionable --evict <project> / --grow-pool flags - Detection uses std::io::stdin().is_terminal() New CLI flags on 'pm add': --evict <project> evict a specific project (non-interactive) --grow-pool add a slot instead of evicting --existing --worktree register existing checkout for worktree use Refactored pool::acquire_slot to return AcquireResult enum. New pool::execute_eviction and pool::grow_and_acquire. Improved git checkout with 3-step fallback strategy. Improved is_branch_merged to handle squash merges.
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
Simple CLI for managing multi-repo projects with git worktree pooling.
Commands
pm new <project>- create a new projectpm add <repo>- add a repo (infers project from cwd, GitHub shorthand)pm rm <project>- remove a project (handles manual rm gracefully)pm status- show all projects and pool statepm cleanup- find stale/merged projectsKey features
block/goosejust works$USER/$PROJECT