@paulduvall/claude-dev-toolkit 0.0.1-alpha.2 → 0.0.1-alpha.5

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 (84) hide show
  1. package/README.md +44 -6
  2. package/commands/active/xarchitecture.md +393 -0
  3. package/commands/active/xconfig.md +127 -0
  4. package/commands/active/xdebug.md +130 -0
  5. package/commands/active/xdocs.md +178 -0
  6. package/commands/active/xgit.md +149 -0
  7. package/commands/active/xpipeline.md +152 -0
  8. package/commands/active/xquality.md +96 -0
  9. package/commands/active/xrefactor.md +198 -0
  10. package/commands/active/xrelease.md +142 -0
  11. package/commands/active/xsecurity.md +92 -0
  12. package/commands/active/xspec.md +174 -0
  13. package/commands/active/xtdd.md +151 -0
  14. package/commands/active/xtest.md +89 -0
  15. package/commands/experiments/xact.md +742 -0
  16. package/commands/experiments/xanalytics.md +113 -0
  17. package/commands/experiments/xanalyze.md +70 -0
  18. package/commands/experiments/xapi.md +161 -0
  19. package/commands/experiments/xatomic.md +112 -0
  20. package/commands/experiments/xaws.md +85 -0
  21. package/commands/experiments/xcicd.md +337 -0
  22. package/commands/experiments/xcommit.md +122 -0
  23. package/commands/experiments/xcompliance.md +182 -0
  24. package/commands/experiments/xconstraints.md +89 -0
  25. package/commands/experiments/xcoverage.md +90 -0
  26. package/commands/experiments/xdb.md +102 -0
  27. package/commands/experiments/xdesign.md +121 -0
  28. package/commands/experiments/xevaluate.md +111 -0
  29. package/commands/experiments/xfootnote.md +12 -0
  30. package/commands/experiments/xgenerate.md +117 -0
  31. package/commands/experiments/xgovernance.md +149 -0
  32. package/commands/experiments/xgreen.md +66 -0
  33. package/commands/experiments/xiac.md +118 -0
  34. package/commands/experiments/xincident.md +137 -0
  35. package/commands/experiments/xinfra.md +115 -0
  36. package/commands/experiments/xknowledge.md +115 -0
  37. package/commands/experiments/xmaturity.md +120 -0
  38. package/commands/experiments/xmetrics.md +118 -0
  39. package/commands/experiments/xmonitoring.md +128 -0
  40. package/commands/experiments/xnew.md +898 -0
  41. package/commands/experiments/xobservable.md +114 -0
  42. package/commands/experiments/xoidc.md +165 -0
  43. package/commands/experiments/xoptimize.md +115 -0
  44. package/commands/experiments/xperformance.md +112 -0
  45. package/commands/experiments/xplanning.md +131 -0
  46. package/commands/experiments/xpolicy.md +115 -0
  47. package/commands/experiments/xproduct.md +98 -0
  48. package/commands/experiments/xreadiness.md +75 -0
  49. package/commands/experiments/xred.md +55 -0
  50. package/commands/experiments/xrisk.md +128 -0
  51. package/commands/experiments/xrules.md +124 -0
  52. package/commands/experiments/xsandbox.md +120 -0
  53. package/commands/experiments/xscan.md +102 -0
  54. package/commands/experiments/xsetup.md +123 -0
  55. package/commands/experiments/xtemplate.md +116 -0
  56. package/commands/experiments/xtrace.md +212 -0
  57. package/commands/experiments/xux.md +171 -0
  58. package/commands/experiments/xvalidate.md +104 -0
  59. package/commands/experiments/xworkflow.md +113 -0
  60. package/hooks/README.md +231 -0
  61. package/hooks/file-logger.sh +98 -0
  62. package/hooks/lib/argument-parser.sh +422 -0
  63. package/hooks/lib/config-constants.sh +230 -0
  64. package/hooks/lib/context-manager.sh +549 -0
  65. package/hooks/lib/error-handler.sh +412 -0
  66. package/hooks/lib/execution-engine.sh +627 -0
  67. package/hooks/lib/file-utils.sh +375 -0
  68. package/hooks/lib/subagent-discovery.sh +465 -0
  69. package/hooks/lib/subagent-validator.sh +597 -0
  70. package/hooks/on-error-debug.sh +221 -0
  71. package/hooks/pre-commit-quality.sh +204 -0
  72. package/hooks/pre-write-security.sh +107 -0
  73. package/hooks/prevent-credential-exposure.sh +265 -0
  74. package/hooks/subagent-trigger-simple.sh +193 -0
  75. package/hooks/subagent-trigger.sh +253 -0
  76. package/lib/hook-installer-core.js +2 -2
  77. package/package.json +3 -1
  78. package/scripts/postinstall.js +28 -10
  79. package/templates/README.md +100 -0
  80. package/templates/basic-settings.json +30 -0
  81. package/templates/comprehensive-settings.json +206 -0
  82. package/templates/hybrid-hook-config.yaml +133 -0
  83. package/templates/security-focused-settings.json +62 -0
  84. package/templates/subagent-hooks.yaml +188 -0
