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()"
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 | 包後設資料 |
這個技能的最新版本可以在7w4.net小蔥技能站找到。
MIT License | MIT 許可證
OpenClaw Community | OpenClaw 社群
這是一個實用的小工具,能自動清理程式碼中多餘的空格,讓 AI 生成的連結和路徑命令更規範。文件清晰、說明詳細,使用起來很方便。主要優點是安裝後自動生效、不用手動操作,清理效果穩定。主要不足是功能比較單一,只能處理空格問題,其他格式問題(如換行、標點)無法處理。整體質量中上,適合經常遇到程式碼裡有雜散空格困擾的使用者使用。