claude-flow 2.5.0-alpha.135 → 2.5.0-alpha.137
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/.claude/settings.json +1 -1
- package/bin/claude-flow +1 -1
- package/dist/src/cli/help-formatter.js +5 -0
- package/dist/src/cli/simple-commands/init/index.js +89 -40
- package/dist/src/cli/simple-commands/init/index.js.map +1 -1
- package/dist/src/utils/metrics-reader.js +37 -39
- package/dist/src/utils/metrics-reader.js.map +1 -1
- package/package.json +1 -1
- package/src/cli/simple-commands/init/index.js +91 -40
package/.claude/settings.json
CHANGED
package/bin/claude-flow
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { printSuccess, printError, printWarning } from '../../utils.js';
|
|
2
2
|
import { existsSync } from 'fs';
|
|
3
3
|
import process from 'process';
|
|
4
|
+
import os from 'os';
|
|
4
5
|
import { spawn, execSync } from 'child_process';
|
|
5
6
|
function runCommand(command, args, options = {}) {
|
|
6
7
|
return new Promise((resolve, reject)=>{
|
|
@@ -120,15 +121,13 @@ async function setupMcpServers(dryRun1 = false) {
|
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
function createStatuslineScript() {
|
|
123
|
-
return
|
|
124
|
-
|
|
125
|
-
# Claude Code Status Line with Claude-Flow Integration
|
|
126
|
-
# Displays model, directory, git branch, and real-time swarm metrics
|
|
124
|
+
return `
|
|
125
|
+
#!/bin/bash
|
|
127
126
|
|
|
128
127
|
# Read JSON input from stdin
|
|
129
128
|
INPUT=$(cat)
|
|
130
|
-
MODEL=$(echo "$INPUT" | jq -r '.model.display_name // "Claude"')
|
|
131
|
-
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\')
|
|
132
131
|
DIR=$(basename "$CWD")
|
|
133
132
|
|
|
134
133
|
# Replace claude-code-flow with branded name
|
|
@@ -149,10 +148,11 @@ FLOW_DIR="$CWD/.claude-flow"
|
|
|
149
148
|
if [ -d "$FLOW_DIR" ]; then
|
|
150
149
|
echo -ne " │"
|
|
151
150
|
|
|
152
|
-
# Swarm Configuration & Topology
|
|
151
|
+
# 1. Swarm Configuration & Topology
|
|
153
152
|
if [ -f "$FLOW_DIR/swarm-config.json" ]; then
|
|
154
|
-
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)
|
|
155
154
|
if [ -n "$STRATEGY" ]; then
|
|
155
|
+
# Map strategy to topology icon
|
|
156
156
|
case "$STRATEGY" in
|
|
157
157
|
"balanced") TOPO_ICON="⚡mesh" ;;
|
|
158
158
|
"conservative") TOPO_ICON="⚡hier" ;;
|
|
@@ -161,96 +161,139 @@ if [ -d "$FLOW_DIR" ]; then
|
|
|
161
161
|
esac
|
|
162
162
|
echo -ne " \\033[35m$TOPO_ICON\\033[0m"
|
|
163
163
|
|
|
164
|
-
|
|
164
|
+
# Count agent profiles as "configured agents"
|
|
165
|
+
AGENT_COUNT=$(jq -r \'.agentProfiles | length\' "$FLOW_DIR/swarm-config.json" 2>/dev/null)
|
|
165
166
|
if [ -n "$AGENT_COUNT" ] && [ "$AGENT_COUNT" != "null" ] && [ "$AGENT_COUNT" -gt 0 ]; then
|
|
166
167
|
echo -ne " \\033[35m🤖 $AGENT_COUNT\\033[0m"
|
|
167
168
|
fi
|
|
168
169
|
fi
|
|
169
170
|
fi
|
|
170
171
|
|
|
171
|
-
# Real-time System Metrics
|
|
172
|
+
# 2. Real-time System Metrics
|
|
172
173
|
if [ -f "$FLOW_DIR/metrics/system-metrics.json" ]; then
|
|
173
|
-
|
|
174
|
+
# Get latest metrics (last entry in array)
|
|
175
|
+
LATEST=$(jq -r \'.[-1]\' "$FLOW_DIR/metrics/system-metrics.json" 2>/dev/null)
|
|
174
176
|
|
|
175
177
|
if [ -n "$LATEST" ] && [ "$LATEST" != "null" ]; then
|
|
176
|
-
|
|
178
|
+
# Memory usage
|
|
179
|
+
MEM_PERCENT=$(echo "$LATEST" | jq -r \'.memoryUsagePercent // 0\' | awk \'{printf "%.0f", $1}\')
|
|
177
180
|
if [ -n "$MEM_PERCENT" ] && [ "$MEM_PERCENT" != "null" ]; then
|
|
181
|
+
# Color-coded memory (green <60%, yellow 60-80%, red >80%)
|
|
178
182
|
if [ "$MEM_PERCENT" -lt 60 ]; then
|
|
179
|
-
MEM_COLOR="\\033[32m"
|
|
183
|
+
MEM_COLOR="\\033[32m" # Green
|
|
180
184
|
elif [ "$MEM_PERCENT" -lt 80 ]; then
|
|
181
|
-
MEM_COLOR="\\033[33m"
|
|
185
|
+
MEM_COLOR="\\033[33m" # Yellow
|
|
182
186
|
else
|
|
183
|
-
MEM_COLOR="\\033[31m"
|
|
187
|
+
MEM_COLOR="\\033[31m" # Red
|
|
184
188
|
fi
|
|
185
|
-
echo -ne "
|
|
189
|
+
echo -ne " ${MEM_COLOR}💾 ${MEM_PERCENT}%\\033[0m"
|
|
186
190
|
fi
|
|
187
191
|
|
|
188
|
-
|
|
192
|
+
# CPU load
|
|
193
|
+
CPU_LOAD=$(echo "$LATEST" | jq -r \'.cpuLoad // 0\' | awk \'{printf "%.0f", $1 * 100}\')
|
|
189
194
|
if [ -n "$CPU_LOAD" ] && [ "$CPU_LOAD" != "null" ]; then
|
|
195
|
+
# Color-coded CPU (green <50%, yellow 50-75%, red >75%)
|
|
190
196
|
if [ "$CPU_LOAD" -lt 50 ]; then
|
|
191
|
-
CPU_COLOR="\\033[32m"
|
|
197
|
+
CPU_COLOR="\\033[32m" # Green
|
|
192
198
|
elif [ "$CPU_LOAD" -lt 75 ]; then
|
|
193
|
-
CPU_COLOR="\\033[33m"
|
|
199
|
+
CPU_COLOR="\\033[33m" # Yellow
|
|
194
200
|
else
|
|
195
|
-
CPU_COLOR="\\033[31m"
|
|
201
|
+
CPU_COLOR="\\033[31m" # Red
|
|
196
202
|
fi
|
|
197
|
-
echo -ne "
|
|
203
|
+
echo -ne " ${CPU_COLOR}⚙ ${CPU_LOAD}%\\033[0m"
|
|
198
204
|
fi
|
|
199
205
|
fi
|
|
200
206
|
fi
|
|
201
207
|
|
|
202
|
-
#
|
|
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
|
|
203
221
|
if [ -f "$FLOW_DIR/metrics/task-metrics.json" ]; then
|
|
204
|
-
|
|
222
|
+
# Parse task metrics for success rate, avg time, and streak
|
|
223
|
+
METRICS=$(jq -r \'
|
|
224
|
+
# Calculate metrics
|
|
205
225
|
(map(select(.success == true)) | length) as $successful |
|
|
206
226
|
(length) as $total |
|
|
207
227
|
(if $total > 0 then ($successful / $total * 100) else 0 end) as $success_rate |
|
|
208
228
|
(map(.duration // 0) | add / length) as $avg_duration |
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
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)
|
|
212
242
|
|
|
213
243
|
if [ -n "$METRICS" ] && [ "$METRICS" != "null" ]; then
|
|
214
|
-
|
|
215
|
-
|
|
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\')
|
|
216
247
|
|
|
217
248
|
if [ -n "$SUCCESS_RATE" ] && [ "$TOTAL_TASKS" -gt 0 ]; then
|
|
249
|
+
# Color-code: Green (>80%), Yellow (60-80%), Red (<60%)
|
|
218
250
|
if [ "$SUCCESS_RATE" -gt 80 ]; then
|
|
219
|
-
SUCCESS_COLOR="\\033[32m"
|
|
251
|
+
SUCCESS_COLOR="\\033[32m" # Green
|
|
220
252
|
elif [ "$SUCCESS_RATE" -ge 60 ]; then
|
|
221
|
-
SUCCESS_COLOR="\\033[33m"
|
|
253
|
+
SUCCESS_COLOR="\\033[33m" # Yellow
|
|
222
254
|
else
|
|
223
|
-
SUCCESS_COLOR="\\033[31m"
|
|
255
|
+
SUCCESS_COLOR="\\033[31m" # Red
|
|
224
256
|
fi
|
|
225
|
-
echo -ne "
|
|
257
|
+
echo -ne " ${SUCCESS_COLOR}🎯 ${SUCCESS_RATE}%\\033[0m"
|
|
226
258
|
fi
|
|
227
259
|
|
|
228
|
-
|
|
260
|
+
# Average Time
|
|
261
|
+
AVG_TIME=$(echo "$METRICS" | jq -r \'.avg_duration // 0\')
|
|
229
262
|
if [ -n "$AVG_TIME" ] && [ "$TOTAL_TASKS" -gt 0 ]; then
|
|
263
|
+
# Format smartly: seconds, minutes, or hours
|
|
230
264
|
if [ $(echo "$AVG_TIME < 60" | bc -l 2>/dev/null || echo 0) -eq 1 ]; then
|
|
231
|
-
TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fs", $1}')
|
|
265
|
+
TIME_STR=$(echo "$AVG_TIME" | awk \'{printf "%.1fs", $1}\')
|
|
232
266
|
elif [ $(echo "$AVG_TIME < 3600" | bc -l 2>/dev/null || echo 0) -eq 1 ]; then
|
|
233
|
-
TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fm", $1/60}')
|
|
267
|
+
TIME_STR=$(echo "$AVG_TIME" | awk \'{printf "%.1fm", $1/60}\')
|
|
234
268
|
else
|
|
235
|
-
TIME_STR=$(echo "$AVG_TIME" | awk '{printf "%.1fh", $1/3600}')
|
|
269
|
+
TIME_STR=$(echo "$AVG_TIME" | awk \'{printf "%.1fh", $1/3600}\')
|
|
236
270
|
fi
|
|
237
271
|
echo -ne " \\033[36m⏱️ $TIME_STR\\033[0m"
|
|
238
272
|
fi
|
|
239
273
|
|
|
240
|
-
|
|
274
|
+
# Streak (only show if > 0)
|
|
275
|
+
STREAK=$(echo "$METRICS" | jq -r \'.streak // 0\')
|
|
241
276
|
if [ -n "$STREAK" ] && [ "$STREAK" -gt 0 ]; then
|
|
242
277
|
echo -ne " \\033[91m🔥 $STREAK\\033[0m"
|
|
243
278
|
fi
|
|
244
279
|
fi
|
|
245
280
|
fi
|
|
246
281
|
|
|
247
|
-
# Active Tasks
|
|
282
|
+
# 5. Active Tasks (check for task files)
|
|
248
283
|
if [ -d "$FLOW_DIR/tasks" ]; then
|
|
249
284
|
TASK_COUNT=$(find "$FLOW_DIR/tasks" -name "*.json" -type f 2>/dev/null | wc -l)
|
|
250
285
|
if [ "$TASK_COUNT" -gt 0 ]; then
|
|
251
286
|
echo -ne " \\033[36m📋 $TASK_COUNT\\033[0m"
|
|
252
287
|
fi
|
|
253
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
|
|
254
297
|
fi
|
|
255
298
|
|
|
256
299
|
echo
|
|
@@ -1049,9 +1092,15 @@ async function enhancedClaudeFlowInit(flags, subArgs = []) {
|
|
|
1049
1092
|
if (!dryRun1) {
|
|
1050
1093
|
await fs.writeFile(`${claudeDir}/statusline-command.sh`, statuslineTemplate, 'utf8');
|
|
1051
1094
|
await fs.chmod(`${claudeDir}/statusline-command.sh`, 0o755);
|
|
1052
|
-
|
|
1095
|
+
const homeClaudeDir = path.join(os.homedir(), '.claude');
|
|
1096
|
+
await fs.mkdir(homeClaudeDir, {
|
|
1097
|
+
recursive: true
|
|
1098
|
+
});
|
|
1099
|
+
await fs.writeFile(path.join(homeClaudeDir, 'statusline-command.sh'), statuslineTemplate, 'utf8');
|
|
1100
|
+
await fs.chmod(path.join(homeClaudeDir, 'statusline-command.sh'), 0o755);
|
|
1101
|
+
printSuccess('✓ Created statusline-command.sh in both .claude/ and ~/.claude/');
|
|
1053
1102
|
} else {
|
|
1054
|
-
console.log('[DRY RUN] Would create .claude/statusline-command.sh');
|
|
1103
|
+
console.log('[DRY RUN] Would create .claude/statusline-command.sh and ~/.claude/statusline-command.sh');
|
|
1055
1104
|
}
|
|
1056
1105
|
} catch (err) {
|
|
1057
1106
|
if (!dryRun1) {
|