@vibeapi/api-helper 0.0.133 → 0.0.135
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/brand.json +1 -1
- package/dist/commands/update.js +1 -1
- package/dist/locales/zh_CN.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -23,13 +23,13 @@ npm install -g @vibeapi/cli
|
|
|
23
23
|
|
|
24
24
|
`@vibeapi/cli` 与 `@vibeapi/api-helper` 是同一个程序的两个包名,同版本内容相同,安装哪个都可以。
|
|
25
25
|
|
|
26
|
-
npmjs.com
|
|
26
|
+
npmjs.com 无法访问时,从高速下载站启动:
|
|
27
27
|
|
|
28
28
|
```bash
|
|
29
29
|
npx --yes --registry https://npm.cnb.cool/vibeapi/npm/-/packages/ @vibeapi/cli@latest
|
|
30
30
|
```
|
|
31
31
|
|
|
32
|
-
全局安装的 `vibecli` 每次启动先检查更新(结果缓存 6 小时),按
|
|
32
|
+
全局安装的 `vibecli` 每次启动先检查更新(结果缓存 6 小时),按 **高速下载站 → npmjs → npmmirror → Yarn registry** 的顺序查询和安装;有新版时自动升级,再重新执行当前命令。网络或权限出错时照常执行原命令:每个安装源最多等 45 秒,安装失败后 1 小时内不再重试。设置 `VIBECLI_DISABLE_AUTO_UPDATE=1` 可关闭启动时的更新。`npx @vibeapi/cli@latest` 由 npm 在 VibeCLI 启动前下载,所以第一次就下载失败时,请改用上面的高速下载站命令。
|
|
33
33
|
|
|
34
34
|
### 还没有安装编码工具
|
|
35
35
|
|
|
@@ -191,7 +191,7 @@ vibecli base default
|
|
|
191
191
|
|
|
192
192
|
## 支持
|
|
193
193
|
|
|
194
|
-
主页 <https://www.vibeapi.cn/> · 反馈 <https://www.vibeapi.cn/support> · [
|
|
194
|
+
主页 <https://www.vibeapi.cn/> · 反馈 <https://www.vibeapi.cn/support> · [高速下载站](https://cnb.cool/vibeapi/npm/-/registries/@vibeapi/cli)
|
|
195
195
|
|
|
196
196
|
## 许可证
|
|
197
197
|
|
package/dist/brand.json
CHANGED
package/dist/commands/update.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import e from"chalk";import{readFileSync as t}from"fs";import{join as r,dirname as o}from"path";import{fileURLToPath as n}from"url";import{i18n as a}from"../lib/i18n.js";import{isJsonMode as s,emitJson as i,isColorEnabled as c}from"../lib/runtime-options.js";import{brand as l}from"../lib/brand.js";const u=l().packageName;export const UPDATE_TIMEOUT_MS=1500;const p=e=>{const t=e["dist-tags"];if(!t||"object"!=typeof t)return null;const r=t.latest;return"string"==typeof r?r:null};export const UPDATE_SOURCES=l().updateRegistries.map(({id:e,url:t})=>({id:e,registry:t,metadataUrl:e=>((e,t,r="")=>`${e}${encodeURIComponent(t)}${r}`)(t,e),readVersion:p}));function m(e){return c()?e:e=>e}export function readLocalPackage(){const e=n(import.meta.url),a=o(e),s=r(a,"..","..");try{const e=JSON.parse(t(r(s,"package.json"),"utf-8"));return{name:e.name||u,version:e.version||"0.0.0",root:s}}catch{return{name:u,version:"0.0.0",root:s}}}function g(e){const[t,...r]=e.split("-"),o=r.length?r.join("-").split("."):[];return{main:t.split(".").map(e=>Number.parseInt(e,10)||0),pre:o}}function f(e,t){const r=Number.parseInt(e,10),o=Number.parseInt(t,10),n=Number.isFinite(r)&&String(r)===e,a=Number.isFinite(o)&&String(o)===t;return n&&a?r-o:n?-1:a?1:e<t?-1:e>t?1:0}export function compareSemver(e,t){const r=g(e),o=g(t),n=Math.max(r.main.length,o.main.length);for(let e=0;e<n;e+=1){const t=(r.main[e]||0)-(o.main[e]||0);if(0!==t)return t}if(0===r.pre.length&&0===o.pre.length)return 0;if(0===r.pre.length)return 1;if(0===o.pre.length)return-1;const a=Math.max(r.pre.length,o.pre.length);for(let e=0;e<a;e+=1){const t=r.pre[e],n=o.pre[e];if(void 0===t)return-1;if(void 0===n)return 1;const a=f(t,n);if(0!==a)return a}return 0}async function d(e,t,r,o){const n=new AbortController,a=setTimeout(()=>n.abort(),o);try{const o=await r(e.metadataUrl(t),{headers:{Accept:"application/json"},signal:n.signal});if(!o.ok)throw new Error(`HTTP ${o.status}`);const a=await o.json(),s=e.readVersion(a);if(!s)throw new Error("invalid registry metadata");return s}catch(e){if(n.signal.aborted)throw new Error(`timeout after ${o}ms`);throw e}finally{clearTimeout(a)}}export async function checkForUpdate(e={}){const t=e.localPackage||readLocalPackage(),r=e.localVersion||t.version,o=e.packageName||t.name,n=e.fetchFn||fetch,a=e.timeoutMs||1500,s=e.sources||UPDATE_SOURCES,i=[];for(const e of s)try{const t=await d(e,o,n,a);return{current:r,latest:t,up_to_date:compareSemver(r,t)>=0,source:e.id,registry:e.registry,errors:i,error:null}}catch(t){i.push({source:e.id,error:t instanceof Error?t.message:String(t)})}return{current:r,latest:null,up_to_date:null,source:null,registry:null,errors:i,error:i.map(e=>`${e.source}: ${e.error}`).join("; ")||"unknown"}}export async function updateCommand(t={}){const r=t.localPackage||readLocalPackage();s()||console.log(m(e.gray)(a.t("update.checking")));const o=await checkForUpdate({...t,localPackage:r});if(s())i(o);else if(console.log(` ${m(e.cyan)(a.t("update.current",{version:o.current}))}`),o.latest)if(console.log(` ${m(e.cyan)(a.t("update.latest",{version:o.latest}))}`),console.log(` ${m(e.cyan)(a.t("update.source",{source:o.source
|
|
1
|
+
import e from"chalk";import{readFileSync as t}from"fs";import{join as r,dirname as o}from"path";import{fileURLToPath as n}from"url";import{i18n as a}from"../lib/i18n.js";import{isJsonMode as s,emitJson as i,isColorEnabled as c}from"../lib/runtime-options.js";import{brand as l}from"../lib/brand.js";const u=l().packageName;export const UPDATE_TIMEOUT_MS=1500;const p=e=>{const t=e["dist-tags"];if(!t||"object"!=typeof t)return null;const r=t.latest;return"string"==typeof r?r:null};export const UPDATE_SOURCES=l().updateRegistries.map(({id:e,url:t})=>({id:e,registry:t,metadataUrl:e=>((e,t,r="")=>`${e}${encodeURIComponent(t)}${r}`)(t,e),readVersion:p}));function m(e){return c()?e:e=>e}export function readLocalPackage(){const e=n(import.meta.url),a=o(e),s=r(a,"..","..");try{const e=JSON.parse(t(r(s,"package.json"),"utf-8"));return{name:e.name||u,version:e.version||"0.0.0",root:s}}catch{return{name:u,version:"0.0.0",root:s}}}function g(e){const[t,...r]=e.split("-"),o=r.length?r.join("-").split("."):[];return{main:t.split(".").map(e=>Number.parseInt(e,10)||0),pre:o}}function f(e,t){const r=Number.parseInt(e,10),o=Number.parseInt(t,10),n=Number.isFinite(r)&&String(r)===e,a=Number.isFinite(o)&&String(o)===t;return n&&a?r-o:n?-1:a?1:e<t?-1:e>t?1:0}export function compareSemver(e,t){const r=g(e),o=g(t),n=Math.max(r.main.length,o.main.length);for(let e=0;e<n;e+=1){const t=(r.main[e]||0)-(o.main[e]||0);if(0!==t)return t}if(0===r.pre.length&&0===o.pre.length)return 0;if(0===r.pre.length)return 1;if(0===o.pre.length)return-1;const a=Math.max(r.pre.length,o.pre.length);for(let e=0;e<a;e+=1){const t=r.pre[e],n=o.pre[e];if(void 0===t)return-1;if(void 0===n)return 1;const a=f(t,n);if(0!==a)return a}return 0}async function d(e,t,r,o){const n=new AbortController,a=setTimeout(()=>n.abort(),o);try{const o=await r(e.metadataUrl(t),{headers:{Accept:"application/json"},signal:n.signal});if(!o.ok)throw new Error(`HTTP ${o.status}`);const a=await o.json(),s=e.readVersion(a);if(!s)throw new Error("invalid registry metadata");return s}catch(e){if(n.signal.aborted)throw new Error(`timeout after ${o}ms`);throw e}finally{clearTimeout(a)}}export async function checkForUpdate(e={}){const t=e.localPackage||readLocalPackage(),r=e.localVersion||t.version,o=e.packageName||t.name,n=e.fetchFn||fetch,a=e.timeoutMs||1500,s=e.sources||UPDATE_SOURCES,i=[];for(const e of s)try{const t=await d(e,o,n,a);return{current:r,latest:t,up_to_date:compareSemver(r,t)>=0,source:e.id,registry:e.registry,errors:i,error:null}}catch(t){i.push({source:e.id,error:t instanceof Error?t.message:String(t)})}return{current:r,latest:null,up_to_date:null,source:null,registry:null,errors:i,error:i.map(e=>`${e.source}: ${e.error}`).join("; ")||"unknown"}}export async function updateCommand(t={}){const r=t.localPackage||readLocalPackage();s()||console.log(m(e.gray)(a.t("update.checking")));const o=await checkForUpdate({...t,localPackage:r});if(s())i(o);else if(console.log(` ${m(e.cyan)(a.t("update.current",{version:o.current}))}`),o.latest)if(console.log(` ${m(e.cyan)(a.t("update.latest",{version:o.latest}))}`),console.log(` ${m(e.cyan)(a.t("update.source",{source:l().updateRegistries.find(e=>e.id===o.source)?.label??o.source??"unknown"}))}`),o.up_to_date)console.log(" "+m(e.green)(a.t("update.up_to_date")));else{const t="npm"===o.source?"":` --registry ${o.registry}`,n=`npm install -g ${r.name}@latest${t}`;console.log(" "+m(e.yellow)(a.t("update.available"))),console.log(" "+m(e.gray)(a.t("update.command_hint",{command:n})))}else console.log(" "+m(e.yellow)(a.t("update.fetch_failed",{error:o.error||"unknown"})))}
|
package/dist/locales/zh_CN.json
CHANGED
|
@@ -874,7 +874,7 @@
|
|
|
874
874
|
},
|
|
875
875
|
"update": {
|
|
876
876
|
"summary": "检查 {{product}} 是否有新版本",
|
|
877
|
-
"description": "
|
|
877
|
+
"description": "依次查询这些来源:{{updateSources}}。有新版本时给出安装命令。\n全局安装的 {{product}} 启动时也会检查(每 6 小时一次),有新版本时自动安装并重新运行当前命令。",
|
|
878
878
|
"ex": {
|
|
879
879
|
"check": "检查新版本",
|
|
880
880
|
"json": "输出 JSON"
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vibeapi/api-helper",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.135",
|
|
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",
|