@vibeapi/api-helper 0.0.100 → 0.0.102
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/README.md +1 -1
- package/dist/commands/setup.d.ts +2 -2
- package/dist/commands/setup.js +1 -1
- package/dist/locales/en_US.json +4 -4
- package/dist/locales/zh_CN.json +4 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -46,7 +46,7 @@ npx --yes --registry https://npm.cnb.cool/vibeapi/npm/-/packages/ @vibeapi/cli@l
|
|
|
46
46
|
vibecli setup --key sk-xxx
|
|
47
47
|
```
|
|
48
48
|
|
|
49
|
-
`--key` 会按令牌能访问的模型分组自动配置:有 Claude 模型配 Claude Code
|
|
49
|
+
`--key` 会按令牌能访问的模型分组自动配置:有 Claude 模型配 Claude Code 和 Claude Desktop(macOS / Windows;桌面端没装也先写好,装好打开就能用)、有 GPT 模型配 Codex、有 Grok 模型配 Grok Build、有 Gemini 模型配 Antigravity CLI(`agy`)。没装的命令行工具也会先写好配置,再问要不要从国内镜像装上(`--install` 直接装)。拿到的是多个分组的令牌(如 Claude 分组 + GPT 分组 + Grok 分组),就各配各的:
|
|
50
50
|
|
|
51
51
|
```bash
|
|
52
52
|
vibecli setup --claudekey sk-a --codexkey sk-b --grokkey sk-c --desktopkey sk-d
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -9,8 +9,8 @@
|
|
|
9
9
|
* vibecli setup --claudekey sk-a --codexkey sk-b --grokkey sk-c --desktopkey sk-d
|
|
10
10
|
* 多令牌各配各的(如 Claude 分组 + GPT 分组 + Grok 分组),各自校验 + 能力核对,
|
|
11
11
|
* 明文存入 config.yaml 的工具专属 Key。只给其中一个旗标就只配对应工具。
|
|
12
|
-
* `--desktopkey` 配 Claude Desktop(桌面端 3p 模式);`--key`
|
|
13
|
-
* Claude Desktop
|
|
12
|
+
* `--desktopkey` 配 Claude Desktop(桌面端 3p 模式);`--key` 在 macOS / Windows 上一律顺带配置它,
|
|
13
|
+
* 没装也先写好(用户 2026-10-18 定),Linux 没有 Claude Desktop 不配。
|
|
14
14
|
*
|
|
15
15
|
* vibecli setup --1m
|
|
16
16
|
* 复用当前 profile 已保存的 Codex Key,开启 1M 上下文并重新应用配置。
|
package/dist/commands/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import o from"chalk";import{getAdapter as e}from"../lib/tools/registry.js";import{postApplyPrompts as t}from"../lib/post-apply.js";import{ensureReachableGatewayAddress as i}from"./base.js";import{i18n as s}from"../lib/i18n.js";import{configManager as l}from"../lib/config.js";import{toolManager as a,SUPPORTED_TOOLS as n}from"../lib/tool-manager.js";import{validateApiKey as r,fetchModels as p}from"../lib/api-validator.js";import{CODEX_ONE_MILLION_CONTEXT_SETTING as d,setCodexOneMillionContext as c}from"../lib/tools/codex.js";import{resolveModelCatalog as u}from"../lib/model-catalog.js";import{CLAUDE_DESKTOP_FORCE_REGISTRY_SETTING as m,CLAUDE_DESKTOP_HIDE_OFFICIAL_LOGIN_SETTING as f}from"../lib/tools/claude-desktop.js";import{operationError as g,authenticationError as y,networkError as k,EXIT_CODES as _}from"../lib/errors.js";import{isJsonMode as h,isNonInteractive as b,shouldAutoConfirm as w}from"../lib/runtime-options.js";import v from"inquirer";import{logger as x}from"../utils/logger.js";import{forgetInstalls as C}from"../lib/tools/tool-installs.js";import{CLI_NAME as
|
|
1
|
+
import o from"chalk";import{getAdapter as e}from"../lib/tools/registry.js";import{postApplyPrompts as t}from"../lib/post-apply.js";import{ensureReachableGatewayAddress as i}from"./base.js";import{i18n as s}from"../lib/i18n.js";import{configManager as l}from"../lib/config.js";import{toolManager as a,SUPPORTED_TOOLS as n}from"../lib/tool-manager.js";import{validateApiKey as r,fetchModels as p}from"../lib/api-validator.js";import{CODEX_ONE_MILLION_CONTEXT_SETTING as d,setCodexOneMillionContext as c}from"../lib/tools/codex.js";import{resolveModelCatalog as u}from"../lib/model-catalog.js";import{CLAUDE_DESKTOP_FORCE_REGISTRY_SETTING as m,CLAUDE_DESKTOP_HIDE_OFFICIAL_LOGIN_SETTING as f}from"../lib/tools/claude-desktop.js";import{operationError as g,authenticationError as y,networkError as k,EXIT_CODES as _}from"../lib/errors.js";import{isJsonMode as h,isNonInteractive as b,shouldAutoConfirm as w}from"../lib/runtime-options.js";import v from"inquirer";import{logger as x}from"../utils/logger.js";import{forgetInstalls as C}from"../lib/tools/tool-installs.js";import{CLI_NAME as j,brandEnv as K}from"../lib/brand.js";export const DEDICATED_KEYS=[{option:"claudekey",tool:"claude-code",need:"claude"},{option:"codexkey",tool:"codex",need:"gpt"},{option:"grokkey",tool:"grok",need:"grok"},{option:"desktopkey",tool:"claude-desktop",need:"claude"},{option:"agykey",tool:"agy",need:"gemini"},{option:"openclawkey",tool:"openclaw",need:"any",hidden:!0},{option:"hermeskey",tool:"hermes",need:"any",hidden:!0},{option:"atomcodekey",tool:"atomcode",need:"any",hidden:!0}];async function T(o){const e=await p(o);if(!e.ok)return{hasClaude:!0,hasGpt:!0,hasGrok:!0,hasGemini:!0,probed:!1};const t=e.models.map(o=>o.toLowerCase());return{hasClaude:t.some(o=>o.includes("claude")),hasGpt:t.some(o=>o.startsWith("gpt")||o.includes("gpt-")||/^o\d/.test(o)),hasGrok:t.some(o=>o.includes("grok")),hasGemini:t.some(o=>o.startsWith("gemini")),probed:!0}}function $(o,e){switch(e){case"claude":return o.hasClaude;case"gpt":return o.hasGpt;case"grok":return o.hasGrok;case"gemini":return o.hasGemini;default:return!0}}export function parseOnOff(o){const e=(o??"").trim().toLowerCase();return!!["on","true","show","1","yes","y"].includes(e)||!["off","false","hide","0","no","n"].includes(e)&&void 0}function G(e){console.log(o.green(e))}function M(e){console.log(o.yellow(e))}function S(e){console.error(o.red(e))}let N=null;function E(o){const e={operation:1,authentication:2,network:3};(!N||e[o]>e[N])&&(N=o)}async function A(e,t){h()||console.log(o.gray(s.t("setup.validating",{label:e})));const i=await r(t);if(i.valid)return!0;const a="zh_CN"===s.getLocale()?"<你的 Key>":"<your key>",n="--key"===e?`${j} setup --key ${a}`:`${j} setup ${e} ${a}`;let p;if("network_error"===i.error?(E("network"),p=k(s.t("setup.unreachable",{url:l.getBaseUrl(),reason:i.message||"network error"}),`${j} base auto`,"network_error")):"invalid_api_key"===i.error?(E("authentication"),p=y(s.t("setup.invalid_key",{label:e,reason:i.message||"invalid"}),n,"invalid_api_key")):(E("operation"),p=g(s.t("setup.invalid_key",{label:e,reason:i.message||i.error||"unknown"}),n,i.error)),h())throw p;return S(p.message),console.log(o.gray(s.t("errors.next_step",{command:p.hint}))),!1}async function O(t,i,r={}){const{oneMillion:p,officialLogin:c,desktopRegistry:u,force:y}=r,k=n[t];try{"claude-desktop"===t&&void 0!==u&&l.setToolSetting("claude-desktop",m,u),"codex"===t&&void 0!==p&&l.setToolSetting("codex",d,p),"claude-desktop"===t&&void 0!==c&&l.setToolSetting("claude-desktop",f,!c),await a.applyPrivateConfig(t,i,l.getModelsForTool(t),{force:y})}catch(o){if(h())throw g(o instanceof Error?o.message:String(o),`${j} setup --key ${"zh_CN"===s.getLocale()?"<你的 Key>":"<your key>"}`,"config_write_failed");const e=(o instanceof Error?o.message:String(o)).replace(/\s+/g," ").trim();return S("× "+s.t("setup.apply_failed",{tool:k.displayName,reason:e})),!1}return a.printApplied(t),y&&console.log(o.gray(" "+s.t("config.force_done",{tool:k.displayName}))),"codex"===t&&void 0!==p&&console.log(o.gray(" "+s.t(p?"setup.codex_1m_enabled":"setup.codex_1m_disabled"))),e(t)?.isInstalled&&!a.isToolInstalled(t)&&console.log(o.yellow(" ! "+s.t("setup.gui_preconfigured",{tool:k.displayName,install:k.installCommand}))),!0}export async function setupCommand(r){N=null;const p=r.key?.trim(),m=DEDICATED_KEYS.map(o=>({...o,apiKey:r[o.option]?.trim()})).filter(o=>Boolean(o.apiKey)),f=void 0!==r.oneMillion,g=void 0!==r.claudeOfficial;let y;if(g&&(y=parseOnOff(r.claudeOfficial),void 0===y))return S(s.t("setup.claude_official_invalid",{value:String(r.claudeOfficial)})),void(process.exitCode=1);const k=void 0!==r.desktopRegistry;let E;if(k&&(E=parseOnOff(r.desktopRegistry),void 0===E))return S(s.t("setup.desktop_registry_invalid",{value:String(r.desktopRegistry)})),void(process.exitCode=1);const I=g||k,L=Boolean(p||m.length>0),D={oneMillion:r.oneMillion,officialLogin:y,desktopRegistry:E,force:r.force};if(!L&&(f||I)){if(f){const o=l.getApiKeyForTool("codex");if(o)try{const e=!0===r.oneMillion;l.setToolSetting("codex",d,e);const t=await u(o);c(e,t??void 0),G(s.t(e?"setup.codex_1m_enabled":"setup.codex_1m_disabled"))}catch(o){S(s.t("setup.apply_failed",{tool:n.codex.displayName,reason:o instanceof Error?o.message:String(o)})),process.exitCode=1}else S(s.t("setup.codex_1m_missing_key")),process.exitCode=1}if(I){const o=l.getApiKeyForTool("claude-desktop");o?await O("claude-desktop",o,{...D,oneMillion:void 0})?await t(["claude-desktop"]):process.exitCode=1:(S(s.t("setup.desktop_official_login_missing_key")),process.exitCode=1)}return}if(!L)return S(s.t("setup.usage")),void(process.exitCode=1);await i(p||m[0].apiKey);let R=0,B=0;const F=new Set,Y=m.map(o=>({tool:o.tool,label:`--${o.option}`,apiKey:o.apiKey,need:o.need}));for(const o of Y){if(!await A(o.label,o.apiKey)){B+=1;continue}const e=await T(o.apiKey);!e.probed||$(e,o.need)?(e.probed||M(s.t("setup.probe_failed",{label:o.label})),l.setToolApiKey(o.tool,o.apiKey),await O(o.tool,o.apiKey,D)?(R+=1,F.add(o.tool)):B+=1):(S(s.t(`setup.key_no_${o.need}`,{label:o.label,tool:n[o.tool].displayName})),B+=1)}if(p){if(!await A("--key",p))return void(process.exitCode=_[N??"operation"]);l.setApiKey(p);const o=await T(p);if(o.probed||M(s.t("setup.probe_failed",{label:"--key"})),o.probed&&!o.hasClaude&&!o.hasGpt&&!o.hasGrok&&!o.hasGemini)return S(s.t("setup.key_no_family")),void(process.exitCode=1);const e=[{tool:"claude-code",capable:o.hasClaude,skipMsg:s.t("setup.skip_no_claude")},{tool:"codex",capable:o.hasGpt,skipMsg:s.t("setup.skip_no_gpt")},{tool:"grok",capable:o.hasGrok,skipMsg:s.t("setup.skip_no_grok")},{tool:"claude-desktop",capable:o.hasClaude&&("darwin"===process.platform||"win32"===process.platform),skipMsg:"",quiet:!0},{tool:"agy",capable:o.hasGemini,skipMsg:s.t("setup.skip_no_gemini")}];for(const o of e)F.has(o.tool)||(o.capable?await O(o.tool,p,D)?(R+=1,F.add(o.tool)):B+=1:o.quiet||M(o.skipMsg))}if(R>0){const t=await async function(t,i,r){const p=t.filter(o=>!e(o)?.isInstalled&&!a.isToolInstalled(o));if(0===p.length)return[];const d=p.map(o=>n[o].displayName).join(s.t("setup.list_separator"));let c=i;if(void 0!==c||h()||(w()?c=!b():process.stdin.isTTY&&(console.log(""),c=(await v.prompt([{type:"confirm",name:"go",message:s.t("setup.install_confirm",{tools:d}),default:!0}])).go)),!c){console.log("");for(const e of p)console.log(o.yellow("! "+s.t("setup.install_hint",{tool:n[e].displayName,install:n[e].installCommand})));return h()||console.log(o.gray(s.t("setup.install_all_hint",{cli:j}))),p}const u=[];for(const e of p){console.log(o.bold(`\n${n[e].displayName}`));try{await a.installTool(e)}catch(o){x.logError(`setup: install ${e}`,o)}C(),a.isToolInstalled(e)||u.push(e)}const m=p.filter(o=>!u.includes(o));m.length>0&&console.log("");for(const o of m){const e=l.getApiKeyForTool(o);e&&await O(o,e,{...r,oneMillion:void 0,force:void 0})}return u}([...F],r.install,D),i=[...F].filter(o=>!e(o)?.isInstalled&&!t.includes(o)),p=i.map(o=>n[o]?.command).filter(Boolean).join(" / "),d=s.t("setup.done",{count:String(R)});G("\n"+(p?`${d}${s.t("setup.done_commands",{commands:p})}`:d)),t.length>0&&M(s.t("setup.still_missing",{tools:t.map(o=>n[o].displayName).join(s.t("setup.list_separator"))}));const c=i.filter(o=>!a.isOnPath(o));if(c.length>0&&!h()&&"1"!==K("PATH_HINT_BY_CALLER")){const e=c.map(o=>n[o].command).join(" / ");console.log(o.yellow(" ! "+s.t("win32"===process.platform?"setup.path_reload_windows":"setup.path_reload",{commands:e})))}}B>0&&(S(s.t("setup.failed_summary",{count:String(B)})),h()||console.error(`${j} setup --key ${"zh_CN"===s.getLocale()?"<你的 Key>":"<your key>"}`)),await t([...F]),(B>0||0===R)&&(process.exitCode=_[N??"operation"])}
|
package/dist/locales/en_US.json
CHANGED
|
@@ -352,7 +352,6 @@
|
|
|
352
352
|
"apply_failed": "Failed to write {{tool}} config: {{reason}}",
|
|
353
353
|
"install_hint": "{{tool}} not found; install it with {{install}}",
|
|
354
354
|
"done": "Done: {{count}} tool(s) configured. ",
|
|
355
|
-
"skip_desktop_not_installed": "Claude Desktop is not installed; skipped (after installing, run {{cli}} setup --desktopkey sk-xxx or use the wizard)",
|
|
356
355
|
"desktop_official_login_missing_key": "No saved Claude Desktop API key found; run {{cli}} setup --desktopkey <your key> (or --key) first",
|
|
357
356
|
"claude_official_invalid": "Invalid value for --claude-official: {{value}} (expected on or off)",
|
|
358
357
|
"done_commands": "Type {{commands}} in your terminal to start",
|
|
@@ -370,7 +369,8 @@
|
|
|
370
369
|
"still_missing": "{{tools}} still not installed; run the commands above to install",
|
|
371
370
|
"path_reload": "Run exec \"$SHELL\" -l in this window (or open a new terminal) to use {{commands}}",
|
|
372
371
|
"path_reload_windows": "Open a new terminal to use {{commands}}",
|
|
373
|
-
"list_separator": ", "
|
|
372
|
+
"list_separator": ", ",
|
|
373
|
+
"gui_preconfigured": "{{tool}} is not installed yet; its config is written already, so it works once you install and open it (download: {{install}})"
|
|
374
374
|
},
|
|
375
375
|
"tools": {
|
|
376
376
|
"version_outdated": "version {{current}} is too old (needs {{min}} or later); upgrade with {{upgrade}}",
|
|
@@ -579,7 +579,7 @@
|
|
|
579
579
|
},
|
|
580
580
|
"autodetect_title": "Models the --key can use → tools configured:",
|
|
581
581
|
"autodetect": {
|
|
582
|
-
"claude": "Claude Code
|
|
582
|
+
"claude": "Claude Code, Claude Desktop (macOS / Windows, written ahead even when not installed)",
|
|
583
583
|
"gpt": "Codex",
|
|
584
584
|
"grok": "Grok Build",
|
|
585
585
|
"gemini": "Antigravity CLI"
|
|
@@ -592,7 +592,7 @@
|
|
|
592
592
|
"install": "Configure, then install whatever is missing (China mirrors)"
|
|
593
593
|
},
|
|
594
594
|
"when": "First setup after you get a key, or to change the key or repair broken configs.",
|
|
595
|
-
"needs": "A {{brand}} API key (create one on the Tokens page of the console)\
|
|
595
|
+
"needs": "A {{brand}} API key (create one on the Tokens page of the console)\nTools can be installed later: missing command-line tools get their config first, then an offer to install them from China mirrors (--install installs without asking); Claude Desktop (macOS / Windows) gets its config even before it is installed",
|
|
596
596
|
"alt": {
|
|
597
597
|
"init": "Choose tools and models step by step",
|
|
598
598
|
"config": "Change one tool only",
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -352,7 +352,6 @@
|
|
|
352
352
|
"apply_failed": "{{tool}} 配置写入失败: {{reason}}",
|
|
353
353
|
"install_hint": "没检测到 {{tool}},运行 {{install}} 安装",
|
|
354
354
|
"done": "完成:已配置 {{count}} 个工具。",
|
|
355
|
-
"skip_desktop_not_installed": "未检测到已安装的 Claude Desktop,已跳过(装好后运行 {{cli}} setup --desktopkey sk-xxx 或在向导里配置)",
|
|
356
355
|
"desktop_official_login_missing_key": "未找到已保存的 Claude Desktop API Key;先运行 {{cli}} setup --desktopkey <你的 Key>(或 --key)",
|
|
357
356
|
"claude_official_invalid": "--claude-official 的值无效: {{value}}(只接受 on / off)",
|
|
358
357
|
"done_commands": "在终端输入 {{commands}} 开始使用",
|
|
@@ -370,7 +369,8 @@
|
|
|
370
369
|
"still_missing": "{{tools}} 还没装好,按上方的命令安装后就能用",
|
|
371
370
|
"path_reload": "在当前窗口运行 exec \"$SHELL\" -l(或新开一个终端)后就能用 {{commands}}",
|
|
372
371
|
"path_reload_windows": "新开一个终端后就能用 {{commands}}",
|
|
373
|
-
"list_separator": "、"
|
|
372
|
+
"list_separator": "、",
|
|
373
|
+
"gui_preconfigured": "{{tool}} 还没装,配置已先写好,装好后打开就能用(下载:{{install}})"
|
|
374
374
|
},
|
|
375
375
|
"tools": {
|
|
376
376
|
"version_outdated": "版本 {{current}} 过旧,需要 {{min}} 及以上,运行 {{upgrade}} 升级",
|
|
@@ -579,7 +579,7 @@
|
|
|
579
579
|
},
|
|
580
580
|
"autodetect_title": "--key 能用的模型 → 自动配置的工具:",
|
|
581
581
|
"autodetect": {
|
|
582
|
-
"claude": "Claude Code
|
|
582
|
+
"claude": "Claude Code、Claude Desktop(macOS / Windows,没装也先写好)",
|
|
583
583
|
"gpt": "Codex",
|
|
584
584
|
"grok": "Grok Build",
|
|
585
585
|
"gemini": "Antigravity CLI"
|
|
@@ -592,7 +592,7 @@
|
|
|
592
592
|
"install": "配好后把没装的工具一起装上(国内镜像)"
|
|
593
593
|
},
|
|
594
594
|
"when": "拿到 Key 后第一次配置,或者换 Key、修复被改坏的配置时。",
|
|
595
|
-
"needs": "一把 {{brand}} 的 API Key(在控制台的「令牌」页创建)\
|
|
595
|
+
"needs": "一把 {{brand}} 的 API Key(在控制台的「令牌」页创建)\n工具可以之后再装:没装的命令行工具会先写好配置,再问要不要从国内镜像装上(--install 直接装);Claude Desktop(macOS / Windows)没装也先写好,装好打开就能用",
|
|
596
596
|
"alt": {
|
|
597
597
|
"init": "想一步步选工具和模型",
|
|
598
598
|
"config": "只改一个工具",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeapi/api-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.102",
|
|
4
4
|
"description": "CLI tool for managing AI coding assistants (Claude Code, Codex, OpenClaw, Hermes, AtomCode, Grok Build) with one unified config",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|