telos-framework 0.1.4 → 0.3.0
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/agents/behavioral-transformation-agent.md +144 -0
- package/.claude/agents/command-system-agent.md +335 -0
- package/.claude/agents/completion-gate.md +71 -0
- package/.claude/agents/component-implementation-agent.md +174 -0
- package/.claude/agents/devops-agent.md +128 -0
- package/.claude/agents/dynamic-agent-creator.md +103 -0
- package/.claude/agents/enhanced-project-manager-agent.md +145 -0
- package/.claude/agents/enhanced-quality-gate.md +54 -0
- package/.claude/agents/feature-implementation-agent.md +148 -0
- package/.claude/agents/functional-testing-agent.md +51 -0
- package/.claude/agents/hook-integration-agent.md +204 -0
- package/.claude/agents/infrastructure-implementation-agent.md +175 -0
- package/.claude/agents/lib/research-analyzer.js +470 -0
- package/.claude/agents/metrics-collection-agent.md +374 -0
- package/.claude/agents/npx-package-agent.md +246 -0
- package/.claude/agents/polish-implementation-agent.md +151 -0
- package/.claude/agents/prd-agent.md +76 -0
- package/.claude/agents/prd-mvp.md +101 -0
- package/.claude/agents/prd-research-agent.md +482 -0
- package/.claude/agents/quality-agent.md +128 -0
- package/.claude/agents/readiness-gate.md +104 -0
- package/.claude/agents/research-agent.md +173 -0
- package/.claude/agents/routing-agent.md +108 -0
- package/.claude/agents/task-checker.md +163 -0
- package/.claude/agents/task-executor.md +107 -0
- package/.claude/agents/task-orchestrator.md +343 -0
- package/.claude/agents/tdd-validation-agent.md +187 -0
- package/.claude/agents/testing-implementation-agent.md +151 -0
- package/.claude/agents/van-maintenance-agent.md +64 -0
- package/.claude/agents/workflow-agent.md +87 -0
- package/.claude/commands/autocompact.md +41 -0
- package/.claude/commands/continue-handoff.md +98 -0
- package/.claude/commands/mock.md +45 -0
- package/.claude/commands/reset-handoff.md +59 -0
- package/.claude/commands/telos/init.md +326 -0
- package/.claude/commands/telos/quick.md +90 -0
- package/.claude/commands/telos/reset.md +100 -0
- package/.claude/commands/telos/status.md +170 -0
- package/.claude/commands/telos/validate.md +143 -0
- package/.claude/commands/tm/add-dependency/add-dependency.md +55 -0
- package/.claude/commands/tm/add-subtask/add-subtask.md +76 -0
- package/.claude/commands/tm/add-subtask/convert-task-to-subtask.md +71 -0
- package/.claude/commands/tm/add-task/add-task.md +78 -0
- package/.claude/commands/tm/analyze-complexity/analyze-complexity.md +121 -0
- package/.claude/commands/tm/clear-subtasks/clear-all-subtasks.md +93 -0
- package/.claude/commands/tm/clear-subtasks/clear-subtasks.md +86 -0
- package/.claude/commands/tm/complexity-report/complexity-report.md +117 -0
- package/.claude/commands/tm/expand/expand-all-tasks.md +51 -0
- package/.claude/commands/tm/expand/expand-task.md +49 -0
- package/.claude/commands/tm/fix-dependencies/fix-dependencies.md +81 -0
- package/.claude/commands/tm/generate/generate-tasks.md +121 -0
- package/.claude/commands/tm/help.md +81 -0
- package/.claude/commands/tm/init/init-project-quick.md +46 -0
- package/.claude/commands/tm/init/init-project.md +50 -0
- package/.claude/commands/tm/learn.md +103 -0
- package/.claude/commands/tm/list/list-tasks-by-status.md +39 -0
- package/.claude/commands/tm/list/list-tasks-with-subtasks.md +29 -0
- package/.claude/commands/tm/list/list-tasks.md +43 -0
- package/.claude/commands/tm/models/setup-models.md +51 -0
- package/.claude/commands/tm/models/view-models.md +51 -0
- package/.claude/commands/tm/next/next-task.md +66 -0
- package/.claude/commands/tm/parse-prd/parse-prd-with-research.md +48 -0
- package/.claude/commands/tm/parse-prd/parse-prd.md +49 -0
- package/.claude/commands/tm/remove-dependency/remove-dependency.md +62 -0
- package/.claude/commands/tm/remove-subtask/remove-subtask.md +84 -0
- package/.claude/commands/tm/remove-task/remove-task.md +107 -0
- package/.claude/commands/tm/set-status/to-cancelled.md +55 -0
- package/.claude/commands/tm/set-status/to-deferred.md +47 -0
- package/.claude/commands/tm/set-status/to-done.md +44 -0
- package/.claude/commands/tm/set-status/to-in-progress.md +36 -0
- package/.claude/commands/tm/set-status/to-pending.md +32 -0
- package/.claude/commands/tm/set-status/to-review.md +40 -0
- package/.claude/commands/tm/setup/install-taskmaster.md +117 -0
- package/.claude/commands/tm/setup/quick-install-taskmaster.md +22 -0
- package/.claude/commands/tm/show/show-task.md +82 -0
- package/.claude/commands/tm/status/project-status.md +64 -0
- package/.claude/commands/tm/sync-readme/sync-readme.md +117 -0
- package/.claude/commands/tm/tm-main.md +146 -0
- package/.claude/commands/tm/update/update-single-task.md +119 -0
- package/.claude/commands/tm/update/update-task.md +72 -0
- package/.claude/commands/tm/update/update-tasks-from-id.md +108 -0
- package/.claude/commands/tm/utils/analyze-project.md +97 -0
- package/.claude/commands/tm/validate-dependencies/validate-dependencies.md +71 -0
- package/.claude/commands/tm/workflows/auto-implement-tasks.md +97 -0
- package/.claude/commands/tm/workflows/command-pipeline.md +77 -0
- package/.claude/commands/tm/workflows/smart-workflow.md +55 -0
- package/.claude/commands/van.md +150 -0
- package/.claude/docs/README.md +214 -0
- package/.claude/docs/TROUBLESHOOTING.md +126 -0
- package/.claude/hooks/block-destructive-commands.sh +243 -0
- package/.claude/hooks/collective-metrics.sh +291 -0
- package/.claude/hooks/directive-enforcer.sh +117 -0
- package/.claude/hooks/load-behavioral-system.sh +49 -0
- package/.claude/hooks/routing-executor.sh +4 -0
- package/.claude/hooks/test-driven-handoff.sh +653 -0
- package/.claude/settings.json +125 -0
- package/README.md +39 -15
- package/lib/commands/init-state.js +102 -0
- package/lib/commands/init.js +58 -95
- package/lib/installers/memory-files.js +77 -0
- package/lib/installers/slash-commands.js +77 -0
- package/package.json +7 -2
- package/templates/AGENTS.md +79 -0
- package/templates/CLAUDE.md +54 -0
|
@@ -0,0 +1,291 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# collective-metrics.sh
|
|
3
|
+
# Phase 3 - Hook Integration System
|
|
4
|
+
# Collects performance metrics and coordination statistics for research validation
|
|
5
|
+
|
|
6
|
+
# Set up metrics storage
|
|
7
|
+
PROJECT_DIR=${CLAUDE_PROJECT_DIR:-"/mnt/h/Active/taskmaster-agent-claude-code"}
|
|
8
|
+
METRICS_DIR="$PROJECT_DIR/.claude-collective/metrics"
|
|
9
|
+
METRICS_FILE="$METRICS_DIR/metrics-$(date +%Y%m%d).json"
|
|
10
|
+
LOG_FILE="$METRICS_DIR/collective-metrics.log"
|
|
11
|
+
|
|
12
|
+
mkdir -p "$METRICS_DIR"
|
|
13
|
+
|
|
14
|
+
timestamp() { date '+%Y-%m-%d %H:%M:%S'; }
|
|
15
|
+
epoch_ms() { date +%s%3N; }
|
|
16
|
+
|
|
17
|
+
log() {
|
|
18
|
+
echo "[$(timestamp)] $1" >> "$LOG_FILE"
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# Initialize environment variables
|
|
22
|
+
EVENT=${EVENT:-""}
|
|
23
|
+
TOOL_NAME=${TOOL_NAME:-""}
|
|
24
|
+
SUBAGENT_NAME=${SUBAGENT_NAME:-""}
|
|
25
|
+
USER_PROMPT=${USER_PROMPT:-""}
|
|
26
|
+
EXECUTION_TIME_MS=${EXECUTION_TIME_MS:-0}
|
|
27
|
+
CLAUDE_PROJECT_DIR=${CLAUDE_PROJECT_DIR:-"/mnt/h/Active/taskmaster-agent-claude-code"}
|
|
28
|
+
|
|
29
|
+
log "METRICS COLLECTION TRIGGERED - Event: $EVENT, Tool: $TOOL_NAME, Agent: $SUBAGENT_NAME"
|
|
30
|
+
|
|
31
|
+
# Initialize metrics file if it doesn't exist
|
|
32
|
+
initialize_metrics_file() {
|
|
33
|
+
if [[ ! -f "$METRICS_FILE" ]]; then
|
|
34
|
+
cat > "$METRICS_FILE" << 'EOF'
|
|
35
|
+
{
|
|
36
|
+
"date": "",
|
|
37
|
+
"research_metrics": {
|
|
38
|
+
"jit_hypothesis": {
|
|
39
|
+
"context_load_times": [],
|
|
40
|
+
"memory_usage": [],
|
|
41
|
+
"agent_spawn_times": []
|
|
42
|
+
},
|
|
43
|
+
"hub_spoke_hypothesis": {
|
|
44
|
+
"routing_accuracy": [],
|
|
45
|
+
"coordination_overhead": [],
|
|
46
|
+
"peer_communication_violations": 0
|
|
47
|
+
},
|
|
48
|
+
"tdd_hypothesis": {
|
|
49
|
+
"handoff_success_rate": [],
|
|
50
|
+
"integration_defects": [],
|
|
51
|
+
"test_coverage": []
|
|
52
|
+
}
|
|
53
|
+
},
|
|
54
|
+
"performance_metrics": {
|
|
55
|
+
"tool_executions": [],
|
|
56
|
+
"agent_handoffs": [],
|
|
57
|
+
"directive_violations": [],
|
|
58
|
+
"quality_gates": []
|
|
59
|
+
},
|
|
60
|
+
"system_health": {
|
|
61
|
+
"uptime": 0,
|
|
62
|
+
"error_rate": 0,
|
|
63
|
+
"response_times": []
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
EOF
|
|
67
|
+
# Set the date
|
|
68
|
+
jq --arg date "$(date -I)" '.date = $date' "$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
69
|
+
log "Initialized metrics file: $METRICS_FILE"
|
|
70
|
+
fi
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
# Collect JIT (Just-in-Time) Context Loading metrics
|
|
74
|
+
collect_jit_metrics() {
|
|
75
|
+
local start_time="$1"
|
|
76
|
+
local context_size="$2"
|
|
77
|
+
|
|
78
|
+
if [[ "$EVENT" == "PreToolUse" ]]; then
|
|
79
|
+
# Record context load time
|
|
80
|
+
local load_time=$(($(epoch_ms) - start_time))
|
|
81
|
+
|
|
82
|
+
jq --argjson load_time "$load_time" \
|
|
83
|
+
--argjson context_size "${context_size:-0}" \
|
|
84
|
+
'.research_metrics.jit_hypothesis.context_load_times += [{
|
|
85
|
+
"timestamp": now,
|
|
86
|
+
"load_time_ms": $load_time,
|
|
87
|
+
"context_size": $context_size,
|
|
88
|
+
"tool": "'$TOOL_NAME'"
|
|
89
|
+
}]' "$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
90
|
+
|
|
91
|
+
log "JIT Metrics: Context load time: ${load_time}ms, Size: $context_size"
|
|
92
|
+
fi
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
# Collect Hub-Spoke Coordination metrics
|
|
96
|
+
collect_hub_spoke_metrics() {
|
|
97
|
+
local routing_decision="$1"
|
|
98
|
+
local coordination_start="$2"
|
|
99
|
+
|
|
100
|
+
if [[ "$EVENT" == "SubagentStop" ]]; then
|
|
101
|
+
# Calculate coordination overhead
|
|
102
|
+
local coordination_time=$(($(epoch_ms) - coordination_start))
|
|
103
|
+
|
|
104
|
+
# Determine routing accuracy (simplified heuristic)
|
|
105
|
+
local accuracy=1
|
|
106
|
+
if echo "$USER_PROMPT" | grep -qi "error\|fail\|retry"; then
|
|
107
|
+
accuracy=0
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
jq --argjson accuracy "$accuracy" \
|
|
111
|
+
--argjson coord_time "$coordination_time" \
|
|
112
|
+
'.research_metrics.hub_spoke_hypothesis.routing_accuracy += [$accuracy] |
|
|
113
|
+
.research_metrics.hub_spoke_hypothesis.coordination_overhead += [{
|
|
114
|
+
"timestamp": now,
|
|
115
|
+
"coordination_time_ms": $coord_time,
|
|
116
|
+
"agent": "'$SUBAGENT_NAME'"
|
|
117
|
+
}]' "$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
118
|
+
|
|
119
|
+
log "Hub-Spoke Metrics: Accuracy: $accuracy, Coordination time: ${coordination_time}ms"
|
|
120
|
+
fi
|
|
121
|
+
|
|
122
|
+
# Check for peer-to-peer communication violations
|
|
123
|
+
if echo "$USER_PROMPT" | grep -qi -E "@[a-z-]*agent.*@[a-z-]*agent"; then
|
|
124
|
+
jq '.research_metrics.hub_spoke_hypothesis.peer_communication_violations += 1' \
|
|
125
|
+
"$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
126
|
+
log "Hub-Spoke Violation: Peer-to-peer communication detected"
|
|
127
|
+
fi
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
# Collect Test-Driven Development metrics
|
|
131
|
+
collect_tdd_metrics() {
|
|
132
|
+
local handoff_quality="$1"
|
|
133
|
+
local test_coverage="$2"
|
|
134
|
+
|
|
135
|
+
if [[ "$EVENT" == "SubagentStop" ]]; then
|
|
136
|
+
# Assess handoff success (simplified scoring)
|
|
137
|
+
local handoff_success=1
|
|
138
|
+
if echo "$USER_PROMPT" | grep -qi -E "error\|fail\|incomplete\|retry"; then
|
|
139
|
+
handoff_success=0
|
|
140
|
+
fi
|
|
141
|
+
|
|
142
|
+
# Check for test mentions
|
|
143
|
+
local has_tests=0
|
|
144
|
+
if echo "$USER_PROMPT" | grep -qi -E "test\|spec\|coverage\|validate"; then
|
|
145
|
+
has_tests=1
|
|
146
|
+
fi
|
|
147
|
+
|
|
148
|
+
jq --argjson success "$handoff_success" \
|
|
149
|
+
--argjson has_tests "$has_tests" \
|
|
150
|
+
--argjson coverage "${test_coverage:-0}" \
|
|
151
|
+
'.research_metrics.tdd_hypothesis.handoff_success_rate += [$success] |
|
|
152
|
+
.research_metrics.tdd_hypothesis.test_coverage += [{
|
|
153
|
+
"timestamp": now,
|
|
154
|
+
"coverage": $coverage,
|
|
155
|
+
"has_tests": $has_tests,
|
|
156
|
+
"agent": "'$SUBAGENT_NAME'"
|
|
157
|
+
}]' "$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
158
|
+
|
|
159
|
+
log "TDD Metrics: Handoff success: $handoff_success, Has tests: $has_tests, Coverage: $test_coverage"
|
|
160
|
+
fi
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
# Collect performance metrics
|
|
164
|
+
collect_performance_metrics() {
|
|
165
|
+
local execution_start=$(epoch_ms)
|
|
166
|
+
|
|
167
|
+
# Record tool execution
|
|
168
|
+
if [[ -n "$TOOL_NAME" ]]; then
|
|
169
|
+
jq --arg tool "$TOOL_NAME" \
|
|
170
|
+
--argjson exec_time "${EXECUTION_TIME_MS:-0}" \
|
|
171
|
+
'.performance_metrics.tool_executions += [{
|
|
172
|
+
"timestamp": now,
|
|
173
|
+
"tool": $tool,
|
|
174
|
+
"execution_time_ms": $exec_time,
|
|
175
|
+
"event": "'$EVENT'"
|
|
176
|
+
}]' "$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
177
|
+
|
|
178
|
+
log "Performance: Tool $TOOL_NAME executed in ${EXECUTION_TIME_MS}ms"
|
|
179
|
+
fi
|
|
180
|
+
|
|
181
|
+
# Record agent handoffs
|
|
182
|
+
if [[ "$EVENT" == "SubagentStop" && -n "$SUBAGENT_NAME" ]]; then
|
|
183
|
+
jq --arg agent "$SUBAGENT_NAME" \
|
|
184
|
+
'.performance_metrics.agent_handoffs += [{
|
|
185
|
+
"timestamp": now,
|
|
186
|
+
"agent": $agent,
|
|
187
|
+
"event": "'$EVENT'"
|
|
188
|
+
}]' "$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
189
|
+
|
|
190
|
+
log "Performance: Agent handoff recorded for $SUBAGENT_NAME"
|
|
191
|
+
fi
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
# Collect system health metrics
|
|
195
|
+
collect_system_health() {
|
|
196
|
+
# Update response times
|
|
197
|
+
if [[ "$EXECUTION_TIME_MS" -gt 0 ]]; then
|
|
198
|
+
jq --argjson response_time "$EXECUTION_TIME_MS" \
|
|
199
|
+
'.system_health.response_times += [$response_time]' \
|
|
200
|
+
"$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
201
|
+
fi
|
|
202
|
+
|
|
203
|
+
# Calculate error rate (simplified)
|
|
204
|
+
local is_error=0
|
|
205
|
+
if echo "$USER_PROMPT" | grep -qi -E "error\|fail\|exception"; then
|
|
206
|
+
is_error=1
|
|
207
|
+
fi
|
|
208
|
+
|
|
209
|
+
if [[ "$is_error" == "1" ]]; then
|
|
210
|
+
jq '.system_health.error_rate += 1' \
|
|
211
|
+
"$METRICS_FILE" > "$METRICS_FILE.tmp" && mv "$METRICS_FILE.tmp" "$METRICS_FILE"
|
|
212
|
+
log "System Health: Error detected and recorded"
|
|
213
|
+
fi
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
# Generate metrics summary
|
|
217
|
+
generate_summary() {
|
|
218
|
+
if [[ ! -f "$METRICS_FILE" ]]; then
|
|
219
|
+
return 0
|
|
220
|
+
fi
|
|
221
|
+
|
|
222
|
+
local summary_file="$METRICS_DIR/summary-$(date +%Y%m%d).txt"
|
|
223
|
+
|
|
224
|
+
cat > "$summary_file" << EOF
|
|
225
|
+
# Collective Metrics Summary - $(date)
|
|
226
|
+
|
|
227
|
+
## Research Hypothesis Validation
|
|
228
|
+
|
|
229
|
+
### JIT Hypothesis
|
|
230
|
+
- Context load times collected: $(jq '.research_metrics.jit_hypothesis.context_load_times | length' "$METRICS_FILE")
|
|
231
|
+
- Average load time: $(jq '[.research_metrics.jit_hypothesis.context_load_times[].load_time_ms] | add / length' "$METRICS_FILE" 2>/dev/null || echo "N/A")ms
|
|
232
|
+
|
|
233
|
+
### Hub-Spoke Hypothesis
|
|
234
|
+
- Routing accuracy: $(jq '[.research_metrics.hub_spoke_hypothesis.routing_accuracy] | add / length * 100' "$METRICS_FILE" 2>/dev/null || echo "N/A")%
|
|
235
|
+
- Peer communication violations: $(jq '.research_metrics.hub_spoke_hypothesis.peer_communication_violations' "$METRICS_FILE")
|
|
236
|
+
|
|
237
|
+
### TDD Hypothesis
|
|
238
|
+
- Handoff success rate: $(jq '[.research_metrics.tdd_hypothesis.handoff_success_rate] | add / length * 100' "$METRICS_FILE" 2>/dev/null || echo "N/A")%
|
|
239
|
+
- Test coverage events: $(jq '.research_metrics.tdd_hypothesis.test_coverage | length' "$METRICS_FILE")
|
|
240
|
+
|
|
241
|
+
## Performance Metrics
|
|
242
|
+
- Tool executions: $(jq '.performance_metrics.tool_executions | length' "$METRICS_FILE")
|
|
243
|
+
- Agent handoffs: $(jq '.performance_metrics.agent_handoffs | length' "$METRICS_FILE")
|
|
244
|
+
- Average response time: $(jq '[.system_health.response_times] | add / length' "$METRICS_FILE" 2>/dev/null || echo "N/A")ms
|
|
245
|
+
|
|
246
|
+
EOF
|
|
247
|
+
|
|
248
|
+
log "Generated metrics summary: $summary_file"
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
# Main collection logic
|
|
252
|
+
main() {
|
|
253
|
+
local start_time=$(epoch_ms)
|
|
254
|
+
|
|
255
|
+
log "Starting metrics collection for event: $EVENT"
|
|
256
|
+
|
|
257
|
+
# Initialize metrics file
|
|
258
|
+
initialize_metrics_file
|
|
259
|
+
|
|
260
|
+
# Collect metrics based on event type
|
|
261
|
+
case "$EVENT" in
|
|
262
|
+
"PreToolUse")
|
|
263
|
+
collect_jit_metrics "$start_time" "$(echo "$USER_PROMPT" | wc -c)"
|
|
264
|
+
collect_performance_metrics
|
|
265
|
+
;;
|
|
266
|
+
"PostToolUse")
|
|
267
|
+
collect_performance_metrics
|
|
268
|
+
collect_system_health
|
|
269
|
+
;;
|
|
270
|
+
"SubagentStop")
|
|
271
|
+
collect_hub_spoke_metrics "routing" "$start_time"
|
|
272
|
+
collect_tdd_metrics "quality" "0"
|
|
273
|
+
collect_performance_metrics
|
|
274
|
+
;;
|
|
275
|
+
*)
|
|
276
|
+
collect_performance_metrics
|
|
277
|
+
;;
|
|
278
|
+
esac
|
|
279
|
+
|
|
280
|
+
# Generate summary periodically (every 10th execution)
|
|
281
|
+
local execution_count=$(jq '.performance_metrics.tool_executions | length' "$METRICS_FILE" 2>/dev/null || echo "0")
|
|
282
|
+
if [[ $((execution_count % 10)) -eq 0 && $execution_count -gt 0 ]]; then
|
|
283
|
+
generate_summary
|
|
284
|
+
fi
|
|
285
|
+
|
|
286
|
+
log "Metrics collection completed for event: $EVENT"
|
|
287
|
+
return 0
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
# Execute main function
|
|
291
|
+
main "$@"
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# directive-enforcer.sh
|
|
3
|
+
# Claude Code Sub-Agent Collective - Directive Enforcement Hook
|
|
4
|
+
# Validates behavioral directives before tool execution
|
|
5
|
+
|
|
6
|
+
# Set up logging
|
|
7
|
+
LOG_FILE="/tmp/directive-enforcer.log"
|
|
8
|
+
timestamp() { date '+%Y-%m-%d %H:%M:%S'; }
|
|
9
|
+
|
|
10
|
+
log() {
|
|
11
|
+
echo "[$(timestamp)] $1" >> "$LOG_FILE"
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
# Initialize environment variables if not set
|
|
15
|
+
USER_PROMPT=${USER_PROMPT:-""}
|
|
16
|
+
TOOL_NAME=${TOOL_NAME:-""}
|
|
17
|
+
CLAUDE_PROJECT_DIR=${CLAUDE_PROJECT_DIR:-"/mnt/h/Active/taskmaster-agent-claude-code"}
|
|
18
|
+
|
|
19
|
+
log "DIRECTIVE ENFORCEMENT TRIGGERED - Tool: $TOOL_NAME"
|
|
20
|
+
|
|
21
|
+
# DIRECTIVE 1: NEVER IMPLEMENT DIRECTLY
|
|
22
|
+
# Block direct implementation when hub-and-spoke pattern should be used
|
|
23
|
+
check_direct_implementation() {
|
|
24
|
+
local prompt="$1"
|
|
25
|
+
local tool="$2"
|
|
26
|
+
|
|
27
|
+
# Check for implementation-related activities
|
|
28
|
+
if [[ "$tool" == "Write" || "$tool" == "Edit" || "$tool" == "MultiEdit" ]]; then
|
|
29
|
+
# Look for direct implementation phrases that violate hub-and-spoke
|
|
30
|
+
if echo "$prompt" | grep -qi -E "(implement|create.*code|write.*function|add.*feature|build.*component)"; then
|
|
31
|
+
# Check if this is coming from a specialized agent (allowed)
|
|
32
|
+
if ! echo "$prompt" | grep -qi "@.*-agent"; then
|
|
33
|
+
log "DIRECTIVE 1 VIOLATION: Direct implementation detected without agent routing"
|
|
34
|
+
echo "❌ DIRECTIVE VIOLATION: Direct implementation attempted"
|
|
35
|
+
echo "🔄 REQUIRED ACTION: Route through @routing-agent for proper agent selection"
|
|
36
|
+
echo "📋 VIOLATION: NEVER IMPLEMENT DIRECTLY - Use hub-and-spoke pattern"
|
|
37
|
+
return 1
|
|
38
|
+
fi
|
|
39
|
+
fi
|
|
40
|
+
fi
|
|
41
|
+
return 0
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
# DIRECTIVE 2: COLLECTIVE ROUTING PROTOCOL
|
|
45
|
+
# Ensure requests flow through proper routing channels
|
|
46
|
+
check_routing_protocol() {
|
|
47
|
+
local prompt="$1"
|
|
48
|
+
|
|
49
|
+
# Check for peer-to-peer agent communication violations
|
|
50
|
+
if echo "$prompt" | grep -qi -E "(@[a-z-]*agent.*@[a-z-]*agent|direct.*communication|bypass.*routing)"; then
|
|
51
|
+
log "DIRECTIVE 2 VIOLATION: Peer-to-peer agent communication detected"
|
|
52
|
+
echo "❌ ROUTING VIOLATION: Peer-to-peer agent communication not allowed"
|
|
53
|
+
echo "🔄 REQUIRED ACTION: Route all requests through @routing-agent hub"
|
|
54
|
+
return 1
|
|
55
|
+
fi
|
|
56
|
+
|
|
57
|
+
return 0
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# DIRECTIVE 3: TEST-DRIVEN VALIDATION
|
|
61
|
+
# Ensure handoffs include proper test validation
|
|
62
|
+
check_test_driven_validation() {
|
|
63
|
+
local prompt="$1"
|
|
64
|
+
local tool="$2"
|
|
65
|
+
|
|
66
|
+
# Check for handoff scenarios without test validation
|
|
67
|
+
if echo "$prompt" | grep -qi -E "(handoff|hand.*off|transfer.*to|route.*to.*agent)"; then
|
|
68
|
+
if ! echo "$prompt" | grep -qi -E "(test|validate|verify|contract|quality.*gate)"; then
|
|
69
|
+
log "DIRECTIVE 3 WARNING: Handoff without explicit test validation mentioned"
|
|
70
|
+
echo "⚠️ TEST-DRIVEN WARNING: Handoff detected without test validation"
|
|
71
|
+
echo "📋 RECOMMENDATION: Include test contract validation in handoff"
|
|
72
|
+
# Don't block, just warn
|
|
73
|
+
fi
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
return 0
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
# Security validation - prevent malicious command injection
|
|
80
|
+
validate_security() {
|
|
81
|
+
local prompt="$1"
|
|
82
|
+
|
|
83
|
+
# Check for basic command injection patterns
|
|
84
|
+
if echo "$prompt" | grep -qi -E "(rm -rf|curl |wget |;s*rm|;s*curl|;s*wget)"; then
|
|
85
|
+
log "SECURITY VIOLATION: Potential command injection detected"
|
|
86
|
+
echo "🚨 SECURITY VIOLATION: Potentially malicious input detected"
|
|
87
|
+
return 1
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
return 0
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# Main enforcement logic
|
|
94
|
+
main() {
|
|
95
|
+
log "Starting directive enforcement for tool: $TOOL_NAME"
|
|
96
|
+
|
|
97
|
+
# Run all validation checks
|
|
98
|
+
if ! validate_security "$USER_PROMPT"; then
|
|
99
|
+
exit 1
|
|
100
|
+
fi
|
|
101
|
+
|
|
102
|
+
if ! check_direct_implementation "$USER_PROMPT" "$TOOL_NAME"; then
|
|
103
|
+
exit 1
|
|
104
|
+
fi
|
|
105
|
+
|
|
106
|
+
if ! check_routing_protocol "$USER_PROMPT"; then
|
|
107
|
+
exit 1
|
|
108
|
+
fi
|
|
109
|
+
|
|
110
|
+
check_test_driven_validation "$USER_PROMPT" "$TOOL_NAME"
|
|
111
|
+
|
|
112
|
+
log "All directive checks passed for tool: $TOOL_NAME"
|
|
113
|
+
return 0
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
# Execute main function
|
|
117
|
+
main "$@"
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Load Collective Behavioral System
|
|
3
|
+
# SessionStart hook to inject behavioral files into Claude's context
|
|
4
|
+
|
|
5
|
+
echo "🚀 CLAUDE CODE COLLECTIVE INITIALIZATION SEQUENCE"
|
|
6
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
7
|
+
echo "🤖 Activating Multi-Agent Behavioral Operating System..."
|
|
8
|
+
echo "⚡ Loading Hub-Spoke Coordination Protocols..."
|
|
9
|
+
echo "🧠 Initializing Context Engineering Framework..."
|
|
10
|
+
echo ""
|
|
11
|
+
|
|
12
|
+
echo "=== COLLECTIVE BEHAVIORAL RULES (.claude-collective/CLAUDE.md) ==="
|
|
13
|
+
cat .claude-collective/CLAUDE.md
|
|
14
|
+
echo ""
|
|
15
|
+
|
|
16
|
+
echo "=== GLOBAL DECISION ENGINE (.claude-collective/DECISION.md) ==="
|
|
17
|
+
cat .claude-collective/DECISION.md
|
|
18
|
+
echo ""
|
|
19
|
+
|
|
20
|
+
echo "=== SPECIALIZED AGENTS (.claude-collective/agents.md) ==="
|
|
21
|
+
cat .claude-collective/agents.md
|
|
22
|
+
echo ""
|
|
23
|
+
|
|
24
|
+
echo "=== HOOK INTEGRATION (.claude-collective/hooks.md) ==="
|
|
25
|
+
cat .claude-collective/hooks.md
|
|
26
|
+
echo ""
|
|
27
|
+
|
|
28
|
+
echo "=== QUALITY ASSURANCE (.claude-collective/quality.md) ==="
|
|
29
|
+
cat .claude-collective/quality.md
|
|
30
|
+
echo ""
|
|
31
|
+
|
|
32
|
+
echo "=== RESEARCH FRAMEWORK (.claude-collective/research.md) ==="
|
|
33
|
+
cat .claude-collective/research.md
|
|
34
|
+
echo ""
|
|
35
|
+
|
|
36
|
+
echo "=== TASKMASTER INTEGRATION (.taskmaster/CLAUDE.md) ==="
|
|
37
|
+
cat .taskmaster/CLAUDE.md
|
|
38
|
+
echo ""
|
|
39
|
+
|
|
40
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
41
|
+
echo "✅ BEHAVIORAL OPERATING SYSTEM ONLINE"
|
|
42
|
+
echo "🎯 Prime Directives: LOADED"
|
|
43
|
+
echo "🔗 Agent Network: 40+ Specialists ACTIVE"
|
|
44
|
+
echo "📊 TDD Framework: ENGAGED"
|
|
45
|
+
echo "🔄 Auto-Delegation: READY"
|
|
46
|
+
echo "📡 Hub-Spoke Coordination: OPERATIONAL"
|
|
47
|
+
echo ""
|
|
48
|
+
echo "🌟 Claude Code Collective v1.4.3 - Ready for Enhanced Development"
|
|
49
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|