Code Url Cleaner

👤 ra1nzzz 📦 v1.2.0 ⭐ 4.4 ⬇️ 979 下載
💻 開發程式設計 免費

📖 技能介紹

Code URL Cleaner Skill | 程式碼 URL 清理器技能

Description | 描述

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 在技能載入時自動註冊 - 無需手動啟用!


✅ Auto-Activation | 自動啟用

English: The hook automatically registers when the skill is loaded by OpenClaw. No manual commands needed!

中文: Hook 在技能被 OpenClaw 載入時自動註冊。無需手動命令!

How It Works | 工作原理

English: When you install this skill, the hook automatically activates in your OpenClaw session. All agent output is cleaned immediately.

中文: 安裝此技能後,Hook 在 OpenClaw 會話中自動啟用。所有 agent 輸出立即被清理。

Optional: Manual Activation | 可選:手動啟用

English: If auto-activation fails, you can manually activate:

中文: 如果自動啟用失敗,可以手動啟用:

python3 -c "from cleaner import register_auto_hook; register_auto_hook()"

Problem | 問題

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

Installation | 安裝

npx clawhub@latest install code-url-cleaner

That's It! | 就這樣!

English: No further setup needed. The hook activates automatically.

中文: 無需進一步配置。Hook 自動啟用。


Usage | 使用方法

Auto Mode (Default) | 自動模式(預設)

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

Manual Mode | 手動模式

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

Hook Implementation | Hook 實現

How It Works | 工作原理

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 輸出並在顯示前清理。這在技能載入時自動發生。

Code | 程式碼

# 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()

Rules | 規則

Cleaned | 清理的

  1. URL Internal Spaces | URL 內部的空格
  2. Multiple Consecutive Spaces in Commands | 命令中的多個連續空格
  3. Path Spaces | 路徑中的空格

Preserved | 保留的

  1. Natural Language Text | 自然語言文本
  2. Single Space Between Arguments | 命令引數之間的單個空格

    小蔥技能7w4.net有更新,你可以訪問看下。

  3. Code Indentation | 程式碼縮排

Testing | 測試

cd /path/to/code-url-cleaner
python3 cleaner.py --test

Expected Output | 期望輸出:

============================================================
Code/URL Space Cleaner 測試
============================================================

✅ URL 中間有空格
✅ 命令多個空格
✅ 路徑空格

============================================================
測試結果:4 通過,0 失敗
============================================================

============================================================
Hook 功能測試
============================================================
Hook 狀態:✅ 已啟用(自動)
============================================================

Files | 檔案

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 包後設資料

Version History | 版本歷史

v1.2.0 (2026-03-08)

  • Auto-hook activation | 自動 Hook 啟用
  • ✅ No manual commands needed | 無需手動命令
  • ✅ Hook registers on module load | Hook 在模組載入時註冊
  • ✅ Backward compatible | 向後相容

v1.1.1 (2026-03-08)

  • ✅ Fix hook activation logic | 修復 Hook 啟用邏輯
  • ✅ Auto-detect OpenClaw environment | 自動檢測 OpenClaw 環境

v1.1.0 (2026-03-08)

  • ✅ Auto-hook feature | 自動 Hook 功能
  • ✅ Hook activation command | Hook 啟用命令
  • ✅ Hook status check | Hook 狀態檢查
  • ✅ Bilingual documentation | 雙語文件

v1.0.0 (2026-03-08)

  • ✅ Initial release | 初始釋出
  • ✅ URL space cleaning | URL 空格清理
  • ✅ Command space cleaning | 命令空格清理
  • ✅ Path space cleaning | 路徑空格清理
  • ✅ 100% test coverage | 100% 測試覆蓋

Requirements | 依賴

  • Python 3.6+
  • OpenClaw 0.1.6+
  • No external dependencies | 無外部依賴

License | 許可證

MIT License | MIT 許可證


Author | 作者

OpenClaw Community | OpenClaw 社群


  • GitHub: https://github.com/ra1nzzz/code-url-cleaner
  • ClawHub: https://clawhub.ai/skills/code-url-cleaner
  • Issues: https://github.com/ra1nzzz/code-url-cleaner/issues

🤖 AI 評測

這是一個實用的小工具,能自動清理程式碼中多餘的空格,讓 AI 生成的連結和路徑命令更規範。文件清晰、說明詳細,使用起來很方便。主要優點是安裝後自動生效、不用手動操作,清理效果穩定。主要不足是功能比較單一,只能處理空格問題,其他格式問題(如換行、標點)無法處理。整體質量中上,適合經常遇到程式碼裡有雜散空格困擾的使用者使用。

📊 多維度評分

適應性4.3
規範性4.2
有效性4.7
可靠性4
可信度5

📁 包含檔案 (4 個)

📄 README.md 6.7 KB
📄 SKILL.md 6.5 KB
📄 _meta.json 135 B
📄 cleaner.py 8.5 KB