Skip to content

docs: add modular shell architecture design and implementation plan#55

Merged
s2005 merged 8 commits intomainfrom
claude/modular-shell-architecture-011CUvFBnvZuTp9qihbzUXSh
Nov 9, 2025
Merged

docs: add modular shell architecture design and implementation plan#55
s2005 merged 8 commits intomainfrom
claude/modular-shell-architecture-011CUvFBnvZuTp9qihbzUXSh

Conversation

@s2005
Copy link
Copy Markdown
Owner

@s2005 s2005 commented Nov 8, 2025

Add comprehensive documentation for modular shell architecture that
enables build-time inclusion/exclusion of specific shells.

Key additions:

  • Architecture design with plugin-based shell system
  • Detailed 7-phase implementation plan (8-10 weeks)
  • Shell plugin interface and registry system
  • Build configuration and preset system
  • Module structure and organization

Benefits:

  • 30-65% bundle size reduction for specialized builds
  • Better code organization and maintainability
  • Easier testing of individual shells
  • Clear separation of concerns

Files added:

  • docs/tasks/modular_shells/ARCHITECTURE.md
  • docs/tasks/modular_shells/IMPLEMENTATION_PLAN.md
  • docs/tasks/modular_shells/README.md

Add comprehensive documentation for modular shell architecture that
enables build-time inclusion/exclusion of specific shells.

Key additions:
- Architecture design with plugin-based shell system
- Detailed 7-phase implementation plan (8-10 weeks)
- Shell plugin interface and registry system
- Build configuration and preset system
- Module structure and organization

Benefits:
- 30-65% bundle size reduction for specialized builds
- Better code organization and maintainability
- Easier testing of individual shells
- Clear separation of concerns

Files added:
- docs/tasks/modular_shells/ARCHITECTURE.md
- docs/tasks/modular_shells/IMPLEMENTATION_PLAN.md
- docs/tasks/modular_shells/README.md
Add comprehensive exploration documents generated during codebase
analysis for the modular shell architecture project.

These documents provide:
- Complete shell architecture reference
- Visual architecture diagrams and flows
- Shell exploration summary with key findings
- Implementation summary and quick reference
- Documentation index for navigation

These complement the modular architecture design in
docs/tasks/modular_shells/ and provide context for the
current implementation before modularization.
Add detailed testing documentation covering test migration, organization,
and best practices for the modular shell architecture.

Key additions:
- Test structure migration strategy (from monolithic to modular)
- Shell module test templates with complete examples
- Build-specific test configurations
- Test utilities and helper functions
- Performance testing approach
- CI/CD integration with GitHub Actions
- Coverage requirements (≥95% for modules)

Test organization:
- Each shell gets dedicated test directory
- Tests organized by: implementation, validation, paths, integration
- Build-specific Jest configurations
- Automated testing workflows

Examples include:
- Git Bash module complete test suite
- Shell registry tests
- Build configuration tests
- E2E tests for different builds
- Performance benchmarks

Updated README.md to include TESTING_GUIDE.md reference
Replace all absolute paths (/home/user/wcli0/) with relative paths
in exploration documentation files.

Changed:
- /home/user/wcli0/src/... → src/...
- /home/user/wcli0/config.examples/... → config.examples/...
- /home/user/wcli0/tests/... → tests/...
- /home/user/wcli0/package.json → package.json

Files updated:
- SHELL_ARCHITECTURE.md
- SHELL_EXPLORATION_SUMMARY.md
- SHELL_IMPLEMENTATION_SUMMARY.txt
Implement foundational infrastructure for modular shell architecture
as outlined in the implementation plan.

New components:
- Shell Plugin Interface (ShellPlugin) with validation and config methods
- Base Shell implementation providing common functionality
- Shell Registry for managing shell plugins (singleton pattern)
- Comprehensive test suite (40 tests, all passing)

Structure created:
- src/shells/base/ - Shell plugin interfaces and base class
- src/core/ - Core registry and server components
- src/build/ - Build configuration (directory)

Key features:
- ShellConfig interface for plugin configuration
- ValidationContext and ValidationResult for command/path validation
- BaseShell abstract class with default implementations
- ShellRegistry for dynamic shell registration and retrieval

Tests:
- ShellInterface contract tests (10 tests)
- BaseShell implementation tests (11 tests)
- ShellRegistry tests (19 tests)
- All tests passing ✓

This completes Phase 1 of the 7-phase implementation plan.
Next: Phase 2 - Extract individual shell modules (PowerShell, CMD,
Git Bash, Bash, WSL)
Extract all 5 shell implementations into individual modules following
the plugin architecture from Phase 1.

