From 357cd0958ff97d9403c5f51bc0ce97cb4c410b94 Mon Sep 17 00:00:00 2001 From: OpenClaw Date: Fri, 8 May 2026 00:52:25 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E7=BB=9F=E4=B8=80=E8=87=AA?= =?UTF-8?q?=E7=A0=94=E6=8F=92=E4=BB=B6=E6=A0=BC=E5=BC=8F=E4=B8=BA=20Liugin?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 18个插件: class Plugin -> class Liugin 10个插件: 测试块 Plugin() -> Liugin() 移除 ai_image.py 中多余的 Liugin = Plugin 别名 所有自研插件现统一使用 class Liugin 作为入口类名, 加载器保留 Plugin 兼容以支持第三方插件。 --- plugins/ai_image.py | 3 +-- plugins/auto_engineer.py | 2 +- plugins/bookmark_manager.py | 4 ++-- plugins/browser_auto.py | 2 +- plugins/cmd_executor.py | 2 +- plugins/code_editor.py | 2 +- plugins/color_picker.py | 4 ++-- plugins/file_manager.py | 2 +- plugins/frontend_tester.py | 2 +- plugins/git_tools.py | 2 +- plugins/gui_auto.py | 2 +- plugins/id_generator.py | 4 ++-- plugins/image_generator.py | 2 +- plugins/json_toolkit.py | 4 ++-- plugins/markdown_tool.py | 4 ++-- plugins/memory_plugin.py | 2 +- plugins/regex_tester.py | 4 ++-- plugins/snippet_manager.py | 4 ++-- plugins/speech_recognition.py | 2 +- plugins/sub_agent.py | 2 +- plugins/task_manager.py | 2 +- 21 files changed, 28 insertions(+), 29 deletions(-) diff --git a/plugins/ai_image.py b/plugins/ai_image.py index 945f318..8602921 100644 --- a/plugins/ai_image.py +++ b/plugins/ai_image.py @@ -25,7 +25,7 @@ except ImportError: WEBSOCKET_AVAILABLE = False -class Plugin: +class Liugin: """AI 生图插件 - 调用 ai.2x.nz 接口生成图片""" BASE_URL = "https://ai.2x.nz" @@ -587,4 +587,3 @@ class Plugin: # 兼容 Liugin 类名 -Liugin = Plugin diff --git a/plugins/auto_engineer.py b/plugins/auto_engineer.py index 9455ab7..c800f66 100644 --- a/plugins/auto_engineer.py +++ b/plugins/auto_engineer.py @@ -10,7 +10,7 @@ import subprocess from typing import Tuple, List -class Plugin: +class Liugin: """工程化工具 - lint/format/test/build + 代码分析""" def __init__(self): diff --git a/plugins/bookmark_manager.py b/plugins/bookmark_manager.py index e50b118..db29c21 100644 --- a/plugins/bookmark_manager.py +++ b/plugins/bookmark_manager.py @@ -11,7 +11,7 @@ from datetime import datetime from typing import List, Optional -class Plugin: +class Liugin: """书签管理器 - 开发资源和链接管理""" def __init__(self): @@ -477,7 +477,7 @@ class Plugin: def test_plugin(): - plugin = Plugin() + plugin = Liugin() print("书签管理器测试:") print(plugin.handle('add https://github.com -n GitHub -c 开发 -t 代码,托管 -d 代码托管平台')) print(plugin.handle('add https://stackoverflow.com -n StackOverflow -c 学习 -t 问答,编程')) diff --git a/plugins/browser_auto.py b/plugins/browser_auto.py index 1acf42b..c791208 100644 --- a/plugins/browser_auto.py +++ b/plugins/browser_auto.py @@ -9,7 +9,7 @@ import time from typing import Optional -class Plugin: +class Liugin: """浏览器自动化 - 网页操控、表单填写、数据抓取、截图""" def __init__(self): diff --git a/plugins/cmd_executor.py b/plugins/cmd_executor.py index 2b1b174..394f485 100644 --- a/plugins/cmd_executor.py +++ b/plugins/cmd_executor.py @@ -7,7 +7,7 @@ import subprocess import platform -class Plugin: +class Liugin: """Shell 命令执行器 - 跨平台命令行工具""" def __init__(self): diff --git a/plugins/code_editor.py b/plugins/code_editor.py index 4463671..6bc165e 100644 --- a/plugins/code_editor.py +++ b/plugins/code_editor.py @@ -16,7 +16,7 @@ import threading from typing import Optional, Tuple, List -class Plugin: +class Liugin: """代码编辑与搜索 - 精准编辑 + 代码理解""" def __init__(self): diff --git a/plugins/color_picker.py b/plugins/color_picker.py index 45da008..34fea2c 100644 --- a/plugins/color_picker.py +++ b/plugins/color_picker.py @@ -8,7 +8,7 @@ import colorsys from typing import List, Tuple -class Plugin: +class Liugin: """颜色工具 - 格式转换、调色板、对比度检查""" def __init__(self): @@ -447,7 +447,7 @@ class Plugin: def test_plugin(): - plugin = Plugin() + plugin = Liugin() print("颜色工具测试:") print(plugin.handle('convert "#3498db"')) print(plugin.handle('contrast "#FFFFFF" "#000000"')) diff --git a/plugins/file_manager.py b/plugins/file_manager.py index 8fbf397..6fd1c23 100644 --- a/plugins/file_manager.py +++ b/plugins/file_manager.py @@ -10,7 +10,7 @@ from pathlib import Path from typing import List -class Plugin: +class Liugin: """文件管理器 - 文件和目录的增删改查""" def __init__(self): diff --git a/plugins/frontend_tester.py b/plugins/frontend_tester.py index 1ec777b..0ca23a8 100644 --- a/plugins/frontend_tester.py +++ b/plugins/frontend_tester.py @@ -443,7 +443,7 @@ JSON格式示例: # 测试函数 def test_plugin(): """测试插件功能""" - plugin = Plugin() + plugin = Liugin() print("前端测试验证插件测试:") print("\n1. 创建测试HTML文件:") diff --git a/plugins/git_tools.py b/plugins/git_tools.py index b06606f..10f4ba0 100644 --- a/plugins/git_tools.py +++ b/plugins/git_tools.py @@ -8,7 +8,7 @@ import subprocess from typing import Tuple, Optional -class Plugin: +class Liugin: """Git 版本控制 - 基础操作 + 工作流自动化""" def __init__(self): diff --git a/plugins/gui_auto.py b/plugins/gui_auto.py index 8ddcaee..cdb78cd 100644 --- a/plugins/gui_auto.py +++ b/plugins/gui_auto.py @@ -14,7 +14,7 @@ from typing import Optional, List, Dict, Any IS_WINDOWS = sys.platform == "win32" -class Plugin: +class Liugin: """Windows GUI 自动化 - 屏幕元素识别、点击、输入、截图、元素树遍历""" def __init__(self): diff --git a/plugins/id_generator.py b/plugins/id_generator.py index b3c768a..9bd1ace 100644 --- a/plugins/id_generator.py +++ b/plugins/id_generator.py @@ -15,7 +15,7 @@ from datetime import datetime from typing import List -class Plugin: +class Liugin: """UUID / ID 生成器 - 多格式唯一标识符生成""" def __init__(self): @@ -367,7 +367,7 @@ class Plugin: def test_plugin(): - plugin = Plugin() + plugin = Liugin() print("ID 生成器测试:") print(plugin.handle('uuid')) print(plugin.handle('uuid -v 1 -n 3')) diff --git a/plugins/image_generator.py b/plugins/image_generator.py index f980425..cb9c5ab 100644 --- a/plugins/image_generator.py +++ b/plugins/image_generator.py @@ -10,7 +10,7 @@ import time from typing import Optional -class Plugin: +class Liugin: """图像生成工具 — 自然语言/Tag 生图,基于 ComfyUI 在线服务""" def __init__(self): diff --git a/plugins/json_toolkit.py b/plugins/json_toolkit.py index ced8273..c8995e9 100644 --- a/plugins/json_toolkit.py +++ b/plugins/json_toolkit.py @@ -9,7 +9,7 @@ import re from typing import List -class Plugin: +class Liugin: """JSON 工具箱 - 格式化/校验/查询/转换""" def __init__(self): @@ -374,7 +374,7 @@ class Plugin: def test_plugin(): - plugin = Plugin() + plugin = Liugin() print("JSON 工具箱测试:") print(plugin.handle('validate \'{"name": "test", "age": 25}\'')) print(plugin.handle('format \'{"name":"test","items":[1,2,3]}\'')) diff --git a/plugins/markdown_tool.py b/plugins/markdown_tool.py index 8669fd2..95bd885 100644 --- a/plugins/markdown_tool.py +++ b/plugins/markdown_tool.py @@ -9,7 +9,7 @@ import os from typing import List, Tuple -class Plugin: +class Liugin: """Markdown 工具 - TOC/渲染/格式转换/统计""" def __init__(self): @@ -529,7 +529,7 @@ class Plugin: def test_plugin(): - plugin = Plugin() + plugin = Liugin() print("Markdown 工具测试:") print(plugin.handle('headings "# Hello\\n## World\\n### Sub"')) print(plugin.handle('stats "# Hello\\n\\nThis is a test."')) diff --git a/plugins/memory_plugin.py b/plugins/memory_plugin.py index 8643e64..4f91496 100644 --- a/plugins/memory_plugin.py +++ b/plugins/memory_plugin.py @@ -13,7 +13,7 @@ sys.path.insert(0, project_root) from xcli_core.memory import MemoryManager -class Plugin: +class Liugin: """持久化记忆系统 — AI 可写日记、搜索记忆、管理聊天记录""" def __init__(self): diff --git a/plugins/regex_tester.py b/plugins/regex_tester.py index 75be488..af46c9f 100644 --- a/plugins/regex_tester.py +++ b/plugins/regex_tester.py @@ -9,7 +9,7 @@ import os from typing import List -class Plugin: +class Liugin: """正则表达式测试器 - 测试、调试、管理正则""" def __init__(self): @@ -430,7 +430,7 @@ class Plugin: def test_plugin(): - plugin = Plugin() + plugin = Liugin() print("正则表达式测试器测试:") print(plugin.handle('test "\\d+" "abc123def456"')) print(plugin.handle('match "[a-z]+" "hello world foo bar"')) diff --git a/plugins/snippet_manager.py b/plugins/snippet_manager.py index 8c62558..61a2b4f 100644 --- a/plugins/snippet_manager.py +++ b/plugins/snippet_manager.py @@ -11,7 +11,7 @@ from datetime import datetime from typing import List, Optional -class Plugin: +class Liugin: """代码片段管理器 - 保存和复用代码片段""" def __init__(self): @@ -416,7 +416,7 @@ class Plugin: def test_plugin(): - plugin = Plugin() + plugin = Liugin() print("代码片段管理器测试:") print(plugin.handle('add hello -l python -c "print(\'Hello, World!\')" -t 示例,入门 -d 最简单的Python程序')) print(plugin.handle('add fib -l python -c "def fib(n): return n if n < 2 else fib(n-1)+fib(n-2)" -t 算法,递归')) diff --git a/plugins/speech_recognition.py b/plugins/speech_recognition.py index 439b7cb..7dcfc3b 100644 --- a/plugins/speech_recognition.py +++ b/plugins/speech_recognition.py @@ -543,7 +543,7 @@ if __name__ == "__main__": if __name__ == "__main__": - plugin = Plugin() + plugin = Liugin() print("语音识别插件") print(f"临时目录: {plugin.temp_dir}") print("\n" + plugin.usage) diff --git a/plugins/sub_agent.py b/plugins/sub_agent.py index 27c97ff..af2206a 100644 --- a/plugins/sub_agent.py +++ b/plugins/sub_agent.py @@ -42,7 +42,7 @@ class SubAgent: } -class Plugin: +class Liugin: """子 Agent 系统 - 创建、管理、协作""" def __init__(self): diff --git a/plugins/task_manager.py b/plugins/task_manager.py index 90afe15..fe31556 100644 --- a/plugins/task_manager.py +++ b/plugins/task_manager.py @@ -258,7 +258,7 @@ JSON格式示例: # 测试函数 def test_plugin(): """测试插件功能""" - plugin = Plugin() + plugin = Liugin() print("任务管理插件测试:") print("\n1. 添加任务:")