Skip to content

fix(obs): resolve squads dir from git root for worktree support#660

Merged
agents-squads[bot] merged 1 commit intodevelopfrom
fix/652-obs-sync-path
Mar 28, 2026
Merged

fix(obs): resolve squads dir from git root for worktree support#660
agents-squads[bot] merged 1 commit intodevelopfrom
fix/652-obs-sync-path

Conversation

@agents-squads
Copy link
Copy Markdown
Contributor

@agents-squads agents-squads bot commented Mar 28, 2026

Summary

squads obs sync failed to find JSONL when invoked from a git worktree or any directory where hq is a sibling (not an ancestor).

Root Cause

findSquadsDir() only walked up ancestors from process.cwd(). From .worktrees/data-lead-xxx/, hq is at agents-squads/hq/ — a sibling, not an ancestor.

Fix

Three-stage fallback in findSquadsDir():

  1. Original 5-level ancestor walk from CWD (unchanged happy path)
  2. git rev-parse --show-toplevel — walk up from git toplevel if different from CWD
  3. git rev-parse --git-common-dir — find main repo root, walk up from there + check siblings

No new npm dependencies (uses built-in child_process.spawnSync).

Testing

  • npm run build passes
  • npm test passes (1892 tests)

Closes #652

findSquadsDir() now uses a 3-stage fallback:
1. Standard 5-level ancestor walk from process.cwd() (unchanged happy path)
2. git rev-parse --show-toplevel — handles CWD deep inside a subdirectory
3. git rev-parse --git-common-dir — resolves main repo root and checks
   sibling directories (e.g. hq/ next to squads-cli/ or worktrees/)

No new npm dependencies. spawnSync from child_process (built-in).

Closes #652
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants