@vibeapi/api-helper 0.0.139 → 0.0.140
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.
|
@@ -37,5 +37,11 @@ export declare function shouldSkipStartupUpdate(args: string[], env?: NodeJS.Pro
|
|
|
37
37
|
* npm-cli.js under the current directory (MODULE_NOT_FOUND, seen on Windows 11 with Node 24.11.1).
|
|
38
38
|
*/
|
|
39
39
|
export declare function windowsShellCommand(command: string, args: string[]): string;
|
|
40
|
+
/**
|
|
41
|
+
* Moves the package npm installed under `staging` into place of the running one and restores missing
|
|
42
|
+
* command shims (npm links them last, so an interrupted global install can leave the package without its
|
|
43
|
+
* command). Returns false when the staged copy isn't the expected version.
|
|
44
|
+
*/
|
|
45
|
+
export declare function swapStagedPackage(staging: string, prefix: string, packageRoot: string, packageName: string, version: string): boolean;
|
|
40
46
|
export declare function runStartupUpdate(args: string[], options?: StartupUpdateOptions): Promise<StartupUpdateResult>;
|
|
41
47
|
export {};
|
package/dist/lib/auto-update.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{chmodSync as e,
|
|
1
|
+
import{chmodSync as e,copyFileSync as t,existsSync as r,lstatSync as n,mkdirSync as o,readdirSync as s,readFileSync as a,readlinkSync as i,renameSync as l,rmSync as c,symlinkSync as u,writeFileSync as p}from"fs";import{homedir as d}from"os";import{basename as m,dirname as f,join as h,sep as _}from"path";import{spawnSync as g}from"child_process";import y from"chalk";import{checkForUpdate as x,readLocalPackage as v,UPDATE_SOURCES as k}from"../commands/update.js";import{i18n as w}from"./i18n.js";import{isColorEnabled as S}from"./runtime-options.js";import{logger as b}from"../utils/logger.js";import{isHelpRequest as $}from"./cli-help.js";import{brand as E,brandEnvName as P}from"./brand.js";export const INSTALL_RETRY_INTERVAL_MS=36e5;export const INSTALL_TIMEOUT_MS=45e3;function I(e,t){return S()?e(t):t}export function resolveUpdateCachePath(e=process.env){const t=e[P("CONFIG_DIR")]?.trim();if(t)return h(t,"update-state.json");const r=e[P("TEST_HOME")]?.trim();return h(r||d(),E().configDirName,"update-state.json")}export function isGlobalPackageInstall(e){return e.split(_).includes("node_modules")}export function isNpxExecution(e=process.env){return"exec"===e.npm_command||"npx"===e.npm_lifecycle_event}export function isPnpmGlobalInstall(e){return e.includes(`${_}.pnpm${_}`)||e.includes(`${_}pnpm${_}global${_}`)}export function resolveNpmGlobalPrefix(e){const t=`${_}node_modules${_}`,r=e.indexOf(t);if(r<0)return null;const n=e.slice(0,r);return n.endsWith(`${_}lib`)?f(n):n}export function shouldSkipStartupUpdate(e,t=process.env){return"1"===t[P("SKIP_AUTO_UPDATE")]||"1"===t[P("DISABLE_AUTO_UPDATE")]||(!(!["--json","--non-interactive","--dry-run","--help","-h","--version","-v"].some(t=>e.includes(t))&&!$(e))||e.includes("update")||e.includes("completion"))}function A(t,r,n,s,a){try{o(f(t),{recursive:!0,mode:448});const i=`${t}.tmp-${process.pid}`,c={package_name:r,checked_at:n,latest:s.latest,source:s.source,registry:s.registry,errors:s.errors,...void 0===a?{}:{install_attempted_at:a,install_attempted_version:s.latest||void 0}};p(i,JSON.stringify(c),{encoding:"utf-8",mode:384}),l(i,t),e(t,384)}catch(e){b.warn("Failed to persist update check cache:",e)}}export function windowsShellCommand(e,t){return[e,...t.map(e=>`"${e}"`)].join(" ")}const N=(e,t)=>{const r={stdio:"inherit",timeout:45e3,killSignal:"SIGTERM"};return"win32"===process.platform?g(windowsShellCommand(e,t),{...r,shell:!0}):g(e,t,r)},j=(e,t)=>g(process.execPath,[process.argv[1],...e],{stdio:"inherit",env:t}),T="-update-";function U(e,t){for(let r=0;;r++)try{return void l(e,t)}catch(e){const t=e.code;if(r>=9||"EPERM"!==t&&"EACCES"!==t&&"EBUSY"!==t)throw e;Atomics.wait(new Int32Array(new SharedArrayBuffer(4)),0,0,200)}}export function swapStagedPackage(e,s,l,p,d){const _=p.split("/"),g=[h(e,"node_modules",..._),h(e,"lib","node_modules",..._)].find(e=>r(h(e,"package.json")));if(!g)return!1;const y=JSON.parse(a(h(g,"package.json"),"utf-8"));if(y.version!==d)return!1;const x=h(f(l),`.${m(l)}${T}old-${process.pid}`);U(l,x);try{U(g,l)}catch(e){throw U(x,l),e}c(x,{recursive:!0,force:!0,maxRetries:3});const v="string"==typeof y.bin?[_[_.length-1]]:Object.keys(y.bin||{});for(const[r,a]of[[h(e,"bin"),h(s,"bin")],[e,s]])for(const e of v.flatMap(e=>["",".cmd",".ps1"].map(t=>e+t))){const s=h(r,e),l=h(a,e),c=n(s,{throwIfNoEntry:!1});if(!n(l,{throwIfNoEntry:!1})&&c&&!c.isDirectory())try{o(a,{recursive:!0}),c.isSymbolicLink()?u(i(s),l):t(s,l)}catch(e){b.warn("Failed to restore command shim:",e)}}return!0}export async function runStartupUpdate(e,t={}){const n=t.env||process.env,o=t.localPackage||v(),i=t.globalInstall??isGlobalPackageInstall(o.root),l=t.npx??isNpxExecution(n);if(!i||l||shouldSkipStartupUpdate(e,n))return{status:"skipped",handled:!1,source:null};const u=t.now??Date.now(),p=t.cachePath||resolveUpdateCachePath(n),d=function(e,t){try{if(!r(e))return null;const n=JSON.parse(a(e,"utf-8"));return n.package_name===t.name&&Number.isFinite(n.checked_at)?n:null}catch{return null}}(p,o);let g=function(e,t,r){if(!e||e.latest||r-e.checked_at>=6e5)return null;const n=Array.isArray(e.errors)?e.errors:[];return{current:t.version,latest:null,up_to_date:null,source:e.source,registry:e.registry,errors:n,error:n.map(e=>`${e.source}: ${e.error}`).join("; ")||"unknown"}}(d,o,u),S=null;if(g||(g=await x({localPackage:o,fetchFn:t.fetchFn}),g.latest&&d?.install_attempted_version===g.latest&&Number.isFinite(d.install_attempted_at)&&(S=d.install_attempted_at),A(p,o.name,u,g,S??void 0)),!g.latest)return{status:"unavailable",handled:!1,source:null};if(g.up_to_date)return{status:"current",handled:!1,source:g.source};if(null!==S&&u-S<36e5)return{status:"update_failed",handled:!1,source:g.source};const b=t.output||console.log,$=t.errorOutput||console.error,E=t.installRunner||N,U=isPnpmGlobalInstall(o.root),O=U?"win32"===process.platform?"pnpm.cmd":"pnpm":"win32"===process.platform?"npm.cmd":"npm",R=U?null:resolveNpmGlobalPrefix(o.root),D=o.root,C=R&&D.endsWith(_+o.name.split("/").join(_))?h(f(D),`.${m(D)}${T}${process.pid}`):null;C&&function(e,t){try{for(const r of s(e))r.startsWith(`.${t}${T}`)&&c(h(e,r),{recursive:!0,force:!0})}catch{}}(f(D),m(D)),A(p,o.name,u,g,u),b(I(y.cyan,w.t("update.auto_installing",{version:g.latest})));const G=[...g.registry?[g.registry]:[],...k.map(e=>e.registry).filter(e=>e!==g.registry)],F=Date.now();let L=null,M="unknown";for(const e of G){if(Date.now()-F>=45e3)break;const t=E(O,U?["add","--global",`${o.name}@${g.latest}`,"--registry",e]:["install","--global",...C?["--prefix",C]:R?["--prefix",R]:[],`${o.name}@${g.latest}`,"--registry",e,"--no-audit","--no-fund","--fetch-timeout=15000","--fetch-retries=1","--fetch-retry-mintimeout=1000","--fetch-retry-maxtimeout=3000"]);if(0===t.status){if(!C){L=e;break}try{if(!swapStagedPackage(C,R,D,o.name,g.latest)){M="staged install incomplete";continue}L=e;break}catch(e){M=e instanceof Error?e.message:String(e);break}finally{c(C,{recursive:!0,force:!0,maxRetries:3})}}else M=t.error?.message||`exit ${t.status??"unknown"}`,C&&c(C,{recursive:!0,force:!0,maxRetries:3})}if(!L)return $(I(y.yellow,w.t("update.auto_failed",{error:M}))),{status:"update_failed",handled:!1,source:g.source};b(I(y.green,w.t("update.auto_installed",{version:g.latest})));const B=(t.reexecRunner||j)(e,{...n,[P("SKIP_AUTO_UPDATE")]:"1"});return B.error?($(I(y.yellow,w.t("update.reexec_failed",{error:B.error.message}))),{status:"update_failed",handled:!1,source:g.source}):(process.exitCode=B.status??1,{status:"reexecuted",handled:!0,source:g.source})}
|
package/dist/locales/en_US.json
CHANGED
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
"available": "A new version is available",
|
|
304
304
|
"fetch_failed": "Couldn't fetch the latest version: {{error}}",
|
|
305
305
|
"command_hint": "Run: {{command}}",
|
|
306
|
-
"auto_installing": "Updating {{product}} to {{version}}…",
|
|
306
|
+
"auto_installing": "Updating {{product}} to {{version}}… (Ctrl+C cancels; the installed version stays as it is)",
|
|
307
307
|
"auto_installed": "Updated {{product}} to {{version}}; rerunning the current command…",
|
|
308
308
|
"auto_failed": "Couldn't update automatically ({{error}}); continuing with the installed version",
|
|
309
309
|
"reexec_failed": "Updated, but couldn't restart ({{error}}); continuing with the current process"
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
"available": "有新版本可用",
|
|
304
304
|
"fetch_failed": "无法获取最新版本:{{error}}",
|
|
305
305
|
"command_hint": "升级命令:{{command}}",
|
|
306
|
-
"auto_installing": "正在自动升级 {{product}} 到 {{version}}
|
|
306
|
+
"auto_installing": "正在自动升级 {{product}} 到 {{version}}…(按 Ctrl+C 可取消,当前版本不受影响)",
|
|
307
307
|
"auto_installed": "已将 {{product}} 升级到 {{version}},正在重新运行当前命令…",
|
|
308
308
|
"auto_failed": "无法自动升级({{error}}),继续使用当前版本",
|
|
309
309
|
"reexec_failed": "已升级,但无法重新启动({{error}}),继续使用当前进程"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeapi/api-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.140",
|
|
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",
|