@vibeapi/api-helper 0.0.38 → 0.0.39
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -0
- package/dist/commands/setup.d.ts +3 -0
- package/dist/commands/setup.js +1 -1
- package/dist/lib/command.js +1 -1
- package/dist/locales/en_US.json +2 -1
- package/dist/locales/zh_CN.json +2 -1
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/commands/setup.d.ts
CHANGED
|
@@ -12,6 +12,9 @@
|
|
|
12
12
|
* vibecli setup --1m
|
|
13
13
|
* 复用当前 profile 已保存的 Codex Key,开启 1M 上下文并重新应用配置。
|
|
14
14
|
*
|
|
15
|
+
* vibecli setup --no-1m
|
|
16
|
+
* 复用当前 profile 已保存的 Codex Key,关闭 1M 上下文且不改写凭据。
|
|
17
|
+
*
|
|
15
18
|
* 重复执行即换令牌(幂等)。模型一律用默认组合,之后可在向导 / tool-model 里改。
|
|
16
19
|
*/
|
|
17
20
|
export interface SetupCommandOptions {
|
package/dist/commands/setup.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import{i18n as o}from"../lib/i18n.js";import{configManager as t}from"../lib/config.js";import{toolManager as a,SUPPORTED_TOOLS as
|
|
1
|
+
import e from"chalk";import{i18n as o}from"../lib/i18n.js";import{configManager as t}from"../lib/config.js";import{toolManager as a,SUPPORTED_TOOLS as l}from"../lib/tool-manager.js";import{validateApiKey as s,fetchModels as i}from"../lib/api-validator.js";import{CODEX_ONE_MILLION_CONTEXT_SETTING as n,setCodexOneMillionContext as d}from"../lib/tools/codex.js";async function r(e){const o=await i(e);if(!o.ok)return{hasClaude:!0,hasGpt:!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)),probed:!0}}function c(o){console.log(e.green(o))}function p(o){console.log(e.yellow(o))}function u(o){console.error(e.red(o))}async function m(t,a){console.log(e.gray(o.t("setup.validating",{label:t})));const l=await s(a);return!!l.valid||(u(o.t("setup.invalid_key",{label:t,reason:l.message||l.error||"invalid"})),!1)}function f(s,i,d){const r=l[s];try{"codex"===s&&void 0!==d&&t.setToolSetting("codex",n,d),a.loadPrivateConfig(s,i,t.getModelsForTool(s))}catch(e){return u(o.t("setup.apply_failed",{tool:r.displayName,reason:e instanceof Error?e.message:String(e)})),!1}return c(o.t("setup.configured",{tool:r.displayName,command:r.command})),"codex"===s&&void 0!==d&&c(o.t(d?"setup.codex_1m_enabled":"setup.codex_1m_disabled")),a.isToolInstalled(s)||console.log(e.gray(o.t("setup.install_hint",{tool:r.displayName,install:r.installCommand}))),!0}export async function setupCommand(e){const a=e.key?.trim(),s=e.claudekey?.trim(),i=e.codexkey?.trim(),y=void 0!==e.oneMillion;if(!a&&!s&&!i&&y){if(!t.getApiKeyForTool("codex"))return u(o.t("setup.codex_1m_missing_key")),void(process.exitCode=1);try{const a=!0===e.oneMillion;t.setToolSetting("codex",n,a),d(a),c(o.t(a?"setup.codex_1m_enabled":"setup.codex_1m_disabled"))}catch(e){u(o.t("setup.apply_failed",{tool:l.codex.displayName,reason:e instanceof Error?e.message:String(e)})),process.exitCode=1}return}if(!a&&!s&&!i)return u(o.t("setup.usage")),void(process.exitCode=1);let g=0,b=0;const _=new Set,x=[];s&&x.push({tool:"claude-code",label:"--claudekey",apiKey:s,need:"claude"}),i&&x.push({tool:"codex",label:"--codexkey",apiKey:i,need:"gpt"});for(const a of x){if(!await m(a.label,a.apiKey)){b+=1;continue}const l=await r(a.apiKey),s="claude"===a.need?l.hasClaude:l.hasGpt;!l.probed||s?(l.probed||p(o.t("setup.probe_failed",{label:a.label})),t.setToolApiKey(a.tool,a.apiKey),f(a.tool,a.apiKey,e.oneMillion)?(g+=1,_.add(a.tool)):b+=1):(u(o.t("claude"===a.need?"setup.key_no_claude":"setup.key_no_gpt",{label:a.label})),b+=1)}if(a){if(!await m("--key",a))return void(process.exitCode=1);t.setApiKey(a);const l=await r(a);if(l.probed||p(o.t("setup.probe_failed",{label:"--key"})),l.probed&&!l.hasClaude&&!l.hasGpt)return u(o.t("setup.key_no_family")),void(process.exitCode=1);const s=[{tool:"claude-code",capable:l.hasClaude,skipMsg:o.t("setup.skip_no_claude")},{tool:"codex",capable:l.hasGpt,skipMsg:o.t("setup.skip_no_gpt")}];for(const o of s)_.has(o.tool)||(o.capable?f(o.tool,a,e.oneMillion)?(g+=1,_.add(o.tool)):b+=1:p(o.skipMsg))}if(g>0){const e=[..._].map(e=>l[e]?.command).filter(Boolean).join(" / ");c("\n"+o.t("setup.done",{count:String(g),commands:e}))}(b>0||0===g)&&(process.exitCode=1)}
|
package/dist/lib/command.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Command as e}from"commander";import{i18n as
|
|
1
|
+
import{Command as e}from"commander";import{i18n as o,detectSystemLang as a}from"./i18n.js";import{configManager as t}from"./config.js";import{wizard as n}from"./wizard.js";import{langCommand as i,authCommand as s,doctorCommand as r,configCommand as c,statusCommand as m}from"../commands/index.js";import{logsCommand as p}from"../commands/logs.js";import{completionCommand as l}from"../commands/completion.js";import{benchCommand as d}from"../commands/bench.js";import{updateCommand as g}from"../commands/update.js";import{setupCommand as u}from"../commands/setup.js";import h from"chalk";import{readFileSync as y}from"fs";import{join as f,dirname as b}from"path";import{fileURLToPath as k}from"url";import{setRuntimeOptions as v,detectColorPreferenceFromEnv as w,isColorEnabled as $,isJsonMode as j}from"./runtime-options.js";import{cleanupAnthropicEnvVars as x}from"./env-cleanup.js";import{runStartupUpdate as C}from"./auto-update.js";export class Command{program;constructor(){const n=t.isFirstRun()?a():t.getLang();o.loadFromConfig(n),this.program=new e,this.setupProgram()}getVersion(){try{const e=k(import.meta.url),o=b(e),a=f(o,"../../package.json");return JSON.parse(y(a,"utf-8")).version}catch{return"1.0.0"}}setupProgram(){this.program.name("vibecli").description(o.t("cli.title")).version(this.getVersion(),"-v, --version",o.t("commands.version")).helpOption("-h, --help",o.t("commands.help")).option("--base <url>","Custom API base URL").option("--non-interactive","Disable interactive prompts (CI mode)").option("--json","Emit machine-readable JSON output where applicable").option("--yes, -y","Auto-confirm prompts that have a default action").option("--dry-run","Show planned changes without writing anywhere").option("--no-color","Disable colored output"),this.program.command("setup").description(o.t("commands.setup")).option("--key <key>","API key for all capable tools (capability auto-detected)").option("--claudekey <key>","Dedicated API key for Claude Code").option("--codexkey <key>","Dedicated API key for Codex").option("--1m","Enable the 1M context window for Codex").option("--no-1m","Disable the 1M context window for Codex").option("--all","Configure every tool the key can serve (default behavior)").action(async e=>{await u({key:e.key,claudekey:e.claudekey,codexkey:e.codexkey,all:e.all,oneMillion:e["1m"]})}),this.program.command("init").description(o.t("commands.init")).action(async()=>{await this.handleInitCommand()});const e=this.program.command("lang").description(o.t("commands.lang"));e.command("show").description(o.t("lang.show_usage")).action(async()=>{await i(["show"])}),e.command("set <locale>").description(o.t("lang.set_usage")).action(async e=>{await i(["set",e])});const a=this.program.command("auth").description(o.t("commands.auth"));a.argument("[token]","API token").action(async e=>{const o=[];e&&o.push(e),await s(o)}),a.command("revoke").description("Revoke saved API key").action(async()=>{await s(["revoke"])}),a.command("reload <tool>").description("Reload plan configuration to the specified tool (e.g., claude)").action(async e=>{await s(["reload",e])}),this.program.command("doctor").description(o.t("commands.doctor")).action(async()=>{await r()}),this.program.command("status").description(o.t("commands.status")).action(async()=>{await m()}),this.program.command("logs").description("Inspect vibecli log files").argument("[action]","list|tail|path").argument("[file]","specific log file when using tail").action(async(e,o)=>{const a=[];e&&a.push(e),o&&a.push(o),await p(a)}),this.program.command("completion <shell>").description("Print shell completion script (bash|zsh|fish)").action(async e=>{await l([e])}),this.program.command("update").description("Check for a newer version across CNB and npm mirrors").action(async()=>{await g()}),this.program.command("bench").description("Benchmark the configured API endpoint").option("--samples <n>","number of samples to send","5").action(async e=>{const o=[];e.samples&&o.push("--samples",e.samples),await d(o)}),this.program.command("config").description("Manage profiles, presets, backups, and per-tool config").argument("[args...]","Subcommand and arguments").allowUnknownOption(!0).action(async e=>{await c(e||[])}),this.program.command("enter [option]").description(o.t("commands.enter")).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:{const o=[e];await c(o);break}}else await n.run()}),this.program.action(async()=>{await n.run()}),this.program.configureHelp({sortSubcommands:!0,subcommandTerm:e=>e.name()+" "+e.usage()}),this.program.addHelpText("after",`\n${h.bold(o.t("cli.examples"))}:\n ${h.gray("$ vibecli # Interactive main menu")}\n ${h.gray("$ vibecli init # Run first-time setup wizard")}\n ${h.gray("$ vibecli setup --key sk-xxx # One-shot setup (auto-detect capable tools)")}\n ${h.gray("$ vibecli setup --claudekey sk-a --codexkey sk-b")}\n ${h.gray("$ vibecli status --json # Machine-readable status")}\n ${h.gray("$ vibecli config profile list")}\n ${h.gray("$ vibecli config profile create work")}\n ${h.gray("$ vibecli config profile use work")}\n ${h.gray("$ vibecli config preset save fast")}\n ${h.gray("$ vibecli config backup create snapshot")}\n ${h.gray("$ vibecli auth <token> --non-interactive")}\n ${h.gray("$ vibecli auth revoke --yes")}\n ${h.gray("$ vibecli logs path")}\n ${h.gray("$ vibecli completion bash")}\n ${h.gray("$ vibecli bench --samples 3")}\n ${h.gray("$ vibecli update")}\n ${h.gray('$ vibecli --base "https://custom.api.com" init # Custom base URL')}\n`)}async handleInitCommand(){await n.runFirstTimeSetup()}cleanupLeakedEnvVars(){const e=x();if(0===e.length||j())return;const a=o.t("messages.env_vars_cleared",{vars:e.join(", ")});console.log($()?h.yellow(a):a)}preflightArgs(e){const o=o=>e.includes(o),a=!o("--no-color")&&w();let n;v({nonInteractive:o("--non-interactive"),json:o("--json"),yes:o("--yes")||o("-y"),dryRun:o("--dry-run"),color:a}),a||(h.level=0);for(let o=0;o<e.length;o+=1){const a=e[o];if("--base"===a&&e[o+1]){n=e[o+1];break}if(a.startsWith("--base=")){n=a.slice(7);break}}n&&t.setBaseUrl(n)}async execute(e){try{if(this.preflightArgs(e),this.cleanupLeakedEnvVars(),(await C(e)).handled)return;await this.program.parseAsync(e,{from:"user"})}catch(e){if(e instanceof Error){const a=$()?h.red:e=>e;console.error(a(o.t("cli.error_general")),e.message)}process.exit(1)}}getProgram(){return this.program}}
|
package/dist/locales/en_US.json
CHANGED
|
@@ -313,8 +313,9 @@
|
|
|
313
313
|
"non_interactive_aborted": "Aborted - missing required input"
|
|
314
314
|
},
|
|
315
315
|
"setup": {
|
|
316
|
-
"usage": "Usage: vibecli setup --key sk-xxx or vibecli setup --claudekey sk-a --codexkey sk-b or vibecli setup --1m",
|
|
316
|
+
"usage": "Usage: vibecli setup --key sk-xxx or vibecli setup --claudekey sk-a --codexkey sk-b or vibecli setup --1m|--no-1m",
|
|
317
317
|
"codex_1m_enabled": "Codex 1M context is enabled",
|
|
318
|
+
"codex_1m_disabled": "Codex 1M context is disabled",
|
|
318
319
|
"codex_1m_missing_key": "No saved Codex API key was found; configure one with --key or --codexkey first",
|
|
319
320
|
"validating": "Validating API key for {{label}}...",
|
|
320
321
|
"invalid_key": "API key for {{label}} is invalid: {{reason}}",
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -313,8 +313,9 @@
|
|
|
313
313
|
"non_interactive_aborted": "已中止 - 缺少必要输入"
|
|
314
314
|
},
|
|
315
315
|
"setup": {
|
|
316
|
-
"usage": "用法: vibecli setup --key sk-xxx 或 vibecli setup --claudekey sk-a --codexkey sk-b 或 vibecli setup --1m",
|
|
316
|
+
"usage": "用法: vibecli setup --key sk-xxx 或 vibecli setup --claudekey sk-a --codexkey sk-b 或 vibecli setup --1m|--no-1m",
|
|
317
317
|
"codex_1m_enabled": "Codex 1M 上下文已开启",
|
|
318
|
+
"codex_1m_disabled": "Codex 1M 上下文已关闭",
|
|
318
319
|
"codex_1m_missing_key": "未找到已保存的 Codex API Key;请先用 --key 或 --codexkey 完成配置",
|
|
319
320
|
"validating": "正在验证 {{label}} 的 API Key...",
|
|
320
321
|
"invalid_key": "{{label}} 的 API Key 无效: {{reason}}",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeapi/api-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.39",
|
|
4
4
|
"description": "CLI tool for managing AI coding assistants (Claude Code, Codex, OpenClaw, Hermes, AtomCode) with one unified config",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|