@paulduvall/claude-dev-toolkit 0.0.1-alpha.1 → 0.0.1-alpha.11

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 (141) hide show
  1. package/README.md +74 -23
  2. package/bin/claude-commands +263 -64
  3. package/commands/active/xarchitecture.md +393 -0
  4. package/commands/active/xconfig.md +127 -0
  5. package/commands/active/xdebug.md +130 -0
  6. package/commands/active/xdocs.md +178 -0
  7. package/commands/active/xgit.md +149 -0
  8. package/commands/active/xpipeline.md +152 -0
  9. package/commands/active/xquality.md +96 -0
  10. package/commands/active/xrefactor.md +198 -0
  11. package/commands/active/xrelease.md +142 -0
  12. package/commands/active/xsecurity.md +92 -0
  13. package/commands/active/xspec.md +174 -0
  14. package/commands/active/xtdd.md +151 -0
  15. package/commands/active/xtest.md +89 -0
  16. package/commands/experiments/xact.md +742 -0
  17. package/commands/experiments/xanalytics.md +113 -0
  18. package/commands/experiments/xanalyze.md +70 -0
  19. package/commands/experiments/xapi.md +161 -0
  20. package/commands/experiments/xatomic.md +112 -0
  21. package/commands/experiments/xaws.md +85 -0
  22. package/commands/experiments/xcicd.md +337 -0
  23. package/commands/experiments/xcommit.md +122 -0
  24. package/commands/experiments/xcompliance.md +182 -0
  25. package/commands/experiments/xconstraints.md +89 -0
  26. package/commands/experiments/xcoverage.md +90 -0
  27. package/commands/experiments/xdb.md +102 -0
  28. package/commands/experiments/xdesign.md +121 -0
  29. package/commands/experiments/xevaluate.md +111 -0
  30. package/commands/experiments/xfootnote.md +12 -0
  31. package/commands/experiments/xgenerate.md +117 -0
  32. package/commands/experiments/xgovernance.md +149 -0
  33. package/commands/experiments/xgreen.md +66 -0
  34. package/commands/experiments/xiac.md +118 -0
  35. package/commands/experiments/xincident.md +137 -0
  36. package/commands/experiments/xinfra.md +115 -0
  37. package/commands/experiments/xknowledge.md +115 -0
  38. package/commands/experiments/xmaturity.md +120 -0
  39. package/commands/experiments/xmetrics.md +118 -0
  40. package/commands/experiments/xmonitoring.md +128 -0
  41. package/commands/experiments/xnew.md +898 -0
  42. package/commands/experiments/xobservable.md +114 -0
  43. package/commands/experiments/xoidc.md +165 -0
  44. package/commands/experiments/xoptimize.md +115 -0
  45. package/commands/experiments/xperformance.md +112 -0
  46. package/commands/experiments/xplanning.md +131 -0
  47. package/commands/experiments/xpolicy.md +115 -0
  48. package/commands/experiments/xproduct.md +98 -0
  49. package/commands/experiments/xreadiness.md +75 -0
  50. package/commands/experiments/xred.md +55 -0
  51. package/commands/experiments/xrisk.md +128 -0
  52. package/commands/experiments/xrules.md +124 -0
  53. package/commands/experiments/xsandbox.md +120 -0
  54. package/commands/experiments/xscan.md +102 -0
  55. package/commands/experiments/xsetup.md +123 -0
  56. package/commands/experiments/xtemplate.md +116 -0
  57. package/commands/experiments/xtrace.md +212 -0
  58. package/commands/experiments/xux.md +171 -0
  59. package/commands/experiments/xvalidate.md +104 -0
  60. package/commands/experiments/xworkflow.md +113 -0
  61. package/hooks/README.md +231 -0
  62. package/hooks/file-logger.sh +98 -0
  63. package/hooks/lib/argument-parser.sh +422 -0
  64. package/hooks/lib/config-constants.sh +230 -0
  65. package/hooks/lib/context-manager.sh +549 -0
  66. package/hooks/lib/error-handler.sh +412 -0
  67. package/hooks/lib/execution-engine.sh +627 -0
  68. package/hooks/lib/file-utils.sh +375 -0
  69. package/hooks/lib/subagent-discovery.sh +465 -0
  70. package/hooks/lib/subagent-validator.sh +597 -0
  71. package/hooks/on-error-debug.sh +221 -0
  72. package/hooks/pre-commit-quality.sh +204 -0
  73. package/hooks/pre-write-security.sh +107 -0
  74. package/hooks/prevent-credential-exposure.sh +265 -0
  75. package/hooks/subagent-trigger-simple.sh +193 -0
  76. package/hooks/subagent-trigger.sh +253 -0
  77. package/lib/backup-restore-command.js +140 -0
  78. package/lib/base/base-command.js +252 -0
  79. package/lib/base/command-result.js +184 -0
  80. package/lib/config/constants.js +255 -0
  81. package/lib/config.js +228 -3
  82. package/lib/configure-command.js +428 -0
  83. package/lib/dependency-validator.js +64 -5
  84. package/lib/hook-installer-core.js +2 -2
  85. package/lib/installation-instruction-generator-backup.js +579 -0
  86. package/lib/installation-instruction-generator.js +213 -495
  87. package/lib/installer.js +134 -56
  88. package/lib/oidc-command.js +363 -0
  89. package/lib/result.js +138 -0
  90. package/lib/services/backup-list-service.js +226 -0
  91. package/lib/services/backup-service.js +230 -0
  92. package/lib/services/command-installer-service.js +217 -0
  93. package/lib/services/logger-service.js +201 -0
  94. package/lib/services/package-manager-service.js +319 -0
  95. package/lib/services/platform-instruction-service.js +294 -0
  96. package/lib/services/recovery-instruction-service.js +348 -0
  97. package/lib/services/restore-service.js +221 -0
  98. package/lib/setup-command.js +309 -0
  99. package/lib/subagent-formatter.js +278 -0
  100. package/lib/subagents-core.js +237 -0
  101. package/lib/subagents.js +508 -0
  102. package/lib/types.d.ts +183 -0
  103. package/lib/utils/claude-path-config.js +184 -0
  104. package/lib/utils/file-system-utils.js +152 -0
  105. package/lib/utils.js +8 -4
  106. package/lib/verify-command.js +430 -0
  107. package/package.json +17 -4
  108. package/scripts/postinstall.js +28 -10
  109. package/subagents/api-guardian.md +29 -0
  110. package/subagents/audit-trail-verifier.md +24 -0
  111. package/subagents/change-scoper.md +23 -0
  112. package/subagents/ci-pipeline-curator.md +24 -0
  113. package/subagents/code-review-assistant.md +258 -0
  114. package/subagents/continuous-release-orchestrator.md +29 -0
  115. package/subagents/contract-tester.md +24 -0
  116. package/subagents/data-steward.md +29 -0
  117. package/subagents/debug-context.md +197 -0
  118. package/subagents/debug-specialist.md +138 -0
  119. package/subagents/dependency-steward.md +24 -0
  120. package/subagents/deployment-strategist.md +29 -0
  121. package/subagents/documentation-curator.md +29 -0
  122. package/subagents/environment-guardian.md +29 -0
  123. package/subagents/license-compliance-guardian.md +29 -0
  124. package/subagents/observability-engineer.md +25 -0
  125. package/subagents/performance-guardian.md +29 -0
  126. package/subagents/product-owner-proxy.md +28 -0
  127. package/subagents/requirements-reviewer.md +26 -0
  128. package/subagents/rollback-first-responder.md +24 -0
  129. package/subagents/sbom-provenance.md +25 -0
  130. package/subagents/security-auditor.md +29 -0
  131. package/subagents/style-enforcer.md +23 -0
  132. package/subagents/test-writer.md +24 -0
  133. package/subagents/trunk-guardian.md +29 -0
  134. package/subagents/workflow-coordinator.md +26 -0
  135. package/templates/README.md +100 -0
  136. package/templates/basic-settings.json +30 -0
  137. package/templates/comprehensive-settings.json +206 -0
  138. package/templates/hybrid-hook-config.yaml +133 -0
  139. package/templates/security-focused-settings.json +62 -0
  140. package/templates/subagent-hooks.yaml +188 -0
  141. package/tsconfig.json +37 -0
