claude-flow-novice 2.14.6 → 2.14.7
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/run-tests.md +119 -0
- package/.claude/hooks/cfn-post-edit.config.json +11 -4
- package/.claude/skills/cfn-agent-selector/SKILL.md +3 -2
- package/.claude/skills/cfn-loop-orchestration/orchestrate.sh +1 -1
- package/.claude/skills/cfn-product-owner-decision/execute-decision.sh +141 -114
- package/.claude/skills/cfn-redis-coordination/report-completion.sh +86 -0
- package/.claude/skills/cfn-redis-coordination/store-context.sh +34 -0
- package/.claude/skills/pre-edit-backup/backup.sh +130 -0
- package/.claude/skills/pre-edit-backup/cleanup.sh +155 -0
- package/.claude/skills/pre-edit-backup/restore.sh +128 -0
- package/.claude/skills/pre-edit-backup/revert-file.sh +168 -0
- package/claude-assets/agents/README-AGENT_LIFECYCLE.md +522 -0
- package/claude-assets/agents/cfn-dev-team/coordinators/cfn-v3-coordinator.md +6 -3
- package/claude-assets/agents/cfn-dev-team/product-owners/product-owner.md +1 -1
- package/claude-assets/agents/cfn-dev-team/test-agent.md +141 -0
- package/claude-assets/agents/cfn-dev-team/utility/agent-builder.md +35 -0
- package/claude-assets/commands/cfn/run-tests.md +119 -0
- package/claude-assets/hooks/cfn-post-edit.config.json +11 -4
- package/claude-assets/skills/agent-name-validation/README.md +28 -0
- package/claude-assets/skills/agent-name-validation/SKILL.md +168 -0
- package/claude-assets/skills/agent-name-validation/validate-agent-names.sh +47 -0
- package/claude-assets/skills/cfn-agent-selector/SKILL.md +3 -2
- package/claude-assets/skills/cfn-loop-orchestration/orchestrate.sh +1 -1
- package/claude-assets/skills/cfn-product-owner-decision/execute-decision.sh +141 -114
- package/claude-assets/skills/cfn-redis-coordination/report-completion.sh +86 -0
- package/claude-assets/skills/cfn-redis-coordination/store-context.sh +34 -0
- package/claude-assets/skills/cfn-task-classifier/SKILL.md +1 -1
- package/claude-assets/skills/cfn-test-runner/SKILL.md +288 -0
- package/claude-assets/skills/cfn-test-runner/detect-regressions.sh +55 -0
- package/claude-assets/skills/cfn-test-runner/init-benchmark-db.sh +48 -0
- package/claude-assets/skills/cfn-test-runner/run-all-tests.sh +222 -0
- package/claude-assets/skills/cfn-test-runner/store-benchmarks.sh +55 -0
- package/claude-assets/skills/cfn-test-runner/validate-redis-keys.sh +143 -0
- package/claude-assets/skills/hook-pipeline/bash-dependency-checker.sh +89 -0
- package/claude-assets/skills/hook-pipeline/bash-pipe-safety.sh +69 -0
- package/claude-assets/skills/hook-pipeline/enforce-lf.sh +36 -0
- package/claude-assets/skills/hook-pipeline/js-promise-safety.sh +110 -0
- package/claude-assets/skills/hook-pipeline/python-async-safety.py +124 -0
- package/claude-assets/skills/hook-pipeline/python-import-checker.py +114 -0
- package/claude-assets/skills/hook-pipeline/python-subprocess-safety.py +77 -0
- package/claude-assets/skills/hook-pipeline/rust-command-safety.sh +38 -0
- package/claude-assets/skills/hook-pipeline/rust-dependency-checker.sh +50 -0
- package/claude-assets/skills/hook-pipeline/rust-future-safety.sh +50 -0
- package/dist/cli/agent-executor.js +1 -1
- package/dist/cli/agent-executor.js.map +1 -1
- package/dist/cli/agent-prompt-builder.js +40 -30
- package/dist/cli/agent-prompt-builder.js.map +1 -1
- package/dist/cli/config-manager.js +109 -91
- package/dist/cli/config-manager.js.map +1 -1
- package/package.json +2 -1
- package/scripts/init-project.js +4 -1
- package/claude-assets/agents/cfn-dev-team/developers/dev-backend-api.md +0 -147
- package/claude-assets/agents/cfn-dev-team/developers/frontend/spec-mobile-react-native.md +0 -199
- package/claude-assets/agents/cfn-dev-team/documentation/docs-api-openapi.md +0 -98
- package/claude-assets/agents/cfn-dev-team/product-owners/product-owner-agent.md +0 -155
- package/claude-assets/agents/cfn-dev-team/reviewers/quality/analyze-code-quality.md +0 -141
- /package/claude-assets/agents/cfn-dev-team/developers/{backend-dev.md → backend-developer.md} +0 -0
- /package/claude-assets/agents/cfn-dev-team/documentation/{api-docs.md → api-documentation.md} +0 -0
- /package/claude-assets/agents/cfn-dev-team/documentation/{specification.md → specification-agent.md} +0 -0
- /package/claude-assets/agents/cfn-dev-team/reviewers/quality/{code-analyzer.md → code-quality-validator.md} +0 -0
- /package/claude-assets/agents/cfn-dev-team/testers/e2e/{playwright-agent.md → playwright-tester.md} +0 -0
- /package/claude-assets/agents/cfn-dev-team/testers/unit/{tdd-london-swarm.md → tdd-london-unit-swarm.md} +0 -0
- /package/claude-assets/agents/cfn-dev-team/testers/validation/{production-validator.md → validation-production-validator.md} +0 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: run-tests
|
|
3
|
+
description: Run CFN test suites with benchmarking and regression detection
|
|
4
|
+
category: testing
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Run CFN Tests
|
|
8
|
+
|
|
9
|
+
Execute CFN test suites (Hello World + CFN E2E) with automatic benchmarking and regression detection.
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
# Run all tests
|
|
15
|
+
/run-tests
|
|
16
|
+
|
|
17
|
+
# Run specific suite
|
|
18
|
+
/run-tests hello-world
|
|
19
|
+
/run-tests cfn-e2e
|
|
20
|
+
|
|
21
|
+
# With benchmarking
|
|
22
|
+
/run-tests --benchmark
|
|
23
|
+
|
|
24
|
+
# With regression detection
|
|
25
|
+
/run-tests --detect-regressions --threshold 0.10
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Execution
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
./.claude/skills/cfn-test-runner/run-all-tests.sh \
|
|
32
|
+
--suite {{arg1:-all}} \
|
|
33
|
+
{{#if benchmark}}--benchmark{{/if}} \
|
|
34
|
+
{{#if detect-regressions}}--detect-regressions --threshold {{threshold:-0.10}}{{/if}}
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Test Suites
|
|
38
|
+
|
|
39
|
+
### Hello World (4 tests)
|
|
40
|
+
- Layer 0: Tool Validation (60s)
|
|
41
|
+
- Layer 5: Coordinator Spawning (120s)
|
|
42
|
+
- Layer 6: Review Handoff (180s)
|
|
43
|
+
- Layer 7: Error Retry (150s)
|
|
44
|
+
|
|
45
|
+
### CFN E2E (9 tests)
|
|
46
|
+
- Coordinator → Orchestrator handoff
|
|
47
|
+
- Loop 3 → Gate Check
|
|
48
|
+
- Gate Pass → Loop 2
|
|
49
|
+
- Loop 2 → Product Owner
|
|
50
|
+
- Product Owner Decision
|
|
51
|
+
- Iteration Cycle
|
|
52
|
+
- Redis Key Structure
|
|
53
|
+
- Error Recovery
|
|
54
|
+
- Cleanup
|
|
55
|
+
|
|
56
|
+
## Benchmarking
|
|
57
|
+
|
|
58
|
+
Results stored in `.artifacts/test-benchmarks.db`:
|
|
59
|
+
- Test run history (30 days)
|
|
60
|
+
- Success rate trends
|
|
61
|
+
- Duration tracking
|
|
62
|
+
- Git commit correlation
|
|
63
|
+
|
|
64
|
+
## Regression Detection
|
|
65
|
+
|
|
66
|
+
Automatic alerts for:
|
|
67
|
+
- Test failures (was passing)
|
|
68
|
+
- Performance degradation (>10% slower)
|
|
69
|
+
- Success rate drops (>10% decrease)
|
|
70
|
+
|
|
71
|
+
View regressions:
|
|
72
|
+
```sql
|
|
73
|
+
sqlite3 .artifacts/test-benchmarks.db "SELECT * FROM regression_alerts WHERE acknowledged = 0"
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
## Examples
|
|
77
|
+
|
|
78
|
+
**Standard test run:**
|
|
79
|
+
```
|
|
80
|
+
/run-tests
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
**With full benchmarking:**
|
|
84
|
+
```
|
|
85
|
+
/run-tests --benchmark --detect-regressions
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
**Specific suite only:**
|
|
89
|
+
```
|
|
90
|
+
/run-tests cfn-e2e --benchmark
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Output
|
|
94
|
+
|
|
95
|
+
```
|
|
96
|
+
==========================================
|
|
97
|
+
CFN Test Suite Runner
|
|
98
|
+
==========================================
|
|
99
|
+
Suite: all
|
|
100
|
+
Benchmark: true
|
|
101
|
+
Detect Regressions: true
|
|
102
|
+
Git: main @ abc123
|
|
103
|
+
|
|
104
|
+
Hello World: 4 passed, 0 failed, 0 skipped (494s)
|
|
105
|
+
CFN E2E: 7 passed, 0 failed, 2 skipped (356s)
|
|
106
|
+
|
|
107
|
+
==========================================
|
|
108
|
+
Test Summary
|
|
109
|
+
==========================================
|
|
110
|
+
Total: 13 tests
|
|
111
|
+
Passed: 11
|
|
112
|
+
Failed: 0
|
|
113
|
+
Skipped: 2
|
|
114
|
+
Duration: 850s
|
|
115
|
+
Success Rate: 84.6%
|
|
116
|
+
|
|
117
|
+
✅ Benchmark stored (run_id: 42)
|
|
118
|
+
✅ No regressions detected
|
|
119
|
+
```
|
|
@@ -3,12 +3,14 @@
|
|
|
3
3
|
"version": "2.0.0",
|
|
4
4
|
"pipeline": "config/hooks/post-edit-pipeline.js",
|
|
5
5
|
"triggerOn": ["Edit", "Write", "MultiEdit"],
|
|
6
|
-
"fileTypes": [".ts", ".tsx", ".js", ".jsx", ".json", ".md"],
|
|
6
|
+
"fileTypes": [".ts", ".tsx", ".js", ".jsx", ".json", ".md", ".sh", ".bash", ".py", ".rs"],
|
|
7
7
|
"blocking": false,
|
|
8
8
|
"exitCodes": {
|
|
9
9
|
"0": "SUCCESS",
|
|
10
10
|
"1": "ERROR",
|
|
11
|
-
"2": "SYNTAX_ERROR"
|
|
11
|
+
"2": "SYNTAX_ERROR",
|
|
12
|
+
"9": "BASH_VALIDATOR_ERROR",
|
|
13
|
+
"10": "BASH_VALIDATOR_WARNING"
|
|
12
14
|
},
|
|
13
15
|
"redis": {
|
|
14
16
|
"enabled": true,
|
|
@@ -26,12 +28,17 @@
|
|
|
26
28
|
"enabled": true,
|
|
27
29
|
"noEmit": true,
|
|
28
30
|
"skipLibCheck": true
|
|
31
|
+
},
|
|
32
|
+
"bash": {
|
|
33
|
+
"enabled": true,
|
|
34
|
+
"validators": ["pipe-safety", "dependency-checker", "line-endings"],
|
|
35
|
+
"timeout": 5000
|
|
29
36
|
}
|
|
30
37
|
},
|
|
31
38
|
"feedback": {
|
|
32
39
|
"provideSuggestions": true,
|
|
33
40
|
"autoFixable": ["LINT_ISSUES"],
|
|
34
|
-
"nonBlocking": ["TYPE_WARNING", "LINT_ISSUES"],
|
|
35
|
-
"blocking": ["SYNTAX_ERROR"]
|
|
41
|
+
"nonBlocking": ["TYPE_WARNING", "LINT_ISSUES", "BASH_VALIDATOR_WARNING"],
|
|
42
|
+
"blocking": ["SYNTAX_ERROR", "BASH_VALIDATOR_ERROR"]
|
|
36
43
|
}
|
|
37
44
|
}
|
|
@@ -13,7 +13,7 @@ Recommends Loop 3 (producers) and Loop 2 (evaluators) agents based on:
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```bash
|
|
16
|
-
AGENTS=$(./.claude/skills/agent-selector/select-agents.sh \
|
|
16
|
+
AGENTS=$(./.claude/skills/cfn-agent-selector/select-agents.sh \
|
|
17
17
|
--task-type "software-development" \
|
|
18
18
|
--description "Implement JWT authentication with refresh tokens")
|
|
19
19
|
|
|
@@ -87,4 +87,5 @@ echo "$AGENTS" | jq '.loop2[]' # ["reviewer", "tester", "security-auditor"]
|
|
|
87
87
|
## Integration
|
|
88
88
|
|
|
89
89
|
Used by:
|
|
90
|
-
- `.claude/agents/cfn-v3-coordinator.md` - Agent selection
|
|
90
|
+
- `.claude/agents/cfn-v3-coordinator.md` - Agent selection
|
|
91
|
+
- `.claude/skills/cfn-agent-selector/select-agents.sh` - Primary selection script
|
|
@@ -635,7 +635,7 @@ function spawn_product_owner() {
|
|
|
635
635
|
# BLOCKER #2 FIX: Match execute-decision.sh actual parameters
|
|
636
636
|
# Required: --task-id, --agent-id, --consensus, --threshold, --iteration, --max-iterations
|
|
637
637
|
local decision_output
|
|
638
|
-
decision_output=$("$SCRIPT_DIR/.claude/skills/cfn-
|
|
638
|
+
decision_output=$("$SCRIPT_DIR/.claude/skills/cfn-product-owner-decision/execute-decision.sh" \
|
|
639
639
|
--task-id "$task_id" \
|
|
640
640
|
--agent-id "$PRODUCT_OWNER" \
|
|
641
641
|
--consensus "$LOOP2_FINAL_CONSENSUS" \
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
#!/bin/bash
|
|
2
|
-
# Product Owner Decision
|
|
3
|
-
#
|
|
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
|
-
|
|
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
|
|
54
|
+
echo "Unknown parameter: $1"
|
|
55
55
|
exit 1
|
|
56
56
|
;;
|
|
57
57
|
esac
|
|
@@ -60,142 +60,169 @@ 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"
|
|
64
|
-
echo "Usage: $0 --task-id
|
|
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
|
-
|
|
69
|
-
|
|
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
|
-
#
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
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
|
|
80
|
-
PO_CONTEXT="
|
|
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
|
-
|
|
84
|
+
Loop 2 Consensus: $CONSENSUS
|
|
85
|
+
Threshold: $THRESHOLD
|
|
86
|
+
Success Criteria: ${SUCCESS_CRITERIA:-"Not specified"}
|
|
83
87
|
|
|
84
|
-
|
|
85
|
-
$
|
|
88
|
+
Loop 2 Feedback:
|
|
89
|
+
$LOOP2_FEEDBACK
|
|
86
90
|
|
|
87
|
-
|
|
88
|
-
$
|
|
91
|
+
Task Context:
|
|
92
|
+
$TASK_CONTEXT
|
|
89
93
|
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
99
|
+
Output format:
|
|
100
|
+
Decision: PROCEED|ITERATE|ABORT
|
|
101
|
+
Reasoning: [your explanation]
|
|
102
|
+
Confidence: [0.0-1.0]
|
|
103
|
+
"
|
|
94
104
|
|
|
95
|
-
|
|
96
|
-
$
|
|
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"
|
|
97
108
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
Max Iterations: $MAX_ITERATIONS
|
|
109
|
+
# Use timeout from agent config
|
|
110
|
+
PO_TIMEOUT=300 # 5 minutes default
|
|
101
111
|
|
|
102
|
-
|
|
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
|
|
103
118
|
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
-
|
|
107
|
-
|
|
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
|
+
PO_OUTPUT=$(cat "$PO_OUTPUT_FILE")
|
|
108
128
|
|
|
109
|
-
|
|
110
|
-
Decision
|
|
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']
|
|
129
|
+
# Try multiple parsing patterns
|
|
130
|
+
DECISION_TYPE=$(echo "$PO_OUTPUT" | grep -oiE "Decision:\s*(PROCEED|ITERATE|ABORT)" | grep -oiE "(PROCEED|ITERATE|ABORT)" | head -1 | tr '[:lower:]' '[:upper:]' || echo "")
|
|
114
131
|
|
|
115
|
-
|
|
132
|
+
if [ -z "$DECISION_TYPE" ]; then
|
|
133
|
+
DECISION_TYPE=$(echo "$PO_OUTPUT" | grep -oE "(PROCEED|ITERATE|ABORT)" | head -1 || echo "")
|
|
134
|
+
fi
|
|
116
135
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
else
|
|
121
|
-
PO_TIMEOUT=900 # Default 15 minutes
|
|
122
|
-
fi
|
|
136
|
+
if [ -z "$DECISION_TYPE" ]; then
|
|
137
|
+
DECISION_TYPE=$(echo "$PO_OUTPUT" | grep -oiE "(proceed|iterate|abort)" | head -1 | tr '[:lower:]' '[:upper:]' || echo "")
|
|
138
|
+
fi
|
|
123
139
|
|
|
124
|
-
#
|
|
125
|
-
|
|
126
|
-
--task-id "$TASK_ID" \
|
|
127
|
-
--agent-id "$AGENT_ID" \
|
|
128
|
-
--context "$PO_CONTEXT" 2>&1 || true)
|
|
140
|
+
# Parse reasoning
|
|
141
|
+
REASONING=$(echo "$PO_OUTPUT" | grep -oiE "Reasoning:\s*.*" | sed 's/Reasoning:\s*//' || echo "No reasoning provided")
|
|
129
142
|
|
|
130
|
-
# Parse
|
|
131
|
-
|
|
143
|
+
# Parse confidence
|
|
144
|
+
CONFIDENCE=$(echo "$PO_OUTPUT" | grep -oE "Confidence:\s*[0-9]+\.?[0-9]*" | grep -oE "[0-9]+\.?[0-9]*" || echo "0.85")
|
|
145
|
+
fi
|
|
132
146
|
|
|
147
|
+
# Validate decision parsing
|
|
133
148
|
if [ -z "$DECISION_TYPE" ]; then
|
|
134
|
-
echo "❌ ERROR: Could not parse Product Owner
|
|
135
|
-
echo "
|
|
136
|
-
echo "$PO_OUTPUT"
|
|
137
|
-
|
|
138
|
-
# Fallback to ABORT on parse failure
|
|
149
|
+
echo -e "${RED}❌ ERROR: Could not parse decision from Product Owner output${NC}"
|
|
150
|
+
echo "Output sample:"
|
|
151
|
+
echo "$PO_OUTPUT" | head -20
|
|
139
152
|
DECISION_TYPE="ABORT"
|
|
140
|
-
REASONING="Failed to parse Product Owner decision
|
|
141
|
-
CONFIDENCE=0.
|
|
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
|
|
153
|
+
REASONING="Failed to parse Product Owner decision"
|
|
154
|
+
CONFIDENCE=0.0
|
|
146
155
|
fi
|
|
147
156
|
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
if [ -n "$EXPECTED_FILES" ]; then
|
|
152
|
-
DELIVERABLE_ARGS="$DELIVERABLE_ARGS --expected-files $EXPECTED_FILES"
|
|
153
|
-
fi
|
|
157
|
+
echo -e "${GREEN}✅ Product Owner Decision: $DECISION_TYPE${NC}"
|
|
158
|
+
echo "Reasoning: $REASONING"
|
|
159
|
+
echo "Confidence: $CONFIDENCE"
|
|
154
160
|
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
161
|
+
# Deliverable verification for PROCEED decisions
|
|
162
|
+
if [ "$DECISION_TYPE" = "PROCEED" ]; then
|
|
163
|
+
echo -e "${YELLOW}🔍 Verifying deliverables...${NC}"
|
|
164
|
+
|
|
165
|
+
# Check if task requires implementation (keywords: create, build, implement, generate)
|
|
166
|
+
REQUIRES_IMPLEMENTATION=$(echo "$TASK_CONTEXT" | grep -iE "(create|build|implement|generate|write|add)" || echo "")
|
|
167
|
+
|
|
168
|
+
if [ -n "$REQUIRES_IMPLEMENTATION" ]; then
|
|
169
|
+
# Check git status for file changes
|
|
170
|
+
FILES_CHANGED=$(git status --short | grep -E "^(A|M|\?\?)" | wc -l || echo "0")
|
|
171
|
+
|
|
172
|
+
if [ "$FILES_CHANGED" -eq 0 ]; then
|
|
173
|
+
echo -e "${YELLOW}⚠️ WARNING: No deliverables created (consensus on plans only)${NC}"
|
|
174
|
+
DECISION_TYPE="ITERATE"
|
|
175
|
+
REASONING="Override PROCEED → ITERATE: No files created despite implementation task. Validators approved plans without actual code."
|
|
176
|
+
CONFIDENCE=0.70
|
|
177
|
+
|
|
178
|
+
# Add deliverable requirement to feedback
|
|
179
|
+
DELIVERABLE_FEEDBACK="
|
|
180
|
+
Critical: Task requires implementation but zero files created.
|
|
181
|
+
Next iteration MUST create actual deliverables, not just plans.
|
|
182
|
+
"
|
|
183
|
+
redis-cli HSET "swarm:${TASK_ID}:loop2:consensus" "deliverable_feedback" "$DELIVERABLE_FEEDBACK"
|
|
166
184
|
else
|
|
167
|
-
|
|
185
|
+
echo -e "${GREEN}✅ Deliverables verified: $FILES_CHANGED files changed${NC}"
|
|
168
186
|
fi
|
|
169
|
-
CONFIDENCE=0.75
|
|
170
187
|
fi
|
|
171
188
|
fi
|
|
172
189
|
|
|
173
190
|
# Build decision JSON
|
|
174
|
-
DECISION_JSON=$(
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
191
|
+
DECISION_JSON=$(cat <<EOF
|
|
192
|
+
{
|
|
193
|
+
"decision": "$DECISION_TYPE",
|
|
194
|
+
"reasoning": "$REASONING",
|
|
195
|
+
"confidence": $CONFIDENCE,
|
|
196
|
+
"iteration": $ITERATION,
|
|
197
|
+
"consensus": $CONSENSUS,
|
|
198
|
+
"threshold": $THRESHOLD,
|
|
199
|
+
"timestamp": $(date +%s)
|
|
200
|
+
}
|
|
201
|
+
EOF
|
|
202
|
+
)
|
|
203
|
+
|
|
204
|
+
# Store decision in Redis
|
|
205
|
+
echo -e "${YELLOW}💾 Storing decision in Redis...${NC}"
|
|
206
|
+
redis-cli LPUSH "swarm:${TASK_ID}:decision" "$DECISION_TYPE"
|
|
207
|
+
redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" "decision" "$DECISION_TYPE"
|
|
208
|
+
redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" "reasoning" "$REASONING"
|
|
209
|
+
redis-cli HSET "swarm:${TASK_ID}:${AGENT_ID}:result" "confidence" "$CONFIDENCE"
|
|
210
|
+
|
|
211
|
+
# Store in metrics
|
|
212
|
+
redis-cli LPUSH "swarm:${TASK_ID}:metrics:product_owner_decisions" "$DECISION_JSON"
|
|
213
|
+
redis-cli INCR "swarm:metrics:decisions:$(echo "$DECISION_TYPE" | tr '[:upper:]' '[:lower:]')"
|
|
214
|
+
|
|
215
|
+
# Signal completion
|
|
216
|
+
redis-cli LPUSH "swarm:${TASK_ID}:${AGENT_ID}:done" "complete"
|
|
217
|
+
|
|
218
|
+
# Report confidence (for orchestrator collection)
|
|
219
|
+
./.claude/skills/cfn-redis-coordination/invoke-waiting-mode.sh report \
|
|
220
|
+
--task-id "$TASK_ID" \
|
|
221
|
+
--agent-id "$AGENT_ID" \
|
|
222
|
+
--confidence "$CONFIDENCE" \
|
|
223
|
+
--iteration "$ITERATION"
|
|
199
224
|
|
|
200
225
|
# Output decision JSON for orchestrator
|
|
201
226
|
echo "$DECISION_JSON"
|
|
227
|
+
|
|
228
|
+
echo -e "${GREEN}✅ Product Owner decision execution complete${NC}"
|
|
@@ -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
|