claude-flow-novice 2.14.2 → 2.14.4

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.
Files changed (161) hide show
  1. package/.claude/commands/CFN_LOOP_TASK_MODE.md +4 -47
  2. package/.claude/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -276
  3. package/claude-assets/commands/CFN_LOOP_TASK_MODE.md +4 -47
  4. package/claude-assets/skills/cfn-redis-coordination/demos/test-cancel-swarm.sh +0 -276
  5. package/dist/cli/agent-prompt-builder.js +25 -0
  6. package/dist/cli/agent-prompt-builder.js.map +1 -1
  7. package/dist/cli/config-manager.js +91 -109
  8. package/package.json +1 -1
  9. package/scripts/init-project.js +1 -1
  10. package/.claude/skills/cfn-redis-coordination/HEARTBEAT.md +0 -57
  11. package/.claude/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +0 -267
  12. package/.claude/skills/cfn-redis-coordination/LOGGING.md +0 -260
  13. package/.claude/skills/cfn-redis-coordination/README.md +0 -65
  14. package/.claude/skills/cfn-redis-coordination/SECURITY_REVIEW.md +0 -25
  15. package/.claude/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +0 -164
  16. package/.claude/skills/cfn-redis-coordination/SKILL.md +0 -720
  17. package/.claude/skills/cfn-redis-coordination/demos/test-dlq.sh +0 -129
  18. package/.claude/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +0 -320
  19. package/.claude/skills/cfn-redis-coordination/demos/test-orchestrator.sh +0 -249
  20. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +0 -148
  21. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +0 -163
  22. package/.claude/skills/cfn-redis-coordination/demos/test-priority-wake.sh +0 -138
  23. package/.claude/skills/cfn-redis-coordination/demos/test-quick-fix.sh +0 -81
  24. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +0 -45
  25. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +0 -68
  26. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +0 -56
  27. package/.claude/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +0 -81
  28. package/.claude/skills/cfn-redis-coordination/demos/test-quorum.sh +0 -57
  29. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +0 -187
  30. package/.claude/skills/cfn-redis-coordination/demos/test-shutdown.sh +0 -160
  31. package/.claude/skills/cfn-redis-coordination/demos/test-utils-unix.sh +0 -97
  32. package/.claude/skills/cfn-redis-coordination/demos/test-utils.sh +0 -97
  33. package/.claude/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +0 -59
  34. package/.claude/skills/cfn-redis-coordination/examples/README.md +0 -73
  35. package/.claude/skills/cfn-redis-coordination/examples/grafana-dashboard.json +0 -352
  36. package/.claude/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +0 -127
  37. package/.claude/skills/cfn-redis-coordination/examples/mesh-pattern.sh +0 -171
  38. package/.claude/skills/cfn-redis-coordination/examples/timeout-handling.sh +0 -227
  39. package/.claude/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +0 -239
  40. package/.claude/skills/cfn-redis-coordination/execute-product-owner-decision.sh +0 -258
  41. package/.claude/skills/cfn-redis-coordination/get-agent-timeout.sh +0 -177
  42. package/.claude/skills/cfn-redis-coordination/heartbeat-functions.sh +0 -137
  43. package/.claude/skills/cfn-redis-coordination/heartbeat-protocol.md +0 -106
  44. package/.claude/skills/cfn-redis-coordination/heartbeat.sh +0 -126
  45. package/.claude/skills/cfn-redis-coordination/init-swarm.sh +0 -148
  46. package/.claude/skills/cfn-redis-coordination/invoke-redis-pattern.sh +0 -220
  47. package/.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh +0 -283
  48. package/.claude/skills/cfn-redis-coordination/list-active-swarms.sh +0 -147
  49. package/.claude/skills/cfn-redis-coordination/log-event.sh +0 -109
  50. package/.claude/skills/cfn-redis-coordination/metrics-export.sh +0 -674
  51. package/.claude/skills/cfn-redis-coordination/metrics-schema.json +0 -66
  52. package/.claude/skills/cfn-redis-coordination/metrics-storage.md +0 -31
  53. package/.claude/skills/cfn-redis-coordination/monitor-cfn-violations.sh +0 -391
  54. package/.claude/skills/cfn-redis-coordination/monitor-heartbeats.sh +0 -101
  55. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +0 -141
  56. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +0 -31
  57. package/.claude/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  58. package/.claude/skills/cfn-redis-coordination/priority-wake-mechanism.md +0 -75
  59. package/.claude/skills/cfn-redis-coordination/priority_wake.py +0 -134
  60. package/.claude/skills/cfn-redis-coordination/query-dlq.sh +0 -162
  61. package/.claude/skills/cfn-redis-coordination/query-logs.sh +0 -103
  62. package/.claude/skills/cfn-redis-coordination/redis-pattern.sh +0 -619
  63. package/.claude/skills/cfn-redis-coordination/retrieve-context.sh +0 -58
  64. package/.claude/skills/cfn-redis-coordination/select-specialist-agent.sh +0 -371
  65. package/.claude/skills/cfn-redis-coordination/semantic-match-tfidf.py +0 -252
  66. package/.claude/skills/cfn-redis-coordination/send-heartbeat.sh +0 -165
  67. package/.claude/skills/cfn-redis-coordination/signal.sh +0 -38
  68. package/.claude/skills/cfn-redis-coordination/store-context.sh +0 -86
  69. package/.claude/skills/cfn-redis-coordination/store-epic-context.sh +0 -123
  70. package/.claude/skills/cfn-redis-coordination/test-context-injection.sh +0 -354
  71. package/.claude/skills/cfn-redis-coordination/test-timeout-enforcement.sh +0 -513
  72. package/.claude/skills/cfn-redis-coordination/tests/convert-line-endings.sh +0 -15
  73. package/.claude/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +0 -102
  74. package/.claude/skills/cfn-redis-coordination/tests/edge-cases-test.sh +0 -99
  75. package/.claude/skills/cfn-redis-coordination/tests/integration-test.sh +0 -170
  76. package/.claude/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +0 -82
  77. package/.claude/skills/cfn-redis-coordination/tests/run-test-suite.sh +0 -92
  78. package/.claude/skills/cfn-redis-coordination/tests/run-tests.sh +0 -4
  79. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +0 -418
  80. package/.claude/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +0 -124
  81. package/.claude/skills/cfn-redis-coordination/tests/test-primitives.sh +0 -166
  82. package/.claude/skills/cfn-redis-coordination/tests/test-utils.sh +0 -54
  83. package/.claude/skills/cfn-redis-coordination/tests/test_utils.sh +0 -49
  84. package/.claude/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +0 -76
  85. package/.claude/skills/cfn-redis-coordination/validate-parameters.sh +0 -492
  86. package/claude-assets/skills/cfn-redis-coordination/HEARTBEAT.md +0 -57
  87. package/claude-assets/skills/cfn-redis-coordination/HEARTBEAT_MONITORING.md +0 -267
  88. package/claude-assets/skills/cfn-redis-coordination/LOGGING.md +0 -260
  89. package/claude-assets/skills/cfn-redis-coordination/README.md +0 -65
  90. package/claude-assets/skills/cfn-redis-coordination/SECURITY_REVIEW.md +0 -25
  91. package/claude-assets/skills/cfn-redis-coordination/SHUTDOWN_HANDLING.md +0 -164
  92. package/claude-assets/skills/cfn-redis-coordination/SKILL.md +0 -720
  93. package/claude-assets/skills/cfn-redis-coordination/demos/test-dlq.sh +0 -129
  94. package/claude-assets/skills/cfn-redis-coordination/demos/test-iteration-feedback.sh +0 -320
  95. package/claude-assets/skills/cfn-redis-coordination/demos/test-orchestrator.sh +0 -249
  96. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake-phase4-unix.sh +0 -148
  97. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake-phase4.sh +0 -163
  98. package/claude-assets/skills/cfn-redis-coordination/demos/test-priority-wake.sh +0 -138
  99. package/claude-assets/skills/cfn-redis-coordination/demos/test-quick-fix.sh +0 -81
  100. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-absolute.sh +0 -45
  101. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-fallback.sh +0 -68
  102. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-percentage.sh +0 -56
  103. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum-with-retry.sh +0 -81
  104. package/claude-assets/skills/cfn-redis-coordination/demos/test-quorum.sh +0 -57
  105. package/claude-assets/skills/cfn-redis-coordination/demos/test-shutdown-handling.sh +0 -187
  106. package/claude-assets/skills/cfn-redis-coordination/demos/test-shutdown.sh +0 -160
  107. package/claude-assets/skills/cfn-redis-coordination/demos/test-utils-unix.sh +0 -97
  108. package/claude-assets/skills/cfn-redis-coordination/demos/test-utils.sh +0 -97
  109. package/claude-assets/skills/cfn-redis-coordination/demos/test-waiting-mode.sh +0 -59
  110. package/claude-assets/skills/cfn-redis-coordination/examples/README.md +0 -73
  111. package/claude-assets/skills/cfn-redis-coordination/examples/grafana-dashboard.json +0 -352
  112. package/claude-assets/skills/cfn-redis-coordination/examples/hierarchical-pattern.sh +0 -127
  113. package/claude-assets/skills/cfn-redis-coordination/examples/mesh-pattern.sh +0 -171
  114. package/claude-assets/skills/cfn-redis-coordination/examples/timeout-handling.sh +0 -227
  115. package/claude-assets/skills/cfn-redis-coordination/examples/waiting-mode-pattern.sh +0 -239
  116. package/claude-assets/skills/cfn-redis-coordination/execute-product-owner-decision.sh +0 -258
  117. package/claude-assets/skills/cfn-redis-coordination/get-agent-timeout.sh +0 -177
  118. package/claude-assets/skills/cfn-redis-coordination/heartbeat-functions.sh +0 -137
  119. package/claude-assets/skills/cfn-redis-coordination/heartbeat-protocol.md +0 -106
  120. package/claude-assets/skills/cfn-redis-coordination/heartbeat.sh +0 -126
  121. package/claude-assets/skills/cfn-redis-coordination/init-swarm.sh +0 -148
  122. package/claude-assets/skills/cfn-redis-coordination/invoke-redis-pattern.sh +0 -220
  123. package/claude-assets/skills/cfn-redis-coordination/invoke-waiting-mode.sh +0 -283
  124. package/claude-assets/skills/cfn-redis-coordination/list-active-swarms.sh +0 -147
  125. package/claude-assets/skills/cfn-redis-coordination/log-event.sh +0 -109
  126. package/claude-assets/skills/cfn-redis-coordination/metrics-export.sh +0 -674
  127. package/claude-assets/skills/cfn-redis-coordination/metrics-schema.json +0 -66
  128. package/claude-assets/skills/cfn-redis-coordination/metrics-storage.md +0 -31
  129. package/claude-assets/skills/cfn-redis-coordination/monitor-cfn-violations.sh +0 -391
  130. package/claude-assets/skills/cfn-redis-coordination/monitor-heartbeats.sh +0 -101
  131. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop-v3.sh +0 -141
  132. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh +0 -31
  133. package/claude-assets/skills/cfn-redis-coordination/orchestrate-cfn-loop.sh.bak +0 -0
  134. package/claude-assets/skills/cfn-redis-coordination/priority-wake-mechanism.md +0 -75
  135. package/claude-assets/skills/cfn-redis-coordination/priority_wake.py +0 -134
  136. package/claude-assets/skills/cfn-redis-coordination/query-dlq.sh +0 -162
  137. package/claude-assets/skills/cfn-redis-coordination/query-logs.sh +0 -103
  138. package/claude-assets/skills/cfn-redis-coordination/redis-pattern.sh +0 -619
  139. package/claude-assets/skills/cfn-redis-coordination/retrieve-context.sh +0 -58
  140. package/claude-assets/skills/cfn-redis-coordination/select-specialist-agent.sh +0 -371
  141. package/claude-assets/skills/cfn-redis-coordination/semantic-match-tfidf.py +0 -252
  142. package/claude-assets/skills/cfn-redis-coordination/send-heartbeat.sh +0 -165
  143. package/claude-assets/skills/cfn-redis-coordination/signal.sh +0 -38
  144. package/claude-assets/skills/cfn-redis-coordination/store-context.sh +0 -86
  145. package/claude-assets/skills/cfn-redis-coordination/store-epic-context.sh +0 -123
  146. package/claude-assets/skills/cfn-redis-coordination/test-context-injection.sh +0 -354
  147. package/claude-assets/skills/cfn-redis-coordination/test-timeout-enforcement.sh +0 -513
  148. package/claude-assets/skills/cfn-redis-coordination/tests/convert-line-endings.sh +0 -15
  149. package/claude-assets/skills/cfn-redis-coordination/tests/dlq-functionality-test.sh +0 -102
  150. package/claude-assets/skills/cfn-redis-coordination/tests/edge-cases-test.sh +0 -99
  151. package/claude-assets/skills/cfn-redis-coordination/tests/integration-test.sh +0 -170
  152. package/claude-assets/skills/cfn-redis-coordination/tests/retry-mechanism-test.sh +0 -82
  153. package/claude-assets/skills/cfn-redis-coordination/tests/run-test-suite.sh +0 -92
  154. package/claude-assets/skills/cfn-redis-coordination/tests/run-tests.sh +0 -4
  155. package/claude-assets/skills/cfn-redis-coordination/tests/test-heartbeat-monitoring.sh +0 -418
  156. package/claude-assets/skills/cfn-redis-coordination/tests/test-heartbeat-simple.sh +0 -124
  157. package/claude-assets/skills/cfn-redis-coordination/tests/test-primitives.sh +0 -166
  158. package/claude-assets/skills/cfn-redis-coordination/tests/test-utils.sh +0 -54
  159. package/claude-assets/skills/cfn-redis-coordination/tests/test_utils.sh +0 -49
  160. package/claude-assets/skills/cfn-redis-coordination/v2_modularization/core_orchestration.sh +0 -76
  161. package/claude-assets/skills/cfn-redis-coordination/validate-parameters.sh +0 -492
