claude-flow-novice 2.14.6 → 2.14.8

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 (66) hide show
  1. package/.claude/commands/cfn/run-tests.md +119 -0
  2. package/.claude/hooks/cfn-post-edit.config.json +11 -4
  3. package/.claude/skills/cfn-agent-selector/SKILL.md +3 -2
  4. package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +1 -1
  5. package/.claude/skills/cfn-product-owner-decision/execute-decision.sh +207 -113
  6. package/.claude/skills/cfn-product-owner-decision/test-backlog-integration.sh +148 -0
  7. package/.claude/skills/cfn-redis-coordination/report-completion.sh +86 -0
  8. package/.claude/skills/cfn-redis-coordination/store-context.sh +34 -0
  9. package/.claude/skills/pre-edit-backup/backup.sh +130 -0
  10. package/.claude/skills/pre-edit-backup/cleanup.sh +155 -0
  11. package/.claude/skills/pre-edit-backup/restore.sh +128 -0
  12. package/.claude/skills/pre-edit-backup/revert-file.sh +168 -0
  13. package/claude-assets/agents/README-AGENT_LIFECYCLE.md +522 -0
  14. package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +13 -8
  15. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -1
  16. package/claude-assets/agents/cfn-dev-team/test-agent.md +141 -0
  17. package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +35 -0
  18. package/claude-assets/commands/cfn/run-tests.md +119 -0
  19. package/claude-assets/hooks/cfn-post-edit.config.json +11 -4
  20. package/claude-assets/skills/agent-name-validation/README.md +28 -0
  21. package/claude-assets/skills/agent-name-validation/SKILL.md +168 -0
  22. package/claude-assets/skills/agent-name-validation/validate-agent-names.sh +47 -0
  23. package/claude-assets/skills/cfn-agent-selector/SKILL.md +3 -2
  24. package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +1 -1
  25. package/claude-assets/skills/cfn-product-owner-decision/execute-decision.sh +207 -113
  26. package/claude-assets/skills/cfn-product-owner-decision/test-backlog-integration.sh +148 -0
  27. package/claude-assets/skills/cfn-redis-coordination/report-completion.sh +86 -0
  28. package/claude-assets/skills/cfn-redis-coordination/store-context.sh +34 -0
  29. package/claude-assets/skills/cfn-task-classifier/SKILL.md +1 -1
  30. package/claude-assets/skills/cfn-test-runner/SKILL.md +288 -0
  31. package/claude-assets/skills/cfn-test-runner/detect-regressions.sh +55 -0
  32. package/claude-assets/skills/cfn-test-runner/init-benchmark-db.sh +48 -0
  33. package/claude-assets/skills/cfn-test-runner/run-all-tests.sh +222 -0
  34. package/claude-assets/skills/cfn-test-runner/store-benchmarks.sh +55 -0
  35. package/claude-assets/skills/cfn-test-runner/validate-redis-keys.sh +143 -0
  36. package/claude-assets/skills/hook-pipeline/bash-dependency-checker.sh +89 -0
  37. package/claude-assets/skills/hook-pipeline/bash-pipe-safety.sh +69 -0
  38. package/claude-assets/skills/hook-pipeline/enforce-lf.sh +36 -0
  39. package/claude-assets/skills/hook-pipeline/js-promise-safety.sh +110 -0
  40. package/claude-assets/skills/hook-pipeline/python-async-safety.py +124 -0
  41. package/claude-assets/skills/hook-pipeline/python-import-checker.py +114 -0
  42. package/claude-assets/skills/hook-pipeline/python-subprocess-safety.py +77 -0
  43. package/claude-assets/skills/hook-pipeline/rust-command-safety.sh +38 -0
  44. package/claude-assets/skills/hook-pipeline/rust-dependency-checker.sh +50 -0
  45. package/claude-assets/skills/hook-pipeline/rust-future-safety.sh +50 -0
  46. package/dist/agents/agent-loader.js +146 -165
  47. package/dist/agents/agent-loader.js.map +1 -1
  48. package/dist/cli/agent-executor.js +1 -1
  49. package/dist/cli/agent-executor.js.map +1 -1
  50. package/dist/cli/agent-prompt-builder.js +40 -30
  51. package/dist/cli/agent-prompt-builder.js.map +1 -1
  52. package/package.json +2 -1
  53. package/scripts/init-project.js +4 -1
  54. package/scripts/switch-api.sh +7 -7
  55. package/claude-assets/agents/cfn-dev-team/developers/dev-backend-api.md +0 -147
  56. package/claude-assets/agents/cfn-dev-team/developers/frontend/spec-mobile-react-native.md +0 -199
  57. package/claude-assets/agents/cfn-dev-team/documentation/docs-api-openapi.md +0 -98
  58. package/claude-assets/agents/cfn-dev-team/product-owners/product-owner-agent.md +0 -155
  59. package/claude-assets/agents/cfn-dev-team/reviewers/quality/analyze-code-quality.md +0 -141
  60. /package/claude-assets/agents/cfn-dev-team/developers/{backend-dev.md → backend-developer.md} +0 -0
  61. /package/claude-assets/agents/cfn-dev-team/documentation/{api-docs.md → api-documentation.md} +0 -0
  62. /package/claude-assets/agents/cfn-dev-team/documentation/{specification.md → specification-agent.md} +0 -0
  63. /package/claude-assets/agents/cfn-dev-team/reviewers/quality/{code-analyzer.md → code-quality-validator.md} +0 -0
  64. /package/claude-assets/agents/cfn-dev-team/testers/e2e/{playwright-agent.md → playwright-tester.md} +0 -0
  65. /package/claude-assets/agents/cfn-dev-team/testers/unit/{tdd-london-swarm.md → tdd-london-unit-swarm.md} +0 -0
  66. /package/claude-assets/agents/cfn-dev-team/testers/validation/{production-validator.md → validation-production-validator.md} +0 -0
