deepflow 0.1.56 → 0.1.58

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.
@@ -184,6 +184,8 @@ run_claude_monitored() {
184
184
 
185
185
  local result_tmp
186
186
  result_tmp="$(mktemp)"
187
+ local error_log
188
+ error_log="$(mktemp)"
187
189
 
188
190
  # Outer loop: may restart with --resume when threshold is hit
189
191
  while true; do
@@ -200,37 +202,22 @@ run_claude_monitored() {
200
202
  local threshold_hit=false
201
203
  local claude_pid=""
202
204
 
203
- # Launch claude -p in background, capture its PID so we can kill it
204
- if [[ -n "$session_id" ]]; then
205
- # When resuming, no prompt is piped
206
- "${cmd_args[@]}" < /dev/null 2>/dev/null &
207
- claude_pid=$!
208
- else
209
- echo "$prompt_text" | "${cmd_args[@]}" 2>/dev/null &
210
- claude_pid=$!
211
- fi
212
-
213
- # Read stdout from the backgrounded process via /dev/fd — we need a pipe.
214
- # Re-architect: use a FIFO so we can read line-by-line while also holding
215
- # the PID for killing.
216
- # Kill the background process we just started (we'll redo with a FIFO).
217
- kill "$claude_pid" 2>/dev/null || true
218
- wait "$claude_pid" 2>/dev/null || true
219
-
205
+ # Use a FIFO so we can read line-by-line while holding the PID for killing
220
206
  local fifo_path
221
207
  fifo_path="$(mktemp -u)"
222
208
  mkfifo "$fifo_path"
223
209
 
224
210
  if [[ -n "$session_id" ]]; then
225
- "${cmd_args[@]}" < /dev/null > "$fifo_path" 2>/dev/null &
211
+ "${cmd_args[@]}" < /dev/null > "$fifo_path" 2>>"$error_log" &
226
212
  claude_pid=$!
227
213
  else
228
- echo "$prompt_text" | "${cmd_args[@]}" > "$fifo_path" 2>/dev/null &
214
+ echo "$prompt_text" | "${cmd_args[@]}" > "$fifo_path" 2>>"$error_log" &
229
215
  claude_pid=$!
230
216
  fi
231
217
 
232
218
  # Read the FIFO line-by-line
233
- while IFS= read -r line; do
219
+ local capturing_result=false
220
+ while IFS= read -r line || [[ -n "$line" ]]; do
234
221
  [[ -z "$line" ]] && continue
235
222
 
236
223
  local parsed
@@ -271,14 +258,13 @@ run_claude_monitored() {
271
258
  context_window="${pline#CONTEXT_WINDOW:}"
272
259
  ;;
273
260
  RESULT_START)
274
- # Next lines until RESULT_END are the result text
275
- local capturing_result=true
261
+ capturing_result=true
276
262
  ;;
277
263
  RESULT_END)
278
264
  capturing_result=false
279
265
  ;;
280
266
  *)
281
- if [[ "${capturing_result:-false}" == "true" ]]; then
267
+ if [[ "$capturing_result" == "true" ]]; then
282
268
  echo "$pline" >> "$result_tmp"
283
269
  fi
284
270
  ;;
@@ -310,6 +296,12 @@ run_claude_monitored() {
310
296
  # Wait for claude process to finish (if it hasn't been killed)
311
297
  wait "$claude_pid" 2>/dev/null || true
312
298
 
299
+ # Log stderr if any
300
+ if [[ -s "$error_log" ]]; then
301
+ auto_log "claude stderr: $(cat "$error_log")"
302
+ : > "$error_log"
303
+ fi
304
+
313
305
  if [[ "$threshold_hit" == "true" && -n "$current_session_id" ]]; then
314
306
  # Restart with --resume and the captured session_id
315
307
  session_id="$current_session_id"
@@ -323,6 +315,8 @@ run_claude_monitored() {
323
315
  break
324
316
  done
325
317
 
318
+ rm -f "$error_log"
319
+
326
320
  # Write final context.json
327
321
  if [[ "$context_window" -gt 0 && "$total_tokens" -gt 0 ]]; then
328
322
  local final_pct=$(( total_tokens * 100 / context_window ))
@@ -466,10 +460,13 @@ run_single_spike() {
466
460
  if [[ -d "$worktree_path" ]]; then
467
461
  auto_log "Worktree already exists at ${worktree_path}, reusing"
468
462
  else
469
- git worktree add -b "$branch_name" "$worktree_path" HEAD 2>/dev/null || {
463
+ local wt_err
464
+ wt_err="$(git worktree add -b "$branch_name" "$worktree_path" HEAD 2>&1)" || {
465
+ auto_log "worktree add -b failed: ${wt_err}"
470
466
  # Branch may already exist from a previous run
471
- git worktree add "$worktree_path" "$branch_name" 2>/dev/null || {
472
- auto_log "ERROR: failed to create worktree for ${slug}"
467
+ wt_err="$(git worktree add "$worktree_path" "$branch_name" 2>&1)" || {
468
+ auto_log "ERROR: failed to create worktree for ${slug}: ${wt_err}"
469
+ echo "Worktree error for ${slug}: ${wt_err}" >&2
473
470
  return 1
474
471
  }
475
472
  }
package/bin/install.js CHANGED
@@ -35,6 +35,23 @@ const GLOBAL_DIR = path.join(os.homedir(), '.claude');
35
35
  const PROJECT_DIR = path.join(process.cwd(), '.claude');
36
36
  const PACKAGE_DIR = path.resolve(__dirname, '..');
37
37
 
38
+ function updateGlobalPackage() {
39
+ const currentVersion = require(path.join(PACKAGE_DIR, 'package.json')).version;
40
+ try {
41
+ const globalPkgPath = execFileSync('node', ['-e',
42
+ "try{console.log(require(require('path').join(require('child_process').execFileSync('npm',['root','-g'],{encoding:'utf8'}).trim(),'deepflow','package.json')).version)}catch(e){console.log('')}"
43
+ ], { encoding: 'utf8' }).trim();
44
+
45
+ if (globalPkgPath && globalPkgPath !== currentVersion) {
46
+ console.log(`Updating global npm package (${globalPkgPath} → ${currentVersion})...`);
47
+ execFileSync('npm', ['install', '-g', `deepflow@${currentVersion}`], { stdio: 'inherit' });
48
+ console.log('');
49
+ }
50
+ } catch (e) {
51
+ // No global installation or npm not available - skip silently
52
+ }
53
+ }
54
+
38
55
  async function main() {
39
56
  // Handle --uninstall flag
40
57
  if (process.argv.includes('--uninstall')) {
@@ -45,6 +62,9 @@ async function main() {
45
62
  console.log(`${c.cyan}deepflow installer${c.reset}`);
46
63
  console.log('');
47
64
 
65
+ // Update global npm package if stale
66
+ updateGlobalPackage();
67
+
48
68
  // Detect existing installations
49
69
  const globalInstalled = isInstalled(GLOBAL_DIR);
50
70
  const projectInstalled = isInstalled(PROJECT_DIR);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "deepflow",
3
- "version": "0.1.56",
3
+ "version": "0.1.58",
4
4
  "description": "Stay in flow state - lightweight spec-driven task orchestration for Claude Code",
5
5
  "keywords": [
6
6
  "claude",