Package Manager Integration
Tab provides a standalone CLI tool that enhances package manager completions with automatic discovery of CLI tools that support Tab completions. This guide focuses on the advanced features and unique capabilities of Tab’s package manager integration.
Quick Setup
Section titled “Quick Setup”For basic setup instructions, see the Getting Started guide. Here’s the minimal setup:
# Install and configurenpm install -g @bombsh/tabtab pnpm zsh > ~/.zsh_completions/tab-pnpm.zshecho 'source ~/.zsh_completions/tab-pnpm.zsh' >> ~/.zshrc
Advanced Features
Section titled “Advanced Features”Automatic CLI Discovery
Section titled “Automatic CLI Discovery”Tab automatically detects and provides completions for CLI tools in your project:
# Tab automatically discovers and provides completions for:pnpm vite dev --port # ← Vite completionspnpm tsc --target # ← TypeScript completionspnpm eslint --ext # ← ESLint completionspnpm jest --config # ← Jest completions
The discovery process:
- Scans
node_modules/.bin/
for available CLI tools - Tests each tool for Tab compatibility (has a
complete
command) - Provides completions automatically for compatible tools
Tab-Compatible CLIs
Section titled “Tab-Compatible CLIs”A CLI tool is “Tab-compatible” if it follows the Tab protocol:
# Test compatibilitymy-cli complete -- --help
# Expected output:--help Show help information:0
Dynamic Script Completions
Section titled “Dynamic Script Completions”Tab reads your package.json
to provide intelligent completions:
# Automatically suggests scripts from package.jsonpnpm run <TAB> # Shows: dev, build, test, lint, etc.
# Suggests dependencies for add/remove commandspnpm add <TAB> # Shows installed packagespnpm remove <TAB> # Shows installed packages
Workspace Support
Section titled “Workspace Support”Enhanced completions for monorepo setups:
# Workspace filteringpnpm --filter my-app run buildpnpm --filter "packages/*" run testpnpm --filter "!packages/docs" run lint
# Tab provides workspace-aware completions for:# - Workspace names# - Workspace patterns# - Workspace-specific scripts
Context-Aware Completions
Section titled “Context-Aware Completions”Completions adapt based on your project context:
# In a TypeScript projectpnpm tsc --target <TAB> # Shows: es2020, es2021, es2022, etc.
# In a Vite projectpnpm vite build --mode <TAB> # Shows: development, production, etc.
# In a React projectpnpm create-react-app <TAB> # Shows: my-app, my-component, etc.
Package Manager Specific Features
Section titled “Package Manager Specific Features”pnpm Enhancements
Section titled “pnpm Enhancements”# Enhanced workspace commandspnpm workspace <TAB> # Shows workspace commandspnpm --filter <TAB> # Shows workspace names and patterns
# Advanced install optionspnpm add --save-dev <TAB> # Shows dependency typespnpm install --frozen-lockfile # Shows install options
npm Enhancements
Section titled “npm Enhancements”# Config managementnpm config get <TAB> # Shows config keysnpm config set <TAB> # Shows config keys
# Package managementnpm install --save-dev <TAB> # Shows dependency typesnpm run <TAB> # Shows scripts with descriptions
yarn Enhancements
Section titled “yarn Enhancements”# Workspace operationsyarn workspace <TAB> # Shows workspace commandsyarn workspaces <TAB> # Shows workspace operations
# Cache managementyarn cache <TAB> # Shows cache operationsyarn cache list # Shows cached packages
bun Enhancements
Section titled “bun Enhancements”# Runtime commandsbun run <TAB> # Shows scriptsbun x <TAB> # Shows available binaries
# Development featuresbun dev <TAB> # Shows dev commandsbun test <TAB> # Shows test options
Configuration
Section titled “Configuration”Environment Variables
Section titled “Environment Variables”# Debug mode for troubleshootingexport DEBUG=1
# Custom timeout for slow completionsexport TAB_COMPLETION_TIMEOUT=3000
# Disable automatic discovery (fallback to basic completions)export TAB_DISABLE_DISCOVERY=1
Performance Optimization
Section titled “Performance Optimization”For large projects, you can optimize performance:
# Increase timeout for projects with many dependenciesexport TAB_COMPLETION_TIMEOUT=5000
# Cache completions (experimental)export TAB_CACHE_COMPLETIONS=1
Troubleshooting
Section titled “Troubleshooting”Common Issues
Section titled “Common Issues”Completions are slow
Section titled “Completions are slow”# Increase timeoutexport TAB_COMPLETION_TIMEOUT=3000
# Check for slow CLI toolsDEBUG=1 tab pnpm complete -- --help
Some CLIs don’t show completions
Section titled “Some CLIs don’t show completions”# Test CLI compatibilitymy-cli complete -- --help
# Check if CLI follows Tab protocol# Should output completions ending with :{number}
Workspace completions not working
Section titled “Workspace completions not working”# Verify workspace configurationcat package.json | grep workspaces
# Check workspace structurels packages/ # Should show workspace directories
Debug Mode
Section titled “Debug Mode”Enable detailed logging:
# Full debug outputDEBUG=1 tab pnpm complete -- --help
# Check discovery processDEBUG=1 tab pnpm complete -- vite dev
Advanced Usage
Section titled “Advanced Usage”Custom Completion Handlers
Section titled “Custom Completion Handlers”For advanced users, you can extend Tab’s completion handlers by modifying the source:
# The completion handlers are in:# tab/bin/package-manager-completion.ts
Integration with Other Tools
Section titled “Integration with Other Tools”Tab works alongside other completion tools:
# Use with existing pnpm completionssource <(pnpm completion)
# Tab enhances existing completions# rather than replacing them
Best Practices
Section titled “Best Practices”1. Use Consistent Package Manager
Section titled “1. Use Consistent Package Manager”Stick to one package manager per project for the best experience.
2. Keep CLI Tools Updated
Section titled “2. Keep CLI Tools Updated”Regularly update your CLI tools to ensure Tab compatibility.
3. Test in Your Projects
Section titled “3. Test in Your Projects”# Test completions in your specific projectstab pnpm complete -- --helppnpm vite complete -- --help
4. Share with Team
Section titled “4. Share with Team”Share your Tab setup to ensure consistent experience across your team.
Next Steps
Section titled “Next Steps”- Learn about Framework Adapters for building Tab-compatible CLIs
- Check out Best Practices for effective autocompletions
- Explore the API Reference for building your own CLI tools