Skip to content

Commit d55595c

Browse files
jsturtevantCopilot
andcommitted
fix: shell resolves global squad when no local .squad/ found (#196)
runShell() hardcoded teamRoot to process.cwd(), ignoring the global (personal) squad path. Now uses a fallback chain: 1. Walk up from cwd for local .squad/ 2. Check global squad path (resolveGlobalSquadPath) 3. Fall back to cwd (triggers init mode) Closes #196 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 831e98e commit d55595c

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

  • packages/squad-cli/src/cli/shell

‎packages/squad-cli/src/cli/shell/index.ts‎

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import { SquadClient } from '@bradygaster/squad-sdk/client';
2121
import type { SquadSession } from '@bradygaster/squad-sdk/client';
2222
import type { SquadPermissionHandler } from '@bradygaster/squad-sdk/client';
2323
import type { ShellMessage } from './types.js';
24-
import { initSquadTelemetry, TIMEOUTS, StreamingPipeline, recordAgentSpawn, recordAgentDuration, recordAgentError, recordAgentDestroy, RuntimeEventBus } from '@bradygaster/squad-sdk';
24+
import { initSquadTelemetry, TIMEOUTS, StreamingPipeline, recordAgentSpawn, recordAgentDuration, recordAgentError, recordAgentDestroy, RuntimeEventBus, resolveSquad, resolveGlobalSquadPath } from '@bradygaster/squad-sdk';
2525
import type { UsageEvent } from '@bradygaster/squad-sdk';
2626
import { enableShellMetrics, recordShellSessionDuration, recordAgentResponseLatency, recordShellError } from './shell-metrics.js';
2727
import { buildCoordinatorPrompt, buildInitModePrompt, parseCoordinatorResponse, hasRosterEntries } from './coordinator.js';
@@ -164,7 +164,24 @@ export async function runShell(): Promise<void> {
164164

165165
const registry = new SessionRegistry();
166166
const renderer = new ShellRenderer();
167-
const teamRoot = process.cwd();
167+
168+
// Resolve teamRoot: local .squad/ → global squad → cwd (init mode)
169+
const teamRoot = (() => {
170+
const cwd = process.cwd();
171+
// 1. Walk up from cwd looking for a local .squad/
172+
const localSquad = resolveSquad(cwd);
173+
if (localSquad) {
174+
return pathResolve(localSquad, '..');
175+
}
176+
// 2. Fall back to global (personal) squad path
177+
const globalPath = resolveGlobalSquadPath();
178+
const globalSquadDir = join(globalPath, '.squad');
179+
if (existsSync(globalSquadDir)) {
180+
return globalPath;
181+
}
182+
// 3. No squad found — use cwd (triggers init mode)
183+
return cwd;
184+
})();
168185

169186
// Session persistence — create or resume a previous session
170187
// Skip resume on first run (no team.md or .first-run marker present)

0 commit comments

Comments
 (0)