feat: Default base_repo_dir to "/", fix linked worktree resolution#23
feat: Default base_repo_dir to "/", fix linked worktree resolution#23nothingnesses wants to merge 5 commits into0xferrous:mainfrom
base_repo_dir to "/", fix linked worktree resolution#23Conversation
Implement [Phase 1](https://github.com/nothingnesses/agent-box/blob/e5c0696569ef64f0b25702b124cd515018dd13dd/plan-issue-16.md) of the `base_repo_dir` removal plan (issue 0xferrous#16): - Default `base_repo_dir` to `"/"` so session mode works for repos anywhere on the filesystem without upfront configuration. - Track whether `base_repo_dir` was explicitly set via `figment.find_value` to distinguish user config from the serde default. - Rewrite `discover_repo_ids` to only scan when safe (explicit non-`"/"` `base_repo_dir`), returning an error with config guidance otherwise. - Fix linked worktree resolution: `find_git_root_from` resolves linked worktrees to the main repo root via `gix::open` on `common_dir`. - Add `find_git_workdir` for local mode (no worktree resolution, no canonicalization). - Fix `display.rs` to use `find_git_root_from`, add repo identity header. - Add `ab dbg list` to scan and display workspace groups with status. - Add `ab dbg remove --unresolved` with dry-run, force, and confirmation warning about `base_repo_dir` changes. - Add `ab new` bare name hint when positional arg has no path separator. - Canonicalize repo paths in `find_git_root_from` and `discover_repos_in_dir` with warn-and-skip on failure. - Add `WorkspaceType::as_str`, `WorkspaceStatus::as_str`, and `WorkspaceInfo::workspace_dir` to reduce duplication. - Regenerate CLI reference docs including `ab dbg` subcommands. - Filter tracing log lines from CLI doc generator output. - Add migration documentation to `config.md`. - Update first-run, overview, and workflow docs. - Update `.gitignore` to include `.direnv/`, `.claude/` and `.playwright-mcp/`.
Manual test findings for ab4d373Date: 2026-03-20 Test 3: Remove
|
| Test | Description | Result |
|---|---|---|
| 1 | cargo build |
PASS |
| 2 | cargo test |
PASS (146 tests) |
| 3 | Remove base_repo_dir, create workspace |
PASS (creation), cleanup requires workaround |
| 4 | Explicit base_repo_dir unchanged |
PASS |
| 5 | ab info from linked worktree |
PASS |
| 6 | ab new from linked worktree |
PASS |
| 7 | ab spawn --local from worktree |
PASS (mount path correct) |
| 8 | ab dbg list |
PASS |
| 9 | ab dbg list --unresolved |
PASS |
| 10 | ab dbg remove --unresolved --dry-run |
PASS |
| 11 | ab dbg remove --unresolved |
PASS |
| 12 | ab info repo identity header |
PASS |
| 13 | ab new bare name hint |
PASS |
Follow-up issues identified
-
ab dbg removecannot manage workspaces when discovery is not configured. Therepoargument always goes throughlocate_repo->discover_repo_ids. Whenbase_repo_dirdefaults to/and no discovery dirs are set, all name-based removal fails. Should accept a direct path as an alternative. -
ab dbg removedoes not clean up git worktree metadata. After removing a workspace directory, the git worktree entry persists in the source repo's.git/worktrees/directory. Stale entries show up inab infoandgit worktree listuntilgit worktree pruneis run. Consider runninggit worktree removeorgit worktree pruneas part of cleanup.
… cleanup Accept absolute source paths in `ab dbg remove` (e.g., `ab dbg remove /home/user/repos/myproject`), bypassing discovery so workspaces can be managed even when `base_repo_dir` is unset. Paths are canonicalized with fallback to `std::path::absolute` for deleted repos. Clean up git worktree metadata on removal via `git worktree remove --force` before deleting workspace directories. When the source repo is missing, print a note suggesting `git worktree prune`. Extract shared `cleanup_git_worktrees` helper used by both `remove_repo` and the `--unresolved` path. Also: use `WorkspaceType` for type-safe dispatch in `remove_repo` instead of string comparison, update migration docs to mention absolute path support, and add tests for malformed `.git` files and short gitdir paths.
Manual test findings for
|
| Test | Description | Result |
|---|---|---|
| F1.1 | Create workspace without base_repo_dir |
PASS |
| F1.2 | ab dbg list shows full source path |
PASS |
| F1.3 | ab dbg remove absolute path, dry run |
PASS |
| F1.4 | ab dbg remove absolute path, actual removal |
PASS |
| F1.5 | Restore config, name-based removal still works | PASS |
| F2.1 | Git worktree metadata cleaned up on removal | PASS |
Follow-up issues identified
[DRY RUN]shown in confirmation preview. Whenab dbg removeis run without--dry-run, the preview (before the confirmation prompt) still prints[DRY RUN] No files were actually deleted.because it callsremove_repo(config, repo_id, true). This is confusing. The preview call should suppress the[DRY RUN]message, or use a separate display mode. This is pre-existing behavior, not introduced by this diff.
The confirmation preview for `ab dbg remove` was showing `[DRY RUN] No files were actually deleted.` even when the user did not pass `--dry-run`, because `remove_repo(dry_run=true)` was used for both the preview and the actual dry-run path. Move the `[DRY RUN]` message out of `remove_repo` into `main.rs` so it only prints when `--dry-run` was explicitly requested.
Codex PR ReviewReviewed branch: Findings1. Git worktree cleanup still breaks for relative
|
…, isolate tests Resolve relative `gitdir:` entries against session_path in remove_git_worktree so cleanup works when worktree.useRelativePaths is enabled. Make scan_workspaces check for VCS markers (.git/.jj) instead of just testing is_dir(), preventing plain directories from being reported as healthy. Isolate all test git commands from global config via GIT_CONFIG_NOSYSTEM and HOME env vars. Escape brackets and angle brackets in doc comments to fix cargo doc warnings.
|
Thanks @0xferrous. I've addressed the feedback with commit 38a324f according to this plan. Let me know if there's any other issues. |
|
i will need some more time to review this, its just too huge |
|
Thanks, I appreciate you doing things properly. Let me know if you find anything else. |
Implement Phase 1 of the
base_repo_dirremoval plan (fixes #16):base_repo_dirto"/"so session mode works for repos anywhere on the filesystem without upfront configuration.base_repo_dirwas explicitly set viafigment.find_valueto distinguish user config from the serde default.discover_repo_idsto only scan when safe (explicit non-"/"base_repo_dir), returning an error with config guidance otherwise.find_git_root_fromresolves linked worktrees to the main repo root viagix::openoncommon_dir.find_git_workdirfor local mode (no worktree resolution, no canonicalization).display.rsto usefind_git_root_from, add repo identity header.ab dbg listto scan and display workspace groups with status.ab dbg remove --unresolvedwith dry-run, force, and confirmation warning aboutbase_repo_dirchanges.ab newbare name hint when positional arg has no path separator.find_git_root_fromanddiscover_repos_in_dirwith warn-and-skip on failure.WorkspaceType::as_str,WorkspaceStatus::as_str, andWorkspaceInfo::workspace_dirto reduce duplication.ab dbgsubcommands.config.md..gitignoreto include.direnv/,.claude/and.playwright-mcp/.