cognesy / instructor-hub
CLI tool to work with Instructor PHP code examples and docs
Installs: 0
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
pkg:composer/cognesy/instructor-hub
Requires
- php: ^8.2
- cebe/markdown: ^1.2
- cognesy/instructor-auxiliary: ^1.13
- cognesy/instructor-doctor: ^1.13
- cognesy/instructor-struct: ^1.13
- cognesy/instructor-utils: ^1.13
- toolkit/cli-utils: ^2.0
Requires (Dev)
- icanhazstring/composer-unused: ^0.9.0
- jetbrains/phpstorm-attributes: ^1.2
- maglnet/composer-require-checker: ^4.16
- pestphp/pest: ^2.34
- phpstan/phpstan: ^1.11
- roave/security-advisories: dev-latest
- vimeo/psalm: ^6.0
- dev-main
- v1.13.0
- v1.12.0
- v1.11.0
- v1.10.3
- v1.10.2
- v1.10.1
- v1.10.0
- v1.9.1
- v1.9.0
- v1.8.1
- v1.8.0
- v1.7.0
- v1.6.0
- v1.5.0
- v1.4.2
- v1.4.1
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.1-RC13
- v1.0.0
- v1.0.0-RC22
- v1.0.0-RC21
- v1.0.0-RC20
- v1.0.0-RC19
- v1.0.0-RC18
- v1.0.0-RC17
- v1.0.0-RC16
- v1.0.0-RC15
- v1.0.0-RC14
- v1.0.0-RC13
- v1.0.0-RC12
- v1.0.0-RC11
- v1.0.0-RC10
- v1.0.0-RC9
- 1.0.0-RC8
- 1.0.0-RC7
- 1.0-rc4
- 1.0-rc3
- 1.0-rc2
- 1.0-rc1
- 0.17.11
- 0.17.10
- 0.17.8
- 0.17.7
- 0.17.5
- 0.17.3
- 0.17.2
- 0.17.1
- 0.17.0
- 0.16.4
- 0.16.3
- 0.16.2
- 0.16.0
- 0.15.2
- 0.15.1
- 0.15.0
- 0.14.7
- 0.14.6
- 0.14.5
- 0.14.4
- 0.14.3
- 0.14.2
- 0.14.1
- 0.14.0
- 0.13.9
This package is auto-updated.
Last update: 2025-12-07 22:36:05 UTC
README
Hub provides example execution with comprehensive status tracking, selective re-execution, and performance analytics.
Quick Start
# Run single example (raw output, colors preserved) composer hub run 1 composer hub run basics/Basic # List all examples composer hub list # Run all examples with tracking composer hub all # Check execution status composer hub status
Core Commands
Single Example Execution
# Raw output (default) - preserves colors, streaming, TTY composer hub run 35 # Real-time streaming output composer hub raw 35 # Alias for raw output # With tracking (stores execution metadata) composer hub -- run 35 --track # Tracked execution > **Note**: When using options with composer scripts, use `composer hub -- <command> --option` > to ensure arguments are passed through correctly.
Bulk Execution
# Run all examples with tracking composer hub all # Start from beginning composer hub all 50 # Start from example 50 # Selective execution composer hub -- all --filter=pending # Only unexecuted examples composer hub -- all --filter=errors # Only failed examples composer hub -- all --filter=stale # Only examples with modified files composer hub -- all --dry-run # Preview without executing # Dedicated commands composer hub errors # Re-run failed examples composer hub stale # Run examples with modified files
Status & Analytics
# Status overview composer hub status # Summary view composer hub -- status --detailed # Per-example breakdown composer hub -- status --errors-only # Show only failures composer hub -- status --format=json # JSON output for automation # Performance analytics composer hub stats # Performance metrics composer hub -- stats --slowest=20 # Show 20 slowest examples
Maintenance
# Clean status data composer hub -- clean --completed # Remove successful runs composer hub -- clean --older-than="1 week" # Remove old data composer hub -- clean --all --backup # Reset all (with backup)
Status Tracking
Status File Location
- File:
.hub/status.json(git-excluded) - Contains: Execution metadata, timing, errors, attempts
- Format: JSON with metadata, examples, and statistics sections
Execution States
pending- Never executedrunning- Currently executingcompleted- Successful executionerror- Failed executioninterrupted- Interrupted by Ctrl+Cstale- Source file modified since last run
Status Data Structure
{
"metadata": {
"version": "1.0",
"lastUpdated": "2024-12-07T15:30:45Z",
"totalExamples": 213
},
"examples": {
"1": {
"index": 1,
"name": "Basic",
"status": "completed",
"executionTime": 1.245,
"lastExecuted": "2024-12-07T15:25:30Z",
"attempts": 1,
"errors": [],
"exitCode": 0
}
},
"statistics": {
"totalExecuted": 150,
"completed": 148,
"errors": 2,
"averageExecutionTime": 1.234
}
}
Filtering System
Filter Modes
all- All examples (default)pending- Never executed exampleserrors- Failed examples onlystale- Examples with modified source filescompleted- Successfully executed examples
Usage Patterns
# Command variations (all equivalent) composer hub all --filter=errors composer hub errors composer hub -- all --filter=errors # Multiple filters composer hub all --filter=pending --dry-run composer hub all --filter=stale --stop-on-error
Output Formats
Table Format (Default)
Total Examples: 213
Executed: 150
Completed: 148
Errors: 2
Success Rate: 98.67%
JSON Format
composer hub status --format=json
# Returns structured JSON for automation
CSV Export
composer hub stats --format=csv > performance.csv # Exports performance data for analysis
Performance Features
Execution Timing
- Per-example timing: Precise execution duration
- Aggregate statistics: Average, median, std deviation
- Performance ranking: Slowest/fastest examples
- Trend analysis: Execution time over multiple runs
Error Tracking
- Error classification: Fatal errors, timeouts, exceptions
- Failure patterns: Frequently failing examples
- Recovery tracking: Success after failure count
- Error details: Full error messages and stack traces
Interruption Handling
- Graceful Ctrl+C: Preserves execution state
- Resume capability: Continue from interruption point
- Partial results: Status saved for completed examples
- Signal handling: Clean shutdown with state preservation
Integration & Automation
CI/CD Integration
# Run only failing tests in CI composer hub errors --format=json > failed-tests.json # Check if any examples are failing composer hub status --errors-only --format=json | jq '.examples | length' # Get performance baseline composer hub stats --format=json > performance-baseline.json
Git Integration
- Automatic .gitignore:
.hub/directory excluded - Stale detection: Modified file tracking
- Branch isolation: Status per branch/worktree
- Hook integration: Pre-commit validation possible
IDE Integration
// .vscode/tasks.json { "tasks": [ { "label": "Hub: Run Example", "type": "shell", "command": "composer hub run ${input:exampleNumber}" }, { "label": "Hub: Check Status", "type": "shell", "command": "composer hub status" } ] }
Advanced Usage
Parallel Development
# Different status per worktree git worktree add ../feature-branch feature/new-functionality cd ../feature-branch composer hub all --filter=pending # Independent status tracking
Custom Workflows
# Development workflow composer hub all --filter=stale # Run modified examples composer hub errors # Fix any failures composer hub status --detailed # Review results # Performance monitoring composer hub stats --slowest=10 # Identify bottlenecks composer hub run 65 --track # Profile specific example composer hub clean --older-than="1 day" # Cleanup old data
Debugging & Troubleshooting
# Raw execution for debugging composer hub run 35 # Full output with colors # Tracked execution for analysis composer hub -- run 35 --track # Status persistence # Error investigation composer hub status --errors-only --detailed composer hub run <failing-example> # Debug with full output
Architecture
DDD Implementation
- Value Objects: ExecutionResult, ExecutionError, ExecutionStatus
- Entities: ExampleExecutionStatus with business logic
- Services: StatusRepository, ExecutionTracker, EnhancedRunner
- Interfaces: CanTrackExecution, CanPersistStatus, CanExecuteExample
File Organization
packages/hub/src/
├── Commands/ # Console commands
├── Contracts/ # Domain interfaces
├── Data/ # Value objects & entities
├── Services/ # Application services
└── Exceptions/ # Domain exceptions
Backward Compatibility
All existing workflows continue unchanged:
composer hub list- Example listingcomposer hub run 1- Single execution (now with raw output)composer hub all- Bulk execution (now with tracking)composer hub show 1- Example details
New capabilities are additive and optional.