Skip to content

Commit 5bb3bef

Browse files
committed
Established single source of truth for state directory name
1 parent d2ee7ba commit 5bb3bef

28 files changed

Lines changed: 181 additions & 121 deletions

plugins/code/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ Cleans up session-level artifacts: removes the session workdir mapping file, cle
276276

277277
Runs when any subagent starts. Performs three tasks:
278278

279-
1. **Loop agent state creation**: If the agent type appears in `loop-agents.json`, creates the initial state file in `{WORKDIR}/.closedloop/` if it does not already exist.
279+
1. **Loop agent state creation**: If the agent type appears in `loop-agents.json`, creates the initial state file in `{WORKDIR}/.closedloop-ai/` if it does not already exist.
280280
2. **Agent type tracking**: Writes the agent type, short name, and start timestamp to `.agent-types/{agent_id}` so the stop hook can track timing and type.
281281
3. **Learning injection**: Reads `~/.closedloop-ai/learnings/org-patterns.toon`, filters patterns matching the agent's name, sorts by category priority (mistake > convention > pattern > insight) and confidence, and injects up to 15 patterns into the agent's context via `additionalContext`. Also injects environment variables (`CLOSEDLOOP_WORKDIR`, `CLAUDE_PLUGIN_ROOT`, etc.) into every agent's context.
282282

@@ -293,7 +293,7 @@ Runs when any subagent exits. Performs:
293293

294294
Implements the validation loop for agents registered in `loop-agents.json`. When an agent exits:
295295

296-
1. Reads the loop state file (`{WORKDIR}/.closedloop/{state_file_suffix}`)
296+
1. Reads the loop state file (`{WORKDIR}/.closedloop-ai/{state_file_suffix}`)
297297
2. Checks whether the agent output contains the expected completion promise (e.g., `<promise>PLAN_VALIDATED</promise>`)
298298
3. If the promise is present, optionally runs a validation script (e.g., `validate-plan.sh`)
299299
4. If validation passes, allows the agent to exit (returns nothing)
@@ -346,7 +346,7 @@ Defines the structure of `code-map.json` produced by the `pre-explorer` agent. R
346346

347347
### `setup-closedloop.sh`
348348

349-
Initializes a ClosedLoop session. Parses arguments (`--prd`, `--max-iterations`, `--prompt`, positional workdir), auto-detects the PRD file by checking common patterns (`prd.md`, `prd.pdf`, `requirements.md`, etc.), establishes the session-to-workdir mapping, validates the prompt name, and writes `{WORKDIR}/.closedloop/config.env` with all environment variables.
349+
Initializes a ClosedLoop session. Parses arguments (`--prd`, `--max-iterations`, `--prompt`, positional workdir), auto-detects the PRD file by checking common patterns (`prd.md`, `prd.pdf`, `requirements.md`, etc.), establishes the session-to-workdir mapping, validates the prompt name, and writes `{WORKDIR}/.closedloop-ai/config.env` with all environment variables.
350350

351351
### `run-loop.sh`
352352

@@ -485,7 +485,7 @@ After a full run, the work directory will contain:
485485
log.md # Change log appended each phase
486486
perf.jsonl # Agent timing events
487487
reviews/ # Critic review files (*.review.json)
488-
.closedloop/config.env # Session environment variables
488+
.closedloop-ai/config.env # Session environment variables
489489
.learnings/ # Self-learning artifacts
490490
pending/ # Unprocessed learning JSON files
491491
outcomes.log # Pattern application outcomes

plugins/code/hooks/loop-stop-hook.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66

77
set -euo pipefail
88

9+
# Single source of truth for the state directory name
10+
CLOSEDLOOP_STATE_DIR=".closedloop-ai"
11+
912
# Debug logging (redirected to WORKDIR once discovered)
1013
DEBUG_LOG="/dev/null"
1114

@@ -39,15 +42,15 @@ SESSION_ID=$(echo "$HOOK_INPUT" | jq -r '.session_id // empty')
3942
# Discover WORKDIR via session_id mapping (created by setup-closedloop.sh)
4043
CLOSEDLOOP_WORKDIR=""
4144
if [[ -n "$SESSION_ID" ]]; then
42-
WORKDIR_FILE="$CWD/.closedloop-ai/session-$SESSION_ID.workdir"
45+
WORKDIR_FILE="$CWD/$CLOSEDLOOP_STATE_DIR/session-$SESSION_ID.workdir"
4346
if [[ -f "$WORKDIR_FILE" ]]; then
4447
CLOSEDLOOP_WORKDIR=$(cat "$WORKDIR_FILE")
4548
fi
4649
fi
4750

