claude-flow-novice 2.15.2 → 2.15.3

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 (98) hide show
  1. package/.claude/hooks/cfn-BACKUP_USAGE.md +243 -243
  2. package/.claude/hooks/cfn-invoke-security-validation.sh +69 -69
  3. package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
  4. package/.claude/hooks/cfn-post-edit.config.json +44 -44
  5. package/.claude/skills/agent-lifecycle/SKILL.md +60 -0
  6. package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +573 -0
  7. package/.claude/skills/agent-lifecycle/simple-audit.sh +31 -0
  8. package/.claude/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
  9. package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
  10. package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
  11. package/.claude/skills/cfn-redis-coordination/get-context.sh +112 -112
  12. package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
  13. package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
  14. package/.claude/skills/cfn-transparency-middleware/test-integration.sh +161 -161
  15. package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
  16. package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
  17. package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
  18. package/claude-assets/hooks/cfn-BACKUP_USAGE.md +243 -243
  19. package/claude-assets/hooks/cfn-invoke-security-validation.sh +69 -69
  20. package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
  21. package/claude-assets/hooks/cfn-post-edit.config.json +44 -44
  22. package/claude-assets/hooks/cfn-post-execution/memory-cleanup.sh +19 -19
  23. package/claude-assets/hooks/cfn-pre-execution/memory-check.sh +19 -19
  24. package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +572 -572
  25. package/claude-assets/skills/agent-lifecycle/simple-audit.sh +30 -30
  26. package/claude-assets/skills/cfn-automatic-memory-persistence/persist-agent-output.sh +48 -48
  27. package/claude-assets/skills/cfn-automatic-memory-persistence/query-agent-history.sh +34 -34
  28. package/claude-assets/skills/cfn-deliverable-validation/confidence-calculator.sh +261 -261
  29. package/claude-assets/skills/cfn-expert-update/update-expert.sh +345 -345
  30. package/claude-assets/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
  31. package/claude-assets/skills/cfn-intervention-detector/detect-intervention.sh +110 -110
  32. package/claude-assets/skills/cfn-intervention-orchestrator/execute-intervention.sh +58 -58
  33. package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
  34. package/claude-assets/skills/cfn-loop2-output-processing/process-validator-output.sh +275 -275
  35. package/claude-assets/skills/cfn-memory-management/check-memory.sh +159 -159
  36. package/claude-assets/skills/cfn-memory-management/cleanup-memory.sh +196 -196
  37. package/claude-assets/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +325 -325
  38. package/claude-assets/skills/cfn-playbook-auto-update/auto-update-playbook.sh +85 -85
  39. package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
  40. package/claude-assets/skills/cfn-redis-coordination/get-context.sh +112 -112
  41. package/claude-assets/skills/cfn-scope-simplifier/simplify-scope.sh +67 -67
  42. package/claude-assets/skills/cfn-specialist-injection/recommend-specialist.sh +56 -56
  43. package/claude-assets/skills/cfn-standardized-error-handling/capture-agent-error.sh +86 -86
  44. package/claude-assets/skills/cfn-standardized-error-handling/test-error-handling.sh +165 -165
  45. package/claude-assets/skills/cfn-task-config-init/initialize-config.sh +264 -264
  46. package/claude-assets/skills/cfn-task-decomposition/task-decomposer.sh +278 -278
  47. package/claude-assets/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
  48. package/claude-assets/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
  49. package/claude-assets/skills/cfn-transparency-middleware/test-integration.sh +161 -161
  50. package/claude-assets/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
  51. package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
  52. package/claude-assets/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
  53. package/claude-assets/skills/docker-build/SKILL.md +96 -203
  54. package/claude-assets/skills/docker-build/build.sh +73 -73
  55. package/claude-assets/skills/integration/agent-handoff.sh +494 -0
  56. package/claude-assets/skills/integration/file-operations.sh +414 -0
  57. package/claude-assets/skills/workflow-codification/APPROVAL_WORKFLOW.md +806 -0
  58. package/claude-assets/skills/workflow-codification/COST_TRACKING.md +637 -0
  59. package/claude-assets/skills/workflow-codification/EDGE_CASE_TRACKING.md +404 -0
  60. package/claude-assets/skills/workflow-codification/README_PHASE4.md +457 -0
  61. package/claude-assets/skills/workflow-codification/SKILL.md +110 -0
  62. package/claude-assets/skills/workflow-codification/analyze-patterns.sh +899 -0
  63. package/claude-assets/skills/workflow-codification/approval-workflow.sh +514 -0
  64. package/claude-assets/skills/workflow-codification/generate-skill-update.sh +525 -0
  65. package/claude-assets/skills/workflow-codification/review-skill.sh +643 -0
  66. package/claude-assets/skills/workflow-codification/templates/email-notification.txt +114 -0
  67. package/claude-assets/skills/workflow-codification/templates/slack-notification.md +85 -0
  68. package/claude-assets/skills/workflow-codification/test-integration.sh +281 -0
  69. package/claude-assets/skills/workflow-codification/track-cost-savings.sh +445 -0
  70. package/claude-assets/skills/workflow-codification/track-edge-case.sh +323 -0
  71. package/dist/cli/config-manager.js +91 -109
  72. package/dist/cli/config-manager.js.map +1 -1
  73. package/dist/integration/DatabaseHandoff.js +507 -0
  74. package/dist/integration/DatabaseHandoff.js.map +1 -0
  75. package/dist/integration/StandardAdapter.js +291 -0
  76. package/dist/integration/StandardAdapter.js.map +1 -0
  77. package/dist/lib/agent-output-parser.js +518 -0
  78. package/dist/lib/agent-output-parser.js.map +1 -0
  79. package/dist/lib/agent-output-validator.js +950 -0
  80. package/dist/lib/agent-output-validator.js.map +1 -0
  81. package/dist/lib/artifact-registry.js +443 -0
  82. package/dist/lib/artifact-registry.js.map +1 -0
  83. package/dist/lib/config-validator.js +687 -0
  84. package/dist/lib/config-validator.js.map +1 -0
  85. package/dist/types/agent-output.js +44 -0
  86. package/dist/types/agent-output.js.map +1 -0
  87. package/dist/types/config.js +28 -0
  88. package/dist/types/config.js.map +1 -0
  89. package/package.json +2 -1
  90. package/scripts/artifact-cleanup.sh +392 -0
  91. package/scripts/deploy-production.sh +355 -355
  92. package/scripts/docker-playwright-fix.sh +311 -311
  93. package/scripts/docker-rebuild-all-agents.sh +127 -127
  94. package/scripts/memory-leak-prevention.sh +305 -305
  95. package/scripts/migrate-artifacts.sh +563 -0
  96. package/scripts/migrate-yaml-to-json.sh +465 -0
  97. package/scripts/run-marketing-tests.sh +42 -42
  98. package/scripts/update_paths.sh +46 -46
