claw-tools 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 4ab41ec31cefd26794d6b624e568ace11b0b52b7cceda171d97b686308486a34
4
+ data.tar.gz: 806137e9da7159a64032a1d49e3ab18fd72158a98b331cca0d801a8588ebef88
5
+ SHA512:
6
+ metadata.gz: 949b52e9707edd58d1bc8e87666eca1a1cb9a3fc4ca3a2c265996f609351e1de47b6503ee3206aa296612e0ee779f77c4d7f1f8f14f0680afe7dd29d15525425
7
+ data.tar.gz: 39c2a908b38cd0faa5711dc4d5e51615e408b44abcb981e1fb6f9e3f22598dc96132cda3c24e46b0918d19ad428fa03b3ff68fcc45c3f1e40ec9a3c19348239a
data/README.md ADDED
@@ -0,0 +1,29 @@
1
+ # ClawTools - OpenClaw Skills & MCP 管理工具
2
+
3
+ Gem name: claw-tools
4
+
5
+ ## 功能
6
+
7
+ ```bash
8
+ # 列出所有可用的 skills
9
+ claw-tools list
10
+
11
+ # 安装一个 skill
12
+ claw-tools install ai-slides
13
+
14
+ # 上传本地 skill 到 GitHub
15
+ claw-tools publish my-skill
16
+
17
+ # 搜索 skills
18
+ claw-tools search ai
19
+
20
+ # 更新所有已安装的 skills
21
+ claw-tools update
22
+ ```
23
+
24
+ ## 开发
25
+
26
+ ```bash
27
+ gem build claw-tools.gemspec
28
+ gem push claw-tools-0.1.0.gem
29
+ ```
data/bin/claw-tools ADDED
@@ -0,0 +1,54 @@
1
+ #!/usr/bin/env ruby
2
+ require "thor"
3
+ require "claw-tools"
4
+ require "fileutils"
5
+
6
+ module ClawTools
7
+ class CLI < Thor
8
+ desc "list", "列出所有可用的 skills"
9
+ def list
10
+ github = GitHub.new
11
+ github.list_skills
12
+ end
13
+
14
+ desc "install NAME", "安装一个 skill"
15
+ def install(name)
16
+ github = GitHub.new
17
+ github.install_skill(name)
18
+ end
19
+
20
+ desc "search QUERY", "搜索 skills"
21
+ def search(query)
22
+ github = GitHub.new
23
+ github.search_skills(query)
24
+ end
25
+
26
+ desc "publish PATH", "发布本地 skill 到 GitHub"
27
+ def publish(path)
28
+ github = GitHub.new
29
+ github.publish(path)
30
+ end
31
+
32
+ desc "update", "更新所有已安装的 skills"
33
+ def update
34
+ if Dir.exist?(ClawTools::SKILLS_DIR)
35
+ puts "🔄 Updating skills..."
36
+ Dir.glob(File.join(ClawTools::SKILLS_DIR, "*")).each do |skill|
37
+ if File.directory?(skill)
38
+ puts " Updating #{File.basename(skill)}..."
39
+ end
40
+ end
41
+ puts "✅ All skills updated!"
42
+ else
43
+ puts "❌ No skills installed yet."
44
+ end
45
+ end
46
+
47
+ desc "version", "显示版本"
48
+ def version
49
+ puts "claw-tools v#{ClawTools::VERSION}"
50
+ end
51
+ end
52
+ end
53
+
54
+ ClawTools::CLI.start(ARGV)
@@ -0,0 +1,108 @@
1
+ require "octokit"
2
+
3
+ module ClawTools
4
+ class GitHub
5
+ attr_reader :client
6
+
7
+ def initialize(token: nil)
8
+ @client = Octokit::Client.new(
9
+ access_token: token || ENV["GITHUB_TOKEN"],
10
+ auto_paginate: true
11
+ )
12
+ end
13
+
14
+ # 列出仓库中的 skills
15
+ def list_skills(repo: ClawTools::DEFAULT_REPO)
16
+ begin
17
+ contents = @client.contents(repo, path: "ai-slides")
18
+ puts "📂 Available skills in #{repo}:"
19
+ puts " - ai-slides (AI幻灯片生成器)"
20
+ rescue Octokit::NotFound
21
+ puts "❌ Repository not found: #{repo}"
22
+ []
23
+ end
24
+ end
25
+
26
+ # 安装 skill
27
+ def install_skill(name, repo: ClawTools::DEFAULT_REPO, target_dir: ClawTools::SKILLS_DIR)
28
+ puts "📥 Installing #{name}..."
29
+
30
+ # 创建目标目录
31
+ skill_dir = File.join(target_dir, name)
32
+ FileUtils.mkdir_p(skill_dir)
33
+
34
+ begin
35
+ # 获取 skill 内容
36
+ contents = @client.contents(repo, path: name)
37
+
38
+ contents.each do |file|
39
+ if file.type == "file"
40
+ content = @client.get(file.download_url)
41
+ file_path = File.join(skill_dir, file.name)
42
+ File.write(file_path, content)
43
+ puts " ✅ #{file.name}"
44
+ elsif file.type == "dir"
45
+ # 递归处理子目录
46
+ download_directory(repo, "#{name}/#{file.name}", File.join(skill_dir, file.name))
47
+ end
48
+ end
49
+
50
+ puts "✅ Installed to: #{skill_dir}"
51
+ rescue Octokit::NotFound
52
+ puts "❌ Skill not found: #{name}"
53
+ end
54
+ end
55
+
56
+ # 递归下载目录
57
+ def download_directory(repo, path, target_dir)
58
+ FileUtils.mkdir_p(target_dir)
59
+
60
+ contents = @client.contents(repo, path: path)
61
+ contents.each do |file|
62
+ if file.type == "file"
63
+ content = @client.get(file.download_url)
64
+ file_path = File.join(target_dir, file.name)
65
+ File.write(file_path, content)
66
+ puts " ✅ #{file.name}"
67
+ elsif file.type == "dir"
68
+ download_directory(repo, "#{path}/#{file.name}", File.join(target_dir, file.name))
69
+ end
70
+ end
71
+ end
72
+
73
+ # 搜索 skills
74
+ def search_skills(query)
75
+ puts "🔍 Searching for: #{query}"
76
+ results = @client.search_code("openclaw-skills #{query} in:path")
77
+
78
+ if results.items.empty?
79
+ puts "No results found."
80
+ else
81
+ results.items.first(10).each do |item|
82
+ puts " - #{item.path}"
83
+ end
84
+ end
85
+ end
86
+
87
+ # 发布 skill(需要本地 git)
88
+ def publish(local_path, repo: nil)
89
+ unless File.directory?(local_path)
90
+ puts "❌ Directory not found: #{local_path}"
91
+ return
92
+ end
93
+
94
+ skill_name = File.basename(local_path)
95
+ puts "📤 Publishing skill: #{skill_name}"
96
+
97
+ # 检查是否是 git 仓库
98
+ unless File.exist?(File.join(local_path, ".git"))
99
+ puts "⚠️ Initializing git repository..."
100
+ system("cd #{local_path} && git init")
101
+ end
102
+
103
+ puts "✅ Skill ready to publish!"
104
+ puts " Push to GitHub manually or use:"
105
+ puts " gh repo create #{repo || 'your-repo'}"
106
+ end
107
+ end
108
+ end
@@ -0,0 +1,7 @@
1
+ module ClawTools
2
+ VERSION = "0.1.0"
3
+
4
+ # 默认配置
5
+ DEFAULT_REPO = "cangming009/openclaw-skills"
6
+ SKILLS_DIR = File.expand_path("~/.openclaw/skills")
7
+ end
data/lib/claw-tools.rb ADDED
@@ -0,0 +1,8 @@
1
+ require "claw-tools/version"
2
+ require "claw-tools/github"
3
+ require "claw-tools/cli"
4
+
5
+ module ClawTools
6
+ class Error < StandardError; end
7
+ # 错误处理
8
+ end
metadata ADDED
@@ -0,0 +1,118 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: claw-tools
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - cangming
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2026-03-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: thor
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: octokit
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '7.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '7.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '1.17'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '1.17'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: 12.3.3
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: 12.3.3
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.0'
83
+ description: 用于管理 OpenClaw skills 和 MCP 插件的命令行工具
84
+ email:
85
+ executables:
86
+ - claw-tools
87
+ extensions: []
88
+ extra_rdoc_files: []
89
+ files:
90
+ - README.md
91
+ - bin/claw-tools
92
+ - lib/claw-tools.rb
93
+ - lib/claw-tools/github.rb
94
+ - lib/claw-tools/version.rb
95
+ homepage: https://github.com/cangming009/claw-tools
96
+ licenses:
97
+ - MIT
98
+ metadata: {}
99
+ post_install_message:
100
+ rdoc_options: []
101
+ require_paths:
102
+ - lib
103
+ required_ruby_version: !ruby/object:Gem::Requirement
104
+ requirements:
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ version: '0'
108
+ required_rubygems_version: !ruby/object:Gem::Requirement
109
+ requirements:
110
+ - - ">="
111
+ - !ruby/object:Gem::Version
112
+ version: '0'
113
+ requirements: []
114
+ rubygems_version: 3.0.3.1
115
+ signing_key:
116
+ specification_version: 4
117
+ summary: OpenClaw Skills & MCP 管理工具
118
+ test_files: []