- shell: |
# Save previous drift report for comparison
if [ -f .prodigy/documentation-drift.json ]; then
cp .prodigy/documentation-drift.json .prodigy/documentation-drift-previous.json
echo "Saved previous drift report for comparison"
else
echo "No previous drift report found, starting fresh analysis"
fi
description: "Save baseline for comparison"
- claude: "/prodigy-docs-drift-analyze"
description: "Comprehensive documentation drift analysis"
on_failure:
- shell: "echo 'Initial analysis failed'; exit 1"
- shell: |
if [ -f .prodigy/documentation-drift.json ]; then
total=$(jq '.summary.total_issues' .prodigy/documentation-drift.json)
critical=$(jq '.summary.critical' .prodigy/documentation-drift.json)
major=$(jq '.summary.major' .prodigy/documentation-drift.json)
minor=$(jq '.summary.minor' .prodigy/documentation-drift.json)
# Store original totals for threshold calculations
jq '. + {summary: (.summary + {original_total: .summary.total_issues})}' \
.prodigy/documentation-drift.json > .prodigy/tmp.json && \
mv .prodigy/tmp.json .prodigy/documentation-drift.json
echo "=== Documentation Drift Metrics ==="
echo "Total Issues: $total"
echo "Critical: $critical (must be 0)"
echo "Major: $major (target < 5)"
echo "Minor: $minor (acceptable < 20)"
# Determine update strategy based on severity
if [ "$critical" -gt 0 ]; then
echo "STRATEGY=critical" > .prodigy/update-strategy.txt
echo "🚨 Critical issues detected - immediate fix required"
elif [ "$major" -gt 10 ]; then
echo "STRATEGY=comprehensive" > .prodigy/update-strategy.txt
echo "⚠️ Many major issues - comprehensive update needed"
elif [ "$total" -gt 50 ]; then
echo "STRATEGY=incremental" > .prodigy/update-strategy.txt
echo "📝 High total drift - incremental updates recommended"
else
echo "STRATEGY=minor" > .prodigy/update-strategy.txt
echo "✅ Documentation in good shape - minor updates only"
fi
fi
description: "Analyze drift metrics and determine strategy"
output: ".prodigy/update-strategy.txt"
- shell: |
STRATEGY=$(cat .prodigy/update-strategy.txt | grep "STRATEGY=" | cut -d= -f2)
echo "Executing $STRATEGY update strategy"
description: "Load update strategy"
- claude: |
STRATEGY=$(cat .prodigy/update-strategy.txt | grep "STRATEGY=" | cut -d= -f2)
if [ "$STRATEGY" = "critical" ] || [ "$STRATEGY" = "comprehensive" ]; then
/prodigy-docs-drift-update critical only
else
echo "No critical issues to fix"
fi
description: "Fix critical issues if present"
commit_required: true
- shell: |
# Re-analyze and check critical issues are resolved
claude /prodigy-docs-drift-analyze critical > /dev/null 2>&1
if [ -f .prodigy/documentation-drift.json ]; then
critical=$(jq '.summary.critical // 0' .prodigy/documentation-drift.json)
if [ "$critical" -gt 0 ]; then
echo "Critical documentation issues still present: $critical"
exit 1
fi
fi
description: "Validate critical issues are resolved"
on_failure:
claude: "/prodigy-docs-drift-update critical force"
max_attempts: 3
fail_workflow: true commit_required: true
- claude: |
STRATEGY=$(cat .prodigy/update-strategy.txt | grep "STRATEGY=" | cut -d= -f2)
if [ "$STRATEGY" = "comprehensive" ] || [ "$STRATEGY" = "incremental" ]; then
/prodigy-docs-drift-update major
else
echo "Skipping major issues based on strategy"
fi
description: "Fix major issues based on strategy"
commit_required: true
- shell: |
# Check if major issues are reduced to acceptable level
claude /prodigy-docs-drift-analyze major > /dev/null 2>&1
if [ -f .prodigy/documentation-drift.json ]; then
major=$(jq '.summary.major // 0' .prodigy/documentation-drift.json)
total=$(jq '.summary.total_issues // 1' .prodigy/documentation-drift.json)
percentage=$((major * 100 / total))
# Major issues should be less than 30% of total
if [ "$percentage" -gt 30 ]; then
echo "Major documentation issues above threshold: ${percentage}% (target: <=30%)"
exit 1
fi
fi
description: "Validate major issues are below threshold"
on_failure:
claude: "/prodigy-docs-drift-update major focused"
max_attempts: 2
fail_workflow: false
commit_required: true
- claude: |
STRATEGY=$(cat .prodigy/update-strategy.txt | grep "STRATEGY=" | cut -d= -f2)
case "$STRATEGY" in
comprehensive)
/prodigy-docs-drift-update all
;;
incremental)
/prodigy-docs-drift-update incremental
;;
minor)
/prodigy-docs-drift-update minor only
;;
*)
echo "Documentation already in good shape"
;;
esac
description: "Fix remaining issues based on strategy"
commit_required: true
- shell: |
echo "=== Documentation Improvement Report ==="
if [ -f .prodigy/documentation-drift-previous.json ] && [ -f .prodigy/documentation-drift.json ]; then
# Compare before and after
before_total=$(jq '.summary.total_issues' .prodigy/documentation-drift-previous.json)
after_total=$(jq '.summary.total_issues' .prodigy/documentation-drift.json)
before_critical=$(jq '.summary.critical // 0' .prodigy/documentation-drift-previous.json)
after_critical=$(jq '.summary.critical // 0' .prodigy/documentation-drift.json)
before_major=$(jq '.summary.major // 0' .prodigy/documentation-drift-previous.json)
after_major=$(jq '.summary.major // 0' .prodigy/documentation-drift.json)
improvement=$((before_total - after_total))
percentage=$((improvement * 100 / (before_total + 1))) # +1 to avoid division by zero
echo "📊 Results:"
echo " Total Issues: $before_total → $after_total (improved by $improvement)"
echo " Critical: $before_critical → $after_critical"
echo " Major: $before_major → $after_major"
echo " Improvement Rate: $percentage%"
if [ "$after_critical" -eq 0 ] && [ "$after_major" -le 5 ] && [ "$after_total" -le 20 ]; then
echo ""
echo "✅ Documentation quality targets achieved!"
echo " ✓ No critical issues"
echo " ✓ Major issues ≤ 5"
echo " ✓ Total issues ≤ 20"
elif [ "$percentage" -ge 50 ]; then
echo ""
echo "👍 Significant improvement achieved (>50% reduction)"
else
echo ""
echo "📝 Documentation updated. Consider running again for further improvements."
fi
else
jq '.summary' .prodigy/documentation-drift.json
fi
# Save improvement metrics
cat > .prodigy/documentation-improvement.json << EOF
{
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
"before": ${before_total:-0},
"after": ${after_total:-0},
"improvement": ${improvement:-0},
"percentage": ${percentage:-0},
"targets_met": $([[ "$after_critical" -eq 0 && "$after_major" -le 5 && "$after_total" -le 20 ]] && echo "true" || echo "false")
}
EOF
description: "Generate improvement report"
- claude: "/prodigy-lint"
description: "Format documentation files"
commit_required: true
- shell: |
# Final quality check
if [ -f .prodigy/documentation-drift.json ]; then
critical=$(jq '.summary.critical // 0' .prodigy/documentation-drift.json)
major=$(jq '.summary.major // 0' .prodigy/documentation-drift.json)
total=$(jq '.summary.total_issues // 0' .prodigy/documentation-drift.json)
if [ "$critical" -gt 0 ]; then
echo "❌ QUALITY GATE FAILED: Critical documentation issues remain"
exit 1
elif [ "$major" -gt 10 ]; then
echo "⚠️ WARNING: $major major documentation issues remain (threshold: 10)"
echo "Consider running workflow again or manual intervention"
exit 0
elif [ "$total" -gt 50 ]; then
echo "📝 INFO: $total total documentation issues (threshold: 50)"
echo "Documentation is acceptable but could be improved"
exit 0
else
echo "✅ QUALITY GATE PASSED: Documentation meets all quality standards"
echo " Critical: $critical (target: 0) ✓"
echo " Major: $major (target: ≤10) ✓"
echo " Total: $total (target: ≤50) ✓"
exit 0
fi
fi
description: "Final quality gate check"
fail_workflow: false