@2api-store/activate 0.3.2 → 0.3.4
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.
- package/lib/detect.mjs +4 -2
- package/lib/install.mjs +9 -4
- package/lib/platforms.mjs +31 -4
- package/package.json +1 -1
package/lib/detect.mjs
CHANGED
|
@@ -62,11 +62,13 @@ function findBinary(name, isWindows) {
|
|
|
62
62
|
function getVersion(bin, isWindows) {
|
|
63
63
|
// --version 是通用约定;codex/claude/gemini/opencode/grok 都支持
|
|
64
64
|
try {
|
|
65
|
-
const
|
|
65
|
+
const cmdBin = isWindows ? process.env.COMSPEC || 'cmd.exe' : bin
|
|
66
|
+
const cmdArgs = isWindows ? ['/c', bin, '--version'] : ['--version']
|
|
67
|
+
const result = spawnSync(cmdBin, cmdArgs, {
|
|
66
68
|
encoding: 'utf8',
|
|
67
69
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
68
70
|
timeout: 5000,
|
|
69
|
-
//
|
|
71
|
+
// Windows: CLI 是 <bin>.cmd batch,必须经 cmd.exe /c 解析;不用 shell:true(DEP0190)
|
|
70
72
|
})
|
|
71
73
|
if (result.status === 0 && result.stdout) {
|
|
72
74
|
const firstLine = result.stdout.trim().split(/\r?\n/)[0]
|
package/lib/install.mjs
CHANGED
|
@@ -38,15 +38,20 @@ export function installCLI(meta, opts = {}) {
|
|
|
38
38
|
|
|
39
39
|
console.log(` 正在执行:${cmd}…`)
|
|
40
40
|
try {
|
|
41
|
-
const
|
|
41
|
+
const isWin = process.platform === 'win32'
|
|
42
|
+
const npmBin = isWin ? process.env.COMSPEC || 'cmd.exe' : 'npm'
|
|
43
|
+
const npmArgs = isWin ? ['/c', 'npm', 'install', '-g', pkg] : ['install', '-g', pkg]
|
|
44
|
+
const result = spawnSync(npmBin, npmArgs, {
|
|
42
45
|
stdio: 'inherit', // npm 进度/输出直接透传到当前终端
|
|
43
|
-
//
|
|
46
|
+
// Windows: npm 是 npm.cmd batch,必须经 cmd.exe /c 解析;不用 shell:true(node 22+ DEP0190)
|
|
44
47
|
})
|
|
48
|
+
if (result.error) {
|
|
49
|
+
return { ok: false, error: result.error.message }
|
|
50
|
+
}
|
|
45
51
|
if (result.status === 0) {
|
|
46
52
|
return { ok: true }
|
|
47
53
|
}
|
|
48
|
-
|
|
49
|
-
return { ok: false, error: errText }
|
|
54
|
+
return { ok: false, error: `npm exit ${result.status}` }
|
|
50
55
|
} catch (err) {
|
|
51
56
|
return { ok: false, error: err.message }
|
|
52
57
|
}
|
package/lib/platforms.mjs
CHANGED
|
@@ -53,7 +53,7 @@ export const CLI_META = {
|
|
|
53
53
|
' codex --sandbox read-only --ask-for-approval never 只读(最安全)',
|
|
54
54
|
' codex --help 查看所有选项',
|
|
55
55
|
].join('\n'),
|
|
56
|
-
isPrimary:
|
|
56
|
+
isPrimary: false, // codex 的 WebSocket 变体(同 CLI 同 config.toml,默认不选避免覆盖 codex 模式)
|
|
57
57
|
},
|
|
58
58
|
claude: {
|
|
59
59
|
name: 'Claude Code',
|
|
@@ -62,7 +62,20 @@ export const CLI_META = {
|
|
|
62
62
|
startCmd: 'claude',
|
|
63
63
|
detectBin: 'claude',
|
|
64
64
|
configFiles: ['~/.claude/', '~/.claude.json'],
|
|
65
|
-
usage:
|
|
65
|
+
usage: [
|
|
66
|
+
'常用命令:',
|
|
67
|
+
' claude 交互模式',
|
|
68
|
+
' claude "你的问题" 带初始问题启动',
|
|
69
|
+
' claude -p "问题" 非交互模式(输出后退出,适合脚本)',
|
|
70
|
+
' claude -c 继续最近会话',
|
|
71
|
+
' claude -r 恢复历史会话(选择器)',
|
|
72
|
+
' claude --model sonnet 指定模型(sonnet/opus/haiku/fable)',
|
|
73
|
+
' claude mcp 管理 MCP 服务器',
|
|
74
|
+
' claude doctor 诊断安装/配置',
|
|
75
|
+
' claude update 更新到最新版',
|
|
76
|
+
'权限模式(Shift+Tab 切换):default / acceptEdits / plan / auto / bypassPermissions',
|
|
77
|
+
'项目根放 CLAUDE.md 让 Claude 了解你的代码库',
|
|
78
|
+
].join('\n'),
|
|
66
79
|
isPrimary: true,
|
|
67
80
|
},
|
|
68
81
|
'gemini-cli': {
|
|
@@ -72,7 +85,15 @@ export const CLI_META = {
|
|
|
72
85
|
startCmd: 'gemini',
|
|
73
86
|
detectBin: 'gemini',
|
|
74
87
|
configFiles: ['~/.gemini/settings.json'],
|
|
75
|
-
usage:
|
|
88
|
+
usage: [
|
|
89
|
+
'常用命令:',
|
|
90
|
+
' gemini 交互模式',
|
|
91
|
+
' gemini "你的问题" 带初始问题启动',
|
|
92
|
+
' gemini -p "问题" 非交互模式(输出后退出)',
|
|
93
|
+
' gemini --resume 恢复历史会话',
|
|
94
|
+
' gemini --help 查看所有选项',
|
|
95
|
+
'项目根放 GEMINI.md 让 Gemini 了解你的代码库',
|
|
96
|
+
].join('\n'),
|
|
76
97
|
isPrimary: true,
|
|
77
98
|
},
|
|
78
99
|
opencode: {
|
|
@@ -83,7 +104,13 @@ export const CLI_META = {
|
|
|
83
104
|
startCmd: 'opencode',
|
|
84
105
|
detectBin: 'opencode',
|
|
85
106
|
configFiles: ['~/.config/opencode/opencode.json', 'opencode.json'],
|
|
86
|
-
usage:
|
|
107
|
+
usage: [
|
|
108
|
+
'常用命令:',
|
|
109
|
+
' opencode 交互模式',
|
|
110
|
+
' opencode "你的问题" 带初始问题启动',
|
|
111
|
+
' opencode --help 查看所有选项',
|
|
112
|
+
'项目根放 AGENTS.md 让 OpenCode 了解你的代码库',
|
|
113
|
+
].join('\n'),
|
|
87
114
|
isPrimary: false,
|
|
88
115
|
},
|
|
89
116
|
}
|