Background
PR #54 wired userConfig.agentsDir into hooks/detect-env.{sh,ps1} so the configured directory is used as the default root when no project state is recorded. However, the lookup for setup-state.json is still hardcoded:
hooks/detect-env.sh (around detect_project_root): if [[ -f ".agents/setup-state.json" ]]; then ...
hooks/detect-env.ps1 (Get-FlowRoot): $setupStateFile = ".agents/setup-state.json"
This means: if a user installs with agentsDir=specs, Flow may write its state file to specs/setup-state.json (or wherever the setup flow places it for that user), but detect-env will only ever look in .agents/. Result: the user's configured root is silently ignored on every SessionStart after the first init, and the script falls back to the (now-correct) default fallback path — which masks the problem rather than surfacing it.
Scope
- Confirm where
setup-state.json actually gets written when agentsDir != ".agents" (likely ${agentsDir}/setup-state.json based on flow-setup conventions, but verify).
- Update
detect_project_root (sh) and Get-FlowRoot (ps1) to look in ${DEFAULT_ROOT_DIR}/setup-state.json first, with .agents/setup-state.json retained as a backwards-compat fallback for projects initialized before the agentsDir toggle existed.
- If the recorded
root_directory inside setup-state.json ever conflicts with the env-var-driven agentsDir, decide precedence (project state should still win — that's likely correct — but the decision should be explicit, not accidental).
Acceptance criteria
Related
Background
PR #54 wired
userConfig.agentsDirintohooks/detect-env.{sh,ps1}so the configured directory is used as the default root when no project state is recorded. However, the lookup forsetup-state.jsonis still hardcoded:hooks/detect-env.sh(arounddetect_project_root):if [[ -f ".agents/setup-state.json" ]]; then ...hooks/detect-env.ps1(Get-FlowRoot):$setupStateFile = ".agents/setup-state.json"This means: if a user installs with
agentsDir=specs, Flow may write its state file tospecs/setup-state.json(or wherever the setup flow places it for that user), butdetect-envwill only ever look in.agents/. Result: the user's configured root is silently ignored on every SessionStart after the first init, and the script falls back to the (now-correct) default fallback path — which masks the problem rather than surfacing it.Scope
setup-state.jsonactually gets written whenagentsDir != ".agents"(likely${agentsDir}/setup-state.jsonbased onflow-setupconventions, but verify).detect_project_root(sh) andGet-FlowRoot(ps1) to look in${DEFAULT_ROOT_DIR}/setup-state.jsonfirst, with.agents/setup-state.jsonretained as a backwards-compat fallback for projects initialized before the agentsDir toggle existed.root_directoryinsidesetup-state.jsonever conflicts with the env-var-drivenagentsDir, decide precedence (project state should still win — that's likely correct — but the decision should be explicit, not accidental).Acceptance criteria
CLAUDE_PLUGIN_OPTION_AGENTSDIR=specsset andspecs/setup-state.jsonpresent, SessionStart reportsFlow Root: specs(not the "(default)" fallback)..agents/setup-state.jsonstill resolve correctly when noagentsDiris configured.Related
bdcalls in commands/skills onuseBeadsuserConfig #53 (parallel follow-up: gatebdin commands/skills onuseBeads)