@@ -1,141 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- ##############################################################################
4
- # CFN Loop Orchestration v3.0.0
5
- # Advanced multi-agent coordination with enhanced Redis context retrieval,
6
- # validation template support, intervention detection, and retrospective capabilities
7
- #
8
- # Key Enhancements:
9
- # - Redis-first context retrieval
10
- # - Domain-specific validation thresholds
11
- # - Real-time intervention detection
12
- # - Automatic playbook update
13
- # - Retrospective trigger
14
- # - Z.ai provider routing
15
- ##############################################################################
16
-
17
- set -euo pipefail
18
-
19
- # V3 Specific Configuration
20
- TASK_ID=""
21
- MODE="standard"
22
- V3_VALIDATION_TEMPLATE=""
23
- INTERVENTION_THRESHOLD=0.75
24
- RETROSPECTIVE_ENABLED=1
25
-
26
- # Import common v2 functions
27
- # shellcheck source=./orchestrate-cfn-loop.sh
28
- source "$(dirname "$0")/orchestrate-cfn-loop.sh"
29
-
30
- # V3 Specific Configuration Loading
31
- function load_v3_configuration() {
32
- # Load configuration from Redis using task context
33
- V3_CONFIG=$(redis-cli HGETALL "cfn_loop:task:${TASK_ID}:v3_config" 2>/dev/null)
34
-
35
- # Parse configuration
36
- while read -r key value; do
37
- case "$key" in
38
- "validation_template")
39
- V3_VALIDATION_TEMPLATE="$value"
40
- ;;
41
- "intervention_threshold")
42
- INTERVENTION_THRESHOLD="$value"
43
- ;;
44
- "retrospective_enabled")
45
- RETROSPECTIVE_ENABLED="$value"
46
- ;;
47
- esac
48
- done <<< "$V3_CONFIG"
49
- }
50
-
51
- # Domain-Specific Validation Template Loader
52
- function load_validation_template() {
53
- local template_path="$1"
54
-
55
- if [ ! -f "$template_path" ]; then
56
- echo "Error: Validation template not found at $template_path"
57
- return 1
58
- fi
59
-
60
- # Load and parse validation template
61
- VALIDATION_CONFIG=$(jq '.' "$template_path")
62
-
63
- # Extract domain-specific thresholds
64
- DOMAIN_GATE_THRESHOLD=$(echo "$VALIDATION_CONFIG" | jq -r '.gate_threshold // 0.75')
65
- DOMAIN_CONSENSUS_THRESHOLD=$(echo "$VALIDATION_CONFIG" | jq -r '.consensus_threshold // 0.90')
66
-
67
- # Override default thresholds
68
- GATE=${DOMAIN_GATE_THRESHOLD}
69
- CONSENSUS=${DOMAIN_CONSENSUS_THRESHOLD}
70
- }
71
-
72
- # Intervention Detection Function
73
- function detect_intervention_needed() {
74
- local confidence_scores=("$@")
75
- local intervention_triggered=0
76
-
77
- for score in "${confidence_scores[@]}"; do
78
- if (( $(echo "$score < $INTERVENTION_THRESHOLD" | bc -l) )); then
79
- intervention_triggered=1
80
- break
81
- fi
82
- done
83
-
84
- return $intervention_triggered
85
- }
86
-
87
- # Trigger Retrospective Analysis
88
- function trigger_retrospective() {
89
- if [ "$RETROSPECTIVE_ENABLED" -eq 1 ]; then
90
- npx cfn-spawn agent retrospective-analyst \
91
- --task-id "$TASK_ID" \
92
- --mode "post_execution" \
93
- --context "{\"task_id\": \"$TASK_ID\", \"mode\": \"$MODE\"}"
94
- fi
95
- }
96
-
97
- # Automatic Playbook Update
98
- function update_playbook() {
99
- ./.claude/skills/cfn-playbook-auto-update/update.sh \
100
- --task-id "$TASK_ID" \
101
- --mode "$MODE" \
102
- --context "$CFN_METADATA"
103
- }
104
-
105
- # Override Main Iteration Logic
106
- function main_iteration_logic() {
107
- # V3: Load Redis context first
108
- load_v3_configuration
109
-
110
- # Load domain-specific validation template if specified
111
- if [ -n "$V3_VALIDATION_TEMPLATE" ]; then
112
- load_validation_template "$V3_VALIDATION_TEMPLATE"
113
- fi
114
-
115
- # Original v2 iteration logic with V3 enhancements
116
- for ITERATION in $(seq 1 $MAX_ITERATIONS); do
117
- # Existing iteration loop logic here...
118
-
119
- # V3: Intervention Detection
120
- if detect_intervention_needed "${AGENT_CONFIDENCE_SCORES[@]}"; then
121
- echo "[V3 Intervention] Confidence threshold not met. Spawning specialist agent..."
122
- # Spawn specialist agent to address low-confidence areas
123
- npx cfn-spawn agent specialist \
124
- --task-id "$TASK_ID" \
125
- --mode intervention \
126
- --context "{\"iteration\": $ITERATION}"
127
- fi
128
-
129
- # Continue with existing iteration logic...
130
- done
131
-
132
- # Finalization: Trigger Retrospective and Update Playbook
133
- trigger_retrospective
134
- update_playbook
135
- }
136
-
137
- # Execute Main Logic
138
- main_iteration_logic
139
-
140
- # Existing cleanup and exit logic from v2 script
141
- cleanup_and_exit 0 "cfn_loop_v3_complete"
@@ -1,31 +0,0 @@
1
- #!/bin/bash
2
-
3
- echo "=========================================="
4
- echo "⚠️ DEPRECATED: orchestrate-cfn-loop.sh"
5
- echo "=========================================="
6
- echo ""
7
- echo "This orchestrator has been replaced by the modular CFN v3 version."
8
- echo ""
9
- echo "New Location:"
10
- echo " ./.claude/skills/cfn-cfn-loop-orchestration/orchestrate.sh"
11
- echo ""
12
- echo "Key Improvements in v3:"
13
- echo " - 78% code reduction (70KB → 26KB)"
14
- echo " - Modular helper scripts"
15
- echo " - Stateless context injection"
16
- echo " - Better agent ID tracking"
17
- echo " - No BLPOP hangs"
18
- echo ""
19
- echo "Migration:"
20
- echo " Replace: orchestrate-cfn-loop.sh"
21
- echo " With: cfn-loop-orchestration/orchestrate.sh"
22
- echo ""
23
- echo "Same parameters supported (backward compatible)"
24
- echo ""
25
- echo "=========================================="
26
- echo ""
27
- echo "Forwarding to new orchestrator..."
28
- echo ""
29
-
30
- # Forward to new version
31
- exec "$(dirname "$0")/.claude/skills/cfn-cfn-cfn-loop-orchestration/orchestrate.sh" "$@"
@@ -1,75 +0,0 @@
1
- # Priority Queue Wake-Up Mechanism
2
-
3
- ## Design Overview
4
-
5
- ### Motivation
6
- Replace traditional LPUSH/BLPOP with ZADD/BZPOPMIN to enable priority-ordered wake-ups across distributed agent swarms.
7
-
8
- ### Priority Scoring Algorithm
9
-
10
- #### Score Calculation
11
- ```
12
- SCORE = TIMESTAMP + (PRIORITY * PRIORITY_MULTIPLIER)
13
-
14
- Where:
15
- - TIMESTAMP: Unix epoch seconds
16
- - PRIORITY: Assigned agent/task priority level
17
- - PRIORITY_MULTIPLIER: 1,000,000 (ensures timestamp remains primary sorting factor)
18
- ```
19
-
20
- ### Priority Levels
21
-
22
- | Level | Range | Example Agents |
23
- |----------|---------|-------------------------------------|
24
- | Critical | 0-10 | Product Owner, System Coordinators |
25
- | High | 11-30 | Loop 2 Validators |
26
- | Medium | 31-60 | Loop 3 Implementers |
27
- | Low | 61-100 | Background Tasks, Monitoring Agents |
28
-
29
- ### Redis Command Translations
30
-
31
- #### Old Method (FIFO)
32
- ```bash
33
- # LPUSH: Adds to end of list
34
- redis-cli lpush "swarm:{task}:{agent}:wake" "$WAKE_MSG"
35
- # BLPOP: Blocks and removes from start of list
36
- redis-cli blpop "swarm:{task}:{agent}:wake" 0
37
- ```
38
-
39
- #### New Method (Priority Queue)
40
- ```bash
41
- # ZADD: Adds to sorted set with score
42
- redis-cli zadd "swarm:{task}:wake-queue" $SCORE "$WAKE_MSG"
43
- # BZPOPMIN: Blocks and removes lowest-score item
44
- redis-cli bzpopmin "swarm:{task}:wake-queue" 0
45
- ```
46
-
47
- ### Configuration Flag
48
- ```json
49
- {
50
- "features": {
51
- "enablePriorityWake": {
52
- "default": false,
53
- "description": "Enable priority-based wake mechanism",
54
- "version": "4.0.0"
55
- }
56
- }
57
- }
58
- ```
59
-
60
- ## Migration Strategy
61
-
62
- 1. Dual Support Phase
63
- - Maintain both LPUSH and ZADD mechanisms
64
- - Gradual rollout with feature flag
65
- - Monitor performance and compatibility
66
-
67
- 2. Transition Steps
68
- - Update Redis Coordination skill
69
- - Modify waiting mode invocation scripts
70
- - Add compatibility layer
71
- - Implement feature flag checks
72
-
73
- 3. Rollback Capabilities
74
- - Preserve original LPUSH mechanism
75
- - Configurable fallback options
@@ -1,134 +0,0 @@
1
- import redis
2
- import time
3
- import json
4
- from typing import Optional, Union, Dict
5
-
6
- class PriorityWakeMechanism:
7
- """
8
- Implements priority-based wake-up mechanism using Redis Sorted Sets
9
- Supports both legacy and new wake-up strategies
10
- """
11
-
12
- PRIORITY_MULTIPLIER = 1_000_000
13
- PRIORITY_LEVELS = {
14
- "critical": (0, 10),
15
- "high": (11, 30),
16
- "medium": (31, 60),
17
- "low": (61, 100)
18
- }
19
-
20
- def __init__(self,
21
- redis_client: redis.Redis,
22
- config_path: str = '/mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/redis-coordination/config.json'):
23
- self.redis = redis_client
24
- self.config = self._load_config(config_path)
25
-
26
- def _load_config(self, config_path: str) -> Dict:
27
- try:
28
- with open(config_path, 'r') as f:
29
- return json.load(f)
30
- except FileNotFoundError:
31
- return {"features": {"enablePriorityWake": {"default": False}}}
32
-
33
- def calculate_score(self, priority_level: str) -> float:
34
- """
35
- Calculate wake-up score based on timestamp and priority
36
-
37
- Args:
38
- priority_level (str): Priority of the wake-up message
39
-
40
- Returns:
41
- float: Calculated score for sorted set insertion
42
- """
43
- now = time.time()
44
- priority_range = self.PRIORITY_LEVELS.get(priority_level, (50, 70))
45
- priority_midpoint = sum(priority_range) / 2
46
-
47
- return now + (priority_midpoint * self.PRIORITY_MULTIPLIER)
48
-
49
- def enqueue_wake_message(
50
- self,
51
- task_id: str,
52
- agent_id: str,
53
- wake_message: str,
54
- priority_level: str = "medium"
55
- ) -> bool:
56
- """
57
- Enqueue a wake message with priority
58
-
59
- Args:
60
- task_id (str): Unique task identifier
61
- agent_id (str): Agent identifier
62
- wake_message (str): Message to be processed
63
- priority_level (str, optional): Priority of message. Defaults to "medium".
64
-
65
- Returns:
66
- bool: Whether message was successfully enqueued
67
- """
68
- if not self._is_priority_wake_enabled():
69
- # Fallback to traditional LPUSH
70
- self.redis.lpush(f"swarm:{task_id}:{agent_id}:wake", wake_message)
71
- return True
72
-
73
- score = self.calculate_score(priority_level)
74
- key = f"swarm:{task_id}:wake-queue"
75
-
76
- try:
77
- self.redis.zadd(key, {wake_message: score})
78
- return True
79
- except Exception as e:
80
- print(f"Wake message enqueue failed: {e}")
81
- return False
82
-
83
- def dequeue_wake_message(
84
- self,
85
- task_id: str,
86
- timeout: int = 0
87
- ) -> Optional[Union[str, tuple]]:
88
- """
89
- Dequeue highest priority wake message
90
-
91
- Args:
92
- task_id (str): Unique task identifier
93
- timeout (int, optional): Blocking timeout. Defaults to 0 (indefinite wait).
94
-
95
- Returns:
96
- Optional message or None if no message available
97
- """
98
- if not self._is_priority_wake_enabled():
99
- # Fallback to traditional BLPOP
100
- return self.redis.blpop(f"swarm:{task_id}:*:wake", timeout)
101
-
102
- key = f"swarm:{task_id}:wake-queue"
103
-
104
- try:
105
- result = self.redis.bzpopmin(key, timeout)
106
- return result[1] if result else None
107
- except Exception as e:
108
- print(f"Wake message dequeue failed: {e}")
109
- return None
110
-
111
- def _is_priority_wake_enabled(self) -> bool:
112
- """
113
- Check if priority wake mechanism is enabled in configuration
114
-
115
- Returns:
116
- bool: Whether priority wake is enabled
117
- """
118
- return self.config.get('features', {}).get('enablePriorityWake', {}).get('default', False)
119
-
120
- def main():
121
- # Example usage
122
- redis_client = redis.Redis(host='localhost', port=6379, db=0)
123
- pwm = PriorityWakeMechanism(redis_client)
124
-
125
- # Enqueue messages with different priorities
126
- pwm.enqueue_wake_message("task123", "agent-1", "Critical update", "critical")
127
- pwm.enqueue_wake_message("task123", "agent-2", "Standard update", "medium")
128
-
129
- # Dequeue messages (will return critical message first)
130
- message = pwm.dequeue_wake_message("task123")
131
- print(f"Received message: {message}")
132
-
133
- if __name__ == "__main__":
134
- main()
@@ -1,162 +0,0 @@
1
- #!/usr/bin/env bash
2
-
3
- ##############################################################################
4
- # Query Dead Letter Queue (DLQ)
5
- # Retrieves and displays failed agent signals from DLQ
6
- #
7
- # Usage:
8
- # ./query-dlq.sh --task-id <id> [--agent-id <id>]
9
- #
10
- # Examples:
11
- # # List all DLQ entries for a task
12
- # ./query-dlq.sh --task-id redis-phase1-1760875302
13
- #
14
- # # List DLQ entries for specific agent
15
- # ./query-dlq.sh --task-id redis-phase1-1760875302 --agent-id backend-dev-2
16
- ##############################################################################
17
-
18
- set -euo pipefail
19
-
20
- # Configuration
21
- TASK_ID=""
22
- AGENT_ID=""
23
-
24
- # Parse arguments
25
- while [[ $# -gt 0 ]]; do
26
- case $1 in
27
- --task-id)
28
- TASK_ID="$2"
29
- shift 2
30
- ;;
31
- --agent-id)
32
- AGENT_ID="$2"
33
- shift 2
34
- ;;
35
- *)
36
- echo "Unknown option: $1"
37
- exit 1
38
- ;;
39
- esac
40
- done
41
-
42
- # Validation
43
- if [ -z "$TASK_ID" ]; then
44
- echo "Error: --task-id is required"
45
- echo "Usage: $0 --task-id <id> [--agent-id <id>]"
46
- exit 1
47
- fi
48
-
49
- ##############################################################################
50
- # Query DLQ Entries
51
- ##############################################################################
52
-
53
- if [ -n "$AGENT_ID" ]; then
54
- # Query specific agent's DLQ
55
- DLQ_KEY="swarm:${TASK_ID}:dlq:${AGENT_ID}"
56
-
57
- echo "=== DLQ Entries for Agent: $AGENT_ID ==="
58
- echo "Task ID: $TASK_ID"
59
- echo ""
60
-
61
- # Check if DLQ exists
62
- EXISTS=$(redis-cli EXISTS "$DLQ_KEY")
63
-
64
- if [ "$EXISTS" = "0" ]; then
65
- echo "No DLQ entries found for agent: $AGENT_ID"
66
- exit 0
67
- fi
68
-
69
- # Get entry count
70
- ENTRY_COUNT=$(redis-cli LLEN "$DLQ_KEY")
71
-
72
- if [ "$ENTRY_COUNT" = "0" ]; then
73
- echo "No DLQ entries found for agent: $AGENT_ID"
74
- exit 0
75
- fi
76
-
77
- # Parse and display entries
78
- for i in $(seq 0 $((ENTRY_COUNT - 1))); do
79
- ENTRY=$(redis-cli LINDEX "$DLQ_KEY" "$i")
80
-
81
- if [ -n "$ENTRY" ]; then
82
- REASON=$(echo "$ENTRY" | jq -r '.reason')
83
- RETRIES=$(echo "$ENTRY" | jq -r '.retry_count')
84
- TIMESTAMP=$(echo "$ENTRY" | jq -r '.timestamp')
85
- HUMAN_TIME=$(date -d "@$TIMESTAMP" -u +"%Y-%m-%d %H:%M:%S UTC" 2>/dev/null || date -r "$TIMESTAMP" -u +"%Y-%m-%d %H:%M:%S UTC")
86
-
87
- echo "Entry #$((i + 1)):"
88
- echo " Agent: $AGENT_ID"
89
- echo " Reason: $REASON"
90
- echo " Retries: $RETRIES"
91
- echo " Timestamp: $HUMAN_TIME ($TIMESTAMP)"
92
- echo ""
93
- fi
94
- done
95
-
96
- else
97
- # Query all agents' DLQs for this task
98
- echo "=== DLQ Entries for Task: $TASK_ID ==="
99
- echo ""
100
-
101
- # Find all DLQ keys for this task
102
- DLQ_PATTERN="swarm:${TASK_ID}:dlq:*"
103
- DLQ_KEYS=$(redis-cli KEYS "$DLQ_PATTERN")
104
-
105
- if [ -z "$DLQ_KEYS" ]; then
106
- echo "No DLQ entries found for task: $TASK_ID"
107
- exit 0
108
- fi
109
-
110
- # Process each DLQ key
111
- echo "$DLQ_KEYS" | while IFS= read -r DLQ_KEY; do
112
- if [ -n "$DLQ_KEY" ]; then
113
- # Extract agent ID from key (format: swarm:task-id:dlq:agent-id)
114
- AGENT=$(echo "$DLQ_KEY" | awk -F':' '{print $NF}')
115
-
116
- # Get entry count for this agent
117
- ENTRY_COUNT=$(redis-cli LLEN "$DLQ_KEY")
118
-
119
- if [ "$ENTRY_COUNT" -gt 0 ]; then
120
- for i in $(seq 0 $((ENTRY_COUNT - 1))); do
121
- ENTRY=$(redis-cli LINDEX "$DLQ_KEY" "$i")
122
-
123
- if [ -n "$ENTRY" ]; then
124
- REASON=$(echo "$ENTRY" | jq -r '.reason')
125
- RETRIES=$(echo "$ENTRY" | jq -r '.retry_count')
126
- TIMESTAMP=$(echo "$ENTRY" | jq -r '.timestamp')
127
- HUMAN_TIME=$(date -d "@$TIMESTAMP" -u +"%Y-%m-%d %H:%M:%S UTC" 2>/dev/null || date -r "$TIMESTAMP" -u +"%Y-%m-%d %H:%M:%S UTC")
128
-
129
- echo "Agent: $AGENT (Entry #$((i + 1))/$ENTRY_COUNT)"
130
- echo " Reason: $REASON"
131
- echo " Retries: $RETRIES"
132
- echo " Timestamp: $HUMAN_TIME ($TIMESTAMP)"
133
- echo ""
134
- fi
135
- done
136
- fi
137
- fi
138
- done
139
- fi
140
-
141
- # Display summary
142
- echo "=== Summary ==="
143
- if [ -n "$AGENT_ID" ]; then
144
- DLQ_KEY="swarm:${TASK_ID}:dlq:${AGENT_ID}"
145
- TOTAL=$(redis-cli LLEN "$DLQ_KEY")
146
- echo "Total DLQ entries for $AGENT_ID: $TOTAL"
147
- else
148
- DLQ_PATTERN="swarm:${TASK_ID}:dlq:*"
149
- TOTAL_KEYS=$(redis-cli KEYS "$DLQ_PATTERN" | wc -l)
150
- echo "Total agents with DLQ entries: $TOTAL_KEYS"
151
- fi
152
-
153
- # Check TTL
154
- if [ -n "$AGENT_ID" ]; then
155
- DLQ_KEY="swarm:${TASK_ID}:dlq:${AGENT_ID}"
156
- TTL=$(redis-cli TTL "$DLQ_KEY")
157
- if [ "$TTL" -gt 0 ]; then
158
- DAYS=$((TTL / 86400))
159
- HOURS=$(((TTL % 86400) / 3600))
160
- echo "TTL remaining: ${DAYS}d ${HOURS}h"
161
- fi
162
- fi
@@ -1,103 +0,0 @@
1
- #!/bin/bash
2
- ##############################################################################
3
- # CFN Loop Log Query Tool
4
- #
5
- # Usage:
6
- # ./query-logs.sh --task-id <id> [options]
7
- #
8
- # Parameters:
9
- # --task-id Task/swarm identifier (required)
10
- # --event-type Filter by event type (optional)
11
- # --level Filter by log level: DEBUG, INFO, WARN, ERROR (optional)
12
- # --loop Filter by loop: loop3, loop2, product_owner, coordinator (optional)
13
- # --agent-id Filter by agent ID (optional)
14
- # --iteration Filter by iteration number (optional)
15
- # --limit Maximum number of results (default: 100)
16
- # --format Output format: json, csv, table (default: json)
17
- #
18
- # Examples:
19
- # # Get all logs for a task
20
- # ./query-logs.sh --task-id "cfn-task-123"
21
- #
22
- # # Get errors only
23
- # ./query-logs.sh --task-id "cfn-task-123" --level ERROR
24
- #
25
- # # Get Loop 3 agent spawns
26
- # ./query-logs.sh --task-id "cfn-task-123" --event-type agent_spawn --loop loop3
27
- #
28
- # # Get latest 10 events in table format
29
- # ./query-logs.sh --task-id "cfn-task-123" --limit 10 --format table
30
- ##############################################################################
31
-
32
- set -euo pipefail
33
-
34
- # Configuration
35
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
36
- DB_PATH="${DB_PATH:-${SCRIPT_DIR}/.claude/skills/cfn-cfn-.claude/skills/cfn-cfn-data/cfn-loop.db}"
37
-
38
- # Parameters
39
- TASK_ID=""
40
- EVENT_TYPE=""
41
- LEVEL=""
42
- LOOP=""
43
- AGENT_ID=""
44
- ITERATION=""
45
- LIMIT=100
46
- FORMAT="json"
47
-
48
- # Parse arguments
49
- while [[ $# -gt 0 ]]; do
50
- case $1 in
51
- --task-id) TASK_ID="$2"; shift 2 ;;
52
- --event-type) EVENT_TYPE="$2"; shift 2 ;;
53
- --level) LEVEL="$2"; shift 2 ;;
54
- --loop) LOOP="$2"; shift 2 ;;
55
- --agent-id) AGENT_ID="$2"; shift 2 ;;
56
- --iteration) ITERATION="$2"; shift 2 ;;
57
- --limit) LIMIT="$2"; shift 2 ;;
58
- --format) FORMAT="$2"; shift 2 ;;
59
- *) echo "Unknown option: $1" >&2; exit 1 ;;
60
- esac
61
- done
62
-
63
- # Validate required parameters
64
- if [ -z "$TASK_ID" ]; then
65
- echo "Error: --task-id is required" >&2
66
- echo "Usage: $0 --task-id <id> [--event-type <type>] [--level <level>] [--limit <n>] [--format json|csv|table]" >&2
67
- exit 1
68
- fi
69
-
70
- # Check if database exists
71
- if [ ! -f "$DB_PATH" ]; then
72
- echo "Error: Database not found at $DB_PATH" >&2
73
- echo "No logs have been written yet." >&2
74
- exit 1
75
- fi
76
-
77
- # Build query
78
- QUERY="SELECT * FROM cfn_loop_logs WHERE task_id = '$TASK_ID'"
79
-
80
- [ -n "$EVENT_TYPE" ] && QUERY="$QUERY AND event_type = '$EVENT_TYPE'"
81
- [ -n "$LEVEL" ] && QUERY="$QUERY AND level = '$LEVEL'"
82
- [ -n "$LOOP" ] && QUERY="$QUERY AND loop = '$LOOP'"
83
- [ -n "$AGENT_ID" ] && QUERY="$QUERY AND agent_id = '$AGENT_ID'"
84
- [ -n "$ITERATION" ] && QUERY="$QUERY AND iteration = $ITERATION"
85
-
86
- QUERY="$QUERY ORDER BY timestamp DESC LIMIT $LIMIT"
87
-
88
- # Execute query with selected format
89
- case "$FORMAT" in
90
- json)
91
- sqlite3 -json "$DB_PATH" "$QUERY"
92
- ;;
93
- csv)
94
- sqlite3 -csv "$DB_PATH" "$QUERY"
95
- ;;
96
- table)
97
- sqlite3 -column -header "$DB_PATH" "$QUERY"
98
- ;;
99
- *)
100
- echo "Error: Invalid format '$FORMAT'. Use: json, csv, or table" >&2
101
- exit 1
102
- ;;
103
- esac