@@ -1,68 +1,68 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- # Parse arguments
5
- while [[ $# -gt 0 ]]; do
6
- case "$1" in
7
- --original-deliverables) IFS=',' read -ra DELIVERABLES <<< "$2"; shift 2 ;;
8
- --files-created) IFS=',' read -ra FILES_CREATED <<< "$2"; shift 2 ;;
9
- --iteration) ITERATION="$2"; shift 2 ;;
10
- *) echo "Unknown parameter: $1"; exit 1 ;;
11
- esac
12
- done
13
-
14
- # Simplification strategies
15
- find_critical_deliverable() {
16
- local priority_patterns=(
17
- "main.ts"
18
- "index.ts"
19
- "core.ts"
20
- "*.config.ts"
21
- "auth.ts"
22
- "base.ts"
23
- )
24
-
25
- for pattern in "${priority_patterns[@]}"; do
26
- for deliverable in "${DELIVERABLES[@]}"; do
27
- if [[ "$deliverable" == $pattern ]]; then
28
- echo "$deliverable"
29
- return
30
- fi
31
- done
32
- done
33
-
34
- # If no priority pattern, select first deliverable
35
- echo "${DELIVERABLES[0]}"
36
- }
37
-
38
- # Check if no files were created
39
- if [[ "${FILES_CREATED[0]}" == "none" ]]; then
40
- CRITICAL_DELIVERABLE=$(find_critical_deliverable)
41
-
42
- # Prepare deferred deliverables
43
- DEFERRED_DELIVERABLES=("${DELIVERABLES[@]}")
44
- for i in "${!DEFERRED_DELIVERABLES[@]}"; do
45
- if [[ "${DEFERRED_DELIVERABLES[i]}" == "$CRITICAL_DELIVERABLE" ]]; then
46
- unset 'DEFERRED_DELIVERABLES[i]'
47
- fi
48
- done
49
-
50
- jq -n \
51
- --arg critical "$CRITICAL_DELIVERABLE" \
52
- --argjson deferred "$(printf '%s\n' "${DEFERRED_DELIVERABLES[@]}" | jq -R . | jq -s '.')" \
53
- --arg iteration "$ITERATION" \
54
- '{
55
- "simplified_scope": true,
56
- "focus_deliverables": [$critical],
57
- "deferred_deliverables": $deferred,
58
- "context_injection": "FOCUS: Create ONLY \($critical) in this iteration. Prioritize its implementation. Defer other deliverables to next iterations.",
59
- "reasoning": "Agents stuck with no files created. Simplifying to single critical deliverable.",
60
- "iteration": $iteration
61
- }'
62
- else
63
- # If files were created, no intervention needed
64
- jq -n '{
65
- "simplified_scope": false,
66
- "reasoning": "Deliverables are progressing. No scope simplification required."
67
- }'
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Parse arguments
5
+ while [[ $# -gt 0 ]]; do
6
+ case "$1" in
7
+ --original-deliverables) IFS=',' read -ra DELIVERABLES <<< "$2"; shift 2 ;;
8
+ --files-created) IFS=',' read -ra FILES_CREATED <<< "$2"; shift 2 ;;
9
+ --iteration) ITERATION="$2"; shift 2 ;;
10
+ *) echo "Unknown parameter: $1"; exit 1 ;;
11
+ esac
12
+ done
13
+
14
+ # Simplification strategies
15
+ find_critical_deliverable() {
16
+ local priority_patterns=(
17
+ "main.ts"
18
+ "index.ts"
19
+ "core.ts"
20
+ "*.config.ts"
21
+ "auth.ts"
22
+ "base.ts"
23
+ )
24
+
25
+ for pattern in "${priority_patterns[@]}"; do
26
+ for deliverable in "${DELIVERABLES[@]}"; do
27
+ if [[ "$deliverable" == $pattern ]]; then
28
+ echo "$deliverable"
29
+ return
30
+ fi
31
+ done
32
+ done
33
+
34
+ # If no priority pattern, select first deliverable
35
+ echo "${DELIVERABLES[0]}"
36
+ }
37
+
38
+ # Check if no files were created
39
+ if [[ "${FILES_CREATED[0]}" == "none" ]]; then
40
+ CRITICAL_DELIVERABLE=$(find_critical_deliverable)
41
+
42
+ # Prepare deferred deliverables
43
+ DEFERRED_DELIVERABLES=("${DELIVERABLES[@]}")
44
+ for i in "${!DEFERRED_DELIVERABLES[@]}"; do
45
+ if [[ "${DEFERRED_DELIVERABLES[i]}" == "$CRITICAL_DELIVERABLE" ]]; then
46
+ unset 'DEFERRED_DELIVERABLES[i]'
47
+ fi
48
+ done
49
+
50
+ jq -n \
51
+ --arg critical "$CRITICAL_DELIVERABLE" \
52
+ --argjson deferred "$(printf '%s\n' "${DEFERRED_DELIVERABLES[@]}" | jq -R . | jq -s '.')" \
53
+ --arg iteration "$ITERATION" \
54
+ '{
55
+ "simplified_scope": true,
56
+ "focus_deliverables": [$critical],
57
+ "deferred_deliverables": $deferred,
58
+ "context_injection": "FOCUS: Create ONLY \($critical) in this iteration. Prioritize its implementation. Defer other deliverables to next iterations.",
59
+ "reasoning": "Agents stuck with no files created. Simplifying to single critical deliverable.",
60
+ "iteration": $iteration
61
+ }'
62
+ else
63
+ # If files were created, no intervention needed
64
+ jq -n '{
65
+ "simplified_scope": false,
66
+ "reasoning": "Deliverables are progressing. No scope simplification required."
67
+ }'
68
68
  fi