@@ -1,10 +1,15 @@
1
1
  #!/bin/bash
2
- # Product Owner Decision Skill - Main Execution Wrapper
3
- # Guarantees decision execution via output parsing (solves BUG #11)
2
+ # Product Owner Decision Execution Script
3
+ # Version: 1.0.0
4
+ # Purpose: Execute Product Owner decision with guaranteed Redis coordination
4
5
 
5
6
  set -euo pipefail
6
7
 
7
- SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
8
+ # Colors for output
9
+ RED='\033[0;31m'
10
+ GREEN='\033[0;32m'
11
+ YELLOW='\033[1;33m'
12
+ NC='\033[0m'
8
13
 
9
14
  # Parse arguments
10
15
  TASK_ID=""
@@ -14,7 +19,6 @@ THRESHOLD=""
14
19
  ITERATION=""
15
20
  MAX_ITERATIONS=""
16
21
  SUCCESS_CRITERIA=""
17
- EXPECTED_FILES=""
18
22
 
19
23
  while [[ $# -gt 0 ]]; do
20
24
  case $1 in
@@ -46,12 +50,8 @@ while [[ $# -gt 0 ]]; do
46
50
  SUCCESS_CRITERIA="$2"
47
51
  shift 2
48
52
  ;;
49
- --expected-files)
50
- EXPECTED_FILES="$2"
51
- shift 2
52
- ;;
53
53
  *)
54
- echo "Unknown option: $1" >&2
54
+ echo "Unknown parameter: $1"
55
55
  exit 1
56
56
  ;;
57
57
  esac
@@ -60,142 +60,236 @@ done
60
60
  # Validate required parameters
61
61
  if [ -z "$TASK_ID" ] || [ -z "$AGENT_ID" ] || [ -z "$CONSENSUS" ] || \
62
62
  [ -z "$THRESHOLD" ] || [ -z "$ITERATION" ] || [ -z "$MAX_ITERATIONS" ]; then
63
- echo "ERROR: Missing required parameters" >&2
64
- echo "Usage: $0 --task-id TASK_ID --agent-id AGENT_ID --consensus CONSENSUS --threshold THRESHOLD --iteration ITERATION --max-iterations MAX_ITERATIONS [--success-criteria JSON]" >&2
63
+ echo -e "${RED}❌ ERROR: Missing required parameters${NC}"
64
+ echo "Usage: $0 --task-id <id> --agent-id <id> --consensus <score> --threshold <score> --iteration <num> --max-iterations <num>"
65
65
  exit 1
66
66
  fi
67
67
 
68
- # Retrieve full context from Redis (if available)
69
- REDIS_CONTEXT=$(redis-cli HGET "cfn_loop:task:${TASK_ID}:context" "full_context" 2>/dev/null || echo "{}")
68
+ echo -e "${GREEN}🎯 Product Owner Decision Execution${NC}"
69
+ echo "Task ID: $TASK_ID"
70
+ echo "Agent ID: $AGENT_ID"
71
+ echo "Consensus: $CONSENSUS"
72
+ echo "Threshold: $THRESHOLD"
73
+ echo "Iteration: $ITERATION / $MAX_ITERATIONS"
70
74
 
71
- # Extract scope from Redis context
72
- EPIC_GOAL=$(echo "$REDIS_CONTEXT" | jq -r '.epicGoal // "Task completion"')
73
- IN_SCOPE=$(echo "$REDIS_CONTEXT" | jq -r '.inScope[]?' | sed 's/^/- /' | tr '\n' '\n' || echo "- Core functionality")
74
- OUT_SCOPE=$(echo "$REDIS_CONTEXT" | jq -r '.outOfScope[]?' | sed 's/^/- /' | tr '\n' '\n' || echo "- Advanced features")
75
- DELIVERABLES=$(echo "$REDIS_CONTEXT" | jq -r '.deliverables[]?' | sed 's/^/- /' | tr '\n' '\n' || echo "- Implementation files")
76
- DIRECTORY=$(echo "$REDIS_CONTEXT" | jq -r '.directory // "."')
77
- ACCEPTANCE=$(echo "$REDIS_CONTEXT" | jq -r '.acceptanceCriteria[]?' | sed 's/^/- /' | tr '\n' '\n' || echo "- Tests pass")
75
+ # Retrieve Loop 2 context from Redis
76
+ echo -e "${YELLOW}📥 Retrieving Loop 2 context...${NC}"
77
+ LOOP2_FEEDBACK=$(redis-cli HGET "swarm:${TASK_ID}:loop2:consensus" "feedback" || echo "")
78
+ TASK_CONTEXT=$(redis-cli HGETALL "swarm:${TASK_ID}:context" || echo "")
78
79
 
79
- # Build Product Owner context with full scope information
80
- PO_CONTEXT="CFN Loop iteration $ITERATION complete.
80
+ # Build Product Owner context
81
+ PO_CONTEXT="
82
+ You are the Product Owner making a strategic decision for CFN Loop iteration $ITERATION of $MAX_ITERATIONS.
81
83
 
82
- Epic Goal: $EPIC_GOAL
84
+ Loop 2 Consensus: $CONSENSUS
85
+ Threshold: $THRESHOLD
86
+ Success Criteria: ${SUCCESS_CRITERIA:-"Not specified"}
83
87
 
84
- In-Scope:
85
- $IN_SCOPE
88
+ Loop 2 Feedback:
89
+ $LOOP2_FEEDBACK
86
90
 
87
- Out-of-Scope:
88
- $OUT_SCOPE
91
+ Task Context:
92
+ $TASK_CONTEXT
89
93
 
90
- Deliverables:
91
- $DELIVERABLES
94
+ Make a strategic decision:
95
+ - PROCEED: Quality threshold met, deliverables complete
96
+ - ITERATE: Improvements needed, iterations remaining
97
+ - ABORT: Max iterations reached or unrecoverable failure
92
98
 
93
- Directory: $DIRECTORY
94
-
95
- Acceptance Criteria:
96
- $ACCEPTANCE
99
+ Output format:
100
+ Decision: PROCEED|ITERATE|ABORT
101
+ Reasoning: [your explanation]
102
+ Confidence: [0.0-1.0]
103
+ "
97
104
 
98
- Loop 2 Consensus: $CONSENSUS (threshold: $THRESHOLD)
99
- Current Iteration: $ITERATION
100
- Max Iterations: $MAX_ITERATIONS
105
+ # Spawn Product Owner agent
106
+ echo -e "${YELLOW}🚀 Spawning Product Owner agent...${NC}"
107
+ PO_OUTPUT_FILE="/tmp/product-owner-${TASK_ID}-${ITERATION}.log"
101
108
 
102
- Make your strategic decision: PROCEED, ITERATE, or ABORT
109
+ # Use timeout from agent config
110
+ PO_TIMEOUT=300 # 5 minutes default
103
111
 
104
- Decision Framework:
105
- - PROCEED: Consensus >= $THRESHOLD AND deliverables verified AND acceptance criteria met
106
- - ITERATE: Consensus < $THRESHOLD AND iteration < $MAX_ITERATIONS
107
- - ABORT: Max iterations reached without consensus
112
+ set +e
113
+ timeout "$PO_TIMEOUT" npx claude-flow-novice agent product-owner \
114
+ --task-id "$TASK_ID" \
115
+ --context "$PO_CONTEXT" > "$PO_OUTPUT_FILE" 2>&1
116
+ PO_EXIT_CODE=$?
117
+ set -e
108
118
 
109
- Output format:
110
- Decision: [PROCEED|ITERATE|ABORT]
111
- Reasoning: [explain using GOAP framework]
112
- Confidence: [0.0-1.0]
113
- Next Action: [specific next step - 'proceed to next sprint', 'complete epic', 'iterate on current sprint']
119
+ # Check timeout
120
+ if [ $PO_EXIT_CODE -eq 124 ]; then
121
+ echo -e "${RED}❌ ERROR: Product Owner timed out after ${PO_TIMEOUT}s${NC}"
122
+ DECISION_TYPE="ABORT"
123
+ REASONING="Product Owner decision timeout after ${PO_TIMEOUT}s"
124
+ CONFIDENCE=0.0
125
+ else
126
+ # Parse decision from output
127
+ # Defensive file handling - TEST 5 fix
128
+ if [ -f "$PO_OUTPUT_FILE" ] && [ -s "$PO_OUTPUT_FILE" ]; then
129
+ PO_OUTPUT=$(cat "$PO_OUTPUT_FILE")
114
130
 
115
- CRITICAL: Do NOT ask for user confirmation. Make autonomous decision."
131
+ # Try multiple parsing patterns
132
+ DECISION_TYPE=$(echo "$PO_OUTPUT" | grep -oiE "Decision:\s*(PROCEED|ITERATE|ABORT)" | grep -oiE "(PROCEED|ITERATE|ABORT)" | head -1 | tr '[:lower:]' '[:upper:]' || echo "")
116
133
 
117
- # Get agent timeout (if get_agent_timeout function available)
118
- if command -v get_agent_timeout &>/dev/null; then
119
- PO_TIMEOUT=$(get_agent_timeout "product-owner" "$TASK_ID")
120
- else
121
- PO_TIMEOUT=900 # Default 15 minutes
122
- fi
134
+ if [ -z "$DECISION_TYPE" ]; then
135
+ DECISION_TYPE=$(echo "$PO_OUTPUT" | grep -oE "(PROCEED|ITERATE|ABORT)" | head -1 || echo "")
136
+ fi
123
137
 
124
- # Spawn Product Owner and capture output
125
- PO_OUTPUT=$(timeout "$PO_TIMEOUT" npx claude-flow-novice agent product-owner \
126
- --task-id "$TASK_ID" \
127
- --agent-id "$AGENT_ID" \
128
- --context "$PO_CONTEXT" 2>&1 || true)
138
+ if [ -z "$DECISION_TYPE" ]; then
139
+ DECISION_TYPE=$(echo "$PO_OUTPUT" | grep -oiE "(proceed|iterate|abort)" | head -1 | tr '[:lower:]' '[:upper:]' || echo "")
140
+ fi
129
141
 
130
- # Parse decision using skill parser
131
- DECISION_TYPE=$("$SCRIPT_DIR/parse-decision.sh" --output "$PO_OUTPUT")
142
+ # Parse reasoning
143
+ REASONING=$(echo "$PO_OUTPUT" | grep -oiE "Reasoning:\s*.*" | sed 's/Reasoning:\s*//' || echo "No reasoning provided")
144
+
145
+ # Parse confidence
146
+ CONFIDENCE=$(echo "$PO_OUTPUT" | grep -oE "Confidence:\s*[0-9]+\.?[0-9]*" | grep -oE "[0-9]+\.?[0-9]*" || echo "0.85")
147
+ else
148
+ echo -e "${RED}❌ ERROR: Product Owner output file missing or empty${NC}"
149
+ echo "Expected: $PO_OUTPUT_FILE"
150
+ PO_OUTPUT=""
151
+ DECISION_TYPE="ABORT"
152
+ REASONING="Product Owner output file missing or empty: $PO_OUTPUT_FILE"
153
+ CONFIDENCE=0.0
154
+ fi
155
+ fi
132
156
 
157
+ # Validate decision parsing
133
158
  if [ -z "$DECISION_TYPE" ]; then
134
- echo "❌ ERROR: Could not parse Product Owner decision" >&2
135
- echo "Product Owner output:" >&2
136
- echo "$PO_OUTPUT" >&2
137
-
138
- # Fallback to ABORT on parse failure
159
+ echo -e "${RED}❌ ERROR: Could not parse decision from Product Owner output${NC}"
160
+ echo "Output sample:"
161
+ echo "$PO_OUTPUT" | head -20
139
162
  DECISION_TYPE="ABORT"
140
- REASONING="Failed to parse Product Owner decision from output"
141
- CONFIDENCE=0.50
142
- else
143
- # Extract reasoning (context around decision)
144
- REASONING=$(echo "$PO_OUTPUT" | grep -A5 -i "decision" | tail -5 | tr '\n' ' ' | sed 's/^[[:space:]]*//;s/[[:space:]]*$//')
145
- CONFIDENCE=0.90
163
+ REASONING="Failed to parse Product Owner decision"
164
+ CONFIDENCE=0.0
146
165
  fi
147
166
 
148
- # Validate deliverables for PROCEED decisions
167
+ echo -e "${GREEN}✅ Product Owner Decision: $DECISION_TYPE${NC}"
168
+ echo "Reasoning: $REASONING"
169
+ echo "Confidence: $CONFIDENCE"
170
+
171
+ # Deliverable verification for PROCEED decisions
149
172
  if [ "$DECISION_TYPE" = "PROCEED" ]; then
150
- DELIVERABLE_ARGS="--task-id $TASK_ID"
151
- if [ -n "$EXPECTED_FILES" ]; then
152
- DELIVERABLE_ARGS="$DELIVERABLE_ARGS --expected-files $EXPECTED_FILES"
173
+ echo -e "${YELLOW}🔍 Verifying deliverables...${NC}"
174
+
175
+ # Check if task requires implementation (keywords: create, build, implement, generate)
176
+ REQUIRES_IMPLEMENTATION=$(echo "$TASK_CONTEXT" | grep -iE "(create|build|implement|generate|write|add)" || echo "")
177
+
178
+ if [ -n "$REQUIRES_IMPLEMENTATION" ]; then
179
+ # Check git status for file changes
180
+ FILES_CHANGED=$(git status --short | grep -E "^(A|M|\?\?)" | wc -l || echo "0")
181
+
182
+ if [ "$FILES_CHANGED" -eq 0 ]; then
183
+ echo -e "${YELLOW}⚠️ WARNING: No deliverables created (consensus on plans only)${NC}"
184
+ DECISION_TYPE="ITERATE"
185
+ REASONING="Override PROCEED → ITERATE: No files created despite implementation task. Validators approved plans without actual code."
186
+ CONFIDENCE=0.70
187
+
188
+ # Add deliverable requirement to feedback
189
+ DELIVERABLE_FEEDBACK="
190
+ Critical: Task requires implementation but zero files created.
191
+ Next iteration MUST create actual deliverables, not just plans.
192
+ "
193
+ redis-cli HSET "swarm:${TASK_ID}:loop2:consensus" "deliverable_feedback" "$DELIVERABLE_FEEDBACK"
194
+ else
195
+ echo -e "${GREEN}✅ Deliverables verified: $FILES_CHANGED files changed${NC}"
196
+ fi
153
197
  fi
198
+ fi
154
199
 
155
- DELIVERABLE_STATUS=$("$SCRIPT_DIR/validate-deliverables.sh" $DELIVERABLE_ARGS)
156
-
157
- if [ "$DELIVERABLE_STATUS" = "FAILED" ]; then
158
- # Retrieve missing files from Redis (if available)
159
- MISSING_FILES_JSON=$(redis-cli get "swarm:${TASK_ID}:missing-files" 2>/dev/null || echo "[]")
160
- MISSING_FILES_LIST=$(echo "$MISSING_FILES_JSON" | jq -r '.[]' | tr '\n' ', ' | sed 's/,$//')
161
-
162
- # Override PROCEED ITERATE
163
- DECISION_TYPE="ITERATE"
164
- if [ -n "$MISSING_FILES_LIST" ]; then
165
- REASONING="Deliverable verification failed - missing files: $MISSING_FILES_LIST"
200
+ # Process deferred items for backlog
201
+ echo -e "${YELLOW}📋 Processing deferred items for backlog...${NC}"
202
+
203
+ # Extract deferred items from Product Owner output
204
+ # Look for sections: "Out of Scope", "Deferred", "Future Work", "Defer"
205
+ DEFERRED_SECTION=$(echo "$PO_OUTPUT" | grep -iA 20 "out of scope\|deferred\|future work\|defer:" || echo "")
206
+
207
+ if [ -n "$DEFERRED_SECTION" ]; then
208
+ echo -e "${YELLOW}Found deferred items section, extracting items...${NC}"
209
+
210
+ # Parse deferred items (lines starting with -, *, or bullet points after marker)
211
+ DEFERRED_ITEMS=$(echo "$DEFERRED_SECTION" | grep -E "^\s*[-*•]" | sed 's/^\s*[-*•]\s*//' || echo "")
212
+
213
+ if [ -n "$DEFERRED_ITEMS" ]; then
214
+ ITEMS_ADDED=0
215
+
216
+ # Process each deferred item
217
+ while IFS= read -r item; do
218
+ # Skip empty lines or section headers
219
+ if [ -n "$item" ] && ! echo "$item" | grep -iqE "^(out of scope|deferred|future work)" && [ ${#item} -ge 10 ]; then
220
+ echo -e "${YELLOW} Adding to backlog: ${item:0:60}...${NC}"
221
+
222
+ # Invoke backlog skill (defensive - don't fail decision on backlog error)
223
+ set +e
224
+ /mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-backlog-management/add-backlog-item.sh \
225
+ --item "$item" \
226
+ --why "Deferred during Product Owner decision (Task: $TASK_ID, Iteration: $ITERATION)" \
227
+ --solution "To be determined during sprint planning" \
228
+ --priority "P2" \
229
+ --category "Technical-Debt" \
230
+ --sprint "Sprint-Backlog-$ITERATION" \
231
+ --force >/dev/null 2>&1
232
+
233
+ if [ $? -eq 0 ]; then
234
+ ITEMS_ADDED=$((ITEMS_ADDED + 1))
235
+ else
236
+ echo -e "${YELLOW} Warning: Failed to add backlog item (non-critical)${NC}" >&2
237
+ fi
238
+ set -e
239
+ fi
240
+ done <<< "$DEFERRED_ITEMS"
241
+
242
+ if [ $ITEMS_ADDED -gt 0 ]; then
243
+ echo -e "${GREEN}✅ Backlog updated with $ITEMS_ADDED deferred item(s)${NC}"
244
+
245
+ # Store backlog metadata in Redis
246
+ redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" "backlog_items_added" "$ITEMS_ADDED"
166
247
  else
167
- REASONING="Deliverable verification failed - no files created (consensus on plans only)"
248
+ echo -e "${YELLOW}⚠️ No valid backlog items extracted${NC}"
168
249
  fi
169
- CONFIDENCE=0.75
250
+ else
251
+ echo -e "${YELLOW}⚠️ Deferred section found but no items extracted${NC}"
170
252
  fi
253
+ else
254
+ echo -e "${GREEN}No deferred items detected in Product Owner output${NC}"
171
255
  fi
172
256
 
173
257
  # Build decision JSON
174
- DECISION_JSON=$(jq -n \
175
- --arg decision "$DECISION_TYPE" \
176
- --arg reasoning "${REASONING:-Parsed from Product Owner output}" \
177
- --arg confidence "$CONFIDENCE" \
178
- --arg iteration "$ITERATION" \
179
- --arg consensus "$CONSENSUS" \
180
- '{
181
- decision: $decision,
182
- reasoning: $reasoning,
183
- confidence: ($confidence | tonumber),
184
- iteration: ($iteration | tonumber),
185
- consensus: ($consensus | tonumber),
186
- timestamp: (now | todate)
187
- }')
188
-
189
- # Push decision to Redis (orchestrator's responsibility, not agent's)
190
- DECISION_KEY="swarm:${TASK_ID}:${AGENT_ID}:decision"
191
- echo "$DECISION_JSON" | redis-cli -x LPUSH "$DECISION_KEY" >/dev/null
192
-
193
- # Signal Product Owner completion
194
- redis-cli LPUSH "swarm:${TASK_ID}:${AGENT_ID}:done" "complete" >/dev/null
195
-
196
- # Store decision in metrics
197
- redis-cli LPUSH "swarm:${TASK_ID}:metrics:product_owner_decisions" "$DECISION_JSON" >/dev/null
198
- redis-cli INCR "swarm:metrics:decisions:$(echo "$DECISION_TYPE" | tr '[:upper:]' '[:lower:]')" >/dev/null
258
+ DECISION_JSON=$(cat <<EOF
259
+ {
260
+ "decision": "$DECISION_TYPE",
261
+ "reasoning": "$REASONING",
262
+ "confidence": $CONFIDENCE,
263
+ "iteration": $ITERATION,
264
+ "consensus": $CONSENSUS,
265
+ "threshold": $THRESHOLD,
266
+ "timestamp": $(date +%s)
267
+ }
268
+ EOF
269
+ )
270
+
271
+ # Store decision in Redis
272
+ echo -e "${YELLOW}💾 Storing decision in Redis...${NC}"
273
+ redis-cli LPUSH "swarm:${TASK_ID}:decision" "$DECISION_TYPE"
274
+ redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" "decision" "$DECISION_TYPE"
275
+ redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" "reasoning" "$REASONING"
276
+ redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" "confidence" "$CONFIDENCE"
277
+
278
+ # Store in metrics
279
+ redis-cli LPUSH "swarm:${TASK_ID}:metrics:product_owner_decisions" "$DECISION_JSON"
280
+ redis-cli INCR "swarm:metrics:decisions:$(echo "$DECISION_TYPE" | tr '[:upper:]' '[:lower:]')"
281
+
282
+ # Signal completion
283
+ redis-cli LPUSH "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
284
+
285
+ # Report confidence (for orchestrator collection)
286
+ ./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh report \
287
+ --task-id "$TASK_ID" \
288
+ --agent-id "$AGENT_ID" \
289
+ --confidence "$CONFIDENCE" \
290
+ --iteration "$ITERATION"
199
291
 
200
292
  # Output decision JSON for orchestrator
201
293
  echo "$DECISION_JSON"
294
+
295
+ echo -e "${GREEN}✅ Product Owner decision execution complete${NC}"
@@ -0,0 +1,148 @@
1
+ #!/bin/bash
2
+ # Test script for backlog integration in execute-decision.sh
3
+ # Version: 1.0.0
4
+ # Purpose: Verify deferred items are correctly extracted and added to backlog
5
+
6
+ set -euo pipefail
7
+
8
+ RED='\033[0;31m'
9
+ GREEN='\033[0;32m'
10
+ YELLOW='\033[1;33m'
11
+ NC='\033[0m'
12
+
13
+ echo -e "${GREEN}🧪 Testing Backlog Integration in execute-decision.sh${NC}"
14
+
15
+ # Create mock Product Owner output with deferred items
16
+ MOCK_PO_OUTPUT=$(cat <<'EOF'
17
+ Decision: PROCEED
18
+ Reasoning: All acceptance criteria met, but some items deferred for future sprints.
19
+
20
+ Out of Scope:
21
+ - Advanced logging with structured JSON format
22
+ - Performance monitoring dashboard
23
+ - Integration with external analytics platform
24
+ - Custom alert webhooks for critical events
25
+
26
+ Confidence: 0.92
27
+ EOF
28
+ )
29
+
30
+ # Test 1: Extract deferred section
31
+ echo -e "${YELLOW}Test 1: Extracting deferred section...${NC}"
32
+ DEFERRED_SECTION=$(echo "$MOCK_PO_OUTPUT" | grep -iA 20 "out of scope|deferred|future work|defer:" || echo "")
33
+
34
+ if [ -n "$DEFERRED_SECTION" ]; then
35
+ echo -e "${GREEN}✅ Deferred section extracted${NC}"
36
+ echo "Preview:"
37
+ echo "$DEFERRED_SECTION" | head -5
38
+ else
39
+ echo -e "${RED}❌ Failed to extract deferred section${NC}"
40
+ exit 1
41
+ fi
42
+
43
+ # Test 2: Parse individual items
44
+ echo -e "\n${YELLOW}Test 2: Parsing individual items...${NC}"
45
+ DEFERRED_ITEMS=$(echo "$DEFERRED_SECTION" | grep -E "^\s*[-*•]" | sed 's/^\s*[-*•]\s*//' || echo "")
46
+
47
+ if [ -n "$DEFERRED_ITEMS" ]; then
48
+ ITEM_COUNT=$(echo "$DEFERRED_ITEMS" | wc -l)
49
+ echo -e "${GREEN}✅ Extracted $ITEM_COUNT deferred items${NC}"
50
+ echo "Items:"
51
+ echo "$DEFERRED_ITEMS" | nl
52
+ else
53
+ echo -e "${RED}❌ Failed to parse individual items${NC}"
54
+ exit 1
55
+ fi
56
+
57
+ # Test 3: Validate item filtering
58
+ echo -e "\n${YELLOW}Test 3: Validating item filtering...${NC}"
59
+ VALID_ITEMS=0
60
+
61
+ while IFS= read -r item; do
62
+ # Skip empty lines or section headers
63
+ if [ -n "$item" ] && ! echo "$item" | grep -iqE "^(out of scope|deferred|future work)" && [ ${#item} -ge 10 ]; then
64
+ VALID_ITEMS=$((VALID_ITEMS + 1))
65
+ echo -e " ${GREEN}✓${NC} Valid item ($VALID_ITEMS): ${item:0:60}..."
66
+ else
67
+ echo -e " ${YELLOW}↷${NC} Filtered out: ${item:0:60}..."
68
+ fi
69
+ done <<< "$DEFERRED_ITEMS"
70
+
71
+ if [ $VALID_ITEMS -eq 4 ]; then
72
+ echo -e "${GREEN}✅ Correctly filtered to $VALID_ITEMS valid items${NC}"
73
+ else
74
+ echo -e "${YELLOW}⚠️ Expected 4 items, got $VALID_ITEMS${NC}"
75
+ fi
76
+
77
+ # Test 4: Mock backlog skill invocation (dry run)
78
+ echo -e "\n${YELLOW}Test 4: Testing backlog skill invocation (dry run)...${NC}"
79
+
80
+ # Check if backlog skill exists
81
+ BACKLOG_SKILL="/mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-backlog-management/add-backlog-item.sh"
82
+
83
+ if [ -f "$BACKLOG_SKILL" ]; then
84
+ echo -e "${GREEN}✅ Backlog skill found: $BACKLOG_SKILL${NC}"
85
+
86
+ # Test with one sample item (dry run - check parameters only)
87
+ SAMPLE_ITEM="Advanced logging with structured JSON format"
88
+
89
+ echo -e "${YELLOW} Testing parameter construction...${NC}"
90
+ echo " Command: $BACKLOG_SKILL \\"
91
+ echo " --item \"$SAMPLE_ITEM\" \\"
92
+ echo " --why \"Deferred during Product Owner decision (Task: test-task-123, Iteration: 1)\" \\"
93
+ echo " --solution \"To be determined during sprint planning\" \\"
94
+ echo " --priority \"P2\" \\"
95
+ echo " --category \"Technical-Debt\" \\"
96
+ echo " --sprint \"Sprint-Backlog-1\" \\"
97
+ echo " --force"
98
+
99
+ echo -e "${GREEN}✅ Parameter construction valid${NC}"
100
+ else
101
+ echo -e "${RED}❌ Backlog skill not found at: $BACKLOG_SKILL${NC}"
102
+ exit 1
103
+ fi
104
+
105
+ # Test 5: Integration point verification
106
+ echo -e "\n${YELLOW}Test 5: Verifying integration point in execute-decision.sh...${NC}"
107
+
108
+ SCRIPT_PATH="/mnt/c/Users/masha/Documents/claude-flow-novice/.claude/skills/cfn-product-owner-decision/execute-decision.sh"
109
+
110
+ if grep -q "Processing deferred items for backlog" "$SCRIPT_PATH"; then
111
+ echo -e "${GREEN}✅ Integration point found in execute-decision.sh${NC}"
112
+
113
+ # Check if backlog skill is invoked
114
+ if grep -q "cfn-backlog-management/add-backlog-item.sh" "$SCRIPT_PATH"; then
115
+ echo -e "${GREEN}✅ Backlog skill invocation found${NC}"
116
+ else
117
+ echo -e "${RED}❌ Backlog skill invocation missing${NC}"
118
+ exit 1
119
+ fi
120
+
121
+ # Check if error handling is present
122
+ if grep -q "set +e" "$SCRIPT_PATH" && grep -q "set -e" "$SCRIPT_PATH"; then
123
+ echo -e "${GREEN}✅ Defensive error handling found${NC}"
124
+ else
125
+ echo -e "${YELLOW}⚠️ Error handling may be missing${NC}"
126
+ fi
127
+ else
128
+ echo -e "${RED}❌ Integration point not found in execute-decision.sh${NC}"
129
+ exit 1
130
+ fi
131
+
132
+ # Summary
133
+ echo -e "\n${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
134
+ echo -e "${GREEN}✅ All tests passed!${NC}"
135
+ echo -e "${GREEN}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
136
+ echo -e "\nBacklog integration features verified:"
137
+ echo " - Deferred section extraction: ✓"
138
+ echo " - Item parsing and filtering: ✓"
139
+ echo " - Backlog skill invocation: ✓"
140
+ echo " - Integration point in execute-decision.sh: ✓"
141
+ echo " - Defensive error handling: ✓"
142
+ echo ""
143
+ echo "Expected behavior:"
144
+ echo " - When Product Owner output contains 'Out of Scope', 'Deferred', or 'Future Work' sections"
145
+ echo " - Items are extracted (lines starting with -, *, or •)"
146
+ echo " - Each item is added to readme/BACKLOG.md with P2 priority"
147
+ echo " - Metadata stored in Redis (backlog_items_added)"
148
+ echo " - Failures are non-blocking (warnings only)"
@@ -0,0 +1,86 @@
1
+ #!/bin/bash
2
+ # Report agent completion and confidence to Redis
3
+ # Replaces deprecated invoke-waiting-mode.sh for CFN Loop coordination
4
+ #
5
+ # Usage: report-completion.sh --task-id <id> --agent-id <id> --confidence <0.0-1.0> [--result <json>]
6
+
7
+ set -euo pipefail
8
+
9
+ # Parse arguments
10
+ TASK_ID=""
11
+ AGENT_ID=""
12
+ CONFIDENCE=""
13
+ RESULT=""
14
+ ITERATION="1"
15
+
16
+ while [[ $# -gt 0 ]]; do
17
+ case $1 in
18
+ --task-id)
19
+ TASK_ID="$2"
20
+ shift 2
21
+ ;;
22
+ --agent-id)
23
+ AGENT_ID="$2"
24
+ shift 2
25
+ ;;
26
+ --confidence)
27
+ CONFIDENCE="$2"
28
+ shift 2
29
+ ;;
30
+ --result)
31
+ RESULT="$2"
32
+ shift 2
33
+ ;;
34
+ --iteration)
35
+ ITERATION="$2"
36
+ shift 2
37
+ ;;
38
+ *)
39
+ echo "Unknown option: $1" >&2
40
+ exit 1
41
+ ;;
42
+ esac
43
+ done
44
+
45
+ # Validate required parameters
46
+ if [ -z "$TASK_ID" ] || [ -z "$AGENT_ID" ] || [ -z "$CONFIDENCE" ]; then
47
+ echo "Error: Missing required parameters" >&2
48
+ echo "Usage: $0 --task-id <id> --agent-id <id> --confidence <0.0-1.0> [--result <json>] [--iteration <n>]" >&2
49
+ exit 1
50
+ fi
51
+
52
+ # Validate confidence range
53
+ if ! awk -v conf="$CONFIDENCE" 'BEGIN { if (conf < 0 || conf > 1) exit 1 }'; then
54
+ echo "Error: Confidence must be between 0.0 and 1.0" >&2
55
+ exit 1
56
+ fi
57
+
58
+ # Step 1: Signal completion (LPUSH for BLPOP coordination)
59
+ redis-cli LPUSH "swarm:${TASK_ID}:${AGENT_ID}:done" "complete" > /dev/null
60
+
61
+ # Step 2: Store confidence score (STRING key for fast access)
62
+ redis-cli SET "swarm:${TASK_ID}:${AGENT_ID}:confidence" "$CONFIDENCE" EX 3600 > /dev/null
63
+
64
+ # Step 3: Store result in hash (structured data)
65
+ if [ -n "$RESULT" ]; then
66
+ redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" \
67
+ "confidence" "$CONFIDENCE" \
68
+ "iteration" "$ITERATION" \
69
+ "result" "$RESULT" \
70
+ "timestamp" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > /dev/null
71
+ else
72
+ redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" \
73
+ "confidence" "$CONFIDENCE" \
74
+ "iteration" "$ITERATION" \
75
+ "timestamp" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" > /dev/null
76
+ fi
77
+
78
+ # Step 4: Add to agent completion list (for orchestrator tracking)
79
+ redis-cli LPUSH "swarm:${TASK_ID}:completed_agents" "$AGENT_ID" > /dev/null
80
+
81
+ # Set TTL on hash
82
+ redis-cli EXPIRE "swarm:${TASK_ID}:${AGENT_ID}:result" 3600 > /dev/null
83
+ redis-cli EXPIRE "swarm:${TASK_ID}:${AGENT_ID}:done" 3600 > /dev/null
84
+
85
+ echo "✅ Reported completion for agent: $AGENT_ID (confidence: $CONFIDENCE)"
86
+ exit 0
@@ -0,0 +1,34 @@
1
+ #!/bin/bash
2
+ # Store CFN Loop task context in Redis
3
+ # Used by orchestrator to pass context to CLI-spawned agents
4
+ #
5
+ # Usage: store-context.sh <task_id> <context_json>
6
+
7
+ set -euo pipefail
8
+
9
+ TASK_ID="${1:-}"
10
+ CONTEXT="${2:-}"
11
+
12
+ if [ -z "$TASK_ID" ]; then
13
+ echo "Error: TASK_ID required" >&2
14
+ echo "Usage: $0 <task_id> <context_json>" >&2
15
+ exit 1
16
+ fi
17
+
18
+ if [ -z "$CONTEXT" ]; then
19
+ echo "Error: CONTEXT required" >&2
20
+ echo "Usage: $0 <task_id> <context_json>" >&2
21
+ exit 1
22
+ fi
23
+
24
+ # Store context in Redis
25
+ redis-cli HSET "cfn_loop:task:${TASK_ID}:context" \
26
+ "task_description" "$CONTEXT" \
27
+ "stored_at" "$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
28
+ > /dev/null
29
+
30
+ # Set TTL (24 hours)
31
+ redis-cli EXPIRE "cfn_loop:task:${TASK_ID}:context" 86400 > /dev/null
32
+
33
+ echo "✅ Context stored for task: $TASK_ID"
34
+ exit 0
@@ -91,4 +91,4 @@ classify-task.sh "Build ETL pipeline for customer data warehouse"
91
91
 
92
92
  Used by:
93
93
  - `.claude/agents/cfn-v3-coordinator.md` - Task analysis
94
- - `.claude/skills/agent-selector/select-agents.sh` - Agent recommendation
94
+ - `.claude/skills/cfn-agent-selector/select-agents.sh` - Agent recommendation