claude-flow-novice 2.15.1 â 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.
- package/.claude/cfn-extras/agents/google-sheets-specialist.md +614 -0
- package/.claude/commands/cfn/create-handoff.md +224 -0
- package/.claude/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/.claude/hooks/cfn-invoke-security-validation.sh +69 -69
- package/.claude/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/.claude/hooks/cfn-post-edit.config.json +44 -44
- package/.claude/skills/agent-lifecycle/SKILL.md +60 -0
- package/.claude/skills/agent-lifecycle/execute-lifecycle-hook.sh +573 -0
- package/.claude/skills/agent-lifecycle/simple-audit.sh +31 -0
- package/.claude/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/.claude/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/.claude/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/.claude/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/.claude/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/.claude/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/.claude/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/.claude/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/.claude/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/.claude/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/agents/cfn-dev-team/coordinators/handoff-coordinator.md +662 -0
- package/claude-assets/agents/cfn-dev-team/dev-ops/docker-specialist.md +29 -0
- package/claude-assets/cfn-extras/agents/google-sheets-specialist.md +614 -0
- package/claude-assets/commands/cfn/create-handoff.md +224 -0
- package/claude-assets/hooks/cfn-BACKUP_USAGE.md +243 -243
- package/claude-assets/hooks/cfn-invoke-security-validation.sh +69 -69
- package/claude-assets/hooks/cfn-post-edit-cfn-retrospective.sh +78 -78
- package/claude-assets/hooks/cfn-post-edit.config.json +44 -44
- package/claude-assets/hooks/cfn-post-execution/memory-cleanup.sh +19 -19
- package/claude-assets/hooks/cfn-pre-execution/memory-check.sh +19 -19
- package/claude-assets/skills/agent-lifecycle/execute-lifecycle-hook.sh +572 -572
- package/claude-assets/skills/agent-lifecycle/simple-audit.sh +30 -30
- package/claude-assets/skills/cfn-automatic-memory-persistence/persist-agent-output.sh +48 -48
- package/claude-assets/skills/cfn-automatic-memory-persistence/query-agent-history.sh +34 -34
- package/claude-assets/skills/cfn-deliverable-validation/confidence-calculator.sh +261 -261
- package/claude-assets/skills/cfn-expert-update/update-expert.sh +345 -345
- package/claude-assets/skills/cfn-hybrid-routing/check-dependencies.sh +51 -51
- package/claude-assets/skills/cfn-intervention-detector/detect-intervention.sh +110 -110
- package/claude-assets/skills/cfn-intervention-orchestrator/execute-intervention.sh +58 -58
- package/claude-assets/skills/cfn-loop-validation/orchestrate-cfn-loop.sh +252 -252
- package/claude-assets/skills/cfn-loop2-output-processing/process-validator-output.sh +275 -275
- package/claude-assets/skills/cfn-memory-management/check-memory.sh +159 -159
- package/claude-assets/skills/cfn-memory-management/cleanup-memory.sh +196 -196
- package/claude-assets/skills/cfn-node-heap-sizer/task-mode-heap-limiter.sh +325 -325
- package/claude-assets/skills/cfn-playbook-auto-update/auto-update-playbook.sh +85 -85
- package/claude-assets/skills/cfn-redis-coordination/agent-recovery.sh +74 -74
- package/claude-assets/skills/cfn-redis-coordination/get-context.sh +112 -112
- package/claude-assets/skills/cfn-scope-simplifier/simplify-scope.sh +67 -67
- package/claude-assets/skills/cfn-specialist-injection/recommend-specialist.sh +56 -56
- package/claude-assets/skills/cfn-standardized-error-handling/capture-agent-error.sh +86 -86
- package/claude-assets/skills/cfn-standardized-error-handling/test-error-handling.sh +165 -165
- package/claude-assets/skills/cfn-task-config-init/initialize-config.sh +264 -264
- package/claude-assets/skills/cfn-task-decomposition/task-decomposer.sh +278 -278
- package/claude-assets/skills/cfn-transparency-middleware/middleware-config.sh +28 -28
- package/claude-assets/skills/cfn-transparency-middleware/performance-benchmark.sh +78 -78
- package/claude-assets/skills/cfn-transparency-middleware/test-integration.sh +161 -161
- package/claude-assets/skills/cfn-transparency-middleware/test-transparency-skill.sh +367 -367
- package/claude-assets/skills/cfn-transparency-middleware/tests/input-validation.sh +92 -92
- package/claude-assets/skills/cfn-transparency-middleware/wrap-agent.sh +131 -131
- package/claude-assets/skills/docker-build/SKILL.md +96 -203
- package/claude-assets/skills/docker-build/build.sh +73 -73
- package/claude-assets/skills/integration/agent-handoff.sh +494 -0
- package/claude-assets/skills/integration/file-operations.sh +414 -0
- package/claude-assets/skills/workflow-codification/APPROVAL_WORKFLOW.md +806 -0
- package/claude-assets/skills/workflow-codification/COST_TRACKING.md +637 -0
- package/claude-assets/skills/workflow-codification/EDGE_CASE_TRACKING.md +404 -0
- package/claude-assets/skills/workflow-codification/README_PHASE4.md +457 -0
- package/claude-assets/skills/workflow-codification/SKILL.md +110 -0
- package/claude-assets/skills/workflow-codification/analyze-patterns.sh +899 -0
- package/claude-assets/skills/workflow-codification/approval-workflow.sh +514 -0
- package/claude-assets/skills/workflow-codification/generate-skill-update.sh +525 -0
- package/claude-assets/skills/workflow-codification/review-skill.sh +643 -0
- package/claude-assets/skills/workflow-codification/templates/email-notification.txt +114 -0
- package/claude-assets/skills/workflow-codification/templates/slack-notification.md +85 -0
- package/claude-assets/skills/workflow-codification/test-integration.sh +281 -0
- package/claude-assets/skills/workflow-codification/track-cost-savings.sh +445 -0
- package/claude-assets/skills/workflow-codification/track-edge-case.sh +323 -0
- package/dist/agents/agent-loader.js +165 -146
- package/dist/agents/agent-loader.js.map +1 -1
- package/dist/cli/config-manager.js +91 -109
- package/dist/cli/config-manager.js.map +1 -1
- package/dist/integration/DatabaseHandoff.js +507 -0
- package/dist/integration/DatabaseHandoff.js.map +1 -0
- package/dist/integration/StandardAdapter.js +291 -0
- package/dist/integration/StandardAdapter.js.map +1 -0
- package/dist/lib/agent-output-parser.js +518 -0
- package/dist/lib/agent-output-parser.js.map +1 -0
- package/dist/lib/agent-output-validator.js +950 -0
- package/dist/lib/agent-output-validator.js.map +1 -0
- package/dist/lib/artifact-registry.js +443 -0
- package/dist/lib/artifact-registry.js.map +1 -0
- package/dist/lib/config-validator.js +687 -0
- package/dist/lib/config-validator.js.map +1 -0
- package/dist/types/agent-output.js +44 -0
- package/dist/types/agent-output.js.map +1 -0
- package/dist/types/config.js +28 -0
- package/dist/types/config.js.map +1 -0
- package/package.json +2 -1
- package/scripts/artifact-cleanup.sh +392 -0
- package/scripts/build-linux.sh +78 -0
- package/scripts/deploy-production.sh +355 -355
- package/scripts/docker-playwright-fix.sh +311 -311
- package/scripts/docker-rebuild-all-agents.sh +127 -127
- package/scripts/memory-leak-prevention.sh +305 -305
- package/scripts/migrate-artifacts.sh +563 -0
- package/scripts/migrate-yaml-to-json.sh +465 -0
- package/scripts/run-marketing-tests.sh +42 -42
- package/scripts/update_paths.sh +46 -46
|
@@ -1,346 +1,346 @@
|
|
|
1
|
-
#!/bin/bash
|
|
2
|
-
|
|
3
|
-
# CFN Expert Update Skill
|
|
4
|
-
# Updates CFN system expert agent with relevant git commits
|
|
5
|
-
|
|
6
|
-
set -euo pipefail
|
|
7
|
-
|
|
8
|
-
# Configuration
|
|
9
|
-
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
-
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
11
|
-
AGENT_FILE="$PROJECT_ROOT/.claude/agents/custom/cfn-system-expert.md"
|
|
12
|
-
STATE_FILE="$PROJECT_ROOT/.claude/state/cfn-expert-last-commit"
|
|
13
|
-
BACKUP_DIR="$PROJECT_ROOT/.claude/backups/cfn-expert"
|
|
14
|
-
|
|
15
|
-
# Ensure directories exist
|
|
16
|
-
mkdir -p "$(dirname "$STATE_FILE")"
|
|
17
|
-
mkdir -p "$BACKUP_DIR"
|
|
18
|
-
|
|
19
|
-
# Parse arguments
|
|
20
|
-
DRY_RUN=false
|
|
21
|
-
FORCE=false
|
|
22
|
-
SINCE_COMMIT=""
|
|
23
|
-
|
|
24
|
-
while [[ $# -gt 0 ]]; do
|
|
25
|
-
case $1 in
|
|
26
|
-
--dry-run)
|
|
27
|
-
DRY_RUN=true
|
|
28
|
-
shift
|
|
29
|
-
;;
|
|
30
|
-
--force)
|
|
31
|
-
FORCE=true
|
|
32
|
-
shift
|
|
33
|
-
;;
|
|
34
|
-
--since=*)
|
|
35
|
-
SINCE_COMMIT="${1#*=}"
|
|
36
|
-
shift
|
|
37
|
-
;;
|
|
38
|
-
*)
|
|
39
|
-
echo "â Unknown parameter: $1"
|
|
40
|
-
echo "Usage: $0 [--dry-run] [--force] [--since=commit_hash]"
|
|
41
|
-
exit 1
|
|
42
|
-
;;
|
|
43
|
-
esac
|
|
44
|
-
done
|
|
45
|
-
|
|
46
|
-
# Colors for output
|
|
47
|
-
RED='\033[0;31m'
|
|
48
|
-
GREEN='\033[0;32m'
|
|
49
|
-
YELLOW='\033[1;33m'
|
|
50
|
-
BLUE='\033[0;34m'
|
|
51
|
-
NC='\033[0m' # No Color
|
|
52
|
-
|
|
53
|
-
# Logging functions
|
|
54
|
-
log_info() { echo -e "${BLUE}âšī¸ $1${NC}"; }
|
|
55
|
-
log_success() { echo -e "${GREEN}â
$1${NC}"; }
|
|
56
|
-
log_warning() { echo -e "${YELLOW}â ī¸ $1${NC}"; }
|
|
57
|
-
log_error() { echo -e "${RED}â $1${NC}"; }
|
|
58
|
-
|
|
59
|
-
# Get last scanned commit
|
|
60
|
-
get_last_commit() {
|
|
61
|
-
if [[ -n "$SINCE_COMMIT" ]]; then
|
|
62
|
-
echo "$SINCE_COMMIT"
|
|
63
|
-
elif [[ -f "$STATE_FILE" ]] && ! $FORCE; then
|
|
64
|
-
head -n1 "$STATE_FILE"
|
|
65
|
-
else
|
|
66
|
-
# Default to 10 commits back if no tracking
|
|
67
|
-
git log --format="%H" -n 10 | tail -n1
|
|
68
|
-
fi
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
# Update last commit tracking
|
|
72
|
-
update_last_commit() {
|
|
73
|
-
local commit_hash="$1"
|
|
74
|
-
local timestamp="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
75
|
-
echo "$commit_hash" > "$STATE_FILE"
|
|
76
|
-
echo "$timestamp" >> "$STATE_FILE"
|
|
77
|
-
log_success "đ Last commit updated: $commit_hash"
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
# Create backup of agent file
|
|
81
|
-
create_backup() {
|
|
82
|
-
if [[ -f "$AGENT_FILE" ]]; then
|
|
83
|
-
local timestamp=$(date +%Y%m%d_%H%M%S)
|
|
84
|
-
local backup_file="$BACKUP_DIR/${timestamp}_cfn-system-expert.md"
|
|
85
|
-
cp "$AGENT_FILE" "$backup_file"
|
|
86
|
-
log_success "đ Backup created: $backup_file"
|
|
87
|
-
echo "$backup_file"
|
|
88
|
-
fi
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
# Check if commit is relevant to CFN system
|
|
92
|
-
is_relevant_commit() {
|
|
93
|
-
local commit_hash="$1"
|
|
94
|
-
local commit_files
|
|
95
|
-
local commit_msg
|
|
96
|
-
|
|
97
|
-
# Get commit message and files
|
|
98
|
-
commit_msg=$(git log --format="%s" -n 1 "$commit_hash")
|
|
99
|
-
commit_files=$(git show --name-only --format="" "$commit_hash" | tr '\n' ' ')
|
|
100
|
-
|
|
101
|
-
# High relevance patterns
|
|
102
|
-
local high_patterns=(
|
|
103
|
-
"CLAUDE\.md"
|
|
104
|
-
"\.claude/commands/cfn/"
|
|
105
|
-
"cfn-loop"
|
|
106
|
-
"CFN Loop"
|
|
107
|
-
"claude-flow-novice"
|
|
108
|
-
)
|
|
109
|
-
|
|
110
|
-
# Medium relevance patterns
|
|
111
|
-
local medium_patterns=(
|
|
112
|
-
"\.claude/skills/cfn-"
|
|
113
|
-
"agent.*coordination"
|
|
114
|
-
"redis.*coordination"
|
|
115
|
-
"cost.*optimization"
|
|
116
|
-
"adaptive.*context"
|
|
117
|
-
"consensus"
|
|
118
|
-
"swarm"
|
|
119
|
-
)
|
|
120
|
-
|
|
121
|
-
# Low relevance patterns
|
|
122
|
-
local low_patterns=(
|
|
123
|
-
"\.claude/agents/cfn-"
|
|
124
|
-
"performance"
|
|
125
|
-
"optimization"
|
|
126
|
-
"debugging"
|
|
127
|
-
"troubleshooting"
|
|
128
|
-
)
|
|
129
|
-
|
|
130
|
-
# Check relevance
|
|
131
|
-
local relevance=0
|
|
132
|
-
local combined_check="$commit_msg $commit_files"
|
|
133
|
-
|
|
134
|
-
# High priority (always relevant)
|
|
135
|
-
for pattern in "${high_patterns[@]}"; do
|
|
136
|
-
if echo "$combined_check" | grep -qE "$pattern"; then
|
|
137
|
-
echo "high"
|
|
138
|
-
return
|
|
139
|
-
fi
|
|
140
|
-
done
|
|
141
|
-
|
|
142
|
-
# Medium priority
|
|
143
|
-
for pattern in "${medium_patterns[@]}"; do
|
|
144
|
-
if echo "$combined_check" | grep -qE "$pattern"; then
|
|
145
|
-
echo "medium"
|
|
146
|
-
return
|
|
147
|
-
fi
|
|
148
|
-
done
|
|
149
|
-
|
|
150
|
-
# Low priority
|
|
151
|
-
for pattern in "${low_patterns[@]}"; do
|
|
152
|
-
if echo "$combined_check" | grep -qE "$pattern"; then
|
|
153
|
-
echo "low"
|
|
154
|
-
return
|
|
155
|
-
fi
|
|
156
|
-
done
|
|
157
|
-
|
|
158
|
-
echo "none"
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
# Extract knowledge from commit
|
|
162
|
-
extract_commit_knowledge() {
|
|
163
|
-
local commit_hash="$1"
|
|
164
|
-
local relevance="$2"
|
|
165
|
-
local commit_msg
|
|
166
|
-
local commit_diff
|
|
167
|
-
local knowledge=""
|
|
168
|
-
|
|
169
|
-
commit_msg=$(git log --format="%s%n%b" -n 1 "$commit_hash")
|
|
170
|
-
commit_diff=$(git show "$commit_hash" -- . | head -200)
|
|
171
|
-
|
|
172
|
-
case "$relevance" in
|
|
173
|
-
"high")
|
|
174
|
-
knowledge="# HIGH PRIORITY UPDATE
|
|
175
|
-
Commit: $commit_hash
|
|
176
|
-
Message: $commit_msg
|
|
177
|
-
|
|
178
|
-
## System Changes
|
|
179
|
-
$commit_diff
|
|
180
|
-
|
|
181
|
-
## Impact
|
|
182
|
-
This commit contains critical system updates that affect CFN Loop methodology, commands, or core rules.
|
|
183
|
-
"
|
|
184
|
-
;;
|
|
185
|
-
"medium")
|
|
186
|
-
knowledge="# MEDIUM PRIORITY UPDATE
|
|
187
|
-
Commit: $commit_hash
|
|
188
|
-
Message: $commit_msg
|
|
189
|
-
|
|
190
|
-
## Process Changes
|
|
191
|
-
$commit_diff
|
|
192
|
-
|
|
193
|
-
## Impact
|
|
194
|
-
This commit updates coordination patterns, skills, or cost optimization strategies.
|
|
195
|
-
"
|
|
196
|
-
;;
|
|
197
|
-
"low")
|
|
198
|
-
knowledge="# LOW PRIORITY UPDATE
|
|
199
|
-
Commit: $commit_hash
|
|
200
|
-
Message: $commit_msg
|
|
201
|
-
|
|
202
|
-
## Informational Changes
|
|
203
|
-
$commit_diff
|
|
204
|
-
|
|
205
|
-
## Impact
|
|
206
|
-
This commit contains improvements or additions that may be useful for reference.
|
|
207
|
-
"
|
|
208
|
-
;;
|
|
209
|
-
esac
|
|
210
|
-
|
|
211
|
-
echo "$knowledge"
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
# Update agent with new knowledge
|
|
215
|
-
update_agent() {
|
|
216
|
-
local new_knowledge="$1"
|
|
217
|
-
local backup_file="$2"
|
|
218
|
-
|
|
219
|
-
if [[ "$DRY_RUN" == "true" ]]; then
|
|
220
|
-
log_info "đ DRY RUN: Would update agent with new knowledge"
|
|
221
|
-
echo "$new_knowledge" | head -20
|
|
222
|
-
log_info "đ ... (truncated in dry run)"
|
|
223
|
-
return
|
|
224
|
-
fi
|
|
225
|
-
|
|
226
|
-
# Create backup if not already created
|
|
227
|
-
if [[ -z "$backup_file" ]]; then
|
|
228
|
-
backup_file=$(create_backup)
|
|
229
|
-
fi
|
|
230
|
-
|
|
231
|
-
# Find insertion point (before "---" at end of file)
|
|
232
|
-
local temp_file=$(mktemp)
|
|
233
|
-
local inserted=false
|
|
234
|
-
|
|
235
|
-
while IFS= read -r line; do
|
|
236
|
-
echo "$line" >> "$temp_file"
|
|
237
|
-
|
|
238
|
-
# Insert new knowledge before the closing ---
|
|
239
|
-
if [[ "$line" == "---" ]] && [[ "$inserted" == "false" ]]; then
|
|
240
|
-
echo "" >> "$temp_file"
|
|
241
|
-
echo "$new_knowledge" >> "$temp_file"
|
|
242
|
-
echo "" >> "$temp_file"
|
|
243
|
-
inserted=true
|
|
244
|
-
fi
|
|
245
|
-
done < "$AGENT_FILE"
|
|
246
|
-
|
|
247
|
-
# Move temp file to agent location
|
|
248
|
-
mv "$temp_file" "$AGENT_FILE"
|
|
249
|
-
log_success "đ Expert agent updated successfully"
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
# Main execution
|
|
253
|
-
main() {
|
|
254
|
-
log_info "đ Starting CFN expert update..."
|
|
255
|
-
|
|
256
|
-
# Validate we're in a git repo
|
|
257
|
-
if ! git rev-parse --git-dir >/dev/null 2>&1; then
|
|
258
|
-
log_error "Not in a git repository"
|
|
259
|
-
exit 1
|
|
260
|
-
fi
|
|
261
|
-
|
|
262
|
-
# Check if agent file exists
|
|
263
|
-
if [[ ! -f "$AGENT_FILE" ]]; then
|
|
264
|
-
log_error "CFN system expert agent not found: $AGENT_FILE"
|
|
265
|
-
exit 1
|
|
266
|
-
fi
|
|
267
|
-
|
|
268
|
-
# Get commit range
|
|
269
|
-
local last_commit=$(get_last_commit)
|
|
270
|
-
local current_head=$(git rev-parse HEAD)
|
|
271
|
-
|
|
272
|
-
if [[ "$last_commit" == "$current_head" ]] && [[ "$FORCE" != "true" ]]; then
|
|
273
|
-
log_info "âšī¸ No new commits to scan"
|
|
274
|
-
return
|
|
275
|
-
fi
|
|
276
|
-
|
|
277
|
-
log_info "đ Scanning commits since ${last_commit:0:8}..."
|
|
278
|
-
|
|
279
|
-
# Get commits since last scan
|
|
280
|
-
local commits
|
|
281
|
-
if [[ "$FORCE" == "true" ]]; then
|
|
282
|
-
commits=$(git log --format="%H" --since="2 weeks ago" | tac)
|
|
283
|
-
else
|
|
284
|
-
commits=$(git log --format="%H" "$last_commit..HEAD" | tac)
|
|
285
|
-
fi
|
|
286
|
-
|
|
287
|
-
if [[ -z "$commits" ]]; then
|
|
288
|
-
log_info "âšī¸ No new commits found"
|
|
289
|
-
return
|
|
290
|
-
fi
|
|
291
|
-
|
|
292
|
-
local commit_count=$(echo "$commits" | wc -l)
|
|
293
|
-
log_info "đ Found $commit_count commits to analyze"
|
|
294
|
-
|
|
295
|
-
# Process commits
|
|
296
|
-
local relevant_commits=0
|
|
297
|
-
local total_knowledge=""
|
|
298
|
-
local backup_file=""
|
|
299
|
-
|
|
300
|
-
while read -r commit_hash; do
|
|
301
|
-
[[ -z "$commit_hash" ]] && continue
|
|
302
|
-
|
|
303
|
-
local relevance=$(is_relevant_commit "$commit_hash")
|
|
304
|
-
|
|
305
|
-
if [[ "$relevance" != "none" ]]; then
|
|
306
|
-
((relevant_commits++))
|
|
307
|
-
log_info "đ¯ Relevant commit found (${relevance}): ${commit_hash:0:8}"
|
|
308
|
-
|
|
309
|
-
local knowledge=$(extract_commit_knowledge "$commit_hash" "$relevance")
|
|
310
|
-
total_knowledge="${total_knowledge}${knowledge}"$'\n'
|
|
311
|
-
fi
|
|
312
|
-
done <<< "$commits"
|
|
313
|
-
|
|
314
|
-
# Report results
|
|
315
|
-
if [[ "$relevant_commits" == "0" ]]; then
|
|
316
|
-
log_info "âšī¸ No CFN-relevant changes found"
|
|
317
|
-
return
|
|
318
|
-
fi
|
|
319
|
-
|
|
320
|
-
log_info "đ Found $relevant_commits/$commit_count relevant commits"
|
|
321
|
-
|
|
322
|
-
if [[ "$DRY_RUN" == "true" ]]; then
|
|
323
|
-
log_info "đ DRY RUN MODE - No changes will be applied"
|
|
324
|
-
log_info "đĄ Run without --dry-run to apply updates"
|
|
325
|
-
echo ""
|
|
326
|
-
echo "Sample of updates that would be applied:"
|
|
327
|
-
echo "$total_knowledge" | head -50
|
|
328
|
-
return
|
|
329
|
-
fi
|
|
330
|
-
|
|
331
|
-
# Create backup before updating
|
|
332
|
-
backup_file=$(create_backup)
|
|
333
|
-
|
|
334
|
-
# Update agent with new knowledge
|
|
335
|
-
update_agent "$total_knowledge" "$backup_file"
|
|
336
|
-
|
|
337
|
-
# Update tracking
|
|
338
|
-
update_last_commit "$current_head"
|
|
339
|
-
|
|
340
|
-
log_success "đ Update complete!"
|
|
341
|
-
log_info "đ Processed $relevant_commits relevant commits"
|
|
342
|
-
log_info "đ Backup available: $backup_file"
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
# Execute main function
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
# CFN Expert Update Skill
|
|
4
|
+
# Updates CFN system expert agent with relevant git commits
|
|
5
|
+
|
|
6
|
+
set -euo pipefail
|
|
7
|
+
|
|
8
|
+
# Configuration
|
|
9
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
11
|
+
AGENT_FILE="$PROJECT_ROOT/.claude/agents/custom/cfn-system-expert.md"
|
|
12
|
+
STATE_FILE="$PROJECT_ROOT/.claude/state/cfn-expert-last-commit"
|
|
13
|
+
BACKUP_DIR="$PROJECT_ROOT/.claude/backups/cfn-expert"
|
|
14
|
+
|
|
15
|
+
# Ensure directories exist
|
|
16
|
+
mkdir -p "$(dirname "$STATE_FILE")"
|
|
17
|
+
mkdir -p "$BACKUP_DIR"
|
|
18
|
+
|
|
19
|
+
# Parse arguments
|
|
20
|
+
DRY_RUN=false
|
|
21
|
+
FORCE=false
|
|
22
|
+
SINCE_COMMIT=""
|
|
23
|
+
|
|
24
|
+
while [[ $# -gt 0 ]]; do
|
|
25
|
+
case $1 in
|
|
26
|
+
--dry-run)
|
|
27
|
+
DRY_RUN=true
|
|
28
|
+
shift
|
|
29
|
+
;;
|
|
30
|
+
--force)
|
|
31
|
+
FORCE=true
|
|
32
|
+
shift
|
|
33
|
+
;;
|
|
34
|
+
--since=*)
|
|
35
|
+
SINCE_COMMIT="${1#*=}"
|
|
36
|
+
shift
|
|
37
|
+
;;
|
|
38
|
+
*)
|
|
39
|
+
echo "â Unknown parameter: $1"
|
|
40
|
+
echo "Usage: $0 [--dry-run] [--force] [--since=commit_hash]"
|
|
41
|
+
exit 1
|
|
42
|
+
;;
|
|
43
|
+
esac
|
|
44
|
+
done
|
|
45
|
+
|
|
46
|
+
# Colors for output
|
|
47
|
+
RED='\033[0;31m'
|
|
48
|
+
GREEN='\033[0;32m'
|
|
49
|
+
YELLOW='\033[1;33m'
|
|
50
|
+
BLUE='\033[0;34m'
|
|
51
|
+
NC='\033[0m' # No Color
|
|
52
|
+
|
|
53
|
+
# Logging functions
|
|
54
|
+
log_info() { echo -e "${BLUE}âšī¸ $1${NC}"; }
|
|
55
|
+
log_success() { echo -e "${GREEN}â
$1${NC}"; }
|
|
56
|
+
log_warning() { echo -e "${YELLOW}â ī¸ $1${NC}"; }
|
|
57
|
+
log_error() { echo -e "${RED}â $1${NC}"; }
|
|
58
|
+
|
|
59
|
+
# Get last scanned commit
|
|
60
|
+
get_last_commit() {
|
|
61
|
+
if [[ -n "$SINCE_COMMIT" ]]; then
|
|
62
|
+
echo "$SINCE_COMMIT"
|
|
63
|
+
elif [[ -f "$STATE_FILE" ]] && ! $FORCE; then
|
|
64
|
+
head -n1 "$STATE_FILE"
|
|
65
|
+
else
|
|
66
|
+
# Default to 10 commits back if no tracking
|
|
67
|
+
git log --format="%H" -n 10 | tail -n1
|
|
68
|
+
fi
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Update last commit tracking
|
|
72
|
+
update_last_commit() {
|
|
73
|
+
local commit_hash="$1"
|
|
74
|
+
local timestamp="$(date -u +%Y-%m-%dT%H:%M:%SZ)"
|
|
75
|
+
echo "$commit_hash" > "$STATE_FILE"
|
|
76
|
+
echo "$timestamp" >> "$STATE_FILE"
|
|
77
|
+
log_success "đ Last commit updated: $commit_hash"
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# Create backup of agent file
|
|
81
|
+
create_backup() {
|
|
82
|
+
if [[ -f "$AGENT_FILE" ]]; then
|
|
83
|
+
local timestamp=$(date +%Y%m%d_%H%M%S)
|
|
84
|
+
local backup_file="$BACKUP_DIR/${timestamp}_cfn-system-expert.md"
|
|
85
|
+
cp "$AGENT_FILE" "$backup_file"
|
|
86
|
+
log_success "đ Backup created: $backup_file"
|
|
87
|
+
echo "$backup_file"
|
|
88
|
+
fi
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
# Check if commit is relevant to CFN system
|
|
92
|
+
is_relevant_commit() {
|
|
93
|
+
local commit_hash="$1"
|
|
94
|
+
local commit_files
|
|
95
|
+
local commit_msg
|
|
96
|
+
|
|
97
|
+
# Get commit message and files
|
|
98
|
+
commit_msg=$(git log --format="%s" -n 1 "$commit_hash")
|
|
99
|
+
commit_files=$(git show --name-only --format="" "$commit_hash" | tr '\n' ' ')
|
|
100
|
+
|
|
101
|
+
# High relevance patterns
|
|
102
|
+
local high_patterns=(
|
|
103
|
+
"CLAUDE\.md"
|
|
104
|
+
"\.claude/commands/cfn/"
|
|
105
|
+
"cfn-loop"
|
|
106
|
+
"CFN Loop"
|
|
107
|
+
"claude-flow-novice"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# Medium relevance patterns
|
|
111
|
+
local medium_patterns=(
|
|
112
|
+
"\.claude/skills/cfn-"
|
|
113
|
+
"agent.*coordination"
|
|
114
|
+
"redis.*coordination"
|
|
115
|
+
"cost.*optimization"
|
|
116
|
+
"adaptive.*context"
|
|
117
|
+
"consensus"
|
|
118
|
+
"swarm"
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
# Low relevance patterns
|
|
122
|
+
local low_patterns=(
|
|
123
|
+
"\.claude/agents/cfn-"
|
|
124
|
+
"performance"
|
|
125
|
+
"optimization"
|
|
126
|
+
"debugging"
|
|
127
|
+
"troubleshooting"
|
|
128
|
+
)
|
|
129
|
+
|
|
130
|
+
# Check relevance
|
|
131
|
+
local relevance=0
|
|
132
|
+
local combined_check="$commit_msg $commit_files"
|
|
133
|
+
|
|
134
|
+
# High priority (always relevant)
|
|
135
|
+
for pattern in "${high_patterns[@]}"; do
|
|
136
|
+
if echo "$combined_check" | grep -qE "$pattern"; then
|
|
137
|
+
echo "high"
|
|
138
|
+
return
|
|
139
|
+
fi
|
|
140
|
+
done
|
|
141
|
+
|
|
142
|
+
# Medium priority
|
|
143
|
+
for pattern in "${medium_patterns[@]}"; do
|
|
144
|
+
if echo "$combined_check" | grep -qE "$pattern"; then
|
|
145
|
+
echo "medium"
|
|
146
|
+
return
|
|
147
|
+
fi
|
|
148
|
+
done
|
|
149
|
+
|
|
150
|
+
# Low priority
|
|
151
|
+
for pattern in "${low_patterns[@]}"; do
|
|
152
|
+
if echo "$combined_check" | grep -qE "$pattern"; then
|
|
153
|
+
echo "low"
|
|
154
|
+
return
|
|
155
|
+
fi
|
|
156
|
+
done
|
|
157
|
+
|
|
158
|
+
echo "none"
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
# Extract knowledge from commit
|
|
162
|
+
extract_commit_knowledge() {
|
|
163
|
+
local commit_hash="$1"
|
|
164
|
+
local relevance="$2"
|
|
165
|
+
local commit_msg
|
|
166
|
+
local commit_diff
|
|
167
|
+
local knowledge=""
|
|
168
|
+
|
|
169
|
+
commit_msg=$(git log --format="%s%n%b" -n 1 "$commit_hash")
|
|
170
|
+
commit_diff=$(git show "$commit_hash" -- . | head -200)
|
|
171
|
+
|
|
172
|
+
case "$relevance" in
|
|
173
|
+
"high")
|
|
174
|
+
knowledge="# HIGH PRIORITY UPDATE
|
|
175
|
+
Commit: $commit_hash
|
|
176
|
+
Message: $commit_msg
|
|
177
|
+
|
|
178
|
+
## System Changes
|
|
179
|
+
$commit_diff
|
|
180
|
+
|
|
181
|
+
## Impact
|
|
182
|
+
This commit contains critical system updates that affect CFN Loop methodology, commands, or core rules.
|
|
183
|
+
"
|
|
184
|
+
;;
|
|
185
|
+
"medium")
|
|
186
|
+
knowledge="# MEDIUM PRIORITY UPDATE
|
|
187
|
+
Commit: $commit_hash
|
|
188
|
+
Message: $commit_msg
|
|
189
|
+
|
|
190
|
+
## Process Changes
|
|
191
|
+
$commit_diff
|
|
192
|
+
|
|
193
|
+
## Impact
|
|
194
|
+
This commit updates coordination patterns, skills, or cost optimization strategies.
|
|
195
|
+
"
|
|
196
|
+
;;
|
|
197
|
+
"low")
|
|
198
|
+
knowledge="# LOW PRIORITY UPDATE
|
|
199
|
+
Commit: $commit_hash
|
|
200
|
+
Message: $commit_msg
|
|
201
|
+
|
|
202
|
+
## Informational Changes
|
|
203
|
+
$commit_diff
|
|
204
|
+
|
|
205
|
+
## Impact
|
|
206
|
+
This commit contains improvements or additions that may be useful for reference.
|
|
207
|
+
"
|
|
208
|
+
;;
|
|
209
|
+
esac
|
|
210
|
+
|
|
211
|
+
echo "$knowledge"
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
# Update agent with new knowledge
|
|
215
|
+
update_agent() {
|
|
216
|
+
local new_knowledge="$1"
|
|
217
|
+
local backup_file="$2"
|
|
218
|
+
|
|
219
|
+
if [[ "$DRY_RUN" == "true" ]]; then
|
|
220
|
+
log_info "đ DRY RUN: Would update agent with new knowledge"
|
|
221
|
+
echo "$new_knowledge" | head -20
|
|
222
|
+
log_info "đ ... (truncated in dry run)"
|
|
223
|
+
return
|
|
224
|
+
fi
|
|
225
|
+
|
|
226
|
+
# Create backup if not already created
|
|
227
|
+
if [[ -z "$backup_file" ]]; then
|
|
228
|
+
backup_file=$(create_backup)
|
|
229
|
+
fi
|
|
230
|
+
|
|
231
|
+
# Find insertion point (before "---" at end of file)
|
|
232
|
+
local temp_file=$(mktemp)
|
|
233
|
+
local inserted=false
|
|
234
|
+
|
|
235
|
+
while IFS= read -r line; do
|
|
236
|
+
echo "$line" >> "$temp_file"
|
|
237
|
+
|
|
238
|
+
# Insert new knowledge before the closing ---
|
|
239
|
+
if [[ "$line" == "---" ]] && [[ "$inserted" == "false" ]]; then
|
|
240
|
+
echo "" >> "$temp_file"
|
|
241
|
+
echo "$new_knowledge" >> "$temp_file"
|
|
242
|
+
echo "" >> "$temp_file"
|
|
243
|
+
inserted=true
|
|
244
|
+
fi
|
|
245
|
+
done < "$AGENT_FILE"
|
|
246
|
+
|
|
247
|
+
# Move temp file to agent location
|
|
248
|
+
mv "$temp_file" "$AGENT_FILE"
|
|
249
|
+
log_success "đ Expert agent updated successfully"
|
|
250
|
+
}
|
|
251
|
+
|
|
252
|
+
# Main execution
|
|
253
|
+
main() {
|
|
254
|
+
log_info "đ Starting CFN expert update..."
|
|
255
|
+
|
|
256
|
+
# Validate we're in a git repo
|
|
257
|
+
if ! git rev-parse --git-dir >/dev/null 2>&1; then
|
|
258
|
+
log_error "Not in a git repository"
|
|
259
|
+
exit 1
|
|
260
|
+
fi
|
|
261
|
+
|
|
262
|
+
# Check if agent file exists
|
|
263
|
+
if [[ ! -f "$AGENT_FILE" ]]; then
|
|
264
|
+
log_error "CFN system expert agent not found: $AGENT_FILE"
|
|
265
|
+
exit 1
|
|
266
|
+
fi
|
|
267
|
+
|
|
268
|
+
# Get commit range
|
|
269
|
+
local last_commit=$(get_last_commit)
|
|
270
|
+
local current_head=$(git rev-parse HEAD)
|
|
271
|
+
|
|
272
|
+
if [[ "$last_commit" == "$current_head" ]] && [[ "$FORCE" != "true" ]]; then
|
|
273
|
+
log_info "âšī¸ No new commits to scan"
|
|
274
|
+
return
|
|
275
|
+
fi
|
|
276
|
+
|
|
277
|
+
log_info "đ Scanning commits since ${last_commit:0:8}..."
|
|
278
|
+
|
|
279
|
+
# Get commits since last scan
|
|
280
|
+
local commits
|
|
281
|
+
if [[ "$FORCE" == "true" ]]; then
|
|
282
|
+
commits=$(git log --format="%H" --since="2 weeks ago" | tac)
|
|
283
|
+
else
|
|
284
|
+
commits=$(git log --format="%H" "$last_commit..HEAD" | tac)
|
|
285
|
+
fi
|
|
286
|
+
|
|
287
|
+
if [[ -z "$commits" ]]; then
|
|
288
|
+
log_info "âšī¸ No new commits found"
|
|
289
|
+
return
|
|
290
|
+
fi
|
|
291
|
+
|
|
292
|
+
local commit_count=$(echo "$commits" | wc -l)
|
|
293
|
+
log_info "đ Found $commit_count commits to analyze"
|
|
294
|
+
|
|
295
|
+
# Process commits
|
|
296
|
+
local relevant_commits=0
|
|
297
|
+
local total_knowledge=""
|
|
298
|
+
local backup_file=""
|
|
299
|
+
|
|
300
|
+
while read -r commit_hash; do
|
|
301
|
+
[[ -z "$commit_hash" ]] && continue
|
|
302
|
+
|
|
303
|
+
local relevance=$(is_relevant_commit "$commit_hash")
|
|
304
|
+
|
|
305
|
+
if [[ "$relevance" != "none" ]]; then
|
|
306
|
+
((relevant_commits++))
|
|
307
|
+
log_info "đ¯ Relevant commit found (${relevance}): ${commit_hash:0:8}"
|
|
308
|
+
|
|
309
|
+
local knowledge=$(extract_commit_knowledge "$commit_hash" "$relevance")
|
|
310
|
+
total_knowledge="${total_knowledge}${knowledge}"$'\n'
|
|
311
|
+
fi
|
|
312
|
+
done <<< "$commits"
|
|
313
|
+
|
|
314
|
+
# Report results
|
|
315
|
+
if [[ "$relevant_commits" == "0" ]]; then
|
|
316
|
+
log_info "âšī¸ No CFN-relevant changes found"
|
|
317
|
+
return
|
|
318
|
+
fi
|
|
319
|
+
|
|
320
|
+
log_info "đ Found $relevant_commits/$commit_count relevant commits"
|
|
321
|
+
|
|
322
|
+
if [[ "$DRY_RUN" == "true" ]]; then
|
|
323
|
+
log_info "đ DRY RUN MODE - No changes will be applied"
|
|
324
|
+
log_info "đĄ Run without --dry-run to apply updates"
|
|
325
|
+
echo ""
|
|
326
|
+
echo "Sample of updates that would be applied:"
|
|
327
|
+
echo "$total_knowledge" | head -50
|
|
328
|
+
return
|
|
329
|
+
fi
|
|
330
|
+
|
|
331
|
+
# Create backup before updating
|
|
332
|
+
backup_file=$(create_backup)
|
|
333
|
+
|
|
334
|
+
# Update agent with new knowledge
|
|
335
|
+
update_agent "$total_knowledge" "$backup_file"
|
|
336
|
+
|
|
337
|
+
# Update tracking
|
|
338
|
+
update_last_commit "$current_head"
|
|
339
|
+
|
|
340
|
+
log_success "đ Update complete!"
|
|
341
|
+
log_info "đ Processed $relevant_commits relevant commits"
|
|
342
|
+
log_info "đ Backup available: $backup_file"
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
# Execute main function
|
|
346
346
|
main "$@"
|