4851
# Source closedloop config from WORKDIR if found
4952
if [[ -n "$CLOSEDLOOP_WORKDIR" ]]; then
50-
CLOSEDLOOP_CONFIG="$CLOSEDLOOP_WORKDIR/.closedloop-ai/config.env"
53+
CLOSEDLOOP_CONFIG="$CLOSEDLOOP_WORKDIR/$CLOSEDLOOP_STATE_DIR/config.env"
5154
if [[ -f "$CLOSEDLOOP_CONFIG" ]]; then
5255
source "$CLOSEDLOOP_CONFIG"
5356
fi
@@ -90,14 +93,14 @@ STATE_FILE_SUFFIX=$(echo "$AGENT_CONFIG" | jq -r '.state_file_suffix // "loop.lo
9093

9194
echo "$(date): Agent config - validation=$VALIDATION_SCRIPT, max_iter=$MAX_ITERATIONS_DEFAULT, promise=$PROMISE, state_suffix=$STATE_FILE_SUFFIX" >> "$DEBUG_LOG"
9295

93-
# Build state file path (in CLOSEDLOOP_WORKDIR/.closedloop-ai/)
96+
# Build state file path (in CLOSEDLOOP_WORKDIR/$CLOSEDLOOP_STATE_DIR/)
9497
# Exit early if CLOSEDLOOP_WORKDIR is not set - no loop context
9598
if [[ -z "$CLOSEDLOOP_WORKDIR" ]]; then
9699
echo "$(date): No CLOSEDLOOP_WORKDIR, exiting loop-stop-hook" >> "$DEBUG_LOG"
97100
exit 0
98101
fi
99102

100-
STATE_FILE="$CLOSEDLOOP_WORKDIR/.closedloop-ai/$STATE_FILE_SUFFIX"
103+
STATE_FILE="$CLOSEDLOOP_WORKDIR/$CLOSEDLOOP_STATE_DIR/$STATE_FILE_SUFFIX"
101104

102105
if [[ ! -f "$STATE_FILE" ]]; then
103106
echo "$(date): No active loop - state file not found: $STATE_FILE" >> "$DEBUG_LOG"

plugins/code/hooks/plan-review.sh

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,16 @@
33
# Triggers when Claude exits plan mode to get a second opinion on the plan
44
# The plan content is available directly from tool_response.plan
55

6+
# Single source of truth for the state directory name
7+
CLOSEDLOOP_STATE_DIR=".closedloop-ai"
8+
69
# Read hook input from stdin (must happen before CWD extraction)
710
INPUT=$(cat)
811

9-
# Debug logging — keeps at most 15 log files in .closedloop-ai/plan-review-logs/
12+
# Debug logging — keeps at most 15 log files in $CLOSEDLOOP_STATE_DIR/plan-review-logs/
1013
CWD=$(echo "$INPUT" | jq -r '.cwd // empty' 2>/dev/null)
1114
CWD="${CWD:-$PWD}"
12-
LOG_DIR="$CWD/.closedloop-ai/plan-review-logs"
15+
LOG_DIR="$CWD/$CLOSEDLOOP_STATE_DIR/plan-review-logs"
1316
mkdir -p "$LOG_DIR"
1417
LOG_FILE="$LOG_DIR/$(date +%Y%m%d-%H%M%S).log"
1518

plugins/code/hooks/pretooluse-hook.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88

99
set -e
1010

11+
# Single source of truth for the state directory name
12+
CLOSEDLOOP_STATE_DIR=".closedloop-ai"
13+
1114
# Debug logging (redirected to WORKDIR once discovered)
1215
DEBUG_LOG="/dev/null"
1316

@@ -122,7 +125,7 @@ esac
122125
# Discover WORKDIR via session_id mapping (same pattern as subagent-start-hook.sh)
123126
CLOSEDLOOP_WORKDIR=""
124127
if [[ -n "$SESSION_ID" ]]; then
125-
WORKDIR_FILE="$CWD/.closedloop-ai/session-$SESSION_ID.workdir"
128+
WORKDIR_FILE="$CWD/$CLOSEDLOOP_STATE_DIR/session-$SESSION_ID.workdir"
126129
if [[ -f "$WORKDIR_FILE" ]]; then
127130
CLOSEDLOOP_WORKDIR=$(cat "$WORKDIR_FILE")
128131
fi
@@ -139,7 +142,7 @@ DEBUG_LOG="$CLOSEDLOOP_WORKDIR/.learnings/pretooluse-hook-debug.log"
139142
echo "$(date): PreToolUse hook started, tool=$TOOL_NAME" >> "$DEBUG_LOG"
140143

141144
# Source closedloop config and skip learning injection if disabled
142-
CLOSEDLOOP_CONFIG="$CLOSEDLOOP_WORKDIR/.closedloop-ai/config.env"
145+
CLOSEDLOOP_CONFIG="$CLOSEDLOOP_WORKDIR/$CLOSEDLOOP_STATE_DIR/config.env"
143146
if [[ -f "$CLOSEDLOOP_CONFIG" ]]; then
144147
source "$CLOSEDLOOP_CONFIG"
145148
fi
@@ -148,7 +151,7 @@ if [[ "${CLOSEDLOOP_SELF_LEARNING:-false}" != "true" ]]; then
148151
fi
149152

150153
# Path to org-patterns.toon
151-
PATTERNS_FILE="$HOME/.closedloop-ai/learnings/org-patterns.toon"
154+
PATTERNS_FILE="$HOME/$CLOSEDLOOP_STATE_DIR/learnings/org-patterns.toon"
152155

153156
if [[ ! -f "$PATTERNS_FILE" ]]; then
154157
echo "$(date): No patterns file found, exiting" >> "$DEBUG_LOG"

plugins/code/hooks/session-end-hook.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
set -e
66

7+
# Single source of truth for the state directory name
8+
CLOSEDLOOP_STATE_DIR=".closedloop-ai"
9+
710
# Debug logging (redirected once CWD is known)
811
DEBUG_LOG="/dev/null"
912

@@ -17,8 +20,8 @@ REASON=$(echo "$INPUT" | jq -r '.reason // empty')
1720

1821
# Redirect debug logs into project dir (not shared /tmp)
1922
if [[ -n "$CWD" ]]; then
20-
mkdir -p "$CWD/.closedloop-ai"
21-
DEBUG_LOG="$CWD/.closedloop-ai/session-end-hook-debug.log"
23+
mkdir -p "$CWD/$CLOSEDLOOP_STATE_DIR"
24+
DEBUG_LOG="$CWD/$CLOSEDLOOP_STATE_DIR/session-end-hook-debug.log"
2225
fi
2326
echo "$(date): Session end hook started, session=$SESSION_ID, reason=$REASON" >> "$DEBUG_LOG"
2427

@@ -27,7 +30,7 @@ echo "$(date): Session end hook started, session=$SESSION_ID, reason=$REASON" >>
2730
# Remove session-specific files from .closedloop-ai/
2831
# ============================================================================
2932

30-
CLOSEDLOOP_DIR="$CWD/.closedloop-ai"
33+
CLOSEDLOOP_DIR="$CWD/$CLOSEDLOOP_STATE_DIR"
3134

3235
# Discover CLOSEDLOOP_WORKDIR before cleaning up mappings
3336
CLOSEDLOOP_WORKDIR=""

plugins/code/hooks/session-start-hook.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
set -e
77

8+
# Single source of truth for the state directory name
9+
CLOSEDLOOP_STATE_DIR=".closedloop-ai"
10+
811
# Debug logging (redirected once CWD is known)
912
DEBUG_LOG="/dev/null"
1013

@@ -19,16 +22,16 @@ if [[ -z "$SESSION_ID" ]] || [[ -z "$CWD" ]]; then
1922
exit 0
2023
fi
2124

22-
# Create .closedloop-ai directory at project root
23-
mkdir -p "$CWD/.closedloop-ai"
25+
# Create state directory at project root
26+
mkdir -p "$CWD/$CLOSEDLOOP_STATE_DIR"
2427

2528
# Redirect debug logs into project dir (not shared /tmp)
26-
DEBUG_LOG="$CWD/.closedloop-ai/session-start-hook-debug.log"
29+
DEBUG_LOG="$CWD/$CLOSEDLOOP_STATE_DIR/session-start-hook-debug.log"
2730
echo "$(date): SessionStart hook started, PPID=$PPID" >> "$DEBUG_LOG"
2831

2932
# Write PID -> session_id mapping using Claude Code's PID (our PPID)
3033
# ! commands will walk up their process tree to find this
31-
echo "$SESSION_ID" > "$CWD/.closedloop-ai/pid-$PPID.session"
34+
echo "$SESSION_ID" > "$CWD/$CLOSEDLOOP_STATE_DIR/pid-$PPID.session"
3235
echo "$(date): Wrote session mapping: pid-$PPID.session -> $SESSION_ID" >> "$DEBUG_LOG"
3336

3437
exit 0

plugins/code/hooks/subagent-start-hook.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
set -e
66

7+
# Single source of truth for the state directory name
8+
CLOSEDLOOP_STATE_DIR=".closedloop-ai"
9+
710
# Debug logging (redirected to WORKDIR once discovered)
811
DEBUG_LOG="/dev/null"
912

@@ -17,14 +20,14 @@ CWD=$(echo "$INPUT" | jq -r '.cwd // empty')
1720
SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty')
1821

1922
# Early debug log (before WORKDIR discovery) to catch all SubagentStart events
20-
EARLY_DEBUG_LOG="${CWD:-.}/.closedloop-ai/subagent-start-hook-debug.log"
23+
EARLY_DEBUG_LOG="${CWD:-.}/$CLOSEDLOOP_STATE_DIR/subagent-start-hook-debug.log"
2124
mkdir -p "$(dirname "$EARLY_DEBUG_LOG")" 2>/dev/null
2225
echo "$(date): SubagentStart hook fired — agent_type=$AGENT_TYPE agent_id=$AGENT_ID session_id=$SESSION_ID" >> "$EARLY_DEBUG_LOG"
2326

2427
# Discover WORKDIR via session_id mapping (created by setup-closedloop.sh)
2528
CLOSEDLOOP_WORKDIR=""
2629
if [[ -n "$SESSION_ID" ]]; then
27-
WORKDIR_FILE="$CWD/.closedloop-ai/session-$SESSION_ID.workdir"
30+
WORKDIR_FILE="$CWD/$CLOSEDLOOP_STATE_DIR/session-$SESSION_ID.workdir"
2831
if [[ -f "$WORKDIR_FILE" ]]; then
2932
CLOSEDLOOP_WORKDIR=$(cat "$WORKDIR_FILE")
3033
echo "$(date): Found WORKDIR=$CLOSEDLOOP_WORKDIR from session mapping" >> "$DEBUG_LOG"
@@ -35,7 +38,7 @@ fi
3538

3639
# Source closedloop config from WORKDIR if found
3740
if [[ -n "$CLOSEDLOOP_WORKDIR" ]]; then
38-
CLOSEDLOOP_CONFIG="$CLOSEDLOOP_WORKDIR/.closedloop-ai/config.env"
41+
CLOSEDLOOP_CONFIG="$CLOSEDLOOP_WORKDIR/$CLOSEDLOOP_STATE_DIR/config.env"
3942
if [[ -f "$CLOSEDLOOP_CONFIG" ]]; then
4043
source "$CLOSEDLOOP_CONFIG"
4144
fi
@@ -72,13 +75,13 @@ if [[ -f "$LOOP_CONFIG" ]] && [[ -n "$AGENT_TYPE" ]]; then
7275
MAX_ITERATIONS="${CLOSEDLOOP_MAX_ITERATIONS:-$CONFIG_MAX_ITERATIONS}"
7376
PRD_FILE="${CLOSEDLOOP_PRD_FILE:-}"
7477
WORKDIR="${CLOSEDLOOP_WORKDIR:-$CWD}"
75-
STATE_FILE="$WORKDIR/.closedloop-ai/$STATE_FILE_SUFFIX"
78+
STATE_FILE="$WORKDIR/$CLOSEDLOOP_STATE_DIR/$STATE_FILE_SUFFIX"
7679

7780
echo "$(date): Loop agent detected: $AGENT_TYPE, state_file=$STATE_FILE" >> "$DEBUG_LOG"
7881

7982
# Only create if state file doesn't exist (idempotent)
8083
if [[ ! -f "$STATE_FILE" ]] && [[ -n "$WORKDIR" ]]; then
81-
mkdir -p "$WORKDIR/.closedloop-ai"
84+
mkdir -p "$WORKDIR/$CLOSEDLOOP_STATE_DIR"
8285

8386
PROMPT="Create a comprehensive implementation plan for the requirements in @${PRD_FILE}.
8487
@@ -124,8 +127,8 @@ if [[ -z "$CLOSEDLOOP_WORKDIR" ]]; then
124127
fi
125128

126129
# Write base environment (same for all agents, only write once)
127-
mkdir -p "$CWD/.closedloop-ai"
128-
BASE_ENV_FILE="$CWD/.closedloop-ai/env"
130+
mkdir -p "$CWD/$CLOSEDLOOP_STATE_DIR"
131+
BASE_ENV_FILE="$CWD/$CLOSEDLOOP_STATE_DIR/env"
129132
if [[ ! -f "$BASE_ENV_FILE" ]]; then
130133
cat > "$BASE_ENV_FILE" << EOF
131134
CLOSEDLOOP_WORKDIR=$CLOSEDLOOP_WORKDIR
@@ -176,7 +179,7 @@ fi
176179
AGENT_NAME="$AGENT_NAME_ONLY"
177180

178181
# Path to org-patterns.toon
179-
PATTERNS_FILE="$HOME/.closedloop-ai/learnings/org-patterns.toon"
182+
PATTERNS_FILE="$HOME/$CLOSEDLOOP_STATE_DIR/learnings/org-patterns.toon"
180183

181184
# Only process learnings if we have agent name and patterns file
182185
if [[ -z "$AGENT_NAME" ]] || [[ ! -f "$PATTERNS_FILE" ]]; then
@@ -424,7 +427,7 @@ if [[ -n "$LEARNINGS" ]]; then
424427
425428
$LEARNINGS"
426429
# Write learnings to agent-specific file
427-
LEARNINGS_FILE="$CWD/.closedloop-ai/learnings-$AGENT_NAME_LOWER"
430+
LEARNINGS_FILE="$CWD/$CLOSEDLOOP_STATE_DIR/learnings-$AGENT_NAME_LOWER"
428431
echo "$LEARNINGS" > "$LEARNINGS_FILE"
429432
echo "$(date): Wrote learnings to $LEARNINGS_FILE" >> "$DEBUG_LOG"
430433
fi

plugins/code/hooks/subagent-stop-hook.sh

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@
55

66
set -e
77

8+
# Single source of truth for the state directory name
9+
CLOSEDLOOP_STATE_DIR=".closedloop-ai"
10+
811
# Debug logging (redirected to WORKDIR once discovered)
912
DEBUG_LOG="/dev/null"
1013

@@ -25,7 +28,7 @@ SESSION_ID=$(echo "$INPUT" | jq -r '.session_id // empty')
2528
# Discover WORKDIR via session_id mapping (created by setup-closedloop.sh)
2629
CLOSEDLOOP_WORKDIR=""
2730
if [[ -n "$SESSION_ID" ]]; then
28-
WORKDIR_FILE="$CWD/.closedloop-ai/session-$SESSION_ID.workdir"
31+
WORKDIR_FILE="$CWD/$CLOSEDLOOP_STATE_DIR/session-$SESSION_ID.workdir"
2932
if [[ -f "$WORKDIR_FILE" ]]; then
3033
CLOSEDLOOP_WORKDIR=$(cat "$WORKDIR_FILE")
3134
echo "$(date): Found WORKDIR=$CLOSEDLOOP_WORKDIR from session mapping" >> "$DEBUG_LOG"
@@ -36,7 +39,7 @@ fi
3639

3740
# Source closedloop config from WORKDIR if found
3841
if [[ -n "$CLOSEDLOOP_WORKDIR" ]]; then
39-
CLOSEDLOOP_CONFIG="$CLOSEDLOOP_WORKDIR/.closedloop-ai/config.env"
42+
CLOSEDLOOP_CONFIG="$CLOSEDLOOP_WORKDIR/$CLOSEDLOOP_STATE_DIR/config.env"
4043
if [[ -f "$CLOSEDLOOP_CONFIG" ]]; then
4144
source "$CLOSEDLOOP_CONFIG"
4245
fi
@@ -179,7 +182,7 @@ if [[ "${CLOSEDLOOP_SELF_LEARNING:-false}" == "true" ]]; then
179182
# This ensures compute_success_rates.py always has data to work with.
180183
# ============================================================================
181184
AGENT_NAME_LOWER=$(echo "$AGENT_NAME" | tr '[:upper:]' '[:lower:]')
182-
LEARNINGS_FILE="$CWD/.closedloop-ai/learnings-$AGENT_NAME_LOWER"
185+
LEARNINGS_FILE="$CWD/$CLOSEDLOOP_STATE_DIR/learnings-$AGENT_NAME_LOWER"
183186

184187
if [[ -f "$LEARNINGS_FILE" ]]; then
185188
echo "$(date): Reading injected patterns from $LEARNINGS_FILE" >> "$DEBUG_LOG"

plugins/code/prompts/overlays/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ this order:
1313
1. If `prompts/<name>.md` exists, use it directly (backward compatible).
1414
2. Else if `prompts/overlays/<name>.overlay.md` exists, assemble
1515
`prompts/prompt.md` + blank line + overlay into
16-
`$CLOSEDLOOP_WORKDIR/.closedloop/prompt-assembled.md` and point
16+
`$CLOSEDLOOP_WORKDIR/.closedloop-ai/prompt-assembled.md` and point
1717
`CLOSEDLOOP_PROMPT_FILE` at that file.
1818
3. Else, fail loud with "prompt not found".
1919

@@ -51,7 +51,7 @@ does not pass `--prompt` explicitly.
5151
## Debugging
5252

5353
- Inspect the assembled file at
54-
`$CLOSEDLOOP_WORKDIR/.closedloop/prompt-assembled.md` after a run
54+
`$CLOSEDLOOP_WORKDIR/.closedloop-ai/prompt-assembled.md` after a run
5555
starts.
5656
- To bypass the overlay, pass `--prompt prompt` — the base is used
5757
unchanged.

plugins/code/scripts/discover-repos.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
# Output: JSON to stdout
55

66
set -e
7+
8+
# Single source of truth for the state directory name
9+
CLOSEDLOOP_STATE_DIR=".closedloop-ai"
10+
711
PROJECT_ROOT="${1:-$PWD}"
812
PROJECT_ROOT=$(cd "$PROJECT_ROOT" && pwd)
913

1014
# Read current repo's identity
11-
CURRENT_IDENTITY="$PROJECT_ROOT/.closedloop-ai/.repo-identity.json"
15+
CURRENT_IDENTITY="$PROJECT_ROOT/$CLOSEDLOOP_STATE_DIR/.repo-identity.json"
1216
if [[ -f "$CURRENT_IDENTITY" ]]; then
1317
CURRENT_NAME=$(jq -r '.name // "unknown"' "$CURRENT_IDENTITY")
1418
CURRENT_TYPE=$(jq -r '.type // "unknown"' "$CURRENT_IDENTITY")
@@ -51,7 +55,7 @@ if [[ -n "${CLOSEDLOOP_ADD_DIRS:-}" ]]; then
5155
_mark_seen "$path"
5256

5357
# Read identity if exists, fall back to basename
54-
identity_file="$path/.closedloop-ai/.repo-identity.json"
58+
identity_file="$path/$CLOSEDLOOP_STATE_DIR/.repo-identity.json"
5559
repo_name=""
5660
repo_type="unknown"
5761
if [[ -f "$identity_file" ]]; then
@@ -86,7 +90,7 @@ if [[ -n "$CLAUDE_WORKSPACE_REPOS" ]]; then
8690
_mark_seen "$path"
8791

8892
# Read identity if exists
89-
identity_file="$path/.closedloop-ai/.repo-identity.json"
93+
identity_file="$path/$CLOSEDLOOP_STATE_DIR/.repo-identity.json"
9094
type="unknown"
9195
repo_name=""
9296
if [[ -f "$identity_file" ]]; then
@@ -108,7 +112,7 @@ if [[ -z "$CLAUDE_WORKSPACE_REPOS" ]]; then
108112
[[ "$sibling" == "$PROJECT_ROOT" ]] && continue
109113
[[ ! -d "$sibling" ]] && continue
110114

111-
identity_file="$sibling/.closedloop-ai/.repo-identity.json"
115+
identity_file="$sibling/$CLOSEDLOOP_STATE_DIR/.repo-identity.json"
112116
if [[ -f "$identity_file" ]]; then
113117
name=$(jq -r '.name // "unknown"' "$identity_file")
114118
type=$(jq -r '.type // "unknown"' "$identity_file")

0 commit comments

Comments
 (0)