Skip to content

fix: respect SQUAD_HOME env var, implement SQUAD_PERSONAL_DIR, fix Windows loop preflight - #1382

Merged
tamirdresher merged 3 commits into
devfrom
bradygaster-squad-1280-squad-home-env-bugs
Jun 25, 2026
Merged

tamirdresher merged 3 commits into
devfrom
bradygaster-squad-1280-squad-home-env-bugs

Conversation

@bradygaster

Copy link
Copy Markdown
Collaborator

Summary

Batch fix for SQUAD_HOME and environment-related bugs. All changes are small, surgical fixes.

Issues Fixed

Issue Fix
#1280 capabilities.ts now uses resolveSquadHome() instead of hardcoded ~/.squad/ for machine-capabilities.json
#1279 comms-teams.ts now uses resolveSquadHome() instead of hardcoded ~/.squad/ for Teams OAuth token storage
#1278 resolvePersonalSquadDir() now respects SQUAD_PERSONAL_DIR env var override
#1372 loop.ts checkCopilotCli() now passes shell: process.platform === 'win32' so Windows can resolve copilot.ps1/.cmd shims
#1010, #984 squad init now sets teamRoot in config.json to the personal squad directory when one exists
#1026 Already fixed by #939 (removed git init call) — no code change needed

Changes by file

  • packages/squad-sdk/src/ralph/capabilities.ts — Replace os.homedir() fallback with resolveSquadHome()
  • packages/squad-sdk/src/platform/comms-teams.ts — Replace hardcoded SQUAD_DIR constant with getSquadDir() helper that uses resolveSquadHome()
  • packages/squad-sdk/src/resolution.ts — Add SQUAD_PERSONAL_DIR env var check at the top of resolvePersonalSquadDir()
  • packages/squad-cli/src/cli/commands/loop.ts — Add shell and timeout options to execFile('copilot', ...) matching sibling call sites
  • packages/squad-cli/src/cli/core/init.ts — After SDK init, patch config.json with teamRoot pointing to personal squad directory

Testing

  • Type-checked both packages (tsc --noEmit): no new errors introduced (pre-existing errors in unrelated files remain)
  • All changes are consistent with existing patterns (e.g., doctor.ts, monitor-teams.ts already use shell: true)

Closes #1280, Closes #1279, Closes #1278, Closes #1372, Closes #1010, Closes #984

…ndows loop preflight

