@holic512/slothtool
v1.3.6
Published
A plugin manager and dispatcher for CLI tools
Downloads
2,124
Readme
SlothTool
SlothTool 是一个 TUI-first 的插件管理器:日常使用默认进入 Ink 全屏界面,同时保留可脚本化的 CLI 命令。
根包通过 npm 分发,官方插件通过 GitHub Release .tgz 资产安装到本机用户目录。当前内置官方插件为 loc 和 image-compress。
npm install -g @holic512/slothtool
slothtoolOverview
SlothTool 把“插件管理器”作为默认交互入口:根命令负责安装、更新、卸载和调度插件;插件自身继续保留独立命令与 TUI。这样日常操作可以在全屏界面完成,自动化脚本仍然可以直接调用稳定的 CLI。
Features
| 能力 | 说明 |
| --- | --- |
| 默认 TUI | slothtool 无参数启动根管理器全屏 TUI。 |
| CLI 兼容 | install、list、update、config、run、self-update 等命令可直接脚本化调用。 |
| 官方插件分发 | 内置官方插件清单,安装源限定为 GitHub Release 资产。 |
| 平台资产选择 | image-compress 按当前系统和 CPU 架构选择匹配的预编译后端资产。 |
| 双语界面 | 根管理器和官方插件支持中文 / English 文案。 |
| 本地用户数据 | 设置、注册表、插件包和插件配置都保存在 ~/.slothtool/。 |
Requirements
- Node.js
>=22.0.0 - npm
>=10
Install
npm install -g @holic512/slothtool验证入口:
slothtool --help
slothtoolQuick Start
启动根 TUI:
slothtool安装并运行官方插件:
slothtool install loc
slothtool install image-compress
slothtool loc
slothtool image-compress使用显式 CLI:
slothtool loc ./src
slothtool loc -v ./src
slothtool image-compress ./photo.jpg --dry-run
slothtool image-compress -r ./album --output-dir ./compressedTUI Pages
根 TUI 的页面模型固定为:
| 页面 | 主要职责 | | --- | --- | | Home | 展示管理器入口信息与当前导航提示。 | | Run | 选择已安装插件并启动插件 TUI 或 CLI 能力。 | | Install | 从内置官方插件清单安装插件。 | | Update | 先检查可更新项,再执行更新。 | | Uninstall | 卸载已安装插件。 | | Settings | 切换语言、代理与 GitHub 源配置。 |
从根 TUI 启动插件后,插件退出会返回根 TUI,并恢复离开前的页面与选择位置。
Commands
| 命令 | 用途 |
| --- | --- |
| slothtool | 启动根全屏 TUI。 |
| slothtool tui | 显式启动根全屏 TUI。 |
| slothtool install <alias> | 安装内置官方插件。 |
| slothtool uninstall <alias> | 卸载指定插件。 |
| slothtool update <alias> | 更新指定插件。 |
| slothtool --update-all | 更新全部可更新目标。 |
| slothtool list | 查看已安装插件。 |
| slothtool run <plugin> [args] | 运行指定插件。 |
| slothtool <plugin> [args] | 插件简写运行方式。 |
| slothtool config <...> | 管理语言、代理和 GitHub 源。 |
| slothtool self-update | 更新根管理器包。 |
| slothtool --uninstall-all | 删除 SlothTool 用户数据与已安装插件。 |
Official Plugins
| Alias | Package | 能力 | 入口 |
| --- | --- | --- | --- |
| loc | @holic512/plugin-loc | 统计目录代码行数、文件类型过滤、排除目录配置、详细模式。 | slothtool loc / loc |
| image-compress | @holic512/plugin-image-compress | JPEG / PNG 图片压缩、目录批处理、拖拽路径 TUI、多平台 Go 后端资产。 | slothtool image-compress / image-compress |
loc
slothtool install loc
slothtool loc
slothtool loc .
slothtool loc -v ./src
loc config show
loc config ext md off
loc config exclude dist on
loc config resetimage-compress
slothtool install image-compress
slothtool image-compress
slothtool image-compress ./photo.jpg
slothtool image-compress ./photo.jpg --dry-run --json
slothtool image-compress -r ./album --output-dir ./compressed常用压缩参数包括 --quality、--max-width、--max-height、--overwrite、--allow-larger、--concurrency、--dry-run、--json 和 --quiet。
Configuration
全局设置默认保存在 ~/.slothtool/settings.json:
{
"language": "zh",
"network": {
"proxy": {
"enabled": false,
"protocol": "http",
"host": "127.0.0.1",
"port": 7980,
"noProxy": "localhost,127.0.0.1,::1"
},
"github": {
"preset": "gh-proxy",
"customBaseUrl": ""
}
}
}常用配置命令:
| 命令 | 说明 |
| --- | --- |
| slothtool config | 查看语言、代理和 GitHub 源摘要。 |
| slothtool config language zh | 切换为中文。 |
| slothtool config language en | 切换为 English。 |
| slothtool config proxy show | 查看网络配置。 |
| slothtool config proxy enabled on | 启用代理。 |
| slothtool config proxy enabled off | 关闭代理。 |
| slothtool config proxy host 127.0.0.1 | 设置代理主机。 |
| slothtool config proxy port 7890 | 设置代理端口。 |
| slothtool config proxy github official | 使用官方 GitHub 源。 |
| slothtool config proxy github gh-proxy | 使用内置 GitHub 代理预设。 |
| slothtool config proxy github-url https://proxy.example.com | 写入自定义 GitHub 代理地址,并切换到 custom。 |
Architecture
flowchart TD
A["slothtool CLI"] --> B{"Has command?"}
B -- "No" --> C["Root Ink TUI"]
B -- "Root command" --> D["Command handlers"]
B -- "Plugin alias" --> E["Plugin runner"]
C --> D
D --> F["Plugin service"]
F --> G["official-plugins.json"]
F --> H["GitHub Release .tgz"]
F --> I["~/.slothtool/registry.json"]
F --> J["~/.slothtool/plugins/<alias>/"]
E --> I
E --> K["Plugin bin"]
K --> L{"No args / --tui?"}
L -- "Yes" --> M["Plugin Ink TUI"]
L -- "No" --> N["Plugin CLI behavior"]安装流程:
slothtool install <alias>从lib/official-plugins.json查找内置官方插件。- SlothTool 根据插件策略、当前系统平台和 CPU 架构选择 GitHub Release
.tgz资产。 - 资产被解包并部署到
~/.slothtool/plugins/<alias>/。 - 插件入口、版本和来源信息写入
~/.slothtool/registry.json。 slothtool <plugin>从注册表解析插件入口;无额外参数时优先进入插件默认 TUI。
Data Layout
~/.slothtool/
├── settings.json
├── registry.json
├── plugins/
│ ├── image-compress/
│ └── loc/
└── plugin-configs/
└── loc.jsonRepository Layout
SlothTool/
├── bin/ Root CLI entry
├── lib/ Root commands, services, settings, i18n, and TUI
├── plugins/
│ ├── loc/ Official LOC plugin workspace
│ ├── image-compress/ Official image compression plugin workspace
│ └── template-basic/ Plugin scaffold template
├── test/ node:test regression suite
├── PLUGIN_DEVELOPMENT.md Plugin contract and development notes
├── LOCAL_BUILD_GUIDE.md Local build and release validation notes
└── package.jsonDevelopment
npm install
npm link
node bin/slothtool.js --help
node plugins/loc/bin/loc.js --help
node plugins/image-compress/bin/image-compress.js --helpFocused checks:
node --check bin/slothtool.js
node --check lib/tui/root-tui.js
SLOTHTOOL_TUI_TEST_ACTION=exit node bin/slothtool.js
SLOTHTOOL_LOC_TUI_TEST_ACTION=exit node plugins/loc/bin/loc.js
SLOTHTOOL_IMAGE_COMPRESS_TUI_TEST_ACTION=exit node plugins/image-compress/bin/image-compress.jsFull regression:
npm testMore project docs:
License
ISC, as declared in package.json. This repository does not currently include a standalone LICENSE file.