New shell modules:
- PowerShell module (src/shells/powershell/)
- CMD module (src/shells/cmd/)
- Git Bash module (src/shells/gitbash/)
- Bash module (src/shells/bash/)
- WSL module (src/shells/wsl/)

Each module includes:
- Implementation class extending BaseShell
- Shell-specific configuration
- Blocked commands list
- Path validation for shell's path format
- Index file for clean exports
- Comprehensive test suite

Shell implementations:
- PowerShellImpl: Windows PowerShell with blocked cmdlets
- CmdImpl: Windows Command Prompt with file operation blocks
- GitBashImpl: Git Bash supporting Unix/Windows hybrid paths
- BashImpl: Standard Bash with WSL mount point support
- WslImpl: WSL wrapper executing bash commands

Path validation:
- PowerShell/CMD: Windows paths (C:\, \\server\, .\)
- Git Bash: Hybrid (C:\, /c/, /, ./)
- Bash: Unix paths (/, /mnt/c/, ./)
- WSL: Unix paths with /mnt/ mount points

Enhancements:
- Improved BaseShell.validateCommand() to support both:
  * Simple command blocking ("del", "rm")
  * Full command pattern blocking ("rm -rf /")

Tests:
- 105 new tests for shell modules (21 tests per shell)
- All 145 tests passing (126 shell + 19 registry)
- Test coverage: configuration, blocked commands, validation, paths

This completes Phase 2 of the 7-phase implementation plan.
Next: Phase 3 - Registry & Dynamic Loading
Implement dynamic shell loading system with build configuration support.
This enables loading only the shells needed at runtime based on
environment variables or preset configurations.

New components:
- Shell loader (src/shells/loader.ts)
  * Dynamic import and registration of shell modules
  * Configurable shell selection
  * Verbose logging support
  * Graceful error handling

- Build configuration (src/build/shell-config.ts)
  * Environment-based configuration (SHELL_BUILD_PRESET, INCLUDED_SHELLS)
  * 6 predefined presets: full, windows, unix, gitbash-only, cmd-only, powershell-only
  * Custom shell list support
  * Verbose mode control (BUILD_VERBOSE)

Shell loader features:
- Dynamically imports shell modules based on config
- Only loads specified shells (tree-shakeable)
- Registers shells with the central registry
- Handles unknown shell types gracefully
- Supports verbose output for debugging

Build presets:
- full: All 5 shells (default)
- windows: PowerShell, CMD, Git Bash
- unix: Bash only
- gitbash-only: Git Bash only
- cmd-only: CMD only
- powershell-only: PowerShell only

Configuration priority:
1. SHELL_BUILD_PRESET environment variable
2. INCLUDED_SHELLS environment variable (comma-separated)
3. Default: all shells

Usage examples:
- SHELL_BUILD_PRESET=gitbash-only npm start
- INCLUDED_SHELLS=gitbash,powershell npm start
- BUILD_VERBOSE=true npm start

Tests:
- 13 loader tests (shell loading, error handling, verbose mode)
- 21 build config tests (presets, custom lists, verbose mode)
- All 179 tests passing (100% success rate)

This completes Phase 3 of the 7-phase implementation plan.
Next: Phase 4 - Build Configuration System (Rollup integration)
Phase 4 - Build Configuration System:
- Integrated modular shell system with main entry point (src/index.ts)
- Modified main() to call loadShells() on startup using getBuildConfig()
- Updated getEnabledShells() to use registry with backward compatibility
- Added build scripts to package.json for different presets (full, windows, unix, gitbash-only, cmd-only, powershell-only)
- Added cross-env dependency for cross-platform environment variable support

Phase 5 - Testing & Validation:
- Fixed TypeScript errors in test files (mockImplementation() calls and spread operator type annotations)
- Created comprehensive integration test suite (tests/integration/modularShellSystem.test.ts)
- Integration tests cover: shell loading, registry integration, dynamic tool schemas, build configuration workflows, error handling
- All 680 tests passing (67 test suites)

Key Implementation Details:
- getEnabledShells() now returns intersection of configured shells and loaded shells from registry
- Backward compatibility: if registry is empty, returns all configured shells (for existing tests)
- Dynamic tool schemas automatically reflect shells loaded in registry
- Build presets enable customized builds with specific shell combinations
@s2005 s2005 merged commit cc29209 into main Nov 9, 2025
3 checks passed
@s2005 s2005 deleted the claude/modular-shell-architecture-011CUvFBnvZuTp9qihbzUXSh branch November 9, 2025 13:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants