claude-cook 1.11.1 → 1.11.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/agents/cook-pm.md +1 -1
- package/commands/cook/pm-start.md +4 -3
- package/package.json +1 -1
- package/scripts/pm-loop.sh +19 -11
package/agents/cook-pm.md
CHANGED
|
@@ -109,7 +109,7 @@ When running under `/cook:pm-start` and `pm-loop.sh`, you MUST avoid asking the
|
|
|
109
109
|
|
|
110
110
|
## PM Loop Launch is MANDATORY
|
|
111
111
|
|
|
112
|
-
When spawned by `/cook:pm-start`, you MUST launch `pm-loop.sh` via Bash after executing the first cycle. The only exception is when `--manual` flag is explicitly set. Without the loop, the PM does one cycle and stops — defeating the purpose of autonomous operation.
|
|
112
|
+
When spawned by `/cook:pm-start`, you MUST launch `pm-loop.sh --background` via Bash after executing the first cycle. The only exception is when `--manual` flag is explicitly set. Without the loop, the PM does one cycle and stops — defeating the purpose of autonomous operation. Do NOT wrap in `nohup` or append `&` — the `--background` flag handles detaching internally via `setsid`/`disown`. The script prints the PID and exits immediately.
|
|
113
113
|
|
|
114
114
|
</philosophy>
|
|
115
115
|
|
|
@@ -145,16 +145,17 @@ Follow the action for the detected state as defined in `pm-cycle.md`:
|
|
|
145
145
|
**If `--manual` is NOT set**, run this command via Bash tool immediately after the first cycle completes:
|
|
146
146
|
|
|
147
147
|
```bash
|
|
148
|
-
|
|
148
|
+
~/.claude/scripts/pm-loop.sh \
|
|
149
149
|
--phase={X} \
|
|
150
150
|
--interval={poll_interval} \
|
|
151
151
|
--max-iterations={max_iterations} \
|
|
152
152
|
--background \
|
|
153
153
|
${init_flag} \
|
|
154
|
-
${prd_flag}
|
|
155
|
-
> /dev/null 2>&1 &
|
|
154
|
+
${prd_flag}
|
|
156
155
|
```
|
|
157
156
|
|
|
157
|
+
**IMPORTANT:** Do NOT wrap this in `nohup` or append `&`. The `--background` flag makes `pm-loop.sh` handle its own detaching internally (via `setsid` or `nohup+disown`). The script prints the PID, writes the pid file, and exits immediately — the loop continues in a fully detached process.
|
|
158
|
+
|
|
158
159
|
Where:
|
|
159
160
|
- `${init_flag}` is `--init` if the `--init` flag was provided
|
|
160
161
|
- `${prd_flag}` is `--prd=<file>` if provided
|
package/package.json
CHANGED
package/scripts/pm-loop.sh
CHANGED
|
@@ -138,12 +138,19 @@ fi
|
|
|
138
138
|
# ─── Background mode: re-exec detached ───────────────────────────
|
|
139
139
|
|
|
140
140
|
if [ "$BACKGROUND" = true ]; then
|
|
141
|
-
# Strip --background from args, re-exec
|
|
141
|
+
# Strip --background from args, re-exec fully detached
|
|
142
142
|
ARGS=()
|
|
143
143
|
for arg in "$@"; do
|
|
144
144
|
[ "$arg" != "--background" ] && ARGS+=("$arg")
|
|
145
145
|
done
|
|
146
|
-
|
|
146
|
+
# Use setsid to create a new session — survives parent shell death
|
|
147
|
+
# Falls back to nohup+disown if setsid not available
|
|
148
|
+
if command -v setsid >/dev/null 2>&1; then
|
|
149
|
+
setsid "$0" "${ARGS[@]}" > .planning/pm-loop.log 2>&1 &
|
|
150
|
+
else
|
|
151
|
+
nohup "$0" "${ARGS[@]}" > .planning/pm-loop.log 2>&1 &
|
|
152
|
+
disown $! 2>/dev/null || true
|
|
153
|
+
fi
|
|
147
154
|
BG_PID=$!
|
|
148
155
|
echo "$BG_PID" > .planning/.pm-loop-pid
|
|
149
156
|
echo "PM loop launched in background (PID: $BG_PID)"
|
|
@@ -524,24 +531,25 @@ while true; do
|
|
|
524
531
|
update_status "running" "completed_cycle" "$(cat "$CALL_COUNT_FILE" 2>/dev/null || echo 0)"
|
|
525
532
|
print_progress
|
|
526
533
|
|
|
527
|
-
#
|
|
534
|
+
# Check if all tickets in current phase are done
|
|
535
|
+
# DON'T exit — let pm-cycle handle phase advancement.
|
|
536
|
+
# pm-cycle will detect PHASE_COMPLETE and advance to next phase,
|
|
537
|
+
# or detect MILESTONE_COMPLETE and exit with code 42.
|
|
528
538
|
if all_tickets_done; then
|
|
529
539
|
TIMESTAMP=$(date '+%Y-%m-%d %H:%M:%S')
|
|
530
540
|
echo ""
|
|
531
541
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
532
|
-
echo " PM ►
|
|
542
|
+
echo " PM ► PHASE TICKETS DONE — advancing..."
|
|
533
543
|
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
534
544
|
echo ""
|
|
535
|
-
echo " All tickets complete
|
|
545
|
+
echo " All current phase tickets complete. Next cycle will advance."
|
|
536
546
|
echo ""
|
|
537
547
|
echo "" >> "$LOG_FILE"
|
|
538
|
-
echo "## [$TIMESTAMP]
|
|
548
|
+
echo "## [$TIMESTAMP] PHASE_TICKETS_DONE" >> "$LOG_FILE"
|
|
539
549
|
echo "" >> "$LOG_FILE"
|
|
540
|
-
echo "- All tickets done after $CYCLE cycles" >> "$LOG_FILE"
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
notify "COOK PM" "All tickets done! Phase complete after $CYCLE cycles."
|
|
544
|
-
exit 0
|
|
550
|
+
echo "- All tickets done in current phase after $CYCLE cycles" >> "$LOG_FILE"
|
|
551
|
+
echo "- Continuing loop — pm-cycle will advance to next phase" >> "$LOG_FILE"
|
|
552
|
+
notify "COOK PM" "Phase tickets done! Advancing to next phase..."
|
|
545
553
|
fi
|
|
546
554
|
|
|
547
555
|
echo ""
|