prizmkit 1.1.90 → 1.1.91

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.
@@ -1,5 +1,5 @@
1
1
  {
2
- "frameworkVersion": "1.1.90",
3
- "bundledAt": "2026-07-01T16:16:33.956Z",
4
- "bundledFrom": "917deef"
2
+ "frameworkVersion": "1.1.91",
3
+ "bundledAt": "2026-07-01T17:51:47.362Z",
4
+ "bundledFrom": "5dcb047"
5
5
  }
@@ -43,6 +43,8 @@ start_heartbeat() {
43
43
  local prev_size=0
44
44
  local prev_max_size=0
45
45
  local prev_child_activity_signature=""
46
+ local prev_progress_signature=""
47
+ local prev_error_loop_signature=""
46
48
  local stale_seconds=0
47
49
  while kill -0 "$cli_pid" 2>/dev/null; do
48
50
  sleep "$heartbeat_interval"
@@ -77,9 +79,10 @@ start_heartbeat() {
77
79
  local child_activity_signature=""
78
80
  local child_total_bytes=0
79
81
  local child_session_count=0
82
+ local progress_signature=""
80
83
  if [[ -f "$progress_json" ]]; then
81
- local child_activity_data
82
- child_activity_data=$(python3 - "$progress_json" <<'PY' 2>/dev/null || true
84
+ local progress_activity_data
85
+ progress_activity_data=$(python3 - "$progress_json" <<'PY' 2>/dev/null || true
83
86
  import json
84
87
  import sys
85
88
 
@@ -89,14 +92,31 @@ try:
89
92
  except Exception:
90
93
  sys.exit(0)
91
94
 
92
- signature = str(progress.get("child_activity_signature") or "")
95
+ child_signature = str(progress.get("child_activity_signature") or "")
93
96
  total_bytes = int(progress.get("child_total_bytes") or 0)
94
97
  session_count = len(progress.get("child_session_files") or [])
95
- print(f"{signature}\t{total_bytes}\t{session_count}")
98
+ progress_signature = json.dumps(
99
+ [
100
+ progress.get("current_phase") or "",
101
+ progress.get("current_tool") or "",
102
+ int(progress.get("message_count") or 0),
103
+ int(progress.get("total_tool_calls") or 0),
104
+ int(progress.get("active_subagent_count") or 0),
105
+ int(progress.get("subagent_spawn_count") or 0),
106
+ child_signature,
107
+ total_bytes,
108
+ session_count,
109
+ progress.get("fatal_error_code") or "",
110
+ progress.get("terminal_result_text") or "",
111
+ ],
112
+ separators=(",", ":"),
113
+ )
114
+ sep = "\x1f"
115
+ print(sep.join([child_signature, str(total_bytes), str(session_count), progress_signature]))
96
116
  PY
97
117
  )
98
- if [[ -n "$child_activity_data" ]]; then
99
- IFS=$'\t' read -r child_activity_signature child_total_bytes child_session_count <<< "$child_activity_data"
118
+ if [[ -n "$progress_activity_data" ]]; then
119
+ IFS=$'\037' read -r child_activity_signature child_total_bytes child_session_count progress_signature <<< "$progress_activity_data"
100
120
  fi
101
121
  fi
102
122
 
@@ -106,6 +126,12 @@ PY
106
126
  fi
107
127
  prev_child_activity_signature="$child_activity_signature"
108
128
 
129
+ local progress_advanced=0
130
+ if [[ -n "$progress_signature" && "$progress_signature" != "$prev_progress_signature" ]]; then
131
+ progress_advanced=1
132
+ fi
133
+ prev_progress_signature="$progress_signature"
134
+
109
135
  local effective_stale_kill_threshold="$stale_kill_threshold"
110
136
  if [[ $stale_kill_threshold -gt 0 && -f "$progress_json" ]]; then
111
137
  local extended_threshold
@@ -172,8 +198,11 @@ PY
172
198
 
173
199
  # Check for error-loop: agent is actively producing output but results are
174
200
  # all read-offset errors or wasted calls. This is a stuck agent that appears
175
- # "active" by log growth but is accomplishing nothing.
201
+ # "active" by log growth but is accomplishing nothing. Only a newly advancing
202
+ # error signature counts; stale historical errors must not turn later normal
203
+ # output into a stale kill.
176
204
  local error_loop_detected=false
205
+ local error_loop_signature=""
177
206
  if [[ $effective_stale_kill_threshold -gt 0 && $growth -gt 0 && -f "$progress_json" ]]; then
178
207
  local error_loop_flag
179
208
  error_loop_flag=$(python3 - "$progress_json" <<'PY' 2>/dev/null || true
@@ -187,33 +216,38 @@ errors = progress.get("errors", [])
187
216
  if isinstance(errors, list) and len(errors) >= 5:
188
217
  recent = errors[-5:]
189
218
  if all(isinstance(e, dict) and e.get("type") in ("read_offset_overflow", "wasted_call") for e in recent):
190
- print("error_loop")
219
+ print(json.dumps(recent, sort_keys=True, separators=(",", ":")))
191
220
  PY
192
221
  )
193
- if [[ "$error_loop_flag" == "error_loop" ]]; then
194
- error_loop_detected=true
222
+ if [[ -n "$error_loop_flag" ]]; then
223
+ error_loop_signature="$error_loop_flag"
224
+ if [[ -n "$prev_error_loop_signature" && "$error_loop_signature" != "$prev_error_loop_signature" ]]; then
225
+ error_loop_detected=true
226
+ fi
195
227
  fi
196
228
  fi
229
+ prev_error_loop_signature="$error_loop_signature"
197
230
 
198
231
  # Track progress staleness. Parent sessions can sit in a wait/polling
199
- # tool while child transcripts keep growing, so child activity counts.
200
- # Error loops bypass normal growth-as-progress because the log is only
201
- # growing with repeated failed reads or wasted calls.
232
+ # tool while child transcripts or structured progress counters keep
233
+ # advancing, so both child activity and progress.json state changes
234
+ # count as progress. Error loops bypass normal growth-as-progress
235
+ # because the log is only growing with repeated failed reads or wasted
236
+ # calls.
202
237
  #
203
238
  # When the main session log has been truncated (e.g. by subagent stdout
204
- # redirection severing the file descriptor), use child activity as the
205
- # primary progress signal — the parent process is still running and children
206
- # are still producing output, so this is not a true stall.
239
+ # redirection severing the file descriptor), use structured progress and
240
+ # child activity as the primary progress signals — the parent process is
241
+ # still running and children may still be producing output.
207
242
  if [[ "$error_loop_detected" == "true" ]]; then
208
243
  stale_seconds=$effective_stale_kill_threshold
209
244
  elif [[ "$log_truncated" == "true" ]]; then
210
- # Log truncated: rely on child growth and CLI process liveness.
211
- # Don't increment staleness — the process is still working.
212
- if [[ $child_growth -gt 0 ]]; then
245
+ if [[ $progress_advanced -gt 0 || $child_growth -gt 0 ]]; then
213
246
  stale_seconds=0
247
+ else
248
+ stale_seconds=$((stale_seconds + heartbeat_interval))
214
249
  fi
215
- # If neither log nor children grow, this is a real stall
216
- elif [[ $growth -le 0 && $child_growth -eq 0 ]]; then
250
+ elif [[ $growth -le 0 && $child_growth -eq 0 && $progress_advanced -eq 0 ]]; then
217
251
  stale_seconds=$((stale_seconds + heartbeat_interval))
218
252
  else
219
253
  stale_seconds=0
@@ -251,7 +285,7 @@ PY
251
285
  local status_icon
252
286
  if $log_truncated; then
253
287
  status_icon="${RED}⚠${NC}"
254
- elif [[ $growth -gt 0 || $child_growth -gt 0 ]]; then
288
+ elif [[ $growth -gt 0 || $child_growth -gt 0 || $progress_advanced -gt 0 ]]; then
255
289
  status_icon="${GREEN}▶${NC}"
256
290
  else
257
291
  status_icon="${YELLOW}⏸${NC}"
@@ -467,13 +467,14 @@ function Get-PrizmEffectiveStaleKillThreshold {
467
467
  return [Math]::Max($BaseThreshold * 4, 3600)
468
468
  }
469
469
 
470
- function Get-PrizmProgressChildActivity {
470
+ function Get-PrizmProgressActivity {
471
471
  param([string]$ProgressFile)
472
472
 
473
473
  $empty = [pscustomobject]@{
474
- Signature = ''
475
- TotalBytes = 0
476
- SessionCount = 0
474
+ ChildSignature = ''
475
+ ChildTotalBytes = 0
476
+ ChildSessionCount = 0
477
+ ProgressSignature = ''
477
478
  }
478
479
  if (-not (Test-Path $ProgressFile)) { return $empty }
479
480
 
@@ -483,25 +484,72 @@ function Get-PrizmProgressChildActivity {
483
484
  return $empty
484
485
  }
485
486
 
486
- $signature = ''
487
+ $childSignature = ''
487
488
  if ($progress.PSObject.Properties['child_activity_signature'] -and $progress.child_activity_signature) {
488
- $signature = [string]$progress.child_activity_signature
489
+ $childSignature = [string]$progress.child_activity_signature
489
490
  }
490
491
 
491
- $totalBytes = [int64]0
492
+ $childTotalBytes = [int64]0
492
493
  if ($progress.PSObject.Properties['child_total_bytes']) {
493
- [int64]::TryParse([string]$progress.child_total_bytes, [ref]$totalBytes) | Out-Null
494
+ [int64]::TryParse([string]$progress.child_total_bytes, [ref]$childTotalBytes) | Out-Null
494
495
  }
495
496
 
496
- $sessionCount = 0
497
+ $childSessionCount = 0
497
498
  if ($progress.PSObject.Properties['child_session_files'] -and $progress.child_session_files) {
498
- $sessionCount = @($progress.child_session_files).Count
499
+ $childSessionCount = @($progress.child_session_files).Count
500
+ }
501
+
502
+ $messageCount = 0
503
+ if ($progress.PSObject.Properties['message_count']) {
504
+ [int]::TryParse([string]$progress.message_count, [ref]$messageCount) | Out-Null
505
+ }
506
+ $totalToolCalls = 0
507
+ if ($progress.PSObject.Properties['total_tool_calls']) {
508
+ [int]::TryParse([string]$progress.total_tool_calls, [ref]$totalToolCalls) | Out-Null
509
+ }
510
+ $activeSubagentCount = 0
511
+ if ($progress.PSObject.Properties['active_subagent_count']) {
512
+ [int]::TryParse([string]$progress.active_subagent_count, [ref]$activeSubagentCount) | Out-Null
513
+ }
514
+ $subagentSpawnCount = 0
515
+ if ($progress.PSObject.Properties['subagent_spawn_count']) {
516
+ [int]::TryParse([string]$progress.subagent_spawn_count, [ref]$subagentSpawnCount) | Out-Null
517
+ }
518
+ $currentPhase = if ($progress.PSObject.Properties['current_phase'] -and $progress.current_phase) { [string]$progress.current_phase } else { '' }
519
+ $currentTool = if ($progress.PSObject.Properties['current_tool'] -and $progress.current_tool) { [string]$progress.current_tool } else { '' }
520
+ $fatalErrorCode = if ($progress.PSObject.Properties['fatal_error_code'] -and $progress.fatal_error_code) { [string]$progress.fatal_error_code } else { '' }
521
+ $terminalResultText = if ($progress.PSObject.Properties['terminal_result_text'] -and $progress.terminal_result_text) { [string]$progress.terminal_result_text } else { '' }
522
+
523
+ $progressSignature = @(
524
+ $currentPhase,
525
+ $currentTool,
526
+ $messageCount,
527
+ $totalToolCalls,
528
+ $activeSubagentCount,
529
+ $subagentSpawnCount,
530
+ $childSignature,
531
+ $childTotalBytes,
532
+ $childSessionCount,
533
+ $fatalErrorCode,
534
+ $terminalResultText
535
+ ) | ConvertTo-Json -Compress
536
+
537
+ return [pscustomobject]@{
538
+ ChildSignature = $childSignature
539
+ ChildTotalBytes = $childTotalBytes
540
+ ChildSessionCount = $childSessionCount
541
+ ProgressSignature = $progressSignature
499
542
  }
543
+ }
544
+
545
+ function Get-PrizmProgressChildActivity {
546
+ param([string]$ProgressFile)
500
547
 
548
+ $activity = Get-PrizmProgressActivity -ProgressFile $ProgressFile
501
549
  return [pscustomobject]@{
502
- Signature = $signature
503
- TotalBytes = $totalBytes
504
- SessionCount = $sessionCount
550
+ Signature = $activity.ChildSignature
551
+ TotalBytes = $activity.ChildTotalBytes
552
+ SessionCount = $activity.ChildSessionCount
505
553
  }
506
554
  }
507
555
 
@@ -740,7 +740,9 @@ function Invoke-PrizmPipeline {
740
740
  $elapsedSeconds = 0
741
741
  $staleSeconds = 0
742
742
  $previousLogSize = 0
743
+ $previousProgressSignature = ''
743
744
  $previousChildActivitySignature = ''
745
+ $previousErrorLoopSignature = ''
744
746
  $wasTimedOut = $false
745
747
  $staleKillMarker = Join-Path $logsDir 'stale-kill.json'
746
748
  $wasStaleKilled = $false
@@ -758,16 +760,22 @@ function Invoke-PrizmPipeline {
758
760
  $growth = $currentLogSize - $previousLogSize
759
761
  $previousLogSize = $currentLogSize
760
762
 
761
- $childActivity = Get-PrizmProgressChildActivity -ProgressFile $progressJson
762
- $childSignature = [string]$childActivity.Signature
763
+ $progressActivity = Get-PrizmProgressActivity -ProgressFile $progressJson
764
+ $progressSignature = [string]$progressActivity.ProgressSignature
765
+ $progressAdvanced = ($progressSignature -and $progressSignature -ne $previousProgressSignature)
766
+ $previousProgressSignature = $progressSignature
767
+ $childSignature = [string]$progressActivity.ChildSignature
763
768
  $childAdvanced = ($childSignature -and $childSignature -ne $previousChildActivitySignature)
764
769
  $previousChildActivitySignature = $childSignature
765
770
 
766
771
  $effectiveStaleKillThreshold = Get-PrizmEffectiveStaleKillThreshold -ProgressFile $progressJson -BaseThreshold $staleKillThreshold
767
772
 
768
773
  # Check for error-loop: agent is actively producing output but results are
769
- # all read-offset errors or wasted calls.
774
+ # all read-offset errors or wasted calls. Only a newly advancing error
775
+ # signature counts; stale historical errors must not turn later normal output
776
+ # into a stale kill.
770
777
  $errorLoopDetected = $false
778
+ $errorLoopSignature = ''
771
779
  if ($effectiveStaleKillThreshold -gt 0 -and $growth -gt 0 -and (Test-Path $progressJson)) {
772
780
  try {
773
781
  $progress = Get-Content $progressJson -Raw | ConvertFrom-Json
@@ -778,17 +786,21 @@ function Invoke-PrizmPipeline {
778
786
  $_.type -in @("read_offset_overflow", "wasted_call")
779
787
  }).Count -eq 5
780
788
  if ($allBad) {
781
- $errorLoopDetected = $true
789
+ $errorLoopSignature = ($recent | ConvertTo-Json -Compress)
790
+ if ($previousErrorLoopSignature -and $errorLoopSignature -ne $previousErrorLoopSignature) {
791
+ $errorLoopDetected = $true
792
+ }
782
793
  }
783
794
  }
784
795
  } catch {
785
796
  # Ignore JSON parse errors — progress file may be incomplete or malformed
786
797
  }
787
798
  }
799
+ $previousErrorLoopSignature = $errorLoopSignature
788
800
 
789
801
  if ($errorLoopDetected) {
790
802
  $staleSeconds = $effectiveStaleKillThreshold
791
- } elseif ($growth -gt 0 -or $childAdvanced) {
803
+ } elseif ($growth -gt 0 -or $childAdvanced -or $progressAdvanced) {
792
804
  $staleSeconds = 0
793
805
  } else {
794
806
  $staleSeconds += $waitSeconds
@@ -121,6 +121,7 @@ $job = Start-Job -ScriptBlock {
121
121
  $elapsedSeconds = 0
122
122
  $staleSeconds = 0
123
123
  $previousLogSize = 0
124
+ $previousProgressSignature = ''
124
125
  $previousChildActivitySignature = ''
125
126
  $wasTimedOut = $false
126
127
  $wasStaleKilled = $false
@@ -136,12 +137,15 @@ while ($true) {
136
137
  $growth = $currentLogSize - $previousLogSize
137
138
  $previousLogSize = $currentLogSize
138
139
 
139
- $childActivity = Get-PrizmProgressChildActivity -ProgressFile $progressPath
140
- $childSignature = [string]$childActivity.Signature
140
+ $progressActivity = Get-PrizmProgressActivity -ProgressFile $progressPath
141
+ $progressSignature = [string]$progressActivity.ProgressSignature
142
+ $progressAdvanced = ($progressSignature -and $progressSignature -ne $previousProgressSignature)
143
+ $previousProgressSignature = $progressSignature
144
+ $childSignature = [string]$progressActivity.ChildSignature
141
145
  $childAdvanced = ($childSignature -and $childSignature -ne $previousChildActivitySignature)
142
146
  $previousChildActivitySignature = $childSignature
143
147
 
144
- if ($growth -gt 0 -or $childAdvanced) { $staleSeconds = 0 } else { $staleSeconds += $waitSeconds }
148
+ if ($growth -gt 0 -or $childAdvanced -or $progressAdvanced) { $staleSeconds = 0 } else { $staleSeconds += $waitSeconds }
145
149
 
146
150
  if ($timeoutSeconds -gt 0 -and $elapsedSeconds -ge $timeoutSeconds) {
147
151
  $wasTimedOut = $true
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.1.90",
2
+ "version": "1.1.91",
3
3
  "skills": {
4
4
  "prizm-kit": {
5
5
  "description": "Full-lifecycle dev toolkit. Covers spec-driven development, Prizm context docs, code quality, debugging, deployment, and knowledge management.",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "prizmkit",
3
- "version": "1.1.90",
3
+ "version": "1.1.91",
4
4
  "description": "Create a new PrizmKit-powered project with clean initialization — no framework dev files, just what you need.",
5
5
  "type": "module",
6
6
  "bin": {