A plugin manager and dispatcher for CLI tools
npm install @holic512/slothtoolπ A lightweight plugin manager and dispatcher for CLI tools.


SlothTool is a plugin management system that allows you to install, manage, and run CLI tools as plugins without
polluting your global npm environment. All plugins are installed in an isolated directory (~/.slothtool/plugins/) with
their own dependencies.
- π Zero Global Pollution: Plugins install to ~/.slothtool/plugins/ instead of global npm
- π¦ Plugin Isolation: Each plugin has its own dependencies in isolated directories
- π Bilingual Support: Full Chinese and English interface (configurable)
- π― Simple CLI: Easy-to-use commands with shorthand syntax
- π¨ Interactive Mode: Menu-driven interface for easier operation
- β‘ Lightweight: Only one runtime dependency (prompts)
``bash`
npm install -g @holic512/slothtool
`bashInstall a plugin
slothtool install @holic512/plugin-loc
Commands
$3
| Command | Description |
|--------------------------------------|--------------------------------|
|
slothtool install | Install a plugin from npm |
| slothtool uninstall | Uninstall a plugin |
| slothtool list | List all installed plugins |
| slothtool run | Run a plugin with arguments |
| slothtool | Shorthand for running a plugin |
| slothtool config language | Configure interface language |
| slothtool -i, --interactive | Launch interactive mode |
| slothtool --help | Show help information |$3
`bash
Install official plugin
slothtool install @holic512/plugin-locInstall any npm package with bin field
slothtool install some-cli-toolRun plugin with arguments
slothtool loc ./src --verboseUninstall plugin
slothtool uninstall locSwitch to English interface
slothtool config language enUse interactive mode
slothtool -i
`How It Works
SlothTool manages CLI tools as isolated plugins:
1. Installation: Plugins are npm packages with a
bin field
2. Storage: Downloaded to ~/.slothtool/plugins/ with isolated dependencies
3. Registry: Maintains a registry at ~/.slothtool/registry.json tracking installed plugins
4. Execution: Spawns the plugin's executable when you run it
5. Configuration: User settings stored in ~/.slothtool/settings.json$3
`
~/.slothtool/
βββ plugins/ # Plugin installation directory
β βββ loc/ # Example: loc plugin
β β βββ node_modules/
β βββ another-plugin/
βββ plugin-configs/ # Plugin-specific configurations
β βββ loc.json
βββ registry.json # Plugin registry
βββ settings.json # User settings (language, etc.)
`Configuration
$3
SlothTool supports Chinese (zh) and English (en):
`bash
Switch to English
slothtool config language enSwitch to Chinese (default)
slothtool config language zhView current language
slothtool config
`$3
Package names are automatically converted to simple aliases:
-
@holic512/plugin-loc β loc
- plugin-mytool β mytool
- some-tool β some-toolOfficial Plugins
- @holic512/plugin-loc - Lines of code counter with interactive features
Creating Plugins
Any npm package with a
bin field can be a SlothTool plugin.$3
`json
{
"name": "@yourscope/plugin-mytool",
"version": "1.0.0",
"description": "My awesome CLI tool",
"bin": {
"mytool": "bin/mytool.js"
},
"keywords": [
"slothtool-plugin",
"cli"
]
}
`$3
1. Naming Convention: Use
plugin- prefix or include in package scope
2. Keywords: Add slothtool-plugin keyword for discoverability
3. Internationalization: Read language from ~/.slothtool/settings.json for i18n support
4. Configuration: Store plugin-specific config in ~/.slothtool/plugin-configs/
5. Interactive Features: Use prompts library for better UX$3
`javascript
#!/usr/bin/env node
const fs = require('fs');
const path = require('path');
const os = require('os');// Read language setting from slothtool
function getLanguage() {
const settingsPath = path.join(os.homedir(), '.slothtool', 'settings.json');
if (fs.existsSync(settingsPath)) {
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
return settings.language || 'zh';
}
return 'zh';
}
const messages = {
zh: {greeting: 'δ½ ε₯½οΌδΈηοΌ'},
en: {greeting: 'Hello, World!'}
};
const lang = getLanguage();
console.log(messages[lang].greeting);
`$3
`bash
Publish to npm
npm publish --access publicUsers can then install it
slothtool install @yourscope/plugin-mytool
slothtool mytool
`Interactive Mode
Launch interactive mode for a menu-driven experience:
`bash
slothtool -i
`Features:
- Install official or custom plugins
- Uninstall plugins
- List installed plugins
- Run plugins
- Configure language settings
Uninstalling
$3
When you uninstall a plugin, SlothTool will automatically remove:
- Plugin directory and all its dependencies (
~/.slothtool/plugins/)
- Plugin-specific configuration file (~/.slothtool/plugin-configs/)
- Registry entry from ~/.slothtool/registry.json`bash
Uninstall a specific plugin
slothtool uninstall Example
slothtool uninstall loc
`The uninstall command will show you exactly what will be removed before proceeding.
$3
To completely remove SlothTool and all its data from your system:
#### Option 1: Using the built-in command (recommended)
`bash
Remove all plugins, configurations, and SlothTool data
slothtool --uninstall-all
`This will remove:
- All installed plugins (
~/.slothtool/plugins/)
- All plugin configurations (~/.slothtool/plugin-configs/)
- Registry file (~/.slothtool/registry.json)
- Settings file (~/.slothtool/settings.json)
- The entire ~/.slothtool/ directoryThen uninstall the global SlothTool package:
`bash
npm uninstall -g @holic512/slothtool
`#### Option 2: Manual removal
`bash
1. Remove all SlothTool data
rm -rf ~/.slothtool/2. Uninstall the global package
npm uninstall -g @holic512/slothtool
`$3
Here's a complete breakdown of what SlothTool stores on your system:
`
~/.slothtool/
βββ plugins/ # All installed plugins and their dependencies
β βββ loc/ # Example: loc plugin
β β βββ node_modules/
β β βββ package.json
β βββ [other-plugins]/
βββ plugin-configs/ # Plugin-specific configurations
β βββ loc.json # Example: loc plugin config
β βββ [other-configs].json
βββ registry.json # Plugin registry (tracks installed plugins)
βββ settings.json # User settings (language preference, etc.)
`Note: SlothTool only stores data in
~/.slothtool/. No other system files or directories are modified.Troubleshooting
$3
`bash
Check installed plugins
slothtool listReinstall if needed
slothtool uninstall
slothtool install
`$3
SlothTool installs to user directory (
~/.slothtool/), so no sudo is required. If you encounter permission issues:`bash
Check directory permissions
ls -la ~/.slothtool/Fix permissions if needed
chmod -R u+w ~/.slothtool/
`Development
$3
`bash
Clone repository
git clone https://github.com/holic512/SlothTool.git
cd SlothToolInstall dependencies
npm installLink for local testing
cd packages/slothtool
npm linkTest the CLI
slothtool --help
`$3
`
packages/slothtool/
βββ bin/
β βββ slothtool.js # CLI entry point
βββ lib/
β βββ commands/ # Command implementations
β β βββ install.js
β β βββ uninstall.js
β β βββ list.js
β β βββ run.js
β β βββ config.js
β β βββ interactive.js
β βββ i18n.js # Internationalization
β βββ plugin-manager.js # Plugin installation/uninstallation
β βββ registry.js # Registry management
β βββ settings.js # Settings management
β βββ utils.js # Utility functions
βββ package.json
``Contributions are welcome! Please feel free to submit issues and pull requests.
- Configuration Analysis - Detailed analysis of the codebase
- npm link vs SlothTool - Comparison with npm link
ISC
holic512