@@ -0,0 +1,549 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Context Management Module for Subagent-Hook Integration
4
+ #
5
+ # This module provides functionality to gather, manage, and pass context
6
+ # information to subagents during hook execution.
7
+
8
+ # Source required modules
9
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
10
+ source "$SCRIPT_DIR/config-constants.sh"
11
+ source "$SCRIPT_DIR/file-utils.sh"
12
+ source "$SCRIPT_DIR/error-handler.sh"
13
+
14
+ ##################################
15
+ # Context Structure
16
+ ##################################
17
+
18
+ # Global variables for context management (compatible with older bash versions)
19
+ CONTEXT_FILE=""
20
+ # CONTEXT_TIMEOUT is defined in config-constants.sh as readonly
21
+ CONTEXT_DATA=""
22
+
23
+ ##################################
24
+ # Context Gathering Functions
25
+ ##################################
26
+
27
+ gather_basic_context() {
28
+ local event_type="${1:-unknown}"
29
+ local subagent_name="${2:-unknown}"
30
+ local additional_context="${3:-}"
31
+
32
+ log_debug "Gathering basic context for $subagent_name (event: $event_type)"
33
+
34
+ # Create base context structure
35
+ local context_json
36
+ context_json=$(cat <<EOF
37
+ {
38
+ "metadata": {
39
+ "timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")",
40
+ "hook_version": "$SUBAGENT_HOOK_VERSION",
41
+ "api_version": "$API_VERSION"
42
+ },
43
+ "event": {
44
+ "type": "$event_type",
45
+ "trigger": "${CLAUDE_HOOK_TRIGGER:-manual}",
46
+ "subagent": "$subagent_name"
47
+ },
48
+ "environment": {
49
+ "user": "$USER",
50
+ "working_directory": "$(pwd)",
51
+ "process_id": $$,
52
+ "session_id": "${CLAUDE_SESSION_ID:-$$}"
53
+ }
54
+ }
55
+ EOF
56
+ )
57
+
58
+ CONTEXT_DATA="$context_json"
59
+ log_debug "Basic context gathered successfully"
60
+ return $EXIT_SUCCESS
61
+ }
62
+
63
+ gather_claude_context() {
64
+ local current_context="$CONTEXT_DATA"
65
+
66
+ log_debug "Gathering Claude-specific context"
67
+
68
+ # Extract Claude environment variables
69
+ local claude_context
70
+ claude_context=$(cat <<EOF
71
+ {
72
+ "claude": {
73
+ "tool": "${CLAUDE_TOOL:-unknown}",
74
+ "file": "${CLAUDE_FILE:-none}",
75
+ "content": "${CLAUDE_CONTENT:-none}",
76
+ "version": "${CLAUDE_VERSION:-unknown}",
77
+ "project": "${CLAUDE_PROJECT:-unknown}",
78
+ "security_override": "${CLAUDE_SECURITY_OVERRIDE:-false}"
79
+ }
80
+ }
81
+ EOF
82
+ )
83
+
84
+ # Merge with existing context
85
+ CONTEXT_DATA=$(echo "$current_context" | jq --argjson claude "$(echo "$claude_context" | jq '.claude')" '. + {claude: $claude}' 2>/dev/null) || {
86
+ log_warning "Failed to merge Claude context with jq, using concatenation"
87
+ CONTEXT_DATA="$current_context,$claude_context"
88
+ }
89
+
90
+ log_debug "Claude context gathered successfully"
91
+ return $EXIT_SUCCESS
92
+ }
93
+
94
+ gather_git_context() {
95
+ local current_context="$CONTEXT_DATA"
96
+
97
+ log_debug "Gathering Git context"
98
+
99
+ local git_branch git_commit git_status git_remote
100
+ git_branch=$(git branch --show-current 2>/dev/null || echo "not-in-git")
101
+ git_commit=$(git rev-parse HEAD 2>/dev/null || echo "unknown")
102
+ git_remote=$(git remote get-url origin 2>/dev/null || echo "none")
103
+
104
+ # Get git status in a safe way
105
+ local git_changes="clean"
106
+ if git status --porcelain 2>/dev/null | grep -q .; then
107
+ git_changes="modified"
108
+ fi
109
+
110
+ local git_context
111
+ git_context=$(cat <<EOF
112
+ {
113
+ "git": {
114
+ "branch": "$git_branch",
115
+ "commit": "${git_commit:0:8}",
116
+ "status": "$git_changes",
117
+ "remote": "$git_remote",
118
+ "in_repo": $(if [[ "$git_branch" != "not-in-git" ]]; then echo "true"; else echo "false"; fi)
119
+ }
120
+ }
121
+ EOF
122
+ )
123
+
124
+ # Merge with existing context
125
+ CONTEXT_DATA=$(echo "$current_context" | jq --argjson git "$(echo "$git_context" | jq '.git')" '. + {git: $git}' 2>/dev/null) || {
126
+ log_warning "Failed to merge Git context with jq, using concatenation"
127
+ CONTEXT_DATA="$current_context,$git_context"
128
+ }
129
+
130
+ log_debug "Git context gathered successfully"
131
+ return $EXIT_SUCCESS
132
+ }
133
+
134
+ gather_file_context() {
135
+ local file_path="${CLAUDE_FILE:-}"
136
+ local current_context="$CONTEXT_DATA"
137
+
138
+ if [[ -z "$file_path" ]] || [[ "$file_path" == "none" ]]; then
139
+ log_debug "No file context to gather"
140
+ return $EXIT_SUCCESS
141
+ fi
142
+
143
+ log_debug "Gathering file context for: $file_path"
144
+
145
+ local file_info=""
146
+ local file_type="unknown"
147
+ local file_size="0"
148
+ local file_permissions="unknown"
149
+
150
+ if [[ -f "$file_path" ]]; then
151
+ file_type=$(file -b "$file_path" 2>/dev/null || echo "unknown")
152
+ file_size=$(stat -f%z "$file_path" 2>/dev/null || stat -c%s "$file_path" 2>/dev/null || echo "0")
153
+ file_permissions=$(stat -f%A "$file_path" 2>/dev/null || stat -c%a "$file_path" 2>/dev/null || echo "unknown")
154
+
155
+ # Get file extension
156
+ local file_ext="${file_path##*.}"
157
+ [[ "$file_ext" == "$file_path" ]] && file_ext="none"
158
+
159
+ file_info="exists"
160
+ elif [[ -d "$file_path" ]]; then
161
+ file_info="directory"
162
+ file_type="directory"
163
+ else
164
+ file_info="not_found"
165
+ fi
166
+
167
+ local file_context
168
+ file_context=$(cat <<EOF
169
+ {
170
+ "file": {
171
+ "path": "$file_path",
172
+ "name": "$(basename "$file_path")",
173
+ "directory": "$(dirname "$file_path")",
174
+ "extension": "${file_ext:-none}",
175
+ "type": "$file_type",
176
+ "size": $file_size,
177
+ "permissions": "$file_permissions",
178
+ "status": "$file_info"
179
+ }
180
+ }
181
+ EOF
182
+ )
183
+
184
+ # Merge with existing context
185
+ CONTEXT_DATA=$(echo "$current_context" | jq --argjson file "$(echo "$file_context" | jq '.file')" '. + {file: $file}' 2>/dev/null) || {
186
+ log_warning "Failed to merge file context with jq, using concatenation"
187
+ CONTEXT_DATA="$current_context,$file_context"
188
+ }
189
+
190
+ log_debug "File context gathered successfully"
191
+ return $EXIT_SUCCESS
192
+ }
193
+
194
+ gather_system_context() {
195
+ local current_context="$CONTEXT_DATA"
196
+
197
+ log_debug "Gathering system context"
198
+
199
+ local system_context
200
+ system_context=$(cat <<EOF
201
+ {
202
+ "system": {
203
+ "hostname": "$(hostname 2>/dev/null || echo 'unknown')",
204
+ "os": "$(uname -s 2>/dev/null || echo 'unknown')",
205
+ "architecture": "$(uname -m 2>/dev/null || echo 'unknown')",
206
+ "shell": "${SHELL##*/}",
207
+ "term": "${TERM:-unknown}",
208
+ "lang": "${LANG:-unknown}",
209
+ "timezone": "$(date +%Z 2>/dev/null || echo 'unknown')",
210
+ "uptime": "$(uptime 2>/dev/null | cut -d',' -f1 | sed 's/.*up //' || echo 'unknown')"
211
+ }
212
+ }
213
+ EOF
214
+ )
215
+
216
+ # Merge with existing context
217
+ CONTEXT_DATA=$(echo "$current_context" | jq --argjson system "$(echo "$system_context" | jq '.system')" '. + {system: $system}' 2>/dev/null) || {
218
+ log_warning "Failed to merge system context with jq, using concatenation"
219
+ CONTEXT_DATA="$current_context,$system_context"
220
+ }
221
+
222
+ log_debug "System context gathered successfully"
223
+ return $EXIT_SUCCESS
224
+ }
225
+
226
+ ##################################
227
+ # Context File Management
228
+ ##################################
229
+
230
+ create_context_file() {
231
+ local subagent_name="${1:-unknown}"
232
+ local event_type="${2:-unknown}"
233
+
234
+ log_debug "Creating context file for $subagent_name"
235
+
236
+ # Generate unique context file name
237
+ local temp_file
238
+ if ! temp_file=$(create_temp_file "$CONTEXT_FILE_PREFIX" "${subagent_name}-${event_type}-$$"); then
239
+ log_error "Failed to create context temp file"
240
+ return $EXIT_GENERAL_ERROR
241
+ fi
242
+
243
+ CONTEXT_FILE="$temp_file"
244
+ log_debug "Context file created: $CONTEXT_FILE"
245
+ return $EXIT_SUCCESS
246
+ }
247
+
248
+ write_context_to_file() {
249
+ local context_file="${1:-$CONTEXT_FILE}"
250
+ local context_data="${2:-$CONTEXT_DATA}"
251
+
252
+ if [[ -z "$context_file" ]]; then
253
+ log_error "Context file path not specified"
254
+ return $EXIT_GENERAL_ERROR
255
+ fi
256
+
257
+ if [[ -z "$context_data" ]]; then
258
+ log_error "No context data to write"
259
+ return $EXIT_GENERAL_ERROR
260
+ fi
261
+
262
+ log_debug "Writing context data to file: $context_file"
263
+
264
+ # Validate JSON format if possible
265
+ if command -v jq >/dev/null 2>&1; then
266
+ if ! echo "$context_data" | jq . >/dev/null 2>&1; then
267
+ log_warning "Context data is not valid JSON, writing as-is"
268
+ fi
269
+ fi
270
+
271
+ # Write context data to file
272
+ if ! echo "$context_data" > "$context_file" 2>/dev/null; then
273
+ log_error "Failed to write context data to file: $context_file"
274
+ return $EXIT_GENERAL_ERROR
275
+ fi
276
+
277
+ log_debug "Context data written successfully: $context_file"
278
+ return $EXIT_SUCCESS
279
+ }
280
+
281
+ ##################################
282
+ # Complete Context Gathering
283
+ ##################################
284
+
285
+ gather_complete_context() {
286
+ local event_type="${1:-unknown}"
287
+ local subagent_name="${2:-unknown}"
288
+ local additional_context="${3:-}"
289
+ local include_system="${4:-false}"
290
+
291
+ log_info "Gathering complete context for subagent: $subagent_name"
292
+
293
+ # Gather all context components
294
+ if ! gather_basic_context "$event_type" "$subagent_name" "$additional_context"; then
295
+ log_error "Failed to gather basic context"
296
+ return $EXIT_GENERAL_ERROR
297
+ fi
298
+
299
+ if ! gather_claude_context; then
300
+ log_error "Failed to gather Claude context"
301
+ return $EXIT_GENERAL_ERROR
302
+ fi
303
+
304
+ if ! gather_git_context; then
305
+ log_warning "Failed to gather Git context (continuing)"
306
+ fi
307
+
308
+ if ! gather_file_context; then
309
+ log_warning "Failed to gather file context (continuing)"
310
+ fi
311
+
312
+ if [[ "$include_system" == true ]]; then
313
+ if ! gather_system_context; then
314
+ log_warning "Failed to gather system context (continuing)"
315
+ fi
316
+ fi
317
+
318
+ # Add additional context if provided
319
+ if [[ -n "$additional_context" ]]; then
320
+ add_additional_context "$additional_context"
321
+ fi
322
+
323
+ log_info "Complete context gathering finished"
324
+ return $EXIT_SUCCESS
325
+ }
326
+
327
+ add_additional_context() {
328
+ local additional_context="$1"
329
+ local current_context="$CONTEXT_DATA"
330
+
331
+ if [[ -z "$additional_context" ]]; then
332
+ return $EXIT_SUCCESS
333
+ fi
334
+
335
+ log_debug "Adding additional context"
336
+
337
+ local additional_json
338
+ additional_json=$(cat <<EOF
339
+ {
340
+ "additional": {
341
+ "user_provided": "$additional_context",
342
+ "timestamp": "$(date -u +"%Y-%m-%dT%H:%M:%SZ")"
343
+ }
344
+ }
345
+ EOF
346
+ )
347
+
348
+ # Merge with existing context
349
+ CONTEXT_DATA=$(echo "$current_context" | jq --argjson additional "$(echo "$additional_json" | jq '.additional')" '. + {additional: $additional}' 2>/dev/null) || {
350
+ log_warning "Failed to merge additional context with jq"
351
+ CONTEXT_DATA="$current_context,$additional_json"
352
+ }
353
+
354
+ log_debug "Additional context added successfully"
355
+ return $EXIT_SUCCESS
356
+ }
357
+
358
+ ##################################
359
+ # Context Validation Functions
360
+ ##################################
361
+
362
+ validate_context_data() {
363
+ local context_data="${1:-$CONTEXT_DATA}"
364
+
365
+ if [[ -z "$context_data" ]]; then
366
+ log_error "No context data to validate"
367
+ return $EXIT_VALIDATION_FAILED
368
+ fi
369
+
370
+ log_debug "Validating context data"
371
+
372
+ # Check if it's valid JSON
373
+ if command -v jq >/dev/null 2>&1; then
374
+ if ! echo "$context_data" | jq . >/dev/null 2>&1; then
375
+ log_error "Context data is not valid JSON"
376
+ return $EXIT_VALIDATION_FAILED
377
+ fi
378
+ fi
379
+
380
+ # Check for required fields
381
+ local required_fields=("metadata" "event" "environment")
382
+ local field
383
+
384
+ for field in "${required_fields[@]}"; do
385
+ if command -v jq >/dev/null 2>&1; then
386
+ if ! echo "$context_data" | jq -e ".$field" >/dev/null 2>&1; then
387
+ log_error "Required context field missing: $field"
388
+ return $EXIT_VALIDATION_FAILED
389
+ fi
390
+ else
391
+ # Fallback validation without jq
392
+ if ! echo "$context_data" | grep -q "\"$field\""; then
393
+ log_error "Required context field missing: $field"
394
+ return $EXIT_VALIDATION_FAILED
395
+ fi
396
+ fi
397
+ done
398
+
399
+ log_debug "Context data validation passed"
400
+ return $EXIT_SUCCESS
401
+ }
402
+
403
+ validate_context_file() {
404
+ local context_file="${1:-$CONTEXT_FILE}"
405
+
406
+ if [[ -z "$context_file" ]]; then
407
+ log_error "No context file specified"
408
+ return $EXIT_VALIDATION_FAILED
409
+ fi
410
+
411
+ if ! file_exists_and_readable "$context_file"; then
412
+ log_error "Context file not accessible: $context_file"
413
+ return $EXIT_VALIDATION_FAILED
414
+ fi
415
+
416
+ # Read and validate content
417
+ local content
418
+ if ! content=$(read_file_safely "$context_file"); then
419
+ log_error "Failed to read context file: $context_file"
420
+ return $EXIT_VALIDATION_FAILED
421
+ fi
422
+
423
+ if ! validate_context_data "$content"; then
424
+ log_error "Context file contains invalid data: $context_file"
425
+ return $EXIT_VALIDATION_FAILED
426
+ fi
427
+
428
+ log_debug "Context file validation passed: $context_file"
429
+ return $EXIT_SUCCESS
430
+ }
431
+
432
+ ##################################
433
+ # Context Cleanup Functions
434
+ ##################################
435
+
436
+ cleanup_context_file() {
437
+ local context_file="${1:-$CONTEXT_FILE}"
438
+
439
+ if [[ -n "$context_file" ]] && [[ -f "$context_file" ]]; then
440
+ log_debug "Cleaning up context file: $context_file"
441
+ cleanup_specific_temp_file "$context_file"
442
+ fi
443
+
444
+ # Reset global variables
445
+ CONTEXT_FILE=""
446
+ CONTEXT_DATA=""
447
+
448
+ return $EXIT_SUCCESS
449
+ }
450
+
451
+ cleanup_all_context_files() {
452
+ log_debug "Cleaning up all context files"
453
+
454
+ # Clean up temporary context files
455
+ cleanup_temp_files "$CONTEXT_FILE_PREFIX*"
456
+
457
+ return $EXIT_SUCCESS
458
+ }
459
+
460
+ ##################################
461
+ # Context Access Functions
462
+ ##################################
463
+
464
+ get_context_file() {
465
+ echo "$CONTEXT_FILE"
466
+ }
467
+
468
+ get_context_data() {
469
+ echo "$CONTEXT_DATA"
470
+ }
471
+
472
+ get_context_field() {
473
+ local field_path="$1"
474
+ local context_data="${2:-$CONTEXT_DATA}"
475
+
476
+ if [[ -z "$field_path" ]]; then
477
+ log_error "Field path is required"
478
+ return $EXIT_VALIDATION_FAILED
479
+ fi
480
+
481
+ if command -v jq >/dev/null 2>&1; then
482
+ echo "$context_data" | jq -r "$field_path" 2>/dev/null || echo ""
483
+ else
484
+ log_warning "jq not available, cannot extract field: $field_path"
485
+ return $EXIT_GENERAL_ERROR
486
+ fi
487
+ }
488
+
489
+ ##################################
490
+ # Context Debugging Functions
491
+ ##################################
492
+
493
+ dump_context() {
494
+ local format="${1:-json}"
495
+ local context_data="${2:-$CONTEXT_DATA}"
496
+
497
+ log_info "Dumping context (format: $format)"
498
+
499
+ case "$format" in
500
+ "json")
501
+ if command -v jq >/dev/null 2>&1; then
502
+ echo "$context_data" | jq .
503
+ else
504
+ echo "$context_data"
505
+ fi
506
+ ;;
507
+ "yaml")
508
+ if command -v yq >/dev/null 2>&1; then
509
+ echo "$context_data" | yq .
510
+ else
511
+ log_warning "yq not available, falling back to JSON"
512
+ dump_context "json" "$context_data"
513
+ fi
514
+ ;;
515
+ "text"|*)
516
+ echo "Context Summary:"
517
+ echo "==============="
518
+
519
+ if command -v jq >/dev/null 2>&1; then
520
+ echo "Event: $(echo "$context_data" | jq -r '.event.type // "unknown"')"
521
+ echo "Subagent: $(echo "$context_data" | jq -r '.event.subagent // "unknown"')"
522
+ echo "User: $(echo "$context_data" | jq -r '.environment.user // "unknown"')"
523
+ echo "Working Directory: $(echo "$context_data" | jq -r '.environment.working_directory // "unknown"')"
524
+ echo "Timestamp: $(echo "$context_data" | jq -r '.metadata.timestamp // "unknown"')"
525
+ else
526
+ echo "Raw context data:"
527
+ echo "$context_data"
528
+ fi
529
+ ;;
530
+ esac
531
+ }
532
+
533
+ ##################################
534
+ # Initialization
535
+ ##################################
536
+
537
+ initialize_context_manager() {
538
+ log_debug "Context manager module initialized"
539
+
540
+ # CONTEXT_TIMEOUT is already set in config-constants.sh as readonly
541
+
542
+ # Ensure temp directory is available
543
+ if [[ ! -d "/tmp" ]]; then
544
+ log_error "Temporary directory not available"
545
+ return $EXIT_GENERAL_ERROR
546
+ fi
547
+
548
+ return $EXIT_SUCCESS
549
+ }