deepflow 0.1.63 → 0.1.65

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.
@@ -168,32 +168,28 @@ discover_specs() {
168
168
  # Context-monitored claude -p wrapper
169
169
  # ---------------------------------------------------------------------------
170
170
 
171
- # run_claude_monitored <working_dir> <prompt_text> [session_id]
171
+ # run_claude_monitored <working_dir> <prompt_text>
172
172
  #
173
173
  # Runs `claude -p --output-format stream-json` and monitors token usage in
174
174
  # real time. If usage reaches CONTEXT_THRESHOLD_PCT% of the context window the
175
- # process is killed and automatically restarted with `--resume <session_id>` so
176
- # it gets a fresh context window.
175
+ # process is killed and restarted with a fresh context (same prompt, clean
176
+ # session). Prior work persists in the worktree via committed files.
177
177
  #
178
178
  # The final result text is written to stdout. A side-effect context.json is
179
179
  # written to <working_dir>/.deepflow/context.json for statusline consumption.
180
180
  run_claude_monitored() {
181
181
  local working_dir="$1"
182
182
  local prompt_text="$2"
183
- local session_id="${3:-}"
184
183
 
185
184
  local result_tmp
186
185
  result_tmp="$(mktemp)"
187
186
  local error_log
188
187
  error_log="$(mktemp)"
189
188
 
190
- # Outer loop: may restart with --resume when threshold is hit
189
+ # Outer loop: restart with fresh context when threshold is hit
191
190
  while true; do
192
191
  # Build command arguments
193
192
  local -a cmd_args=(claude -p --output-format stream-json --dangerously-skip-permissions)
194
- if [[ -n "$session_id" ]]; then
195
- cmd_args+=(--resume --session-id "$session_id")
196
- fi
197
193
 
198
194
  # Accumulated token count and context window size across events
199
195
  local total_tokens=0
@@ -207,13 +203,8 @@ run_claude_monitored() {
207
203
  fifo_path="$(mktemp -u)"
208
204
  mkfifo "$fifo_path"
209
205
 
210
- if [[ -n "$session_id" ]]; then
211
- "${cmd_args[@]}" < /dev/null > "$fifo_path" 2>>"$error_log" &
212
- claude_pid=$!
213
- else
214
- echo "$prompt_text" | "${cmd_args[@]}" > "$fifo_path" 2>>"$error_log" &
215
- claude_pid=$!
216
- fi
206
+ echo "$prompt_text" | "${cmd_args[@]}" > "$fifo_path" 2>>"$error_log" &
207
+ claude_pid=$!
217
208
 
218
209
  # Read the FIFO line-by-line (set +e to tolerate EINTR from signals)
219
210
  local capturing_result=false
@@ -304,12 +295,10 @@ run_claude_monitored() {
304
295
  : > "$error_log"
305
296
  fi
306
297
 
307
- if [[ "$threshold_hit" == "true" && -n "$current_session_id" ]]; then
308
- # Restart with --resume and the captured session_id
309
- session_id="$current_session_id"
310
- total_tokens=0
311
- context_window=0
312
- auto_log "Restarting claude -p with --resume session_id=${session_id}"
298
+ if [[ "$threshold_hit" == "true" ]]; then
299
+ # Restart with fresh context the prompt is re-sent but prior work
300
+ # persists in the worktree (committed files, etc.)
301
+ auto_log "Restarting claude -p with fresh context (prior work is in worktree)"
313
302
  continue
314
303
  fi
315
304
 
@@ -608,9 +597,29 @@ run_spikes() {
608
597
  pids+=($!)
609
598
  done
610
599
 
611
- # Wait for all remaining spikes to complete
600
+ # Wait for all remaining spikes with progress heartbeat
612
601
  auto_log "Waiting for all ${#pids[@]} spike(s) to complete..."
613
- wait
602
+ local wait_start=$SECONDS
603
+ while true; do
604
+ local -a still_running=()
605
+ local pid
606
+ for pid in "${pids[@]}"; do
607
+ if kill -0 "$pid" 2>/dev/null; then
608
+ still_running+=("$pid")
609
+ fi
610
+ done
611
+ if [[ ${#still_running[@]} -eq 0 ]]; then
612
+ break
613
+ fi
614
+ local elapsed=$(( SECONDS - wait_start ))
615
+ local mins=$(( elapsed / 60 ))
616
+ local secs=$(( elapsed % 60 ))
617
+ printf "\r ⏳ %d spike(s) running... [%dm%02ds] " "${#still_running[@]}" "$mins" "$secs"
618
+ pids=("${still_running[@]}")
619
+ sleep 5
620
+ done
621
+ printf "\r \r"
622
+ wait 2>/dev/null || true
614
623
  auto_log "All spikes completed for ${spec_name} cycle ${cycle}"
615
624
 
616
625
  # Collect results and process
@@ -788,9 +797,29 @@ Important:
788
797
  impl_slugs+=("$slug")
789
798
  done
790
799
 
791
- # Wait for all implementations to complete
800
+ # Wait for all implementations with progress heartbeat
792
801
  auto_log "Waiting for all ${#pids[@]} implementation(s) to complete..."
793
- wait
802
+ local wait_start=$SECONDS
803
+ while true; do
804
+ local -a still_running=()
805
+ local pid
806
+ for pid in "${pids[@]}"; do
807
+ if kill -0 "$pid" 2>/dev/null; then
808
+ still_running+=("$pid")
809
+ fi
810
+ done
811
+ if [[ ${#still_running[@]} -eq 0 ]]; then
812
+ break
813
+ fi
814
+ local elapsed=$(( SECONDS - wait_start ))
815
+ local mins=$(( elapsed / 60 ))
816
+ local secs=$(( elapsed % 60 ))
817
+ printf "\r ⏳ %d implementation(s) running... [%dm%02ds] " "${#still_running[@]}" "$mins" "$secs"
818
+ pids=("${still_running[@]}")
819
+ sleep 5
820
+ done
821
+ printf "\r \r"
822
+ wait 2>/dev/null || true
794
823
  auto_log "All implementations completed for ${spec_name} cycle ${cycle}"
795
824
 
796
825
  # Collect results
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepflow",
3
- "version": "0.1.63",
3
+ "version": "0.1.65",
4
4
  "description": "Stay in flow state - lightweight spec-driven task orchestration for Claude Code",
5
5
  "keywords": [
6
6
  "claude",