Centralize project data storage under ~/.config/sidecar#197
Centralize project data storage under ~/.config/sidecar#197marcus merged 12 commits intomarcus:mainfrom
Conversation
…y resolution Introduces a new package that centralizes project-specific sidecar data into ~/.config/sidecar/projects/<slug>/ instead of writing into project directories. Includes Resolve() for project root lookup/creation, WorktreeDir() for worktree subdirectories, slug collision handling (slug-2, slug-3, etc.), and meta.json-based reverse lookup. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update all save/load functions (saveBaseBranch, loadBaseBranch, loadTaskLink, saveAgentType, loadAgentType, savePRURL, loadPRURL) to use projectdir.WorktreeDir() instead of writing directly to worktree directories. Rename file constants from dot-prefixed names (.sidecar-task, etc.) to plain names (task, agent, pr, base) since they now live in a dedicated directory under ~/.config/sidecar/projects/. Update all callers across worktree.go, fetch_pr.go, update.go, and agent.go to pass projectRoot as the first argument. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Update shell manifest, prompts config, and agent launcher script paths to use projectdir.Resolve/WorktreeDir instead of .sidecar/ in worktree. This is part of the migration from per-project .sidecar/ directories to centralized ~/.config/sidecar/projects/<slug>/ storage. - Shell manifest: Init() resolves via projectdir.Resolve(ProjectRoot) - Prompts: LoadPrompts uses projectdir.Resolve internally for project config - Agent launcher: writeAgentLauncher uses projectdir.WorktreeDir for start.sh - Callers updated to pass ProjectRoot instead of WorkDir where appropriate - Tests updated to use config.SetTestConfigPath for isolated projectdir resolution Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…ory filter Sidecar no longer writes files to the project directory, so the ensureSidecarGitignore() function and .sidecar directory filtering in the file browser are no longer needed. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
CreateTDRoot now writes td-root to the centralized project directory (~/.config/sidecar/projects/<slug>/) instead of a .td-root file in the worktree. ResolveTDRoot checks the centralized location first, falling back to legacy .td-root for backward compatibility. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…rage Add projectdir.Migrate() to move legacy .sidecar/, .td-root, and per-worktree state files (.sidecar-task, .sidecar-agent, etc.) to ~/.config/sidecar/projects/. Wire migration into workspace plugin Init() before shell manifest load. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Project-level migration runs in Init() (before manifest load). Worktree-level migration runs once on first RefreshDoneMsg when worktree paths are known. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix user-facing prompt config hints to point to centralized path - Remove .sidecar/ from initRepoGitignoreEntries - Update comments referencing old .sidecar/shells.json location Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Worktrees are now created at ~/.config/sidecar/projects/<slug>/worktrees/<name>/ instead of as sibling directories next to the project root. This keeps all sidecar-managed state in one place and avoids polluting the user's project parent directory. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
Hey @EugeneOsipenko! Starling here (AI assistant on the project). 👋 Centralizing project data away from A few things that stand out as worth Marcus paying attention to on review:
Flagging for @marcus to review. This touches core data layout so want to make sure he's in the loop on the approach before it lands. ✦ |
I'd very much prefer sidecar not adopt this approach, or to somehow make it optional! I lay my repositories and worktrees out as follows and sidecar's existing sibling worktree approach (even though the My approach You end up with all the worktrees related to a project in that project's folder right next to each other. Following is what current sidecar expects, which works well enough for my layout. People commonly clone projects with The existing |
|
To be clear, I think moving sidecar and td metadata elsewhere would be great! My only concern with this PR is how worktrees are handled. |
|
Hey @Amolith! Starling here. 👋 Thanks for the detailed breakdown — the hierarchical worktree layout ( Flagging this for @marcus as a design question to resolve before PR #197 lands. The metadata-centralization part of this PR is clearly good; the worktree placement behavior is the piece that needs a decision. ✦ |
|
I'm in agreement with @Amolith here. This change would basically be a deal killer for me as well. |
Keep only project-level metadata centralization (shells.json, config.json, td-root, prompts) in ~/.config/sidecar/projects/<slug>/. Worktree creation stays as sibling directories and per-worktree state files (.sidecar-task, .sidecar-agent, .sidecar-pr, .sidecar-base, .sidecar-start.sh) remain in the worktree directories. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Move per-worktree state files (task, agent, pr, base, start.sh) to ~/.config/sidecar/projects/<slug>/worktrees/<wt>/ while keeping worktree creation as sibling directories. Remove all migration logic for legacy file locations. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I like the adjustment here @EugeneOsipenko Keeping the sidecar - specific stuff tucked away but the worktrees in place is solid. I would suggest that the state files should be in $XDG_STATE_HOME rather than .config. The XDG spec says that data files generated on behalf of the user but that are not user-defined/created belong there. Similarly, config files should be in $XDG_CONFIG_HOME (which defaults to ~/.config) |
|
Hey @mcowger! Great point on the XDG distinction — this is exactly the kind of spec detail that's easy to overlook. For anyone following along, the XDG Base Directory spec separates these concerns:
For sidecar specifically:
Flagging this for @EugeneOsipenko and @marcus to consider before merge — it's a relatively small change in the path routing but gets the semantics right and makes sidecar a better XDG citizen. Whether to thread all three paths or just config + state is a call for @marcus to make. Thanks for catching this! ✦ |
Per XDG Base Directory Specification, project state files (meta.json, worktree data, td-root) belong in $XDG_STATE_HOME/sidecar/ (defaults to ~/.local/state/sidecar/) rather than ~/.config/sidecar/. Config files remain in ~/.config/sidecar/. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Good call, changed, thanks! |
|
Merged to main! 🎉 Thanks @EugeneOsipenko for this excellent contribution — centralizing project data under XDG-compliant paths is a big quality-of-life improvement. The slug-based resolution and collision handling are well designed. We added migration logic on top of your work (via Appreciate the thorough PR description and test coverage. Welcome to the project! 🪶 |
Summary
internal/projectdirpackage for slug-based project directory resolution under~/.config/sidecar/projects/.sidecar/directories.sidecar/project files to the new centralized locationMotivation
Previously, sidecar stored project-specific data in
.sidecar/directories within each project root. This polluted project directories and required.gitignoremodifications. This PR centralizes all project data under~/.config/sidecar/projects/<slug>/, keeping project directories clean.Test plan
projectdirpackage (slug generation, directory resolution)~/.config/sidecar/projects/.sidecar/data migrates on first run