fix(cli): extend SQUAD_TEAM_ROOT to all resolveSquad() call sites#841
fix(cli): extend SQUAD_TEAM_ROOT to all resolveSquad() call sites#841tamirdresher merged 5 commits intodevfrom
Conversation
🛫 PR Readiness Check
|
| Status | Check | Details |
|---|---|---|
| ❌ | Single commit | 5 commits — consider squashing before review |
| ✅ | 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 | 1 unresolved Copilot thread(s) — fix and resolve before merging |
| ❌ | CI passing | 16 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.
🟡 Impact Analysis — PR #841Risk tier: 🟡 MEDIUM 📊 Summary
🎯 Risk Factors
📦 Modules Affectedroot (1 file)
squad-cli (1 file)
This report is generated automatically for every PR. See #733 for details. |
There was a problem hiding this comment.
Pull request overview
Extends SQUAD_TEAM_ROOT / --team-root handling so CLI commands resolve the squad starting directory consistently in subprocess contexts (where process.cwd() may differ).
Changes:
- Replaced many remaining
process.cwd()-based command entrypoints withgetSquadStartDir(). - Ensured commands that pass a “root/working directory” into handlers (e.g., migrate/watch/loop/export/import/start/etc.) now respect
SQUAD_TEAM_ROOT. - Added a patch changeset for
@bradygaster/squad-cli.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| packages/squad-cli/src/cli-entry.ts | Routes most command handlers through getSquadStartDir() instead of process.cwd() to support subprocess invocation. |
| .changeset/fix-team-root-all-commands.md | Patch changeset documenting the CLI behavior update. |
| const fromIdx = args.indexOf('--from'); | ||
| const from = (fromIdx !== -1 && args[fromIdx + 1]) ? args[fromIdx + 1] : undefined; | ||
| const dryRun = args.includes('--dry-run'); | ||
| await runMigrate(process.cwd(), { to, from: from as 'ai-team' | undefined, dryRun }); | ||
| await runMigrate(getSquadStartDir(), { to, from: from as 'ai-team' | undefined, dryRun }); | ||
| return; |
There was a problem hiding this comment.
There are currently regression tests for --team-root/SQUAD_TEAM_ROOT only for nap (see test/cli/nap-subprocess.test.ts). This PR updates many additional command entrypoints to use getSquadStartDir(), but there’s no test coverage to ensure those commands still resolve/operate correctly when process.cwd() differs from the squad root (the subprocess scenario this change targets). Consider adding at least one CLI-level integration test (similar to the nap subprocess test) that runs another updated command (e.g., export, watch --health, loop --init, etc.) with SQUAD_TEAM_ROOT set to a different directory than the command’s cwd.
tamirdresher
left a comment
There was a problem hiding this comment.
✅ LGTM — Pure mechanical process.cwd() → getSquadStartDir() across 23 commands. Correctly excludes init/init-remote.
Summary
All commands now respect the
SQUAD_TEAM_ROOTenvironment variable for subprocess compatibility.PR #763 (Amanda Silver) added
getSquadStartDir()which returnsprocess.env['SQUAD_TEAM_ROOT'] || process.cwd(), but only wired it into 3 commands (nap, status, cost). This PR extends it to all 23 remaining command handlers that were still usingprocess.cwd()directly.Commands updated
upgrade, migrate, watch (health + config + run), loop (init + run), export, import, plugin, copilot, build, subsquads/streams, start, consult, extract, link, rc, schedule, personal, cast, economy, config
Commands intentionally NOT changed
process.cwd()is semantically correct.Testing
npx vitest run test/cli/nap-subprocess.test.ts— ✅ passesnpx vitest run test/cli/cost.test.ts— ✅ passesnpx vitest run test/cli/doctor.test.ts test/cli/init.test.ts— ✅ passesCloses #835
Related: PR #763, #734