English: Automatically clean extra spaces in code and URLs, preserving necessary spaces (text, indentation). Hook auto-registers on skill load - no manual activation needed!
中文: 自动清理代码和 URL 中的多余空格,保留必要的空格(文本、缩进)。Hook 在技能加载时自动注册 - 无需手动激活!
English: The hook automatically registers when the skill is loaded by OpenClaw. No manual commands needed!
中文: Hook 在技能被 OpenClaw 加载时自动注册。无需手动命令!
English: When you install this skill, the hook automatically activates in your OpenClaw session. All agent output is cleaned immediately.
中文: 安装此技能后,Hook 在 OpenClaw 会话中自动激活。所有 agent 输出立即被清理。
English: If auto-activation fails, you can manually activate:
中文: 如果自动激活失败,可以手动激活:
python3 -c "from cleaner import register_auto_hook; register_auto_hook()"
小葱技能有更好的技能skills插件。
English: When generating code and URLs, extra spaces are often inserted in wrong positions, causing execution failures.
中文: 在生成代码和 URL 时,经常会在错误的位置插入多余空格,导致执行失败。
Examples | 示例:
❌ https://github.com/Johnserf-Seed /TikTokDownload.git
✅ https://github.com/Johnserf-Seed/TikTokDownload.git
❌ cd /tmp && git clone https://github.com/Johnserf-Seed /TikTokDownload.git
✅ cd /tmp && git clone https://github.com/Johnserf-Seed/TikTokDownload.git
❌ pip3 install -r requirements.txt --break-system-packages
✅ pip3 install -r requirements.txt --break-system-packages
npx clawhub@latest install code-url-cleaner
English: No further setup needed. The hook activates automatically.
中文: 无需进一步配置。Hook 自动激活。
English: Once installed, all agent output is automatically cleaned. No manual calls needed.
中文: 安装后,所有 agent 输出自动清理,无需手动调用。
# Agent output is automatically cleaned | Agent 输出自动清理
print("https://github.com/Johnserf-Seed /TikTokDownload.git")
# Output: https://github.com/Johnserf-Seed/TikTokDownload.git
from cleaner import clean_text
text = "https://github.com/Johnserf-Seed /TikTokDownload.git"
cleaned = clean_text(text)
print(cleaned)
# Output: https://github.com/Johnserf-Seed/TikTokDownload.git
English: The skill registers an OpenClaw lifecycle hook that intercepts agent output and cleans it before display. This happens automatically on skill load.
中文: 技能注册一个 OpenClaw 生命周期钩子,拦截 agent 输出并在显示前清理。这在技能加载时自动发生。
# cleaner.py - Auto-executed on import | 导入时自动执行
def _auto_register_hook():
from openclaw import get_current_agent
agent = get_current_agent()
def clean_output(event, ctx):
output = event.get('output', '')
return {'output': clean_text(output)}
agent.on('before_output', clean_output)
return True
# Auto-register on module load | 模块加载时自动注册
_auto_register_hook()
cd /path/to/code-url-cleaner
python3 cleaner.py --test
Expected Output | 期望输出:
============================================================
Code/URL Space Cleaner 测试
============================================================
✅ URL 中间有空格
✅ 命令多个空格
✅ 路径空格
============================================================
测试结果:4 通过,0 失败
============================================================
============================================================
Hook 功能测试
============================================================
Hook 状态:✅ 已激活(自动)
============================================================
| File | 文件 | Description | 描述 |
|---|---|---|---|
cleaner.py |
cleaner.py |
Core cleaning logic + Auto-Hook | 核心清理逻辑 + 自动 Hook |
SKILL.md |
SKILL.md |
This documentation | 本文档 |
README.md |
README.md |
User guide | 用户指南 |
_meta.json |
_meta.json |
Package metadata | 包元数据 |
MIT License | MIT 许可证
OpenClaw Community | OpenClaw 社区
这是一个实用的小工具,能自动清理代码中多余的空格,让 AI 生成的链接和路径命令更规范。文档清晰、说明详细,使用起来很方便。主要优点是安装后自动生效、不用手动操作,清理效果稳定。主要不足是功能比较单一,只能处理空格问题,其他格式问题(如换行、标点)无法处理。整体质量中上,适合经常遇到代码里有杂散空格困扰的用户使用。