Skip to content

fix(cli): extend SQUAD_TEAM_ROOT to all resolveSquad() call sites - #841

Merged
tamirdresher merged 5 commits into
devfrom
squad/835-team-root-all-commands
Apr 5, 2026
Merged

tamirdresher merged 5 commits into
devfrom
squad/835-team-root-all-commands

Conversation

@diberry

@diberry diberry commented Apr 4, 2026

Copy link
Copy Markdown
Contributor

Summary

All commands now respect the SQUAD_TEAM_ROOT environment variable for subprocess compatibility.

PR #763 (Amanda Silver) added getSquadStartDir() which returns process.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 using process.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

  • init / init-remote: These create new squads in the current directory, so process.cwd() is semantically correct.

Testing

  • npx vitest run test/cli/nap-subprocess.test.ts — ✅ passes
  • npx vitest run test/cli/cost.test.ts — ✅ passes
  • npx vitest run test/cli/doctor.test.ts test/cli/init.test.ts — ✅ passes

Closes #835
Related: PR #763, #734

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>
Copilot AI review requested due to automatic review settings April 4, 2026 23:39
@github-actions

github-actions Bot commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 288c02e

⚠️ 4 item(s) to address before review

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.

@github-actions

github-actions Bot commented Apr 4, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #841

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 2
Files added 1
Files modified 1
Files deleted 0
Modules touched 2

🎯 Risk Factors

  • 2 files changed (≤5 → LOW)
  • 2 modules touched (2-4 → MEDIUM)

📦 Modules Affected

root (1 file)
  • .changeset/fix-team-root-all-commands.md
squad-cli (1 file)
  • packages/squad-cli/src/cli-entry.ts

This report is generated automatically for every PR. See #733 for details.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 with getSquadStartDir().
  • 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.

Comment on lines 361 to 365
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;

Copilot AI Apr 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.

@tamirdresher tamirdresher left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ LGTM — Pure mechanical process.cwd() → getSquadStartDir() across 23 commands. Correctly excludes init/init-remote.

@tamirdresher
tamirdresher merged commit e4a49f1 into dev Apr 5, 2026
18 checks passed
@tamirdresher
tamirdresher deleted the squad/835-team-root-all-commands branch April 5, 2026 06:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(cli): extend SQUAD_TEAM_ROOT to all resolveSquad() call sites

3 participants