@@ -1,57 +1,57 @@
1
- #!/usr/bin/env bash
2
- set -euo pipefail
3
-
4
- # Parse arguments
5
- while [[ $# -gt 0 ]]; do
6
- case "$1" in
7
- --current-loop3) IFS=',' read -ra CURRENT_AGENTS <<< "$2"; shift 2 ;;
8
- --feedback-themes) IFS=',' read -ra THEMES <<< "$2"; shift 2 ;;
9
- --recurring-count) RECURRING_COUNT="$2"; shift 2 ;;
10
- *) echo "Unknown parameter: $1"; exit 1 ;;
11
- esac
12
- done
13
-
14
- # Specialist Mapping
15
- get_specialist_for_theme() {
16
- local theme="$1"
17
- case "$theme" in
18
- *security*|*authentication*|*jwt*) echo "security-specialist" ;;
19
- *performance*) echo "performance-engineer" ;;
20
- *test*|*coverage*) echo "testing-expert" ;;
21
- *architecture*) echo "architecture-consultant" ;;
22
- *) echo "" ;;
23
- esac
24
- }
25
-
26
- # Find most appropriate specialist based on recurring themes
27
- recommended_specialist=""
28
- for theme in "${THEMES[@]}"; do
29
- specialist=$(get_specialist_for_theme "$theme")
30
- if [[ -n "$specialist" ]]; then
31
- recommended_specialist="$specialist"
32
- break
33
- fi
34
- done
35
-
36
- # Validate recurring theme requirement
37
- if [[ -z "$recommended_specialist" ]] || [[ -z "${RECURRING_COUNT:-}" ]]; then
38
- echo '{"add_specialist": null, "error": "No matching specialist or missing recurring count"}' | jq .
39
- exit 1
40
- fi
41
-
42
- # Check if specialist is already in current team
43
- if [[ " ${CURRENT_AGENTS[*]} " == *" $recommended_specialist "* ]]; then
44
- echo '{"add_specialist": null, "error": "Specialist already in team"}' | jq .
45
- exit 0
46
- fi
47
-
48
- # Generate output
49
- jq -n \
50
- --arg specialist "$recommended_specialist" \
51
- --argjson current_agents "$(printf '%s\n' "${CURRENT_AGENTS[@]}" | jq -R . | jq -s '.')" \
52
- --argjson themes "$(printf '%s\n' "${THEMES[@]}" | jq -R . | jq -s '.')" \
53
- '{
54
- "add_specialist": $specialist,
55
- "reasoning": "Recurring feedback themes: \(join(", ", $themes)). Added as number of occurrences reached required threshold.",
56
- "new_loop3_agents": [$current_agents, $specialist]
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ # Parse arguments
5
+ while [[ $# -gt 0 ]]; do
6
+ case "$1" in
7
+ --current-loop3) IFS=',' read -ra CURRENT_AGENTS <<< "$2"; shift 2 ;;
8
+ --feedback-themes) IFS=',' read -ra THEMES <<< "$2"; shift 2 ;;
9
+ --recurring-count) RECURRING_COUNT="$2"; shift 2 ;;
10
+ *) echo "Unknown parameter: $1"; exit 1 ;;
11
+ esac
12
+ done
13
+
14
+ # Specialist Mapping
15
+ get_specialist_for_theme() {
16
+ local theme="$1"
17
+ case "$theme" in
18
+ *security*|*authentication*|*jwt*) echo "security-specialist" ;;
19
+ *performance*) echo "performance-engineer" ;;
20
+ *test*|*coverage*) echo "testing-expert" ;;
21
+ *architecture*) echo "architecture-consultant" ;;
22
+ *) echo "" ;;
23
+ esac
24
+ }
25
+
26
+ # Find most appropriate specialist based on recurring themes
27
+ recommended_specialist=""
28
+ for theme in "${THEMES[@]}"; do
29
+ specialist=$(get_specialist_for_theme "$theme")
30
+ if [[ -n "$specialist" ]]; then
31
+ recommended_specialist="$specialist"
32
+ break
33
+ fi
34
+ done
35
+
36
+ # Validate recurring theme requirement
37
+ if [[ -z "$recommended_specialist" ]] || [[ -z "${RECURRING_COUNT:-}" ]]; then
38
+ echo '{"add_specialist": null, "error": "No matching specialist or missing recurring count"}' | jq .
39
+ exit 1
40
+ fi
41
+
42
+ # Check if specialist is already in current team
43
+ if [[ " ${CURRENT_AGENTS[*]} " == *" $recommended_specialist "* ]]; then
44
+ echo '{"add_specialist": null, "error": "Specialist already in team"}' | jq .
45
+ exit 0
46
+ fi
47
+
48
+ # Generate output
49
+ jq -n \
50
+ --arg specialist "$recommended_specialist" \
51
+ --argjson current_agents "$(printf '%s\n' "${CURRENT_AGENTS[@]}" | jq -R . | jq -s '.')" \
52
+ --argjson themes "$(printf '%s\n' "${THEMES[@]}" | jq -R . | jq -s '.')" \
53
+ '{
54
+ "add_specialist": $specialist,
55
+ "reasoning": "Recurring feedback themes: \(join(", ", $themes)). Added as number of occurrences reached required threshold.",
56
+ "new_loop3_agents": [$current_agents, $specialist]
57
57
  }'
