claude-flow 2.5.0-alpha.136 → 2.5.0-alpha.138

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.
@@ -121,15 +121,13 @@ async function setupMcpServers(dryRun1 = false) {
121
121
  }
122
122
  }
123
123
  function createStatuslineScript() {
124
- return `#!/bin/bash
125
-
126
- # Claude Code Status Line with Claude-Flow Integration
127
- # Displays model, directory, git branch, and real-time swarm metrics
124
+ return `
125
+ #!/bin/bash
128
126
 
129
127
  # Read JSON input from stdin
130
128
  INPUT=$(cat)
131
- MODEL=$(echo "$INPUT" | jq -r '.model.display_name // "Claude"')
132
- CWD=$(echo "$INPUT" | jq -r '.workspace.current_dir // .cwd')
129
+ MODEL=$(echo "$INPUT" | jq -r \'.model.display_name // "Claude"\')
130
+ CWD=$(echo "$INPUT" | jq -r \'.workspace.current_dir // .cwd\')
133
131
  DIR=$(basename "$CWD")
134
132
 
135
133
  # Replace claude-code-flow with branded name
@@ -150,10 +148,11 @@ FLOW_DIR="$CWD/.claude-flow"
150
148
  if [ -d "$FLOW_DIR" ]; then
151
149
  echo -ne " │"
152
150
 
153
- # Swarm Configuration & Topology
151
+ # 1. Swarm Configuration & Topology
154
152
  if [ -f "$FLOW_DIR/swarm-config.json" ]; then
155
- STRATEGY=$(jq -r '.defaultStrategy // empty' "$FLOW_DIR/swarm-config.json" 2>/dev/null)
153
+ STRATEGY=$(jq -r \'.defaultStrategy // empty\' "$FLOW_DIR/swarm-config.json" 2>/dev/null)
156
154
  if [ -n "$STRATEGY" ]; then
155
+ # Map strategy to topology icon
157
156
  case "$STRATEGY" in
158
157
  "balanced") TOPO_ICON="⚡mesh" ;;
159
158
  "conservative") TOPO_ICON="⚡hier" ;;
@@ -162,96 +161,139 @@ if [ -d "$FLOW_DIR" ]; then
162
161
  esac
163
162
  echo -ne " \\033[35m$TOPO_ICON\\033[0m"
164
163
 
165
- AGENT_COUNT=$(jq -r '.agentProfiles | length' "$FLOW_DIR/swarm-config.json" 2>/dev/null)
164
+ # Count agent profiles as "configured agents"
165
+ AGENT_COUNT=$(jq -r \'.agentProfiles | length\' "$FLOW_DIR/swarm-config.json" 2>/dev/null)
166
166
  if [ -n "$AGENT_COUNT" ] && [ "$AGENT_COUNT" != "null" ] && [ "$AGENT_COUNT" -gt 0 ]; then
167
167
  echo -ne " \\033[35m🤖 $AGENT_COUNT\\033[0m"
168
168
  fi
169
169
  fi
170
170
  fi
171
171
 
172
- # Real-time System Metrics
172
+ # 2. Real-time System Metrics
173
173
  if [ -f "$FLOW_DIR/metrics/system-metrics.json" ]; then
174
- LATEST=$(jq -r '.[-1]' "$FLOW_DIR/metrics/system-metrics.json" 2>/dev/null)
174
+ # Get latest metrics (last entry in array)
175
+ LATEST=$(jq -r \'.[-1]\' "$FLOW_DIR/metrics/system-metrics.json" 2>/dev/null)
175
176
 
176
177
  if [ -n "$LATEST" ] && [ "$LATEST" != "null" ]; then
177
- MEM_PERCENT=$(echo "$LATEST" | jq -r '.memoryUsagePercent // 0' | awk '{printf "%.0f", $1}')
178
+ # Memory usage
179
+ MEM_PERCENT=$(echo "$LATEST" | jq -r \'.memoryUsagePercent // 0\' | awk \'{printf "%.0f", $1}\')
178
180
  if [ -n "$MEM_PERCENT" ] && [ "$MEM_PERCENT" != "null" ]; then
181
+ # Color-coded memory (green <60%, yellow 60-80%, red >80%)
179
182
  if [ "$MEM_PERCENT" -lt 60 ]; then
180
- MEM_COLOR="\\033[32m"
183
+ MEM_COLOR="\\033[32m" # Green
181
184
  elif [ "$MEM_PERCENT" -lt 80 ]; then
182
- MEM_COLOR="\\033[33m"
185
+ MEM_COLOR="\\033[33m" # Yellow
183
186
  else
184
- MEM_COLOR="\\033[31m"
187
+ MEM_COLOR="\\033[31m" # Red
185
188
  fi
186
- echo -ne " \${MEM_COLOR}💾 \${MEM_PERCENT}%\\033[0m"
189
+ echo -ne " ${MEM_COLOR}💾 ${MEM_PERCENT}%\\033[0m"
187
190
  fi
188
191
 
189
- CPU_LOAD=$(echo "$LATEST" | jq -r '.cpuLoad // 0' | awk '{printf "%.0f", $1 * 100}')
192
+ # CPU load
193
+ CPU_LOAD=$(echo "$LATEST" | jq -r \'.cpuLoad // 0\' | awk \'{printf "%.0f", $1 * 100}\')
190
194
  if [ -n "$CPU_LOAD" ] && [ "$CPU_LOAD" != "null" ]; then
195
+ # Color-coded CPU (green <50%, yellow 50-75%, red >75%)
191
196
  if [ "$CPU_LOAD" -lt 50 ]; then
192
- CPU_COLOR="\\033[32m"
197
+ CPU_COLOR="\\033[32m" # Green
193
198
  elif [ "$CPU_LOAD" -lt 75 ]; then
194
- CPU_COLOR="\\033[33m"
199
+ CPU_COLOR="\\033[33m" # Yellow
195
200
  else
196
- CPU_COLOR="\\033[31m"
201
+ CPU_COLOR="\\033[31m" # Red
197
202
  fi
198
- echo -ne " \${CPU_COLOR}⚙ \${CPU_LOAD}%\\033[0m"
203
+ echo -ne " ${CPU_COLOR}⚙ ${CPU_LOAD}%\\033[0m"
199
204
  fi
200
205
  fi
201
206
  fi
202
207
 
203
- # Performance Metrics
208
+ # 3. Session State
209
+ if [ -f "$FLOW_DIR/session-state.json" ]; then
210
+ SESSION_ID=$(jq -r \'.sessionId // empty\' "$FLOW_DIR/session-state.json" 2>/dev/null)
211
+ ACTIVE=$(jq -r \'.active // false\' "$FLOW_DIR/session-state.json" 2>/dev/null)
212
+
213
+ if [ "$ACTIVE" = "true" ] && [ -n "$SESSION_ID" ]; then
214
+ # Show abbreviated session ID
215
+ SHORT_ID=$(echo "$SESSION_ID" | cut -d\'-\' -f1)
216
+ echo -ne " \\033[34m🔄 $SHORT_ID\\033[0m"
217
+ fi
218
+ fi
219
+
220
+ # 4. Performance Metrics from task-metrics.json
204
221
  if [ -f "$FLOW_DIR/metrics/task-metrics.json" ]; then
205
- METRICS=$(jq -r '
222
+ # Parse task metrics for success rate, avg time, and streak
223
+ METRICS=$(jq -r \'
224
+ # Calculate metrics
206
225
  (map(select(.success == true)) | length) as $successful |
207
226
  (length) as $total |
208
227
  (if $total > 0 then ($successful / $total * 100) else 0 end) as $success_rate |
209
228
  (map(.duration // 0) | add / length) as $avg_duration |
210
- (reverse | reduce .[] as $task (0; if $task.success == true then . + 1 else 0 end)) as $streak |
211
- { success_rate: $success_rate, avg_duration: $avg_duration, streak: $streak, total: $total } | @json
212
- ' "$FLOW_DIR/metrics/task-metrics.json" 2>/dev/null)
229
+ # Calculate streak (consecutive successes from end)
230
+ (reverse |
231
+ reduce .[] as $task (0;
232
+ if $task.success == true then . + 1 else 0 end
233
+ )
234
+ ) as $streak |
235
+ {
236
+ success_rate: $success_rate,
237
+ avg_duration: $avg_duration,
238
+ streak: $streak,
239
+ total: $total
240
+ } | @json
241
+ \' "$FLOW_DIR/metrics/task-metrics.json" 2>/dev/null)
213
242
 
214
243
  if [ -n "$METRICS" ] && [ "$METRICS" != "null" ]; then
215
- SUCCESS_RATE=$(echo "$METRICS" | jq -r '.success_rate // 0' | awk '{printf "%.0f", $1}')
216
- TOTAL_TASKS=$(echo "$METRICS" | jq -r '.total // 0')
244
+ # Success Rate
245
+ SUCCESS_RATE=$(echo "$METRICS" | jq -r \'.success_rate // 0\' | awk \'{printf "%.0f", $1}\')
246
+ TOTAL_TASKS=$(echo "$METRICS" | jq -r \'.total // 0\')
217
247
 
218
248
  if [ -n "$SUCCESS_RATE" ] && [ "$TOTAL_TASKS" -gt 0 ]; then
249
+ # Color-code: Green (>80%), Yellow (60-80%), Red (<60%)
219
250
  if [ "$SUCCESS_RATE" -gt 80 ]; then
220
- SUCCESS_COLOR="\\033[32m"
251
+ SUCCESS_COLOR="\\033[32m" # Green
221
252
  elif [ "$SUCCESS_RATE" -ge 60 ]; then
222
- SUCCESS_COLOR="\\033[33m"
253
+ SUCCESS_COLOR="\\033[33m" # Yellow
223
254
  else
224
- SUCCESS_COLOR="\\033[31m"
255
+ SUCCESS_COLOR="\\033[31m" # Red
225
256
  fi
226
- echo -ne " \${SUCCESS_COLOR}🎯 \${SUCCESS_RATE}%\\033[0m"
257
+ echo -ne " ${SUCCESS_COLOR}🎯 ${SUCCESS_RATE}%\\033[0m"
227
258
  fi
228
259
 
229
- AVG_TIME=$(echo "$METRICS" | jq -r '.avg_duration // 0')
260
+ # Average Time
261
+ AVG_TIME=$(echo "$METRICS" | jq -r \'.avg_duration // 0\')
230
262
  if [ -n "$AVG_TIME" ] && [ "$TOTAL_TASKS" -gt 0 ]; then
263
+ # Format smartly: seconds, minutes, or hours
231
264
  if [ $(echo "$AVG_TIME < 60" | bc -l 2>/dev/null || echo 0) -eq 1 ]; then
232
- TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fs", $1}')
265
+ TIME_STR=$(echo "$AVG_TIME" | awk \'{printf "%.1fs", $1}\')
233
266
  elif [ $(echo "$AVG_TIME < 3600" | bc -l 2>/dev/null || echo 0) -eq 1 ]; then
234
- TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fm", $1/60}')
267
+ TIME_STR=$(echo "$AVG_TIME" | awk \'{printf "%.1fm", $1/60}\')
235
268
  else
236
- TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fh", $1/3600}')
269
+ TIME_STR=$(echo "$AVG_TIME" | awk \'{printf "%.1fh", $1/3600}\')
237
270
  fi
238
271
  echo -ne " \\033[36m⏱️ $TIME_STR\\033[0m"
239
272
  fi
240
273
 
241
- STREAK=$(echo "$METRICS" | jq -r '.streak // 0')
274
+ # Streak (only show if > 0)
275
+ STREAK=$(echo "$METRICS" | jq -r \'.streak // 0\')
242
276
  if [ -n "$STREAK" ] && [ "$STREAK" -gt 0 ]; then
243
277
  echo -ne " \\033[91m🔥 $STREAK\\033[0m"
244
278
  fi
245
279
  fi
246
280
  fi
247
281
 
248
- # Active Tasks
282
+ # 5. Active Tasks (check for task files)
249
283
  if [ -d "$FLOW_DIR/tasks" ]; then
250
284
  TASK_COUNT=$(find "$FLOW_DIR/tasks" -name "*.json" -type f 2>/dev/null | wc -l)
251
285
  if [ "$TASK_COUNT" -gt 0 ]; then
252
286
  echo -ne " \\033[36m📋 $TASK_COUNT\\033[0m"
253
287
  fi
254
288
  fi
289
+
290
+ # 6. Check for hooks activity
291
+ if [ -f "$FLOW_DIR/hooks-state.json" ]; then
292
+ HOOKS_ACTIVE=$(jq -r \'.enabled // false\' "$FLOW_DIR/hooks-state.json" 2>/dev/null)
293
+ if [ "$HOOKS_ACTIVE" = "true" ]; then
294
+ echo -ne " \\033[35m🔗\\033[0m"
295
+ fi
296
+ fi
255
297
  fi
256
298
 
257
299
  echo