@@ -0,0 +1,465 @@
1
+ #!/usr/bin/env bash
2
+
3
+ # Subagent Discovery Module for Subagent-Hook Integration
4
+ #
5
+ # This module provides functionality to discover, locate, and enumerate
6
+ # available subagents across different directory hierarchies.
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
+ # Discovery Functions
16
+ ##################################
17
+
18
+ find_subagent() {
19
+ local subagent_name="$1"
20
+
21
+ if [[ -z "$subagent_name" ]]; then
22
+ log_error "Subagent name is required for discovery"
23
+ return $EXIT_VALIDATION_FAILED
24
+ fi
25
+
26
+ log_debug "Searching for subagent: $subagent_name"
27
+
28
+ # Use the file utilities function for path resolution
29
+ local subagent_path
30
+ if subagent_path=$(resolve_subagent_path "$subagent_name"); then
31
+ log_debug "Found subagent at: $subagent_path"
32
+ echo "$subagent_path"
33
+ return $EXIT_SUCCESS
34
+ else
35
+ log_debug "Subagent not found: $subagent_name"
36
+ return $EXIT_SUBAGENT_NOT_FOUND
37
+ fi
38
+ }
39
+
40
+ discover_available_subagents() {
41
+ local search_dir="${1:-$SUBAGENTS_DIR}"
42
+ local subagents=()
43
+
44
+ log_debug "Discovering subagents in: $search_dir"
45
+
46
+ if [[ ! -d "$search_dir" ]]; then
47
+ log_debug "Subagents directory does not exist: $search_dir"
48
+ return $EXIT_SUCCESS
49
+ fi
50
+
51
+ # Find all .md files in the subagents directory
52
+ while IFS= read -r -d '' file; do
53
+ if is_valid_subagent_file "$file"; then
54
+ local name
55
+ name=$(basename "$file" "$SUBAGENT_FILE_EXTENSION")
56
+ subagents+=("$name")
57
+ log_debug "Discovered valid subagent: $name"
58
+ else
59
+ log_debug "Invalid subagent file skipped: $file"
60
+ fi
61
+ done < <(find "$search_dir" -name "*$SUBAGENT_FILE_EXTENSION" -type f -print0 2>/dev/null)
62
+
63
+ # Sort subagents alphabetically
64
+ IFS=$'\n' subagents=($(sort <<<"${subagents[*]}"))
65
+ unset IFS
66
+
67
+ log_debug "Discovery complete: ${#subagents[@]} valid subagents found"
68
+
69
+ # Output results
70
+ printf '%s\n' "${subagents[@]}"
71
+ return $EXIT_SUCCESS
72
+ }
73
+
74
+ get_all_available_subagents() {
75
+ local all_subagents=()
76
+ local user_subagents project_subagents
77
+
78
+ log_debug "Getting all available subagents from all locations"
79
+
80
+ # Get user-level subagents
81
+ if user_subagents=$(discover_available_subagents "$SUBAGENTS_DIR" 2>/dev/null); then
82
+ while IFS= read -r subagent; do
83
+ [[ -n "$subagent" ]] && all_subagents+=("$subagent")
84
+ done <<< "$user_subagents"
85
+ fi
86
+
87
+ # Get project-level subagents (these take priority)
88
+ if [[ -d "$PROJECT_SUBAGENTS_DIR" ]]; then
89
+ if project_subagents=$(discover_available_subagents "$PROJECT_SUBAGENTS_DIR" 2>/dev/null); then
90
+ while IFS= read -r subagent; do
91
+ [[ -n "$subagent" ]] && all_subagents+=("$subagent")
92
+ done <<< "$project_subagents"
93
+ fi
94
+ fi
95
+
96
+ # Remove duplicates (project-level takes precedence)
97
+ local unique_subagents=()
98
+ local -A seen
99
+
100
+ for subagent in "${all_subagents[@]}"; do
101
+ if [[ -z "${seen[$subagent]}" ]]; then
102
+ unique_subagents+=("$subagent")
103
+ seen[$subagent]=1
104
+ fi
105
+ done
106
+
107
+ # Sort results
108
+ IFS=$'\n' unique_subagents=($(sort <<<"${unique_subagents[*]}"))
109
+ unset IFS
110
+
111
+ log_debug "Total unique subagents available: ${#unique_subagents[@]}"
112
+
113
+ # Output results
114
+ printf '%s\n' "${unique_subagents[@]}"
115
+ return $EXIT_SUCCESS
116
+ }
117
+
118
+ ##################################
119
+ # Subagent Information Functions
120
+ ##################################
121
+
122
+ get_subagent_info() {
123
+ local subagent_name="$1"
124
+ local info_type="${2:-all}"
125
+
126
+ if [[ -z "$subagent_name" ]]; then
127
+ log_error "Subagent name is required"
128
+ return $EXIT_VALIDATION_FAILED
129
+ fi
130
+
131
+ local subagent_path
132
+ if ! subagent_path=$(find_subagent "$subagent_name"); then
133
+ log_error "Subagent not found: $subagent_name"
134
+ return $EXIT_SUBAGENT_NOT_FOUND
135
+ fi
136
+
137
+ local content
138
+ if ! content=$(read_file_safely "$subagent_path"); then
139
+ log_error "Failed to read subagent file: $subagent_path"
140
+ return $EXIT_GENERAL_ERROR
141
+ fi
142
+
143
+ # Parse YAML frontmatter
144
+ local in_frontmatter=false
145
+ local name="" description="" version="" tools="" tags=""
146
+
147
+ while IFS= read -r line; do
148
+ if [[ "$line" == "---" ]]; then
149
+ if [[ "$in_frontmatter" == true ]]; then
150
+ break # End of frontmatter
151
+ else
152
+ in_frontmatter=true
153
+ continue
154
+ fi
155
+ fi
156
+
157
+ if [[ "$in_frontmatter" == true ]]; then
158
+ case "$line" in
159
+ name:*)
160
+ name="${line#*: }"
161
+ name="${name#\"}"
162
+ name="${name%\"}"
163
+ ;;
164
+ description:*)
165
+ description="${line#*: }"
166
+ description="${description#\"}"
167
+ description="${description%\"}"
168
+ ;;
169
+ version:*)
170
+ version="${line#*: }"
171
+ version="${version#\"}"
172
+ version="${version%\"}"
173
+ ;;
174
+ tools:*)
175
+ tools="${line#*: }"
176
+ tools="${tools#\"}"
177
+ tools="${tools%\"}"
178
+ ;;
179
+ tags:*)
180
+ tags="${line#*: }"
181
+ ;;
182
+ esac
183
+ fi
184
+ done <<< "$content"
185
+
186
+ # Output requested information
187
+ case "$info_type" in
188
+ "name")
189
+ echo "$name"
190
+ ;;
191
+ "description")
192
+ echo "$description"
193
+ ;;
194
+ "version")
195
+ echo "$version"
196
+ ;;
197
+ "tools")
198
+ echo "$tools"
199
+ ;;
200
+ "tags")
201
+ echo "$tags"
202
+ ;;
203
+ "path")
204
+ echo "$subagent_path"
205
+ ;;
206
+ "all"|*)
207
+ cat <<EOF
208
+ Name: $name
209
+ Description: $description
210
+ Version: ${version:-unknown}
211
+ Tools: ${tools:-all}
212
+ Tags: ${tags:-none}
213
+ Path: $subagent_path
214
+ EOF
215
+ ;;
216
+ esac
217
+
218
+ return $EXIT_SUCCESS
219
+ }
220
+
221
+ list_subagents_with_info() {
222
+ local format="${1:-table}"
223
+ local available_subagents
224
+
225
+ log_debug "Listing all subagents with information (format: $format)"
226
+
227
+ if ! available_subagents=$(get_all_available_subagents); then
228
+ log_error "Failed to get available subagents"
229
+ return $EXIT_GENERAL_ERROR
230
+ fi
231
+
232
+ if [[ -z "$available_subagents" ]]; then
233
+ echo "No subagents found."
234
+ return $EXIT_SUCCESS
235
+ fi
236
+
237
+ case "$format" in
238
+ "json")
239
+ echo "["
240
+ local first=true
241
+ while IFS= read -r subagent; do
242
+ [[ -z "$subagent" ]] && continue
243
+
244
+ if [[ "$first" == true ]]; then
245
+ first=false
246
+ else
247
+ echo ","
248
+ fi
249
+
250
+ local name description version tools path
251
+ name=$(get_subagent_info "$subagent" "name" 2>/dev/null || echo "$subagent")
252
+ description=$(get_subagent_info "$subagent" "description" 2>/dev/null || echo "")
253
+ version=$(get_subagent_info "$subagent" "version" 2>/dev/null || echo "unknown")
254
+ tools=$(get_subagent_info "$subagent" "tools" 2>/dev/null || echo "all")
255
+ path=$(get_subagent_info "$subagent" "path" 2>/dev/null || echo "")
256
+
257
+ cat <<EOF
258
+ {
259
+ "name": "$name",
260
+ "description": "$description",
261
+ "version": "$version",
262
+ "tools": "$tools",
263
+ "path": "$path"
264
+ }
265
+ EOF
266
+ done <<< "$available_subagents"
267
+ echo "]"
268
+ ;;
269
+ "table"|*)
270
+ printf "%-20s %-50s %-10s\n" "NAME" "DESCRIPTION" "VERSION"
271
+ printf "%-20s %-50s %-10s\n" "----" "-----------" "-------"
272
+
273
+ while IFS= read -r subagent; do
274
+ [[ -z "$subagent" ]] && continue
275
+
276
+ local name description version
277
+ name=$(get_subagent_info "$subagent" "name" 2>/dev/null || echo "$subagent")
278
+ description=$(get_subagent_info "$subagent" "description" 2>/dev/null || echo "No description")
279
+ version=$(get_subagent_info "$subagent" "version" 2>/dev/null || echo "unknown")
280
+
281
+ # Truncate long descriptions
282
+ if [[ ${#description} -gt 47 ]]; then
283
+ description="${description:0:44}..."
284
+ fi
285
+
286
+ printf "%-20s %-50s %-10s\n" "$name" "$description" "$version"
287
+ done <<< "$available_subagents"
288
+ ;;
289
+ esac
290
+
291
+ return $EXIT_SUCCESS
292
+ }
293
+
294
+ ##################################
295
+ # Event-Based Discovery Functions
296
+ ##################################
297
+
298
+ get_subagents_for_event() {
299
+ local event_type="$1"
300
+ local config_file="${2:-$CONFIG_FILE}"
301
+ local subagents=()
302
+
303
+ if [[ -z "$event_type" ]]; then
304
+ log_error "Event type is required"
305
+ return $EXIT_VALIDATION_FAILED
306
+ fi
307
+
308
+ log_debug "Finding subagents for event: $event_type"
309
+
310
+ # Check if config file exists
311
+ if [[ ! -f "$config_file" ]]; then
312
+ log_debug "Configuration file not found: $config_file"
313
+ return $EXIT_SUCCESS
314
+ fi
315
+
316
+ if ! file_exists_and_readable "$config_file"; then
317
+ log_error "Configuration file not readable: $config_file"
318
+ return $EXIT_GENERAL_ERROR
319
+ fi
320
+
321
+ # Simple YAML parsing for event mappings
322
+ local in_event=false
323
+ local content
324
+
325
+ if ! content=$(read_file_safely "$config_file"); then
326
+ log_error "Failed to read configuration file: $config_file"
327
+ return $EXIT_GENERAL_ERROR
328
+ fi
329
+
330
+ while IFS= read -r line; do
331
+ # Skip comments and empty lines
332
+ [[ "$line" =~ ^[[:space:]]*# ]] && continue
333
+ [[ -z "${line// }" ]] && continue
334
+
335
+ # Check for event section
336
+ if [[ "$line" =~ ^[[:space:]]*${event_type}:[[:space:]]*$ ]]; then
337
+ in_event=true
338
+ log_debug "Found event section: $event_type"
339
+ continue
340
+ elif [[ "$line" =~ ^[[:space:]]*[a-z_][a-z0-9_-]*:[[:space:]]*$ ]]; then
341
+ in_event=false
342
+ continue
343
+ fi
344
+
345
+ # Extract subagent names from list items
346
+ if [[ "$in_event" == true ]] && [[ "$line" =~ ^[[:space:]]*-[[:space:]]*([a-z][a-z0-9-]*)[[:space:]]*$ ]]; then
347
+ local subagent_name="${BASH_REMATCH[1]}"
348
+
349
+ # Verify subagent exists before adding to list
350
+ if find_subagent "$subagent_name" >/dev/null 2>&1; then
351
+ subagents+=("$subagent_name")
352
+ log_debug "Added subagent for event: $subagent_name"
353
+ else
354
+ log_warning "Configured subagent not found: $subagent_name"
355
+ fi
356
+ fi
357
+ done <<< "$content"
358
+
359
+ log_debug "Found ${#subagents[@]} subagents for event: $event_type"
360
+
361
+ # Output results
362
+ printf '%s\n' "${subagents[@]}"
363
+ return $EXIT_SUCCESS
364
+ }
365
+
366
+ get_priority_for_subagent() {
367
+ local subagent_name="$1"
368
+ local config_file="${2:-$CONFIG_FILE}"
369
+ local default_priority="$DEFAULT_PRIORITY"
370
+
371
+ if [[ -z "$subagent_name" ]]; then
372
+ log_error "Subagent name is required"
373
+ return $EXIT_VALIDATION_FAILED
374
+ fi
375
+
376
+ # Check if config file exists and is readable
377
+ if [[ ! -f "$config_file" ]] || ! file_exists_and_readable "$config_file"; then
378
+ echo "$default_priority"
379
+ return $EXIT_SUCCESS
380
+ fi
381
+
382
+ local content
383
+ if ! content=$(read_file_safely "$config_file"); then
384
+ echo "$default_priority"
385
+ return $EXIT_SUCCESS
386
+ fi
387
+
388
+ # Look for priority configuration
389
+ local in_priorities=false
390
+ local in_subagent=false
391
+
392
+ while IFS= read -r line; do
393
+ # Skip comments and empty lines
394
+ [[ "$line" =~ ^[[:space:]]*# ]] && continue
395
+ [[ -z "${line// }" ]] && continue
396
+
397
+ # Check for priorities section
398
+ if [[ "$line" =~ ^[[:space:]]*priorities:[[:space:]]*$ ]]; then
399
+ in_priorities=true
400
+ continue
401
+ elif [[ "$line" =~ ^[[:space:]]*[a-z_][a-z0-9_-]*:[[:space:]]*$ ]] && [[ "$in_priorities" == false ]]; then
402
+ continue
403
+ fi
404
+
405
+ # Check for subagent in priorities section
406
+ if [[ "$in_priorities" == true ]]; then
407
+ if [[ "$line" =~ ^[[:space:]]*${subagent_name}:[[:space:]]*$ ]]; then
408
+ in_subagent=true
409
+ continue
410
+ elif [[ "$line" =~ ^[[:space:]]*[a-z][a-z0-9-]*:[[:space:]]*$ ]]; then
411
+ in_subagent=false
412
+ continue
413
+ fi
414
+
415
+ # Extract priority value
416
+ if [[ "$in_subagent" == true ]] && [[ "$line" =~ ^[[:space:]]*priority:[[:space:]]*([0-9]+)[[:space:]]*$ ]]; then
417
+ echo "${BASH_REMATCH[1]}"
418
+ return $EXIT_SUCCESS
419
+ fi
420
+ fi
421
+ done <<< "$content"
422
+
423
+ # Return default if not found
424
+ echo "$default_priority"
425
+ return $EXIT_SUCCESS
426
+ }
427
+
428
+ ##################################
429
+ # Discovery Validation Functions
430
+ ##################################
431
+
432
+ validate_discovery_environment() {
433
+ log_debug "Validating discovery environment"
434
+
435
+ # Check if subagents directory exists
436
+ if [[ ! -d "$SUBAGENTS_DIR" ]]; then
437
+ log_warning "User subagents directory does not exist: $SUBAGENTS_DIR"
438
+ if ! ensure_directory_exists "$SUBAGENTS_DIR"; then
439
+ log_error "Failed to create subagents directory: $SUBAGENTS_DIR"
440
+ return $EXIT_GENERAL_ERROR
441
+ fi
442
+ fi
443
+
444
+ # Check directory permissions
445
+ if [[ ! -r "$SUBAGENTS_DIR" ]]; then
446
+ log_error "Subagents directory not readable: $SUBAGENTS_DIR"
447
+ return $EXIT_GENERAL_ERROR
448
+ fi
449
+
450
+ log_debug "Discovery environment validation complete"
451
+ return $EXIT_SUCCESS
452
+ }
453
+
454
+ ##################################
455
+ # Initialization
456
+ ##################################
457
+
458
+ initialize_subagent_discovery() {
459
+ log_debug "Subagent discovery module initialized"
460
+
461
+ # Validate discovery environment
462
+ validate_discovery_environment || return $?
463
+
464
+ return $EXIT_SUCCESS
465
+ }