@vibeapi/api-helper 0.0.189 → 0.0.190

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.
@@ -13,8 +13,6 @@ export declare class Command {
13
13
  */
14
14
  private preflightArgs;
15
15
  execute(args: string[]): Promise<void>;
16
- /** The detached process `startToolAutoUpgrade` starts: nobody watches its output and nothing may prompt. */
17
- private runAutoUpgradeWorker;
18
16
  /** `--dry-run` on a command that would write anyway: refuse before anything runs. */
19
17
  private rejectUnsupportedDryRun;
20
18
  private rejectUnknownCommand;
@@ -1 +1 @@
1
- import{i18n as r,detectSystemLang as o}from"./i18n.js";import{configManager as n}from"./config.js";import{runModelRefresh as t}from"./model-refresh.js";import{AUTO_UPGRADE_WORKER_ARG as e,runToolAutoUpgradeRound as i,startToolAutoUpgrade as s}from"./tool-auto-upgrade.js";import{refreshClientConfig as a}from"./client-config-sync.js";import{normalizeBaseUrl as m}from"./gateway-addresses.js";import c from"chalk";import{setRuntimeOptions as l,detectColorPreferenceFromEnv as d,isDryRun as u}from"./runtime-options.js";import{runStartupUpdate as p}from"./auto-update.js";import{buildProgram as g}from"./program.js";import{firstCommandWord as f,isHelpRequest as h,renderHelpTopic as y}from"./cli-help.js";import{reportCliError as w,usageError as _,CliError as j,EXIT_CODES as k}from"./errors.js";import{brandEnv as v,CLI_NAME as C}from"./brand.js";import{dryRunUnsupportedCommand as x}from"./dry-run.js";import{flushTelemetry as A,installClientHeaders as O,lastFailureReason as b,maskSecrets as U,setTelemetryCommand as D,track as M,watchConsoleErrors as E}from"./telemetry.js";export{buildProgram}from"./program.js";const R=new Set(["setup","init","auth","enter","config"]);export class Command{program;configuring=!1;constructor(){const t=n.isLangChosen()?n.getLang():o();r.loadFromConfig(t),this.program=g()}preflightArgs(r){const o=o=>r.includes(o),t=!o("--no-color")&&d();if(l({nonInteractive:o("--non-interactive"),json:o("--json"),yes:o("--yes")||o("-y"),dryRun:o("--dry-run"),color:t}),t||(c.level=0),this.configuring=!1,h(r))return;let e;for(let o=0;o<r.length;o+=1){const n=r[o];"--base"===n&&r[o+1]?(e=r[o+1],o+=1):n.startsWith("--base=")&&(e=n.slice(7))}const i=f(r),s=void 0===i&&!["--version","-v"].some(o);this.configuring=s||void 0!==i&&R.has(i),e&&n.setBaseUrl(m(e)??e,this.configuring&&!o("--dry-run"))}async execute(r){const o=Date.now();let n=!1;if(r[0]!==e)try{if(this.preflightArgs(r),O(),!h(r)&&!["--version","-v"].some(o=>r.includes(o))){D(f(r)??"wizard");const o=v("INSTALLER_NOTE")?.trim();M("command","start",{detail:{args:r.filter(r=>r.startsWith("-")&&!/key/i.test(r)),...o?{installer:U(o).slice(0,400)}:{}}}),n=!0,E()}if("help"===r[0]&&r[1]){const o=y(r[1]);if(o)return void process.stdout.write(o)}if(this.rejectUnknownCommand(r),!h(r)){if(u()&&this.rejectUnsupportedDryRun(r),(await p(r)).handled)return;this.configuring&&await a({timeoutMs:5e3}),await t(r),s(r)}if(await this.program.parseAsync(r,{from:"user"}),n){const r=Boolean(process.exitCode)&&0!==process.exitCode,n=Number(process.exitCode)===k.cancelled;M("command",n?"cancel":r?"fail":"ok",{duration_ms:Date.now()-o,...r?{error:b(),detail:{exit_code:process.exitCode}}:{}})}}catch(t){if("commander.helpDisplayed"===t?.code||"commander.version"===t?.code)return;const e=this.normalizeCommanderError(t,r),i=w(e);if(n){const r=e instanceof j?`${e.type}${e.subtype?"/"+e.subtype:""}`:void 0;M("command",130===i?"cancel":"fail",{duration_ms:Date.now()-o,error:e,detail:{exit_code:i,...r?{type:r}:{}}})}}finally{n&&await A()}else await this.runAutoUpgradeWorker()}async runAutoUpgradeWorker(){l({nonInteractive:!0,json:!1,yes:!1,dryRun:!1,color:!1}),c.level=0,O(),D("auto-upgrade");try{await i()}catch(r){M("auto-upgrade","fail",{error:r})}finally{await A()}}rejectUnsupportedDryRun(o){const n=x(o);if(null!==n)throw _(r.t("runtime.dry_run_unsupported",{command:n,cli:C}),r.t("runtime.dry_run_unsupported_hint",{cli:C}),"dry_run_unsupported")}rejectUnknownCommand(o){const n=f(o);if(!n||"help"===n)return;if(this.program.commands.some(r=>r.name()===n))return;const t=this.suggestCommand(n),e=t?r.t("cli.unknown_hint_suggestion",{command:t}):r.t("cli.unknown_hint");throw _(r.t("cli.error_unknown",{command:n}),e,"unknown_command")}suggestCommand(r){const o=(r,o)=>{const n=Array.from({length:o.length+1},(r,o)=>o);for(let t=1;t<=r.length;t+=1){let e=n[0];n[0]=t;for(let i=1;i<=o.length;i+=1){const s=n[i];n[i]=Math.min(n[i]+1,n[i-1]+1,e+(r[t-1]===o[i-1]?0:1)),e=s}}return n[o.length]};return this.program.commands.map(r=>r.name()).map(n=>({name:n,score:o(r,n)})).filter(({score:o})=>o<=Math.max(2,Math.floor(r.length/2))).sort((r,o)=>r.score-o.score)[0]?.name}normalizeCommanderError(o,n){if(o instanceof j)return o;const t=o?.code,e=o instanceof Error?o.message:String(o);if("commander.unknownOption"===t||"commander.missingArgument"===t||"commander.missingMandatoryOption"===t||"commander.invalidArgument"===t){const o=f(n),i=/'([^']+)'/.exec(e)?.[1]??"",s="commander.unknownOption"===t?"cli.err_unknown_option":"commander.missingArgument"===t?"cli.err_missing_argument":"commander.missingMandatoryOption"===t?"cli.err_missing_option":null,a="commander.unknownOption"===t?this.gluedOption(i):void 0,m=U(i),c=a?r.t("cli.err_glued_option",{name:m,option:a}):s&&i?r.t(s,{name:m}):U(e.replace(/^error:\s*/,""));return _(c,o?r.t("cli.unknown_option_hint",{command:o}):r.t("cli.unknown_option_hint_root"),t)}return o}gluedOption(r){const o=new Set,n=r=>{for(const n of r.options)n.long&&o.add(n.long);for(const o of r.commands)n(o)};return n(this.program),[...o].filter(o=>r.length>o.length&&r.startsWith(o)).sort((r,o)=>o.length-r.length)[0]}getProgram(){return this.program}}
1
+ import{i18n as n,detectSystemLang as o}from"./i18n.js";import{configManager as r}from"./config.js";import{runModelRefresh as t}from"./model-refresh.js";import{refreshClientConfig as e}from"./client-config-sync.js";import{normalizeBaseUrl as i}from"./gateway-addresses.js";import s from"chalk";import{setRuntimeOptions as m,detectColorPreferenceFromEnv as a,isDryRun as c}from"./runtime-options.js";import{runStartupUpdate as l}from"./auto-update.js";import{buildProgram as d}from"./program.js";import{firstCommandWord as u,isHelpRequest as p,renderHelpTopic as g}from"./cli-help.js";import{reportCliError as f,usageError as h,CliError as _,EXIT_CODES as y}from"./errors.js";import{brandEnv as w,CLI_NAME as j}from"./brand.js";import{dryRunUnsupportedCommand as k}from"./dry-run.js";import{flushTelemetry as v,installClientHeaders as C,lastFailureReason as x,maskSecrets as A,setTelemetryCommand as O,track as b,watchConsoleErrors as D}from"./telemetry.js";export{buildProgram}from"./program.js";const M=new Set(["setup","init","auth","enter","config"]);export class Command{program;configuring=!1;constructor(){const t=r.isLangChosen()?r.getLang():o();n.loadFromConfig(t),this.program=d()}preflightArgs(n){const o=o=>n.includes(o),t=!o("--no-color")&&a();if(m({nonInteractive:o("--non-interactive"),json:o("--json"),yes:o("--yes")||o("-y"),dryRun:o("--dry-run"),color:t}),t||(s.level=0),this.configuring=!1,p(n))return;let e;for(let o=0;o<n.length;o+=1){const r=n[o];"--base"===r&&n[o+1]?(e=n[o+1],o+=1):r.startsWith("--base=")&&(e=r.slice(7))}const c=u(n),l=void 0===c&&!["--version","-v"].some(o);this.configuring=l||void 0!==c&&M.has(c),e&&r.setBaseUrl(i(e)??e,this.configuring&&!o("--dry-run"))}async execute(n){const o=Date.now();let r=!1;try{if(this.preflightArgs(n),C(),!p(n)&&!["--version","-v"].some(o=>n.includes(o))){O(u(n)??"wizard");const o=w("INSTALLER_NOTE")?.trim();b("command","start",{detail:{args:n.filter(n=>n.startsWith("-")&&!/key/i.test(n)),...o?{installer:A(o).slice(0,400)}:{}}}),r=!0,D()}if("help"===n[0]&&n[1]){const o=g(n[1]);if(o)return void process.stdout.write(o)}if(this.rejectUnknownCommand(n),!p(n)){if(c()&&this.rejectUnsupportedDryRun(n),(await l(n)).handled)return;this.configuring&&await e({timeoutMs:5e3}),await t(n)}if(await this.program.parseAsync(n,{from:"user"}),r){const n=Boolean(process.exitCode)&&0!==process.exitCode,r=Number(process.exitCode)===y.cancelled;b("command",r?"cancel":n?"fail":"ok",{duration_ms:Date.now()-o,...n?{error:x(),detail:{exit_code:process.exitCode}}:{}})}}catch(t){if("commander.helpDisplayed"===t?.code||"commander.version"===t?.code)return;const e=this.normalizeCommanderError(t,n),i=f(e);if(r){const n=e instanceof _?`${e.type}${e.subtype?"/"+e.subtype:""}`:void 0;b("command",130===i?"cancel":"fail",{duration_ms:Date.now()-o,error:e,detail:{exit_code:i,...n?{type:n}:{}}})}}finally{r&&await v()}}rejectUnsupportedDryRun(o){const r=k(o);if(null!==r)throw h(n.t("runtime.dry_run_unsupported",{command:r,cli:j}),n.t("runtime.dry_run_unsupported_hint",{cli:j}),"dry_run_unsupported")}rejectUnknownCommand(o){const r=u(o);if(!r||"help"===r)return;if(this.program.commands.some(n=>n.name()===r))return;const t=this.suggestCommand(r),e=t?n.t("cli.unknown_hint_suggestion",{command:t}):n.t("cli.unknown_hint");throw h(n.t("cli.error_unknown",{command:r}),e,"unknown_command")}suggestCommand(n){const o=(n,o)=>{const r=Array.from({length:o.length+1},(n,o)=>o);for(let t=1;t<=n.length;t+=1){let e=r[0];r[0]=t;for(let i=1;i<=o.length;i+=1){const s=r[i];r[i]=Math.min(r[i]+1,r[i-1]+1,e+(n[t-1]===o[i-1]?0:1)),e=s}}return r[o.length]};return this.program.commands.map(n=>n.name()).map(r=>({name:r,score:o(n,r)})).filter(({score:o})=>o<=Math.max(2,Math.floor(n.length/2))).sort((n,o)=>n.score-o.score)[0]?.name}normalizeCommanderError(o,r){if(o instanceof _)return o;const t=o?.code,e=o instanceof Error?o.message:String(o);if("commander.unknownOption"===t||"commander.missingArgument"===t||"commander.missingMandatoryOption"===t||"commander.invalidArgument"===t){const o=u(r),i=/'([^']+)'/.exec(e)?.[1]??"",s="commander.unknownOption"===t?"cli.err_unknown_option":"commander.missingArgument"===t?"cli.err_missing_argument":"commander.missingMandatoryOption"===t?"cli.err_missing_option":null,m="commander.unknownOption"===t?this.gluedOption(i):void 0,a=A(i),c=m?n.t("cli.err_glued_option",{name:a,option:m}):s&&i?n.t(s,{name:a}):A(e.replace(/^error:\s*/,""));return h(c,o?n.t("cli.unknown_option_hint",{command:o}):n.t("cli.unknown_option_hint_root"),t)}return o}gluedOption(n){const o=new Set,r=n=>{for(const r of n.options)r.long&&o.add(r.long);for(const o of n.commands)r(o)};return r(this.program),[...o].filter(o=>n.length>o.length&&n.startsWith(o)).sort((n,o)=>o.length-n.length)[0]}getProgram(){return this.program}}
@@ -0,0 +1,11 @@
1
+ /** Machine setting: the installed version the customer chose to keep (answered "no"). */
2
+ export declare const DECLINED_KEY = "upgrade_declined";
3
+ /**
4
+ * After writing configs: offer to bring each installed command-line tool up to the mirror's latest
5
+ * release, one question per tool showing both versions (用户 2026-11-22 定:升级前要客户确认,
6
+ * 有客户要停在指定版本). Only someone at a terminal is asked; `--yes` and no terminal never upgrade
7
+ * to latest (tools below the minimum version are handled before this, as before). "No" is
8
+ * remembered for that installed version: the customer is not asked again until the version
9
+ * changes, so a pinned version stays pinned. `vibecli upgrade <tool>` upgrades any time.
10
+ */
11
+ export declare function offerLatestUpgrades(tools: string[], skip?: ReadonlySet<string>): Promise<void>;
@@ -0,0 +1 @@
1
+ import t from"chalk";import o from"inquirer";import{CLI_NAME as r}from"./brand.js";import{configManager as e}from"./config.js";import{i18n as n}from"./i18n.js";import{compareVersions as s}from"./model-registry.js";import{canPrompt as l,hasExplicitYes as i}from"./runtime-options.js";import{track as a}from"./telemetry.js";import{upgradeTool as m}from"./tool-upgrade.js";import{getAdapter as f}from"./tools/registry.js";import{findInstalls as c,latestRelease as p}from"./tools/tool-installs.js";import{logger as u}from"../utils/logger.js";export const DECLINED_KEY="upgrade_declined";export async function offerLatestUpgrades(g,d=new Set){if(!l()||i())return;const j=await Promise.all([...new Set(g)].filter(t=>!d.has(t)).map(async t=>{try{const o=f(t),r=o?.installSpec,n=r?c(r)[0]?.version??null:null;if(!o||!r||!n)return null;if(e.getMachineSetting(t,DECLINED_KEY)===n)return null;const l=await p(r);return!l||s(n,l.version)>=0?null:{tool:t,name:o.displayName,current:n,latest:l.version}}catch(o){return u.logError(`offerLatestUpgrades(${t})`,o),null}}));for(const s of j){if(!s)continue;const{ok:l}=await o.prompt([{type:"confirm",name:"ok",default:!0,message:n.t("setup.offer_latest",{tool:s.name,current:s.current,latest:s.latest})}]);a(`offer-latest:${s.tool}`,l?"ok":"skip",{detail:{from:s.current,to:s.latest}}),l?await m(s.tool):(e.setMachineSetting(s.tool,DECLINED_KEY,s.current),console.log(t.gray(" "+n.t("setup.latest_declined",{tool:s.name,current:s.current,command:`${r} upgrade ${s.tool}`}))))}}
@@ -97,16 +97,6 @@ export interface ModelRegistryData {
97
97
  agy?: Partial<AgyRules>;
98
98
  /** Oldest tool release vibecli's written config works with (tool id → semver). */
99
99
  toolMinVersions?: Record<string, string>;
100
- /** Installed command-line tools vibecli keeps up to date in the background (see tool-auto-upgrade.ts). */
101
- autoUpgrade?: Partial<AutoUpgradeRules>;
102
- }
103
- export interface AutoUpgradeRules {
104
- /** Tool ids; empty stops background upgrades (ships with the next release, which customers get at their next command). */
105
- tools: string[];
106
- /** At most one background round per this many hours. */
107
- intervalHours: number;
108
- /** A release this fresh is left for a later round: same-day fixes often replace a bad build. */
109
- minAgeHours: number;
110
100
  }
111
101
  /** One address the gateway answers on (another domain or route to the same site). */
112
102
  export interface GatewayAddress {
@@ -144,5 +134,4 @@ export declare function getAgyRules(): AgyRules;
144
134
  /** Compare dotted numeric versions (`2.1.9` < `2.1.10`); missing parts count as 0. */
145
135
  export declare function compareVersions(a: string, b: string): number;
146
136
  export declare function getToolMinVersion(toolName: string): string | null;
147
- export declare function getAutoUpgradeRules(): AutoUpgradeRules;
148
137
  export declare function reloadRegistry(): void;
@@ -1 +1 @@
1
- import{dirname as e,join as o}from"path";import{fileURLToPath as t}from"url";import{existsSync as r,readFileSync as n}from"fs";import{currentClientConfig as l,usableClientSection as s}from"./client-config.js";import{brand as a}from"./brand.js";const i=e(t(import.meta.url)),u=(e=[],o=[])=>[...new Set([...e,...o])];export function overlayClientSection(e,o){if(!o)return e;const t={...e.retiredDefaultModels??{}};for(const[e,r]of Object.entries(o.retiredDefaultModels??{}))t[e]=u(t[e],r);return{...e,defaultModels:{...e.defaultModels,...o.defaultModels??{}},retiredDefaultModels:t,toolDefaults:{...e.toolDefaults??{},...o.toolDefaults??{}},claudeCode:o.tierChains?{...e.claudeCode??{},tierChains:{...e.claudeCode?.tierChains??{},...o.tierChains}}:e.claudeCode,claudeDesktop:o.oneMillionFallback?{...e.claudeDesktop??{},oneMillionFallback:[...o.oneMillionFallback]}:e.claudeDesktop,gatewayModels:o.retiredModels?{...e.gatewayModels??{},retired:u(e.gatewayModels?.retired,o.retiredModels)}:e.gatewayModels,toolMinVersions:{...e.toolMinVersions??{},...o.toolMinVersions??{}},agy:o.agyModels?{...e.agy??{},gatewayModels:[...o.agyModels]}:e.agy}}let d=null;function c(){return d||(d=overlayClientSection(function(){const e=[o(i,"..","..","models.json"),o(i,"..","models.json"),o(i,"models.json")];for(const o of e)if(r(o))return JSON.parse(n(o,"utf-8"));throw new Error(`models.json not found, searched: ${e.join(", ")}`)}(),s(l()?.config))),d}export function getDefaultModels(){return{...c().defaultModels}}export function isRetiredDefaultModel(e,o){return c().retiredDefaultModels?.[e]?.includes(o)??!1}export function getRetiredDefaultModelIds(){return[...new Set(Object.values(c().retiredDefaultModels??{}).flat())]}export function getDefaultToolModel(){return c().defaultToolModel?.trim()||"gpt-5.5"}export function getToolDefaultModel(e){const o=c().toolDefaults;return o&&Object.prototype.hasOwnProperty.call(o,e)?(o[e]??"").trim():getDefaultToolModel()}export function getToolMenuModels(e){return[...c().toolMenuModels?.[e]??[]]}export function getPresets(){return[...c().presets]}export function resolvePreset(e){return e.models?{...e.models}:e.model?{haiku:e.model,sonnet:e.model,opus:e.model,reasoning:e.model}:getDefaultModels()}export function getClaudeCodeTierChains(){const e=c().claudeCode?.tierChains??{};return Object.fromEntries(Object.entries(e).map(([e,o])=>[e,[...o]]))}export function getClaudeDesktopRules(){const e=c().claudeDesktop??{};return{oneMillionFallback:[...e.oneMillionFallback??[]],oneMillionExclusions:(e.oneMillionExclusions??[]).map(e=>({...e,models:[...e.models]}))}}export function getGatewayModelRules(){const e=c().gatewayModels??{};return{autoCompactRatio:e.autoCompactRatio??.8,models:(e.models??[]).map(e=>({...e})),retired:[...e.retired??[]]}}export function getBuiltinGatewayAddresses(){return a().gatewayAddresses.map(e=>({...e}))}export function getCodexRules(){return{standardContextWindow:c().codex?.standardContextWindow??272e3}}export function getAgyRules(){return{gatewayModels:[...c().agy?.gatewayModels??[]]}}export function compareVersions(e,o){const t=e.split(".").map(e=>parseInt(e,10)||0),r=o.split(".").map(e=>parseInt(e,10)||0);for(let e=0;e<Math.max(t.length,r.length);e++){const o=(t[e]??0)-(r[e]??0);if(0!==o)return o}return 0}export function getToolMinVersion(e){return c().toolMinVersions?.[e]?.trim()||null}export function getAutoUpgradeRules(){const e=c().autoUpgrade??{};return{tools:Array.isArray(e.tools)?e.tools.filter(e=>"string"==typeof e):[],intervalHours:"number"==typeof e.intervalHours&&e.intervalHours>0?e.intervalHours:24,minAgeHours:"number"==typeof e.minAgeHours&&e.minAgeHours>=0?e.minAgeHours:6}}export function reloadRegistry(){d=null}
1
+ import{dirname as e,join as o}from"path";import{fileURLToPath as t}from"url";import{existsSync as l,readFileSync as n}from"fs";import{currentClientConfig as r,usableClientSection as s}from"./client-config.js";import{brand as a}from"./brand.js";const i=e(t(import.meta.url)),d=(e=[],o=[])=>[...new Set([...e,...o])];export function overlayClientSection(e,o){if(!o)return e;const t={...e.retiredDefaultModels??{}};for(const[e,l]of Object.entries(o.retiredDefaultModels??{}))t[e]=d(t[e],l);return{...e,defaultModels:{...e.defaultModels,...o.defaultModels??{}},retiredDefaultModels:t,toolDefaults:{...e.toolDefaults??{},...o.toolDefaults??{}},claudeCode:o.tierChains?{...e.claudeCode??{},tierChains:{...e.claudeCode?.tierChains??{},...o.tierChains}}:e.claudeCode,claudeDesktop:o.oneMillionFallback?{...e.claudeDesktop??{},oneMillionFallback:[...o.oneMillionFallback]}:e.claudeDesktop,gatewayModels:o.retiredModels?{...e.gatewayModels??{},retired:d(e.gatewayModels?.retired,o.retiredModels)}:e.gatewayModels,toolMinVersions:{...e.toolMinVersions??{},...o.toolMinVersions??{}},agy:o.agyModels?{...e.agy??{},gatewayModels:[...o.agyModels]}:e.agy}}let u=null;function c(){return u||(u=overlayClientSection(function(){const e=[o(i,"..","..","models.json"),o(i,"..","models.json"),o(i,"models.json")];for(const o of e)if(l(o))return JSON.parse(n(o,"utf-8"));throw new Error(`models.json not found, searched: ${e.join(", ")}`)}(),s(r()?.config))),u}export function getDefaultModels(){return{...c().defaultModels}}export function isRetiredDefaultModel(e,o){return c().retiredDefaultModels?.[e]?.includes(o)??!1}export function getRetiredDefaultModelIds(){return[...new Set(Object.values(c().retiredDefaultModels??{}).flat())]}export function getDefaultToolModel(){return c().defaultToolModel?.trim()||"gpt-5.5"}export function getToolDefaultModel(e){const o=c().toolDefaults;return o&&Object.prototype.hasOwnProperty.call(o,e)?(o[e]??"").trim():getDefaultToolModel()}export function getToolMenuModels(e){return[...c().toolMenuModels?.[e]??[]]}export function getPresets(){return[...c().presets]}export function resolvePreset(e){return e.models?{...e.models}:e.model?{haiku:e.model,sonnet:e.model,opus:e.model,reasoning:e.model}:getDefaultModels()}export function getClaudeCodeTierChains(){const e=c().claudeCode?.tierChains??{};return Object.fromEntries(Object.entries(e).map(([e,o])=>[e,[...o]]))}export function getClaudeDesktopRules(){const e=c().claudeDesktop??{};return{oneMillionFallback:[...e.oneMillionFallback??[]],oneMillionExclusions:(e.oneMillionExclusions??[]).map(e=>({...e,models:[...e.models]}))}}export function getGatewayModelRules(){const e=c().gatewayModels??{};return{autoCompactRatio:e.autoCompactRatio??.8,models:(e.models??[]).map(e=>({...e})),retired:[...e.retired??[]]}}export function getBuiltinGatewayAddresses(){return a().gatewayAddresses.map(e=>({...e}))}export function getCodexRules(){return{standardContextWindow:c().codex?.standardContextWindow??272e3}}export function getAgyRules(){return{gatewayModels:[...c().agy?.gatewayModels??[]]}}export function compareVersions(e,o){const t=e.split(".").map(e=>parseInt(e,10)||0),l=o.split(".").map(e=>parseInt(e,10)||0);for(let e=0;e<Math.max(t.length,l.length);e++){const o=(t[e]??0)-(l[e]??0);if(0!==o)return o}return 0}export function getToolMinVersion(e){return c().toolMinVersions?.[e]?.trim()||null}export function reloadRegistry(){u=null}
@@ -1 +1 @@
1
- import o from"chalk";import t from"inquirer";import{i18n as e}from"./i18n.js";import{canPrompt as n,hasExplicitYes as r}from"./runtime-options.js";import{flushTelemetry as l,track as i}from"./telemetry.js";import{toolManager as a}from"./tool-manager.js";import{getAdapter as s}from"./tools/registry.js";import{upgradeTool as p}from"./tool-upgrade.js";import{appsForTools as c,upgradeApp as f}from"./app-update.js";import{logger as u}from"../utils/logger.js";async function m(o){const{ok:e}=await t.prompt([{type:"confirm",name:"ok",message:o,default:!0}]);return e}export async function runPendingElevations(t){const a=n(),p=r();for(const n of t){const t=s(n)?.pendingElevation?.();if(!t)continue;const r=s(n)?.displayName??n;if(!p&&!a){console.log(o.yellow(" ! "+e.t("setup.elevation_skipped",{tool:r}))),i("elevate-registry","skip",{detail:{tool:n,reason:"no_terminal"}});continue}if(!p&&!await m(t.prompt)){i("elevate-registry","cancel",{detail:{tool:n,reason:"declined"}});continue}console.log(o.gray(" "+e.t("setup.elevation_running")));const c=Date.now();i("elevate-registry","start",{detail:{tool:n,asked:!p}}),await l();const f=t.run();i("elevate-registry",f?"ok":"fail",{duration_ms:Date.now()-c,detail:{tool:n,asked:!p}}),console.log(f?o.green(" √ "+e.t("setup.elevation_done",{tool:r})):o.yellow(" ! "+e.t("setup.elevation_failed",{tool:r})))}}export async function runFollowUps(t){const e=n();for(const n of t){let t,l;try{t=await(s(n)?.followUp?.())}catch(o){u.logError(`postApplyPrompts.followUp(${n})`,o);continue}if(t)if("run"in t&&(r()||e))if(r()||await m(t.prompt)){try{l=await t.run()}catch(e){u.logError(`postApplyPrompts.followUp.run(${n})`,e),i(`follow-up:${n}`,"fail",{error:e}),console.log(o.yellow(" ! "+t.hint));continue}for(const t of l)console.log("action"===t.kind?o.yellow(" ! "+t.text):o.green(" √ "+t.text))}else t.decline();else console.log(o.yellow(" ! "+t.hint))}}export async function postApplyPrompts(t,l={}){const i=new Set;for(const o of l.apps?c(t):[])try{const t=await f(o,{install:l.apps.install,quiet:!0,askBeforeUpgrade:!0});t.upgraded&&t.running&&i.add(o)}catch(t){u.logError(`postApplyPrompts.upgradeApp(${o})`,t)}for(const e of t){const t=await(s(e)?.prepareRuntime?.())??[];for(const e of t)console.log("action"===e.kind?o.yellow(" ! "+e.text):o.green(" √ "+e.text))}await runPendingElevations(t),await runFollowUps(t);const g=n(),d=r(),y=g||d?t.filter(o=>s(o)?.installSpec&&a.outdatedVersion(o)):[];if(y.length>0){const o=y.map(o=>s(o)?.displayName??o).join("、");if(d||await m(e.t("setup.offer_upgrade",{tools:o})))for(const o of y)await p(o)}for(const n of t){const t=s(n);if(i.has(n)||!t?.runningApp?.isRunning())continue;if(d||!g){console.log(o.yellow(" ! "+e.t("setup.reopen_hint",{tool:t.displayName})));continue}if(!await m(e.t("setup.offer_restart",{tool:t.displayName})))continue;const r=t.runningApp.restart();console.log(r?o.green(" √ "+e.t("setup.restarted",{tool:t.displayName})):o.yellow(" ! "+e.t("setup.restart_failed",{tool:t.displayName})))}}
1
+ import o from"chalk";import t from"inquirer";import{i18n as e}from"./i18n.js";import{canPrompt as n,hasExplicitYes as r}from"./runtime-options.js";import{flushTelemetry as l,track as i}from"./telemetry.js";import{toolManager as a}from"./tool-manager.js";import{getAdapter as s}from"./tools/registry.js";import{upgradeTool as p}from"./tool-upgrade.js";import{appsForTools as c,upgradeApp as f}from"./app-update.js";import{offerLatestUpgrades as u}from"./latest-upgrade.js";import{logger as m}from"../utils/logger.js";async function g(o){const{ok:e}=await t.prompt([{type:"confirm",name:"ok",message:o,default:!0}]);return e}export async function runPendingElevations(t){const a=n(),p=r();for(const n of t){const t=s(n)?.pendingElevation?.();if(!t)continue;const r=s(n)?.displayName??n;if(!p&&!a){console.log(o.yellow(" ! "+e.t("setup.elevation_skipped",{tool:r}))),i("elevate-registry","skip",{detail:{tool:n,reason:"no_terminal"}});continue}if(!p&&!await g(t.prompt)){i("elevate-registry","cancel",{detail:{tool:n,reason:"declined"}});continue}console.log(o.gray(" "+e.t("setup.elevation_running")));const c=Date.now();i("elevate-registry","start",{detail:{tool:n,asked:!p}}),await l();const f=t.run();i("elevate-registry",f?"ok":"fail",{duration_ms:Date.now()-c,detail:{tool:n,asked:!p}}),console.log(f?o.green(" √ "+e.t("setup.elevation_done",{tool:r})):o.yellow(" ! "+e.t("setup.elevation_failed",{tool:r})))}}export async function runFollowUps(t){const e=n();for(const n of t){let t,l;try{t=await(s(n)?.followUp?.())}catch(o){m.logError(`postApplyPrompts.followUp(${n})`,o);continue}if(t)if("run"in t&&(r()||e))if(r()||await g(t.prompt)){try{l=await t.run()}catch(e){m.logError(`postApplyPrompts.followUp.run(${n})`,e),i(`follow-up:${n}`,"fail",{error:e}),console.log(o.yellow(" ! "+t.hint));continue}for(const t of l)console.log("action"===t.kind?o.yellow(" ! "+t.text):o.green(" √ "+t.text))}else t.decline();else console.log(o.yellow(" ! "+t.hint))}}export async function postApplyPrompts(t,l={}){const i=new Set;for(const o of l.apps?c(t):[])try{const t=await f(o,{install:l.apps.install,quiet:!0,askBeforeUpgrade:!0});t.upgraded&&t.running&&i.add(o)}catch(t){m.logError(`postApplyPrompts.upgradeApp(${o})`,t)}for(const e of t){const t=await(s(e)?.prepareRuntime?.())??[];for(const e of t)console.log("action"===e.kind?o.yellow(" ! "+e.text):o.green(" √ "+e.text))}await runPendingElevations(t),await runFollowUps(t);const d=n(),y=r(),w=d||y?t.filter(o=>s(o)?.installSpec&&a.outdatedVersion(o)):[];if(w.length>0){const o=w.map(o=>s(o)?.displayName??o).join("、");if(y||await g(e.t("setup.offer_upgrade",{tools:o})))for(const o of w)await p(o)}await u(t.filter(o=>s(o)?.installSpec),new Set(w));for(const n of t){const t=s(n);if(i.has(n)||!t?.runningApp?.isRunning())continue;if(y||!d){console.log(o.yellow(" ! "+e.t("setup.reopen_hint",{tool:t.displayName})));continue}if(!await g(e.t("setup.offer_restart",{tool:t.displayName})))continue;const r=t.runningApp.restart();console.log(r?o.green(" √ "+e.t("setup.restarted",{tool:t.displayName})):o.yellow(" ! "+e.t("setup.restart_failed",{tool:t.displayName})))}}
@@ -349,6 +349,8 @@
349
349
  "done_commands": "Type {{commands}} in your terminal to start",
350
350
  "failed_summary": "{{count}} tool(s) not configured; see above",
351
351
  "offer_upgrade": "Upgrade {{tools}}? The installed version is too old.",
352
+ "offer_latest": "Upgrade {{tool}} ({{current}} → {{latest}})?",
353
+ "latest_declined": "Kept {{tool}} {{current}}; you won't be asked again for this version. To upgrade, run {{command}}",
352
354
  "offer_restart": "Restart {{tool}} so the new config takes effect? It is running and its windows will close.",
353
355
  "reopen_hint": "Reopen {{tool}} for the new config to take effect (it is running and was not restarted)",
354
356
  "restarted": "{{tool}} restarted",
@@ -349,6 +349,8 @@
349
349
  "done_commands": "在终端输入 {{commands}} 开始使用",
350
350
  "failed_summary": "{{count}} 个工具未完成配置,原因见上方",
351
351
  "offer_upgrade": "升级 {{tools}}?当前版本过旧。",
352
+ "offer_latest": "升级 {{tool}}({{current}} → {{latest}})?",
353
+ "latest_declined": "已保持 {{tool}} {{current}},这个版本不再询问;要升级运行 {{command}}",
352
354
  "offer_restart": "重启 {{tool}} 让新配置生效?它正在运行,当前窗口会被关闭。",
353
355
  "reopen_hint": "重新打开 {{tool}} 后生效(它正在运行,没有自动重启)",
354
356
  "restarted": "已重启 {{tool}}",
package/dist/models.json CHANGED
@@ -303,11 +303,6 @@
303
303
  "gemini-3.1-pro-preview"
304
304
  ]
305
305
  },
306
- "autoUpgrade": {
307
- "tools": ["claude-code", "codex", "grok"],
308
- "intervalHours": 24,
309
- "minAgeHours": 6
310
- },
311
306
  "toolMinVersions": {
312
307
  "codex": "0.122.0",
313
308
  "claude-code": "2.1.321",
package/models.json CHANGED
@@ -303,11 +303,6 @@
303
303
  "gemini-3.1-pro-preview"
304
304
  ]
305
305
  },
306
- "autoUpgrade": {
307
- "tools": ["claude-code", "codex", "grok"],
308
- "intervalHours": 24,
309
- "minAgeHours": 6
310
- },
311
306
  "toolMinVersions": {
312
307
  "codex": "0.122.0",
313
308
  "claude-code": "2.1.321",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vibeapi/api-helper",
3
- "version": "0.0.189",
3
+ "version": "0.0.190",
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",
@@ -1,29 +0,0 @@
1
- import { type ToolInstall, type ToolInstallSpec } from './tools/tool-installs.js';
2
- /**
3
- * Keeps the installed command-line tools (models.json → autoUpgrade.tools) up to date without the
4
- * customer running `vibecli upgrade` (用户 2026-11-22 定). A command starts a detached worker at
5
- * most once a day; the worker upgrades each installed tool that is behind the mirror's latest
6
- * release through `upgradeTool` (vendor updater, then our mirror). The command itself never waits.
7
- * Not installed tools stay uninstalled; desktop apps keep their own rules (app-update.ts).
8
- * A release younger than `minAgeHours` waits for a later round; on Windows a tool whose program
9
- * is running waits too (its .exe is locked and replacing it would break the open session).
10
- */
11
- /** First argument of the worker process. */
12
- export declare const AUTO_UPGRADE_WORKER_ARG = "__tool-auto-upgrade";
13
- export type AutoUpgradeOutcome = 'upgraded' | 'failed' | 'current' | 'not_installed' | 'too_new' | 'running' | 'offline' | 'unknown_version';
14
- export declare function shouldSkipToolAutoUpgrade(args: string[], env?: NodeJS.ProcessEnv): boolean;
15
- export declare function setAutoUpgradeSpawnerForTests(fn: ((env: NodeJS.ProcessEnv) => void) | null): void;
16
- /** Startup hook: starts the background worker when a round is due. Never fails or delays the command. */
17
- export declare function startToolAutoUpgrade(args: string[], options?: {
18
- env?: NodeJS.ProcessEnv;
19
- now?: number;
20
- }): boolean;
21
- export declare function setRunningCheckForTests(fn: ((spec: ToolInstallSpec, installs: ToolInstall[]) => boolean) | null): void;
22
- /** One round over the configured tools; returns what happened to each and when the next round is due. */
23
- export declare function runToolAutoUpgradeRound(options?: {
24
- env?: NodeJS.ProcessEnv;
25
- now?: () => number;
26
- }): Promise<{
27
- results: Record<string, AutoUpgradeOutcome>;
28
- nextAt: number;
29
- }>;
@@ -1 +0,0 @@
1
- import{spawn as o,spawnSync as t}from"child_process";import{readFileSync as e}from"fs";import{dirname as r,join as n}from"path";import{brandEnvName as s}from"./brand.js";import{isHelpRequest as i}from"./cli-help.js";import{installBlocker as l}from"./components.js";import{compareVersions as a,getAutoUpgradeRules as u}from"./model-registry.js";import{powerShellEnv as p}from"./powershell-env.js";import{resolveUpdateCachePath as c,isNpxExecution as f}from"./auto-update.js";import{track as d}from"./telemetry.js";import{upgradeTool as m}from"./tool-upgrade.js";import{atomicWriteFile as g}from"./tools/backup.js";import{getAdapter as h}from"./tools/registry.js";import{findInstalls as _,forgetInstalls as v,latestRelease as w}from"./tools/tool-installs.js";import{logger as A}from"../utils/logger.js";export const AUTO_UPGRADE_WORKER_ARG="__tool-auto-upgrade";const j=36e5,U=new Set(["upgrade","update","install","completion","logs","__tool-auto-upgrade"]),y=["--json","--dry-run","--help","-h","--version","-v"];function x(o){return n(r(c(o)),"tool-auto-upgrade.json")}function E(o,t,e){try{g(o,JSON.stringify({next_at:t,...e?{results:e}:{}})+"\n")}catch(o){A.logError("toolAutoUpgrade: state",o)}}export function shouldSkipToolAutoUpgrade(o,t=process.env){if("1"===t[s("DISABLE_TOOL_AUTO_UPGRADE")]||t.CI)return!0;if(y.some(t=>o.includes(t))||i(o))return!0;const e=o.find(o=>!o.startsWith("-"));return!(void 0===e||!U.has(e))||f(t)||null!==l(t)||0===u().tools.length}let S=t=>{const e=process.argv[1];if(!e)return;const r=o(process.execPath,[e,"__tool-auto-upgrade"],{detached:!0,stdio:"ignore",windowsHide:!0,env:t});r.on("error",o=>A.logError("toolAutoUpgrade: spawn",o)),r.unref()};export function setAutoUpgradeSpawnerForTests(o){S=o??(o=>{})}export function startToolAutoUpgrade(o,t={}){const r=t.env??process.env,n=t.now??Date.now();try{if(shouldSkipToolAutoUpgrade(o,r))return!1;const t=x(r);return!(n<function(o,t){try{const r=JSON.parse(e(o,"utf-8")).next_at;return"number"==typeof r&&r-t<=744*j?r:0}catch{return 0}}(t,n)||(E(t,n+u().intervalHours*j),S(r),0))}catch(o){return A.logError("toolAutoUpgrade: start",o),!1}}let T=(o,e)=>{if("win32"!==process.platform)return!1;const r=`${t("powershell.exe",["-NoProfile","-NonInteractive","-Command",`(Get-Process -Name '${o.command}' -ErrorAction SilentlyContinue) | ForEach-Object { if ($_.Path) { $_.Path } else { '?' } }`],{encoding:"utf-8",windowsHide:!0,timeout:2e4,env:p()}).stdout??""}`.split(/\r?\n/).map(o=>o.trim().toLowerCase()).filter(Boolean),n=new Set(e.map(o=>o.path.toLowerCase()));return r.some(o=>"?"===o||n.has(o))};export function setRunningCheckForTests(o){T=o??(()=>!1)}export async function runToolAutoUpgradeRound(o={}){const t=o.env??process.env,e=o.now??Date.now,r=u(),n={};let s=e()+r.intervalHours*j;const i=o=>{s=Math.min(s,o)};for(const o of r.tools){const t=h(o)?.installSpec;if(!t)continue;v();const s=_(t),l=s[0]?.version??null,u=s.length>0&&l?await w(t):null;let p;if(0===s.length)p="not_installed";else if(l)if(u)if(a(l,u.version)>=0)p="current";else if(e()-u.publishedAt<r.minAgeHours*j)p="too_new";else if(T(t,s))p="running";else{const r=e();d(`auto-upgrade:${o}`,"start",{detail:{from:l,to:u.version}});try{await m(o)}catch(t){A.logError(`toolAutoUpgrade(${o})`,t)}v();const n=_(t)[0]?.version??null;p=n&&a(n,l)>0?"upgraded":"failed",d(`auto-upgrade:${o}`,"upgraded"===p?"ok":"fail",{duration_ms:e()-r,detail:{from:l,to:u.version,after:n}})}else p="offline";else p="unknown_version";"offline"!==p&&"running"!==p||i(e()+72e5),"too_new"===p&&u&&i(u.publishedAt+r.minAgeHours*j),"upgraded"!==p&&"failed"!==p&&"not_installed"!==p&&"current"!==p&&d(`auto-upgrade:${o}`,"skip",{detail:{reason:p,from:l,latest:u?.version}}),n[o]=p}return E(x(t),s,n),{results:n,nextAt:s}}