easyai 1.0.2 → 1.0.3
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 +4 -4
- data/CLAUDE.md +154 -5
- data/README.md +38 -57
- data/bin/easyai +5 -5
- data/lib/easyai/auth/authclaude.rb +440 -0
- data/lib/easyai/auth/jpslogin.rb +384 -0
- data/lib/easyai/base/file_crypto.rb +214 -0
- data/lib/easyai/base/system_keychain.rb +240 -0
- data/lib/easyai/base/update_notifier.rb +129 -0
- data/lib/easyai/base/version_checker.rb +329 -0
- data/lib/easyai/command/claude.rb +278 -0
- data/lib/easyai/command/clean.rb +453 -0
- data/lib/easyai/command/gemini.rb +58 -0
- data/lib/easyai/command/gpt.rb +58 -0
- data/lib/easyai/command/update.rb +210 -0
- data/lib/easyai/command/utils/decry.rb +102 -0
- data/lib/easyai/command/utils/encry.rb +102 -0
- data/lib/easyai/command/utils.rb +32 -0
- data/lib/easyai/command.rb +56 -0
- data/lib/easyai/config/config.rb +550 -0
- data/lib/easyai/version.rb +1 -1
- data/lib/easyai.rb +67 -55
- metadata +17 -4
- data/lib/easyai/claude.rb +0 -61
- data/lib/easyai/gemini.rb +0 -61
- data/lib/easyai/gpt.rb +0 -60
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: easyai
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wade
|
@@ -93,9 +93,22 @@ files:
|
|
93
93
|
- bin/easyai
|
94
94
|
- easyai.gemspec
|
95
95
|
- lib/easyai.rb
|
96
|
-
- lib/easyai/
|
97
|
-
- lib/easyai/
|
98
|
-
- lib/easyai/
|
96
|
+
- lib/easyai/auth/authclaude.rb
|
97
|
+
- lib/easyai/auth/jpslogin.rb
|
98
|
+
- lib/easyai/base/file_crypto.rb
|
99
|
+
- lib/easyai/base/system_keychain.rb
|
100
|
+
- lib/easyai/base/update_notifier.rb
|
101
|
+
- lib/easyai/base/version_checker.rb
|
102
|
+
- lib/easyai/command.rb
|
103
|
+
- lib/easyai/command/claude.rb
|
104
|
+
- lib/easyai/command/clean.rb
|
105
|
+
- lib/easyai/command/gemini.rb
|
106
|
+
- lib/easyai/command/gpt.rb
|
107
|
+
- lib/easyai/command/update.rb
|
108
|
+
- lib/easyai/command/utils.rb
|
109
|
+
- lib/easyai/command/utils/decry.rb
|
110
|
+
- lib/easyai/command/utils/encry.rb
|
111
|
+
- lib/easyai/config/config.rb
|
99
112
|
- lib/easyai/version.rb
|
100
113
|
homepage: https://github.com/wade/easyai
|
101
114
|
licenses:
|
data/lib/easyai/claude.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
module EasyAI
|
2
|
-
class Claude < Command
|
3
|
-
self.command = 'claude'
|
4
|
-
self.summary = '使用配置的环境运行 Claude CLI'
|
5
|
-
self.description = <<-DESC
|
6
|
-
使用预配置的 API 令牌和代理设置运行 Claude CLI 工具。
|
7
|
-
所有参数都会传递给 claude 命令。
|
8
|
-
DESC
|
9
|
-
|
10
|
-
def initialize(argv)
|
11
|
-
@claude_args = argv.remainder!
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def validate!
|
16
|
-
super
|
17
|
-
help! '未找到 Claude CLI。请安装:npm install -g @anthropic-ai/claude-code' unless claude_available?
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
config = load_config
|
22
|
-
|
23
|
-
env = ENV.to_h.merge({
|
24
|
-
'ANTHROPIC_API_KEY' => config['claude_token'] || config['anthropic_api_key'],
|
25
|
-
'CLAUDE_CODE_OAUTH_TOKEN' => config['claude_token'] || config['anthropic_api_key']
|
26
|
-
})
|
27
|
-
|
28
|
-
# Add proxy settings if configured
|
29
|
-
if config['http_proxy']
|
30
|
-
env['HTTP_PROXY'] = config['http_proxy']
|
31
|
-
env['HTTPS_PROXY'] = config['http_proxy']
|
32
|
-
env['http_proxy'] = config['http_proxy']
|
33
|
-
env['https_proxy'] = config['http_proxy']
|
34
|
-
end
|
35
|
-
|
36
|
-
puts "正在运行: claude #{@claude_args.join(' ')}".blue if verbose?
|
37
|
-
exec(env, 'claude', *@claude_args)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def claude_available?
|
43
|
-
# 跨平台命令检测
|
44
|
-
if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
|
45
|
-
system('where claude >nul 2>&1')
|
46
|
-
else
|
47
|
-
system('which claude > /dev/null 2>&1')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def load_config
|
52
|
-
config_path = File.expand_path('~/.easyai/config.yml')
|
53
|
-
return {} unless File.exist?(config_path)
|
54
|
-
|
55
|
-
YAML.load_file(config_path) || {}
|
56
|
-
rescue => e
|
57
|
-
puts "加载配置出错: #{e.message}".red
|
58
|
-
{}
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/lib/easyai/gemini.rb
DELETED
@@ -1,61 +0,0 @@
|
|
1
|
-
module EasyAI
|
2
|
-
class Gemini < Command
|
3
|
-
self.command = 'gemini'
|
4
|
-
self.summary = '使用配置的环境运行 Gemini CLI'
|
5
|
-
self.description = <<-DESC
|
6
|
-
使用预配置的 API 令牌和代理设置运行 Gemini CLI 工具。
|
7
|
-
所有参数都会传递给 gemini 命令。
|
8
|
-
DESC
|
9
|
-
|
10
|
-
def initialize(argv)
|
11
|
-
@gemini_args = argv.remainder!
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def validate!
|
16
|
-
super
|
17
|
-
help! '未找到 Gemini CLI。请安装:npm install -g @google/gemini-cli' unless gemini_available?
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
config = load_config
|
22
|
-
|
23
|
-
env = ENV.to_h.merge({
|
24
|
-
'GOOGLE_API_KEY' => config['gemini_token'] || config['google_api_key'],
|
25
|
-
'GEMINI_API_KEY' => config['gemini_token'] || config['google_api_key']
|
26
|
-
})
|
27
|
-
|
28
|
-
# Add proxy settings if configured
|
29
|
-
if config['http_proxy']
|
30
|
-
env['HTTP_PROXY'] = config['http_proxy']
|
31
|
-
env['HTTPS_PROXY'] = config['http_proxy']
|
32
|
-
env['http_proxy'] = config['http_proxy']
|
33
|
-
env['https_proxy'] = config['http_proxy']
|
34
|
-
end
|
35
|
-
|
36
|
-
puts "正在运行: gemini #{@gemini_args.join(' ')}".blue if verbose?
|
37
|
-
exec(env, 'gemini', *@gemini_args)
|
38
|
-
end
|
39
|
-
|
40
|
-
private
|
41
|
-
|
42
|
-
def gemini_available?
|
43
|
-
# 跨平台命令检测
|
44
|
-
if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
|
45
|
-
system('where gemini >nul 2>&1')
|
46
|
-
else
|
47
|
-
system('which gemini > /dev/null 2>&1')
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def load_config
|
52
|
-
config_path = File.expand_path('~/.easyai/config.yml')
|
53
|
-
return {} unless File.exist?(config_path)
|
54
|
-
|
55
|
-
YAML.load_file(config_path) || {}
|
56
|
-
rescue => e
|
57
|
-
puts "加载配置出错: #{e.message}".red
|
58
|
-
{}
|
59
|
-
end
|
60
|
-
end
|
61
|
-
end
|
data/lib/easyai/gpt.rb
DELETED
@@ -1,60 +0,0 @@
|
|
1
|
-
module EasyAI
|
2
|
-
class GPT < Command
|
3
|
-
self.command = 'gpt'
|
4
|
-
self.summary = '使用配置的环境运行 OpenAI CLI'
|
5
|
-
self.description = <<-DESC
|
6
|
-
使用预配置的 API 令牌和代理设置运行 OpenAI CLI 工具。
|
7
|
-
所有参数都会传递给 openai 命令。
|
8
|
-
DESC
|
9
|
-
|
10
|
-
def initialize(argv)
|
11
|
-
@gpt_args = argv.remainder!
|
12
|
-
super
|
13
|
-
end
|
14
|
-
|
15
|
-
def validate!
|
16
|
-
super
|
17
|
-
help! '未找到 OpenAI CLI。请安装:pip install openai' unless gpt_available?
|
18
|
-
end
|
19
|
-
|
20
|
-
def run
|
21
|
-
config = load_config
|
22
|
-
|
23
|
-
env = ENV.to_h.merge({
|
24
|
-
'OPENAI_API_KEY' => config['openai_token'] || config['openai_api_key']
|
25
|
-
})
|
26
|
-
|
27
|
-
# Add proxy settings if configured
|
28
|
-
if config['http_proxy']
|
29
|
-
env['HTTP_PROXY'] = config['http_proxy']
|
30
|
-
env['HTTPS_PROXY'] = config['http_proxy']
|
31
|
-
env['http_proxy'] = config['http_proxy']
|
32
|
-
env['https_proxy'] = config['http_proxy']
|
33
|
-
end
|
34
|
-
|
35
|
-
puts "正在运行: openai #{@gpt_args.join(' ')}".blue if verbose?
|
36
|
-
exec(env, 'openai', *@gpt_args)
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def gpt_available?
|
42
|
-
# 跨平台命令检测
|
43
|
-
if RUBY_PLATFORM =~ /mswin|mingw|cygwin/
|
44
|
-
system('where openai >nul 2>&1')
|
45
|
-
else
|
46
|
-
system('which openai > /dev/null 2>&1')
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
def load_config
|
51
|
-
config_path = File.expand_path('~/.easyai/config.yml')
|
52
|
-
return {} unless File.exist?(config_path)
|
53
|
-
|
54
|
-
YAML.load_file(config_path) || {}
|
55
|
-
rescue => e
|
56
|
-
puts "加载配置出错: #{e.message}".red
|
57
|
-
{}
|
58
|
-
end
|
59
|
-
end
|
60
|
-
end
|