claude-flow-novice 2.13.0 → 2.14.1
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/commands/cfn/README.md +177 -129
- package/.claude/commands/cfn/cfn-loop-cli.md +279 -0
- package/.claude/commands/cfn/cfn-loop-document.md +20 -1
- package/.claude/commands/cfn/cfn-loop-frontend.md +17 -2
- package/.claude/commands/cfn/cfn-loop-task.md +460 -0
- package/.claude/commands/cfn/context-curate.md +27 -38
- package/.claude/commands/cfn/context-inject.md +14 -25
- package/.claude/commands/cfn/context-query.md +40 -45
- package/.claude/commands/cfn/context-reflect.md +40 -38
- package/.claude/commands/cfn/context-stats.md +13 -38
- package/.claude/commands/cfn/launch-web-dashboard.md +0 -295
- package/.claude/commands/cfn/list-agents-rebuild.md +18 -18
- package/.claude/commands/cfn/write-plan.md +246 -75
- package/.claude/root-claude-distribute/CFN-CLAUDE.md +126 -233
- package/.claude/skills/cfn-backlog-management/add-backlog-item.sh +25 -27
- package/.claude/skills/cfn-changelog-management/add-changelog-entry.sh +21 -19
- package/.claude/skills/cfn-changelog-management/bulk-import.sh +268 -0
- package/.claude/skills/cfn-changelog-management/lib/README.md +212 -0
- package/.claude/skills/cfn-changelog-management/lib/validation.sh +72 -0
- package/.claude/skills/cfn-product-owner-decision/execute-decision.sh +36 -11
- package/claude-assets/agents/cfn-dev-team/analysts/root-cause-analyst.md +259 -0
- package/claude-assets/agents/cfn-dev-team/reviewers/reviewer.md +45 -6
- package/claude-assets/agents/cfn-dev-team/testers/tester.md +59 -0
- package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +4 -4
- package/claude-assets/commands/cfn/auto-compact.md +80 -0
- package/claude-assets/commands/cfn/cfn-loop-cli.md +13 -2
- package/claude-assets/commands/cfn/cfn-loop-epic.md +478 -0
- package/claude-assets/commands/cfn/cfn-loop-single.md +256 -0
- package/claude-assets/commands/cfn/cfn-loop-sprints.md +396 -0
- package/claude-assets/commands/cfn/cfn-loop-task.md +27 -9
- package/claude-assets/commands/cfn/cfn-loop.md +518 -0
- package/claude-assets/commands/cfn/claude-md.md +64 -0
- package/claude-assets/commands/cfn/claude-soul.md +22 -0
- package/claude-assets/commands/cfn/cost-savings-off.md +35 -0
- package/claude-assets/commands/cfn/cost-savings-on.md +35 -0
- package/claude-assets/commands/cfn/cost-savings-status.md +34 -0
- package/claude-assets/commands/cfn/custom-routing-activate.md +55 -0
- package/claude-assets/commands/cfn/custom-routing-deactivate.md +46 -0
- package/claude-assets/commands/cfn/dependency-recommendations.md +171 -0
- package/claude-assets/commands/cfn/fullstack.md +179 -0
- package/claude-assets/commands/cfn/github.md +221 -0
- package/claude-assets/commands/cfn/hooks.md +38 -0
- package/claude-assets/commands/cfn/metrics-summary.md +58 -0
- package/claude-assets/commands/cfn/neural.md +39 -0
- package/claude-assets/commands/cfn/parse-epic.md +357 -0
- package/claude-assets/commands/cfn/performance.md +41 -0
- package/claude-assets/commands/cfn/sparc.md +46 -0
- package/claude-assets/commands/cfn/suggest-improvements.md +95 -0
- package/claude-assets/commands/cfn/suggest-templates.md +147 -0
- package/claude-assets/commands/cfn/swarm.md +24 -0
- package/claude-assets/root-claude-distribute/CFN-CLAUDE.md +126 -233
- package/claude-assets/skills/cfn-backlog-management/add-backlog-item.sh +25 -27
- package/claude-assets/skills/cfn-changelog-management/add-changelog-entry.sh +21 -19
- package/claude-assets/skills/cfn-changelog-management/bulk-import.sh +268 -0
- package/claude-assets/skills/cfn-changelog-management/lib/README.md +212 -0
- package/claude-assets/skills/cfn-changelog-management/lib/validation.sh +72 -0
- package/claude-assets/skills/cfn-product-owner-decision/execute-decision.sh +36 -11
- package/claude-assets/skills/cfn-task-config-init/SKILL.md +204 -0
- package/claude-assets/skills/cfn-task-config-init/initialize-config.sh +264 -0
- package/dist/agents/agent-loader.js +165 -146
- package/dist/agents/agent-loader.js.map +1 -1
- package/package.json +2 -2
- package/.claude/commands/README.md +0 -205
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -840
- package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh.backup-p7 +0 -423
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup +0 -38
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-1761167675 +0 -1672
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-p5 +0 -1604
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase1 +0 -1550
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase2 +0 -1621
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase3 +0 -1621
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.broken +0 -1627
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.corrupted +0 -80
- package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.deprecated +0 -1864
- package/.claude/skills/cfn-redis-coordination/tests/test_coordination_primitives.sh.deprecated +0 -20
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh.backup +0 -840
- package/claude-assets/skills/cfn-loop2-output-processing/execute-and-extract.sh.backup +0 -36
- package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh.backup-p7 +0 -423
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup +0 -38
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-1761167675 +0 -1672
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-p5 +0 -1604
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase1 +0 -1550
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase2 +0 -1621
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.backup-phase3 +0 -1621
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.broken +0 -1627
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.corrupted +0 -80
- package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.deprecated +0 -1864
- package/claude-assets/skills/cfn-redis-coordination/tests/test_coordination_primitives.sh.deprecated +0 -20
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
set -euo pipefail
|
|
3
|
-
|
|
4
|
-
# Loop 2 Output Processing: Execute and Extract Validator Output
|
|
5
|
-
# Spawns validator agent and captures output for processing
|
|
6
|
-
|
|
7
|
-
# Input parameters
|
|
8
|
-
TASK_ID="${1:-undefined}"
|
|
9
|
-
AGENT_ID="${2:-reviewer-1}"
|
|
10
|
-
ITERATION="${3:-1}"
|
|
11
|
-
|
|
12
|
-
# Validate inputs
|
|
13
|
-
if [[ "$TASK_ID" == "undefined" ]]; then
|
|
14
|
-
echo "Error: Task ID is required" >&2
|
|
15
|
-
exit 1
|
|
16
|
-
fi
|
|
17
|
-
|
|
18
|
-
# Temporary output file
|
|
19
|
-
OUTPUT_FILE="/tmp/loop2-validator-${TASK_ID}-${ITERATION}.txt"
|
|
20
|
-
|
|
21
|
-
# Spawn validator agent
|
|
22
|
-
npx cfn-spawn agent "$AGENT_ID" --task-id "$TASK_ID" > "$OUTPUT_FILE" 2>&1
|
|
23
|
-
|
|
24
|
-
# Check agent output
|
|
25
|
-
if [[ ! -s "$OUTPUT_FILE" ]]; then
|
|
26
|
-
echo "Error: No output from validator agent" >&2
|
|
27
|
-
exit 1
|
|
28
|
-
fi
|
|
29
|
-
|
|
30
|
-
# Process output
|
|
31
|
-
cat "$OUTPUT_FILE" | "$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"/parse-feedback.sh
|
|
32
|
-
|
|
33
|
-
# Cleanup
|
|
34
|
-
trap 'rm -f "$OUTPUT_FILE"' EXIT
|
|
35
|
-
|
|
36
|
-
exit 0
|
|
@@ -1,423 +0,0 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
#
|
|
3
|
-
# Redis Waiting Mode CLI Wrapper for Agents
|
|
4
|
-
#
|
|
5
|
-
# Usage:
|
|
6
|
-
# ./invoke-waiting-mode.sh enter --task-id <task> --agent-id <agent> --context <context>
|
|
7
|
-
# ./invoke-waiting-mode.sh wake --task-id <task> --agent-id <agent> --reason <reason> [--iteration <n>] [--priority <0-100>] [--fork-id <fork_id>]
|
|
8
|
-
# ./invoke-waiting-mode.sh report --task-id <task> --agent-id <agent> --confidence <score> [--iteration <n>]
|
|
9
|
-
# ./invoke-waiting-mode.sh collect --task-id <task> --agent-ids <id1,id2,id3>
|
|
10
|
-
# ./invoke-waiting-mode.sh shutdown --task-id <task> [--reason <reason>]
|
|
11
|
-
#
|
|
12
|
-
# New parameter: --fork-id
|
|
13
|
-
# Optional unique identifier for conversation continuation
|
|
14
|
-
# Allows tracking and resuming specific conversation forks
|
|
15
|
-
# Stored in Redis with 5-minute TTL during agent wake
|
|
16
|
-
#
|
|
17
|
-
# Priority Levels (0-100, higher = more urgent, default = 50):
|
|
18
|
-
# 90-100: Critical (security patches, system failures)
|
|
19
|
-
# 70-89: High (urgent features, blocking bugs)
|
|
20
|
-
# 40-60: Medium (normal tasks, default)
|
|
21
|
-
# 20-39: Low (optimizations, refactoring)
|
|
22
|
-
# 0-19: Minimal (documentation, cleanup)
|
|
23
|
-
#
|
|
24
|
-
# Examples:
|
|
25
|
-
# # Agent enters waiting mode
|
|
26
|
-
# ./invoke-waiting-mode.sh enter --task-id auth-system --agent-id coder-1 --context "iteration-1"
|
|
27
|
-
#
|
|
28
|
-
# # Coordinator wakes agent with fork ID
|
|
29
|
-
# ./invoke-waiting-mode.sh wake --task-id auth-system --agent-id coder-1 --reason cfn_loop_iteration --iteration 2 --fork-id "fork-1-a3b2c1d4"
|
|
30
|
-
#
|
|
31
|
-
# # Other existing use cases remain unchanged
|
|
32
|
-
|
|
33
|
-
set -euo pipefail
|
|
34
|
-
|
|
35
|
-
# Debug mode (set DEBUG=true for verbose output)
|
|
36
|
-
DEBUG="${DEBUG:-false}"
|
|
37
|
-
|
|
38
|
-
# Parse command
|
|
39
|
-
COMMAND="${1:-}"
|
|
40
|
-
shift || true
|
|
41
|
-
|
|
42
|
-
# Parse arguments
|
|
43
|
-
TASK_ID=""
|
|
44
|
-
AGENT_ID=""
|
|
45
|
-
AGENT_IDS=""
|
|
46
|
-
CONTEXT=""
|
|
47
|
-
REASON=""
|
|
48
|
-
ITERATION=""
|
|
49
|
-
CONFIDENCE=""
|
|
50
|
-
FEEDBACK=""
|
|
51
|
-
TASK_DESC=""
|
|
52
|
-
FORK_ID=""
|
|
53
|
-
PRIORITY=50 # Default medium priority (0-100, higher = more urgent)
|
|
54
|
-
|
|
55
|
-
while [[ $# -gt 0 ]]; do
|
|
56
|
-
case $1 in
|
|
57
|
-
--task-id)
|
|
58
|
-
TASK_ID="$2"
|
|
59
|
-
shift 2
|
|
60
|
-
;;
|
|
61
|
-
--agent-id)
|
|
62
|
-
AGENT_ID="$2"
|
|
63
|
-
shift 2
|
|
64
|
-
;;
|
|
65
|
-
--agent-ids)
|
|
66
|
-
AGENT_IDS="$2"
|
|
67
|
-
shift 2
|
|
68
|
-
;;
|
|
69
|
-
--context)
|
|
70
|
-
CONTEXT="$2"
|
|
71
|
-
shift 2
|
|
72
|
-
;;
|
|
73
|
-
--reason)
|
|
74
|
-
REASON="$2"
|
|
75
|
-
shift 2
|
|
76
|
-
;;
|
|
77
|
-
--iteration)
|
|
78
|
-
ITERATION="$2"
|
|
79
|
-
shift 2
|
|
80
|
-
;;
|
|
81
|
-
--confidence)
|
|
82
|
-
CONFIDENCE="$2"
|
|
83
|
-
shift 2
|
|
84
|
-
;;
|
|
85
|
-
--feedback)
|
|
86
|
-
FEEDBACK="$2"
|
|
87
|
-
shift 2
|
|
88
|
-
;;
|
|
89
|
-
--task)
|
|
90
|
-
TASK_DESC="$2"
|
|
91
|
-
shift 2
|
|
92
|
-
;;
|
|
93
|
-
--priority)
|
|
94
|
-
PRIORITY="$2"
|
|
95
|
-
shift 2
|
|
96
|
-
;;
|
|
97
|
-
--fork-id)
|
|
98
|
-
FORK_ID="$2"
|
|
99
|
-
shift 2
|
|
100
|
-
;;
|
|
101
|
-
*)
|
|
102
|
-
echo "Unknown argument: $1"
|
|
103
|
-
exit 1
|
|
104
|
-
;;
|
|
105
|
-
esac
|
|
106
|
-
done
|
|
107
|
-
|
|
108
|
-
# Validate required arguments
|
|
109
|
-
case "$COMMAND" in
|
|
110
|
-
enter)
|
|
111
|
-
if [ -z "$TASK_ID" ] || [ -z "$AGENT_ID" ] || [ -z "$CONTEXT" ]; then
|
|
112
|
-
echo "Error: enter requires --task-id, --agent-id, and --context"
|
|
113
|
-
exit 1
|
|
114
|
-
fi
|
|
115
|
-
|
|
116
|
-
# Enter waiting mode
|
|
117
|
-
READY_KEY="swarm:${TASK_ID}:${AGENT_ID}:ready"
|
|
118
|
-
WAKE_QUEUE="swarm:${TASK_ID}:${AGENT_ID}:wake-queue"
|
|
119
|
-
SHUTDOWN_KEY="swarm:${TASK_ID}:shutdown"
|
|
120
|
-
|
|
121
|
-
# Publish ready status
|
|
122
|
-
READY_MSG=$(jq -n \
|
|
123
|
-
--arg status "waiting" \
|
|
124
|
-
--arg context "$CONTEXT" \
|
|
125
|
-
--arg ts "$(date +%s)" \
|
|
126
|
-
'{status: $status, context: $context, timestamp: ($ts | tonumber)}')
|
|
127
|
-
|
|
128
|
-
echo "$READY_MSG" | redis-cli -x LPUSH "$READY_KEY" >/dev/null
|
|
129
|
-
|
|
130
|
-
echo "[$AGENT_ID] Entered waiting mode (context: $CONTEXT)"
|
|
131
|
-
echo "[$AGENT_ID] Blocking on priority queue $WAKE_QUEUE and $SHUTDOWN_KEY (infinite timeout)..."
|
|
132
|
-
echo "[$AGENT_ID] Zero token cost while waiting"
|
|
133
|
-
|
|
134
|
-
# Poll loop: check shutdown first, then block on wake queue with timeout
|
|
135
|
-
# This allows us to support both priority queues and shutdown signals
|
|
136
|
-
while true; do
|
|
137
|
-
# Check for shutdown signal first (highest priority)
|
|
138
|
-
SHUTDOWN_CHECK=$(redis-cli LPOP "$SHUTDOWN_KEY")
|
|
139
|
-
|
|
140
|
-
if [ -n "$SHUTDOWN_CHECK" ] && [ "$SHUTDOWN_CHECK" != "(nil)" ]; then
|
|
141
|
-
# Shutdown signal received
|
|
142
|
-
SHUTDOWN_REASON=$(echo "$SHUTDOWN_CHECK" | jq -r '.reason // "unknown"')
|
|
143
|
-
echo "[$AGENT_ID] 🛑 Shutdown signal received"
|
|
144
|
-
echo "[$AGENT_ID] Reason: $SHUTDOWN_REASON"
|
|
145
|
-
echo "$SHUTDOWN_CHECK" | jq '.'
|
|
146
|
-
|
|
147
|
-
# Exit with SIGINT code to indicate graceful shutdown
|
|
148
|
-
exit 130
|
|
149
|
-
fi
|
|
150
|
-
|
|
151
|
-
# Block on wake queue with 1-second timeout (allows periodic shutdown checks)
|
|
152
|
-
# BZPOPMIN returns: key, member, score (3 lines)
|
|
153
|
-
WAKE_RESULT=$(redis-cli BZPOPMIN "$WAKE_QUEUE" 1 2>/dev/null)
|
|
154
|
-
|
|
155
|
-
if [ -n "$WAKE_RESULT" ] && [ "$WAKE_RESULT" != "(nil)" ]; then
|
|
156
|
-
# Parse result (BZPOPMIN returns 3 lines: key, member, score)
|
|
157
|
-
WAKE_MSG=$(echo "$WAKE_RESULT" | sed -n '2p')
|
|
158
|
-
|
|
159
|
-
# Validate JSON before processing
|
|
160
|
-
if echo "$WAKE_MSG" | jq empty 2>/dev/null; then
|
|
161
|
-
echo "[$AGENT_ID] ✅ Woken up!"
|
|
162
|
-
echo "$WAKE_MSG" | jq '.'
|
|
163
|
-
|
|
164
|
-
# Return wake message to caller
|
|
165
|
-
echo "$WAKE_MSG"
|
|
166
|
-
break
|
|
167
|
-
else
|
|
168
|
-
echo "[$AGENT_ID] ⚠️ Invalid JSON in wake message, ignoring"
|
|
169
|
-
continue
|
|
170
|
-
fi
|
|
171
|
-
fi
|
|
172
|
-
|
|
173
|
-
# If no wake signal received, loop back to check shutdown again
|
|
174
|
-
done
|
|
175
|
-
;;
|
|
176
|
-
|
|
177
|
-
wake)
|
|
178
|
-
if [ -z "$TASK_ID" ] || [ -z "$AGENT_ID" ] || [ -z "$REASON" ]; then
|
|
179
|
-
echo "Error: wake requires --task-id, --agent-id, and --reason"
|
|
180
|
-
exit 1
|
|
181
|
-
fi
|
|
182
|
-
|
|
183
|
-
WAKE_QUEUE="swarm:${TASK_ID}:${AGENT_ID}:wake-queue"
|
|
184
|
-
|
|
185
|
-
# Build wake message (compact JSON for Redis storage)
|
|
186
|
-
WAKE_MSG=$(jq -nc \
|
|
187
|
-
--arg reason "$REASON" \
|
|
188
|
-
--arg iteration "${ITERATION:-0}" \
|
|
189
|
-
--arg task "${TASK_DESC:-}" \
|
|
190
|
-
--arg feedback "${FEEDBACK:-}" \
|
|
191
|
-
--arg priority "$PRIORITY" \
|
|
192
|
-
--arg fork_id "${FORK_ID:-}" \
|
|
193
|
-
--arg ts "$(date +%s)" \
|
|
194
|
-
'{
|
|
195
|
-
reason: $reason,
|
|
196
|
-
iteration: ($iteration | tonumber),
|
|
197
|
-
task: $task,
|
|
198
|
-
feedback: ($feedback | split(",") | map(select(length > 0))),
|
|
199
|
-
priority: ($priority | tonumber),
|
|
200
|
-
fork_id: $fork_id,
|
|
201
|
-
timestamp: ($ts | tonumber)
|
|
202
|
-
}')
|
|
203
|
-
|
|
204
|
-
# Store feedback in Redis for agent to read (if provided and iteration > 0)
|
|
205
|
-
# Debug: Echo values before conditional (only if feedback provided)
|
|
206
|
-
if [ -n "$FEEDBACK" ]; then
|
|
207
|
-
[ "$DEBUG" = "true" ] && echo "[DEBUG] Checking feedback storage: FEEDBACK='$FEEDBACK', ITERATION='${ITERATION:-0}'"
|
|
208
|
-
fi
|
|
209
|
-
|
|
210
|
-
# Only store feedback if: feedback is non-empty AND iteration > 0
|
|
211
|
-
# Check iteration value explicitly (not just default)
|
|
212
|
-
if [ -n "$FEEDBACK" ] && [ -n "$ITERATION" ] && [ "$ITERATION" -gt 0 ]; then
|
|
213
|
-
FEEDBACK_KEY="swarm:${TASK_ID}:${AGENT_ID}:feedback:iteration-${ITERATION}"
|
|
214
|
-
FEEDBACK_ARRAY=$(echo "$FEEDBACK" | jq -Rc 'split(",") | map(select(length > 0))')
|
|
215
|
-
|
|
216
|
-
# Only store if feedback array is not empty after filtering
|
|
217
|
-
ARRAY_LENGTH=$(echo "$FEEDBACK_ARRAY" | jq 'length')
|
|
218
|
-
if [ "$ARRAY_LENGTH" -gt 0 ]; then
|
|
219
|
-
# Store as JSON array with 24-hour TTL
|
|
220
|
-
REDIS_RESULT=$(printf '%s' "$FEEDBACK_ARRAY" | redis-cli -x SET "$FEEDBACK_KEY")
|
|
221
|
-
redis-cli EXPIRE "$FEEDBACK_KEY" 86400 >/dev/null
|
|
222
|
-
|
|
223
|
-
# Always log feedback storage (not just in DEBUG mode)
|
|
224
|
-
if [ "$REDIS_RESULT" = "OK" ]; then
|
|
225
|
-
echo " [Feedback] Stored $ARRAY_LENGTH items in Redis (TTL: 24h)"
|
|
226
|
-
fi
|
|
227
|
-
|
|
228
|
-
if [ "$DEBUG" = "true" ]; then
|
|
229
|
-
echo "[DEBUG] Stored feedback in $FEEDBACK_KEY (TTL: 24h)"
|
|
230
|
-
echo "[DEBUG] Feedback: $FEEDBACK_ARRAY"
|
|
231
|
-
echo "[DEBUG] Redis SET result: $REDIS_RESULT"
|
|
232
|
-
fi
|
|
233
|
-
fi
|
|
234
|
-
fi
|
|
235
|
-
|
|
236
|
-
# Calculate priority score (lower score = higher priority, popped first)
|
|
237
|
-
# Score = (100 - priority) * 1000000 + timestamp
|
|
238
|
-
# This ensures higher priority messages are processed first, with FIFO for same priority
|
|
239
|
-
TIMESTAMP=$(date +%s)
|
|
240
|
-
PRIORITY_SCORE=$(echo "(100 - $PRIORITY) * 1000000 + $TIMESTAMP" | bc)
|
|
241
|
-
|
|
242
|
-
# Debug output
|
|
243
|
-
if [ "$DEBUG" = "true" ]; then
|
|
244
|
-
echo "[DEBUG] WAKE_QUEUE: $WAKE_QUEUE"
|
|
245
|
-
echo "[DEBUG] PRIORITY: $PRIORITY"
|
|
246
|
-
echo "[DEBUG] Priority score: $PRIORITY_SCORE"
|
|
247
|
-
echo "[DEBUG] Message: $WAKE_MSG"
|
|
248
|
-
fi
|
|
249
|
-
|
|
250
|
-
# Add to sorted set (ZADD with calculated score)
|
|
251
|
-
redis-cli ZADD "$WAKE_QUEUE" "$PRIORITY_SCORE" "$WAKE_MSG" >/dev/null
|
|
252
|
-
|
|
253
|
-
# Store fork ID in Redis if provided
|
|
254
|
-
if [ -n "$FORK_ID" ]; then
|
|
255
|
-
FORK_KEY="swarm:${TASK_ID}:${AGENT_ID}:fork-id"
|
|
256
|
-
# Store fork ID with 5-minute expiration
|
|
257
|
-
redis-cli SETEX "$FORK_KEY" 300 "$FORK_ID" >/dev/null
|
|
258
|
-
echo "[Coordinator] Fork ID stored: $FORK_ID (5-minute TTL)"
|
|
259
|
-
fi
|
|
260
|
-
|
|
261
|
-
echo "[Coordinator] ✅ Wake signal sent to $AGENT_ID"
|
|
262
|
-
echo " Reason: $REASON"
|
|
263
|
-
echo " Priority: $PRIORITY (score: $PRIORITY_SCORE)"
|
|
264
|
-
[ -n "$ITERATION" ] && echo " Iteration: $ITERATION"
|
|
265
|
-
;;
|
|
266
|
-
|
|
267
|
-
report)
|
|
268
|
-
if [ -z "$TASK_ID" ] || [ -z "$AGENT_ID" ] || [ -z "$CONFIDENCE" ]; then
|
|
269
|
-
echo "Error: report requires --task-id, --agent-id, and --confidence"
|
|
270
|
-
exit 1
|
|
271
|
-
fi
|
|
272
|
-
|
|
273
|
-
RESULT_KEY="swarm:${TASK_ID}:${AGENT_ID}:result"
|
|
274
|
-
|
|
275
|
-
# Build result message with optional feedback
|
|
276
|
-
RESULT_MSG=$(jq -n \
|
|
277
|
-
--arg confidence "$CONFIDENCE" \
|
|
278
|
-
--arg iteration "${ITERATION:-0}" \
|
|
279
|
-
--arg feedback "${FEEDBACK:-}" \
|
|
280
|
-
--arg ts "$(date +%s)" \
|
|
281
|
-
'{
|
|
282
|
-
confidence: ($confidence | tonumber),
|
|
283
|
-
iteration: ($iteration | tonumber),
|
|
284
|
-
feedback: ($feedback | split(",") | map(select(length > 0))),
|
|
285
|
-
timestamp: ($ts | tonumber)
|
|
286
|
-
}')
|
|
287
|
-
|
|
288
|
-
echo "$RESULT_MSG" | redis-cli -x LPUSH "$RESULT_KEY" >/dev/null
|
|
289
|
-
|
|
290
|
-
echo "[$AGENT_ID] ✅ Result reported"
|
|
291
|
-
echo " Confidence: $CONFIDENCE"
|
|
292
|
-
[ -n "$ITERATION" ] && echo " Iteration: $ITERATION"
|
|
293
|
-
if [ -n "$FEEDBACK" ]; then
|
|
294
|
-
echo " Feedback items: $(echo "$FEEDBACK" | tr ',' '\n' | wc -l)"
|
|
295
|
-
fi
|
|
296
|
-
;;
|
|
297
|
-
|
|
298
|
-
collect)
|
|
299
|
-
if [ -z "$TASK_ID" ] || [ -z "$AGENT_IDS" ]; then
|
|
300
|
-
echo "Error: collect requires --task-id and --agent-ids"
|
|
301
|
-
exit 1
|
|
302
|
-
fi
|
|
303
|
-
|
|
304
|
-
echo "[Coordinator] Collecting results from agents..."
|
|
305
|
-
echo ""
|
|
306
|
-
|
|
307
|
-
# Split agent IDs
|
|
308
|
-
IFS=',' read -ra AGENTS <<< "$AGENT_IDS"
|
|
309
|
-
|
|
310
|
-
RESULTS=()
|
|
311
|
-
CONFIDENCES=()
|
|
312
|
-
ALL_FEEDBACK=()
|
|
313
|
-
|
|
314
|
-
for AGENT in "${AGENTS[@]}"; do
|
|
315
|
-
RESULT_KEY="swarm:${TASK_ID}:${AGENT}:result"
|
|
316
|
-
|
|
317
|
-
# Get latest result (non-blocking)
|
|
318
|
-
RESULT=$(redis-cli LPOP "$RESULT_KEY")
|
|
319
|
-
|
|
320
|
-
if [ -n "$RESULT" ] && [ "$RESULT" != "(nil)" ]; then
|
|
321
|
-
CONF=$(echo "$RESULT" | jq -r '.confidence')
|
|
322
|
-
echo " [$AGENT] Confidence: $CONF"
|
|
323
|
-
RESULTS+=("$RESULT")
|
|
324
|
-
CONFIDENCES+=("$CONF")
|
|
325
|
-
|
|
326
|
-
# Check if result includes feedback array
|
|
327
|
-
FEEDBACK=$(echo "$RESULT" | jq -r '.feedback // empty | .[]?' 2>/dev/null)
|
|
328
|
-
if [ -n "$FEEDBACK" ]; then
|
|
329
|
-
echo " [$AGENT] Feedback provided:"
|
|
330
|
-
echo "$RESULT" | jq -r '.feedback[]' | sed 's/^/ - /'
|
|
331
|
-
|
|
332
|
-
# Collect all feedback items
|
|
333
|
-
while IFS= read -r ITEM; do
|
|
334
|
-
ALL_FEEDBACK+=("$ITEM")
|
|
335
|
-
done < <(echo "$RESULT" | jq -r '.feedback[]')
|
|
336
|
-
fi
|
|
337
|
-
else
|
|
338
|
-
echo " [$AGENT] ⚠️ No result found"
|
|
339
|
-
fi
|
|
340
|
-
done
|
|
341
|
-
|
|
342
|
-
# Calculate consensus
|
|
343
|
-
if [ ${#CONFIDENCES[@]} -gt 0 ]; then
|
|
344
|
-
SUM=0
|
|
345
|
-
for CONF in "${CONFIDENCES[@]}"; do
|
|
346
|
-
SUM=$(echo "$SUM + $CONF" | bc)
|
|
347
|
-
done
|
|
348
|
-
COUNT=${#CONFIDENCES[@]}
|
|
349
|
-
CONSENSUS=$(echo "scale=2; $SUM / $COUNT" | bc)
|
|
350
|
-
|
|
351
|
-
echo ""
|
|
352
|
-
echo "[Coordinator] Consensus: $CONSENSUS"
|
|
353
|
-
|
|
354
|
-
# Print aggregated feedback if available
|
|
355
|
-
if [ ${#ALL_FEEDBACK[@]} -gt 0 ]; then
|
|
356
|
-
echo "[Coordinator] Aggregated Feedback (${#ALL_FEEDBACK[@]} items):"
|
|
357
|
-
printf '%s\n' "${ALL_FEEDBACK[@]}" | sort -u | sed 's/^/ - /'
|
|
358
|
-
fi
|
|
359
|
-
|
|
360
|
-
echo "$CONSENSUS"
|
|
361
|
-
else
|
|
362
|
-
echo ""
|
|
363
|
-
echo "[Coordinator] No results to calculate consensus"
|
|
364
|
-
echo "0.0"
|
|
365
|
-
fi
|
|
366
|
-
;;
|
|
367
|
-
|
|
368
|
-
shutdown)
|
|
369
|
-
if [ -z "$TASK_ID" ]; then
|
|
370
|
-
echo "Error: shutdown requires --task-id"
|
|
371
|
-
exit 1
|
|
372
|
-
fi
|
|
373
|
-
|
|
374
|
-
SHUTDOWN_KEY="swarm:${TASK_ID}:shutdown"
|
|
375
|
-
|
|
376
|
-
# Build shutdown message
|
|
377
|
-
SHUTDOWN_MSG=$(jq -n \
|
|
378
|
-
--arg reason "${REASON:-task_complete}" \
|
|
379
|
-
--arg ts "$(date +%s)" \
|
|
380
|
-
'{
|
|
381
|
-
reason: $reason,
|
|
382
|
-
timestamp: ($ts | tonumber)
|
|
383
|
-
}')
|
|
384
|
-
|
|
385
|
-
# Broadcast shutdown signal (use LPUSH to add to list)
|
|
386
|
-
# All waiting agents will check this key and exit gracefully
|
|
387
|
-
echo "$SHUTDOWN_MSG" | redis-cli -x LPUSH "$SHUTDOWN_KEY" >/dev/null
|
|
388
|
-
|
|
389
|
-
echo "[Coordinator] 🛑 Shutdown signal broadcasted"
|
|
390
|
-
echo " Task ID: $TASK_ID"
|
|
391
|
-
echo " Reason: ${REASON:-task_complete}"
|
|
392
|
-
echo ""
|
|
393
|
-
echo "Note: Signal added to $SHUTDOWN_KEY"
|
|
394
|
-
echo "All waiting agents will receive shutdown on next poll cycle (max 1 second)"
|
|
395
|
-
;;
|
|
396
|
-
|
|
397
|
-
*)
|
|
398
|
-
echo "Usage: $0 <command> [options]"
|
|
399
|
-
echo ""
|
|
400
|
-
echo "Commands:"
|
|
401
|
-
echo " enter - Agent enters waiting mode"
|
|
402
|
-
echo " wake - Coordinator wakes an agent (supports --priority 0-100, --fork-id)"
|
|
403
|
-
echo " report - Agent reports result"
|
|
404
|
-
echo " collect - Coordinator collects results"
|
|
405
|
-
echo " shutdown - Coordinator broadcasts shutdown signal to all waiting agents"
|
|
406
|
-
echo ""
|
|
407
|
-
echo "Priority Levels (0-100, higher = more urgent, default = 50):"
|
|
408
|
-
echo " 90-100: Critical (security patches, system failures)"
|
|
409
|
-
echo " 70-89: High (urgent features, blocking bugs)"
|
|
410
|
-
echo " 40-60: Medium (normal tasks, default)"
|
|
411
|
-
echo " 20-39: Low (optimizations, refactoring)"
|
|
412
|
-
echo " 0-19: Minimal (documentation, cleanup)"
|
|
413
|
-
echo ""
|
|
414
|
-
echo "Examples:"
|
|
415
|
-
echo " $0 enter --task-id auth --agent-id coder-1 --context iteration-1"
|
|
416
|
-
echo " $0 wake --task-id auth --agent-id coder-1 --reason cfn_loop_iteration --iteration 2 --fork-id fork-1"
|
|
417
|
-
echo " $0 wake --task-id auth --agent-id coder-1 --reason security_patch --priority 95"
|
|
418
|
-
echo " $0 report --task-id auth --agent-id coder-1 --confidence 0.85 --iteration 1"
|
|
419
|
-
echo " $0 collect --task-id auth --agent-ids coder-1,reviewer-1,tester-1"
|
|
420
|
-
echo " $0 shutdown --task-id auth --reason task_complete"
|
|
421
|
-
exit 1
|
|
422
|
-
;;
|
|
423
|
-
esac
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
|
|
3
|
-
# Rest of the file content remains the same...
|
|
4
|
-
|
|
5
|
-
# After the # BLPOP with Retry Logic section, add:
|
|
6
|
-
# Step 3: Build Loop 2 JSON context (v2.10.0 - bidirectional JSON)
|
|
7
|
-
LOOP3_AGENT_IDS_JSON=$(printf '%s\n' "${LOOP3_COMPLETED_AGENTS[@]}" 2>/dev/null | jq -R . | jq -s . || echo '[]')
|
|
8
|
-
SAFE_LOOP3_IDS="${LOOP3_AGENT_IDS_JSON:-[]}"
|
|
9
|
-
|
|
10
|
-
LOOP2_VALIDATOR_CONTEXT=$(jq -n \
|
|
11
|
-
--arg task "Loop 2 validation for iteration $ITERATION" \
|
|
12
|
-
--argjson validationTarget "$(jq -n \
|
|
13
|
-
--argjson loop3AgentIds "$SAFE_LOOP3_IDS" \
|
|
14
|
-
--argjson deliverables "$SAFE_DELIVERABLES" \
|
|
15
|
-
--argjson acceptanceCriteria "$SAFE_ACCEPTANCE" \
|
|
16
|
-
'{loop3AgentIds: $loop3AgentIds, deliverables: $deliverables, acceptanceCriteria: $acceptanceCriteria}')" \
|
|
17
|
-
--argjson reviewAspects '["File existence","Implementation completeness","Acceptance criteria compliance","Code quality"]' \
|
|
18
|
-
--arg taskId "$TASK_ID" \
|
|
19
|
-
--arg iteration "$ITERATION" \
|
|
20
|
-
--arg epicGoal "$EPIC_GOAL" \
|
|
21
|
-
--arg directory "${DIRECTORY:-}" \
|
|
22
|
-
'{
|
|
23
|
-
loop: "loop2",
|
|
24
|
-
iteration: ($iteration | tonumber),
|
|
25
|
-
task: $task,
|
|
26
|
-
epicGoal: $epicGoal,
|
|
27
|
-
validationTarget: $validationTarget,
|
|
28
|
-
reviewAspects: $reviewAspects,
|
|
29
|
-
taskId: $taskId,
|
|
30
|
-
directory: (if $directory == "" then null else $directory end),
|
|
31
|
-
validationInstructions: [
|
|
32
|
-
"Verify all deliverable files exist in correct directory",
|
|
33
|
-
"Check files contain actual implementation (not placeholders)",
|
|
34
|
-
"Validate against acceptance criteria",
|
|
35
|
-
"Provide structured feedback (critical/warnings/suggestions)",
|
|
36
|
-
"Report confidence score based on deliverable completeness"
|
|
37
|
-
]
|
|
38
|
-
}')
|