@vibeapi/api-helper 0.0.91 → 0.0.93
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 +3 -3
- package/dist/cli.js +1 -1
- package/dist/commands/base.js +1 -1
- package/dist/commands/setup.d.ts +3 -0
- package/dist/commands/setup.js +1 -1
- package/dist/lib/cli-help.d.ts +2 -0
- package/dist/lib/cli-help.js +1 -1
- package/dist/lib/command-docs.js +1 -1
- package/dist/lib/command.d.ts +3 -0
- package/dist/lib/command.js +1 -1
- package/dist/lib/errors.d.ts +16 -0
- package/dist/lib/errors.js +1 -0
- package/dist/lib/program.js +1 -1
- package/dist/lib/tools/antigravity.js +1 -1
- package/dist/lib/tools/atomcode.js +1 -1
- package/dist/lib/tools/codex.js +1 -1
- package/dist/lib/tools/hermes.js +1 -1
- package/dist/lib/tools/openclaw.js +1 -1
- package/dist/lib/wizard.js +1 -1
- package/dist/locales/en_US.json +29 -5
- package/dist/locales/zh_CN.json +29 -5
- package/dist/models.json +1 -1
- package/models.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# VibeCLI(@vibeapi/api-helper)
|
|
2
2
|
|
|
3
|
-
> 一条命令,在 Claude Code / Claude Desktop / Codex /
|
|
3
|
+
> 一条命令,在 Claude Code / Claude Desktop / Codex / Grok Build / Antigravity CLI 之间统一配置 API Key 与模型。
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@vibeapi/api-helper)
|
|
6
6
|
[](https://nodejs.org)
|
|
@@ -52,7 +52,7 @@ vibecli setup --key sk-xxx
|
|
|
52
52
|
vibecli setup --claudekey sk-a --codexkey sk-b --grokkey sk-c --desktopkey sk-d
|
|
53
53
|
```
|
|
54
54
|
|
|
55
|
-
每个工具都能单独给 Key:`--claudekey`、`--codexkey`、`--grokkey`、`--desktopkey`、`--agykey
|
|
55
|
+
每个工具都能单独给 Key:`--claudekey`、`--codexkey`、`--grokkey`、`--desktopkey`、`--agykey`。
|
|
56
56
|
|
|
57
57
|
Codex 同时开启 1M 上下文时,末尾加最短参数 `--1m`;已经配置过的用户无需再次输入 Key。单独执行 `--1m` 只重新生成模型目录里的上下文设置,不改写 Codex 凭据:
|
|
58
58
|
|
|
@@ -88,7 +88,7 @@ vibecli config claude-code clear-model # 模型选择被钉住时,交还给
|
|
|
88
88
|
|
|
89
89
|
## 能做什么
|
|
90
90
|
|
|
91
|
-
- **多工具一键配置**:把当前 API Key / 模型注入 Claude Code、Claude Desktop(桌面端第三方推理模式,写应用本地配置库,无需管理员 / 描述文件)、Codex、
|
|
91
|
+
- **多工具一键配置**:把当前 API Key / 模型注入 Claude Code、Claude Desktop(桌面端第三方推理模式,写应用本地配置库,无需管理员 / 描述文件)、Codex、Grok Build、Antigravity CLI(OpenCode 暂时下架,`vibecli config opencode` 仍可用)。
|
|
92
92
|
- **按工具选模型**:使用默认 / 实时从 API 拉取 / 内置预设 / 手动输入;每个工具可用不同模型。
|
|
93
93
|
- Claude Code 用默认模型时不写 `ANTHROPIC_*_MODEL` 环境变量,顶层 `model` 由 `settings-template.json` 提供(当前为 `opus[1m]`);显式选择其它模型时会覆盖该模板值。Codex 默认 `gpt-6-astra`,Grok Build 默认 `grok-4.6`,其余工具默认 `gpt-5.5`。
|
|
94
94
|
- Codex(CLI 与桌面版)的模型菜单除自带的 GPT 模型外,还列出网关的 Claude、Gemini 与国产模型(只列 Key 能用的);Claude Code 的 `/model` 菜单也会在内置档位后列出 Key 能用的国产模型;每个模型按自己的上下文窗口设置,窗口用到 80% 时自动压缩。默认启用 1M 上下文,交互配置 Codex 时可取消(取消后窗口不超过 272K)。需要 Codex 0.122 及以上;Codex、Claude Code 版本过旧时,配置完成会提示升级命令。
|
package/dist/cli.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
Number(process.versions.node.split(".")[0])<20&&(console.error(`VibeCLI 需要 Node.js 20 或更高版本,当前是 v${process.versions.node}。\n请安装 Node.js LTS(国内镜像:https://registry.npmmirror.com/binary.html?path=node/ ,或用 nvm install --lts),装好后重开终端再运行。\nVibeCLI needs Node.js 20 or later (found v${process.versions.node}); install the LTS release and open a new terminal.`),process.exit(1));const{Command:e}=await import("./lib/command.js"),{
|
|
2
|
+
Number(process.versions.node.split(".")[0])<20&&(console.error(`VibeCLI 需要 Node.js 20 或更高版本,当前是 v${process.versions.node}。\n请安装 Node.js LTS(国内镜像:https://registry.npmmirror.com/binary.html?path=node/ ,或用 nvm install --lts),装好后重开终端再运行。\nVibeCLI needs Node.js 20 or later (found v${process.versions.node}); install the LTS release and open a new terminal.`),process.exit(1));const{Command:e}=await import("./lib/command.js"),{logger:r}=await import("./utils/logger.js"),{reportCliError:o}=await import("./lib/errors.js");try{await(new e).execute(process.argv.slice(2))}catch(e){r.logError("CLI",e),o(e)}export{};
|
package/dist/commands/base.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import{configManager as r,DEFAULT_BASE_URL as o}from"../lib/config.js";import{i18n as t}from"../lib/i18n.js";import{toolManager as s}from"../lib/tool-manager.js";import{listAdapters as a}from"../lib/tools/registry.js";import{postApplyPrompts as n}from"../lib/post-apply.js";import{emitJson as l,isJsonMode as i}from"../lib/runtime-options.js";import{logger as u}from"../utils/logger.js";import{
|
|
1
|
+
import e from"chalk";import{configManager as r,DEFAULT_BASE_URL as o}from"../lib/config.js";import{i18n as t}from"../lib/i18n.js";import{toolManager as s}from"../lib/tool-manager.js";import{listAdapters as a}from"../lib/tools/registry.js";import{postApplyPrompts as n}from"../lib/post-apply.js";import{emitJson as l,isJsonMode as i}from"../lib/runtime-options.js";import{logger as u}from"../utils/logger.js";import{reportCliError as c,usageError as p,authenticationError as d,networkError as f,operationError as b}from"../lib/errors.js";import{gatewayAddresses as m,normalizeBaseUrl as y,probeGatewayAddress as g}from"../lib/gateway-addresses.js";export async function baseCommand(s){const a=r.getBaseUrl(),n=addressesWithCurrent(),u=s?.trim().toLowerCase();if(!u)return void await async function(r,o){const s=savedApiKey(),a=await probeAll(r,{apiKey:s,samples:3});i()?l({ok:!0,current:o,addresses:r.map((e,r)=>({...e,...a[r],current:e.url===o}))}):(console.log(e.bold(t.t("base.current",{url:o}))),console.log(e.gray(t.t(s?"base.probe_with_key":"base.probe_without_key"))+"\n"),_(r,a,o),console.log("\n"+e.gray(t.t("base.usage_hint"))))}(n,a);if("auto"===u){const e=await probeAll(n,{apiKey:savedApiKey()}),r=e.find(e=>e.ok);if(!r){const r=e.every(e=>"key_rejected"===e.error);return h(r?"key_rejected":"no_reachable",t.t(r?"base.key_rejected_everywhere":"base.none_reachable")),void _(n,e,a)}return void await switchGatewayAddress(r.url)}let c;if("default"===u||"reset"===u)c=o;else if(/^\d+$/.test(u)){if(c=n[Number(u)-1]?.url??null,!c)return void h("bad_index",t.t("base.bad_index",{index:u,count:String(n.length)}))}else if(c=y(s),!c)return void h("bad_url",t.t("base.bad_url",{value:s}));const p=await g(c,{apiKey:savedApiKey()});p.ok?await switchGatewayAddress(c):h("unreachable",t.t("base.unreachable",{url:c,reason:reasonText(p)}))}export async function ensureReachableGatewayAddress(s=savedApiKey()){if(r.hasRuntimeBaseUrl())return null;const a=r.getBaseUrl(),n=await g(a,{apiKey:s});if(n.ok||"key_rejected"===n.error)return null;const l=m().filter(e=>e.url!==a),u=(await probeAll(l,{apiKey:s})).find(e=>e.ok);return u?(u.url===o?r.resetBaseUrl():r.setBaseUrl(u.url,!0),i()||console.log(e.yellow(t.t("base.setup_fallback",{from:a,reason:reasonText(n),url:u.url}))),u.url):null}export function addressesWithCurrent(){const e=r.getBaseUrl(),o=m();return o.some(r=>r.url===e)||o.push({url:e,label:t.t("base.custom_label")}),o}export function savedApiKey(){return r.getApiKey()||a().map(e=>r.getApiKeyForTool(e.name)).find(Boolean)}export async function probeAll(e,r={}){return Promise.all(e.map(e=>g(e.url,r)))}export function probeSummary(r,o){if(!r.ok)return e.red(`× ${reasonText(r)}`);const s=[`${r.ms} ms`];return void 0!==r.models&&s.push(t.t("base.models_count",{count:String(r.models)})),o&&s.push(t.t("base.fastest")),e.green(`√ ${s.join(" · ")}`)}export function fastestIndex(e){let r=-1;return e.forEach((o,t)=>{o.ok&&(r<0||o.ms<e[r].ms)&&(r=t)}),r}export function reasonText(e){if(!e.error)return"";const r=t.t(`base.error_${e.error}`);return e.detail?`${r}(${e.detail})`:r}function h(e,r){const o="bad_index"===e||"bad_url"===e?p(r,"下一步:运行 vibecli base --help",e):"key_rejected"===e?d(r,"下一步:运行 vibecli setup --key <你的 Key>",e):f(r,"下一步:运行 vibecli base auto 查看可用接入地址",e);c(o)}function _(r,o,s){if(i())return;const a=o.length>1?fastestIndex(o):-1;r.forEach((r,n)=>{const l=r.url===s?e.cyan(` ← ${t.t("base.current_mark")}`):"";console.log(`${n+1}. ${r.url} ${e.gray(r.label)}\n ${probeSummary(o[n],n===a)}${l}`)})}export async function switchGatewayAddress(p){const d=r.getBaseUrl();p===o?r.resetBaseUrl():r.setBaseUrl(p,!0);const f=[],m=[];for(const e of function(){const e=[];for(const o of a()){const t=r.getApiKeyForTool(o.name);if(t)try{o.detectCurrentConfig().apiKey===t&&e.push(o.name)}catch(e){u.logError(`base.detectCurrentConfig(${o.name})`,e)}}return e}()){const o=r.getApiKeyForTool(e);try{await s.applyPrivateConfig(e,o,r.getModelsForTool(e)),f.push(e)}catch(r){m.push({tool:e,reason:r instanceof Error?r.message:String(r)})}}if(m.length>0&&c(b(m.map(({tool:e,reason:r})=>`${e}: ${r}`).join("; "),"下一步:运行 vibecli setup --key <你的 Key>","config_write_failed")),i()&&0===m.length)l({ok:0===m.length,previous:d,base_url:p,applied:f,failed:m});else{console.log(e.green(t.t(p===d?"base.kept":"base.switched",{url:p}))),f.length>0&&console.log(t.t("base.tools_moved"));for(const e of f)s.printApplied(e);for(const{tool:r,reason:o}of m)console.error(e.red(`× ${t.t("setup.apply_failed",{tool:r,reason:o})}`));0===f.length&&0===m.length&&console.log(e.yellow(t.t("base.no_tools",{url:p}))),await n(f)}}
|
package/dist/commands/setup.d.ts
CHANGED
|
@@ -57,14 +57,17 @@ export declare const DEDICATED_KEYS: readonly [{
|
|
|
57
57
|
readonly option: "openclawkey";
|
|
58
58
|
readonly tool: "openclaw";
|
|
59
59
|
readonly need: "any";
|
|
60
|
+
readonly hidden: true;
|
|
60
61
|
}, {
|
|
61
62
|
readonly option: "hermeskey";
|
|
62
63
|
readonly tool: "hermes";
|
|
63
64
|
readonly need: "any";
|
|
65
|
+
readonly hidden: true;
|
|
64
66
|
}, {
|
|
65
67
|
readonly option: "atomcodekey";
|
|
66
68
|
readonly tool: "atomcode";
|
|
67
69
|
readonly need: "any";
|
|
70
|
+
readonly hidden: true;
|
|
68
71
|
}];
|
|
69
72
|
export type DedicatedKeyOption = (typeof DEDICATED_KEYS)[number]['option'];
|
|
70
73
|
export interface SetupCommandOptions extends Partial<Record<DedicatedKeyOption, string>> {
|
package/dist/commands/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import{getAdapter as o}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 a}from"../lib/config.js";import{toolManager as
|
|
1
|
+
import e from"chalk";import{getAdapter as o}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 a}from"../lib/config.js";import{toolManager as n,SUPPORTED_TOOLS as l}from"../lib/tool-manager.js";import{validateApiKey as r,fetchModels as d}from"../lib/api-validator.js";import{CODEX_ONE_MILLION_CONTEXT_SETTING as p,setCodexOneMillionContext as c}from"../lib/tools/codex.js";import{resolveModelCatalog as u}from"../lib/model-catalog.js";import{CLAUDE_DESKTOP_FORCE_REGISTRY_SETTING as f,CLAUDE_DESKTOP_HIDE_OFFICIAL_LOGIN_SETTING as m}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 b}from"../lib/runtime-options.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 h(e){const o=await d(e);if(!o.ok)return{hasClaude:!0,hasGpt:!0,hasGrok:!0,hasGemini:!0,probed:!1};const t=o.models.map(e=>e.toLowerCase());return{hasClaude:t.some(e=>e.includes("claude")),hasGpt:t.some(e=>e.startsWith("gpt")||e.includes("gpt-")||/^o\d/.test(e)),hasGrok:t.some(e=>e.includes("grok")),hasGemini:t.some(e=>e.startsWith("gemini")),probed:!0}}function v(e,o){switch(o){case"claude":return e.hasClaude;case"gpt":return e.hasGpt;case"grok":return e.hasGrok;case"gemini":return e.hasGemini;default:return!0}}export function parseOnOff(e){const o=(e??"").trim().toLowerCase();return!!["on","true","show","1","yes","y"].includes(o)||!["off","false","hide","0","no","n"].includes(o)&&void 0}function w(o){console.log(e.green(o))}function x(o){console.log(e.yellow(o))}function C(o){console.error(e.red(o))}let K=null;function G(e){const o={operation:1,authentication:2,network:3};(!K||o[e]>o[K])&&(K=e)}async function S(o,t){b()||console.log(e.gray(s.t("setup.validating",{label:o})));const i=await r(t);if(i.valid)return!0;const n="zh_CN"===s.getLocale()?"<你的 Key>":"<your key>",l="--key"===o?`vibecli setup --key ${n}`:`vibecli setup ${o} ${n}`;let d;if("network_error"===i.error?(G("network"),d=k(s.t("setup.unreachable",{url:a.getBaseUrl(),reason:i.message||"network error"}),"vibecli base auto","network_error")):"invalid_api_key"===i.error?(G("authentication"),d=y(s.t("setup.invalid_key",{label:o,reason:i.message||"invalid"}),l,"invalid_api_key")):(G("operation"),d=g(s.t("setup.invalid_key",{label:o,reason:i.message||i.error||"unknown"}),l,i.error)),b())throw d;return C(d.message),console.log(e.gray(s.t("errors.next_step",{command:d.hint}))),!1}async function j(o,t,i={}){const{oneMillion:r,officialLogin:d,desktopRegistry:c,force:u}=i,y=l[o];try{"claude-desktop"===o&&void 0!==c&&a.setToolSetting("claude-desktop",f,c),"codex"===o&&void 0!==r&&a.setToolSetting("codex",p,r),"claude-desktop"===o&&void 0!==d&&a.setToolSetting("claude-desktop",m,!d),await n.applyPrivateConfig(o,t,a.getModelsForTool(o),{force:u})}catch(e){if(b())throw g(e instanceof Error?e.message:String(e),"vibecli setup --key "+("zh_CN"===s.getLocale()?"<你的 Key>":"<your key>"),"config_write_failed");const o=(e instanceof Error?e.message:String(e)).replace(/\s+/g," ").trim();return C("× "+s.t("setup.apply_failed",{tool:y.displayName,reason:o})),!1}return n.printApplied(o),u&&console.log(e.gray(" "+s.t("config.force_done",{tool:y.displayName}))),"codex"===o&&void 0!==r&&console.log(e.gray(" "+s.t(r?"setup.codex_1m_enabled":"setup.codex_1m_disabled"))),n.isToolInstalled(o)||console.log(e.yellow(" ! "+s.t("setup.install_hint",{tool:y.displayName,install:y.installCommand}))),!0}export async function setupCommand(e){K=null;const r=e.key?.trim(),d=DEDICATED_KEYS.map(o=>({...o,apiKey:e[o.option]?.trim()})).filter(e=>Boolean(e.apiKey)),f=void 0!==e.oneMillion,m=void 0!==e.claudeOfficial;let g;if(m&&(g=parseOnOff(e.claudeOfficial),void 0===g))return C(s.t("setup.claude_official_invalid",{value:String(e.claudeOfficial)})),void(process.exitCode=1);const y=void 0!==e.desktopRegistry;let k;if(y&&(k=parseOnOff(e.desktopRegistry),void 0===k))return C(s.t("setup.desktop_registry_invalid",{value:String(e.desktopRegistry)})),void(process.exitCode=1);const G=m||y,M=Boolean(r||d.length>0),T={oneMillion:e.oneMillion,officialLogin:g,desktopRegistry:k,force:e.force};if(!M&&(f||G)){if(f){const o=a.getApiKeyForTool("codex");if(o)try{const t=!0===e.oneMillion;a.setToolSetting("codex",p,t);const i=await u(o);c(t,i??void 0),w(s.t(t?"setup.codex_1m_enabled":"setup.codex_1m_disabled"))}catch(e){C(s.t("setup.apply_failed",{tool:l.codex.displayName,reason:e instanceof Error?e.message:String(e)})),process.exitCode=1}else C(s.t("setup.codex_1m_missing_key")),process.exitCode=1}if(G){const e=a.getApiKeyForTool("claude-desktop");e?await j("claude-desktop",e,{...T,oneMillion:void 0})?await t(["claude-desktop"]):process.exitCode=1:(C(s.t("setup.desktop_official_login_missing_key")),process.exitCode=1)}return}if(!M)return C(s.t("setup.usage")),void(process.exitCode=1);await i(r||d[0].apiKey);let E=0,O=0;const N=new Set,A=d.map(e=>({tool:e.tool,label:`--${e.option}`,apiKey:e.apiKey,need:e.need}));for(const e of A){if(!await S(e.label,e.apiKey)){O+=1;continue}const o=await h(e.apiKey);!o.probed||v(o,e.need)?(o.probed||x(s.t("setup.probe_failed",{label:e.label})),a.setToolApiKey(e.tool,e.apiKey),await j(e.tool,e.apiKey,T)?(E+=1,N.add(e.tool)):O+=1):(C(s.t(`setup.key_no_${e.need}`,{label:e.label,tool:l[e.tool].displayName})),O+=1)}if(r){if(!await S("--key",r))return void(process.exitCode=_[K??"operation"]);a.setApiKey(r);const e=await h(r);if(e.probed||x(s.t("setup.probe_failed",{label:"--key"})),e.probed&&!e.hasClaude&&!e.hasGpt&&!e.hasGrok&&!e.hasGemini)return C(s.t("setup.key_no_family")),void(process.exitCode=1);const o=[{tool:"claude-code",capable:e.hasClaude,skipMsg:s.t("setup.skip_no_claude")},{tool:"codex",capable:e.hasGpt,skipMsg:s.t("setup.skip_no_gpt")},{tool:"grok",capable:e.hasGrok,skipMsg:s.t("setup.skip_no_grok")},{tool:"claude-desktop",capable:e.hasClaude&&n.isToolInstalled("claude-desktop"),skipMsg:s.t("setup.skip_desktop_not_installed"),quiet:!e.hasClaude},{tool:"agy",capable:e.hasGemini,skipMsg:s.t("setup.skip_no_gemini")}];for(const e of o)N.has(e.tool)||(e.capable?await j(e.tool,r,T)?(E+=1,N.add(e.tool)):O+=1:e.quiet||x(e.skipMsg))}if(E>0){const e=[...N].filter(e=>!o(e)?.isInstalled).map(e=>l[e]?.command).filter(Boolean).join(" / "),t=s.t("setup.done",{count:String(E)});w("\n"+(e?`${t}${s.t("setup.done_commands",{commands:e})}`:t))}O>0&&(C(s.t("setup.failed_summary",{count:String(O)})),b()||console.error("vibecli setup --key "+("zh_CN"===s.getLocale()?"<你的 Key>":"<your key>"))),await t([...N]),(O>0||0===E)&&(process.exitCode=_[K??"operation"])}
|
package/dist/lib/cli-help.d.ts
CHANGED
|
@@ -55,3 +55,5 @@ export declare function helpConfiguration(): HelpConfiguration;
|
|
|
55
55
|
export declare function firstCommandWord(args: readonly string[]): string | undefined;
|
|
56
56
|
/** `-h` / `--help` anywhere, or `vibecli help ...`: only print help, change nothing. */
|
|
57
57
|
export declare function isHelpRequest(args: readonly string[]): boolean;
|
|
58
|
+
/** Render one of the stable, topic-oriented help pages. */
|
|
59
|
+
export declare function renderHelpTopic(topic: string): string | null;
|
package/dist/lib/cli-help.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i18n as e}from"./i18n.js";import{stringWidth as t}from"../utils/string-width.js";export const DOCS_URL="https://docs.vibeapi.cn/zh/docs/coding-tools/commands";const n=new WeakMap;export function attachCommandHelp(e,t){return n.set(e,{when:"",prerequisites:[],alternatives:[],sections:[],examples:[],...t}),e.addHelpText("after",()=>renderHelpExtras(e)),e}export function getCommandHelp(e){return n.get(e)??{when:"",prerequisites:[],alternatives:[],sections:[],examples:[]}}export function commandPath(e){const t=[];for(let n=e;n;n=n.parent)t.unshift(n.name());return t.join(" ")}function
|
|
1
|
+
import{i18n as e}from"./i18n.js";import{stringWidth as t}from"../utils/string-width.js";export const DOCS_URL="https://docs.vibeapi.cn/zh/docs/coding-tools/commands";const n=new WeakMap;export function attachCommandHelp(e,t){return n.set(e,{when:"",prerequisites:[],alternatives:[],sections:[],examples:[],...t}),e.addHelpText("after",()=>renderHelpExtras(e)),e}export function getCommandHelp(e){return n.get(e)??{when:"",prerequisites:[],alternatives:[],sections:[],examples:[]}}export function commandPath(e){const t=[];for(let n=e;n;n=n.parent)t.unshift(n.name());return t.join(" ")}function o(e){let t=e;for(;t.parent;)t=t.parent;return t}export function visibleSubcommands(e){return e.commands.filter(e=>!e._hidden)}const r=34;function i(e){const n=e.filter(([,e])=>e),o=Math.min(r,Math.max(0,...n.map(([e])=>t(e)))),i=[];for(const[n,r]of e){const e=t(n);r?e>o?i.push(` ${n}`,` ${" ".repeat(o)} ${r}`):i.push(` ${n}${" ".repeat(o-e)} ${r}`):i.push(` ${n}`)}return i}export function learnMoreRows(t){const n=[];if(visibleSubcommands(t).length>0){const o=t.parent?e.t("help.placeholder.subcommand"):e.t("help.placeholder.command");n.push([`${commandPath(t)} ${o} --help`,e.t("help.learn_more.command_help")])}return t.parent&&n.push([`${commandPath(o(t))} --help`,e.t("help.learn_more.all_commands")]),n.push(["vibecli help exit-codes",e.t("help.learn_more.exit_codes")]),n.push(["vibecli help environment",e.t("help.learn_more.environment")]),n.push([e.t("help.learn_more.docs",{url:DOCS_URL}),""]),n}export function renderHelpExtras(t){const n=getCommandHelp(t),o=[];for(const e of n.sections)o.push("",e.title,...i(e.rows));return n.when&&o.push("",e.t("help.title.when"),...n.when.split("\n").map(e=>` ${e}`)),n.prerequisites.length>0&&o.push("",e.t("help.title.prerequisites"),...n.prerequisites.map(e=>` - ${e}`)),n.alternatives.length>0&&o.push("",e.t("help.title.alternatives"),...i(n.alternatives.map(e=>[e.command,e.note]))),n.examples.length>0&&o.push("",e.t("help.title.examples"),...i(n.examples.map(e=>[e.command,e.note]))),o.push("",e.t("help.title.learn_more"),...i(learnMoreRows(t))),o.join("\n")}const s={"Usage:":"help.title.usage","Arguments:":"help.title.arguments","Options:":"help.title.options","Global Options:":"help.title.global_options","Commands:":"help.title.commands"};export function localizeTitle(t){const n=s[t];return n?e.t(n):t}function l(t,n,o){if(void 0===n)return t;const r=o??("string"==typeof n?n:JSON.stringify(n)),i=e.t("help.default_value",{value:r});return t?`${t}(${i})`:i}export function describeOption(e){return e.required||e.optional?l(e.description,e.defaultValue,e.defaultValueDescription):e.description}export function describeArgument(e){return l(e.description,e.defaultValue,e.defaultValueDescription)}export function helpConfiguration(){return{showGlobalOptions:!0,styleTitle:e=>localizeTitle(e),optionDescription:e=>describeOption(e),argumentDescription:e=>describeArgument(e)}}export function firstCommandWord(e){for(let t=0;t<e.length;t+=1){const n=e[t];if("--"===n)return;if("--base"!==n){if(!n.startsWith("-"))return n}else t+=1}}export function isHelpRequest(e){for(const t of e){if("--"===t)break;if("-h"===t||"--help"===t)return!0}return"help"===firstCommandWord(e)}export function renderHelpTopic(t){const n="exit-codes"===t?"exit_codes":"environment"===t?"environment":null;return n?`${e.t(`help_topics.${n}.title`)}\n\n${e.t(`help_topics.${n}.body`)}\n`:null}
|
package/dist/lib/command-docs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i18n as t}from"./i18n.js";import{buildProgram as e}from"./program.js";import{commandPath as n,describeArgument as o,describeOption as s,getCommandHelp as p,visibleSubcommands as r,DOCS_URL as i}from"./cli-help.js";export const DOC_LOCALES=["zh_CN","en_US"];export function commandDocsPath(t){return`docs/commands.${t}.md`}function a(e,n){return t.t(`help.doc.${e}`,n)}function l(t){return t.replace(/[::]\s*$/,"")}function c(t){return"`"+t.replace(/\|/g,"\\|")+"`"}function
|
|
1
|
+
import{i18n as t}from"./i18n.js";import{buildProgram as e}from"./program.js";import{commandPath as n,describeArgument as o,describeOption as s,getCommandHelp as p,visibleSubcommands as r,DOCS_URL as i}from"./cli-help.js";export const DOC_LOCALES=["zh_CN","en_US"];export function commandDocsPath(t){return`docs/commands.${t}.md`}function a(e,n){return t.t(`help.doc.${e}`,n)}function l(t){return t.replace(/[::]\s*$/,"")}function c(t){return"`"+t.replace(/\|/g,"\\|")+"`"}function m(t){return n(t).replace(/\s+/g,"-").toLowerCase()}function u(t){return`[${c(n(t))}](#${m(t)})`}function h(t,e){return[`| ${t[0]} | ${t[1]} |`,"| --- | --- |",...e.map(([t,e])=>{return`| ${t} | ${n=e,n.replace(/\|/g,"\\|").replace(/\n/g,"<br>")} |`;var n})]}function d(t){return t.createHelp().visibleOptions(t)}function f(t){return t.map(t=>[c(t.flags),s(t)])}function g(t){return t.split("\n").filter(Boolean).flatMap(t=>[t,""])}function $(t){return r(t).flatMap(t=>[t,...$(t)])}function x(e,s){const i=e.createHelp(),$=p(e),x=[`<a id="${m(e)}"></a>`,"",`## ${c(n(e))}`,""];x.push(...g(e.description())),x.push(`**${l(t.t("help.title.usage"))}**`,"","```text",i.commandUsage(e),"```","");const _=i.visibleArguments(e);_.length>0&&(x.push(`**${l(t.t("help.title.arguments"))}**`,""),x.push(...h([a("argument"),a("description")],_.map(t=>[c(i.argumentTerm(t)),o(t)])),"")),x.push(`**${l(t.t("help.title.options"))}**`,""),x.push(...h([a("option"),a("description")],f(d(e))),"");const b=s.options.map(t=>c(t.flags)).join(" ");x.push(a("global_inherited",{options:b,anchor:"global-options"}),"");const C=r(e);C.length>0&&(x.push(`**${l(t.t("help.title.commands"))}**`,""),x.push(...h([a("command"),a("description")],C.map(t=>[u(t),t.summary()||t.description()])),""));for(const t of $.sections)x.push(`**${l(t.title)}**`,""),x.push(...h([a("item"),a("description")],t.rows.map(([t,e])=>[c(t),e])),"");$.when&&x.push(`**${l(t.t("help.title.when"))}**`,"",...g($.when)),$.prerequisites.length>0&&x.push(`**${l(t.t("help.title.prerequisites"))}**`,"",...$.prerequisites.map(t=>`- ${t}`),""),$.alternatives.length>0&&(x.push(`**${l(t.t("help.title.alternatives"))}**`,""),x.push(...h([a("command"),a("use_instead")],$.alternatives.map(t=>[c(t.command),t.note])),"")),$.examples.length>0&&(x.push(`**${l(t.t("help.title.examples"))}**`,""),x.push(...h([a("command"),a("description")],$.examples.map(t=>[c(t.command),t.note])),""));const j=[c(`${n(e)} --help`)];return e.parent&&e.parent!==s&&j.push(u(e.parent)),j.push(`[${a("back_to_index")}](#commands)`),x.push(`**${a("see_also")}**: ${j.join(" · ")}`,""),x}function _(e){const n=[`\x3c!-- ${a("generated_note")} --\x3e`,"",`# ${a("title")}`,"",...g(e.description()),a("docs_link",{url:i}),"",'<a id="global-options"></a>',"",`## ${l(t.t("help.group.global_options"))}`,"",a("global_note"),"",...h([a("option"),a("description")],f(d(e))),"",'<a id="commands"></a>',"",`## ${l(t.t("help.title.commands"))}`,""],o=new Map;for(const n of r(e)){const e=n.helpGroup()||t.t("help.title.commands");o.set(e,[...o.get(e)??[],n])}for(const[t,e]of o)n.push(`### ${l(t)}`,""),n.push(...h([a("command"),a("description")],e.map(t=>[u(t),t.summary()||t.description()])),"");const s=p(e).examples;s.length>0&&(n.push(`## ${l(t.t("help.title.examples"))}`,""),n.push(...h([a("command"),a("description")],s.map(t=>[c(t.command),t.note])),""));for(const t of $(e))n.push(...x(t,e));return n.join("\n").replace(/\n{3,}/g,"\n\n").trimEnd()+"\n"}export function generateCommandDocs(n){const o=t.getLocale();t.loadFromConfig(n);try{return _(e())}finally{t.loadFromConfig(o)}}
|
package/dist/lib/command.d.ts
CHANGED
package/dist/lib/command.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{i18n as
|
|
1
|
+
import{i18n as n,detectSystemLang as r}from"./i18n.js";import{configManager as o}from"./config.js";import{runModelRefresh as e}from"./model-refresh.js";import{normalizeBaseUrl as t}from"./gateway-addresses.js";import s from"chalk";import{setRuntimeOptions as i,detectColorPreferenceFromEnv as m,isColorEnabled as a,isJsonMode as c}from"./runtime-options.js";import{cleanupAnthropicEnvVars as l,machineEnvVarsLeft as g}from"./env-cleanup.js";import{runStartupUpdate as u}from"./auto-update.js";import{buildProgram as d}from"./program.js";import{firstCommandWord as p,isHelpRequest as f,renderHelpTopic as h}from"./cli-help.js";import{reportCliError as v,usageError as w,VibeCliError as _}from"./errors.js";export{buildProgram}from"./program.js";const j=new Set(["setup","init","auth","enter","config"]);export class Command{program;configuring=!1;constructor(){const e=o.isLangChosen()?o.getLang():r();n.loadFromConfig(e),this.program=d()}cleanupLeakedEnvVars(){const r=l();if(0===r.length||c())return;const o=n.t("messages.env_vars_cleared",{vars:r.join(", ")});console.log(a()?s.yellow(o):o);const e=g();if(e.length>0){const r=n.t("messages.env_vars_machine_left",{vars:e.join(", ")});console.log(a()?s.yellow(r):r)}}preflightArgs(n){const r=r=>n.includes(r),e=!r("--no-color")&&m();if(i({nonInteractive:r("--non-interactive"),json:r("--json"),yes:r("--yes")||r("-y"),dryRun:r("--dry-run"),color:e}),e||(s.level=0),this.configuring=!1,f(n))return;let a;for(let r=0;r<n.length;r+=1){const o=n[r];"--base"===o&&n[r+1]?(a=n[r+1],r+=1):o.startsWith("--base=")&&(a=o.slice(7))}const c=p(n),l=void 0===c&&!["--version","-v"].some(r);this.configuring=l||void 0!==c&&j.has(c),a&&o.setBaseUrl(t(a)??a,this.configuring)}async execute(n){try{if(this.preflightArgs(n),"help"===n[0]&&n[1]){const r=h(n[1]);if(r)return void process.stdout.write(r)}if(this.rejectUnknownCommand(n),!f(n)){if(this.configuring&&this.cleanupLeakedEnvVars(),(await u(n)).handled)return;await e(n)}await this.program.parseAsync(n,{from:"user"})}catch(r){if("commander.helpDisplayed"===r?.code||"commander.version"===r?.code)return;v(this.normalizeCommanderError(r,n))}}rejectUnknownCommand(r){const o=p(r);if(!o||"help"===o)return;if(this.program.commands.some(n=>n.name()===o))return;const e=this.suggestCommand(o),t=e?n.t("cli.unknown_hint_suggestion",{command:e}):n.t("cli.unknown_hint");throw w(n.t("cli.error_unknown",{command:o}),t,"unknown_command")}suggestCommand(n){const r=(n,r)=>{const o=Array.from({length:r.length+1},(n,r)=>r);for(let e=1;e<=n.length;e+=1){let t=o[0];o[0]=e;for(let s=1;s<=r.length;s+=1){const i=o[s];o[s]=Math.min(o[s]+1,o[s-1]+1,t+(n[e-1]===r[s-1]?0:1)),t=i}}return o[r.length]};return this.program.commands.map(n=>n.name()).map(o=>({name:o,score:r(n,o)})).filter(({score:r})=>r<=Math.max(2,Math.floor(n.length/2))).sort((n,r)=>n.score-r.score)[0]?.name}normalizeCommanderError(r,o){if(r instanceof _)return r;const e=r?.code,t=r instanceof Error?r.message:String(r);if("commander.unknownOption"===e||"commander.missingArgument"===e||"commander.missingMandatoryOption"===e||"commander.invalidArgument"===e){const r=p(o)??"vibecli",s=/'([^']+)'/.exec(t)?.[1]??"",i="commander.unknownOption"===e?"cli.err_unknown_option":"commander.missingArgument"===e?"cli.err_missing_argument":"commander.missingMandatoryOption"===e?"cli.err_missing_option":null,m=i&&s?n.t(i,{name:s}):t.replace(/^error:\s*/,"");return w(m,n.t("cli.unknown_option_hint",{command:r}),e)}return r}getProgram(){return this.program}}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export type VibeCliErrorType = 'operation' | 'usage' | 'authentication' | 'network' | 'internal' | 'confirmation' | 'cancelled';
|
|
2
|
+
export declare const EXIT_CODES: Record<VibeCliErrorType, number>;
|
|
3
|
+
export declare class VibeCliError extends Error {
|
|
4
|
+
readonly type: VibeCliErrorType;
|
|
5
|
+
readonly hint: string;
|
|
6
|
+
readonly subtype?: string;
|
|
7
|
+
constructor(type: VibeCliErrorType, message: string, hint: string, subtype?: string);
|
|
8
|
+
}
|
|
9
|
+
export declare function exitCodeForError(error: unknown): number;
|
|
10
|
+
export declare function asVibeCliError(error: unknown): VibeCliError;
|
|
11
|
+
/** Print the one stable error envelope used by every CLI entry point. */
|
|
12
|
+
export declare function reportCliError(error: unknown): number;
|
|
13
|
+
export declare function usageError(message: string, hint: string, subtype?: string): VibeCliError;
|
|
14
|
+
export declare function operationError(message: string, hint: string, subtype?: string): VibeCliError;
|
|
15
|
+
export declare function authenticationError(message: string, hint: string, subtype?: string): VibeCliError;
|
|
16
|
+
export declare function networkError(message: string, hint: string, subtype?: string): VibeCliError;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import r from"chalk";import{i18n as e}from"./i18n.js";import{isColorEnabled as t,isJsonMode as o}from"./runtime-options.js";export const EXIT_CODES={operation:1,usage:2,authentication:3,network:4,internal:5,confirmation:10,cancelled:130};export class VibeCliError extends Error{type;hint;subtype;constructor(r,e,t,o){super(e),this.name="VibeCliError",this.type=r,this.hint=t,this.subtype=o}}export function exitCodeForError(r){return r instanceof VibeCliError?EXIT_CODES[r.type]:EXIT_CODES.internal}export function asVibeCliError(r){if(r instanceof VibeCliError)return r;if("ExitPromptError"===r?.name)return new VibeCliError("cancelled",e.t("errors.cancelled"),e.t("errors.cancel_hint"),"user_cancelled");const t=r instanceof Error?r.message:String(r);return new VibeCliError("internal",t,e.t("errors.hint_logs"),"unexpected_error")}export function reportCliError(e){const n=asVibeCliError(e),i={ok:!1,error:{type:n.type,message:n.message,hint:n.hint,...n.subtype?{subtype:n.subtype}:{}}};if(o())process.stderr.write(JSON.stringify(i)+"\n");else{const e=t()?r.red:r=>r;process.stderr.write(e(n.message)+"\n"+n.hint+"\n")}const s=exitCodeForError(n);return process.exitCode=s,s}export function usageError(r,e,t){return new VibeCliError("usage",r,e,t)}export function operationError(r,e,t){return new VibeCliError("operation",r,e,t)}export function authenticationError(r,e,t){return new VibeCliError("authentication",r,e,t)}export function networkError(r,e,t){return new VibeCliError("network",r,e,t)}
|
package/dist/lib/program.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Command as e}from"commander";import{readFileSync as o}from"fs";import{join as t,dirname as i}from"path";import{fileURLToPath as s}from"url";import{i18n as a}from"./i18n.js";import{wizard as n}from"./wizard.js";import{SUPPORTED_TOOLS as c}from"./tool-manager.js";import{DEFAULT_BASE_URL as l}from"./config.js";import{attachCommandHelp as r,helpConfiguration as p}from"./cli-help.js";import{langCommand as m,authCommand as u,doctorCommand as d,configCommand as b,statusCommand as g}from"../commands/index.js";import{logsCommand as f}from"../commands/logs.js";import{completionCommand as x}from"../commands/completion.js";import{benchCommand as v}from"../commands/bench.js";import{updateCommand as y}from"../commands/update.js";import{upgradeCommand as h}from"../commands/upgrade.js";import{codexSessionsCommand as k}from"../commands/codex-sessions.js";import{setupCommand as _,DEDICATED_KEYS as w}from"../commands/setup.js";import{baseCommand as j}from"../commands/base.js";function O(e,o){return a.t(`help.${e}`,o)}function G(e,o){return{command:e,note:O(o)}}function z(e){const o=O(e);return o===`help.${e}`?"":o}function $(e,o=[]){return{when:z(`${e}.when`),prerequisites:z(`${e}.needs`).split("\n").filter(Boolean),alternatives:o.map(([e,o])=>G(e,o))}}function C(e){return e.helpCommand("help [command]",O("help_command"))}export function buildProgram(){const a=new e;a.name("vibecli").summary(O("root.summary")).description(O("root.description")).configureHelp(p()).allowExcessArguments(!0).optionsGroup(O("group.global_options")).helpOption("-h, --help",O("global.help")).version(function(){try{const e=i(s(import.meta.url));return JSON.parse(o(t(e,"../../package.json"),"utf-8")).version}catch{return"1.0.0"}}(),"-v, --version",O("global.version")).option("--base <url>",O("global.base")).option("--non-interactive",O("global.non_interactive")).option("--json",O("global.json")).option("-y, --yes",O("global.yes")).option("--dry-run",O("global.dry_run")).option("--no-color",O("global.no_color")),a.commandsGroup(O("group.configure"));const z=a.command("setup").summary(O("setup.summary")).description(O("setup.description")).option("--key <key>",O("setup.opt.key"));for(const e of w)z.option(`--${e.option} <key>`,O(`setup.opt.${e.option}`));z.option("--1m",O("setup.opt.one_m")).option("--no-1m",O("setup.opt.no_one_m")).option("--claude-official <on|off>",O("setup.opt.claude_official")).option("--desktop-registry <on|off>",O("setup.opt.desktop_registry")).option("--force",O("setup.opt.force")).option("--all",O("setup.opt.all")).action(async e=>{await _({key:e.key,...Object.fromEntries(w.map(o=>[o.option,e[o.option]])),all:e.all,oneMillion:e["1m"],claudeOfficial:e.claudeOfficial,desktopRegistry:e.desktopRegistry,force:e.force})}),r(z,{...$("setup",[["vibecli init","setup.alt.init"],["vibecli config <tool>","setup.alt.config"],["vibecli auth <key>","setup.alt.auth"]]),sections:[{title:O("setup.autodetect_title"),rows:[["Claude",O("setup.autodetect.claude")],["GPT",O("setup.autodetect.gpt")],["Grok",O("setup.autodetect.grok")],["Gemini",O("setup.autodetect.gemini")]]}],examples:[G("vibecli setup --key sk-xxx","setup.ex.key"),G("vibecli setup --claudekey sk-a --codexkey sk-b --agykey sk-g","setup.ex.split"),G("vibecli setup --desktopkey sk-d --claude-official off","setup.ex.desktop"),G("vibecli setup --key sk-xxx --force","setup.ex.force"),G("vibecli setup --key sk-xxx --base https://www.vibeapi.si","setup.ex.base")]});const N=a.command("init").summary(O("init.summary")).description(O("init.description")).action(async()=>{await n.runFirstTimeSetup()});r(N,{...$("init",[["vibecli setup --key <key>","init.alt.setup"],["vibecli","init.alt.menu"]]),examples:[G("vibecli init","init.ex.run"),G("vibecli init --base https://www.vibeapi.si","init.ex.base"),G("vibecli","init.ex.menu")]});const S=a.command("auth").summary(O("auth.summary")).description(O("auth.description")).argument("[token]",O("auth.arg.token")).action(async e=>{const o=[];e&&o.push(e),await u(o)});C(S);const A=S.command("revoke").description(O("auth.revoke")).action(async()=>{await u(["revoke"])});r(A,{examples:[G("vibecli auth revoke","auth.ex.revoke_ask"),G("vibecli auth revoke --yes","auth.ex.revoke")]});const E=S.command("reload <tool>").description(O("auth.reload")).action(async e=>{await u(["reload",e])});r(E,{examples:[G("vibecli auth reload claude-code","auth.ex.reload"),G("vibecli auth reload claude-code --json","auth.ex.reload_json")]}),r(S,{...$("auth",[["vibecli setup --key <key>","auth.alt.setup"]]),examples:[G("vibecli auth","auth.ex.prompt"),G("vibecli auth sk-xxx --non-interactive","auth.ex.save"),G("vibecli auth revoke --yes","auth.ex.revoke"),G("vibecli auth reload claude-code","auth.ex.reload")]});const M=a.command("config").summary(O("config.summary")).description(O("config.description")).argument("[args...]",O("config.arg.args")).option("-f, --force",O("config.opt.force")).allowUnknownOption(!0).action(async(e=[],o={})=>{await b(o.force?[...e,"--force"]:e)});r(M,{...$("config",[["vibecli setup --key <key> --force","config.alt.setup"],["vibecli status","config.alt.status"]]),sections:[{title:O("config.subcommands_title"),rows:[["<tool>",O("config.sub.tool")],["<tool> --force",O("config.sub.tool_force")],["<tool> --non-interactive",O("config.sub.tool_non_interactive")],["<tool> restore",O("config.sub.tool_restore")],["<tool> backups",O("config.sub.tool_backups")],["<tool> clear-model",O("config.sub.tool_clear_model")],["tool-model list",O("config.sub.tool_model_list")],["tool-model set <tool> [slot] <model>",O("config.sub.tool_model_set")],["tool-model clear <tool>",O("config.sub.tool_model_clear")],["profile list",O("config.sub.profile_list")],["profile create <name>",O("config.sub.profile_create")],["profile use <name>",O("config.sub.profile_use")],["profile delete <name>",O("config.sub.profile_delete")],["preset list",O("config.sub.preset_list")],["preset save <name>",O("config.sub.preset_save")],["preset use <name>",O("config.sub.preset_use")],["preset delete <name>",O("config.sub.preset_delete")],["backup list",O("config.sub.backup_list")],["backup create [label]",O("config.sub.backup_create")],["backup restore <name>",O("config.sub.backup_restore")]]},{title:O("config.tools_title"),rows:Object.values(c).filter(e=>!e.hidden).map(e=>[e.name,e.displayName])}],examples:[G("vibecli config codex","config.ex.menu"),G("vibecli config claude-code --force","config.ex.force"),G("vibecli config tool-model set codex gpt-6-astra","config.ex.tool_model"),G("vibecli config profile create work","config.ex.profile"),G("vibecli config backup create before-upgrade","config.ex.backup")]});const P=a.command("base").summary(O("base.summary")).description(O("base.description")).argument("[target]",O("base.arg.target")).action(async e=>{await j(e)});r(P,{...$("base",[["vibecli doctor","base.alt.doctor"],["vibecli bench","base.alt.bench"]]),sections:[{title:O("base.targets_title"),rows:[[O("base.target.none_term"),O("base.target.none")],[O("base.target.index_term"),O("base.target.index")],[O("base.target.url_term"),O("base.target.url")],["auto",O("base.target.auto")],["default",O("base.target.default",{url:l})]]}],examples:[G("vibecli base","base.ex.list"),G("vibecli base auto","base.ex.auto"),G("vibecli base 2","base.ex.index"),G("vibecli base https://www.vibeapi.si","base.ex.url"),G("vibecli base default","base.ex.default")]}),a.commandsGroup(O("group.diagnose"));const R=a.command("status").summary(O("status.summary")).description(O("status.description")).action(async()=>{await g()});r(R,{...$("status",[["vibecli doctor","status.alt.doctor"]]),examples:[G("vibecli status","status.ex.show"),G("vibecli status --json","status.ex.json")]});const T=a.command("doctor").summary(O("doctor.summary")).description(O("doctor.description")).option("--deep",O("doctor.opt.deep")).action(async e=>{await d({deep:e.deep})});r(T,{...$("doctor",[["vibecli base auto","doctor.alt.base"],["vibecli logs tail","doctor.alt.logs"]]),examples:[G("vibecli doctor","doctor.ex.run"),G("vibecli doctor --deep","doctor.ex.deep")]});const U=a.command("bench").summary(O("bench.summary")).description(O("bench.description")).option("--samples <n>",O("bench.opt.samples"),"5").action(async e=>{const o=[];e.samples&&o.push("--samples",e.samples),await v(o)});r(U,{...$("bench",[["vibecli base","bench.alt.base"]]),examples:[G("vibecli bench","bench.ex.run"),G("vibecli bench --samples 3","bench.ex.samples"),G("vibecli bench --json","bench.ex.json")]});const q=a.command("logs").summary(O("logs.summary")).description(O("logs.description")).argument("[action]",O("logs.arg.action")).argument("[file]",O("logs.arg.file")).action(async(e,o)=>{const t=[];e&&t.push(e),o&&t.push(o),await f(t)});r(q,{...$("logs",[["vibecli doctor","logs.alt.doctor"]]),sections:[{title:O("logs.actions_title"),rows:[["list",O("logs.action.list")],["tail [file]",O("logs.action.tail")],["path",O("logs.action.path")]]}],examples:[G("vibecli logs","logs.ex.list"),G("vibecli logs tail","logs.ex.tail"),G("vibecli logs path","logs.ex.path")]}),a.commandsGroup(O("group.maintain"));const B=a.command("upgrade").summary(O("upgrade.summary")).description(O("upgrade.description")).argument("[tools...]",O("upgrade.arg.tools")).action(async(e=[])=>{await h(e)});r(B,{...$("upgrade",[["vibecli update","upgrade.alt.update"]]),examples:[G("vibecli upgrade","upgrade.ex.all"),G("vibecli upgrade claude-code","upgrade.ex.one"),G("vibecli upgrade codex agy","upgrade.ex.many")]});const F=a.command("update").summary(O("update.summary")).description(O("update.description")).action(async()=>{await y()});r(F,{...$("update",[["vibecli upgrade","update.alt.upgrade"]]),examples:[G("vibecli update","update.ex.check"),G("vibecli update --json","update.ex.json")]});const H=a.command("codex").summary(O("codex.summary")).description(O("codex.description"));C(H);const J=H.command("sessions").summary(O("codex_sessions.summary")).description(O("codex_sessions.description")).option("--to <provider>",O("codex_sessions.opt.to")).option("--undo <dir>",O("codex_sessions.opt.undo")).action(async e=>{await k(e)});r(H,{...$("codex"),examples:[G("vibecli codex sessions","codex_sessions.ex.move"),G("vibecli codex sessions --undo <dir>","codex_sessions.ex.undo")]}),r(J,{...$("codex_sessions",[["vibecli codex sessions --undo <dir>","codex_sessions.alt.undo"]]),examples:[G("vibecli codex sessions","codex_sessions.ex.move"),G("vibecli codex sessions --to custom","codex_sessions.ex.to"),G("vibecli codex sessions --undo <dir>","codex_sessions.ex.undo")]});const K=a.command("lang").summary(O("lang.summary")).description(O("lang.description"));C(K);const L=K.command("show").description(O("lang.show")).action(async()=>{await m(["show"])}),D=K.command("set <locale>").description(O("lang.set")).action(async e=>{await m(["set",e])}),I=[G("vibecli lang show","lang.ex.show"),G("vibecli lang set en_US","lang.ex.set_en"),G("vibecli lang set zh_CN","lang.ex.set_zh")];r(K,{...$("lang",[["vibecli enter lang","lang.alt.enter"]]),examples:I}),r(L,{examples:[I[0],G("vibecli lang show --json","lang.ex.show_json")]}),r(D,{examples:I.slice(1)});const Q=a.command("completion").summary(O("completion.summary")).description(O("completion.description")).argument("<shell>",O("completion.arg.shell")).action(async e=>{await x([e])});r(Q,{...$("completion"),examples:[G("vibecli completion bash > ~/.vibecli-completion.bash","completion.ex.bash"),G("vibecli completion zsh > ~/.vibecli-completion.zsh","completion.ex.zsh"),G("vibecli completion fish > ~/.config/fish/completions/vibecli.fish","completion.ex.fish")]});const V=a.command("enter").summary(O("enter.summary")).description(O("enter.description")).argument("[option]",O("enter.arg.option")).action(async e=>{if(e)switch(e){case"lang":case"language":await n.configLanguage();break;case"apikey":case"api-key":await n.configApiKey();break;case"models":await n.configModels();break;default:await b([e])}else await n.run()});r(V,{...$("enter",[["vibecli","enter.alt.menu"],["vibecli config <tool>","enter.alt.config"]]),sections:[{title:O("enter.options_title"),rows:[[O("enter.option.none_term"),O("enter.option.none")],["lang",O("enter.option.lang")],["apikey",O("enter.option.apikey")],["models",O("enter.option.models")],["<tool>",O("enter.option.tool")]]}],examples:[G("vibecli enter","enter.ex.menu"),G("vibecli enter models","enter.ex.models"),G("vibecli enter codex","enter.ex.tool")]}),C(a),a.action(async()=>{await n.run()}),r(a,{examples:[G("vibecli","root.ex.menu"),G("vibecli setup --key sk-xxx","root.ex.setup"),G("vibecli doctor","root.ex.doctor"),G("vibecli base auto","root.ex.base"),G("vibecli config codex","root.ex.config")]});const W=e=>{for(const o of e.commands)o.helpOption("-h, --help",O("global.help")),W(o)};return W(a),a}
|
|
1
|
+
import{Command as e,Option as o}from"commander";import{readFileSync as t}from"fs";import{join as i,dirname as s}from"path";import{fileURLToPath as a}from"url";import{i18n as n}from"./i18n.js";import{wizard as c}from"./wizard.js";import{SUPPORTED_TOOLS as l}from"./tool-manager.js";import{DEFAULT_BASE_URL as r}from"./config.js";import{attachCommandHelp as p,helpConfiguration as u}from"./cli-help.js";import{langCommand as m,authCommand as d,doctorCommand as b,configCommand as g,statusCommand as f}from"../commands/index.js";import{logsCommand as v}from"../commands/logs.js";import{completionCommand as x}from"../commands/completion.js";import{benchCommand as y}from"../commands/bench.js";import{updateCommand as h}from"../commands/update.js";import{upgradeCommand as k}from"../commands/upgrade.js";import{codexSessionsCommand as _}from"../commands/codex-sessions.js";import{setupCommand as w,DEDICATED_KEYS as j}from"../commands/setup.js";import{baseCommand as O}from"../commands/base.js";import{usageError as S}from"./errors.js";function z(e,o){return n.t(`help.${e}`,o)}function C(e,o){return{command:e,note:z(o)}}function G(e){const o=z(e);return o===`help.${e}`?"":o}function $(e,o=[]){return{when:G(`${e}.when`),prerequisites:G(`${e}.needs`).split("\n").filter(Boolean),alternatives:o.map(([e,o])=>C(e,o))}}function R(e){return e.helpCommand("help [command]",z("help_command"))}export function buildProgram(){const G=new e;G.name("vibecli").summary(z("root.summary")).description(z("root.description")).configureHelp(u()).allowExcessArguments(!0).optionsGroup(z("group.global_options")).helpOption("-h, --help",z("global.help")).version(function(){try{const e=s(a(import.meta.url));return JSON.parse(t(i(e,"../../package.json"),"utf-8")).version}catch{return"1.0.0"}}(),"-v, --version",z("global.version")).option("--base <url>",z("global.base")).option("--non-interactive",z("global.non_interactive")).option("--json",z("global.json")).option("-y, --yes",z("global.yes")).option("--dry-run",z("global.dry_run")).option("--no-color",z("global.no_color")),G.configureOutput({writeErr:()=>{},outputError:()=>{}}),G.showSuggestionAfterError(),G.exitOverride(e=>{throw e}),G.commandsGroup(z("group.configure"));const E=G.command("setup").summary(z("setup.summary")).description(z("setup.description")).option("--key <key>",z("setup.opt.key"));for(const e of j){const t=new o(`--${e.option} <key>`,z(`setup.opt.${e.option}`));e.hidden&&t.hideHelp(),E.addOption(t)}E.option("--1m",z("setup.opt.one_m")).option("--no-1m",z("setup.opt.no_one_m")).option("--claude-official <on|off>",z("setup.opt.claude_official")).option("--desktop-registry <on|off>",z("setup.opt.desktop_registry")).option("--force",z("setup.opt.force")).option("--all",z("setup.opt.all")).action(async e=>{const o=Boolean(e.key||j.some(o=>e[o.option])),t=void 0!==e["1m"]||void 0!==e.claudeOfficial||void 0!==e.desktopRegistry,i="zh_CN"===n.getLocale()?"<你的 Key>":"<your key>";if(!o&&!t)throw S(n.t("setup.usage"),`vibecli setup --key ${i}`,"missing_key");if(void 0!==e.claudeOfficial&&!["on","off"].includes(String(e.claudeOfficial).toLowerCase()))throw S(n.t("setup.claude_official_invalid",{value:String(e.claudeOfficial)}),"vibecli setup --claude-official on|off","invalid_value");if(void 0!==e.desktopRegistry&&!["on","off"].includes(String(e.desktopRegistry).toLowerCase()))throw S(n.t("setup.desktop_registry_invalid",{value:String(e.desktopRegistry)}),"vibecli setup --desktop-registry on|off","invalid_value");await w({key:e.key,...Object.fromEntries(j.map(o=>[o.option,e[o.option]])),all:e.all,oneMillion:e["1m"],claudeOfficial:e.claudeOfficial,desktopRegistry:e.desktopRegistry,force:e.force})}),p(E,{...$("setup",[["vibecli init","setup.alt.init"],["vibecli config <tool>","setup.alt.config"],["vibecli auth <key>","setup.alt.auth"]]),sections:[{title:z("setup.autodetect_title"),rows:[["Claude",z("setup.autodetect.claude")],["GPT",z("setup.autodetect.gpt")],["Grok",z("setup.autodetect.grok")],["Gemini",z("setup.autodetect.gemini")]]}],examples:[C("vibecli setup --key sk-xxx","setup.ex.key"),C("vibecli setup --claudekey sk-a --codexkey sk-b --agykey sk-g","setup.ex.split"),C("vibecli setup --desktopkey sk-d --claude-official off","setup.ex.desktop"),C("vibecli setup --key sk-xxx --force","setup.ex.force"),C("vibecli setup --key sk-xxx --base https://www.vibeapi.si","setup.ex.base")]});const L=G.command("init").summary(z("init.summary")).description(z("init.description")).action(async()=>{await c.runFirstTimeSetup()});p(L,{...$("init",[["vibecli setup --key <key>","init.alt.setup"],["vibecli","init.alt.menu"]]),examples:[C("vibecli init","init.ex.run"),C("vibecli init --base https://www.vibeapi.si","init.ex.base"),C("vibecli","init.ex.menu")]});const N=G.command("auth").summary(z("auth.summary")).description(z("auth.description")).argument("[token]",z("auth.arg.token")).action(async e=>{const o=[];e&&o.push(e),await d(o)});R(N);const A=N.command("revoke").description(z("auth.revoke")).action(async()=>{await d(["revoke"])});p(A,{examples:[C("vibecli auth revoke","auth.ex.revoke_ask"),C("vibecli auth revoke --yes","auth.ex.revoke")]});const B=N.command("reload <tool>").description(z("auth.reload")).action(async e=>{await d(["reload",e])});p(B,{examples:[C("vibecli auth reload claude-code","auth.ex.reload"),C("vibecli auth reload claude-code --json","auth.ex.reload_json")]}),p(N,{...$("auth",[["vibecli setup --key <key>","auth.alt.setup"]]),examples:[C("vibecli auth","auth.ex.prompt"),C("vibecli auth sk-xxx --non-interactive","auth.ex.save"),C("vibecli auth revoke --yes","auth.ex.revoke"),C("vibecli auth reload claude-code","auth.ex.reload")]});const H=G.command("config").summary(z("config.summary")).description(z("config.description")).argument("[args...]",z("config.arg.args")).option("-f, --force",z("config.opt.force")).allowUnknownOption(!0).action(async(e=[],o={})=>{await g(o.force?[...e,"--force"]:e)});p(H,{...$("config",[["vibecli setup --key <key> --force","config.alt.setup"],["vibecli status","config.alt.status"]]),sections:[{title:z("config.subcommands_title"),rows:[["<tool>",z("config.sub.tool")],["<tool> --force",z("config.sub.tool_force")],["<tool> --non-interactive",z("config.sub.tool_non_interactive")],["<tool> restore",z("config.sub.tool_restore")],["<tool> backups",z("config.sub.tool_backups")],["<tool> clear-model",z("config.sub.tool_clear_model")],["tool-model list",z("config.sub.tool_model_list")],["tool-model set <tool> [slot] <model>",z("config.sub.tool_model_set")],["tool-model clear <tool>",z("config.sub.tool_model_clear")],["profile list",z("config.sub.profile_list")],["profile create <name>",z("config.sub.profile_create")],["profile use <name>",z("config.sub.profile_use")],["profile delete <name>",z("config.sub.profile_delete")],["preset list",z("config.sub.preset_list")],["preset save <name>",z("config.sub.preset_save")],["preset use <name>",z("config.sub.preset_use")],["preset delete <name>",z("config.sub.preset_delete")],["backup list",z("config.sub.backup_list")],["backup create [label]",z("config.sub.backup_create")],["backup restore <name>",z("config.sub.backup_restore")]]},{title:z("config.tools_title"),rows:Object.values(l).filter(e=>!e.hidden).map(e=>[e.name,e.displayName])}],examples:[C("vibecli config codex","config.ex.menu"),C("vibecli config claude-code --force","config.ex.force"),C("vibecli config tool-model set codex gpt-6-astra","config.ex.tool_model"),C("vibecli config profile create work","config.ex.profile"),C("vibecli config backup create before-upgrade","config.ex.backup")]});const K=G.command("base").summary(z("base.summary")).description(z("base.description")).argument("[target]",z("base.arg.target")).action(async e=>{await O(e)});p(K,{...$("base",[["vibecli doctor","base.alt.doctor"],["vibecli bench","base.alt.bench"]]),sections:[{title:z("base.targets_title"),rows:[[z("base.target.none_term"),z("base.target.none")],[z("base.target.index_term"),z("base.target.index")],[z("base.target.url_term"),z("base.target.url")],["auto",z("base.target.auto")],["default",z("base.target.default",{url:r})]]}],examples:[C("vibecli base","base.ex.list"),C("vibecli base auto","base.ex.auto"),C("vibecli base 2","base.ex.index"),C("vibecli base https://www.vibeapi.si","base.ex.url"),C("vibecli base default","base.ex.default")]}),G.commandsGroup(z("group.diagnose"));const M=G.command("status").summary(z("status.summary")).description(z("status.description")).action(async()=>{await f()});p(M,{...$("status",[["vibecli doctor","status.alt.doctor"]]),examples:[C("vibecli status","status.ex.show"),C("vibecli status --json","status.ex.json")]});const P=G.command("doctor").summary(z("doctor.summary")).description(z("doctor.description")).option("--deep",z("doctor.opt.deep")).action(async e=>{await b({deep:e.deep})});p(P,{...$("doctor",[["vibecli base auto","doctor.alt.base"],["vibecli logs tail","doctor.alt.logs"]]),examples:[C("vibecli doctor","doctor.ex.run"),C("vibecli doctor --deep","doctor.ex.deep")]});const T=G.command("bench").summary(z("bench.summary")).description(z("bench.description")).option("--samples <n>",z("bench.opt.samples"),"5").action(async e=>{const o=[];e.samples&&o.push("--samples",e.samples),await y(o)});p(T,{...$("bench",[["vibecli base","bench.alt.base"]]),examples:[C("vibecli bench","bench.ex.run"),C("vibecli bench --samples 3","bench.ex.samples"),C("vibecli bench --json","bench.ex.json")]});const U=G.command("logs").summary(z("logs.summary")).description(z("logs.description")).argument("[action]",z("logs.arg.action")).argument("[file]",z("logs.arg.file")).action(async(e,o)=>{const t=[];e&&t.push(e),o&&t.push(o),await v(t)});p(U,{...$("logs",[["vibecli doctor","logs.alt.doctor"]]),sections:[{title:z("logs.actions_title"),rows:[["list",z("logs.action.list")],["tail [file]",z("logs.action.tail")],["path",z("logs.action.path")]]}],examples:[C("vibecli logs","logs.ex.list"),C("vibecli logs tail","logs.ex.tail"),C("vibecli logs path","logs.ex.path")]}),G.commandsGroup(z("group.maintain"));const q=G.command("upgrade").summary(z("upgrade.summary")).description(z("upgrade.description")).argument("[tools...]",z("upgrade.arg.tools")).action(async(e=[])=>{await k(e)});p(q,{...$("upgrade",[["vibecli update","upgrade.alt.update"]]),examples:[C("vibecli upgrade","upgrade.ex.all"),C("vibecli upgrade claude-code","upgrade.ex.one"),C("vibecli upgrade codex agy","upgrade.ex.many")]});const F=G.command("update").summary(z("update.summary")).description(z("update.description")).action(async()=>{await h()});p(F,{...$("update",[["vibecli upgrade","update.alt.upgrade"]]),examples:[C("vibecli update","update.ex.check"),C("vibecli update --json","update.ex.json")]});const J=G.command("codex").summary(z("codex.summary")).description(z("codex.description"));R(J);const D=J.command("sessions").summary(z("codex_sessions.summary")).description(z("codex_sessions.description")).option("--to <provider>",z("codex_sessions.opt.to")).option("--undo <dir>",z("codex_sessions.opt.undo")).action(async e=>{await _(e)});p(J,{...$("codex"),examples:[C("vibecli codex sessions","codex_sessions.ex.move"),C("vibecli codex sessions --undo <dir>","codex_sessions.ex.undo")]}),p(D,{...$("codex_sessions",[["vibecli codex sessions --undo <dir>","codex_sessions.alt.undo"]]),examples:[C("vibecli codex sessions","codex_sessions.ex.move"),C("vibecli codex sessions --to custom","codex_sessions.ex.to"),C("vibecli codex sessions --undo <dir>","codex_sessions.ex.undo")]});const I=G.command("lang").summary(z("lang.summary")).description(z("lang.description"));R(I);const Q=I.command("show").description(z("lang.show")).action(async()=>{await m(["show"])}),V=I.command("set <locale>").description(z("lang.set")).action(async e=>{await m(["set",e])}),W=[C("vibecli lang show","lang.ex.show"),C("vibecli lang set en_US","lang.ex.set_en"),C("vibecli lang set zh_CN","lang.ex.set_zh")];p(I,{...$("lang",[["vibecli enter lang","lang.alt.enter"]]),examples:W}),p(Q,{examples:[W[0],C("vibecli lang show --json","lang.ex.show_json")]}),p(V,{examples:W.slice(1)});const X=G.command("completion").summary(z("completion.summary")).description(z("completion.description")).argument("<shell>",z("completion.arg.shell")).action(async e=>{await x([e])});p(X,{...$("completion"),examples:[C("vibecli completion bash > ~/.vibecli-completion.bash","completion.ex.bash"),C("vibecli completion zsh > ~/.vibecli-completion.zsh","completion.ex.zsh"),C("vibecli completion fish > ~/.config/fish/completions/vibecli.fish","completion.ex.fish")]});const Y=G.command("enter").summary(z("enter.summary")).description(z("enter.description")).argument("[option]",z("enter.arg.option")).action(async e=>{if(e)switch(e){case"lang":case"language":await c.configLanguage();break;case"apikey":case"api-key":await c.configApiKey();break;case"models":await c.configModels();break;default:await g([e])}else await c.run()});p(Y,{...$("enter",[["vibecli","enter.alt.menu"],["vibecli config <tool>","enter.alt.config"]]),sections:[{title:z("enter.options_title"),rows:[[z("enter.option.none_term"),z("enter.option.none")],["lang",z("enter.option.lang")],["apikey",z("enter.option.apikey")],["models",z("enter.option.models")],["<tool>",z("enter.option.tool")]]}],examples:[C("vibecli enter","enter.ex.menu"),C("vibecli enter models","enter.ex.models"),C("vibecli enter codex","enter.ex.tool")]}),R(G),G.action(async()=>{await c.run()}),p(G,{examples:[C("vibecli","root.ex.menu"),C("vibecli setup --key sk-xxx","root.ex.setup"),C("vibecli doctor","root.ex.doctor"),C("vibecli base auto","root.ex.base"),C("vibecli config codex","root.ex.config")]});const Z=e=>{for(const o of e.commands)o.helpOption("-h, --help",z("global.help")),Z(o)};return Z(G),G}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{chmodSync as t,existsSync as e,readFileSync as r}from"fs";import{join as n}from"path";import{i18n as o}from"../i18n.js";import{prettyModelName as i}from"../gateway-models.js";import{getAgyRules as a}from"../model-registry.js";import{logger as l}from"../../utils/logger.js";import{readPersistentEnvFile as s,removePersistentEnv as c,writePersistentEnv as u}from"../persistent-env.js";import{backupBeforeWrite as p,atomicWriteFile as d}from"./backup.js";import{mirrorInstallCommand as g}from"./tool-installs.js";import{toolHome as m}from"./types.js";const y="agy",f="AGY_LLM_GATEWAY_MODELS",v=["GEMINI_API_KEY","GOOGLE_GEMINI_BASE_URL","AGY_LLM_GATEWAY_URL","AGY_LLM_GATEWAY_API_KEY"],A="gemini",_=()=>n(m(),".gemini","antigravity-cli"),h=()=>n(_(),"settings.json"),E=()=>n(_(),"vibeapi.env"),j=()=>n(m(),".antigravity","settings.json"),b="https://cnb.cool/vibeapi/agy/-/releases/latest/download",w={command:"agy",native:{binDir:"win32"===process.platform?["AppData","Local","agy","bin"]:[".local","bin"],updateArgs:["update"],dataDirs:[]},mirrorScript:{sh:`${b}/install.sh`,ps1:`${b}/install.ps1`}};function I(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function K(t,n){if(!e(t))return{};const o=r(t,"utf-8");if(!o.trim())return{};try{const t=JSON.parse(o);if(!I(t))throw new Error(`${n} root must be an object`);return t}catch(t){throw new Error(`Existing ${n} cannot be parsed, back it up and fix it first: ${t instanceof Error?t.message:String(t)}`)}}const P=()=>K(h(),"~/.gemini/antigravity-cli/settings.json"),G=()=>K(j(),"~/.antigravity/settings.json");function L(e,r,n){p(e),d(e,JSON.stringify(r,null,2)+"\n",n),void 0!==n&&t(e,n)}function M(t){return(t||"").replace(/\/+$/,"").replace(/\/v1(beta)?$/,"")}function C(t){const e=a().gatewayModels,r=t?e.filter(e=>t.models.includes(e)):[];return r.length>0?r:e}const N=t=>i(t.replace(/-preview$/,""));function S(t){const e=t.gateway;return I(e)&&!0===e.enabled&&"string"==typeof e.apiKey&&e.apiKey.trim()&&"string"==typeof e.url?{url:e.url,apiKey:e.apiKey}:null}function Y(t){const e=t.models;return I(e)&&Array.isArray(e.list)?e.list.map(t=>I(t)&&"string"==typeof t.modelId?t.modelId:"").filter(Boolean):[]}function $(){try{if(P().modelProvider!==A)return null}catch{return null}const t=s(E()),e=t.GEMINI_API_KEY;return e&&e.trim()?{apiKey:e,url:t.GOOGLE_GEMINI_BASE_URL??""}:null}function k(t,e,r){const n=P(),o=G();o.gateway={...I(o.gateway)?o.gateway:{},enabled:!0,url:e,apiKey:t,wireProtocol:"genai"},o.models={...I(o.models)?o.models:{},defaultModelId:r[0],list:r.map(t=>({modelId:t,displayName:N(t),supportsThinking:!0}))},L(j(),o,384),v.some(t=>void 0!==s(E())[t])&&c(y,E(),v);const i=u(y,E(),{[f]:r.join(",")}).rcFiles;for(const t of v)delete process.env[t];return n.modelProvider===A&&(delete n.modelProvider,L(h(),n)),i}let O=null,x=null;export const antigravityAdapter={name:"agy",displayName:"Antigravity CLI",command:"agy",installCommand:g(w),installSpec:w,configPath:j(),wantsModelCatalog:!0,loadPrivateConfig(t){P(),G();const e=C(t.catalog);O=k(t.apiKey,M(t.baseUrl),e),x=e},unloadPrivateConfig(){try{const t=G();S(t)&&(delete t.gateway,delete t.models,L(j(),t,384))}catch(t){l.logError("antigravityAdapter.unloadPrivateConfig",t)}try{const t=P();t.modelProvider===A&&(delete t.modelProvider,L(h(),t))}catch(t){l.logError("antigravityAdapter.unloadPrivateConfig",t)}c(y,E(),[f,...v])},detectCurrentConfig(){try{const t=S(G());if(t)return{apiKey:t.apiKey}}catch{return{apiKey:null}}return{apiKey:$()?.apiKey??null}},listedModels(){try{const t=G();if(S(t))return Y(t)}catch{return null}return $()?[]:null},refreshModelMenu(t){const e=G(),r=S(e)??$();if(!r)return;const n=C(t.catalog),o=r.url||M(t.baseUrl);null!==S(e)&&Y(e).join(",")===n.join(",")&&s(E())[f]===n.join(",")&&null===$()||k(r.apiKey,o,n)},getConfig(){try{return G()}catch(t){return l.logError("antigravityAdapter.getConfig",t),null}},applyNotes(){const t=[];if(x&&x.length>0){const e=x.map(N);t.push({kind:"summary",text:o.t("tools.agy.menu_written",{count:String(e.length),list:e.join(o.t("tools.grok.list_separator")),default:e[0]})})}return null===O||t.push({kind:"action",text:o.t("tools.agy.effort_after_reopen")}),t},backupPaths:()=>[j(),h(),E()],forceResetPaths:()=>[E()]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as r,readFileSync as o}from"fs";import{join as t}from"path";import*as e from"@iarna/toml";import{logger as i}from"../../utils/logger.js";import{BRAND_NAME as n}from"../brand.js";import{backupBeforeWrite as a,atomicWriteFile as d}from"./backup.js";import{pickModel as m,toolHome as s,withV1 as p}from"./types.js";import{getToolDefaultModel as l}from"../model-registry.js";const c=()=>t(t(s(),".atomcode"),"config.toml"),f=n;function u(r){return!!r&&"object"==typeof r&&!Array.isArray(r)}function g(){if(!r(c()))return{};const t=o(c(),"utf-8");if(!t.trim())return{};try{const r=e.parse(t);if(!u(r))throw new Error("config.toml root must be a TOML table");return r}catch(r){throw new Error(`Existing ~/.atomcode/config.toml cannot be parsed, back it up and fix it first: ${r instanceof Error?r.message:String(r)}`)}}export const atomcodeAdapter={name:"atomcode",displayName:"AtomCode",command:"atomcode",installCommand:"npm install -g atomcode",configPath:c(),loadPrivateConfig(r){const o=g(),t=u(o.providers)?o.providers:o.providers={},i=u(t[f])?{...t[f]}:{};t[f]={...i,type:"openai",base_url:p(r.baseUrl),context_window:2e5,api_key:r.apiKey,model:m(r.models,l("atomcode"))},o.default_provider=f,a(c()),d(c(),e.stringify(o))},unloadPrivateConfig(){if(!r(c()))return;let o;try{o=g()}catch(r){return void i.logError("atomcodeAdapter.unloadPrivateConfig",r)}u(o.providers)&&(delete o.providers[f],0===Object.keys(o.providers).length&&delete o.providers),o.default_provider===f&&delete o.default_provider,a(c()),d(c(),e.stringify(o))},detectCurrentConfig(){try{const r=g(),o=u(r.providers)?r.providers[f]:null,t=u(o)?o.api_key:null;return{apiKey:"string"==typeof t&&t.trim()?t:null}}catch{return{apiKey:null}}},getConfig(){try{return g()}catch(r){return i.logError("atomcodeAdapter.getConfig",r),null}}};
|
|
1
|
+
import{existsSync as r,readFileSync as o}from"fs";import{join as t}from"path";import*as e from"@iarna/toml";import{logger as i}from"../../utils/logger.js";import{BRAND_NAME as n}from"../brand.js";import{backupBeforeWrite as a,atomicWriteFile as d}from"./backup.js";import{pickModel as m,toolHome as s,withV1 as p}from"./types.js";import{getToolDefaultModel as l}from"../model-registry.js";const c=()=>t(t(s(),".atomcode"),"config.toml"),f=n;function u(r){return!!r&&"object"==typeof r&&!Array.isArray(r)}function g(){if(!r(c()))return{};const t=o(c(),"utf-8");if(!t.trim())return{};try{const r=e.parse(t);if(!u(r))throw new Error("config.toml root must be a TOML table");return r}catch(r){throw new Error(`Existing ~/.atomcode/config.toml cannot be parsed, back it up and fix it first: ${r instanceof Error?r.message:String(r)}`)}}export const atomcodeAdapter={name:"atomcode",displayName:"AtomCode",command:"atomcode",installCommand:"npm install -g atomcode",hidden:!0,configPath:c(),loadPrivateConfig(r){const o=g(),t=u(o.providers)?o.providers:o.providers={},i=u(t[f])?{...t[f]}:{};t[f]={...i,type:"openai",base_url:p(r.baseUrl),context_window:2e5,api_key:r.apiKey,model:m(r.models,l("atomcode"))},o.default_provider=f,a(c()),d(c(),e.stringify(o))},unloadPrivateConfig(){if(!r(c()))return;let o;try{o=g()}catch(r){return void i.logError("atomcodeAdapter.unloadPrivateConfig",r)}u(o.providers)&&(delete o.providers[f],0===Object.keys(o.providers).length&&delete o.providers),o.default_provider===f&&delete o.default_provider,a(c()),d(c(),e.stringify(o))},detectCurrentConfig(){try{const r=g(),o=u(r.providers)?r.providers[f]:null,t=u(o)?o.api_key:null;return{apiKey:"string"==typeof t&&t.trim()?t:null}}catch{return{apiKey:null}}},getConfig(){try{return g()}catch(r){return i.logError("atomcodeAdapter.getConfig",r),null}}};
|
package/dist/lib/tools/codex.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as t}from"fs";import{join as o}from"path";import*as n from"@iarna/toml";import{logger as r}from"../../utils/logger.js";import{i18n as i}from"../i18n.js";import{backupBeforeWrite as l,atomicWriteFile as a}from"./backup.js";import{pickModel as s,toolHome as d,withV1 as c}from"./types.js";import{getToolDefaultModel as m}from"../model-registry.js";import{buildCodexCatalog as u,codexCatalogPath as p,loadBundledCodexModels as _,loadPreviousCodexModels as
|
|
1
|
+
import{existsSync as e,readFileSync as t}from"fs";import{join as o}from"path";import*as n from"@iarna/toml";import{logger as r}from"../../utils/logger.js";import{i18n as i}from"../i18n.js";import{backupBeforeWrite as l,atomicWriteFile as a}from"./backup.js";import{pickModel as s,toolHome as d,withV1 as c}from"./types.js";import{getToolDefaultModel as m}from"../model-registry.js";import{buildCodexCatalog as u,codexCatalogPath as p,loadBundledCodexModels as _,loadPreviousCodexModels as f,previousGatewayModelIds as g}from"./codex-catalog.js";import{gatewayModelSpecs as x,modelFamily as y}from"../gateway-models.js";import{mirrorInstallCommand as b,vibeapiInstallScripts as h}from"./tool-installs.js";const k=()=>o(d(),".codex"),j=()=>o(k(),"config.toml"),w=()=>o(k(),"auth.json"),O="OPENAI_API_KEY",C="custom",v=1e6,M=9e5;export const CODEX_ONE_MILLION_CONTEXT_SETTING="one_million_context";function E(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function N(e,t){return E(e[t])||(e[t]={}),e[t]}function S(){if(!e(j()))return{};const o=t(j(),"utf-8");if(!o.trim())return{};try{const e=n.parse(o);if(!E(e))throw new Error("config.toml root must be a TOML table");return e}catch(e){throw new Error(`Existing ~/.codex/config.toml cannot be parsed, back it up and fix it first: ${e instanceof Error?e.message:String(e)}`)}}function A(){if(!e(w()))return{};try{const e=JSON.parse(t(w(),"utf-8"));return E(e)?e:{}}catch{return{}}}function P(e){const t=e.profiles;if(E(t)){for(const[e,o]of Object.entries(t))E(o)&&2===Object.keys(o).length&&o.model_provider===C&&o.model===e&&delete t[e];0===Object.keys(t).length&&delete e.profiles}}let T=null;function I(o,n,i){const s=!1!==n.settings?.one_million_context;!function(e){e.model_context_window===v&&delete e.model_context_window,e.model_auto_compact_token_limit===M&&delete e.model_auto_compact_token_limit}(o);const d=_()??f();if(!d)return r.logError("codexAdapter.writeModelCatalog",new Error("no Codex binary found; model catalog skipped")),T="skipped",o.model_catalog_json===p()&&delete o.model_catalog_json,void(s&&(o.model_context_window=v,o.model_auto_compact_token_limit=M));const c=n.catalog,m=u({bundled:d,specs:x("codex",c?.clientModels),...c?{keyModels:c.models}:{},gatewayAvailable:c?.models??g(),oneMillion:s,selectedModel:i,..."gateway"===c?.oneMillionSource?{claudeOneMillion:c.oneMillion}:{}});T={listed:m.models.filter(e=>"list"===e.visibility).map(e=>({id:String(e.slug),name:String(e.display_name??e.slug)}))};const y=JSON.stringify(m,null,2)+"\n",b=p();e(b)&&t(b,"utf-8")===y||(l(b),a(b,y)),o.model_catalog_json=b}export function setCodexOneMillionContext(e,t){const o=S(),r=n.stringify(o),i="string"==typeof o.model?o.model:m("codex");I(o,{settings:{[CODEX_ONE_MILLION_CONTEXT_SETTING]:e},catalog:t},i);const s=n.stringify(o);s!==r&&(l(j()),a(j(),s))}const L={command:"codex",npmPackage:"@openai/codex",native:{binDir:"win32"===process.platform?["AppData","Local","Programs","OpenAI","Codex","bin"]:[".local","bin"],updateArgs:["update"],updateTimeoutMs:12e4,dataDirs:[[".codex","packages","standalone"]]},mirrorScript:h("codex"),brew:"codex"};export const codexAdapter={name:"codex",displayName:"Codex",command:"codex",installCommand:b(L),installSpec:L,configPath:j(),wantsModelCatalog:!0,listedModels(){if(S().model_catalog_json!==p())return null;try{return(JSON.parse(t(p(),"utf-8")).models??[]).filter(e=>"list"===e.visibility).map(e=>String(e.slug))}catch{return null}},refreshModelMenu(e){S().model_catalog_json===p()&&setCodexOneMillionContext(!1!==e.settings?.one_million_context,e.catalog)},applyNotes(){if("skipped"===T)return[{kind:"action",text:i.t("tools.codex.catalog_skipped")}];if(!T)return[];const e=new Map;for(const t of T.listed)e.set(y(t.id),(e.get(y(t.id))??0)+1);const t=["gpt","claude","gemini","other","grok"].filter(t=>e.has(t)).map(t=>`${i.t(`tools.model_family.${t}`)} ${e.get(t)}`).join(" · ");return[{kind:"summary",text:i.t("tools.codex.catalog_written",{count:String(T.listed.length),breakdown:t})},{kind:"detail",text:T.listed.map(e=>e.name).join(", ")}]},loadPrivateConfig(e){const t=m("codex"),o=s(e.models,t),r=function(e){return/(?:^|\/)claude(?:-|$)/i.test(e)}(o)?t:o,i=c(e.baseUrl),d=S();d.model=r,d.model_provider=C,d.model_reasoning_effort="high",I(d,e,r);const u=N(d,"model_providers"),p=E(u[C])?{...u[C]}:{};delete p.env_key;const{experimental_bearer_token:_,...f}=p;u[C]={...f,name:"custom",wire_api:"responses",requires_openai_auth:!0,base_url:i},P(d),N(N(d,"tui"),"model_availability_nux")[r]=4;const g=N(d,"features");g.goals=!0,g.js_repl=!1,l(j()),a(j(),n.stringify(d)),function(e){const t=e.trim();if(!t)return;const o={...A(),auth_mode:"apikey",[O]:t};l(w()),a(w(),JSON.stringify(o,null,2)+"\n")}(e.apiKey)},unloadPrivateConfig(){if(!e(j()))return;let t;try{t=S()}catch(e){return void r.logError("codexAdapter.unloadPrivateConfig",e)}const o=t.model_providers;E(o)&&(delete o[C],0===Object.keys(o).length&&delete t.model_providers),t.model_provider===C&&delete t.model_provider,t.model_catalog_json===p()&&delete t.model_catalog_json,P(t),l(j()),a(j(),n.stringify(t))},detectCurrentConfig(){const e=A()[O];return{apiKey:"string"==typeof e&&e.trim()?e.trim():null}},getConfig(){try{return S()}catch(e){return r.logError("codexAdapter.getConfig",e),null}},backupPaths:()=>[j(),w(),p()]};export function codexAuthProblem(){try{const e=S(),t=e.model_providers?.[C];if(e.model_provider!==C||!t)return null;if("string"==typeof t.experimental_bearer_token&&t.experimental_bearer_token)return"stale_bearer";const o=A();return!0===t.requires_openai_auth&&"chatgpt"===o.auth_mode?"chatgpt_login":null}catch{return null}}
|
package/dist/lib/tools/hermes.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as t,readFileSync as
|
|
1
|
+
import{existsSync as t,readFileSync as e}from"fs";import{join as r}from"path";import*as n from"js-yaml";import{logger as i}from"../../utils/logger.js";import{API_KEY_ENV as o}from"../brand.js";import{backupBeforeWrite as s,atomicWriteFile as m}from"./backup.js";import{pickModel as l,toolHome as a,withV1 as c}from"./types.js";import{getToolDefaultModel as f}from"../model-registry.js";const d=()=>r(a(),".hermes"),u=()=>r(d(),"config.yaml"),p=()=>r(d(),".env");function h(t){return!!t&&"object"==typeof t&&!Array.isArray(t)}function g(){if(!t(u()))return{};const r=e(u(),"utf-8");if(!r.trim())return{};const i=n.load(r);if(!h(i))throw new Error("config.yaml root must be a YAML mapping");return i}export const hermesAdapter={name:"hermes",displayName:"Hermes",command:"hermes",installCommand:"npm install -g hermes-cli",hidden:!0,configPath:u(),loadPrivateConfig(r){let i;try{i=g()}catch(t){throw new Error(`Existing ~/.hermes/config.yaml cannot be parsed, back it up and fix it first: ${t instanceof Error?t.message:String(t)}`)}const a=h(i.model)?i.model:i.model={};a.provider="custom",a.base_url=c(r.baseUrl),a.default=l(r.models,f("hermes")),s(u()),m(u(),n.dump(i,{indent:2,lineWidth:-1,noRefs:!0,sortKeys:!1}));const d=t(p())?e(p(),"utf-8"):"";s(p()),m(p(),function(t,e,r){const n=(t||"").split(/\r?\n/),i=`${e}=${r}`;let o=!1;const s=n.map(t=>{const r=t.trim();if(!r||r.startsWith("#"))return t;const n=r.indexOf("=");return n<=0?t:r.slice(0,n).trim()===e?(o=!0,i):t});if(!o){if(!(t||"").trim())return i+"\n";s.length&&""!==s[s.length-1]&&s.push(""),s.push(i)}const m=s.join("\n");return m.endsWith("\n")?m:m+"\n"}(d,o,r.apiKey))},unloadPrivateConfig(){if(t(u()))try{const t=g();h(t.model)&&(delete t.model.provider,delete t.model.base_url,delete t.model.default,0===Object.keys(t.model).length&&delete t.model),s(u()),m(u(),n.dump(t,{indent:2,lineWidth:-1,noRefs:!0,sortKeys:!1}))}catch(t){i.logError("hermesAdapter.unloadPrivateConfig",t)}t(p())&&(s(p()),m(p(),function(t,e){const r=(t||"").split(/\r?\n/).filter(t=>{const r=t.trim();if(!r||r.startsWith("#"))return!0;const n=r.indexOf("=");return n<=0||r.slice(0,n).trim()!==e}).join("\n");return r.endsWith("\n")||""===r?r:r+"\n"}(e(p(),"utf-8"),o)))},detectCurrentConfig(){const r=function(){if(!t(p()))return{};const r={};for(const t of e(p(),"utf-8").split(/\r?\n/)){const e=t.trim();if(!e||e.startsWith("#"))continue;const n=e.indexOf("=");if(n<=0)continue;const i=e.slice(0,n).trim();let o=e.slice(n+1).trim();(o.startsWith('"')&&o.endsWith('"')||o.startsWith("'")&&o.endsWith("'"))&&(o=o.slice(1,-1)),r[i]=o}return r}()[o];return{apiKey:r&&r.trim()?r:null}},getConfig(){try{return g()}catch(t){return i.logError("hermesAdapter.getConfig",t),null}},backupPaths:()=>[u(),p()]};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{existsSync as e,readFileSync as r}from"fs";import{join as o}from"path";import{logger as t}from"../../utils/logger.js";import{PROVIDER_KEY as n}from"../brand.js";import{backupBeforeWrite as s,atomicWriteFile as l}from"./backup.js";import{pickModel as a,toolHome as i,withV1 as d}from"./types.js";import{getToolDefaultModel as m}from"../model-registry.js";const p=()=>o(o(i(),".openclaw"),"openclaw.json");function c(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function f(){if(!e(p()))return{};const o=r(p(),"utf-8");if(!o.trim())return{};const t=JSON.parse(o);if(!c(t))throw new Error("openclaw.json root must be a JSON object");return t}export const openclawAdapter={name:"openclaw",displayName:"OpenClaw",command:"openclaw",installCommand:"npm install -g openclaw",configPath:p(),loadPrivateConfig(e){let r;try{r=f()}catch(e){throw new Error(`Existing ~/.openclaw/openclaw.json cannot be parsed, back it up and fix it first: ${e instanceof Error?e.message:String(e)}`)}const o=c(r.models)?r.models:r.models={};o.mode||(o.mode="merge");const t=c(o.providers)?o.providers:o.providers={},i=c(t[n])?{...t[n]}:{},u=a(e.models,m("openclaw"))||function(e){const r=c(e.agents)?e.agents:{},o=c(r.defaults)?r.defaults:{},t=c(o.model)?o.model:{},s=`${n}/`;if("string"==typeof t.primary&&t.primary.startsWith(s))return t.primary.slice(s.length);const l=c(e.models)?e.models:{},a=c(l.providers)?l.providers:{},i=c(a[n])?a[n]:null;return i&&Array.isArray(i.models)&&c(i.models[0])&&"string"==typeof i.models[0].id?i.models[0].id:""}(r);t[n]={...i,baseUrl:d(e.baseUrl),api:"openai-completions",apiKey:e.apiKey,models:[{id:u,name:u}]};const y=c(r.agents)?r.agents:r.agents={},g=c(y.defaults)?y.defaults:y.defaults={},w=c(g.model)?g.model:g.model={},h=`${n}/${u}`;w.primary=h;const v=c(g.models)?g.models:g.models={};Object.prototype.hasOwnProperty.call(v,h)||(v[h]={}),s(p()),l(p(),JSON.stringify(r,null,2))},unloadPrivateConfig(){if(!e(p()))return;let r;try{r=f()}catch(e){return void t.logError("openclawAdapter.unloadPrivateConfig",e)}const o=c(r.models)?r.models:null;o&&c(o.providers)&&delete o.providers[n];const a=c(r.agents)?r.agents:null,i=a&&c(a.defaults)?a.defaults:null,d=i&&c(i.model)?i.model:null,m=`${n}/`;if(d&&"string"==typeof d.primary&&d.primary.startsWith(m)&&delete d.primary,i&&c(i.models))for(const e of Object.keys(i.models))e.startsWith(m)&&delete i.models[e];s(p()),l(p(),JSON.stringify(r,null,2))},detectCurrentConfig(){try{const e=f(),r=c(e.models)?e.models:{},o=c(r.providers)?r.providers:{},t=c(o[n])?o[n]:null,s=t&&"string"==typeof t.apiKey?t.apiKey:null;return{apiKey:s&&s.trim()?s:null}}catch{return{apiKey:null}}},getConfig(){try{return f()}catch(e){return t.logError("openclawAdapter.getConfig",e),null}}};
|
|
1
|
+
import{existsSync as e,readFileSync as r}from"fs";import{join as o}from"path";import{logger as t}from"../../utils/logger.js";import{PROVIDER_KEY as n}from"../brand.js";import{backupBeforeWrite as s,atomicWriteFile as l}from"./backup.js";import{pickModel as a,toolHome as i,withV1 as d}from"./types.js";import{getToolDefaultModel as m}from"../model-registry.js";const p=()=>o(o(i(),".openclaw"),"openclaw.json");function c(e){return!!e&&"object"==typeof e&&!Array.isArray(e)}function f(){if(!e(p()))return{};const o=r(p(),"utf-8");if(!o.trim())return{};const t=JSON.parse(o);if(!c(t))throw new Error("openclaw.json root must be a JSON object");return t}export const openclawAdapter={name:"openclaw",displayName:"OpenClaw",command:"openclaw",installCommand:"npm install -g openclaw",hidden:!0,configPath:p(),loadPrivateConfig(e){let r;try{r=f()}catch(e){throw new Error(`Existing ~/.openclaw/openclaw.json cannot be parsed, back it up and fix it first: ${e instanceof Error?e.message:String(e)}`)}const o=c(r.models)?r.models:r.models={};o.mode||(o.mode="merge");const t=c(o.providers)?o.providers:o.providers={},i=c(t[n])?{...t[n]}:{},u=a(e.models,m("openclaw"))||function(e){const r=c(e.agents)?e.agents:{},o=c(r.defaults)?r.defaults:{},t=c(o.model)?o.model:{},s=`${n}/`;if("string"==typeof t.primary&&t.primary.startsWith(s))return t.primary.slice(s.length);const l=c(e.models)?e.models:{},a=c(l.providers)?l.providers:{},i=c(a[n])?a[n]:null;return i&&Array.isArray(i.models)&&c(i.models[0])&&"string"==typeof i.models[0].id?i.models[0].id:""}(r);t[n]={...i,baseUrl:d(e.baseUrl),api:"openai-completions",apiKey:e.apiKey,models:[{id:u,name:u}]};const y=c(r.agents)?r.agents:r.agents={},g=c(y.defaults)?y.defaults:y.defaults={},w=c(g.model)?g.model:g.model={},h=`${n}/${u}`;w.primary=h;const v=c(g.models)?g.models:g.models={};Object.prototype.hasOwnProperty.call(v,h)||(v[h]={}),s(p()),l(p(),JSON.stringify(r,null,2))},unloadPrivateConfig(){if(!e(p()))return;let r;try{r=f()}catch(e){return void t.logError("openclawAdapter.unloadPrivateConfig",e)}const o=c(r.models)?r.models:null;o&&c(o.providers)&&delete o.providers[n];const a=c(r.agents)?r.agents:null,i=a&&c(a.defaults)?a.defaults:null,d=i&&c(i.model)?i.model:null,m=`${n}/`;if(d&&"string"==typeof d.primary&&d.primary.startsWith(m)&&delete d.primary,i&&c(i.models))for(const e of Object.keys(i.models))e.startsWith(m)&&delete i.models[e];s(p()),l(p(),JSON.stringify(r,null,2))},detectCurrentConfig(){try{const e=f(),r=c(e.models)?e.models:{},o=c(r.providers)?r.providers:{},t=c(o[n])?o[n]:null,s=t&&"string"==typeof t.apiKey?t.apiKey:null;return{apiKey:s&&s.trim()?s:null}}catch{return{apiKey:null}}},getConfig(){try{return f()}catch(e){return t.logError("openclawAdapter.getConfig",e),null}}};
|
package/dist/lib/wizard.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"inquirer";import t from"chalk";import a from"ora";import{configManager as o,DEFAULT_MODELS as i}from"./config.js";import{getPresets as n,resolvePreset as r,getToolDefaultModel as s}from"./model-registry.js";import{toolManager as l,SUPPORTED_TOOLS as c}from"./tool-manager.js";import{postApplyPrompts as d}from"./post-apply.js";import{i18n as p,detectSystemLang as m}from"./i18n.js";import{createBorderLine as u,createContentLine as g}from"../utils/string-width.js";import{validateApiKey as _,fetchModels as w}from"./api-validator.js";import{CODEX_ONE_MILLION_CONTEXT_SETTING as f}from"./tools/codex.js";import{CLAUDE_DESKTOP_HIDE_OFFICIAL_LOGIN_SETTING as y}from"./tools/claude-desktop.js";import{addressesWithCurrent as h,ensureReachableGatewayAddress as z,fastestIndex as v,probeAll as k,probeSummary as x,reasonText as b,savedApiKey as C,switchGatewayAddress as S}from"../commands/base.js";import{readFileSync as M}from"fs";import{dirname as T,join as A}from"path";import{fileURLToPath as K}from"url";const N=T(K(import.meta.url)),B=t.hex("#FF8700");export class Wizard{static instance;BOX_WIDTH=63;validatedApiKeys=new Set;constructor(){}static getInstance(){return Wizard.instance||(Wizard.instance=new Wizard),Wizard.instance}createBox(e){console.log(B.bold("\n"+u("╔","╗","═",this.BOX_WIDTH))),console.log(B.bold(g(e,"║","║",this.BOX_WIDTH,"center"))),console.log(B.bold(u("╚","╝","═",this.BOX_WIDTH))),console.log("")}showOperationHints(){const e=[t.gray(p.t("wizard.hint_navigate")),t.gray(p.t("wizard.hint_confirm"))];console.log(t.gray("💡 ")+e.join(t.gray(" | "))+"\n")}async promptWithHints(t){this.showOperationHints();const a=t.map(e=>"list"!==e.type||e.pageSize?e:{...e,pageSize:20});return e.prompt(a)}printBanner(){const e=65,t=p.t("wizard.banner_subtitle"),a=g(t,"║","║",e,"center"),o=g("","║","║",e,"center"),i=g(`VibeCLI v${function(){try{return JSON.parse(M(A(N,"..","..","package.json"),"utf-8")).version}catch{return"0.0.0"}}()}`,"║","║",e,"center"),n=[" ▄▀▄ █▀▄ █ █▄█ ██▀ █ █▀▄ ██▀ █▀▄ "," █▀█ █▀ █ █ █ █▄▄ █▄▄ █▀ █▄▄ █▀▄ "].map(t=>g(t,"║","║",e,"center")),r=[u("╔","╗","═",e),o,...n,o,i,a,u("╚","╝","═",e)];console.log(B.bold("\n"+r.join("\n")))}resetScreen(){console.clear(),this.printBanner()}printGoodbye(){const e=l.getSupportedTools().filter(e=>{try{return Boolean(l.detectCurrentConfig(e.name).apiKey)}catch{return!1}});let a;if(e.length>0){const t=e.map(e=>e.command).join(" / ");a=p.t("wizard.goodbye_message_tools",{commands:t}),e.some(e=>"claude-code"===e.name)&&(a+=" "+p.t("wizard.goodbye_claude_hint"))}else a=p.t("wizard.goodbye_message");console.log(t.green("\n👋 "+a))}async runFirstTimeSetup(){const e="zh_CN"===m();e&&(o.setLang("zh_CN"),p.setLocale("zh_CN")),this.resetScreen(),console.log(B.bold("\n"+p.t("wizard.welcome"))),console.log(t.gray(p.t("wizard.privacy_note")+"\n")),e?console.log(t.gray(p.t("wizard.lang_auto_zh")+"\n")):await this.configLanguage(),await z(),await this.configApiKey()&&await this.selectAndConfigureTool(!0)}async configLanguage(){for(;;){this.resetScreen(),this.createBox(p.t("wizard.select_language"));const a=p.getLocale(),{language:i}=await this.promptWithHints([{type:"list",name:"language",message:"✨ "+p.t("wizard.select_language"),choices:[{name:"[EN] English"+("en_US"===a?t.green(" ✓ ("+p.t("wizard.current_active")+")"):""),value:"en_US"},{name:"[CN] 中文"+("zh_CN"===a?t.green(" ✓ ("+p.t("wizard.current_active")+")"):""),value:"zh_CN"},new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"back"},{name:"x "+p.t("wizard.nav_exit"),value:"exit"}],default:"zh_CN"}]);if("exit"===i)this.printGoodbye(),process.exit(0);else if("back"===i)return;return o.setLang(i),void p.setLocale(i)}}buildPresetChoices(){const a=n(),o=a.filter(e=>e.recommended),i=a.filter(e=>!e.recommended),r=e=>({name:(p.t(e.name)!==e.name?p.t(e.name):e.name)+(e.models?t.gray(` [H:${e.models.haiku} S:${e.models.sonnet} O:${e.models.opus}]`):""),value:{type:"preset",preset:e}}),s=[];return o.length>0&&(s.push(new e.Separator(t.hex("#FF8700")("── "+p.t("wizard.recommended")+" ──"))),s.push(...o.map(r))),i.length>0&&(s.push(new e.Separator(t.gray("── "+p.t("wizard.other_models")+" ──"))),s.push(...i.map(r))),s}async handleCustomModelInput(){const a=o.getModels(),{customMode:n}=await e.prompt([{type:"list",name:"customMode",message:p.t("wizard.custom_model_mode"),choices:[{name:p.t("wizard.custom_model_single"),value:"single"},{name:p.t("wizard.custom_model_per_role"),value:"per_role"}]}]);if("single"===n){const{customModel:t}=await e.prompt([{type:"input",name:"customModel",message:p.t("wizard.input_custom_model"),default:i.sonnet}]);o.setModels({haiku:t,sonnet:t,opus:t,reasoning:t})}else{const t=await e.prompt([{type:"input",name:"haiku",message:p.t("wizard.model_haiku"),default:a.haiku},{type:"input",name:"sonnet",message:p.t("wizard.model_sonnet"),default:a.sonnet},{type:"input",name:"opus",message:p.t("wizard.model_opus"),default:a.opus},{type:"input",name:"reasoning",message:p.t("wizard.model_reasoning"),default:a.reasoning}]);o.setModels(t)}console.log(t.green("\n✓ "+p.t("wizard.models_saved")))}async configModels(a){const i=o.getApiKey();if(await this.validatedKeyForConfiguration(i))for(;;){this.resetScreen(),this.createBox(p.t("wizard.config_models"));const i=[...this.buildPresetChoices()];i.push(new e.Separator),i.push({name:"✏️ "+p.t("wizard.custom_model_input"),value:{type:"custom_input"}}),i.push(new e.Separator),i.push({name:"<- "+p.t("wizard.nav_return"),value:{type:"back"}}),i.push({name:"x "+p.t("wizard.nav_exit"),value:{type:"exit"}});const{modelChoice:n}=await this.promptWithHints([{type:"list",name:"modelChoice",message:p.t("wizard.select_model_config"),choices:i}]);if("exit"===n.type)this.printGoodbye(),process.exit(0);else{if("back"===n.type)return;if("custom_input"===n.type)return await this.handleCustomModelInput(),void(a?.skipLoadPrompt||await this.promptLoadAfterModelConfig());if("preset"===n.type){const e=r(n.preset);return o.setModels(e),console.log(t.green("\n✓ "+p.t("wizard.models_saved"))),void(a?.skipLoadPrompt||await this.promptLoadAfterModelConfig())}}}else await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}async promptLoadAfterModelConfig(){const{shouldLoad:t}=await e.prompt([{type:"list",name:"shouldLoad",message:p.t("wizard.load_config_now"),choices:[{name:p.t("wizard.load_config_yes"),value:!0},{name:p.t("wizard.load_config_later"),value:!1}]}]);t&&await this.selectAndConfigureTool()}async configBaseUrl(){const i=o.getBaseUrl(),n=h(),r=a(p.t("wizard.base_testing")).start(),s=await k(n,{apiKey:C(),samples:3});r.stop();const l=v(s),c=n.map((e,a)=>{const o=e.url===i?t.cyan(` ← ${p.t("base.current_mark")}`):"";return{name:`${e.url} ${t.gray(e.label)} ${x(s[a],a===l)}${o}`,value:e.url}});c.push(new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"__back__"});const{url:d}=await this.promptWithHints([{type:"list",name:"url",message:p.t("wizard.base_select"),choices:c,default:i}]);if("__back__"===d)return;const m=s[n.findIndex(e=>e.url===d)];m.ok?await S(d):console.log(t.red(p.t("base.unreachable",{url:d,reason:b(m)}))),await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}async configApiKey(){for(;;){this.resetScreen(),this.createBox(p.t("wizard.input_api_key")),console.log(t.gray("\n💡 "+p.t("wizard.api_key_input_hint"))),console.log(t.gray(" "+p.t("wizard.api_key_get_hint",{url:"https://www.vibeapi.cn/console/token"}))),console.log();const{apiKey:i}=await e.prompt([{type:"password",name:"apiKey",message:p.t("wizard.input_your_api_key"),mask:"*"}]);if(!i||""===i.trim()){const{action:t}=await e.prompt([{type:"list",name:"action",message:p.t("wizard.select_action"),choices:[{name:p.t("wizard.retry_input"),value:"retry"},{name:"<- "+p.t("wizard.nav_return"),value:"back"}]}]);if("back"===t)return!1;continue}const n=a(p.t("wizard.validating_api_key")).start(),r=await _(i.trim());if(n.stop(),r.valid)return o.setApiKey(i.trim()),this.validatedApiKeys.add(i.trim()),console.log(t.green("\n✓ "+p.t("wizard.api_key_valid"))),!0;{this.validatedApiKeys.delete(i.trim()),"invalid_api_key"===r.error?console.log(t.red("\n✗ "+p.t("wizard.api_key_invalid"))):console.log(t.red("\n✗ "+p.t("wizard.api_key_network_error")));const{action:a}=await e.prompt([{type:"list",name:"action",message:p.t("wizard.select_action"),choices:[{name:p.t("wizard.retry_input"),value:"retry"},{name:"<- "+p.t("wizard.nav_return"),value:"back"}]}]);if("back"===a)return!1}}}async selectAndConfigureTool(t=!1){for(;;){this.resetScreen(),this.createBox(p.t("wizard.select_tool"));const a=l.getSupportedTools().map(e=>({name:e.displayName,value:e.name})),{tool:o}=await this.promptWithHints([{type:"list",name:"tool",message:"🛠️ "+p.t("wizard.select_tool"),choices:[...a,new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"back"},{name:"x "+p.t("wizard.nav_exit"),value:"exit"}]}]);if("exit"===o)this.printGoodbye(),process.exit(0);else if("back"===o)return;await this.configureTool(o,t)}}async configureTool(a,o=!1){const i=c[a];if(i){if(!l.isToolInstalled(a)){console.log(t.yellow("\n"+p.t("wizard.tool_not_installed",{tool:i.displayName})));const{install:o}=await e.prompt([{type:"confirm",name:"install",message:p.t("wizard.install_tool_confirm"),default:!0}]);if(!o)return;try{await l.installTool(a)}catch{return void console.log(t.red(p.t("wizard.install_failed")))}}o?await this.configureToolModel(a)&&await this.loadConfig(a):await this.showToolMenu(a)}}async showToolMenu(t){for(;;){this.resetScreen();const a=c[t];if(!a)return;this.createBox(a.displayName+" "+p.t("wizard.menu_title"));const o=[{name:"📥 "+p.t("wizard.action_load_config",{tool:a.displayName}),value:"load"},{name:"📤 "+p.t("wizard.action_unload_config",{tool:a.displayName}),value:"unload"}];l.supportsClearPinnedModels(t)&&o.push({name:"🧹 "+p.t("wizard.action_clear_model",{tool:a.displayName}),value:"clear-model"}),o.push({name:"🧨 "+p.t("wizard.action_force_config",{tool:a.displayName}),value:"force"},{name:"↩️ "+p.t("wizard.action_restore_config",{tool:a.displayName}),value:"restore"},new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"back"},{name:"x "+p.t("wizard.nav_exit"),value:"exit"});const{action:i}=await this.promptWithHints([{type:"list",name:"action",message:"⚙️ "+p.t("wizard.select_action"),choices:o}]);if("exit"===i)this.printGoodbye(),process.exit(0);else{if("back"===i)return;"load"===i?await this.configureToolModel(t)&&await this.loadConfig(t):"force"===i?await this.forceConfig(t):"unload"===i?await this.unloadConfig(t):"clear-model"===i?await this.clearPinnedModels(t):"restore"===i&&await this.restoreConfig(t)}}}singleModelOverride(e){const t=e.trim();return/claude/i.test(t)?{opus:t}:{haiku:t,sonnet:t,opus:t,reasoning:t}}hasConfiguredApiKey(){return!!o.getApiKey()?.trim()||o.listToolApiKeys().some(e=>Boolean(o.getApiKeyForTool(e)?.trim()))}async validatedKeyForConfiguration(e){const o=e?.trim();if(!o)return console.log(t.red("\n"+p.t("wizard.api_key_required"))),console.log(t.yellow(p.t("wizard.please_config_api_key_first"))),null;if(this.validatedApiKeys.has(o))return o;const i=a(p.t("wizard.validating_api_key")).start(),n=await _(o);if(n.valid)return this.validatedApiKeys.add(o),i.succeed(p.t("wizard.api_key_valid")),o;this.validatedApiKeys.delete(o);const r="invalid_api_key"===n.error?p.t("wizard.api_key_invalid"):p.t("wizard.api_key_network_error");return i.fail(r),console.log(t.red("\n"+p.t("wizard.please_reconfig_api_key"))),null}async configureToolModel(i){const n=c[i];if(!n)return!1;const l=await this.validatedKeyForConfiguration(o.getApiKeyForTool(i));if(!l)return await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}]),!1;const d="claude-code"===i,m=s(i),u=d||!m?p.t("wizard.model_builtin_default"):m;this.resetScreen(),this.createBox(n.displayName+" · "+p.t("wizard.config_models"));const g=[{name:"✅ "+p.t("wizard.use_default_model",{model:u}),value:{type:"default"}},{name:"🌐 "+p.t("wizard.fetch_models_from_api"),value:{type:"fetch"}},...this.buildPresetChoices(),new e.Separator,{name:"✏️ "+p.t("wizard.input_custom_model"),value:{type:"custom"}},new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:{type:"back"}}],{choice:_}=await this.promptWithHints([{type:"list",name:"choice",message:p.t("wizard.select_tool_model",{tool:n.displayName}),choices:g}]);if("back"===_.type)return!1;if("default"===_.type)o.setToolModel(i,null);else if("preset"===_.type)o.setToolModel(i,r(_.preset));else if("custom"===_.type){const{model:t}=await e.prompt([{type:"input",name:"model",message:p.t("wizard.input_custom_model"),default:!d&&m?m:void 0}]),a=(t||"").trim();o.setToolModel(i,a?this.singleModelOverride(a):null)}else if("fetch"===_.type){const n=a(p.t("wizard.fetching_models")).start(),r=await w(l);let s;if(n.stop(),r.ok&&r.models.length>0){const{model:t}=await e.prompt([{type:"list",name:"model",message:p.t("wizard.select_fetched_model"),pageSize:20,choices:[...r.models,new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"__back__"}]}]);if("__back__"===t)return!1;s=t}else{console.log(t.yellow("\n"+p.t("wizard.fetch_models_failed")));const{model:a}=await e.prompt([{type:"input",name:"model",message:p.t("wizard.input_custom_model"),default:!d&&m?m:void 0}]);s=(a||"").trim()}o.setToolModel(i,s?this.singleModelOverride(s):null)}if("codex"===i){const t=o.getToolSetting(i,f),{enableOneMillionContext:a}=await e.prompt([{type:"confirm",name:"enableOneMillionContext",message:p.t("wizard.codex_enable_1m_context"),default:!1!==t}]);o.setToolSetting(i,f,Boolean(a))}if("claude-desktop"===i){const t=o.getToolSetting(i,y),{hideOfficialLogin:a}=await e.prompt([{type:"confirm",name:"hideOfficialLogin",message:p.t("wizard.desktop_hide_official_login"),default:!1!==t}]);o.setToolSetting(i,y,Boolean(a))}return console.log(t.green("\n✓ "+p.t("wizard.models_saved"))),d&&console.log(t.gray("💡 "+p.t("wizard.claude_model_hint"))),!0}async forceConfig(t){const a=c[t]?.displayName||t,{confirm:o}=await e.prompt([{type:"confirm",name:"confirm",message:p.t("config.confirm_force",{tool:a}),default:!1}]);o&&await this.loadConfig(t,{force:!0})}async loadConfig(i,n={}){const r=o.getModelsForTool(i),s=await this.validatedKeyForConfiguration(o.getApiKeyForTool(i));if(!s)return void await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}]);const m=a(p.t("wizard.loading_config")).start();try{await l.applyPrivateConfig(i,s,r,n),m.stop(),l.printApplied(i),await d([i]),n.force&&console.log(t.yellow(p.t("config.force_done",{tool:c[i]?.displayName||i})));const a=c[i]?.command;a&&console.log(t.green("\n"+p.t("wizard.run_tool_hint",{command:a})));const{nextAction:o}=await e.prompt([{type:"list",name:"nextAction",message:p.t("wizard.what_next"),choices:[{name:p.t("wizard.exit_and_start"),value:"exit"},{name:p.t("wizard.continue_config"),value:"continue"}]}]);"exit"===o&&(this.printGoodbye(),process.exit(0))}catch(a){m.fail(p.t("wizard.config_failed")),console.log(t.red(a instanceof Error?a.message:String(a))),await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}}async clearPinnedModels(a){const o=c[a]?.displayName||a,{confirm:i}=await e.prompt([{type:"confirm",name:"confirm",message:p.t("wizard.confirm_clear_model",{tool:o}),default:!1}]);if(i){try{const e=await l.clearPinnedModels(a);0===e.length?console.log(t.yellow("\n"+p.t("config.clear_model_none",{tool:o}))):(console.log(t.green("\n✓ "+p.t("config.clear_model_done",{tool:o}))),e.forEach(e=>console.log(t.gray(` - ${e}`))),console.log(t.gray(p.t("config.clear_model_restart_hint",{tool:o}))))}catch(e){console.log(t.red("\n"+(e instanceof Error?e.message:String(e))))}await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}}async unloadConfig(o){const{confirm:i}=await e.prompt([{type:"confirm",name:"confirm",message:p.t("wizard.confirm_unload_config",{tool:c[o]?.displayName||o}),default:!1}]);if(!i)return;const n=a(p.t("wizard.unloading_config")).start();try{l.unloadPrivateConfig(o),n.succeed(p.t("wizard.config_unloaded"));const{nextAction:t}=await e.prompt([{type:"list",name:"nextAction",message:p.t("wizard.what_next"),choices:[{name:p.t("wizard.exit_and_start"),value:"exit"},{name:p.t("wizard.continue_config"),value:"continue"}]}]);"exit"===t&&(this.printGoodbye(),process.exit(0))}catch(a){n.fail(p.t("wizard.config_unload_failed")),console.log(t.red(a instanceof Error?a.message:String(a))),await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}}async restoreConfig(o){const i=c[o]?.displayName||o,{confirm:n}=await e.prompt([{type:"confirm",name:"confirm",message:p.t("wizard.confirm_restore_config",{tool:i}),default:!1}]);if(!n)return;const r=a(p.t("wizard.restoring_config")).start();try{const e=l.restorePrivateConfig(o).filter(e=>e.result.restored);0===e.length?r.warn(p.t("wizard.restore_no_backup")):(r.succeed(p.t("wizard.config_restored",{tool:i})),e.forEach(e=>console.log(t.gray(` ${e.file} ← ${e.result.from}`))))}catch(e){r.fail(p.t("wizard.config_restore_failed")),console.log(t.red(e instanceof Error?e.message:String(e)))}await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}async run(){await this.showMainMenu()}async showMainMenu(){if(this.hasConfiguredApiKey())for(;;){this.resetScreen();const a=o.getApiKey()||"",i=a.length>4?"sk-****"+a.slice(-4):"****";console.log(t.gray(` 🔑 API Key: ${i}`)+t.green(" ✓")),console.log("");const n=l.getSupportedTools().map(e=>({name:"🛠️ "+e.displayName,value:{type:"tool",tool:e.name}})),r=[new e.Separator(B("── "+p.t("wizard.select_tool")+" ──")),...n,new e.Separator(t.gray("── "+p.t("wizard.settings")+" ──")),{name:"🔑 "+p.t("wizard.menu_change_api_key"),value:{type:"apikey"}},{name:"🔗 "+p.t("wizard.menu_base_url",{url:o.getBaseUrl()}),value:{type:"base"}},{name:"🌐 "+p.t("wizard.menu_config_language"),value:{type:"language"}},new e.Separator,{name:"x "+p.t("wizard.nav_exit"),value:{type:"exit"}}],{action:s}=await this.promptWithHints([{type:"list",name:"action",message:"🛠️ "+p.t("wizard.select_tool"),choices:r}]);"exit"===s.type?(this.printGoodbye(),process.exit(0)):"tool"===s.type?await this.configureTool(s.tool):"apikey"===s.type?await this.configApiKey():"base"===s.type?await this.configBaseUrl():"language"===s.type&&await this.configLanguage()}else await this.runFirstTimeSetup()}}export const wizard=Wizard.getInstance();
|
|
1
|
+
import e from"inquirer";import t from"chalk";import a from"ora";import{configManager as o,DEFAULT_MODELS as i}from"./config.js";import{getPresets as n,resolvePreset as r,getToolDefaultModel as s}from"./model-registry.js";import{toolManager as l,SUPPORTED_TOOLS as c}from"./tool-manager.js";import{postApplyPrompts as d}from"./post-apply.js";import{i18n as p,detectSystemLang as m}from"./i18n.js";import{createBorderLine as u,createContentLine as _}from"../utils/string-width.js";import{validateApiKey as g,fetchModels as w}from"./api-validator.js";import{CODEX_ONE_MILLION_CONTEXT_SETTING as f}from"./tools/codex.js";import{CLAUDE_DESKTOP_HIDE_OFFICIAL_LOGIN_SETTING as y}from"./tools/claude-desktop.js";import{addressesWithCurrent as h,ensureReachableGatewayAddress as z,fastestIndex as v,probeAll as k,probeSummary as x,reasonText as b,savedApiKey as S,switchGatewayAddress as C}from"../commands/base.js";import{readFileSync as M}from"fs";import{dirname as T,join as A}from"path";import{fileURLToPath as K}from"url";const N=T(K(import.meta.url)),B=t.hex("#FF8700");export class Wizard{static instance;BOX_WIDTH=63;validatedApiKeys=new Set;constructor(){}static getInstance(){return Wizard.instance||(Wizard.instance=new Wizard),Wizard.instance}createBox(e){console.log(B.bold("\n"+u("╔","╗","═",this.BOX_WIDTH))),console.log(B.bold(_(e,"║","║",this.BOX_WIDTH,"center"))),console.log(B.bold(u("╚","╝","═",this.BOX_WIDTH))),console.log("")}showOperationHints(){const e=[t.gray(p.t("wizard.hint_navigate")),t.gray(p.t("wizard.hint_confirm"))];console.log(t.gray("💡 ")+e.join(t.gray(" | "))+"\n")}async promptWithHints(t){this.showOperationHints();const a=t.map(e=>"list"!==e.type||e.pageSize?e:{...e,pageSize:20});return e.prompt(a)}printBanner(){const e=60,t=p.t("wizard.banner_subtitle"),a=_(t,"║","║",e,"center"),o=_("","║","║",e,"center"),i=_(`VibeCLI v${function(){try{return JSON.parse(M(A(N,"..","..","package.json"),"utf-8")).version}catch{return"0.0.0"}}()}`,"║","║",e,"center"),n=[String.raw`__ ___ _ ____ _ ___ `,String.raw`\ \ / (_) |__ ___ / ___| | |_ _|`,String.raw` \ \ / /| | '_ \ / _ \ | | | | | `,String.raw` \ V / | | |_) | __/ |___| |___ | | `,String.raw` \_/ |_|_.__/ \___|\____|_____|___|`],r=Math.max(...n.map(e=>e.length)),s=" ".repeat(Math.floor((58-r)/2)),l=n.map(t=>_(s+t,"║","║",e,"left")),c=[u("╔","╗","═",e),o,...l,o,i,a,u("╚","╝","═",e)];console.log(B.bold("\n"+c.join("\n")))}resetScreen(){console.clear(),this.printBanner()}printGoodbye(){const e=l.getSupportedTools().filter(e=>{try{return Boolean(l.detectCurrentConfig(e.name).apiKey)}catch{return!1}});let a;if(e.length>0){const t=e.map(e=>e.command).join(" / ");a=p.t("wizard.goodbye_message_tools",{commands:t}),e.some(e=>"claude-code"===e.name)&&(a+=" "+p.t("wizard.goodbye_claude_hint"))}else a=p.t("wizard.goodbye_message");console.log(t.green("\n👋 "+a))}async runFirstTimeSetup(){const e="zh_CN"===m();e&&(o.setLang("zh_CN"),p.setLocale("zh_CN")),this.resetScreen(),console.log(B.bold("\n"+p.t("wizard.welcome"))),console.log(t.gray(p.t("wizard.privacy_note")+"\n")),e?console.log(t.gray(p.t("wizard.lang_auto_zh")+"\n")):await this.configLanguage(),await z(),await this.configApiKey()&&await this.selectAndConfigureTool(!0)}async configLanguage(){for(;;){this.resetScreen(),this.createBox(p.t("wizard.select_language"));const a=p.getLocale(),{language:i}=await this.promptWithHints([{type:"list",name:"language",message:"✨ "+p.t("wizard.select_language"),choices:[{name:"[EN] English"+("en_US"===a?t.green(" ✓ ("+p.t("wizard.current_active")+")"):""),value:"en_US"},{name:"[CN] 中文"+("zh_CN"===a?t.green(" ✓ ("+p.t("wizard.current_active")+")"):""),value:"zh_CN"},new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"back"},{name:"x "+p.t("wizard.nav_exit"),value:"exit"}],default:"zh_CN"}]);if("exit"===i)this.printGoodbye(),process.exit(0);else if("back"===i)return;return o.setLang(i),void p.setLocale(i)}}buildPresetChoices(){const a=n(),o=a.filter(e=>e.recommended),i=a.filter(e=>!e.recommended),r=e=>({name:(p.t(e.name)!==e.name?p.t(e.name):e.name)+(e.models?t.gray(` [H:${e.models.haiku} S:${e.models.sonnet} O:${e.models.opus}]`):""),value:{type:"preset",preset:e}}),s=[];return o.length>0&&(s.push(new e.Separator(t.hex("#FF8700")("── "+p.t("wizard.recommended")+" ──"))),s.push(...o.map(r))),i.length>0&&(s.push(new e.Separator(t.gray("── "+p.t("wizard.other_models")+" ──"))),s.push(...i.map(r))),s}async handleCustomModelInput(){const a=o.getModels(),{customMode:n}=await e.prompt([{type:"list",name:"customMode",message:p.t("wizard.custom_model_mode"),choices:[{name:p.t("wizard.custom_model_single"),value:"single"},{name:p.t("wizard.custom_model_per_role"),value:"per_role"}]}]);if("single"===n){const{customModel:t}=await e.prompt([{type:"input",name:"customModel",message:p.t("wizard.input_custom_model"),default:i.sonnet}]);o.setModels({haiku:t,sonnet:t,opus:t,reasoning:t})}else{const t=await e.prompt([{type:"input",name:"haiku",message:p.t("wizard.model_haiku"),default:a.haiku},{type:"input",name:"sonnet",message:p.t("wizard.model_sonnet"),default:a.sonnet},{type:"input",name:"opus",message:p.t("wizard.model_opus"),default:a.opus},{type:"input",name:"reasoning",message:p.t("wizard.model_reasoning"),default:a.reasoning}]);o.setModels(t)}console.log(t.green("\n✓ "+p.t("wizard.models_saved")))}async configModels(a){const i=o.getApiKey();if(await this.validatedKeyForConfiguration(i))for(;;){this.resetScreen(),this.createBox(p.t("wizard.config_models"));const i=[...this.buildPresetChoices()];i.push(new e.Separator),i.push({name:"✏️ "+p.t("wizard.custom_model_input"),value:{type:"custom_input"}}),i.push(new e.Separator),i.push({name:"<- "+p.t("wizard.nav_return"),value:{type:"back"}}),i.push({name:"x "+p.t("wizard.nav_exit"),value:{type:"exit"}});const{modelChoice:n}=await this.promptWithHints([{type:"list",name:"modelChoice",message:p.t("wizard.select_model_config"),choices:i}]);if("exit"===n.type)this.printGoodbye(),process.exit(0);else{if("back"===n.type)return;if("custom_input"===n.type)return await this.handleCustomModelInput(),void(a?.skipLoadPrompt||await this.promptLoadAfterModelConfig());if("preset"===n.type){const e=r(n.preset);return o.setModels(e),console.log(t.green("\n✓ "+p.t("wizard.models_saved"))),void(a?.skipLoadPrompt||await this.promptLoadAfterModelConfig())}}}else await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}async promptLoadAfterModelConfig(){const{shouldLoad:t}=await e.prompt([{type:"list",name:"shouldLoad",message:p.t("wizard.load_config_now"),choices:[{name:p.t("wizard.load_config_yes"),value:!0},{name:p.t("wizard.load_config_later"),value:!1}]}]);t&&await this.selectAndConfigureTool()}async configBaseUrl(){const i=o.getBaseUrl(),n=h(),r=a(p.t("wizard.base_testing")).start(),s=await k(n,{apiKey:S(),samples:3});r.stop();const l=v(s),c=n.map((e,a)=>{const o=e.url===i?t.cyan(` ← ${p.t("base.current_mark")}`):"";return{name:`${e.url} ${t.gray(e.label)} ${x(s[a],a===l)}${o}`,value:e.url}});c.push(new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"__back__"});const{url:d}=await this.promptWithHints([{type:"list",name:"url",message:p.t("wizard.base_select"),choices:c,default:i}]);if("__back__"===d)return;const m=s[n.findIndex(e=>e.url===d)];m.ok?await C(d):console.log(t.red(p.t("base.unreachable",{url:d,reason:b(m)}))),await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}async configApiKey(){for(;;){this.resetScreen(),this.createBox(p.t("wizard.input_api_key")),console.log(t.gray("\n💡 "+p.t("wizard.api_key_input_hint"))),console.log(t.gray(" "+p.t("wizard.api_key_get_hint",{url:"https://www.vibeapi.cn/console/token"}))),console.log();const{apiKey:i}=await e.prompt([{type:"password",name:"apiKey",message:p.t("wizard.input_your_api_key"),mask:"*"}]);if(!i||""===i.trim()){const{action:t}=await e.prompt([{type:"list",name:"action",message:p.t("wizard.select_action"),choices:[{name:p.t("wizard.retry_input"),value:"retry"},{name:"<- "+p.t("wizard.nav_return"),value:"back"}]}]);if("back"===t)return!1;continue}const n=a(p.t("wizard.validating_api_key")).start(),r=await g(i.trim());if(n.stop(),r.valid)return o.setApiKey(i.trim()),this.validatedApiKeys.add(i.trim()),console.log(t.green("\n✓ "+p.t("wizard.api_key_valid"))),!0;{this.validatedApiKeys.delete(i.trim()),"invalid_api_key"===r.error?console.log(t.red("\n✗ "+p.t("wizard.api_key_invalid"))):console.log(t.red("\n✗ "+p.t("wizard.api_key_network_error")));const{action:a}=await e.prompt([{type:"list",name:"action",message:p.t("wizard.select_action"),choices:[{name:p.t("wizard.retry_input"),value:"retry"},{name:"<- "+p.t("wizard.nav_return"),value:"back"}]}]);if("back"===a)return!1}}}async selectAndConfigureTool(t=!1){for(;;){this.resetScreen(),this.createBox(p.t("wizard.select_tool"));const a=l.getSupportedTools().map(e=>({name:e.displayName,value:e.name})),{tool:o}=await this.promptWithHints([{type:"list",name:"tool",message:"🛠️ "+p.t("wizard.select_tool"),choices:[...a,new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"back"},{name:"x "+p.t("wizard.nav_exit"),value:"exit"}]}]);if("exit"===o)this.printGoodbye(),process.exit(0);else if("back"===o)return;await this.configureTool(o,t)}}async configureTool(a,o=!1){const i=c[a];if(i){if(!l.isToolInstalled(a)){console.log(t.yellow("\n"+p.t("wizard.tool_not_installed",{tool:i.displayName})));const{install:o}=await e.prompt([{type:"confirm",name:"install",message:p.t("wizard.install_tool_confirm"),default:!0}]);if(!o)return;try{await l.installTool(a)}catch{return void console.log(t.red(p.t("wizard.install_failed")))}}o?await this.configureToolModel(a)&&await this.loadConfig(a):await this.showToolMenu(a)}}async showToolMenu(t){for(;;){this.resetScreen();const a=c[t];if(!a)return;this.createBox(a.displayName+" "+p.t("wizard.menu_title"));const o=[{name:"📥 "+p.t("wizard.action_load_config",{tool:a.displayName}),value:"load"},{name:"📤 "+p.t("wizard.action_unload_config",{tool:a.displayName}),value:"unload"}];l.supportsClearPinnedModels(t)&&o.push({name:"🧹 "+p.t("wizard.action_clear_model",{tool:a.displayName}),value:"clear-model"}),o.push({name:"🧨 "+p.t("wizard.action_force_config",{tool:a.displayName}),value:"force"},{name:"↩️ "+p.t("wizard.action_restore_config",{tool:a.displayName}),value:"restore"},new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"back"},{name:"x "+p.t("wizard.nav_exit"),value:"exit"});const{action:i}=await this.promptWithHints([{type:"list",name:"action",message:"⚙️ "+p.t("wizard.select_action"),choices:o}]);if("exit"===i)this.printGoodbye(),process.exit(0);else{if("back"===i)return;"load"===i?await this.configureToolModel(t)&&await this.loadConfig(t):"force"===i?await this.forceConfig(t):"unload"===i?await this.unloadConfig(t):"clear-model"===i?await this.clearPinnedModels(t):"restore"===i&&await this.restoreConfig(t)}}}singleModelOverride(e){const t=e.trim();return/claude/i.test(t)?{opus:t}:{haiku:t,sonnet:t,opus:t,reasoning:t}}hasConfiguredApiKey(){return!!o.getApiKey()?.trim()||o.listToolApiKeys().some(e=>Boolean(o.getApiKeyForTool(e)?.trim()))}async validatedKeyForConfiguration(e){const o=e?.trim();if(!o)return console.log(t.red("\n"+p.t("wizard.api_key_required"))),console.log(t.yellow(p.t("wizard.please_config_api_key_first"))),null;if(this.validatedApiKeys.has(o))return o;const i=a(p.t("wizard.validating_api_key")).start(),n=await g(o);if(n.valid)return this.validatedApiKeys.add(o),i.succeed(p.t("wizard.api_key_valid")),o;this.validatedApiKeys.delete(o);const r="invalid_api_key"===n.error?p.t("wizard.api_key_invalid"):p.t("wizard.api_key_network_error");return i.fail(r),console.log(t.red("\n"+p.t("wizard.please_reconfig_api_key"))),null}async configureToolModel(i){const n=c[i];if(!n)return!1;const l=await this.validatedKeyForConfiguration(o.getApiKeyForTool(i));if(!l)return await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}]),!1;const d="claude-code"===i,m=s(i),u=d||!m?p.t("wizard.model_builtin_default"):m;this.resetScreen(),this.createBox(n.displayName+" · "+p.t("wizard.config_models"));const _=[{name:"✅ "+p.t("wizard.use_default_model",{model:u}),value:{type:"default"}},{name:"🌐 "+p.t("wizard.fetch_models_from_api"),value:{type:"fetch"}},...this.buildPresetChoices(),new e.Separator,{name:"✏️ "+p.t("wizard.input_custom_model"),value:{type:"custom"}},new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:{type:"back"}}],{choice:g}=await this.promptWithHints([{type:"list",name:"choice",message:p.t("wizard.select_tool_model",{tool:n.displayName}),choices:_}]);if("back"===g.type)return!1;if("default"===g.type)o.setToolModel(i,null);else if("preset"===g.type)o.setToolModel(i,r(g.preset));else if("custom"===g.type){const{model:t}=await e.prompt([{type:"input",name:"model",message:p.t("wizard.input_custom_model"),default:!d&&m?m:void 0}]),a=(t||"").trim();o.setToolModel(i,a?this.singleModelOverride(a):null)}else if("fetch"===g.type){const n=a(p.t("wizard.fetching_models")).start(),r=await w(l);let s;if(n.stop(),r.ok&&r.models.length>0){const{model:t}=await e.prompt([{type:"list",name:"model",message:p.t("wizard.select_fetched_model"),pageSize:20,choices:[...r.models,new e.Separator,{name:"<- "+p.t("wizard.nav_return"),value:"__back__"}]}]);if("__back__"===t)return!1;s=t}else{console.log(t.yellow("\n"+p.t("wizard.fetch_models_failed")));const{model:a}=await e.prompt([{type:"input",name:"model",message:p.t("wizard.input_custom_model"),default:!d&&m?m:void 0}]);s=(a||"").trim()}o.setToolModel(i,s?this.singleModelOverride(s):null)}if("codex"===i){const t=o.getToolSetting(i,f),{enableOneMillionContext:a}=await e.prompt([{type:"confirm",name:"enableOneMillionContext",message:p.t("wizard.codex_enable_1m_context"),default:!1!==t}]);o.setToolSetting(i,f,Boolean(a))}if("claude-desktop"===i){const t=o.getToolSetting(i,y),{hideOfficialLogin:a}=await e.prompt([{type:"confirm",name:"hideOfficialLogin",message:p.t("wizard.desktop_hide_official_login"),default:!1!==t}]);o.setToolSetting(i,y,Boolean(a))}return console.log(t.green("\n✓ "+p.t("wizard.models_saved"))),d&&console.log(t.gray("💡 "+p.t("wizard.claude_model_hint"))),!0}async forceConfig(t){const a=c[t]?.displayName||t,{confirm:o}=await e.prompt([{type:"confirm",name:"confirm",message:p.t("config.confirm_force",{tool:a}),default:!1}]);o&&await this.loadConfig(t,{force:!0})}async loadConfig(i,n={}){const r=o.getModelsForTool(i),s=await this.validatedKeyForConfiguration(o.getApiKeyForTool(i));if(!s)return void await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}]);const m=a(p.t("wizard.loading_config")).start();try{await l.applyPrivateConfig(i,s,r,n),m.stop(),l.printApplied(i),await d([i]),n.force&&console.log(t.yellow(p.t("config.force_done",{tool:c[i]?.displayName||i})));const a=c[i]?.command;a&&console.log(t.green("\n"+p.t("wizard.run_tool_hint",{command:a})));const{nextAction:o}=await e.prompt([{type:"list",name:"nextAction",message:p.t("wizard.what_next"),choices:[{name:p.t("wizard.exit_and_start"),value:"exit"},{name:p.t("wizard.continue_config"),value:"continue"}]}]);"exit"===o&&(this.printGoodbye(),process.exit(0))}catch(a){m.fail(p.t("wizard.config_failed")),console.log(t.red(a instanceof Error?a.message:String(a))),await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}}async clearPinnedModels(a){const o=c[a]?.displayName||a,{confirm:i}=await e.prompt([{type:"confirm",name:"confirm",message:p.t("wizard.confirm_clear_model",{tool:o}),default:!1}]);if(i){try{const e=await l.clearPinnedModels(a);0===e.length?console.log(t.yellow("\n"+p.t("config.clear_model_none",{tool:o}))):(console.log(t.green("\n✓ "+p.t("config.clear_model_done",{tool:o}))),e.forEach(e=>console.log(t.gray(` - ${e}`))),console.log(t.gray(p.t("config.clear_model_restart_hint",{tool:o}))))}catch(e){console.log(t.red("\n"+(e instanceof Error?e.message:String(e))))}await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}}async unloadConfig(o){const{confirm:i}=await e.prompt([{type:"confirm",name:"confirm",message:p.t("wizard.confirm_unload_config",{tool:c[o]?.displayName||o}),default:!1}]);if(!i)return;const n=a(p.t("wizard.unloading_config")).start();try{l.unloadPrivateConfig(o),n.succeed(p.t("wizard.config_unloaded"));const{nextAction:t}=await e.prompt([{type:"list",name:"nextAction",message:p.t("wizard.what_next"),choices:[{name:p.t("wizard.exit_and_start"),value:"exit"},{name:p.t("wizard.continue_config"),value:"continue"}]}]);"exit"===t&&(this.printGoodbye(),process.exit(0))}catch(a){n.fail(p.t("wizard.config_unload_failed")),console.log(t.red(a instanceof Error?a.message:String(a))),await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}}async restoreConfig(o){const i=c[o]?.displayName||o,{confirm:n}=await e.prompt([{type:"confirm",name:"confirm",message:p.t("wizard.confirm_restore_config",{tool:i}),default:!1}]);if(!n)return;const r=a(p.t("wizard.restoring_config")).start();try{const e=l.restorePrivateConfig(o).filter(e=>e.result.restored);0===e.length?r.warn(p.t("wizard.restore_no_backup")):(r.succeed(p.t("wizard.config_restored",{tool:i})),e.forEach(e=>console.log(t.gray(` ${e.file} ← ${e.result.from}`))))}catch(e){r.fail(p.t("wizard.config_restore_failed")),console.log(t.red(e instanceof Error?e.message:String(e)))}await e.prompt([{type:"input",name:"continue",message:p.t("wizard.press_enter")}])}async run(){await this.showMainMenu()}async showMainMenu(){if(this.hasConfiguredApiKey())for(;;){this.resetScreen();const a=o.getApiKey()||"",i=a.length>4?"sk-****"+a.slice(-4):"****";console.log(t.gray(` 🔑 API Key: ${i}`)+t.green(" ✓")),console.log("");const n=l.getSupportedTools().map(e=>({name:"🛠️ "+e.displayName,value:{type:"tool",tool:e.name}})),r=[new e.Separator(B("── "+p.t("wizard.select_tool")+" ──")),...n,new e.Separator(t.gray("── "+p.t("wizard.settings")+" ──")),{name:"🔑 "+p.t("wizard.menu_change_api_key"),value:{type:"apikey"}},{name:"🔗 "+p.t("wizard.menu_base_url",{url:o.getBaseUrl()}),value:{type:"base"}},{name:"🌐 "+p.t("wizard.menu_config_language"),value:{type:"language"}},new e.Separator,{name:"x "+p.t("wizard.nav_exit"),value:{type:"exit"}}],{action:s}=await this.promptWithHints([{type:"list",name:"action",message:"🛠️ "+p.t("wizard.select_tool"),choices:r}]);"exit"===s.type?(this.printGoodbye(),process.exit(0)):"tool"===s.type?await this.configureTool(s.tool):"apikey"===s.type?await this.configApiKey():"base"===s.type?await this.configBaseUrl():"language"===s.type&&await this.configLanguage()}else await this.runFirstTimeSetup()}}export const wizard=Wizard.getInstance();
|
package/dist/locales/en_US.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": {
|
|
3
3
|
"error_unknown": "Unknown command: {{command}}",
|
|
4
|
-
"error_general": "Error:"
|
|
4
|
+
"error_general": "Error:",
|
|
5
|
+
"unknown_hint": "Next: run vibecli --help to see the available commands",
|
|
6
|
+
"unknown_hint_suggestion": "Did you mean vibecli {{command}}?",
|
|
7
|
+
"err_unknown_option": "Unknown option: {{name}}",
|
|
8
|
+
"err_missing_argument": "Missing argument: {{name}}",
|
|
9
|
+
"err_missing_option": "Missing required option: {{name}}",
|
|
10
|
+
"unknown_option_hint": "Next: run vibecli {{command}} --help to see the correct usage"
|
|
5
11
|
},
|
|
6
12
|
"lang": {
|
|
7
13
|
"current": "Current language",
|
|
@@ -328,6 +334,7 @@
|
|
|
328
334
|
"codex_1m_disabled": "Codex 1M context is disabled",
|
|
329
335
|
"codex_1m_missing_key": "No saved Codex API key was found; run vibecli setup --codexkey <your key> (or --key) first",
|
|
330
336
|
"validating": "Validating API key for {{label}}...",
|
|
337
|
+
"unreachable": "Cannot reach the gateway address {{url}} ({{reason}})",
|
|
331
338
|
"invalid_key": "API key for {{label}} is invalid: {{reason}}",
|
|
332
339
|
"probe_failed": "Capability probe for {{label}} failed (network); continuing as if all families are available",
|
|
333
340
|
"key_no_claude": "{{label}} cannot access Claude models (token group excludes Claude); skipped {{tool}}",
|
|
@@ -360,8 +367,7 @@
|
|
|
360
367
|
"version_outdated": "version {{current}} is too old (needs {{min}} or later); upgrade with {{upgrade}}",
|
|
361
368
|
"agy": {
|
|
362
369
|
"menu_written": "{{count}} models in the menu ({{list}}), default {{default}}",
|
|
363
|
-
"
|
|
364
|
-
"reopen_terminal_windows": "Key and address were saved as user environment variables; reopen the terminal before running agy"
|
|
370
|
+
"effort_after_reopen": "agy works right away; in a new terminal the model menu also offers thinking levels (low / medium / high)"
|
|
365
371
|
},
|
|
366
372
|
"grok": {
|
|
367
373
|
"menu_written": "{{count}} models in the menu ({{list}}), default {{default}}",
|
|
@@ -496,7 +502,9 @@
|
|
|
496
502
|
"learn_more": {
|
|
497
503
|
"command_help": "Usage and examples for one command",
|
|
498
504
|
"docs": "Online docs: {{url}}",
|
|
499
|
-
"all_commands": "List every command"
|
|
505
|
+
"all_commands": "List every command",
|
|
506
|
+
"exit_codes": "See exit codes and the --json error format",
|
|
507
|
+
"environment": "See the environment variables VibeCLI reads"
|
|
500
508
|
},
|
|
501
509
|
"title": {
|
|
502
510
|
"usage": "Usage:",
|
|
@@ -539,7 +547,7 @@
|
|
|
539
547
|
},
|
|
540
548
|
"setup": {
|
|
541
549
|
"summary": "Configure tools in one command (picked by the models your key can use)",
|
|
542
|
-
"description": "Write the configs in one command, without the wizard.\n--key configures the tools that match the models the key can use (see below).\nSeparate keys: --claudekey / --codexkey / --grokkey / --desktopkey / --agykey
|
|
550
|
+
"description": "Write the configs in one command, without the wizard.\n--key configures the tools that match the models the key can use (see below).\nSeparate keys: --claudekey / --codexkey / --grokkey / --desktopkey / --agykey.\nRun it again to change the key; your other settings stay.",
|
|
543
551
|
"opt": {
|
|
544
552
|
"key": "One key; configures every tool its models can serve",
|
|
545
553
|
"claudekey": "Key just for Claude Code",
|
|
@@ -884,5 +892,21 @@
|
|
|
884
892
|
"back_to_index": "Command list",
|
|
885
893
|
"use_instead": "Use it instead when"
|
|
886
894
|
}
|
|
895
|
+
},
|
|
896
|
+
"errors": {
|
|
897
|
+
"next_step": "Next: {{command}}",
|
|
898
|
+
"hint_logs": "Next: run vibecli logs tail to inspect the detailed log",
|
|
899
|
+
"cancelled": "Operation cancelled",
|
|
900
|
+
"cancel_hint": "Next: run vibecli to start again"
|
|
901
|
+
},
|
|
902
|
+
"help_topics": {
|
|
903
|
+
"exit_codes": {
|
|
904
|
+
"title": "Exit codes and error output",
|
|
905
|
+
"body": "Exit codes:\n 0 success\n 1 operation failed\n 2 usage or input error\n 3 authentication failed (invalid or rejected key)\n 4 network problem (DNS, certificate, timeout, or unreachable gateway)\n 5 internal error\n 10 confirmation required (--yes is needed in non-interactive mode)\n 130 cancelled by the user\n\nWith --json, successful output keeps its existing format. Failures write one JSON object to stderr:\n{\"ok\":false,\"error\":{\"type\":\"usage\",\"message\":\"…\",\"hint\":\"…\",\"subtype\":\"…\"}}"
|
|
906
|
+
},
|
|
907
|
+
"environment": {
|
|
908
|
+
"title": "Environment variables",
|
|
909
|
+
"body": "VibeCLI reads these environment variables:\n VIBECLI_DISABLE_AUTO_UPDATE=1 disable the startup update check\n VIBECLI_DISABLE_MODEL_REFRESH=1 disable the startup model refresh\n VIBECLI_CONFIG_DIR=<directory> set the VibeCLI config directory\n VIBECLI_SKIP_AUTO_UPDATE=1 skip the update check for this run\n NO_COLOR=1 disable colors\n FORCE_COLOR=0 disable colors (FORCE_COLOR=false also works)"
|
|
910
|
+
}
|
|
887
911
|
}
|
|
888
912
|
}
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"cli": {
|
|
3
3
|
"error_unknown": "未知命令: {{command}}",
|
|
4
|
-
"error_general": "错误:"
|
|
4
|
+
"error_general": "错误:",
|
|
5
|
+
"unknown_hint": "下一步:运行 vibecli --help 查看可用命令",
|
|
6
|
+
"unknown_hint_suggestion": "你是不是想运行 vibecli {{command}}?",
|
|
7
|
+
"err_unknown_option": "未知选项:{{name}}",
|
|
8
|
+
"err_missing_argument": "缺少参数:{{name}}",
|
|
9
|
+
"err_missing_option": "缺少必填选项:{{name}}",
|
|
10
|
+
"unknown_option_hint": "下一步:运行 vibecli {{command}} --help 查看正确用法"
|
|
5
11
|
},
|
|
6
12
|
"lang": {
|
|
7
13
|
"current": "当前语言",
|
|
@@ -328,6 +334,7 @@
|
|
|
328
334
|
"codex_1m_disabled": "Codex 1M 上下文已关闭",
|
|
329
335
|
"codex_1m_missing_key": "未找到已保存的 Codex API Key;先运行 vibecli setup --codexkey <你的 Key>(或 --key)",
|
|
330
336
|
"validating": "正在验证 {{label}} 的 API Key...",
|
|
337
|
+
"unreachable": "连不上接入地址 {{url}}({{reason}})",
|
|
331
338
|
"invalid_key": "{{label}} 的 API Key 无效: {{reason}}",
|
|
332
339
|
"probe_failed": "{{label}} 的模型能力探测失败(网络原因),按全部可用继续",
|
|
333
340
|
"key_no_claude": "{{label}} 无法访问 Claude 模型(令牌分组不含 Claude),已跳过 {{tool}}",
|
|
@@ -360,8 +367,7 @@
|
|
|
360
367
|
"version_outdated": "版本 {{current}} 过旧,需要 {{min}} 及以上,运行 {{upgrade}} 升级",
|
|
361
368
|
"agy": {
|
|
362
369
|
"menu_written": "模型菜单 {{count}} 个({{list}}),默认 {{default}}",
|
|
363
|
-
"
|
|
364
|
-
"reopen_terminal_windows": "Key 与地址已写入用户环境变量,重新打开终端再运行 agy"
|
|
370
|
+
"effort_after_reopen": "现在就能运行 agy;新开的终端里模型菜单还会带思考档位(低 / 中 / 高)"
|
|
365
371
|
},
|
|
366
372
|
"grok": {
|
|
367
373
|
"menu_written": "模型菜单 {{count}} 个({{list}}),默认 {{default}}",
|
|
@@ -496,7 +502,9 @@
|
|
|
496
502
|
"learn_more": {
|
|
497
503
|
"command_help": "查看某个命令的用法和示例",
|
|
498
504
|
"docs": "在线文档:{{url}}",
|
|
499
|
-
"all_commands": "查看全部命令"
|
|
505
|
+
"all_commands": "查看全部命令",
|
|
506
|
+
"exit_codes": "查看退出码和 --json 错误格式",
|
|
507
|
+
"environment": "查看 VibeCLI 读取的环境变量"
|
|
500
508
|
},
|
|
501
509
|
"title": {
|
|
502
510
|
"usage": "用法:",
|
|
@@ -539,7 +547,7 @@
|
|
|
539
547
|
},
|
|
540
548
|
"setup": {
|
|
541
549
|
"summary": "一条命令配好工具(按 Key 能用的模型自动选)",
|
|
542
|
-
"description": "不进向导,一条命令写好配置。\n--key 先用 Key 拉模型列表,按能用的模型配置对应工具(见下表)。\n不同分组的 Key 用 --claudekey / --codexkey / --grokkey / --desktopkey / --agykey
|
|
550
|
+
"description": "不进向导,一条命令写好配置。\n--key 先用 Key 拉模型列表,按能用的模型配置对应工具(见下表)。\n不同分组的 Key 用 --claudekey / --codexkey / --grokkey / --desktopkey / --agykey 分开给。\n重复执行就是换 Key,其他配置保留。",
|
|
543
551
|
"opt": {
|
|
544
552
|
"key": "一把 Key,按它能用的模型自动配置工具",
|
|
545
553
|
"claudekey": "单独给 Claude Code 的 Key",
|
|
@@ -884,5 +892,21 @@
|
|
|
884
892
|
"back_to_index": "命令列表",
|
|
885
893
|
"use_instead": "什么情况下改用它"
|
|
886
894
|
}
|
|
895
|
+
},
|
|
896
|
+
"errors": {
|
|
897
|
+
"next_step": "下一步:{{command}}",
|
|
898
|
+
"hint_logs": "下一步:运行 vibecli logs tail 查看详细日志",
|
|
899
|
+
"cancelled": "已取消操作",
|
|
900
|
+
"cancel_hint": "下一步:运行 vibecli 重新开始"
|
|
901
|
+
},
|
|
902
|
+
"help_topics": {
|
|
903
|
+
"exit_codes": {
|
|
904
|
+
"title": "退出码与错误输出",
|
|
905
|
+
"body": "退出码:\n 0 成功\n 1 操作失败\n 2 用法或输入错误\n 3 认证失败(Key 无效或被拒绝)\n 4 网络问题(DNS、证书、超时或网关不可达)\n 5 内部错误\n 10 需要确认(非交互模式请加 --yes)\n 130 用户取消\n\n使用 --json 时,成功输出保持原格式;失败只在 stderr 输出一个 JSON 对象:\n{\"ok\":false,\"error\":{\"type\":\"usage\",\"message\":\"…\",\"hint\":\"…\",\"subtype\":\"…\"}}"
|
|
906
|
+
},
|
|
907
|
+
"environment": {
|
|
908
|
+
"title": "环境变量",
|
|
909
|
+
"body": "VibeCLI 会读取这些环境变量:\n VIBECLI_DISABLE_AUTO_UPDATE=1 禁用启动时自动更新检查\n VIBECLI_DISABLE_MODEL_REFRESH=1 禁用启动时模型菜单刷新\n VIBECLI_CONFIG_DIR=<目录> 指定 VibeCLI 配置目录\n VIBECLI_SKIP_AUTO_UPDATE=1 跳过本次自动更新检查\n NO_COLOR=1 禁用颜色\n FORCE_COLOR=0 禁用颜色(FORCE_COLOR=false 同样有效)"
|
|
910
|
+
}
|
|
887
911
|
}
|
|
888
912
|
}
|
package/dist/models.json
CHANGED
package/models.json
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeapi/api-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.93",
|
|
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",
|