- capabilities.ts: use resolveSquadHome() instead of hardcoded ~/.squad/ (#1280)
- comms-teams.ts: use resolveSquadHome() for Teams OAuth token storage (#1279)
- resolution.ts: implement SQUAD_PERSONAL_DIR env var override (#1278)
- loop.ts: add shell flag for Windows copilot.ps1/.cmd resolution (#1372)
- init.ts: link to personal squad teamRoot when available (#1010, #984)

Closes #1280, Closes #1279, Closes #1278, Closes #1372, Closes #1010, Closes #984

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings June 24, 2026 09:29
@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

🛫 PR Readiness Check

ℹ️ This comment updates on each push. Last checked: commit 9b372a6

PR Scope: 📦🔧 Mixed (product + infrastructure)

⚠️ 2 item(s) to address before review

Status Check Details
❌ Single commit 3 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 4 active Copilot thread(s) resolved (1 outdated skipped)
✅ CI passing All checks passing

Files Changed (8 files, +125 −15)

File +/−
.changeset/fix-squad-home-env-bugs.md +12 −0
packages/squad-cli/src/cli/commands/loop.ts +1 −1
packages/squad-cli/src/cli/core/init.ts +22 −1
packages/squad-sdk/src/platform/comms-teams.ts +13 −7
packages/squad-sdk/src/ralph/capabilities.ts +10 −4
packages/squad-sdk/src/resolution.ts +8 −0
test/comms-teams-integration.test.ts +30 −2
test/personal-squad-init.test.ts +29 −0

Total: +125 −15


This check runs automatically on every push. Fix any ❌ items and push again.
See CONTRIBUTING.md and PR Requirements for details.

@github-actions

Copy link
Copy Markdown
Contributor

🏗️ Architectural Review

⚠️ Architectural review: 1 warning(s).

Severity Category Finding Files
🟡 warning bootstrap-area 1 file(s) in the bootstrap area (packages/squad-cli/src/cli/core/) were modified. These files must maintain zero external dependencies. Review carefully. packages/squad-cli/src/cli/core/init.ts

Automated architectural review — informational only.

@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown
Contributor

🟡 Impact Analysis — PR #1382

Risk tier: 🟡 MEDIUM

📊 Summary

Metric Count
Files changed 8
Files added 1
Files modified 7
Files deleted 0
Modules touched 4

🎯 Risk Factors

  • 8 files changed (6-20 → MEDIUM)
  • 4 modules touched (2-4 → MEDIUM)

📦 Modules Affected

root (1 file)
  • .changeset/fix-squad-home-env-bugs.md
squad-cli (2 files)
  • packages/squad-cli/src/cli/commands/loop.ts
  • packages/squad-cli/src/cli/core/init.ts
squad-sdk (3 files)
  • packages/squad-sdk/src/platform/comms-teams.ts
  • packages/squad-sdk/src/ralph/capabilities.ts
  • packages/squad-sdk/src/resolution.ts
tests (2 files)
  • test/comms-teams-integration.test.ts
  • test/personal-squad-init.test.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

This PR aims to fix several environment/path-related bugs by routing user-level state through the SDK’s resolution helpers (not hardcoded ~/.squad paths), adding a SQUAD_PERSONAL_DIR override, and improving Windows compatibility for Copilot CLI preflight.

Changes:

  • Use resolveSquadHome() for capability and Teams token storage so SQUAD_HOME is honored.
  • Add SQUAD_PERSONAL_DIR support to resolvePersonalSquadDir().
  • Fix Windows squad loop preflight by enabling shell when invoking copilot.
Show a summary per file
File Description
packages/squad-sdk/src/resolution.ts Adds SQUAD_PERSONAL_DIR override handling in personal squad resolution.
packages/squad-sdk/src/ralph/capabilities.ts Switches user-level capabilities lookup to resolveSquadHome() (respects SQUAD_HOME).
packages/squad-sdk/src/platform/comms-teams.ts Routes Teams token cache storage through resolveSquadHome() (respects SQUAD_HOME).
packages/squad-cli/src/cli/core/init.ts Attempts to link repo init to a personal squad by patching .squad/config.json.
packages/squad-cli/src/cli/commands/loop.ts Makes Copilot CLI availability check Windows-friendly via shell + timeout.
.changeset/fix-squad-home-env-bugs.md Adds a changeset covering CLI + SDK patch releases for these fixes.

Copilot's findings

  • Files reviewed: 6/6 changed files
  • Comments generated: 5

Comment thread packages/squad-cli/src/cli/core/init.ts Resolved
Comment thread packages/squad-sdk/src/resolution.ts Resolved
Comment thread packages/squad-sdk/src/resolution.ts Resolved

@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 — the SQUAD_HOME / env handling is correct and idempotent (the if (!config['teamRoot']) guard keeps init from overwriting an existing value), and the Windows loop preflight fix matches the existing agent-spawn.ts pattern. Approving.

Two non-blocking things worth a follow-up:

  1. SQUAD_PERSONAL_DIR doesn't expand ~. path.resolve('~/foo') becomes <cwd>/~/foo, fails existsSync, and resolvePersonalSquadDir() returns null silently — so the most natural value a Unix user would type quietly does nothing. Either expand ~ (envDir.startsWith('~/') ? path.join(os.homedir(), envDir.slice(1)) : envDir) or console.warn when the var is set but the path doesn't exist.
  2. shell flag convention now differs from doctor.ts / monitor-*.ts, which pass unconditional shell: true. No injection risk here since the args are hardcoded, but might be worth unifying on the conditional shell: process.platform === 'win32' pattern you used.

A test for the new init → teamRoot linking would be a nice addition too. None of these block — good to merge.

brady gaster and others added 2 commits June 24, 2026 09:37
…oc, tests

- init.ts: use resolveGlobalSquadPath() for teamRoot instead of personal-squad dir
- resolution.ts: validate SQUAD_PERSONAL_DIR is a directory, not just exists
- comms-teams.ts: update JSDoc to reflect resolveSquadHome() usage
- capabilities.ts: update JSDoc search order to document SQUAD_HOME support
- test: add SQUAD_PERSONAL_DIR env var test cases

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Closes #1280

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@tamirdresher
tamirdresher merged commit fc057de into dev Jun 25, 2026
14 checks passed
@bradygaster
bradygaster deleted the bradygaster-squad-1280-squad-home-env-bugs branch August 20, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants