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

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 (143) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +88 -37
  3. package/bin/claude-commands +307 -65
  4. package/commands/active/xarchitecture.md +393 -0
  5. package/commands/active/xconfig.md +127 -0
  6. package/commands/active/xcontinue.md +92 -0
  7. package/commands/active/xdebug.md +130 -0
  8. package/commands/active/xdocs.md +178 -0
  9. package/commands/active/xexplore.md +94 -0
  10. package/commands/active/xgit.md +149 -0
  11. package/commands/active/xpipeline.md +152 -0
  12. package/commands/active/xquality.md +96 -0
  13. package/commands/active/xrefactor.md +198 -0
  14. package/commands/active/xrelease.md +142 -0
  15. package/commands/active/xsecurity.md +92 -0
  16. package/commands/active/xspec.md +174 -0
  17. package/commands/active/xtdd.md +151 -0
  18. package/commands/active/xtest.md +89 -0
  19. package/commands/active/xverify.md +80 -0
  20. package/commands/experiments/xact.md +742 -0
  21. package/commands/experiments/xanalytics.md +113 -0
  22. package/commands/experiments/xanalyze.md +70 -0
  23. package/commands/experiments/xapi.md +161 -0
  24. package/commands/experiments/xatomic.md +112 -0
  25. package/commands/experiments/xaws.md +85 -0
  26. package/commands/experiments/xcicd.md +337 -0
  27. package/commands/experiments/xcommit.md +122 -0
  28. package/commands/experiments/xcompliance.md +182 -0
  29. package/commands/experiments/xconstraints.md +89 -0
  30. package/commands/experiments/xcoverage.md +90 -0
  31. package/commands/experiments/xdb.md +102 -0
  32. package/commands/experiments/xdesign.md +121 -0
  33. package/commands/experiments/xdevcontainer.md +238 -0
  34. package/commands/experiments/xevaluate.md +111 -0
  35. package/commands/experiments/xfootnote.md +12 -0
  36. package/commands/experiments/xgenerate.md +117 -0
  37. package/commands/experiments/xgovernance.md +149 -0
  38. package/commands/experiments/xgreen.md +66 -0
  39. package/commands/experiments/xiac.md +118 -0
  40. package/commands/experiments/xincident.md +137 -0
  41. package/commands/experiments/xinfra.md +115 -0
  42. package/commands/experiments/xknowledge.md +115 -0
  43. package/commands/experiments/xmaturity.md +120 -0
  44. package/commands/experiments/xmetrics.md +118 -0
  45. package/commands/experiments/xmonitoring.md +128 -0
  46. package/commands/experiments/xnew.md +903 -0
  47. package/commands/experiments/xobservable.md +114 -0
  48. package/commands/experiments/xoidc.md +165 -0
  49. package/commands/experiments/xoptimize.md +115 -0
  50. package/commands/experiments/xperformance.md +112 -0
  51. package/commands/experiments/xplanning.md +131 -0
  52. package/commands/experiments/xpolicy.md +115 -0
  53. package/commands/experiments/xproduct.md +98 -0
  54. package/commands/experiments/xreadiness.md +75 -0
  55. package/commands/experiments/xred.md +55 -0
  56. package/commands/experiments/xrisk.md +128 -0
  57. package/commands/experiments/xrules.md +124 -0
  58. package/commands/experiments/xsandbox.md +120 -0
  59. package/commands/experiments/xscan.md +102 -0
  60. package/commands/experiments/xsetup.md +123 -0
  61. package/commands/experiments/xtemplate.md +116 -0
  62. package/commands/experiments/xtrace.md +212 -0
  63. package/commands/experiments/xux.md +171 -0
  64. package/commands/experiments/xvalidate.md +104 -0
  65. package/commands/experiments/xworkflow.md +113 -0
  66. package/hooks/.smellrc.example.json +19 -0
  67. package/hooks/README.md +263 -0
  68. package/hooks/check-commit-signing.py +127 -0
  69. package/hooks/check-complexity.py +38 -0
  70. package/hooks/check-security.py +37 -0
  71. package/hooks/claude-wrapper.sh +29 -0
  72. package/hooks/config.py +110 -0
  73. package/hooks/file-logger.sh +100 -0
  74. package/hooks/lib/argument-parser.sh +427 -0
  75. package/hooks/lib/config-constants.sh +230 -0
  76. package/hooks/lib/context-manager.sh +560 -0
  77. package/hooks/lib/error-handler.sh +423 -0
  78. package/hooks/lib/execution-engine.sh +444 -0
  79. package/hooks/lib/execution-results.sh +113 -0
  80. package/hooks/lib/execution-simulation.sh +114 -0
  81. package/hooks/lib/field-validators.sh +104 -0
  82. package/hooks/lib/file-utils.sh +398 -0
  83. package/hooks/lib/subagent-discovery.sh +468 -0
  84. package/hooks/lib/subagent-validator.sh +407 -0
  85. package/hooks/lib/validation-reporter.sh +134 -0
  86. package/hooks/on-error-debug.sh +226 -0
  87. package/hooks/pre-commit-quality.sh +204 -0
  88. package/hooks/pre-commit-test-runner.sh +132 -0
  89. package/hooks/pre-write-security.sh +115 -0
  90. package/hooks/prevent-credential-exposure.sh +279 -0
  91. package/hooks/security_bandit.py +177 -0
  92. package/hooks/security_checks.py +97 -0
  93. package/hooks/security_secrets.py +81 -0
  94. package/hooks/security_trojan.py +61 -0
  95. package/hooks/settings.example.json +52 -0
  96. package/hooks/smell_checks.py +238 -0
  97. package/hooks/smell_javascript.py +231 -0
  98. package/hooks/smell_python.py +110 -0
  99. package/hooks/smell_ruff.py +70 -0
  100. package/hooks/smell_types.py +72 -0
  101. package/hooks/subagent-trigger-simple.sh +202 -0
  102. package/hooks/subagent-trigger.sh +253 -0
  103. package/hooks/suppression.py +82 -0
  104. package/hooks/tab-color.sh +70 -0
  105. package/hooks/verify-before-edit.sh +135 -0
  106. package/lib/backup-restore-command.js +140 -0
  107. package/lib/base/base-command.js +252 -0
  108. package/lib/base/command-result.js +184 -0
  109. package/lib/config/constants.js +255 -0
  110. package/lib/config.js +48 -6
  111. package/lib/configure-command.js +428 -0
  112. package/lib/dependency-validator.js +64 -5
  113. package/lib/hook-installer-core.js +2 -2
  114. package/lib/installation-instruction-generator.js +213 -495
  115. package/lib/installer.js +134 -56
  116. package/lib/oidc-command.js +740 -0
  117. package/lib/services/backup-list-service.js +226 -0
  118. package/lib/services/backup-service.js +230 -0
  119. package/lib/services/command-installer-service.js +217 -0
  120. package/lib/services/logger-service.js +201 -0
  121. package/lib/services/package-manager-service.js +319 -0
  122. package/lib/services/platform-instruction-service.js +294 -0
  123. package/lib/services/recovery-instruction-service.js +348 -0
  124. package/lib/services/restore-service.js +221 -0
  125. package/lib/setup-command.js +359 -0
  126. package/lib/setup-wizard.js +155 -262
  127. package/lib/uninstall-command.js +100 -0
  128. package/lib/utils/claude-path-config.js +184 -0
  129. package/lib/utils/file-system-utils.js +152 -0
  130. package/lib/utils.js +8 -4
  131. package/lib/verify-command.js +430 -0
  132. package/package.json +7 -3
  133. package/scripts/postinstall.js +172 -157
  134. package/subagents/debug-specialist.md +7 -0
  135. package/templates/README.md +115 -0
  136. package/templates/basic-settings.json +30 -0
  137. package/templates/comprehensive-settings.json +57 -0
  138. package/templates/global-claude.md +344 -0
  139. package/templates/hybrid-hook-config.yaml +132 -0
  140. package/templates/security-focused-settings.json +62 -0
  141. package/templates/subagent-hooks.yaml +188 -0
  142. package/lib/package-manager-service.js +0 -270
  143. package/subagents/debug-context.md +0 -197
@@ -0,0 +1,742 @@
1
+ ---
2
+ description: Local GitHub Actions testing with nektos/act for rapid development feedback
3
+ tags: [github-actions, local-testing, development, act, docker, automation, macos]
4
+ ---
5
+
6
+ # `/xact` - Local GitHub Actions Testing
7
+
8
+ Test GitHub Actions workflows locally using nektos/act for fast feedback during development, before pushing to GitHub.
9
+
10
+ ## Usage
11
+
12
+ ```bash
13
+ /xact # Auto-discover and run all workflows
14
+ /xact --workflow ci.yml # Run specific workflow file
15
+ /xact --job test # Run specific job only
16
+ /xact --list # List available workflows
17
+ /xact --install-deps # Install nektos/act and Docker
18
+ /xact --check-deps # Check dependency status
19
+ /xact --simulate # Run in simulation mode
20
+ /xact --dry-run # Preview execution without running
21
+ /xact --start-docker # Start Docker daemon (macOS)
22
+ ```
23
+
24
+ ## Options
25
+
26
+ ### Core Operations
27
+
28
+ **`--workflow <file>`** - Run specific workflow file
29
+ ```bash
30
+ /xact --workflow .github/workflows/ci.yml
31
+ /xact --workflow tests.yml
32
+ ```
33
+
34
+ **`--job <name>`** - Execute specific job only
35
+ ```bash
36
+ /xact --job test
37
+ /xact --job build
38
+ /xact --job security-scan
39
+ ```
40
+
41
+ **`--list`** - List all available workflows
42
+ ```bash
43
+ /xact --list # Show discoverable workflows
44
+ ```
45
+
46
+ ### Dependency Management
47
+
48
+ **`--install-deps`** - Install nektos/act and Docker
49
+ ```bash
50
+ /xact --install-deps # Auto-install dependencies
51
+ ```
52
+
53
+ **`--check-deps`** - Verify dependency availability
54
+ ```bash
55
+ /xact --check-deps # Check act and Docker status
56
+ ```
57
+
58
+ **`--start-docker`** - Start Docker daemon (macOS-specific)
59
+ ```bash
60
+ /xact --start-docker # Launch Docker Desktop on macOS
61
+ ```
62
+
63
+ ### Execution Modes
64
+
65
+ **`--simulate`** - Run in fallback simulation mode
66
+ ```bash
67
+ /xact --simulate # Simulate when Docker unavailable
68
+ ```
69
+
70
+ **`--dry-run`** - Preview without execution
71
+ ```bash
72
+ /xact --dry-run # Show what would be executed
73
+ ```
74
+
75
+ ## Implementation
76
+
77
+ Based on $ARGUMENTS, perform local GitHub Actions testing operations:
78
+
79
+ First, check project structure and workflow availability:
80
+ !find .github/workflows -name "*.yml" -o -name "*.yaml" 2>/dev/null | head -10
81
+ !ls -la .github/workflows/ 2>/dev/null || echo "No GitHub Actions workflows found"
82
+
83
+ Create enhanced Act runner script following your specifications:
84
+
85
+ !cat > scripts/xact.sh << 'EOF'
86
+ #!/bin/bash
87
+ set -euo pipefail
88
+
89
+ # Enhanced GitHub Actions Local Runner using nektos/act
90
+ # Implements: Local GitHub Actions testing with comprehensive dependency management
91
+
92
+ # Colors for professional output
93
+ BLUE='\033[0;34m'
94
+ GREEN='\033[0;32m'
95
+ YELLOW='\033[1;33m'
96
+ RED='\033[0;31m'
97
+ NC='\033[0m' # No Color
98
+
99
+ PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
100
+ TIMEOUT_SECONDS=600
101
+ ACT_CONFIG_FILE="${PROJECT_ROOT}/.actrc"
102
+ ARTIFACT_PATH="/tmp/act-artifacts"
103
+
104
+ # Arrays to track workflow results
105
+ workflow_names=()
106
+ workflow_statuses=()
107
+
108
+ log() {
109
+ echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" >&2
110
+ }
111
+
112
+ # Function to add workflow result
113
+ add_workflow_result() {
114
+ local name="$1"
115
+ local status="$2"
116
+ workflow_names+=("$name")
117
+ workflow_statuses+=("$status")
118
+ }
119
+
120
+ show_help() {
121
+ echo -e "${BLUE}🎬 Enhanced Act GitHub Actions Runner${NC}"
122
+ echo "======================================"
123
+ echo ""
124
+ cat << HELP_EOF
125
+ USAGE:
126
+ ./scripts/xact.sh [OPTIONS] [WORKFLOW_FILE]
127
+
128
+ OPTIONS:
129
+ --help Show this help message
130
+ --check-docker Check Docker availability
131
+ --simulate Run in fallback simulation mode
132
+ --list List available workflows
133
+ --job JOB_NAME Run specific job
134
+ --install-deps Install nektos/act and Docker dependencies
135
+ --check-deps Check for missing dependencies
136
+ --install-docker Install Docker only
137
+ --start-docker Start Docker daemon
138
+
139
+ EXAMPLES:
140
+ ./scripts/xact.sh # Auto-discover and run all workflows
141
+ ./scripts/xact.sh .github/workflows/ci.yml # Run specific workflow
142
+ ./scripts/xact.sh --job test # Run specific job
143
+ ./scripts/xact.sh --simulate # Run in simulation mode
144
+
145
+ FEATURES:
146
+ ✓ Automatic workflow discovery and validation
147
+ ✓ Workflow-specific execution logic
148
+ ✓ Professional colored output
149
+ ✓ Intelligent dependency installation
150
+ ✓ Hybrid real/simulation execution
151
+ ✓ Automatic Docker daemon startup
152
+
153
+ HELP_EOF
154
+ }
155
+
156
+ check_docker() {
157
+ log "Checking Docker availability..."
158
+
159
+ if ! command -v docker &> /dev/null; then
160
+ log "ERROR: Docker not installed"
161
+ echo "docker: not found"
162
+ return 1
163
+ fi
164
+
165
+ if ! docker info &> /dev/null; then
166
+ log "ERROR: Docker daemon not running"
167
+ echo "docker: daemon not running"
168
+ return 1
169
+ fi
170
+
171
+ log "Docker is available and running"
172
+ echo "docker: available"
173
+ return 0
174
+ }
175
+
176
+ run_simulation() {
177
+ log "Running in fallback simulation mode..."
178
+
179
+ cat << SIM_EOF
180
+ === GitHub Actions Workflow Simulation ===
181
+
182
+ This is a fallback simulation for workflows requiring GitHub-specific features.
183
+ Act is not available or Docker is not running.
184
+
185
+ Simulated workflow execution:
186
+ ✓ Workflow syntax validation
187
+ ✓ Job dependency analysis
188
+ ✓ Environment variable validation
189
+ ✓ Artifact path verification
190
+ ✓ Security scan simulation
191
+
192
+ Simulation completed successfully.
193
+ SIM_EOF
194
+ return 0
195
+ }
196
+
197
+ install_dependencies() {
198
+ log "Installing dependencies..."
199
+ local install_failed=false
200
+
201
+ # Install nektos/act
202
+ if ! command -v act &> /dev/null; then
203
+ echo "Installing nektos/act..."
204
+ if [[ "$OSTYPE" == "darwin"* ]]; then
205
+ if command -v brew &> /dev/null; then
206
+ if brew install act; then
207
+ echo "✓ nektos/act installed successfully"
208
+ else
209
+ echo "✗ Failed to install nektos/act via Homebrew"
210
+ install_failed=true
211
+ fi
212
+ else
213
+ echo "✗ Homebrew not found. Please install Homebrew first: https://brew.sh"
214
+ install_failed=true
215
+ fi
216
+ elif [[ "$OSTYPE" == "linux"* ]]; then
217
+ if curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash; then
218
+ echo "✓ nektos/act installed successfully"
219
+ else
220
+ echo "✗ Failed to install nektos/act"
221
+ install_failed=true
222
+ fi
223
+ else
224
+ echo "✗ Unsupported platform: $OSTYPE"
225
+ install_failed=true
226
+ fi
227
+ else
228
+ echo "✓ nektos/act is already installed"
229
+ fi
230
+
231
+ # Check Docker installation
232
+ if ! command -v docker &> /dev/null; then
233
+ echo "Installing Docker..."
234
+ if [[ "$OSTYPE" == "darwin"* ]]; then
235
+ echo "⚠️ Docker Desktop requires manual installation on macOS"
236
+ echo " Please download and install from: https://docker.com/products/docker-desktop"
237
+ echo " After installation, start Docker Desktop and run this script again"
238
+ install_failed=true
239
+ elif [[ "$OSTYPE" == "linux"* ]]; then
240
+ if curl -fsSL https://get.docker.com -o get-docker.sh && sudo sh get-docker.sh; then
241
+ rm -f get-docker.sh
242
+ echo "✓ Docker installed successfully"
243
+ echo "⚠️ You may need to start the Docker service: sudo systemctl start docker"
244
+ else
245
+ rm -f get-docker.sh
246
+ echo "✗ Failed to install Docker"
247
+ install_failed=true
248
+ fi
249
+ else
250
+ echo "✗ Unsupported platform: $OSTYPE"
251
+ install_failed=true
252
+ fi
253
+ else
254
+ echo "✓ Docker is already installed"
255
+ fi
256
+
257
+ if [[ "$install_failed" = true ]]; then
258
+ echo "Some dependencies could not be installed automatically"
259
+ return 1
260
+ fi
261
+
262
+ echo "Dependency installation completed"
263
+ return 0
264
+ }
265
+
266
+ check_dependencies() {
267
+ log "Checking dependencies..."
268
+ local missing_deps=0
269
+
270
+ # Check for nektos/act
271
+ if ! command -v act &> /dev/null; then
272
+ echo "Missing dependency: nektos/act"
273
+ missing_deps=1
274
+ else
275
+ echo "✓ nektos/act is installed"
276
+ fi
277
+
278
+ # Check for Docker
279
+ if ! command -v docker &> /dev/null; then
280
+ echo "Missing dependency: Docker"
281
+ missing_deps=1
282
+ elif ! docker info &> /dev/null; then
283
+ echo "Missing dependency: Docker daemon not running"
284
+ missing_deps=1
285
+ else
286
+ echo "✓ Docker is installed and running"
287
+ fi
288
+
289
+ if [[ $missing_deps -eq 1 ]]; then
290
+ echo "Run './scripts/xact.sh --install-deps' to install missing dependencies"
291
+ return 1
292
+ else
293
+ echo "All dependencies are available"
294
+ return 0
295
+ fi
296
+ }
297
+
298
+ start_docker_daemon() {
299
+ log "Starting Docker daemon..."
300
+
301
+ if [[ "$OSTYPE" == "darwin"* ]]; then
302
+ # macOS - Start Docker Desktop
303
+ echo "Starting Docker Desktop..."
304
+ if command -v open &> /dev/null; then
305
+ # Check if Docker Desktop is installed
306
+ if [ -d "/Applications/Docker.app" ]; then
307
+ if open -a Docker; then
308
+ echo -e "${GREEN}✓${NC} Docker Desktop launch initiated"
309
+ echo "Waiting for Docker daemon to start..."
310
+
311
+ # Wait for Docker daemon to be ready (up to 60 seconds)
312
+ local max_wait=60
313
+ local wait_count=0
314
+ while [ $wait_count -lt $max_wait ]; do
315
+ if docker info &> /dev/null; then
316
+ echo -e "${GREEN}✓${NC} Docker daemon is now running"
317
+ return 0
318
+ fi
319
+ echo -n "."
320
+ sleep 2
321
+ wait_count=$((wait_count + 2))
322
+ done
323
+
324
+ echo ""
325
+ echo -e "${YELLOW}⚠${NC} Docker Desktop started but daemon not ready yet"
326
+ echo "Please wait a moment and try again"
327
+ return 1
328
+ else
329
+ echo -e "${RED}✗${NC} Failed to start Docker Desktop"
330
+ return 1
331
+ fi
332
+ else
333
+ echo -e "${RED}✗${NC} Docker Desktop not found at /Applications/Docker.app"
334
+ echo "Please install Docker Desktop from https://docker.com/products/docker-desktop"
335
+ return 1
336
+ fi
337
+ else
338
+ echo -e "${RED}✗${NC} 'open' command not available"
339
+ return 1
340
+ fi
341
+ elif [[ "$OSTYPE" == "linux"* ]]; then
342
+ # Linux - Start Docker service
343
+ echo "Starting Docker service..."
344
+ if command -v systemctl &> /dev/null; then
345
+ if sudo systemctl start docker; then
346
+ echo -e "${GREEN}✓${NC} Docker service started"
347
+
348
+ # Wait for Docker daemon to be ready
349
+ sleep 5
350
+ if docker info &> /dev/null; then
351
+ echo -e "${GREEN}✓${NC} Docker daemon is running"
352
+ return 0
353
+ else
354
+ echo -e "${YELLOW}⚠${NC} Docker service started but daemon not ready"
355
+ return 1
356
+ fi
357
+ else
358
+ echo -e "${RED}✗${NC} Failed to start Docker service"
359
+ return 1
360
+ fi
361
+ else
362
+ echo -e "${RED}✗${NC} systemctl not available"
363
+ return 1
364
+ fi
365
+ else
366
+ echo -e "${RED}✗${NC} Unsupported platform: $OSTYPE"
367
+ return 1
368
+ fi
369
+ }
370
+
371
+ run_workflow_with_act() {
372
+ local workflow_file="$1"
373
+ local job_name="$2"
374
+ local workflow_name=$(basename "$workflow_file" .yml)
375
+
376
+ echo -e "${BLUE}Running: $workflow_file${NC}"
377
+ echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
378
+
379
+ # Create temporary directory for Act artifacts
380
+ local act_dir="/tmp/act-${workflow_name}-$$"
381
+ mkdir -p "$act_dir"
382
+
383
+ # Determine execution strategy based on workflow type
384
+ local act_args=()
385
+ case "$workflow_name" in
386
+ "security-checks")
387
+ echo -e "${YELLOW}⚠${NC} Security workflow requires GitHub-specific features"
388
+ echo " - CodeQL analysis"
389
+ echo " - Dependency review"
390
+ echo " - Secret scanning"
391
+ echo "These will be simulated locally"
392
+ add_workflow_result "$workflow_name" "simulated"
393
+ rm -rf "$act_dir"
394
+ echo ""
395
+ return 0
396
+ ;;
397
+ "ci")
398
+ # Standard CI workflow
399
+ act_args+=("-j" "test")
400
+ ;;
401
+ *)
402
+ # Generic workflow - run all jobs
403
+ ;;
404
+ esac
405
+
406
+ # Add standard Act arguments
407
+ act_args+=("--rm")
408
+ act_args+=("--artifact-server-path" "$act_dir")
409
+ act_args+=("--workflows" "$workflow_file")
410
+
411
+ # Add job if specified
412
+ if [[ -n "$job_name" ]]; then
413
+ act_args+=("-j" "$job_name")
414
+ fi
415
+
416
+ # Run Act with timeout
417
+ echo "Running Act (this may take a few minutes)..."
418
+ if timeout "$TIMEOUT_SECONDS" act "${act_args[@]}" 2>&1 | tee "/tmp/act-${workflow_name}.log"; then
419
+ add_workflow_result "$workflow_name" "passed"
420
+ echo -e "${GREEN}✅ Workflow completed successfully!${NC}"
421
+ else
422
+ add_workflow_result "$workflow_name" "failed"
423
+ echo -e "${RED}✗ Workflow failed${NC}"
424
+ echo "Check /tmp/act-${workflow_name}.log for details"
425
+ fi
426
+
427
+ # Cleanup
428
+ rm -rf "$act_dir"
429
+ echo ""
430
+ }
431
+
432
+ discover_and_run_workflows() {
433
+ echo -e "${BLUE}🎬 Act GitHub Actions Runner${NC}"
434
+ echo "=============================="
435
+ echo ""
436
+
437
+ # Find all workflow files
438
+ local workflow_files=()
439
+ while IFS= read -r -d '' file; do
440
+ workflow_files+=("$file")
441
+ done < <(find "${PROJECT_ROOT}/.github/workflows" -name "*.yml" -o -name "*.yaml" 2>/dev/null | sort | tr '\n' '\0')
442
+
443
+ if [ ${#workflow_files[@]} -eq 0 ]; then
444
+ echo -e "${RED}No workflow files found in .github/workflows${NC}"
445
+ return 1
446
+ fi
447
+
448
+ echo "Found ${#workflow_files[@]} workflow(s) to run:"
449
+ for file in "${workflow_files[@]}"; do
450
+ echo " - $(basename "$file")"
451
+ done
452
+ echo ""
453
+
454
+ # Ask user if they want to run all workflows
455
+ echo -e "${YELLOW}Note:${NC} Running all workflows with Act can take significant time"
456
+ echo "and resources. Some workflows may require specific secrets or"
457
+ echo "GitHub-specific features that cannot be simulated locally."
458
+ echo ""
459
+ read -p "Do you want to continue? (y/N) " -n 1 -r
460
+ echo ""
461
+
462
+ if [[ ! $REPLY =~ ^[Yy]$ ]]; then
463
+ echo "Aborted."
464
+ return 0
465
+ fi
466
+
467
+ echo ""
468
+
469
+ # Run each workflow
470
+ for workflow in "${workflow_files[@]}"; do
471
+ run_workflow_with_act "$workflow" ""
472
+ done
473
+
474
+ # Summary
475
+ echo -e "${BLUE}━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━${NC}"
476
+ echo -e "${BLUE}Summary:${NC}"
477
+ echo "─────────"
478
+
479
+ local all_passed=true
480
+ local i=0
481
+ while [ $i -lt ${#workflow_names[@]} ]; do
482
+ workflow="${workflow_names[$i]}"
483
+ status="${workflow_statuses[$i]}"
484
+ case "$status" in
485
+ "passed")
486
+ echo -e " ${GREEN}✓${NC} $workflow: passed"
487
+ ;;
488
+ "failed")
489
+ echo -e " ${RED}✗${NC} $workflow: failed"
490
+ all_passed=false
491
+ ;;
492
+ "simulated")
493
+ echo -e " ${BLUE}ℹ${NC} $workflow: simulated (requires GitHub environment)"
494
+ ;;
495
+ esac
496
+ i=$((i + 1))
497
+ done
498
+
499
+ echo ""
500
+ if [ "$all_passed" = true ]; then
501
+ echo -e "${GREEN}✅ All runnable workflows passed!${NC}"
502
+ echo "Push to GitHub to run the complete workflows"
503
+ return 0
504
+ else
505
+ echo -e "${RED}❌ Some workflows failed${NC}"
506
+ echo "Fix the issues before pushing to GitHub"
507
+ return 1
508
+ fi
509
+ }
510
+
511
+ main() {
512
+ local workflow_file=""
513
+ local job_name=""
514
+ local simulate_mode=false
515
+
516
+ # Parse arguments
517
+ while [[ $# -gt 0 ]]; do
518
+ case $1 in
519
+ --help)
520
+ show_help
521
+ exit 0
522
+ ;;
523
+ --check-docker)
524
+ check_docker
525
+ exit $?
526
+ ;;
527
+ --simulate)
528
+ simulate_mode=true
529
+ shift
530
+ ;;
531
+ --job)
532
+ job_name="$2"
533
+ shift 2
534
+ ;;
535
+ --list)
536
+ log "Available workflows:"
537
+ find "${PROJECT_ROOT}/.github/workflows" -name "*.yml" -o -name "*.yaml" 2>/dev/null || echo "No workflows found"
538
+ exit 0
539
+ ;;
540
+ --install-deps)
541
+ install_dependencies
542
+ exit $?
543
+ ;;
544
+ --check-deps)
545
+ check_dependencies
546
+ exit $?
547
+ ;;
548
+ --start-docker)
549
+ start_docker_daemon
550
+ exit $?
551
+ ;;
552
+ -*)
553
+ log "ERROR: Unknown option $1"
554
+ show_help
555
+ exit 1
556
+ ;;
557
+ *)
558
+ workflow_file="$1"
559
+ shift
560
+ ;;
561
+ esac
562
+ done
563
+
564
+ # Create artifact directory
565
+ mkdir -p "$ARTIFACT_PATH"
566
+
567
+ # Run in simulation mode if requested
568
+ if [[ "$simulate_mode" = true ]]; then
569
+ run_simulation
570
+ exit 0
571
+ fi
572
+
573
+ # Check and install dependencies automatically
574
+ local need_installation=false
575
+
576
+ # Check Act installation
577
+ if ! command -v act &> /dev/null; then
578
+ log "nektos/act not found, installing automatically..."
579
+ need_installation=true
580
+ fi
581
+
582
+ # Check Docker availability
583
+ if ! check_docker; then
584
+ log "Docker not available, installing automatically..."
585
+ need_installation=true
586
+ fi
587
+
588
+ # Install dependencies if needed
589
+ if [[ "$need_installation" = true ]]; then
590
+ log "Installing missing dependencies..."
591
+ if ! install_dependencies; then
592
+ log "Failed to install dependencies. Please install manually:"
593
+ log " - nektos/act: https://github.com/nektos/act"
594
+ log " - Docker: https://docker.com/products/docker-desktop"
595
+ exit 1
596
+ fi
597
+ log "Dependencies installed successfully"
598
+ fi
599
+
600
+ # Final verification
601
+ if ! command -v act &> /dev/null; then
602
+ log "ERROR: nektos/act still not available after installation"
603
+ log "Please install nektos/act manually: https://github.com/nektos/act"
604
+ exit 1
605
+ fi
606
+
607
+ local docker_available=true
608
+ if ! check_docker; then
609
+ log "WARNING: Docker still not available after installation"
610
+ if command -v docker &> /dev/null; then
611
+ log "Docker is installed but daemon not running - attempting to start..."
612
+ if start_docker_daemon; then
613
+ log "Docker daemon started successfully"
614
+ docker_available=true
615
+ else
616
+ log "Failed to start Docker daemon automatically"
617
+ log "Please start Docker manually and try again"
618
+ docker_available=false
619
+ fi
620
+ else
621
+ log "Please install Docker manually: https://docker.com/products/docker-desktop"
622
+ log "Will show workflow discovery, but Docker required for execution"
623
+ docker_available=false
624
+ fi
625
+ fi
626
+
627
+ # Run workflows
628
+ if [[ -n "$workflow_file" ]]; then
629
+ # Run specific workflow
630
+ if [[ "$docker_available" = true ]]; then
631
+ run_workflow_with_act "$workflow_file" "$job_name"
632
+ else
633
+ echo -e "${RED}Cannot run workflows without Docker. Please start Docker and try again.${NC}"
634
+ exit 1
635
+ fi
636
+ else
637
+ # Auto-discover workflows (works without Docker)
638
+ if [[ "$docker_available" = true ]]; then
639
+ discover_and_run_workflows
640
+ else
641
+ echo -e "${RED}Docker is required to run workflows. Please start Docker and try again.${NC}"
642
+ echo "Workflow discovery completed successfully."
643
+ exit 1
644
+ fi
645
+ fi
646
+ }
647
+
648
+ # Run with specific workflow if provided as argument
649
+ if [ $# -eq 1 ] && [[ "$1" != --* ]]; then
650
+ workflow_file="$1"
651
+ if [ -f "$workflow_file" ]; then
652
+ # Parse other arguments and run specific workflow
653
+ main "$@"
654
+ exit $?
655
+ else
656
+ echo -e "${RED}Workflow file not found: $workflow_file${NC}"
657
+ exit 1
658
+ fi
659
+ fi
660
+
661
+ # Otherwise run main function with all arguments
662
+ main "$@"
663
+ EOF
664
+
665
+ Make the script executable:
666
+ !chmod +x scripts/xact.sh
667
+
668
+ If arguments include dependency management operations:
669
+
670
+ **For --install-deps:**
671
+ !scripts/xact.sh --install-deps
672
+
673
+ **For --check-deps:**
674
+ !scripts/xact.sh --check-deps
675
+
676
+ **For --start-docker (macOS specific):**
677
+ !scripts/xact.sh --start-docker
678
+
679
+ If arguments include workflow operations:
680
+
681
+ **For --list:**
682
+ !scripts/xact.sh --list
683
+
684
+ **For --workflow:**
685
+ !scripts/xact.sh --workflow "${workflow_file}"
686
+
687
+ **For --job:**
688
+ !scripts/xact.sh --job "${job_name}"
689
+
690
+ If no specific operation, auto-discover and run workflows:
691
+ !scripts/xact.sh
692
+
693
+ ## Features
694
+
695
+ ### 🎯 **Smart Dependency Management**
696
+ - Automatic installation of nektos/act via Homebrew (macOS) or curl (Linux)
697
+ - Docker availability checking and automatic startup
698
+ - macOS-specific Docker Desktop integration
699
+ - Graceful fallback to simulation mode when dependencies unavailable
700
+
701
+ ### 🔧 **Workflow Execution**
702
+ - Auto-discovery of GitHub Actions workflows in `.github/workflows/`
703
+ - Selective workflow and job execution
704
+ - Professional colored output with progress indicators
705
+ - Timeout protection and artifact management
706
+ - Intelligent workflow categorization (CI, security, etc.)
707
+
708
+ ### 🛡️ **Error Handling & Simulation**
709
+ - Comprehensive error handling with detailed diagnostics
710
+ - Fallback simulation mode for GitHub-specific features
711
+ - Workflow result tracking and summary reporting
712
+ - Detailed logging and troubleshooting information
713
+
714
+ ### 📋 **Integration Points**
715
+ - Works with existing `/xcicd` for production pipeline management
716
+ - Complements `/xworkflow` for general workflow automation
717
+ - Supports local development workflow before GitHub push
718
+ - Compatible with standard GitHub Actions workflow patterns
719
+
720
+ ## Use Cases
721
+
722
+ ### Development Workflow
723
+ ```bash
724
+ /xact # Test all workflows before commit
725
+ /xact --job test # Quick test job validation
726
+ /xact --workflow ci.yml # Test specific CI workflow
727
+ ```
728
+
729
+ ### Setup and Maintenance
730
+ ```bash
731
+ /xact --install-deps # One-time setup
732
+ /xact --check-deps # Verify environment
733
+ /xact --start-docker # Fix Docker issues
734
+ ```
735
+
736
+ ### Debugging and Analysis
737
+ ```bash
738
+ /xact --simulate # Test without Docker
739
+ /xact --list # See available workflows
740
+ ```
741
+
742
+ This command provides comprehensive local GitHub Actions testing capabilities with intelligent dependency management, making it easy for developers to test workflows locally before pushing to GitHub.