Skip to content

setup-state.json lookup ignores agentsDir userConfig #55

@cofin

Description

@cofin

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

  1. Confirm where setup-state.json actually gets written when agentsDir != ".agents" (likely ${agentsDir}/setup-state.json based on flow-setup conventions, but verify).
  2. 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.
  3. 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

  • With CLAUDE_PLUGIN_OPTION_AGENTSDIR=specs set and specs/setup-state.json present, SessionStart reports Flow Root: specs (not the "(default)" fallback).
  • Existing projects with .agents/setup-state.json still resolve correctly when no agentsDir is configured.
  • PowerShell parity.

Related

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions