fix(cli): wire SQUAD_TEAM_ROOT into squad resolution for subprocess compatibility (#734)#763
Conversation
There was a problem hiding this comment.
Pull request overview
This PR fixes a CLI wiring gap where --team-root / SQUAD_TEAM_ROOT was parsed but not used when resolving the active .squad/ directory, improving reliability when squad is invoked from subprocesses whose process.cwd() differs from the interactive shell (notably Copilot CLI bang commands on Windows).
Changes:
- Added
getSquadStartDir()incli-entry.tsto preferSQUAD_TEAM_ROOToverprocess.cwd(). - Updated
status,cost, andnapto resolve squads starting fromgetSquadStartDir(). - Added a new test file and a patch changeset; improved
nap“no squad found” error to include the searched directory and hint--team-root.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
packages/squad-cli/src/cli-entry.ts |
Adds getSquadStartDir() and uses it to drive squad resolution for status, cost, and nap; improves the nap missing-squad error message. |
test/cli/nap-subprocess.test.ts |
Adds tests intended to cover subprocess/--team-root scenarios for nap. |
.changeset/fix-nap-subprocess-cwd.md |
Adds a patch changeset describing the CLI fix and its motivation. |
🟡 Impact Analysis — PR #763Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (1 file)
squad-cli (1 file)
tests (1 file)
This report is generated automatically for every PR. See #733 for details. |
🛫 PR Readiness Check
|
| Status | Check | Details |
|---|---|---|
| ✅ | Single commit | 1 commit — clean history |
| ✅ | Not in draft | Ready for review |
| ✅ | Branch up to date | Up to date with dev |
| ❌ | Copilot review | No Copilot review yet — it may still be processing |
| ✅ | Changeset present | Changeset file found |
| ✅ | Scope clean | No .squad/ or docs/proposals/ files |
| ✅ | No merge conflicts | No merge conflicts |
| ✅ | Copilot threads resolved | 0 active Copilot thread(s) resolved (2 outdated skipped) |
| ❌ | CI passing | 5 check(s) still running |
This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.
| * working directory differs from the interactive shell. (#734) | ||
| */ | ||
| function getSquadStartDir(): string { | ||
| return process.env['SQUAD_TEAM_ROOT'] || process.cwd(); |
✅ APPROVE WITH FOLLOW-UPThis PR correctly fixes the subprocess invocation issue (#734) where \squad nap\ fails when \process.cwd()\ differs from the project root. The implementation is sound and safe. Code Review✅ Correctness: \getSquadStartDir()\ properly implements the fallback pattern: ✅ Completeness: All 3
Verified against the diff — no call sites missed. ✅ Security: No path traversal risk. The env var is:
✅ Test Quality: The Copilot bot's review comments were valid when written but are now obsolete — commit 01ed21a (current HEAD) addressed both concerns:
The 5 tests cover:
Existing review threads are correctly marked as resolved/outdated. ✅ Error Message Improvement: The updated nap error is helpful: Required Actions Before Merge
VerdictAPPROVE WITH FOLLOW-UP — Code is production-ready. Merge blocked only by Git hygiene (rebase + squash), not code quality. cc @AmandaSilver — please rebase onto latest \dev\ and squash to 1 commit, then CI should auto-run. Code review complete ✅ |
…ompatibility (bradygaster#734) Adds getSquadStartDir() helper that reads SQUAD_TEAM_ROOT env var for nap, status, and cost commands. Previously the --team-root flag was parsed but never passed through to resolveSquad(). - Added getSquadStartDir(): returns SQUAD_TEAM_ROOT ?? process.cwd() - Updated 3 resolveSquad(process.cwd()) calls to use resolveSquad(getSquadStartDir()) - Improved nap error message to show searched directory and suggest --team-root - 5 new tests in test/cli/nap-subprocess.test.ts Closes bradygaster#734 Co-authored-by: AmandaSilver <11282874+AmandaSilver@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
01ed21a to
17d780a
Compare
Follow-up Issues CreatedTwo follow-up issues filed to extend this fix:
These capture the remaining work to make subprocess invocation robust across all commands. |
All commands now respect SQUAD_TEAM_ROOT env var for subprocess compatibility. Previously only nap, status, and cost used getSquadStartDir(). Closes #835 Related: PR #763, #734 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Tamir Dresher <tamir.dresher@gmail.com>
What
Wires the --team-root\ / \SQUAD_TEAM_ROOT\ env var into the
esolveSquad()\ calls for the
ap, \status, and \cost\ commands. Previously the flag was parsed at CLI entry but never passed through to resolution.
Why
\squad nap\ (and other commands) fail when invoked as a subprocess where \process.cwd()\ differs from the interactive shell — e.g. Copilot CLI bang commands (!squad nap) on Windows (#734). The --team-root\ flag was already parsed and stored in \SQUAD_TEAM_ROOT, but no command ever read it.
How
esolveSquad(process.cwd())\ calls to use
esolveSquad(getSquadStartDir())\
Testing
Files Changed
Exports
N/A — no new public API
Breaking Changes
None — additive behavior only. Existing invocations are unchanged.
Waivers
None
Closes #734
Co-authored-by: Copilot 223556219+Copilot@users.noreply.github.com