Repository navigation
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Problem
After running \squad externalize, several CLI commands still read from the local .squad/\ directory instead of resolving to the external state directory. This means externalized state (e.g., \ eam.md,
outing.md, \�gents/, \plugins/) becomes invisible to those commands.
Evidence
- \detectSquadDir()\ only returns local .squad/\ or .ai-team/\ — it never follows \stateLocation: external\ + \projectKey\ to the external dir (\detect-squad-dir.ts:49-75)
esolveSquadPaths()\ ignores \stateLocation\ entirely (
esolution.ts:258-292)- The 'external'\ backend in \state-backend.ts:262-268\ is still a stub that maps to \WorktreeBackend\
- \loadDirConfig()\ parses \stateLocation/\projectKey\ from \config.json\ (
esolution.ts:210-233), but nothing uses them to redirect to
esolveExternalStateDir()\
Affected commands (non-exhaustive)
- \squad start\ / shell — reads \ eam.md\ directly (\shell/index.ts:191-214, \shell/lifecycle.ts:67-85)
- \squad start\ / coordinator — reads \ eam.md\ +
outing.md\ (\shell/coordinator.ts:237-259) - \squad loop\ — requires local \ eam.md\ (\loop.ts:269-275)
- \squad watch\ — requires local \ eam.md\ +
outing.md\ (\watch/index.ts:651-657) - \squad plugin marketplace\ — reads/writes .squad/plugins/\ (\plugin.ts:39-60)
- \squad doctor\ — reads \ eam.md,
outing.md, \�gents/\ (\doctor.ts:158-190) - \squad schedule\ — reads/writes \schedule.json\ + .schedule-state.json\ (\schedule.ts:26-33)
Proposed fix
Add an \�ffectiveSquadDir()\ resolver that:
- Reads \config.json\ from the local .squad/\
- If \stateLocation === 'external', resolves the external path via
esolveExternalStateDir(projectKey)\ - Returns the external path for state reads, local path for KEEP_LOCAL files
Then update all affected commands to use \�ffectiveSquadDir()\ instead of hardcoding local .squad/\ paths.
Additional issue: stale state resurrection
unExternalize\ copies into the external dir but never cleans pre-existing contents there.
unInternalize\ copies back but never removes stale external files afterward. Deleted/renamed files can persist in the external dir and come back on a later internalize. Consider mirror-sync or cleanup semantics.
Related
- arch: replace hardcoded STATE_DIRS/STATE_FILES in externalize.ts with discoverable manifest #863 (fixed orphaned files via dynamic scan — PR fix(cli): replace hardcoded state lists with dynamic directory scan #908)
- The \KEEP_LOCAL\ set in \�xternalize.ts\ correctly protects files that bypass state resolution
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working
Activity
diberry commentedon Apr 10, 2026
🔒 On hold — investigation revealed this requires an \�ffectiveSquadDir()\ abstraction threaded through 12+ CLI commands (loop, watch, doctor, plugin, build, import/export, migrate, upstream, copilot, shell/start), plus the external state backend stub. Too large for a minimal fix; reclassifying as high-touch architecture work.
fix(cli): runtime commands resolve externalized state paths
fix(cli): runtime commands resolve externalized state paths