@@ -1,87 +1,87 @@
1
- #!/bin/bash
2
- set -euo pipefail
3
-
4
- # Mandatory error capture script for CFN Loop agents
5
- # Categorizes and logs agent failures
6
-
7
- # Argument validation
8
- if [[ $# -lt 4 ]]; then
9
- echo "Usage: $0 <AGENT_TYPE> <TASK_ID> <AGENT_ID> <EXIT_CODE> [STDERR]"
10
- exit 1
11
- fi
12
-
13
- AGENT_TYPE="$1"
14
- TASK_ID="$2"
15
- AGENT_ID="$3"
16
- EXIT_CODE="$4"
17
- STDERR="${5:-}"
18
-
19
- # Error category determination
20
- categorize_error() {
21
- local exit_code="$1"
22
- local stderr="$2"
23
-
24
- if [[ $exit_code -eq 124 ]]; then
25
- echo "TIMEOUT"
26
- elif [[ $exit_code -ne 0 ]]; then
27
- echo "CRASH"
28
- elif [[ -n "$stderr" ]]; then
29
- if echo "$stderr" | grep -qE "MODULE_NOT_FOUND|ENOENT|dependency"; then
30
- echo "DEPENDENCY_FAILURE"
31
- elif echo "$stderr" | grep -qE "invalid|unparseable|syntax error"; then
32
- echo "INVALID_OUTPUT"
33
- else
34
- echo "CRASH"
35
- fi
36
- else
37
- echo "NO_DELIVERABLES"
38
- fi
39
- }
40
-
41
- # Determine retry recommendation
42
- should_retry() {
43
- local category="$1"
44
- case "$category" in
45
- "TIMEOUT"|"CRASH")
46
- echo "true"
47
- ;;
48
- "DEPENDENCY_FAILURE"|"INVALID_OUTPUT")
49
- echo "false"
50
- ;;
51
- *)
52
- echo "false"
53
- ;;
54
- esac
55
- }
56
-
57
- # Categorize error
58
- ERROR_CATEGORY=$(categorize_error "$EXIT_CODE" "$STDERR")
59
- RETRY_RECOMMENDED=$(should_retry "$ERROR_CATEGORY")
60
-
61
- # Ensure logs directory exists
62
- mkdir -p ".claude/logs/errors"
63
-
64
- # Generate structured error report
65
- ERROR_LOG_FILE=".claude/logs/errors/${TASK_ID}_${AGENT_ID}_$(date +%Y%m%d_%H%M%S).json"
66
- cat <<EOF > "$ERROR_LOG_FILE"
67
- {
68
- "schema_version": "1.0.0",
69
- "agent_id": "$AGENT_ID",
70
- "agent_type": "$AGENT_TYPE",
71
- "task_id": "$TASK_ID",
72
- "category": "$ERROR_CATEGORY",
73
- "exit_code": $EXIT_CODE,
74
- "stderr": "$(echo "$STDERR" | base64 -w 0)",
75
- "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
76
- "retry_recommended": $RETRY_RECOMMENDED,
77
- "error_log_file": "$ERROR_LOG_FILE"
78
- }
79
- EOF
80
-
81
- # Publish error to Redis for centralized tracking
82
- redis-cli LPUSH "error_queue:$TASK_ID" "$ERROR_LOG_FILE"
83
-
84
- # Output error category for potential scripting use
85
- echo "$ERROR_CATEGORY"
86
-
1
+ #!/bin/bash
2
+ set -euo pipefail
3
+
4
+ # Mandatory error capture script for CFN Loop agents
5
+ # Categorizes and logs agent failures
6
+
7
+ # Argument validation
8
+ if [[ $# -lt 4 ]]; then
9
+ echo "Usage: $0 <AGENT_TYPE> <TASK_ID> <AGENT_ID> <EXIT_CODE> [STDERR]"
10
+ exit 1
11
+ fi
12
+
13
+ AGENT_TYPE="$1"
14
+ TASK_ID="$2"
15
+ AGENT_ID="$3"
16
+ EXIT_CODE="$4"
17
+ STDERR="${5:-}"
18
+
19
+ # Error category determination
20
+ categorize_error() {
21
+ local exit_code="$1"
22
+ local stderr="$2"
23
+
24
+ if [[ $exit_code -eq 124 ]]; then
25
+ echo "TIMEOUT"
26
+ elif [[ $exit_code -ne 0 ]]; then
27
+ echo "CRASH"
28
+ elif [[ -n "$stderr" ]]; then
29
+ if echo "$stderr" | grep -qE "MODULE_NOT_FOUND|ENOENT|dependency"; then
30
+ echo "DEPENDENCY_FAILURE"
31
+ elif echo "$stderr" | grep -qE "invalid|unparseable|syntax error"; then
32
+ echo "INVALID_OUTPUT"
33
+ else
34
+ echo "CRASH"
35
+ fi
36
+ else
37
+ echo "NO_DELIVERABLES"
38
+ fi
39
+ }
40
+
41
+ # Determine retry recommendation
42
+ should_retry() {
43
+ local category="$1"
44
+ case "$category" in
45
+ "TIMEOUT"|"CRASH")
46
+ echo "true"
47
+ ;;
48
+ "DEPENDENCY_FAILURE"|"INVALID_OUTPUT")
49
+ echo "false"
50
+ ;;
51
+ *)
52
+ echo "false"
53
+ ;;
54
+ esac
55
+ }
56
+
57
+ # Categorize error
58
+ ERROR_CATEGORY=$(categorize_error "$EXIT_CODE" "$STDERR")
59
+ RETRY_RECOMMENDED=$(should_retry "$ERROR_CATEGORY")
60
+
61
+ # Ensure logs directory exists
62
+ mkdir -p ".claude/logs/errors"
63
+
64
+ # Generate structured error report
65
+ ERROR_LOG_FILE=".claude/logs/errors/${TASK_ID}_${AGENT_ID}_$(date +%Y%m%d_%H%M%S).json"
66
+ cat <<EOF > "$ERROR_LOG_FILE"
67
+ {
68
+ "schema_version": "1.0.0",
69
+ "agent_id": "$AGENT_ID",
70
+ "agent_type": "$AGENT_TYPE",
71
+ "task_id": "$TASK_ID",
72
+ "category": "$ERROR_CATEGORY",
73
+ "exit_code": $EXIT_CODE,
74
+ "stderr": "$(echo "$STDERR" | base64 -w 0)",
75
+ "timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
76
+ "retry_recommended": $RETRY_RECOMMENDED,
77
+ "error_log_file": "$ERROR_LOG_FILE"
78
+ }
79
+ EOF
80
+
81
+ # Publish error to Redis for centralized tracking
82
+ redis-cli LPUSH "error_queue:$TASK_ID" "$ERROR_LOG_FILE"
83
+
84
+ # Output error category for potential scripting use
85
+ echo "$ERROR_CATEGORY"
86
+
87
87
  exit 0